@mmon-co/ncept-local 0.3.11 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,23 +15,23 @@ const tar = await profile.pack();
15
15
  await unpackDirectory(tar, "/path/to/moved-profile", [defaultTheory]);
16
16
  ```
17
17
 
18
- `init` creates an empty personal Patch, empty log and reserved directories in an ordinary project directory. `profile.json` contains `format: 1`, `personal`, `theory` (Core's requirement), `theories` (package names, initially `@mmon-co/ncept-default-theory`) and `sessions` (surface → pi filename). Account credentials live at `credentialsPath()`, outside the Profile, in `~/.config/ncept/credentials.json`.
18
+ `init` creates an empty personal Patch, empty log and reserved directories in an ordinary project directory. `profile.json` contains `format: 2`, `personal`, `theory` (Core's requirement), `theories` (package names, initially `@mmon-co/ncept-default-theory`) and `sessions` (surface → pi filename). Account credentials live at `credentialsPath()`, outside the Profile, in `~/.config/ncept/credentials.json`.
19
19
 
20
- `openProfile` and `unpack` migrate a stored minor pin (or an exact web-export release) with the supplied executable Theory’s `migrations` before strict resolution. Broad requirements still use strict resolution without migration. Migration writes new immutable Patch revisions and a content-addressed log snapshot, then atomically switches `profile.json`’s personal head, Theory requirement and optional `log` digest together. Interrupted writes leave the old generation active; reopening retries pure steps from that generation. Old revision/log files remain unread history. Opening a Profile also upgrades its host log: Lesson Sessions are entered on their Mission and run entries no longer retain a stop. The read-only Learn panel performs this log upgrade when it first opens an older Profile. Host futures are rebuilt from the migrated Profile; captured Session transcripts are not rewritten as futures.
20
+ `openProfile` and `unpack` upgrade format 1 monolithic Patch files to Merkle manifests and chunks, relinking exact references and retained undo targets. They also migrate a stored minor pin (or an exact web-export release) with the supplied executable Theory’s `migrations` before strict resolution. Broad requirements still use strict resolution without migration. Migration writes new immutable Patch revisions and a content-addressed log snapshot, then atomically switches `profile.json`’s personal head, Theory requirement and optional `log` digest together. Interrupted writes leave the old generation active; reopening retries pure steps from that generation. Old revision/log files remain unread history. Opening also upgrades the host log: legacy Lessons enter on their Mission or target, and retired Review Sessions close. The read-only Learn panel sees the upgrade in memory; a writable open persists it. Host futures are rebuilt from the migrated Profile; captured Session transcripts are not rewritten as futures.
21
21
 
22
- `openProfile` verifies digests, the personal Patch's complete base closure, log envelopes and the configured Theory range. Its handle appends log identities, adds immutable revisions and blobs, changes the personal head, and registers trusted transcripts. Add attachment bytes before revisions referring to them. A new revision replaces its identity's prior content; its bases are other Patches, not its own history.
22
+ `openProfile` verifies digests, the personal Patch and its selected sparse base closure, log envelopes and the configured Theory range. Its handle appends log identities, adds immutable revisions and blobs, changes the personal head, and registers trusted transcripts. Add attachment bytes before revisions referring to them. A new revision replaces its identity's prior content; its bases are other Patches, not its own history.
23
23
 
24
24
  pi chooses `sessions/<timestamp>_<sessionId>.jsonl`. After project trust, use `registerSession(surface, filename, { trusted: true })` for an existing pi file or `writeSession` for an imported one. Files merely present in `sessions/` do not count: pi can create them before trust. Moving/opening or unpacking rewrites registered session headers' `cwd` so pi's `/resume` can find them; entry and tool-call ids stay unchanged. `parsePiSession`/`serializePiSession` preserve provider metadata and opaque non-message entries alongside the exchange's typed messages.
25
25
 
26
26
  ## Pure exchange
27
27
 
28
- Import `@mmon-co/ncept-local/exchange` in Convex actions or browsers; it has no Node imports. `pack(files, theories)`, `unpack(tar, theories, { cwd })` and `validate(files, theories)` use a map of relative paths to bytes and supplied Theory identities. Package names in the manifest are data, not imports. The uncompressed ustar contains only `profile.json`, its selected log (`log.jsonl` initially, `log-<digest>.jsonl` after a write), `patches/`, `blobs/` and registered `sessions/`; the directory adapter leaves working copies in `materials/` and unrelated project files behind. Unsupported tar entry types, unsafe paths and duplicate paths are refused. `unpackDirectory` requires unused reserved directories rather than merging into an existing Profile.
28
+ Import `@mmon-co/ncept-local/exchange` in Convex actions or browsers; it has no Node imports. `pack(files, theories)`, `unpack(tar, theories, { cwd })` and `validate(files, theories)` use a map of relative paths to bytes and supplied Theory identities. Package names in the manifest are data, not imports. The uncompressed ustar contains only `profile.json`, its selected log (`log.jsonl` initially, `log-<digest>.jsonl` after a write), `manifests/`, `chunks/`, `blobs/` and registered `sessions/`; the directory adapter leaves working copies in `materials/` and unrelated project files behind. Unsupported tar entry types, unsafe paths and duplicate paths are refused. `unpackDirectory` requires unused reserved directories rather than merging into an existing Profile.
29
29
 
30
30
  ## Host contract
31
31
 
32
32
  `openHost({ profileDir, theories, model, confirm })` runs the selected Theory over the directory. The front end supplies constrained JSON replies for `judge` and `assess` (including decision grading), confirms proposals, and carries out the conversation/carry in a returned mode switch. Native catalog members are mounted by their original names; the web's envelopes remain unchanged. `web` and `bash` are the front end's capabilities, not tools implemented here. `host.hub` connects to the hosted Hub over anonymous HTTP and authenticated MCP.
33
33
 
34
- Open a Session with `host.sessions.open({ mode, entry })`, then call `.turn(session, {})` for its prompt, context, Skills and bound tools. The default Theory's modes are `empty`, `charting` (entries `goal`, `mission`, `target`, `checkpoint`), `authoring` and `lesson` (entries `mission`, `target`, `review`); the turn's `context` lists each mode's entry kinds and allowed switches. A tool is `{ name, description, schema, run(input) }`:
34
+ Open a Session with `host.sessions.open({ mode, entry })`, then call `.turn(session, {})` for its prompt, context, Skills and bound tools. The default Theory's modes are `empty`, `charting` (entries `goal`, `mission`, `target`, `checkpoint`), `authoring` and `lesson` (entries `mission`, `target`); the turn's `context` lists each mode's entry kinds and allowed switches. A tool is `{ name, description, schema, run(input) }`:
35
35
 
36
36
  ```ts
