UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

52 lines (51 loc) • 3.18 kB
/** * The judged-read PORT of a caller tool's declared read ({@link import("../../core/tool-spec.js").ToolExecuteContext.judgedReads}): * the one way such a tool reads a target the model named. Each entry is a target the file read station judged for the call; `open` * is that judgment again, on the key the station judged, then the environment's bound open, then the judgment once more — and only * the held object leaves. An environment that cannot hold the object is a refusal: the target is never read by name instead. */ import type { ExecutionEnv } from "../../internal/harness-types.js"; import type { JudgedRead, JudgedReadsUnavailable } from "../../core/judged-read.js"; import type { ToolExecuteContext } from "../../core/tool-spec.js"; /** The closed set of {@link JudgedReadsUnavailable}, as a list (every word once). */ export declare const JUDGED_READS_UNAVAILABLE: readonly JudgedReadsUnavailable[]; /** The port seat of one leg: the station's ports per call, or none when the leg mounts no file read station; and the wire names of * the tools the leg mounted with the port (`ported`, written where they are mounted). */ export type JudgedReadsSeat = { current?: ((toolCallId: string) => readonly JudgedRead[] | undefined) | null; ported?: Set<string>; }; /** * `ctx` with the port of a tool that declares a read target: a fresh object with `ctx`'s own property descriptors (its getters stay * getters) and `judgedReads`, read when the tool reads it — the station's judgment of this call, or why there is none. */ export declare function withJudgedReads(ctx: ToolExecuteContext, seat: JudgedReadsSeat): ToolExecuteContext; import type { ContainmentFace } from "./containment-face.js"; import { type ReadDenyMatcher } from "./read-deny.js"; /** One element of a call's declared read as the station recorded it: its spelling, the base it resolves against, and the * canonical key the judgment landed on. */ export interface JudgedElement { readonly spelled: string; readonly base: string | undefined; readonly key: string; } /** What the station holds for one judged call: the call's name (the refusals say it), its elements in slot order, and the targets * outside the roots whose question the gate applied (an open may read them; nothing else outside the roots). */ export interface JudgedCall { readonly toolName: string; readonly elements: readonly JudgedElement[]; readonly admitted: Set<string>; } /** The judgment the port asks again: the station's own tables, read for the call. */ export interface JudgedReadTables { readonly env: ExecutionEnv; readonly rootCanonical: string; readonly roots: () => readonly string[]; readonly readDeny?: ReadDenyMatcher; readonly readFace?: ContainmentFace; readonly excluded?: (canonicalKey: string) => boolean; readonly exempt?: (canonicalKey: string) => boolean; readonly outsideRemedy?: string; } /** The port's entries for one judged call (`toolCallId`), in slot order. Never throws: every refusal is a result. */ export declare function judgedReadsOf(tables: JudgedReadTables, toolCallId: string, call: JudgedCall): readonly JudgedRead[];