@sema-agent/core
Version:
Stateless, task-oriented AI agent core
42 lines (41 loc) • 2.46 kB
TypeScript
import type { ToolExecuteContext, ToolSpec } from "../core/types.js";
import type { SubagentToolOptions } from "./subagent.js";
/** What one leg's adoption of its yielded background agents came to: the rows it claimed and drove on, the ones it
* could not (each with why), and — when the row store could not be read at all — why (`unreadable`). */
export interface YieldedAgentAdoption {
readonly adopted: readonly string[];
readonly refused: ReadonlyArray<{
readonly id: string;
readonly why: string;
}>;
readonly unreadable?: string;
}
type Enrich = (ctx: ToolExecuteContext) => ToolExecuteContext;
/** Register a delegation tool node's adoption (the factory's own call, on the node it built; a node without a background
* lane has none). */
export declare function registerYieldAdoption(node: ToolSpec, bag: SubagentToolOptions["background"]): void;
/** What a leg's adoption step came to that its first request carries: the account of the workflow runs it continued (or
* why a person's decision for one was not used), the `workflow_continuation` frame's body. */
export interface LegAdoptionReport {
readonly workflowContinuation?: string;
}
/** The leg's one adoption step (`Prepared.legAdoption`), run at its run-body opening: its usage account is bound and its gate
* answers, its first request is not made. Two contributors, one place, one pass — the yielded background agents this leg
* owns ({@link adoptYieldedBackgroundWork}) and the finished workflow runs a person decided a card of (the Workflow tool's
* adopter, judged at this leg's gate). Never throws. */
export interface LegAdoption {
run(): Promise<LegAdoptionReport>;
}
/** The leg's adoption seat from its two contributors (prepare collects them; the run body runs the seat once). */
export declare function legAdoptionOf(contributors: {
readonly yielded: () => Promise<void>;
readonly workflowParks?: () => Promise<string | undefined>;
}): LegAdoption;
/** A leg's one adoption step, once it is sure to run: every delegation tool on its spec continues the yielded agents this
* leg owns (see {@link adoptYieldedAgents}); what could not be continued is said once on `onError`. Never throws. */
export declare function adoptYieldedBackgroundWork(tools: ReadonlyArray<{
readonly execute: unknown;
}>, enrich: Enrich, leg: {
readonly resumed: boolean;
}, onError: (e: Error) => void): Promise<void>;
export {};