UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

59 lines (58 loc) • 5.07 kB
import { type LockedPreflight } from "./locked-config.js"; import { type RosterFace } from "./runner/caller-roster.js"; import { type MountFactDeps, type MountFactSpec, type ToolMountFacts } from "./tool-mount-facts.js"; import { type ToolMountPlanExecutionEnv, type ToolMountIdentity, type ToolMountPlan } from "./tool-mount-plan.js"; import { type LegModSeats } from "./mods/host.js"; import { type ScreenedUserAttachment } from "./user-attachment.js"; import type { RunnerDeps, TaskSpec } from "./types.js"; import type { RunInternals } from "./runner/contracts.js"; /** The deps members the static reading reads. */ export type StaticToolPlanDeps = MountFactDeps & Pick<RunnerDeps, "checkpointStore" | "sessionStore" | "peerDirectory" | "mailboxStore" | "executionEnv" | "executionEnvFactory" | "runtimeCapsResolver" | "memoryBackend" | "toolResultThresholdChars" | "toolResultStore" | "toolModelGate" | "models" | "tiers" | "roles" | "onQuestion" | "lockedConfig" | "toolPolicy" | "basePolicyForResumeEdit" | "peerSeat" | "mods" | "writeProtectedPaths">; /** The spec members the static reading reads. */ export type StaticToolPlanSpec = MountFactSpec & Pick<TaskSpec, "tools" | "allowTools" | "excludeTools" | "excludeAllTools" | "deferTools" | "alwaysLoadTools" | "restoreGatedTools" | "permissionMode" | "shellGate" | "planFile" | "mcp" | "a2a" | "toolPolicy" | "basePolicyForResumeEdit" | "sessionId" | "memory" | "model" | "modelRole" | "roles" | "thinking" | "toolResultThresholdChars" | "checkpointStore" | "onQuestion" | "durableApproval" | "mods" | "skills" | "ownHandsReadOnly" | "workspace" | "userAttachments" | "restoreFiles" | "rewindFilesTo" | "writeProtectedAdditions">; /** What a host states about the session a static reading is made for: `session: "new"` — the submission mints its session, * so there is no checkout record, no resume and no delegating caller's placement. Absent ⇒ unknown: those needs stay open. */ export interface StaticWiringStatement { readonly session?: "new"; } /** What a leg's prepare hands {@link readLegExecutionEnv}, before its environment starts. */ export interface LegExecutionEnvInput { readonly deps: Pick<RunnerDeps, "writeProtectedPaths" | "memoryBackend">; readonly spec: Pick<TaskSpec, "workspace" | "planFile" | "restoreFiles" | "rewindFilesTo" | "writeProtectedAdditions" | "memory"> & { readonly tools?: readonly RosterFace[]; }; /** The leg's facts its environment does not decide (its own word, the deployment's seats, its shape), stated once — * the same record the leg's roster ledger is handed beside the environment's facts. */ readonly facts: ToolMountFacts; /** The leg's valve (its one reading) and the protocol peers it leaves. */ readonly leaves: (identity: ToolMountIdentity) => boolean; readonly leavesPeer: (prefix: string) => boolean; readonly preflight: LockedPreflight; readonly userAttachments: readonly ScreenedUserAttachment[] | undefined; /** The leg's registrations, listed once — the list its admission takes. */ readonly mods: LegModSeats; /** Whether the session's checkout record makes the leg work in its tree (`checkoutRecordNeedsEnv`), on a leg that declares * no workspace; `undefined` on a declaring leg (its record is read after its leaf) or an unreadable record. */ readonly checkout: boolean | undefined; /** The leg's resume: a workspace to restore, or the working directory its checkpoint stood in. */ readonly resume: { readonly workspaceHandle?: unknown; readonly seed: { readonly handsCwd?: string; }; } | undefined; /** Whether the leg's read state carries in files a compaction on it re-delivers (`legCarriedReads`); `undefined` = not read. */ readonly compactionRestore: boolean | undefined; /** What a delegating caller asked of the leg's placement. */ readonly internals: Pick<RunInternals, "requestedCwd" | "isolation" | "worktreeOffered" | "placementTarget" | "callerRoot" | "callerCheckout" | "agentStartersWithheld"> | undefined; } /** A leg's own reading of whether it needs an execution environment, made before the environment starts (prepare's * `startsEnv`) and reported as its effective plan's `executionEnv`. The caller's entries are the ones the leg mounts (the * model's class gate already took its removals); a fact the leg states only later stays open. */ export declare function readLegExecutionEnv(input: LegExecutionEnvInput): ToolMountPlanExecutionEnv; /** * The static plan of `(deps, spec)`: the mount table's rows, the caller's own tools, the MCP resource trio and the declared * peers' families, evaluated over the facts read above. Refuses a spec prepare would refuse at the same doors. Whether the * leg needs an execution environment reads the session's own needs as open unless `statement` says the session is new. */ export declare function planStaticToolMounts(deps: StaticToolPlanDeps, handed: StaticToolPlanSpec, statement?: StaticWiringStatement): ToolMountPlan;