37
37
  const session = await host.sessions.open({ mode: "charting", entry: { kind: "goal", text: "Learn addition" } });
@@ -48,7 +48,7 @@ The front end writes pi transcripts and registers their filenames against `sessi
48
48
 
49
49
  Graph drafts stay unsaved until a confirmed `propose`. Mission and guidance/graph proposals and preference changes use `confirm`; a refusal changes no Profile files. Materials use the `local` playground, immutable blob bytes and working copies under `materials/<node>/<material>/<filename>`. Opening preserves an existing working copy. Read-back returns both the saved body and current working-copy text. Other playgrounds' Materials remain readable as saved data without claiming a runner.
50
50
 
51
- `host.config.update({ ...await host.config.read(), timezone: "America/New_York" })` configures learner-days. The initial zone is the machine's IANA zone; each learner-day ends at 04:00 local, including across DST. At startup, the host raises `day.ended` once per elapsed day and records its receipt alongside the Theory's writes. No account or background daemon is needed. Set `sessionLength` through the same config API to choose the Session budget in minutes (default 20). Review opens the Theory’s budgeted maintenance stop, preserving its Node order; the due count still describes all due Nodes.
51
+ `host.config.update({ ...await host.config.read(), timezone: "America/New_York" })` configures learner-days. The initial zone is the machine's IANA zone; each learner-day ends at 04:00 local, including across DST. At startup, the host raises `day.ended` once per elapsed day and records its receipt alongside the Theory's writes. No account or background daemon is needed. Set `sessionLength` through the same config API to choose the Session budget in minutes (default 20).
52
52
 
53
53
  ## Hub and web exchange
54
54
 
@@ -63,7 +63,9 @@ const imported = await host.hub.importFrom("web"); // web Profile replaces local
63
63
  await host.sessions.open({ mode: "authoring", resume: imported.sessions[0] });
64
64
  ```
