@prismshadow/penguin-library-agent · library/agent/src/snapshot-service.ts:119

SnapshotService

component

No JSDoc comment in source yet.

API

@Component()
export class SnapshotService implements Snapshots {
  @Use() private readonly paths!: SnapshotPaths;
  @Use() private readonly log!: SnapshotLog;
  @Use() private readonly clock!: SnapshotClock;
  async currentVersion(projectId: string, agentId: string): Promise<number>;
  async importArchive(projectId: string, agentId: string, pkg: AgentPackage, opts: { preSnapshot: boolean }): Promise<{ version: number; backup?: string }>;
}

Dependencies & Wiring

Extracted from class decorators
implementsinterfaces
@Userequires (3)
paths: SnapshotPaths · log: SnapshotLog · clock: SnapshotClock

Methods (2)

currentVersion

async currentVersion(projectId: string, agentId: string): Promise<number>

Current Agent State version number (missing field treated as 1); throws 404 if the Agent doesn't exist.

@paramprojectIdstring
@paramagentIdstring
@returnsPromise<number>

importArchive

async importArchive(projectId: string, agentId: string, pkg: AgentPackage, opts: { preSnapshot: boolean }): Promise<{ version: number; backup?: string }>

Import: validates the package structure and version, packs a fresh backup of the current State, then replaces agent_state/ while keeping the current vault, and hands the package's traces/ to pkg.landTraces.

preSnapshot: false skips the pre-import backup — for seeding a freshly created Agent, whose template state is not worth preserving.

@paramprojectIdstring
@paramagentIdstring
@parampkgAgentPackage
@paramopts{ preSnapshot: boolean }
@returnsPromise<{ version: number; backup?: string }>