import type { Delegate } from '../types/agent/delegate.js'; import type { CreateTaskOptions, TaskHandle, TaskScheduler } from '../types/agent/scheduler.js'; import type { TaskId } from '../types/ids/index.js'; import { type CancelCause } from '../types/session/cancel-cause.js'; import type { ChildSessionLifecycleEvent } from '../types/session/events.js'; /** * Presents a set of foreign delegates as a `TaskScheduler`. * * The two delegation tools, the completion inbox and the sibling-failure * policy all speak `TaskScheduler`, and none of them should have to learn * that a specialist moved out of process. So the seam is here rather than * in the tools: an id this knows about is dispatched to its `Delegate`, and * anything else falls through to the local scheduler untouched. * * **The mapping onto `TaskHandle` is the load-bearing part.** `taskSucceeded` * and `taskFailed` require the gateway state and the turn status to AGREE, * because locally they are two independent authorities and a check reading * only one of them has already shipped a failed worker as an answer. A * foreign delegate has only its own word, so both fields are written from * that one answer — which keeps every existing predicate correct without * inventing a second authority that would only ever agree with the first. */ export interface DelegatingTaskSchedulerConfig { /** * Where an id no delegate claims goes. * * Optional, and its absence is a real configuration: a host that * delegates ONLY to foreign peers has no local scheduler to fall back * to, and an unknown id there is a caller error rather than something to * pass along. */ readonly local?: TaskScheduler; readonly delegates: readonly Delegate[]; } /** Two delegates, or a delegate and nothing, claiming one id. */ export declare class DelegateIdCollisionError extends Error { readonly details: { id: string; }; constructor(details: { id: string; }); } /** A delegate whose declared capabilities do not match its methods. */ export declare class DelegateCapabilityMismatchError extends Error { readonly details: { id: string; capability: string; }; constructor(details: { id: string; capability: string; }); } /** An operation the delegate said it cannot do. */ export declare class DelegateCapabilityError extends Error { readonly details: { id: string; capability: string; }; constructor(details: { id: string; capability: string; }); } /** An agent id nothing can serve. */ export declare class NoDelegateError extends Error { readonly details: { agentId: string; }; constructor(details: { agentId: string; }); } export declare class DelegatingTaskScheduler implements TaskScheduler { private readonly config; private readonly byId; private readonly tasks; private readonly listeners; constructor(config: DelegatingTaskSchedulerConfig); /** The delegate serving this id, or `undefined` for the local path. */ delegateFor(agentId: string): Delegate | undefined; get budget(): import("../public-runtime.js").SessionTokenBudget | undefined; createTask(options: CreateTaskOptions): Promise; private settle; waitForTask(taskId: TaskId): Promise; continueTask(taskId: TaskId, message: string): Promise; cancelTask(taskId: TaskId, cause?: CancelCause): void; getTask(taskId: TaskId): TaskHandle | undefined; listTasks(): TaskHandle[]; onTaskCompleted(callback: (handle: TaskHandle) => void): () => void; /** The local gateway's children; a foreign delegate's work has no child session here. */ onChildSessionEvent(callback: (event: ChildSessionLifecycleEvent) => void): () => void; } //# sourceMappingURL=delegating.d.ts.map