65
65
 
66
- Pull verifies the closed bundle and all attachment digests before adopting its root as a direct base of the personal Patch. Publish confirms the packaged content, uploads its blobs, then captures, names and publishes a public release. Account operations require `signIn` once; the MCP SDK discovers the protected resource and authorization server, registers the client, requests `patches publish learn`, and refreshes saved tokens when necessary. Credentials are private (`0600`), outside the Profile and exchange archive.
66
+ Pull verifies the release's sparse Merkle closure and surviving blobs before adding the release as a direct base of the personal Patch. Publish retains exact bases: a base readable on that Hub can be reused as-is; any other base must have its complete chunks and attachment bytes available for capture. Share flattens the Mission's View. Profile exchange carries the selected Notebook reading and the personal Patch's full authored delta so it can still be edited.
67
+
68
+ Account operations require `signIn` once; initialize web Main before the first export to web. The MCP SDK discovers the protected resource and authorization server, registers the client, requests `patches publish learn`, and refreshes saved tokens when necessary. Credentials are private (`0600`), outside the Profile and exchange archive.
67
69
 
68
70
  `openHost({ ..., hub: { url, clientMetadataUrl, credentialsFile, openUrl } })` optionally overrides the Application base URL (default `https://co.mmon.co/ncept`), credential file (default `credentialsPath()`) and browser opening. For issuers using CIMD rather than dynamic registration, supply the front end's public native-client metadata document as `clientMetadataUrl` (the pi package uses pi's published identity). Front ends running remotely can present the authorization URL themselves through `openUrl`; the browser must be able to reach the host machine’s loopback callback. HTTP is allowed only for loopback development URLs.
69
71
 
@@ -1,4 +1,4 @@
1
- import { type ContentDigest, type ExactPatchRef, type PatchContent, type PatchId, type ProfileLogEntry, type TheoryRequirement } from "@mmon-co/ncept-core";
1
+ import { type SparsePatchBundle, type ContentDigest, type ExactPatchRef, type PatchContent, type PatchId, type ProfileLogEntry, type TheoryRequirement } from "@mmon-co/ncept-core";
2
2
  import { type ConfiguredTheory, type ProfileFiles, type ValidatedProfile } from "./exchange.js";
3
3
  import { type PiSession } from "./sessions.js";
4
4
  /** Account credentials never belong to a Profile or its exchange tar. */
