UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

30 lines (29 loc) • 1.63 kB
import type { ReasoningWireFacts } from "../../brain/reasoning.js"; import type { PushQueue } from "../push-queue.js"; import type { TaskEvent } from "../types.js"; import type { RunInternals, RunState } from "./contracts.js"; export interface RunBrainSinksInput { /** borrowed-mutable — the run's event queue: the `status` frames. */ queue: PushQueue<TaskEvent>; /** borrowed-readonly — the trusted run-scoped channel: `agentName` (the display name), `onStatusEvent` (the second sink). */ internals: RunInternals | undefined; /** borrowed-readonly — the run's mutable state, read for the telemetry frames' tracer and task id. */ rs: RunState; /** borrowed-readonly — the run's event-identity mint (stamped on every status frame). */ ident: () => { eventId: string; parentToolCallId?: string; sourceTaskId?: string; }; /** borrowed-readonly — the spawning tool call's id when this task runs AS A SUB-AGENT; absent on a top-level run. */ parentToolCallId: string | undefined; /** borrowed-readonly — the reasoning lane's wire-facts consumer, the third sink the composition installs. */ observeReasoningWireFacts: (facts: ReasoningWireFacts) => void; } export interface RunBrainSinksResult { /** The subagent's human display name for its `task_progress` ticks, or undefined. */ subagentName: string | undefined; /** Compose the three brain ALS sinks around a brain-driving call. */ withBrainSinks: <T>(fn: () => Promise<T>) => Promise<T>; } export declare function runBrainSinks(input: RunBrainSinksInput): RunBrainSinksResult;