import { createHash } from 'node:crypto' import { lstatSync, mkdirSync } from 'node:fs' import { link, mkdir, open, readFile, realpath, unlink } from 'node:fs/promises' import { tmpdir, userInfo } from 'node:os' import { basename, dirname, join } from 'node:path' import type { CheckpointId, GoalId, MessageId, ProjectId, SessionId, TaskId, TurnId, } from '../types/ids/index.js' import { type ProjectDocument, ProjectDocumentSchema } from '../types/session/records.js' import { type EntityIdKind, asSessionId, generateProjectId, isEntityId } from '../utils/id.js' import { uuidv7 } from '../utils/uuidv7.js' /** * The on-disk layout of `NAMZU_HOME`, shared by the SDK and the CLI: * * ```text * $NAMZU_HOME/ * index.sqlite rebuildable index over every log * projects// * project.json the project id, minted once * memory/ residents/ worktrees/