import { Task } from "../../models/task.cjs"; import { TaskFailureReporter } from "../../types/telemetry.cjs"; import { TaskStore } from "../taskStore/index.cjs"; import { MAX_BRIEF_FILES } from "../../types/delegation.cjs"; import { DoomDelegationService, InlineAgent } from "@agimon-ai/doompi-core/delegation"; import { Context } from "@deepseek-ai/cordis"; //#region src/services/delegation/index.d.ts export declare const NOTIFY_CUSTOM_TYPE = "doom-task-notify"; export declare const BACKGROUND_WORK_PROVIDER = "doom-task"; export declare const ERR_NO_RUNTIME = "No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled."; export declare const ERR_CHILD_SESSION = "assign is only available in the main session. Update this task directly instead of re-delegating it."; export declare const ERR_CANCEL_UNACKNOWLEDGED = "Subagent did not acknowledge the cancel request"; /** Live progress from a running subagent. Kept in memory: persisting per-tool * ticks would rewrite the store file every second for no durable benefit. */ export interface DelegationProgress { agent: string; currentTool?: string; toolCount?: number; tokens?: number; /** Latest child-runtime duration baseline, excluding assignment wait. */ durationMs?: number; /** Wall-clock time at which durationMs was observed or rebased. */ durationObservedAt?: number; /** Assign-time context-pack shape, carried so the completion event can be * grouped by it without joining back to the assignment event. */ contextFileCount?: number; contextNotesLength?: number; } export type DelegationNotifier = (message: { customType: string; content: string; display: boolean; }, options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn'; }) => void; export interface DelegationPlatform { readonly environment: Readonly>; readonly processId: number; readonly createRequestId: () => string; readonly formatBriefPath: (entry: string, cwd: string) => string; } export interface DelegationManagerOptions { store: TaskStore; cwd: string; platform: DelegationPlatform; notify?: DelegationNotifier; getSessionId?: () => string | undefined; onChange?: () => void; startedTimeoutMs?: number; /** How long a started run may go without reporting a result. */ runTimeoutMs?: number; /** How long to wait for a cancelled run to report back before forcing it. */ cancelTimeoutMs?: number; now?: () => string; nowMs?: () => number; /** Called when a completion notification could not be delivered. */ onNotifyError: (error: unknown, taskId: number) => void; /** Where other swallowed delegation failures go. */ report?: TaskFailureReporter; } export interface AssignOptions { agent?: string; inlineAgent?: InlineAgent; instructions?: string; /** Paths the parent already located, rendered into the brief so the child * skips rediscovering them. */ relevantFiles?: string[]; /** Facts the parent already established, rendered into the brief so the child * does not re-derive them. */ priorFindings?: string; model?: string; context?: 'fresh' | 'fork'; signal?: AbortSignal; } export interface DelegationOutcome { ok: boolean; message: string; } /** * Owns the lifecycle of tasks delegated to subagents. * * Delegation rides Team's injected Cordis service rather than spawning * processes directly, so doom-task stays decoupled from the subagent runtime * and degrades to a clear error when that service is not loaded. * * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so * a delegation always has a deadline no matter which phase it is in. Losing * that pairing is what previously left tasks running forever. */ export declare class DelegationManager { private readonly options; private readonly progress; private readonly pendingTasks; private readonly settlingRequests; private readonly timers; private readonly subscriptions; private service; constructor(options: DelegationManagerOptions); private now; private nowMs; private get runTimeoutMs(); private report; /** True in a session that is itself a subagent child. */ get isChildSession(): boolean; /** Live progress for a task, for the overlay to render. */ progressFor(task: Task): DelegationProgress | undefined; /** Displayed runtime duration, rebased from the latest child observation. */ static elapsedMs(progress: DelegationProgress, nowMs?: number): number; /** Rebind to the active Team service without stacking lifecycle listeners. */ bind(ctx: Context, service: DoomDelegationService): () => void; /** Remove only the cross-package binding; task state and watchdogs remain live. */ unbind(): void; /** Items still in flight, surfaced so auto-stop will not kill the harness. */ listActiveWork(): Array<{ id: string; sessionId: string; }>; /** * Return tasks nothing can finish to `pending`. * * The live request set is read inside the mutation so a delegation assigned * while the lock was contended is not mistaken for a leftover. */ reconcile(isCurrent?: () => boolean): Promise; assign(taskId: number, options: AssignOptions): Promise; cancel(taskId: number): Promise; /** Settle without awaiting, reporting rather than dropping a failure. */ private settleDetached; /** * Fail a delegation that nobody acknowledged. * * Provider loss or a stalled Team runtime can still leave a dispatched * request silent. Without this acknowledgement deadline the task would sit * in `requested` forever. */ private armStartedTimeout; /** * Bound a run that already started. * * The request carries the same budget, so in the normal case the runtime ends * the run itself and reports a richer result. The grace period biases toward * that answer; this timer only covers a runtime that goes silent, which is * precisely the case where no response event will ever arrive. */ private armRunTimeout; /** * Guarantee a cancel reaches a terminal state. * * Calling the service is a request, not an outcome: a runtime that has * already forgotten the request answers nothing at all. The window still * favours a real response, which carries the run's partial output. */ private armCancelTimeout; private armTimer; private clearTimer; /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */ private handleAccepted; private handleStarted; private handleUpdate; private handleResponse; /** * Apply the terminal state of a delegation and tell the model about it. * * A cancelled run returns the task to `pending` (the work is still wanted, * just not by that agent); a failure marks it `failed` so it stays visible * rather than silently rejoining the backlog. * * The request is claimed in `settlingRequests` while it remains published as * active work. It is removed only after the terminal state and model notification * have been handed off, so an auto-stop observer cannot end the session between * receiving the result and delivering it to the model. */ private settle; private notifyModel; /** * Rewrite the task carrying `requestId`, returning the updated task as the mutation value. * * Terminal delegations are left alone. The document here is the freshest one, * read under the store lock, which is the only place the check is meaningful: * a `started` event can land after a cancel already settled the run, and * without this guard its write would resurrect a delegation that nothing is * tracking any more. */ private patchDelegation; dispose(): void; /** Clear one Pi session's transient delegation state without losing service injection. */ reset(): void; } //#endregion export { MAX_BRIEF_FILES }; //# sourceMappingURL=index.d.cts.map