UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

64 lines (63 loc) • 3.73 kB
import type { SessionStore } from "./session.js"; import type { TerminalFailureDetail } from "./terminal-cause.js"; import type { RunnerDeps, TaskSpec } from "./types.js"; import type { RunInternals } from "./runner/contracts.js"; import { type InstructionsWithheldReason } from "./runner/nested-memory-lane.js"; import { type SessionReadFileStates } from "./runner/session-read-file-states.js"; /** Why an `outside_its_root` withheld file would still be refused by Read admission even after `externalIncludes` approval. */ export declare const EXTERNAL_INCLUDE_POST_APPROVAL_BLOCKS: readonly ["outside_roots", "rule_denied", "approval_required", "admission_unknown"]; export type ExternalIncludePostApprovalBlock = (typeof EXTERNAL_INCLUDE_POST_APPROVAL_BLOCKS)[number]; /** One instruction file loaded via an `@` include on a leg's first load. */ export interface InstructionIncludedEntry { /** Resolved canonical path of the included instruction file. */ readonly path: string; /** Resolved path of the file (or name of the host text) whose `@` include named this file. */ readonly includedBy: string; /** Path after `@` as the engine read it. */ readonly spelled: string; } /** One lane-discovered or host-text instruction file that was not loaded on a leg's first load. */ export interface InstructionWithheldEntry { /** Path the lane probed (or first skipped host text name for `too_many_texts`, or spelled include for `unanchored`). */ readonly path: string; /** Why the file was not loaded — the same closed set `instructions.withheld` notices carry. */ readonly reason: InstructionsWithheldReason; /** Resolved canonical target for `outside_its_root` when resolution named a key (pass this in `externalIncludes`). */ readonly target?: string; /** Resolved path of the file (or name of the host text) whose `@` include named this file. */ readonly includedBy?: string; /** Path after `@` as the engine read it; present with `includedBy`. */ readonly spelled?: string; /** Present on `outside_its_root` entries only when Read admission would still refuse the file after approval. */ readonly blockedAfterApproval?: ExternalIncludePostApprovalBlock; } /** The instruction files a leg starts with, shared identically by `WiringManifest.instructions` and `Runner.previewInstructions`. */ export interface WiringInstructions { readonly selected: readonly string[]; readonly additionalDirectories?: ReadonlyArray<{ readonly directory: string; readonly selected: readonly string[]; }>; /** Files loaded via `@` include; present iff non-empty. */ readonly included?: readonly InstructionIncludedEntry[]; /** Lane-discovered and host-text files withheld; present iff non-empty. */ readonly withheld?: readonly InstructionWithheldEntry[]; } /** Coded answer of `Runner.previewInstructions(spec)`: either the instruction manifest preview, or the run's coded refusal. */ export type InstructionPreviewResult = { readonly ok: true; readonly projectMemory: "on" | "disabled" | "absent"; readonly instructions?: WiringInstructions; } | { readonly ok: false; readonly code?: string; readonly message: string; readonly detail?: TerminalFailureDetail; }; export interface PreviewInstructionsSeats { readonly deps: RunnerDeps; readonly sessions: SessionStore; readonly readStates: SessionReadFileStates; } /** Read what instruction files a run of `spec` would load or withhold, through the lane's single first-load reading. */ export declare function previewInstructionsOf(seats: PreviewInstructionsSeats, spec: TaskSpec, internals?: RunInternals): Promise<InstructionPreviewResult>;