import type { AgentInput } from '../types/agent/base.js'; import type { AgentManagerContract } from '../types/agent/manager.js'; import type { CreateTaskOptions, SiblingFailurePolicy, TaskHandle, TaskScheduler } from '../types/agent/scheduler.js'; import type { AgentTaskContext } from '../types/agent/task.js'; import type { TaskId } from '../types/ids/index.js'; import type { CancelCause } from '../types/session/cancel-cause.js'; import type { ChildSessionLifecycleEvent, SessionEventListener } from '../types/session/events.js'; import { type Logger } from '../utils/logger.js'; export declare class LocalTaskScheduler implements TaskScheduler { private agentManager; private taskContext; private listener; private trackedTaskIds; private parentInput?; private completionListeners; /** * The settled summary of each task, kept past the manager's eviction. * * Terminal tasks leave the manager 30 seconds after they finish, and * `listTasks` rebuilt itself by looking every tracked id back up — so a * task that finished a minute ago simply vanished from the tool whose * whole job is the end-of-turn check. A supervisor could not tell an * evicted task from one that never launched; both read as absence. * * Eviction is there to release the heavy state — messages, controllers, * spawn records — not the fact that the task ran. This is a handful of * fields per task, bounded by the number the gateway itself launched. */ private settledHandles; private siblingFailurePolicy; /** See {@link onTaskProgress}. */ private readonly progressListeners; private readonly childSessionListeners; /** * One non-blocking delivery chain per observer. * * Child streaming never awaits these promises, but a listener still sees * its own events in source order. Keeping the chains separate also means a * slow exporter cannot hold up a task-specific screen (or another task's * screen) that uses a different callback. */ private readonly observerDeliveries; /** Raw, unresolved — kept as the caller handed it so each of the two log * sites below resolves it independently via `resolveLogger`, rather than * this constructor baking in ONE `.child()` binding both would then share * (which would also change how many `component:` bindings this file has, * a different ratchet than the one this task moves). */ private readonly log?; constructor(agentManager: AgentManagerContract, taskContext: AgentTaskContext, listener?: SessionEventListener, parentInput?: Pick, options?: { siblingFailurePolicy?: SiblingFailurePolicy; log?: Logger; }); get budget(): import("../public-runtime.js").SessionTokenBudget; createTask(options: CreateTaskOptions): Promise; private deliverEvent; private drainObserver; private reportObserverFailure; /** * Decide what a failed child means for the ones still running. * * The primitive to stop them already existed — every child holds an * abort controller chained to the parent's, and `AgentManager.cancel` * uses it — but nothing connected a failure to it. So a supervisor that * fanned out five tasks and watched one die had no way to say the other * four were now pointless: they ran to completion spending budget on * work whose premise had gone. * * `'continue'` stays the default, and deliberately. Partial results are * usually worth having, and a policy that tore down healthy siblings on * any failure would make one flaky child able to waste four good ones. * The point is that the choice is now expressible, not that the answer * changed. */ private applySiblingPolicy; waitForTask(taskId: TaskId): Promise; continueTask(taskId: TaskId, message: string): Promise; cancelTask(taskId: TaskId, cause?: CancelCause): void; getTask(taskId: TaskId): TaskHandle | undefined; /** * Snapshots a task's terminal state so it survives eviction. * * Called when the task settles, while the manager still holds it. */ rememberSettled(taskId: TaskId): void; /** * Drop the oldest tasks once the ledger passes {@link GATEWAY_TASK_LEDGER_CAP}. * * A gateway constructed per turn is bounded by that turn and this never * fires. But `SupervisorAgentConfig.gateway` lets a host supply its own, * and a long-lived host reusing one accumulates an id and a settled handle * per task it ever launched, for the life of the process — the doc above * says "bounded by the number the gateway itself launched", which is true * and is not a bound when the gateway outlives the turn. * * Both collections are evicted **together and in insertion order**. Losing * a tracked id while keeping its handle, or the reverse, would make a task * that ran read as one that never launched — which is the exact defect the * settled-handle map was added to fix, reintroduced by its own cleanup. */ private forgetOldestBeyondCap; listTasks(): TaskHandle[]; /** * Every event a child emits, reduced to "this one is still alive". * * Deliberately just the id. A caller that wanted the event itself has * the turn listener; what an idle clock needs is the fact, and passing * the payload here would make this a second way to read a worker's * output — one nobody documented and nothing frames as untrusted. */ onTaskProgress(callback: (taskId: TaskId) => void): () => void; onTaskCompleted(callback: (handle: TaskHandle) => void): () => void; onChildSessionEvent(callback: (event: ChildSessionLifecycleEvent) => void): () => void; } //# sourceMappingURL=local.d.ts.map