@@ -16,6 +16,7 @@ export interface ProfileDirectory {
16
16
  /** A conditional append checks the current Profile while holding its write lock. */
17
17
  appendLog(entries: readonly ProfileLogEntry[], accept?: (current: ValidatedProfile) => boolean): Promise<void>;
18
18
  addRevision(identity: PatchId, content: PatchContent): Promise<ExactPatchRef>;
19
+ addSparseClosure(bundle: SparsePatchBundle): Promise<void>;
19
20
  setPersonal(ref: ExactPatchRef): Promise<void>;
20
21
  configure(options: InitOptions): Promise<void>;
21
22
  addBlob(bytes: Uint8Array): Promise<ContentDigest>;
package/dist/directory.js CHANGED
@@ -3,9 +3,10 @@ import { homedir } from "node:os";
3
3
  import { join, resolve } from "node:path";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { lock, lockSync } from "proper-lockfile";
6
- import { attachmentDigest, candidateRevision, emptyPatch, isPatchId, mergeProfileLogs, PERSONAL_PATCH_ID, } from "@mmon-co/ncept-core";
6
+ import { attachmentDigest, verifySparseBundle, candidateRevision, emptyPatch, isPatchId, mergeProfileLogs, PERSONAL_PATCH_ID, resolveTheory, } from "@mmon-co/ncept-core";
7
7
  import { DEFAULT_THEORY_PACKAGES, DEFAULT_THEORY_REQUIREMENT, jsonBytes, logBytes, liveLogPath, migrateLessonLog, migrateProfileFiles, pack, parseManifest, sessionFilename, unpack, utf8, validate, } from "./exchange.js";
8
8
  import { parsePiSession, piSessionFilename, relocatePiSession, serializePiSession, } from "./sessions.js";
9
+ import { PackedPatches, packedFiles } from "./packed.js";
9
10
  /** Account credentials never belong to a Profile or its exchange tar. */
10
11
  export function credentialsPath(home = homedir()) {
11
12
  return join(home, ".config", "ncept", "credentials.json");
@@ -27,7 +28,7 @@ async function atomic(dir, path, bytes) {
27
28
  await rename(join(dir, temp), join(dir, path));
28
29
  }
29
30
  async function immutable(dir, path, bytes) {
30
- // Stage outside patches/: an interrupted write must not leave a truncated
31
+ // Stage outside the content-addressed directories: an interrupted write must not leave a truncated
31
32
  // content-addressed file that prevents reopening even the old live generation.
32
33
  const temp = join(dir, "." + randomUUID() + ".tmp");
33
34
  try {
@@ -39,8 +40,13 @@ async function immutable(dir, path, bytes) {
39
40
  if (!existsError(error))
40
41
  throw error;
41
42
  const existing = await regular(dir, path);
42
- if (existing.length !== bytes.length || existing.some((byte, index) => byte !== bytes[index]))
43
- throw new Error("Conflicting immutable Profile file: " + path);
43
+ if (existing.length !== bytes.length || existing.some((byte, index) => byte !== bytes[index])) {
44
+ // Merkle filenames identify JSON values. Another exchange writer can encode the same value differently.
45
+ if (path.startsWith("manifests/") || path.startsWith("chunks/"))
46
+ PackedPatches.fromFiles(new Map([[path, existing]]));
47
+ else
48
+ throw new Error("Conflicting immutable Profile file: " + path);
49
+ }
44
50
  }
45
51
  }
46
52
  finally {
@@ -63,7 +69,7 @@ async function filesAt(dir, retries = 3) {
63
69
  return filesAt(dir, retries - 1);
64
70
  throw error;
65
71
  }
66
- for (const folder of ["patches", "blobs"]) {
72
+ for (const folder of manifest.format === 1 ? ["patches", "blobs"] : ["manifests", "chunks", "blobs"]) {
67
73
  if (!(await lstat(join(dir, folder))).isDirectory())
68
74
  throw new Error("Not a Profile directory: " + folder);
69
75
  for (const name of await readdir(join(dir, folder))) {
@@ -82,14 +88,14 @@ async function filesAt(dir, retries = 3) {
82
88
  export async function init(dir, options = {}) {
83
89
  dir = resolve(dir);
84
90
  await mkdir(dir, { recursive: true });
85
- for (const folder of ["patches", "blobs", "sessions", "materials"]) {
91
+ for (const folder of ["manifests", "chunks", "blobs", "sessions", "materials"]) {
86
92
  await mkdir(join(dir, folder), { recursive: true });
87
93
  if (!(await lstat(join(dir, folder))).isDirectory())
88
94
  throw new Error("Not a Profile directory: " + folder);
89
95
  }
90
96
  const patch = candidateRevision(PERSONAL_PATCH_ID, emptyPatch());
91
97
  const manifest = {
92
- format: 1,
98
+ format: 2,
93
99
  personal: patch.ref,
94
100
  theory: options.theory ?? DEFAULT_THEORY_REQUIREMENT,
95
101
  theories: options.theories ?? DEFAULT_THEORY_PACKAGES,
@@ -97,7 +103,10 @@ export async function init(dir, options = {}) {
97
103
  };
98
104
  // Reserve the manifest first: a second init must not erase a learner's log.
99
105
  await writeFile(join(dir, "profile.json"), jsonBytes(manifest), { flag: "wx" });
100
- await immutable(dir, "patches/" + patch.ref.digest + ".json", jsonBytes(emptyPatch()));
106
+ const packed = new PackedPatches();
107
+ packed.add(emptyPatch());
108
+ for (const [path, data] of packedFiles(packed))
109
+ await immutable(dir, path, data);
101
110
  await writeFile(join(dir, "log.jsonl"), new Uint8Array(), { flag: "wx" });
102
111
  }
103
112
  async function locked(dir, operation) {
@@ -120,20 +129,19 @@ async function locked(dir, operation) {
120
129
  await release();
121
130
  }
122
131
  }
123
- function installedPin(files, theories) {
124
- const { theory, range } = parseManifest(files.get("profile.json")).theory;
125
- const version = theories.find((candidate) => candidate.id === theory)?.version;
126
- return version !== undefined && range === "~" + version.split(".").slice(0, 2).join(".");
127
- }
128
132
  export async function openProfile(dir, theories, options = {}) {
129
133
  dir = resolve(dir);
130
- const readOnlyFiles = options.readOnly ? await filesAt(dir) : undefined;
131
- // A read-only open migrates like a writable one, but only takes the lock (and pays a second
132
- // validation beyond read()'s) when the Lesson log or the stored Theory pin is behind.
133
- if (!readOnlyFiles || migrateLessonLog(readOnlyFiles) !== readOnlyFiles || !installedPin(readOnlyFiles, theories))
134
+ if (!options.readOnly)
134
135
  await locked(dir, async () => {
135
136
  const stored = await filesAt(dir);
136
- const initial = migrateProfileFiles(stored, theories);
137
+ const initial = await migrateProfileFiles(stored, theories);
138
+ const legacy = parseManifest(stored.get("profile.json")).format === 1;
139
+ if (legacy)
140
+ for (const folder of ["manifests", "chunks"]) {
141
+ await mkdir(join(dir, folder), { recursive: true });
142
+ if (!(await lstat(join(dir, folder))).isDirectory())
143
+ throw new Error("Not a Profile directory: " + folder);
144
+ }
137
145
  // Immutable data first, then a single atomic live-head/log/pin switch. An interruption
138
146
  // leaves either the old generation or the complete new one; retry never repeats a step.
139
147
  for (const [path, bytes] of initial) {
@@ -143,10 +151,11 @@ export async function openProfile(dir, theories, options = {}) {
143
151
  const manifest = initial.get("profile.json");
144
152
  if (manifest !== stored.get("profile.json") && manifest)
145
153
  await atomic(dir, "profile.json", manifest);
146
- if (options.readOnly)
147
- return;
154
+ if (legacy)
155
+ await rm(join(dir, "patches"), { recursive: true });
156
+ const current = parseManifest(manifest);
148
157
  // A copied or moved Profile must still appear in pi's cwd-filtered /resume list.
149
- for (const filename of Object.values(parseManifest(manifest).sessions)) {
158
+ for (const filename of Object.values(current.sessions)) {
150
159
  const path = "sessions/" + filename;
151
160
  const bytes = initial.get(path);
152
161
  if (bytes) {
@@ -165,8 +174,25 @@ export async function openProfile(dir, theories, options = {}) {
165
174
  tail = result.catch(() => { });
166
175
  return result;
167
176
  }
177
+ async function files() {
178
+ const stored = await filesAt(dir);
179
+ if (!options.readOnly)
180
+ return stored;
181
+ // Learn reads before opening its first writable tutor session, even after init.
182
+ const manifest = parseManifest(stored.get("profile.json"));
183
+ if (manifest.format === 2) {
184
+ try {
185
+ resolveTheory(manifest.theory, theories);
186
+ return migrateLessonLog(stored);
187
+ }
188
+ catch {
189
+ // An older stored pin can migrate in memory without changing the live files.
190
+ }
191
+ }
192
+ return migrateProfileFiles(stored, theories);
193
+ }
168
194
  async function read() {
169
- return validate(await filesAt(dir), theories);
195
+ return validate(await files(), theories);
170
196
  }
171
197
  async function manifestWith(change) {
172
198
  const files = await filesAt(dir);
@@ -183,7 +209,7 @@ export async function openProfile(dir, theories, options = {}) {
183
209
  if (!files.has(path))
184
210
  files.set(path, await regular(dir, path));
185
211
  }
186
- validate(files, theories);
212
+ await validate(files, theories);
187
213
  const bytes = files.get("profile.json");
188
214
  if (bytes)
189
215
  await atomic(dir, "profile.json", bytes);
@@ -202,7 +228,7 @@ export async function openProfile(dir, theories, options = {}) {
202
228
  return {
203
229
  dir,
204
230
  read,
205
- files: () => filesAt(dir),
231
+ files,
206
232
  appendLog: (entries, accept) => serial(async () => {
207
233
  const current = await read();
208
234
  if (accept && !accept(current))
@@ -222,13 +248,22 @@ export async function openProfile(dir, theories, options = {}) {
222
248
  throw new Error("Invalid Patch identity");
223
249
  const revision = candidateRevision(identity, content);
224
250
  const files = await filesAt(dir);
225
- const path = "patches/" + revision.ref.digest + ".json";
226
- files.set(path, jsonBytes(content));
251
+ const store = new PackedPatches();
252
+ store.add(content);
253
+ const parts = packedFiles(store);
254
+ for (const [path, data] of parts)
255
+ files.set(path, data);
227
256
  files.set("profile.json", jsonBytes({ ...parseManifest(files.get("profile.json")), personal: revision.ref }));
228
- validate(files, theories);
229
- await immutable(dir, path, jsonBytes(content));
257
+ await validate(files, theories);
258
+ for (const [path, data] of parts)
259
+ await immutable(dir, path, data);
230
260
  return revision.ref;
231
261
  }),
262
+ addSparseClosure: (bundle) => serial(async () => {
263
+ await verifySparseBundle(bundle);
264
+ for (const [path, data] of packedFiles(bundle))
265
+ await immutable(dir, path, data);
266
+ }),
232
267
  setPersonal: (personal) => serial(() => manifestWith({ personal })),
233
268
  configure: (options) => serial(() => manifestWith(options)),
234
269
  addBlob: (bytes) => serial(async () => {
@@ -246,16 +281,16 @@ export async function openProfile(dir, theories, options = {}) {
246
281
  await register(surface, filename, options);
247
282
  return filename;
248
283
  }),
249
- pack: async () => pack(await filesAt(dir), theories),
284
+ pack: async () => pack(await files(), theories),
250
285
  };
251
286
  }
252
287
  /** Unpack into a new Profile, leaving unrelated project files alone and never following links. */
253
288
  export async function unpackDirectory(archive, dir, theories) {
254
289
  dir = resolve(dir);
255
- const files = unpack(archive, theories, { cwd: dir });
290
+ const files = await unpack(archive, theories, { cwd: dir });
256
291
  await mkdir(dir, { recursive: true });
257
292
  // Exclusive creation of reserved directories avoids merging with old data or symlink trees.
258
- for (const folder of ["patches", "blobs", "sessions"])
293
+ for (const folder of ["manifests", "chunks", "blobs", "sessions"])
259
294
  await mkdir(join(dir, folder));
260
295
  for (const [path, bytes] of files) {
261
296
  if (path !== "profile.json")
@@ -1,10 +1,12 @@
1
- import { type Theory, type ContentDigest, type ExactPatchRef, type Profile, type ProfileLogEntry, type TheoryRequirement } from "@mmon-co/ncept-core";
1
+ import { type SparsePatchBundle, type ResolvedGraph, type Theory, type ContentDigest, type ExactPatchRef, type PatchContent, type Profile, type ProfileLogEntry, type TheoryRequirement } from "@mmon-co/ncept-core";
2
2
  import { type ProfileFiles } from "./tar.js";
3
+ export { packedFiles } from "./packed.js";
4
+ export { encodeTar } from "./tar.js";
3
5
  export type { ProfileFiles } from "./tar.js";
4
6
  export declare const DEFAULT_THEORY_PACKAGES: readonly ["@mmon-co/ncept-default-theory"];
5
7
  export declare const DEFAULT_THEORY_REQUIREMENT: TheoryRequirement;
6
8
  export interface ProfileManifest {
7
- readonly format: 1;
9
+ readonly format: 2;
8
10
  readonly personal: ExactPatchRef;
9
11
  /** Content-addressed live log snapshot; absent on the initial directory shape. */
10
12
  readonly log?: ContentDigest;
@@ -15,7 +17,10 @@ export interface ProfileManifest {
15
17
  readonly sessions: Readonly<Record<string, string>>;
16
18
  }
17
19
  export type ConfiguredTheory = Pick<Theory<unknown>, "id" | "version" | "migrations">;
18
- export interface ValidatedProfile extends Profile {
20
+ export interface ValidatedProfile extends Omit<Profile, "patches"> {
21
+ readonly patches: SparsePatchBundle;
22
+ readonly graph: ResolvedGraph;
23
+ readonly personal: PatchContent;
19
24
  readonly manifest: ProfileManifest;
20
25
  readonly blobs: ReadonlyMap<ContentDigest, Uint8Array>;
21
26
  /** Surface -> original pi JSONL; entry/message ids are preserved. */
@@ -24,18 +29,20 @@ export interface ValidatedProfile extends Profile {
24
29
  export declare const utf8: TextEncoder;
25
30
  export declare function jsonBytes(value: unknown): Uint8Array;
26
31
  export declare function sessionFilename(value: unknown): value is string;
27
- export declare function parseManifest(bytes: Uint8Array | undefined): ProfileManifest;
32
+ type StoredManifest = Omit<ProfileManifest, "format"> & {
33
+ format: 1 | 2;
34
+ };
35
+ export declare function parseManifest(bytes: Uint8Array | undefined): StoredManifest;
28
36
  export declare function parseLog(bytes: Uint8Array | undefined): readonly ProfileLogEntry[];
29
37
  export declare function logBytes(entries: readonly ProfileLogEntry[]): Uint8Array;
30
- /** Pure validation; safe in a Convex action. No filesystem, package loading, or provider calls. */
31
- export declare function validate(files: ProfileFiles, theories: readonly ConfiguredTheory[]): ValidatedProfile;
32
- export declare function liveLogPath(manifest: ProfileManifest): string;
38
+ export declare function validate(files: ProfileFiles, theories: readonly ConfiguredTheory[]): Promise<ValidatedProfile>;
39
+ export declare function liveLogPath(manifest: StoredManifest): string;
33
40
  /** Rewrite host-owned state before validating the log in its current shape. */
34
41
  export declare function migrateLessonLog(files: ProfileFiles): ProfileFiles;
35
42
  /** Migrate structurally valid live data before ordinary strict Theory resolution. */
36
- export declare function migrateProfileFiles(files: ProfileFiles, theories: readonly ConfiguredTheory[]): Map<string, Uint8Array>;
43
+ export declare function migrateProfileFiles(files: ProfileFiles, theories: readonly ConfiguredTheory[]): Promise<Map<string, Uint8Array<ArrayBufferLike>>>;
37
44
  /** Only exchange files belong in this map. The directory adapter excludes materials and untrusted sessions. */
38
- export declare function pack(files: ProfileFiles, theories: readonly ConfiguredTheory[]): Uint8Array;
45
+ export declare function pack(files: ProfileFiles, theories: readonly ConfiguredTheory[]): Promise<Uint8Array<ArrayBufferLike>>;
39
46
  export declare function unpack(archive: Uint8Array, theories: readonly ConfiguredTheory[], options?: {
40
47
  cwd?: string;
41
- }): Map<string, Uint8Array>;
48
+ }): Promise<Map<string, Uint8Array<ArrayBufferLike>>>;