UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

45 lines (44 loc) • 3.32 kB
import type { EngineNotice } from "../core/engine-notice.js"; import type { RunnerSelfSeat } from "../core/runner/contracts.js"; import type { SessionAddress, SessionCompletionLane, TaskNotificationSink } from "../core/task-notification.js"; /** The root anchor a tree records — its id, the occupant it was born under, the scope its box mounts in — as the address the * runner's route reads; `undefined` where it names no root. */ export declare function rootSessionAddressOf(root: { readonly rootSessionId?: string; readonly rootSessionIncarnation?: string; readonly rootSessionScope?: string; }): SessionAddress | undefined; /** * The address of the root of a leg's session TREE, by the delegation fixed point — one construction for both kinds of leg, so the root * and its descendants name it alike: a descendant the root its anchor records ({@link rootSessionAddressOf}); a root its OWN address * (`own`: its id, its occupant as its prepare read it) under its task scope (`taskScope`, the scope its children's anchors record as * `rootSessionScope`). The tree-keyed seats read their key off this ({@link rootSessionAddressKeyOf}). */ export declare function treeRootAddressOf(anchor: { readonly rootSessionId?: string; readonly rootSessionIncarnation?: string; readonly rootSessionScope?: string; }, own: SessionAddress, taskScope: string): SessionAddress; /** * The canonical key of a root session's address: two addresses share it exactly when they name the same box scope, the same * session id and the same occupant by `sameOccupant` (engine/session/repo-utils.ts: the same token, or no token on either side). An address whose occupant * could not be read (`unread`) names nobody and has no key. */ export declare function rootSessionAddressKeyOf(address: SessionAddress): string | undefined; /** Such a drive's way to its tree's root: the runner's own answer ({@link RunnerSelfSeat.sessionCompletionLane}), or one of the * two only the drive can see — the tree names no root (`no_root`), the runner seat offers no route (`no_route`). */ export type RootSessionLane = SessionCompletionLane | { readonly ok: false; readonly cause: { readonly code: "no_root"; } | { readonly code: "no_route"; }; }; export declare function rootSessionLaneOf(runner: Pick<RunnerSelfSeat, "sessionCompletionLane">, root: SessionAddress | undefined, unkept?: TaskNotificationSink): RootSessionLane; /** Such a drive's ONE completion sink: each frame goes to the tree's root through the runner's route while the route is there when * the frame is delivered, else to the mount's own sink (`mount`, absent ⇒ nowhere — a drive admitted without one had the route). */ export declare function rootSessionSink(runner: Pick<RunnerSelfSeat, "sessionCompletionLane">, root: SessionAddress | undefined, mount: TaskNotificationSink | undefined): TaskNotificationSink; /** The account of a parked agent resumed by a drive whose task registry holds no park of it (`delegation.resume_lane_missing`): * where its completion goes — its tree's root through the route (`detail.path: "box"`), or the deployment's channel and why. */ export declare function resumeLaneMissingNotice(taskId: string, rootSessionId: string | undefined, lane: RootSessionLane): EngineNotice;