export * from "@agimon-ai/doompi-core/delegation"; //#region src/schemas/team/delegation.d.ts /** * Subagent delegation - a cross-extension event protocol. * * Delegation lets another extension ask this runtime to run a subagent without * depending on its internals: the requester emits a request event and receives * started/update/response events back over the host event bus. * * Two generations coexist. V1 correlates purely by `requestId`. V2 adds * `ownerRunId` and `nodeId` so one owner can fan out to many nodes and have each * reply routed back, and it carries a typed `result` request. * * PROTOCOL COMPATIBILITY (do not change): * The event names and version numbers below are shared with doom-pi-subagents * and with doom-task and agiflow-pi-extension, which speak this protocol today. * The event names deliberately keep their `prompt-template:` prefix: that is the * established transport, and renaming it would silently stop delivery. Pinned by * contract tests. * * AVOID: * - Adding a required field to an existing version; add a version instead */ export declare const SUBAGENT_DELEGATION_PROTOCOL_VERSION: 1; export declare const SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION: 2; export declare const SUBAGENT_DELEGATION_REQUEST_EVENT = "prompt-template:subagent:request"; export declare const SUBAGENT_DELEGATION_STARTED_EVENT = "prompt-template:subagent:started"; export declare const SUBAGENT_DELEGATION_UPDATE_EVENT = "prompt-template:subagent:update"; export declare const SUBAGENT_DELEGATION_RESPONSE_EVENT = "prompt-template:subagent:response"; export declare const SUBAGENT_DELEGATION_CANCEL_EVENT = "prompt-template:subagent:cancel"; export interface SubagentDelegationTurnBudget { maxTurns: number; graceTurns?: number; } export interface SubagentDelegationToolBudget { soft?: number; hard: number; block?: string[] | '*'; } export interface SubagentDelegationAgentContract { version: 1; } export type SubagentDelegationJsonSchemaObject = Record; export interface SubagentDelegationExecutionResult { status: 'completed' | 'failed' | 'paused' | 'stopped' | 'detached'; success: boolean; exitCode: number; error?: string; interrupted?: boolean; timedOut?: boolean; stopped?: boolean; detached?: boolean; } export interface SubagentDelegationReviewResult { status: 'not-requested' | 'review-required' | 'reviewed' | 'blockers'; findings?: Array<{ severity: 'blocker' | 'non-blocking'; file?: string; issue: string; rationale: string; }>; } export interface SubagentDelegationEffectsResult { fileMutation?: { status: 'not-requested' | 'not-applicable' | 'observed' | 'missing'; expected: boolean; attempted: boolean; message?: string; }; } export type SubagentDelegationAcceptanceEvidence = 'changed-files' | 'tests-added' | 'commands-run' | 'validation-output' | 'residual-risks' | 'no-staged-files' | 'diff-summary' | 'review-findings' | 'manual-notes'; export interface SubagentDelegationAcceptanceCriterion { id: string; must: string; evidence?: SubagentDelegationAcceptanceEvidence[]; severity?: 'required' | 'recommended'; } export interface SubagentDelegationAcceptanceVerifyCommand { id: string; command: string; timeoutMs?: number; cwd?: string; env?: Record; allowFailure?: boolean; } export interface SubagentDelegationAcceptanceReview { agent?: string; focus?: string; required?: boolean; } interface SubagentDelegationAcceptanceFields { criteria?: Array; evidence?: SubagentDelegationAcceptanceEvidence[]; verify?: SubagentDelegationAcceptanceVerifyCommand[]; review?: SubagentDelegationAcceptanceReview | false; stopRules?: string[]; } export type SubagentDelegationAcceptanceConfig = SubagentDelegationAcceptanceFields & ({ level: 'none'; reason: string; } | { level?: 'auto' | 'attested' | 'checked' | 'verified'; reason?: string; }); export type SubagentDelegationAcceptance = 'auto' | 'attested' | 'checked' | 'verified' | false | SubagentDelegationAcceptanceConfig; export interface SubagentDelegationRequest { version: typeof SUBAGENT_DELEGATION_PROTOCOL_VERSION; requestId: string; agent: string; task: string; context: 'fresh' | 'fork'; cwd: string; model?: string; timeoutMs?: number; turnBudget?: SubagentDelegationTurnBudget; toolBudget?: SubagentDelegationToolBudget; skill?: string | string[] | boolean; output?: string | boolean; outputMode?: 'inline' | 'file-only'; outputSchema?: SubagentDelegationJsonSchemaObject; agentContract?: SubagentDelegationAgentContract; acceptance?: SubagentDelegationAcceptance; artifacts?: boolean; /** Foreground remains the compatibility default. */ runMode?: 'foreground' | 'detached'; /** Optional task identity shown to active root-session teammates. */ teamTask?: { id: string; subject: string; }; } export interface SubagentDelegationStarted { version: typeof SUBAGENT_DELEGATION_PROTOCOL_VERSION; requestId: string; runId?: string; } export interface SubagentDelegationUpdate extends SubagentDelegationStarted { runId?: string; currentTool?: string; currentToolArgs?: string; recentOutput?: string; recentOutputLines?: string[]; recentTools?: Array<{ tool: string; args: string; }>; model?: string; toolCount?: number; durationMs?: number; tokens?: number; } export type SubagentDelegationStatus = 'completed' | 'failed' | 'timed_out' | 'cancelled' | 'interrupted' | 'turn_budget_exhausted' | 'tool_budget_exhausted' | 'structured_output_failed' | 'acceptance_failed' | 'invalid_request' | 'unavailable_context'; export type SubagentDelegationAcceptanceStatus = 'pending' | 'not-required' | 'claimed' | 'attested' | 'checked' | 'verified' | 'review-required' | 'reviewed' | 'accepted' | 'rejected'; export interface SubagentDelegationAcceptanceResult { status: SubagentDelegationAcceptanceStatus; evidenceStatus: Exclude; explicit: boolean; } export interface SubagentDelegationResponse extends SubagentDelegationStarted { status: SubagentDelegationStatus; error?: string; runId?: string; childIndex?: number; agent?: string; model?: string; exitCode?: number; execution?: SubagentDelegationExecutionResult; output?: string; outputPath?: string; sessionFile?: string; acceptance?: SubagentDelegationAcceptanceResult; review?: SubagentDelegationReviewResult; effects?: SubagentDelegationEffectsResult; turns?: number; toolCount?: number; durationMs?: number; tokens?: number; warnings?: string[]; } export interface SubagentDelegationCancel extends SubagentDelegationStarted {} export type SubagentDelegationV2Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'; export type SubagentDelegationV2ResultRequest = { kind: 'text'; } | { kind: 'structured'; schema: SubagentDelegationJsonSchemaObject; }; export interface SubagentDelegationV2Request { version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION; requestId: string; ownerRunId: string; nodeId: string; agent: string; task: string; context: 'fresh' | 'fork'; cwd: string; model?: string; thinking?: SubagentDelegationV2Thinking; timeoutMs?: number; turnBudget?: SubagentDelegationTurnBudget; toolBudget?: SubagentDelegationToolBudget; skill?: string | string[] | boolean; artifacts?: boolean; result: SubagentDelegationV2ResultRequest; } export interface SubagentDelegationV2Started { version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION; requestId: string; ownerRunId: string; nodeId: string; } export interface SubagentDelegationV2Update extends SubagentDelegationV2Started { runId?: string; currentTool?: string; currentToolArgs?: string; recentOutput?: string; recentOutputLines?: string[]; recentTools?: Array<{ tool: string; args: string; }>; model?: string; toolCount?: number; durationMs?: number; tokens?: number; } export type SubagentDelegationV2Status = SubagentDelegationStatus | 'duplicate_node'; export type SubagentDelegationV2Value = { kind: 'text'; text: string; } | { kind: 'structured'; value: unknown; }; export interface SubagentDelegationV2Usage { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number; turns: number; toolCalls: number; durationMs: number; } export interface SubagentDelegationV2TerminalResponse extends SubagentDelegationV2Started { status: Exclude; error?: string; runId?: string; agent?: string; model?: string; thinking?: string; exitCode?: number; launchContractDigest?: string; result?: SubagentDelegationV2Value; usage?: SubagentDelegationV2Usage; } /** A malformed V2 request can only be correlated by the valid identity fields it supplied. */ export interface SubagentDelegationV2InvalidResponse { version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION; requestId: string; ownerRunId?: string; nodeId?: string; status: 'invalid_request'; error?: string; } export type SubagentDelegationV2Response = SubagentDelegationV2TerminalResponse | SubagentDelegationV2InvalidResponse; export interface SubagentDelegationV2Cancel extends SubagentDelegationV2Started {} //#endregion //# sourceMappingURL=delegation.d.mts.map