UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

21 lines (20 loc) • 1.77 kB
/** * The fan-out protocol a script runner is handed beside the primitives ({@link WorkflowFanOutPlaces}): how a runner whose domain * carries no host async context (an isolate, another process) reaches the ENGINE's fan-outs, so a call it makes in a slot is * placed where the same call is placed when the engine runs the fan-out. * * `open` starts the engine's own `parallel` / `pipeline` on the chain `at` names; every slot is a host function that keeps the * fan-out scope the engine started it in ({@link captureWorkflowFanOutScope}) and waits. `agent(at, …)` runs the run's agent * primitive with that scope restored — only that scope: every other async store the caller set stays as it is — and * `open(…, at)` starts a nested fan-out there. `join` lets every slot end at once (a call's place was fixed when it was made) * and answers the engine's fan-out, its join's refusal included; a slot's scope stays reachable after it, as a late call in * an engine slot keeps its slot. There is no second numbering: the places are the engine's. * * Tokens belong to the protocol that minted them; anything else, and every malformed argument, is refused * ({@link WorkflowScriptError}) before a fan-out starts or a call is made. */ import { type WorkflowRunContext } from "./workflow.js"; import type { WorkflowFanOutPlaces } from "./workflow-script-runner.js"; /** The fan-out protocol of one run. `agentBody` is the run's own agent primitive (its governance included). Built where the * script runs: the chain current then is the root chain an absent `at` names. */ export declare function fanOutPlaces(ctx: Pick<WorkflowRunContext, "parallel" | "pipeline">, agentBody: (spec: unknown, opts?: unknown) => Promise<unknown>): WorkflowFanOutPlaces;