let subagentAnnounceDeps: SubagentAnnounceDeps = defaultSubagentAnnounceDeps;
let subagentRegistryRuntimePromise: Promise< typeofimport("./subagent-announce.registry.runtime.js")
> | null = null;
function loadSubagentRegistryRuntime() {
subagentRegistryRuntimePromise ??= import("./subagent-announce.registry.runtime.js"); return subagentRegistryRuntimePromise;
}
export { buildSubagentSystemPrompt } from "./subagent-system-prompt.js";
export { captureSubagentCompletionReply } from "./subagent-announce-output.js";
export type { SubagentRunOutcome } from "./subagent-announce-output.js";
export type SubagentAnnounceType = "subagent task" | "cron job";
function buildAnnounceReplyInstruction(params: {
requesterIsSubagent: boolean;
announceType: SubagentAnnounceType;
expectsCompletionMessage?: boolean;
}): string { if (params.requesterIsSubagent) { return `Convert this completion into a concise internal orchestration update for your parent agent in your own words. Keep this internal context private (don't mention system/log/stats/session details or announce type). If this result is duplicate or no update is needed, reply ONLY: ${SILENT_REPLY_TOKEN}.`;
} if (params.expectsCompletionMessage) { return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type).`;
} return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type), and do not copy the internal event text verbatim. Reply ONLY: ${SILENT_REPLY_TOKEN} if this exact result was already delivered to the user in this same turn.`;
}
function buildAnnounceSteerMessage(events: AgentInternalEvent[]): string { return (
formatAgentInternalEventsForPrompt(events) || "A background task finished. Process the completion update now."
);
}
function buildDescendantWakeMessage(params: { findings: string; taskLabel: string }): string { return [ "[Subagent Context] Your prior run ended while waiting for descendant subagent completions.", "[Subagent Context] All pending descendants for that run have now settled.", "[Subagent Context] Continue your workflow using these results. Spawn more subagents if needed, otherwise send your final answer.", "",
`Task: ${params.taskLabel}`, "",
params.findings,
].join("\n");
}
const WAKE_RUN_SUFFIX = ":wake";
function stripWakeRunSuffixes(runId: string): string {
let next = runId.trim(); while (next.endsWith(WAKE_RUN_SUFFIX)) {
next = next.slice(0, -WAKE_RUN_SUFFIX.length);
} return next || runId.trim();
}
function isWakeContinuationRun(runId: string): boolean { const trimmed = runId.trim(); if (!trimmed) { returnfalse;
} return stripWakeRunSuffixes(trimmed) !== trimmed;
}
function stripAndClassifyReply(text: string): string | null {
let result = text;
let didStrip = false; const hasLeadingSilentToken = startsWithSilentToken(result, SILENT_REPLY_TOKEN); if (hasLeadingSilentToken) {
result = stripLeadingSilentToken(result, SILENT_REPLY_TOKEN);
didStrip = true;
} if (hasLeadingSilentToken || result.toLowerCase().includes(SILENT_REPLY_TOKEN.toLowerCase())) {
result = stripSilentToken(result, SILENT_REPLY_TOKEN);
didStrip = true;
} if (
didStrip &&
(!result.trim() || isSilentReplyText(result, SILENT_REPLY_TOKEN) || isAnnounceSkip(result))
) { returnnull;
} return result;
}
// A worker can finish just after the first wait request timed out. // If we already have real completion content, do one cached recheck so // the final completion event prefers the authoritative terminal state. // This is best-effort; if the recheck fails, keep the known timeout // outcome instead of dropping the announcement entirely. if (outcome?.status === "timeout" && reply?.trim() && params.waitForCompletion !== false) { try { const rechecked = await waitForSubagentRunOutcome(params.childRunId, 0); const applied = applySubagentWaitOutcome({
wait: rechecked,
outcome,
startedAt: params.startedAt,
endedAt: params.endedAt,
});
outcome = applied.outcome;
params.startedAt = applied.startedAt;
params.endedAt = applied.endedAt;
} catch { // Best-effort recheck; keep the existing timeout outcome on failure.
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.55Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.