UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

33 lines (32 loc) • 1.94 kB
/** * The `tool_end` output/structured projection, verbatim from * `runtask.ts`'s runLocked R4 phase. Pure functions over the harness `AgentToolResult`: zero closure * state, zero runtask coupling — the module-level inputs are the text cap below and the shared media budget default * (`mediaBudgetBytes`); the leg hands in its own `mediaByteCapBytes`. */ /** A block's own size in characters — the ONE counter `tool_end.totalChars` adds up over a tool result's blocks (a * consumer that re-renders a result sums the same function): a text block its text plus whatever else it carries at * its serialized length (the contract's text block carries nothing else), a media block its payload, any other block * its serialization. */ export declare const toolOutputBlockChars: (b: unknown) => number; type ToolOutput = { output: unknown; truncated: boolean; totalChars?: number; }; export declare const toolOutputFrom: (result: unknown, mediaByteCapBytes: number | undefined) => ToolOutput | undefined; /** The `tool_end.structured` projection over a harness tool result: the CC card when `details.type` names a card * the leg admits, else undefined. Minted per leg by {@link createStructuredProjector}; every body projection takes it * as a parameter — there is no module-level card set to fall back to. */ export type StructuredProjector = (result: unknown) => unknown; /** * L4's run-time half: a per-leg projector — the engine card set plus the leg's declared * caller cards — that DROPS an undeclared `details.type` and announces it ONCE per leg * (`config.tool_card_undeclared`, audience operator). With no options it is the engine set alone, unannounced — * the shape a caller outside a leg (a test, a fixture) uses. */ export declare function createStructuredProjector(opts?: { declaredCards?: Iterable<string>; onUndeclared?: (type: string) => void; }): StructuredProjector; export {};