UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

26 lines (25 loc) • 1.76 kB
import type { ToolResultStore } from "../tool-result-store.js"; import { type ContractAssertionRunner } from "./contract-harness.js"; /** * design/159 S1 — the cross-backend {@link ToolResultStore} contract, extracted VERBATIM from * `test/cross-backend-shared.ts` into a vitest-free kit (see `contract-harness.ts` for the runner * seam and `contract-kit-version.ts` for version lockstep). `make()` must return a FRESH, empty * store each call. * * Semantics since @sema-agent/core 2.1.0 (RB-266 + RB-273): ref safety is UNIFORM across backends — * the write face rejects the intersection-unsafe ref set on EVERY backend (`assertSafeToolResultRef` * is the shared floor) and a ref the contract accepts must round-trip on EVERY backend (a backend * with a narrower native key space owns an injective encoding, not a rejection). Before 2.1.0 the * bundled backends genuinely diverged on both halves (dev-green / deployment-red), so running this * kit against a pre-2.1.0-modeled backend is expected to go red on those two entries. * * Backlog #119 adds the provenance leg: `put`'s third argument and the `ownerOf` read face. `ownerOf` * is typed OPTIONAL on the interface (source compatibility for a backend written against an older * engine), but this kit REQUIRES it — a backend that cannot say who owns a ref cannot authorize a * host-side read face, and an optional parameter one store honors while another drops it silently is * exactly the divergence the two legs above exist to prevent. */ export declare function toolResultStoreContract(make: () => ToolResultStore, runAssertion?: ContractAssertionRunner, onOptionalMember?: (report: { member: "deleteBySession"; status: "verified" | "absent"; }) => void): Promise<void>;