UNPKG

@code-yeongyu/senpi

Version:

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

61 lines • 2.78 kB
/** * Who may write a session file when sessions move between devices (sisyphuslabs/omo-desktop-app#3137, * senpi#3630). The file itself records ownership as a sequence of transitions, folded in order: * - writable (no ownership entry yet, a `takeover` release, `session_moved_in`, `session_reclaimed`); * - `moving` after a `move` release: only that move may continue, with `session_moved` (it arrived), * `session_reclaimed` (it was given back) or `session_moved_in` (an import of that same move); * - `moved` after `session_moved`: nothing may reopen it. A new move id arriving by import replaces the file. * A transition the current state does not allow is refused when written and ignored when read. Entries name the * session they belong to (`session_id`); a copy or branch under a new id ignores the entries it inherited. */ /** `customType` of the release entry; shared with `release_session` (`modes/rpc/session-release.ts`). */ export declare const SESSION_RELEASED = "session_released"; export declare const SESSION_MOVED_IN = "session_moved_in"; export declare const SESSION_MOVED = "session_moved"; export declare const SESSION_RECLAIMED = "session_reclaimed"; export type MoveId = string & { readonly __brand: "MoveId"; }; export type RefusedOwnership = { readonly writable: false; readonly state: "moving"; readonly moveId: MoveId; readonly target: string; } | { readonly writable: false; readonly state: "moved"; readonly moveId: MoveId; readonly target: string; }; export type SessionOwnership = { readonly writable: true; } | RefusedOwnership; export type OwnershipStep = { readonly kind: "none"; } | { readonly kind: "apply"; readonly next: SessionOwnership; } | { readonly kind: "refused"; }; interface EntryLike { readonly type: string; readonly customType?: string; readonly data?: unknown; readonly id?: unknown; } export declare function isOwnershipEntryType(customType: string | undefined): boolean; /** * The single transition rule. `sessionId` is the id of the session being written; an entry naming another session * (inherited by a copy or branch) is not an ownership step for this one. */ export declare function ownershipStep(current: SessionOwnership, entry: EntryLike, sessionId: string | undefined): OwnershipStep; export declare function headerSessionId(entries: readonly EntryLike[]): string | undefined; export declare function sessionOwnership(entries: readonly EntryLike[]): SessionOwnership; export declare class SessionMovedAwayError extends Error { readonly code = "session_moved_away"; readonly ownership: RefusedOwnership; constructor(sessionFile: string, ownership: RefusedOwnership); } export {}; //# sourceMappingURL=ownership.d.ts.map