UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

27 lines (26 loc) • 1.81 kB
/** * design/159 S1 — the shared runner seam every store-contract kit in this directory uses, extracted * verbatim from the proven shape in `src/core/workflow-run-store-contract.ts` (the kit service * already consumes in production). vitest-free BY CONTRACT: the kits run under any harness — a * vitest binding passes `(name, fn) => { it(name, fn); }`, a bare script passes nothing and gets * the sequential default — so a third-party store implementor needs NO test framework to verify * their backend (shell/client-core run self-written runners). */ /** * Labels + schedules one contract case. May return a promise (collected and awaited by the kit's * final `Promise.all`) or register the case with a harness and return void (vitest `it`). * * ⚠️ Binding note (inherited from workflowRunStoreContract): cases are REGISTERED * eagerly — an async runner that starts work immediately will interleave cases. Every case builds * its own fresh store via `make()`, so interleaving is safe UNLESS your binding's stores share * state (e.g. SQL twins on one table); such bindings must serialize inside `runAssertion`. */ export type ContractAssertionRunner = (name: string, fn: () => Promise<void>) => void | Promise<void>; /** The no-harness default: run each case immediately in order, surfacing the first failure. */ export declare function defaultSequentialRunner(_name: string, fn: () => Promise<void>): Promise<void>; /** The eager-register + collect-promises loop shared by every kit (same semantics as the inline * original in workflow-run-store-contract.ts). Call `run` per case, then `await settle()`. */ export declare function beginContract(runAssertion?: ContractAssertionRunner): { run: (name: string, fn: () => Promise<void>) => void; settle: () => Promise<void>; };