feat(mcp): Push-Kanal beim Bridge-Start binden (agenthub mcp --agent <name>)
Bisher band die Bridge den Push-Kanal erst, wenn der Agent seinen Namen nannte (hello/work). Genau davor — direkt nach dem Session-Start — war er also weiterhin taub, und das ist der Zustand, den wir beheben wollen. Mit `--agent <name>` bindet die Bridge ab der ersten Sekunde. Codex- und Kimi-Konfiguration entsprechend gesetzt (args ["mcp","--agent",…]). Briefing umgeschrieben: Es sagte "du bist waehrend der Arbeit taub" — das stimmt nicht mehr. Jetzt: Push-Benachrichtigungen sind verbindlich, sofort darauf reagieren; der pending-Block im task_log-Ergebnis bleibt als zweiter Empfangsweg, Loggen bleibt Pflicht. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e8c2e43cb0
commit
dbaf29a6c6
@ -38,10 +38,16 @@ export function agentBriefing(agent: string, role: string): string {
|
|||||||
'2. Deine Aufgabe steht IMMER im Handoff des Tasks. Lies ihn, bevor du baust.',
|
'2. Deine Aufgabe steht IMMER im Handoff des Tasks. Lies ihn, bevor du baust.',
|
||||||
`3. Logge nach jedem Teilschritt: agenthub_task_log(id, text, agent="${agent}").`,
|
`3. Logge nach jedem Teilschritt: agenthub_task_log(id, text, agent="${agent}").`,
|
||||||
'',
|
'',
|
||||||
'WÄHREND DER ARBEIT BIST DU TAUB — das ist der wichtigste Punkt:',
|
'DU WIRST GEPUSHT — auch ohne laufenden Tool-Call:',
|
||||||
'Solange du einen Task ausführst, erreichen dich KEINE Events. Der einzige',
|
'Die AgentHub-Bridge schickt dir MCP-Benachrichtigungen, sobald etwas für',
|
||||||
'Draht nach außen ist die ANTWORT von agenthub_task_log. Deshalb ist Loggen',
|
'dich anliegt: neue oder zurückgegebene Task, Nachricht, beantwortete Frage,',
|
||||||
'keine Höflichkeit, sondern dein Empfang.',
|
'Abbruch. Diese Meldungen sind VERBINDLICH — reagiere sofort darauf, statt',
|
||||||
|
'zu warten. Steht dort ein Abbruch oder eine Rückgabe: aufhören, nicht',
|
||||||
|
'einreichen.',
|
||||||
|
'',
|
||||||
|
'ZUSÄTZLICH (Netz, kein Ersatz): die ANTWORT von agenthub_task_log trägt',
|
||||||
|
'einen `pending`-Block, wenn etwas offen ist. Loggen bleibt Pflicht — es ist',
|
||||||
|
'dein zweiter Empfangsweg und macht deinen Fortschritt sichtbar.',
|
||||||
'',
|
'',
|
||||||
' - Enthält die Antwort `pending.interrupted`, wurde dir der Task',
|
' - Enthält die Antwort `pending.interrupted`, wurde dir der Task',
|
||||||
' zurückgegeben, abgebrochen oder entzogen: SOFORT aufhören, NICHT',
|
' zurückgegeben, abgebrochen oder entzogen: SOFORT aufhören, NICHT',
|
||||||
|
|||||||
@ -838,12 +838,13 @@ export function createProgram(cwd: string): Command {
|
|||||||
.command('mcp [action]')
|
.command('mcp [action]')
|
||||||
.description('Start the MCP server (stdio). `agenthub mcp install` writes .mcp.json so MCP-aware agents auto-register.')
|
.description('Start the MCP server (stdio). `agenthub mcp install` writes .mcp.json so MCP-aware agents auto-register.')
|
||||||
.option('--print', 'Dry run: print the config instead of writing .mcp.json')
|
.option('--print', 'Dry run: print the config instead of writing .mcp.json')
|
||||||
.action(async (action: string | undefined, options: { print?: boolean }) => {
|
.option('--agent <name>', 'Bind the MCP push channel to this agent at startup (recommended: the bridge then pushes from the first second, without waiting for a tool call)')
|
||||||
|
.action(async (action: string | undefined, options: { print?: boolean; agent?: string }) => {
|
||||||
if (action === 'install') {
|
if (action === 'install') {
|
||||||
installMcp(cwd, { print: options.print });
|
installMcp(cwd, { print: options.print });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await startMcpServer(cwd);
|
await startMcpServer(cwd, { agent: options.agent });
|
||||||
});
|
});
|
||||||
|
|
||||||
// ─── hello (presence) ──────────────────────────────────────────────────────
|
// ─── hello (presence) ──────────────────────────────────────────────────────
|
||||||
|
|||||||
@ -198,7 +198,7 @@ export function waitForTask<T>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startMcpServer(cwd: string): Promise<void> {
|
export async function startMcpServer(cwd: string, options: { agent?: string } = {}): Promise<void> {
|
||||||
const { root, serverUrl } = await resolveMcpContext(cwd);
|
const { root, serverUrl } = await resolveMcpContext(cwd);
|
||||||
const remote = !!serverUrl;
|
const remote = !!serverUrl;
|
||||||
// `logging` MUSS deklariert werden: sendLoggingMessage prueft
|
// `logging` MUSS deklariert werden: sendLoggingMessage prueft
|
||||||
@ -213,6 +213,11 @@ export async function startMcpServer(cwd: string): Promise<void> {
|
|||||||
const bindPush = (agent?: string) => {
|
const bindPush = (agent?: string) => {
|
||||||
if (remote && agent) bindPushChannel(server, serverUrl!, agent);
|
if (remote && agent) bindPushChannel(server, serverUrl!, agent);
|
||||||
};
|
};
|
||||||
|
// Beim Start binden, wenn der Name bekannt ist (`agenthub mcp --agent codex`).
|
||||||
|
// Ohne das beginnt der Push erst mit dem ersten Tool-Aufruf — und genau in
|
||||||
|
// dem Fenster davor ist der Agent wieder taub, also fuer den Zustand, den
|
||||||
|
// wir beheben wollen.
|
||||||
|
bindPush(options.agent);
|
||||||
|
|
||||||
server.tool('agenthub_hello', 'Announce yourself to the hub (presence). Run once when you start.',
|
server.tool('agenthub_hello', 'Announce yourself to the hub (presence). Run once when you start.',
|
||||||
{ agent: z.string(), role: z.string().optional() },
|
{ agent: z.string(), role: z.string().optional() },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user