@sema-agent/core
Version:
Stateless, task-oriented AI agent core
42 lines (41 loc) • 2.46 kB
TypeScript
import { takeSeat } from "./swappable-deps.js";
import { type ActorAssertion } from "../internal/llm.js";
import type { TerminalFailureDetail } from "./terminal-cause.js";
import type { SessionStore } from "./session.js";
import type { RunnerDeps, TaskSpec } from "./types.js";
import type { RunInternals } from "./runner/contracts.js";
/**
* The answer: `{ ok: true }`, or the `failed` terminal the run would end on, in its own words: `code` (`TaskResult.terminal.code` —
* absent only when the thrown value carries none), `message` its sentence, `detail` its coded account.
*
* `ok: true` is NOT a promise that the run may go: it says only that this stretch of doors does not refuse the request on this Runner
* right now — do not keep it as a receipt that the request can run. The run can still be refused later, by its session, its execution
* environment, a connection, a store or its first request.
*/
export type TaskStartVerdict = {
readonly ok: true;
} | {
readonly ok: false;
readonly code?: string;
readonly message: string;
readonly detail?: TerminalFailureDetail;
};
/**
* The stream entry's synchronous reads of the caller's spec, in its order: the run's one read (`readCallerSpec`, taking the per-model
* auth seat against the catalog `liveCatalog` reads) and the attribution snapshot of `actor` (an `actor` that is not an object, or whose
* member read throws, throws here, at the call). `runTaskStream` and the task-start judge both take them through this one function.
*/
export declare function readEntrySpec(spec: TaskSpec, liveCatalog: Parameters<typeof takeSeat>[1]): {
readonly spec: TaskSpec;
readonly actor: ActorAssertion | undefined;
};
/**
* Would a run of `spec` (with `internals`, as `runTaskStream` would be handed them) be refused before its session is acquired? See the
* module note. A refusal the run would end on as a `failed` terminal is RETURNED; what the entry's spec reads throw synchronously at the
* call — a spec that is no object, the `actor` snapshot — is THROWN here the same way. Not asked: the entry's door on the internals bag
* (KL-4525-c: a retired member such as `onStatusEvent`, the `onLegFrame` seat, a bag that is no object), which the run throws at the call.
*/
export declare function taskStartVerdictOf(spec: TaskSpec, internals: RunInternals | undefined, seats: {
readonly deps: RunnerDeps;
readonly sessions: SessionStore;
}): TaskStartVerdict;