fix: wire v2 setup flow — barrel import, registration, verification

- Import channel barrel from src/index.ts so channel skills that
  uncomment lines in src/channels/index.ts actually execute
- Rewrite setup/register.ts to create v2 entities (agent_groups,
  messaging_groups, messaging_group_agents) in data/v2.db instead
  of v1's store/messages.db
- Fix setup/verify.ts to check v2 central DB for registered groups
- Add prominent "MESSAGE DROPPED" warnings in router when no agent
  groups are wired, with actionable guidance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-09 12:23:23 +03:00
parent b76fd425c8
commit e7514edd35
6 changed files with 143 additions and 74 deletions

View File

@@ -20,6 +20,7 @@ export {
createMessagingGroupAgent,
getMessagingGroupAgents,
getMessagingGroupAgent,
getMessagingGroupAgentByPair,
updateMessagingGroupAgent,
deleteMessagingGroupAgent,
} from './messaging-groups.js';

View File

@@ -71,6 +71,15 @@ export function getMessagingGroupAgents(messagingGroupId: string): MessagingGrou
.all(messagingGroupId) as MessagingGroupAgent[];
}
export function getMessagingGroupAgentByPair(
messagingGroupId: string,
agentGroupId: string,
): MessagingGroupAgent | undefined {
return getDb()
.prepare('SELECT * FROM messaging_group_agents WHERE messaging_group_id = ? AND agent_group_id = ?')
.get(messagingGroupId, agentGroupId) as MessagingGroupAgent | undefined;
}
export function getMessagingGroupAgent(id: string): MessagingGroupAgent | undefined {
return getDb().prepare('SELECT * FROM messaging_group_agents WHERE id = ?').get(id) as
| MessagingGroupAgent

View File

@@ -19,8 +19,9 @@ import { writeSessionMessage } from './session-manager.js';
import { wakeContainer } from './container-runner.js';
import { log } from './log.js';
// Channel imports — each triggers self-registration
import './channels/discord.js';
// Channel barrel — each enabled channel self-registers on import.
// Channel skills uncomment lines in channels/index.ts to enable them.
import './channels/index.js';
import type { ChannelAdapter, ChannelSetup, ConversationConfig } from './channels/adapter.js';
import { initChannelAdapters, teardownChannelAdapters, getChannelAdapter } from './channels/channel-registry.js';

View File

@@ -58,8 +58,11 @@ export async function routeInbound(event: InboundEvent): Promise<void> {
// 2. Resolve agent group via messaging_group_agents
const agents = getMessagingGroupAgents(mg.id);
if (agents.length === 0) {
log.warn('No agent groups configured for messaging group', {
// This is a common fresh-install issue: channels work but no agent group
// is wired to handle messages. Run setup/register to create the wiring.
log.warn('MESSAGE DROPPED — no agent groups wired to this channel. Run setup register step to configure.', {
messagingGroupId: mg.id,
channelType: event.channelType,
platformId: event.platformId,
});
return;
@@ -68,7 +71,10 @@ export async function routeInbound(event: InboundEvent): Promise<void> {
// Pick the best matching agent (highest priority, trigger matching in future)
const match = pickAgent(agents, event);
if (!match) {
log.debug('No agent matched for message', { messagingGroupId: mg.id });
log.warn('MESSAGE DROPPED — no agent matched trigger rules', {
messagingGroupId: mg.id,
channelType: event.channelType,
});
return;
}