UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

36 lines (35 loc) • 2.48 kB
import type { TaskRegistry } from "../core/task-registry.js"; import { type TaskNotificationPayload } from "../core/task-notification.js"; import type { SubagentRetainEntry } from "./retain-ledger.js"; /** The registry owner keys a child's own background work registers under: run-scoped work under the * child's task id, session-scoped work under its session id (the `sessionScoped ? sessionId : taskId` * owner read of the bash and monitor tools and of the sub-agent lanes). On a background lane the two * differ — the task id is the row id — so a reader of "the child's work" reads both; elsewhere they are * one key. */ export declare function childOwnerKeys(taskId: string, sessionId: string): readonly string[]; /** Running background tasks under any of `owners` (the gate's liveness read). */ export declare function runningBackgroundUnder(registry: TaskRegistry, owners: readonly string[]): number; /** * design/144 §1.2 — PARK a background child's `completed` notification behind its own still-running * background tasks (207 p0g: "the child finished, but work it launched is still running — the completion * news waits for the last of it"). Callers: the spawn settle resolve leg AND the resume settle resolve * leg (1.284 C1 — the gate applies to every stop cycle). The frame is the PARK-TIME SNAPSHOT (seq / * recentSteps / editedFiles composed by the caller before this call); delivery happens on the registry's * owner-quiescence hook (the LAST settling background task's poke), exactly once (registry one-shot set * + the `done` latch). The delivered frame's summary gets a decorative "(delivered after N …)" suffix — * DISPLAY ONLY, not contract (tests must never lock that wording). `entry.deferredNotify` is both the * resume-void hook (a wake cancels the watcher and drops the frame — see the SubagentRetainEntry ruling) * and the C2 eviction-flush hook (an entry leaving the ledger delivers the frame NOW, undecorated). */ export declare function parkCompletionNotify(deps: { registry: TaskRegistry; entry: SubagentRetainEntry; /** The child's owner keys in the registry ({@link childOwnerKeys}). */ owners: readonly string[]; /** Running background-task count at park time (rides the decorative delivery suffix). */ pendingCount: number; payload: TaskNotificationPayload; notify: (n: TaskNotificationPayload, opts?: { priority?: "now" | "next" | "later"; }) => void; }): void;