UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

48 lines (47 loc) • 3.45 kB
/** * WHERE A LEG STANDS, as one value: the ONE projection of it ({@link workspaceSnapshotOf}) and the seat that announces * it on the `workspace_changed` frame ({@link createWorkspaceFrameSeat}) — the leg-start snapshot, then a frame only * when the snapshot's digest moved, by the rule every whole-snapshot frame shares ({@link createSnapshotFrameSeat}). * * The fixed members (root, session, declaration, directories, project, remote) are leg facts handed in at prepare; the two live ones * are read off the leg's own seats at each observation (the tracked cwd, the active EnterWorktree switch), never copied. */ import type { ActiveWorktreeSession } from "../internal/harness-types.js"; import type { SessionProject } from "./memory-engine/scope-contract.js"; import { type SnapshotFrameSeat } from "./snapshot-frame-seat.js"; import type { TaskEvent, TaskEventIdentity } from "./task-event.js"; /** The frame's value — derived from the `workspace_changed` arm of the event union (one source; never a hand-copied shape). */ export type WorkspaceSnapshot = Omit<Extract<TaskEvent, { type: "workspace_changed"; }>, "type" | keyof TaskEventIdentity>; /** What a leg's snapshot is projected from. */ export interface WorkspaceFacts { /** The leg's task root as its root receiving point settled it (`resolveTaskRootCanonical`). */ readonly root: string; /** The leg's tracked logical cwd — present only where a real shell is mounted; absent ⇒ the cwd is `root`. */ readonly cwdRef?: { readonly current: string; }; /** The leg's EnterWorktree seat — present only where the worktree tools are mounted. */ readonly worktreeSessionRef?: { readonly current?: ActiveWorktreeSession; }; /** The leg's project verdict (`resolveSessionProject`); absent ⇒ the leg has no project identity. */ readonly project?: SessionProject; /** The session's checkout as the frame reports it (`sessionFrameOf`); absent ⇒ the session declared no workspace, or this leg sent `workspace: null`. */ readonly session?: WorkspaceSnapshot["session"]; /** The declaration that checkout was opened under (`sessionFrameOf`), present with `session`. */ readonly declaration?: WorkspaceSnapshot["declaration"]; /** The leg's additional roots where they stand (`openSessionCheckout`'s `directories`); empty ⇒ the member is absent. */ readonly directories?: NonNullable<WorkspaceSnapshot["directories"]>; /** The leg's one remoteness reading (the restore phase's, the same value `ResolvedWorkspace.remote` carries). */ readonly remote: boolean; } /** The ONE mint of the `workspace_changed` value. */ export declare function workspaceSnapshotOf(facts: WorkspaceFacts): WorkspaceSnapshot; /** The leg's frame seat (held on `Prepared`): the run binds its sink once, and observes after every tool that may have moved the leg. */ export type WorkspaceFrameSeat = SnapshotFrameSeat<WorkspaceSnapshot>; /** The frame states the workspace the deployment handed the leg: an environment (its factory's answer, or its static env), or * — on a deployment that hands none (no env seat, or a factory that answered none) — the stand-in, its one workspace. * `undefined` ⇒ the deployment handed this leg none (its factory left unasked, no static env): the seat never sends. */ export declare function createWorkspaceFrameSeat(facts: WorkspaceFacts | undefined): WorkspaceFrameSeat;