fix: only send onboarding message on first wiring, not re-registration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -169,8 +169,10 @@ export async function run(args: string[]): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Wire agent to messaging group
|
// 3. Wire agent to messaging group
|
||||||
|
let newlyWired = false;
|
||||||
const existing = getMessagingGroupAgentByPair(messagingGroup.id, agentGroup.id);
|
const existing = getMessagingGroupAgentByPair(messagingGroup.id, agentGroup.id);
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
|
newlyWired = true;
|
||||||
const mgaId = generateId('mga');
|
const mgaId = generateId('mga');
|
||||||
const triggerRules = parsed.trigger
|
const triggerRules = parsed.trigger
|
||||||
? JSON.stringify({
|
? JSON.stringify({
|
||||||
@@ -191,19 +193,21 @@ export async function run(args: string[]): Promise<void> {
|
|||||||
log.info('Wired agent to messaging group', { mgaId, agentGroup: agentGroup.id, messagingGroup: messagingGroup.id });
|
log.info('Wired agent to messaging group', { mgaId, agentGroup: agentGroup.id, messagingGroup: messagingGroup.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Send onboarding message — triggers the /welcome skill in the container
|
// 4. Send onboarding message — only on first wiring, not re-registration
|
||||||
const { session } = resolveSession(agentGroup.id, messagingGroup.id, null, parsed.sessionMode as 'shared' | 'per-thread' | 'agent-shared');
|
if (newlyWired) {
|
||||||
writeSessionMessage(agentGroup.id, session.id, {
|
const { session } = resolveSession(agentGroup.id, messagingGroup.id, null, parsed.sessionMode as 'shared' | 'per-thread' | 'agent-shared');
|
||||||
id: generateId('onboard'),
|
writeSessionMessage(agentGroup.id, session.id, {
|
||||||
kind: 'task',
|
id: generateId('onboard'),
|
||||||
timestamp: new Date().toISOString(),
|
kind: 'task',
|
||||||
platformId: parsed.platformId,
|
timestamp: new Date().toISOString(),
|
||||||
channelType: parsed.channel,
|
platformId: parsed.platformId,
|
||||||
content: JSON.stringify({
|
channelType: parsed.channel,
|
||||||
prompt: `A new ${parsed.channel} channel has been connected. Run /welcome to introduce yourself to the user.`,
|
content: JSON.stringify({
|
||||||
}),
|
prompt: `A new ${parsed.channel} channel has been connected. Run /welcome to introduce yourself to the user.`,
|
||||||
});
|
}),
|
||||||
log.info('Onboarding message written', { sessionId: session.id, channel: parsed.channel });
|
});
|
||||||
|
log.info('Onboarding message written', { sessionId: session.id, channel: parsed.channel });
|
||||||
|
}
|
||||||
|
|
||||||
// 5. Create group folders
|
// 5. Create group folders
|
||||||
fs.mkdirSync(path.join(projectRoot, 'groups', parsed.folder, 'logs'), { recursive: true });
|
fs.mkdirSync(path.join(projectRoot, 'groups', parsed.folder, 'logs'), { recursive: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user