UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

44 lines (43 loc) • 2.47 kB
/** * A WORKER'S ACTIONS DIGEST — what a delegated child did, counted over its whole event stream (every tool call that ended, not * the last-steps ring a resume prompt reads): calls by tool, the shell commands it ran with the exit codes the shell reported, and * the files it changed. The engine's own record, set beside the child's self-report on the faces a run with a member ledger reads * (the `<actions>` section of a completion notification, the ledger row): it says what was done, never whether it was right. * * Types, one sentence and one shape check — no imports, so every carrier (the step recorder, the notification codec, the ledger) * can read it without a cycle. */ /** One file the child changed, and how many times. */ export interface ActionsDigestFile { readonly path: string; readonly edits: number; } /** See the module head. */ export interface SubagentActions { /** Every tool call that ended, all tools. */ readonly toolCalls: number; /** Calls by tool name, most first (ties by first use); at most {@link ACTIONS_TOOLS_CAP} names — `toolCalls` counts all. */ readonly byTool: ReadonlyArray<{ readonly tool: string; readonly calls: number; }>; /** Shell commands, in order, first line each (redacted and cut as every step field is); at most {@link ACTIONS_COMMANDS_CAP}. */ readonly commands: ReadonlyArray<{ readonly command: string; readonly exitCode?: number; }>; /** Commands past the listed ones — absent when every command is listed (never `0`). */ readonly commandsUnlisted?: number; /** Files changed; empty when none — the fact a self-report of edits is read against. */ readonly filesEdited: ReadonlyArray<ActionsDigestFile>; } /** How many shell commands a digest lists. */ export declare const ACTIONS_COMMANDS_CAP = 20; /** How many tool names a digest lists. */ export declare const ACTIONS_TOOLS_CAP = 16; /** The digest as the one engine line every face reads: `tool calls 9: Read 5, Bash 3, Grep 1 · commands: \`npm test\` (exit 0) · * files edited: none`. */ export declare function subagentActionsLine(a: SubagentActions): string; /** Does a value read as a {@link SubagentActions} — the check a frame that came from outside this process (a boxed frame) passes * before it is rendered. A key this build does not read is not judged. */ export declare function isSubagentActions(v: unknown): v is SubagentActions;