UNPKG

@code-yeongyu/senpi

Version:

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

84 lines • 4.85 kB
import { type RepositoryIdentity } from "../repository-identity.ts"; import type { MoveId } from "./ownership.ts"; export declare const MOVE_BUNDLE_FORMAT = 1; export declare const MANIFEST_FILE = "manifest.json"; export declare const SESSION_BUNDLE_PATH = "files/session.jsonl"; export interface BundleFile { readonly path: string; readonly sha256: string; } /** * Optional extra payloads travel next to the session without changing its shape: `extension-state` carries what * extensions wrote at the move release (senpi#3676). An importer that does not know a kind refuses the bundle. */ export interface MovePayload { readonly kind: string; readonly files: readonly BundleFile[]; } export interface MoveManifest { readonly format: typeof MOVE_BUNDLE_FORMAT; readonly moveId: MoveId; readonly sessionId: string; readonly sessionFileName: string; readonly sourceCwd: string; readonly repository: RepositoryIdentity | undefined; readonly session: BundleFile; readonly sidecars: readonly BundleFile[]; readonly droppedUserMessages: readonly string[]; readonly payloads: readonly MovePayload[]; } export declare class MoveBundleInvalidError extends Error { readonly code = "move_bundle_invalid"; constructor(detail: string); } /** Streams the file through the hash, so a large blob never blocks the host's event loop. */ export declare function sha256File(path: string): Promise<string>; /** Both separators count: a bundle written on one OS is read on another. */ export declare function leavesBundle(path: string): boolean; /** * The most segments a path in a bundle may have (senpi#6469). The engine's own paths are at most four deep * (`files/extensions/<extension>/<id>.json`, `files/resident-blobs/<session>/<id>.blob`); extension state under * `state/` is as deep as its extension makes it, and this leaves eight times the engine's depth for it. With no cap a * path of 1,024 bytes names about 500 folders, and an import creates every folder of every listed path. */ export declare const MAX_BUNDLE_PATH_SEGMENTS = 32; /** Both separators count, as in `leavesBundle`. */ export declare function nestsTooDeep(path: string): boolean; /** A path as an error may show it: quoted, and cut short only when it is long. */ export declare const shown: (path: string) => string; /** * A file the move would carry sits deeper than a bundle path may be, so a receiver would refuse the bundle. The * sender refuses first: before it seals the session where it still can, and before it writes a bundle where the * session was sealed already (by a version that did not look). */ export declare class MovePathTooDeepError extends Error { readonly code = "move_path_too_deep"; constructor(path: string, sealedAlready: boolean); } export declare function isPlainId(value: unknown): value is string; export declare function isMoveId(value: unknown): value is MoveId; export declare function parsePlainId(value: unknown, what: string): string; export declare function parseMoveId(value: unknown): MoveId; /** Whether `value` is a name a session can land under: what a manifest may carry and what a `status` may name. */ export declare const isSessionFileName: (value: unknown) => value is string; /** Payload kinds this version imports; any other kind refuses the bundle. */ export declare const KNOWN_PAYLOAD_KINDS: ReadonlySet<string>; /** Where `extension-state` payload files sit inside the bundle. */ export declare const EXTENSION_STATE_PREFIX = "state/"; export declare function readManifest(bundleDir: string): Promise<MoveManifest>; /** * What a sender reads back from the bundle it kept: the move it is for, and the queued input the release took out, * in a format this version knows. Nothing else is checked. The bundle is the sender's own, and a rule about its paths that is newer than the bundle * (the depth cap) must not stop the sender from finishing its move. */ export declare function readKeptBundle(bundleDir: string): Promise<Pick<MoveManifest, "moveId" | "droppedUserMessages">>; /** The manifest from its own text: an inline bundle's manifest is read before any of its files is written. */ export declare function parseManifest(text: string): MoveManifest; /** Every file a manifest lists besides itself: the session, its sidecars and the payload files. */ export declare const listedFiles: (manifest: MoveManifest) => readonly BundleFile[]; /** * Checks every listed file against the manifest. `sent` is the sha256 each file of an inline bundle arrived with * (senpi#6267): a file must match that too, so an entry that contradicts its own bytes is refused like a changed file. */ export declare function verifyBundle(bundleDir: string, manifest: MoveManifest, sent?: ReadonlyMap<string, string>): Promise<void>; //# sourceMappingURL=bundle.d.ts.map