@sema-agent/core
Version:
Stateless, task-oriented AI agent core
29 lines (28 loc) • 2.13 kB
TypeScript
import type { ExecutionEnv } from "../../internal/harness.js";
import type { EngineNotice } from "../engine-notice.js";
/** One declaration whose value is not the shape its seat takes, with the type it actually carries. */
export interface MalformedCapabilityDeclaration {
readonly key: string;
readonly valueType: string;
/** The shape the seat takes: a `capabilities.*` boolean (or the block itself, an object), an optional seam method, or
* nothing (`absent`: a member of the block that is no capability). */
readonly expected: "boolean" | "object" | "function" | "absent";
}
/**
* Every capability this env does not DECLARE as a boolean: each key of the block that is absent, not a boolean, or
* cannot be received — or the block itself, when it is present but not an object or cannot be received — and each
* member the block carries outside the nine keys (a misspelled key leaves the key it meant undeclared).
*
* The block is judged on its one receipt (`capabilityReceiptOf`), the frozen copy every reader reads. `undefined` is
* where absence lands — an absent key and an explicit `undefined` are the same word to every reader — and both are
* announced, as a wrong shape is. An env with no block at all is announced once per key: every reader takes every key's
* safe side, and the operator learns which.
*
* TOTAL by construction: a diagnostic may not be the thing that fails a run. Every read of the adapter can throw on a
* getter or a Proxy trap — the block acquisition, each key, each optional method — and a read that throws is itself a
* declaration nobody can use, so it is reported rather than raised (`unreadable`, under the key when there is one and
* under `capabilities` when the block itself could not be had).
*/
export declare function malformedCapabilityDeclarations(env: ExecutionEnv): MalformedCapabilityDeclaration[];
/** Announce each undeclared or malformed declaration once, to the operator who wired the adapter. */
export declare function announceMalformedCapabilities(env: ExecutionEnv, onNotice: ((notice: EngineNotice) => void) | undefined): void;