@sema-agent/core
Version:
Stateless, task-oriented AI agent core
37 lines (36 loc) • 2.72 kB
TypeScript
import { type RunLedgerBook } from "../core/run-ledger.js";
import type { RunnerDeps, TaskSpec } from "../core/types.js";
import { type LegReceipt } from "../core/runner/leg-receipt.js";
import { type WorkflowCatalog } from "./workflow-catalog.js";
/** Whether a leg's prepare reads a team ({@link resolveLegTeam}): synchronous, so a leg that runs none is not awaited on. */
export declare function legReadsTeam(receipt: object | undefined): boolean;
/** The appended block of a team's leg — the duties, then the team's own prompt — once its prepare read the team; else `undefined`. */
export declare function teamAppendOf(receipt: object | undefined): string | undefined;
/** The parked row a resumed leg resumes, as far as a team's run reads it: its member ledger section. */
type ParkedRow = {
readonly state: {
readonly runLedger?: unknown;
};
};
/** Whether a leg is a team's run to make ({@link teamLeg}): its spec names a team, or the row it resumes (`row`; absent on a
* leg that resumes nothing) records one. */
export declare function legRunsTeam(spec: Pick<TaskSpec, "team">, row: ParkedRow | undefined): boolean;
/**
* The spec a leg runs on and the receipt its prepare judges: `spec` and `receipt` themselves when it runs no team ({@link legRunsTeam});
* otherwise the spec with the recipe's role, own hands and ledger seats and the same call's receipt with them (`receiptWith`), the team
* riding that receipt — or a refusal thrown. A spec whose own read was refused is handed back as it is: prepare's door refuses it as
* read. `row`: the parked row the leg resumes. A task's team is fixed by its first leg, which freezes it into the row's ledger section: a
* resumed leg runs the team the row records, and its spec names that team or none; a row that records no team is resumed naming none.
*/
export declare function teamLeg(spec: TaskSpec, receipt: LegReceipt, deps: Pick<RunnerDeps, "workflowCatalog">, row?: ParkedRow): {
readonly spec: TaskSpec;
readonly receivedPeers: LegReceipt;
};
/**
* The team of a leg whose receipt carries one ({@link teamLeg}), read in its prepare from `catalog` — the leg's catalog, the one its
* Workflow tool lists (absent: the deployment has none) — and named on its member ledger (`book`). Refused when the catalog lists no
* team of that name, cannot be read, or reads a file that hashes otherwise than the row the leg resumes recorded. Its caller asks
* {@link legReadsTeam} first, so a leg that runs no team is not awaited on.
*/
export declare function resolveLegTeam(receipt: object | undefined, catalog: (() => WorkflowCatalog | undefined), book: Pick<RunLedgerBook, "setTeam"> | undefined): Promise<void>;
export {};