UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

49 lines • 2.98 kB
import { type MoveManifest } from "./bundle.ts"; import { type MoveId } from "./ownership.ts"; export interface ExportSessionForMoveOptions { /** A session no live runtime holds: an RPC host releases it first (`release_session` reason `move`). */ readonly sessionFile: string; readonly moveId: MoveId; readonly target: string; /** Queued user input the release took out of the session (`dropped.user_messages`), in order. */ readonly droppedUserMessages: readonly string[]; readonly bundleDir: string; /** * What the extensions wrote at the move release, bundled as the `extension-state` payload. A function is resolved * inside the move lock, right before the bundle is written (`sealedOutgoingStateDir`: the sealing attempt's folder). */ readonly extensionStateDir?: string | (() => string | undefined | Promise<string | undefined>); /** Runs inside this process's move queue before anything is read; throw to refuse. */ readonly guard?: () => void | Promise<void>; /** * Runs inside the cross-process move lock, right before the session is read and sealed; throw to refuse. A check on * the session file's state belongs here: another generation can change it between `guard` and the lock. */ readonly lockedGuard?: () => void | Promise<void>; } /** * Seals the session for the move (a `session_released` entry with reason `move`; from then on this device refuses * writes) and writes a self-verifying bundle: the session file, its extension sidecars and resident blobs, and a * manifest. Running it again for the same move rewrites the same bundle without a second release entry. */ export declare function exportSessionForMove(options: ExportSessionForMoveOptions): Promise<MoveManifest>; /** * `exportSessionForMove`, then `read` on the written bundle folder before the move lock is released, so a `finish` or * a second export of the session cannot change the folder while it is read (senpi#6267: the inline answer). */ export declare function exportSessionForMoveAndRead<T>(options: ExportSessionForMoveOptions, read: (bundleDir: string) => Promise<T>): Promise<{ readonly manifest: MoveManifest; readonly read: T; }>; /** The release that sealed the session staged extension state that is no longer on disk; bundling would lose it. */ export declare class MovedStateMissingError extends Error { constructor(dir: string); } /** * Refuses a move one of whose files would sit in the bundle deeper than a bundle path may be (senpi#6469): the * session's resident blobs, and the extension state staged for the move. Whoever seals a session for a move asks * first, so a session a receiver would refuse is never sealed. */ export declare function assertMoveFits(sessionFile: string, sessionId: string, stateDir: string | undefined, sealedAlready: boolean): Promise<void>; export declare function filesUnder(dir: string): Promise<string[]>; //# sourceMappingURL=export.d.ts.map