import type { EventBus } from '../kernel/events.js'; import type { SubagentConfig } from '../types/multi-agent.js'; import type { Tool } from '../types/tool.js'; import type { Director } from './director.js'; /** * Opaque host interface so this factory doesn't have to depend on the * CLI's `MultiAgentHost`. Any caller that exposes the same methods * can wire `delegate` — including test doubles. * * Director Mode is permanently on, so `ensureDirector()` always succeeds. * The promotion fallback exists only for backward compatibility. */ export interface DelegateHost { /** True if a Director is already attached and running. */ isDirectorMode(): boolean; /** Build (or return the cached) Director. */ ensureDirector(): Promise; /** * Return the live Director. Since Director Mode is permanently on, * this always succeeds. Idempotent. */ promoteToDirector(): Promise; } export interface CreateDelegateToolOptions { host: DelegateHost; /** * Roster used to resolve `role` strings into full `SubagentConfig`s. * Typically `FLEET_ROSTER`. When omitted, `delegate({ role })` calls * fail and only the explicit `name + provider + model` path works. */ roster?: Record; /** * Default await timeout in milliseconds. `delegate` blocks until the * subagent's task resolves; without a cap, a stuck worker would hang * the host indefinitely. Set generously (default: 4 hours) so the * orchestrator can run multi-step refactors / monorepo audits * without being killed for being slow — the orchestrator must * decide per-call when a task needs to be cut short. */ defaultTimeoutMs?: number | undefined; /** * Absolute directory under which per-subagent JSONL transcripts live — * matches `MultiAgentHostOptions.sessionsRoot`. When set, the delegate * tool reads the subagent's transcript on timeout / budget-exhaustion * to extract partial output, so the host LLM gets *something* useful * back instead of just an error. */ sessionsRoot?: string | undefined; /** * The directorRunId used to namespace transcripts (typically the host * session id). Combined with `sessionsRoot` to locate per-subagent * JSONLs at `//.jsonl`. */ directorRunId?: string | undefined; /** * Buffer subtracted from the caller's `timeoutMs` before passing it * to the subagent. Gives the host a window to detect a subagent that * has gone silent and surface a partial result rather than a generic * timeout. Default: 60_000 ms (raised from 30s to give subagents * more headroom before the host kills them). */ subagentTimeoutBufferMs?: number | undefined; /** * Host EventBus. When supplied, `delegate` emits `delegate.started` * (before it blocks on the subagent) and `delegate.completed` (once the * subagent settles) so UIs / the Telegram bridge can render readable * start/finish lines instead of inferring them from the truncated * `tool.executed` JSON preview. Optional — emits are best-effort and a * missing bus never affects delegation behaviour. */ events?: EventBus | undefined; } /** * `delegate` — the compact multi-agent tool exposed after Director mode is * enabled. It bundles spawn + assign + await into a single call. * * The model never has to ask "are we in director mode?" — it just calls * `delegate({ role, task })` and gets back a `TaskResult`. The cost of * that ergonomic packaging is that `delegate` cannot be used for * parallel work as-is; the model must fire multiple `delegate` calls in * parallel through the provider's parallel-tool-call surface, or escalate * to the explicit `spawn_subagent` + `assign_task` + `await_tasks` flow * when it wants fan-out it controls itself. */ export declare function createDelegateTool(opts: CreateDelegateToolOptions): Tool; /** * Per-kind orchestrator hint. Returned alongside the structured error * so the calling model has a concrete next step instead of "task * failed, good luck". Returns undefined for success / unknown kinds — * the caller checks for presence before including in output. */ export declare function hintForKind(kind: string | undefined, retryable: boolean | undefined, backoffMs: number | undefined, partial?: { lastAssistantText?: string | undefined; } | undefined): string | undefined; //# sourceMappingURL=delegate-tool.d.ts.map