mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-12 18:11:51 +08:00
75c2fde2b5
Checkpoints the builder-agent dev-agent/worktree/swap flow (create_dev_agent, request_swap, classifier, deadman, promote) before pivoting to a unified draft-activate approach with OS-level RO enforcement. Lifts container_config out of the agent_groups row into groups/<folder>/container.json so install_packages, add_mcp_server, and rebuild flows can eventually route through the same draft path as source edits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
/**
|
|
* Seed the v2 central DB with a Discord agent group + messaging group.
|
|
*
|
|
* Usage: npx tsx scripts/seed-discord.ts
|
|
*/
|
|
import path from 'path';
|
|
|
|
import { DATA_DIR } from '../src/config.js';
|
|
import { initDb } from '../src/db/connection.js';
|
|
import { runMigrations } from '../src/db/migrations/index.js';
|
|
import { createAgentGroup, getAgentGroup } from '../src/db/agent-groups.js';
|
|
import {
|
|
createMessagingGroup,
|
|
createMessagingGroupAgent,
|
|
getMessagingGroup,
|
|
} from '../src/db/messaging-groups.js';
|
|
|
|
const db = initDb(path.join(DATA_DIR, 'v2.db'));
|
|
runMigrations(db);
|
|
|
|
const AGENT_GROUP_ID = 'ag-main';
|
|
const MESSAGING_GROUP_ID = 'mg-discord';
|
|
const CHANNEL_ID = 'discord:1470188214710046894:1491569326447132673';
|
|
|
|
// Agent group
|
|
if (!getAgentGroup(AGENT_GROUP_ID)) {
|
|
createAgentGroup({
|
|
id: AGENT_GROUP_ID,
|
|
name: 'Main',
|
|
folder: 'main',
|
|
agent_provider: 'claude',
|
|
created_at: new Date().toISOString(),
|
|
});
|
|
console.log('Created agent group:', AGENT_GROUP_ID);
|
|
} else {
|
|
console.log('Agent group already exists:', AGENT_GROUP_ID);
|
|
}
|
|
|
|
// Messaging group
|
|
if (!getMessagingGroup(MESSAGING_GROUP_ID)) {
|
|
createMessagingGroup({
|
|
id: MESSAGING_GROUP_ID,
|
|
channel_type: 'discord',
|
|
platform_id: CHANNEL_ID,
|
|
name: 'Discord Test',
|
|
is_group: 1,
|
|
unknown_sender_policy: 'strict',
|
|
created_at: new Date().toISOString(),
|
|
});
|
|
console.log('Created messaging group:', MESSAGING_GROUP_ID);
|
|
} else {
|
|
console.log('Messaging group already exists:', MESSAGING_GROUP_ID);
|
|
}
|
|
|
|
// Link
|
|
try {
|
|
createMessagingGroupAgent({
|
|
id: 'mga-discord',
|
|
messaging_group_id: MESSAGING_GROUP_ID,
|
|
agent_group_id: AGENT_GROUP_ID,
|
|
trigger_rules: null,
|
|
response_scope: 'all',
|
|
session_mode: 'shared',
|
|
priority: 0,
|
|
created_at: new Date().toISOString(),
|
|
});
|
|
console.log('Created messaging_group_agent link');
|
|
} catch (err: any) {
|
|
if (err.message?.includes('UNIQUE')) {
|
|
console.log('Messaging group agent link already exists');
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
console.log('Done! Run: npm run build && node dist/index.js');
|