@qlairoslabs/acp-client 0.5.0 → 0.7.0

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.
Files changed (62) hide show
  1. package/CHANGELOG-metering.md +288 -0
  2. package/CONSUMER_GUIDE.md +579 -292
  3. package/README.md +25 -0
  4. package/package.json +6 -3
  5. package/src/agent-session.ts +2589 -96
  6. package/src/cli/index.ts +33 -5
  7. package/src/cli/managed.ts +220 -0
  8. package/src/client.ts +57 -1
  9. package/src/controller.ts +43 -0
  10. package/src/index.ts +379 -3
  11. package/src/metering/catalog/build.ts +285 -0
  12. package/src/metering/catalog/index.ts +243 -0
  13. package/src/metering/catalog/live.ts +171 -0
  14. package/src/metering/catalog/models-dev.catalog.json +8797 -0
  15. package/src/metering/catalog/models-dev.meta.json +6 -0
  16. package/src/metering/categories.ts +129 -0
  17. package/src/metering/certification.ts +86 -0
  18. package/src/metering/context.ts +134 -0
  19. package/src/metering/delta.ts +108 -0
  20. package/src/metering/engine.ts +999 -0
  21. package/src/metering/money.ts +356 -0
  22. package/src/metering/opencode/channel.ts +389 -0
  23. package/src/metering/opencode/index.ts +159 -0
  24. package/src/metering/opencode/plugin.js +90 -0
  25. package/src/metering/opencode/profile.ts +159 -0
  26. package/src/metering/pricing.ts +285 -0
  27. package/src/metering/provider.ts +121 -0
  28. package/src/metering/rating.ts +349 -0
  29. package/src/metering/record.ts +275 -0
  30. package/src/metering/state.ts +421 -0
  31. package/src/metering/usage.ts +72 -0
  32. package/src/persistence/activity-projection.ts +71 -0
  33. package/src/persistence/audit-log-reader.ts +506 -0
  34. package/src/persistence/audit-runtime.ts +162 -0
  35. package/src/persistence/checkpoint.ts +304 -0
  36. package/src/persistence/config.ts +538 -0
  37. package/src/persistence/configuration-state.ts +191 -0
  38. package/src/persistence/deletion.ts +227 -0
  39. package/src/persistence/file-registry-store.ts +740 -0
  40. package/src/persistence/integrity.ts +147 -0
  41. package/src/persistence/legacy-registry-import.ts +240 -0
  42. package/src/persistence/managed-checkpoint.ts +81 -0
  43. package/src/persistence/managed-creation.ts +456 -0
  44. package/src/persistence/managed-load.ts +172 -0
  45. package/src/persistence/managed-registry.ts +57 -0
  46. package/src/persistence/migration.ts +298 -0
  47. package/src/persistence/paths.ts +172 -0
  48. package/src/persistence/projection.ts +373 -0
  49. package/src/persistence/reconfiguration.ts +453 -0
  50. package/src/persistence/records.ts +873 -0
  51. package/src/persistence/reducer.ts +498 -0
  52. package/src/persistence/registry.ts +446 -0
  53. package/src/persistence/restoration.ts +689 -0
  54. package/src/persistence/session-log-writer.ts +480 -0
  55. package/src/persistence/state-runtime.ts +176 -0
  56. package/src/persistence/transcript-reader.ts +980 -0
  57. package/src/persistence/transcript-runtime.ts +667 -0
  58. package/src/persistence/transcript-scanner.ts +385 -0
  59. package/src/persistence/truncation.ts +276 -0
  60. package/src/session-manager.ts +257 -7
  61. package/src/transcript.ts +3 -3
  62. package/src/types.ts +28 -5
@@ -0,0 +1,147 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ export type PersistedMachineCode = string;
4
+
5
+ export class PersistenceSerializationError extends Error {
6
+ constructor(message: string) {
7
+ super(message);
8
+ this.name = "PersistenceSerializationError";
9
+ }
10
+ }
11
+
12
+ const MACHINE_CODE = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/;
13
+
14
+ export function isPersistedMachineCode(value: unknown): value is PersistedMachineCode {
15
+ return typeof value === "string" && MACHINE_CODE.test(value);
16
+ }
17
+
18
+ /** Provider-originated values are telemetry: invalid prose becomes one stable safe code. */
19
+ export function normalizeProviderMachineCode(value: unknown): PersistedMachineCode {
20
+ return isPersistedMachineCode(value) ? value : "unknown";
21
+ }
22
+
23
+ /** Consumer/library structural codes fail closed rather than changing their meaning. */
24
+ export function assertPersistedMachineCode(
25
+ value: unknown,
26
+ label = "persisted machine code",
27
+ ): asserts value is PersistedMachineCode {
28
+ if (!isPersistedMachineCode(value)) {
29
+ throw new PersistenceSerializationError(
30
+ `${label} must match ^[A-Za-z][A-Za-z0-9_.:-]{0,127}$`,
31
+ );
32
+ }
33
+ }
34
+
35
+ /** RFC 8785 JSON Canonicalization Scheme serialization for JSON-compatible input. */
36
+ export function canonicalizeJson(value: unknown, maxDepth = 128): string {
37
+ if (!Number.isSafeInteger(maxDepth) || maxDepth < 1) {
38
+ throw new PersistenceSerializationError("maxDepth must be a positive safe integer");
39
+ }
40
+ return canonicalize(value, 0, maxDepth, new Set<object>());
41
+ }
42
+
43
+ export function sha256CanonicalJson(value: unknown, maxDepth = 128): string {
44
+ return createHash("sha256").update(canonicalizeJson(value, maxDepth), "utf8").digest("hex");
45
+ }
46
+
47
+ export function checkpointDigest(
48
+ checkpoint: Readonly<Record<string, unknown>>,
49
+ maxDepth = 128,
50
+ ): string {
51
+ const body: Record<string, unknown> = {};
52
+ for (const [key, value] of Object.entries(checkpoint)) {
53
+ if (key !== "digest") body[key] = value;
54
+ }
55
+ return sha256CanonicalJson(body, maxDepth);
56
+ }
57
+
58
+ export function checkpointDigestMatches(
59
+ checkpoint: Readonly<Record<string, unknown>>,
60
+ maxDepth = 128,
61
+ ): boolean {
62
+ return isLowercaseSha256(checkpoint.digest) && checkpoint.digest === checkpointDigest(checkpoint, maxDepth);
63
+ }
64
+
65
+ function canonicalize(
66
+ value: unknown,
67
+ depth: number,
68
+ maxDepth: number,
69
+ ancestors: Set<object>,
70
+ ): string {
71
+ if (depth > maxDepth) {
72
+ throw new PersistenceSerializationError(`JSON value exceeds maximum depth ${maxDepth}`);
73
+ }
74
+ if (value === null) return "null";
75
+
76
+ switch (typeof value) {
77
+ case "boolean":
78
+ return value ? "true" : "false";
79
+ case "number": {
80
+ if (!Number.isFinite(value)) {
81
+ throw new PersistenceSerializationError("JSON numbers must be finite");
82
+ }
83
+ return JSON.stringify(value);
84
+ }
85
+ case "string":
86
+ assertUnicodeScalarString(value);
87
+ return JSON.stringify(value);
88
+ case "object":
89
+ break;
90
+ default:
91
+ throw new PersistenceSerializationError(`unsupported JSON value: ${typeof value}`);
92
+ }
93
+
94
+ if (ancestors.has(value)) throw new PersistenceSerializationError("cyclic JSON value");
95
+ ancestors.add(value);
96
+ try {
97
+ if (Array.isArray(value)) {
98
+ const items: string[] = [];
99
+ for (let index = 0; index < value.length; index++) {
100
+ if (!Object.hasOwn(value, index)) {
101
+ throw new PersistenceSerializationError("sparse arrays are not valid canonical JSON");
102
+ }
103
+ items.push(canonicalize(value[index], depth + 1, maxDepth, ancestors));
104
+ }
105
+ return `[${items.join(",")}]`;
106
+ }
107
+
108
+ const prototype = Object.getPrototypeOf(value);
109
+ if (prototype !== Object.prototype && prototype !== null) {
110
+ throw new PersistenceSerializationError("canonical JSON objects must be plain objects");
111
+ }
112
+ if (Object.getOwnPropertySymbols(value).length > 0) {
113
+ throw new PersistenceSerializationError("symbol keys are not valid canonical JSON");
114
+ }
115
+
116
+ const record = value as Record<string, unknown>;
117
+ const members: string[] = [];
118
+ for (const key of Object.keys(record).sort()) {
119
+ assertUnicodeScalarString(key);
120
+ members.push(
121
+ `${JSON.stringify(key)}:${canonicalize(record[key], depth + 1, maxDepth, ancestors)}`,
122
+ );
123
+ }
124
+ return `{${members.join(",")}}`;
125
+ } finally {
126
+ ancestors.delete(value);
127
+ }
128
+ }
129
+
130
+ function assertUnicodeScalarString(value: string): void {
131
+ for (let index = 0; index < value.length; index++) {
132
+ const unit = value.charCodeAt(index);
133
+ if (unit >= 0xd800 && unit <= 0xdbff) {
134
+ const next = value.charCodeAt(index + 1);
135
+ if (index + 1 >= value.length || next < 0xdc00 || next > 0xdfff) {
136
+ throw new PersistenceSerializationError("strings must not contain lone surrogates");
137
+ }
138
+ index++;
139
+ } else if (unit >= 0xdc00 && unit <= 0xdfff) {
140
+ throw new PersistenceSerializationError("strings must not contain lone surrogates");
141
+ }
142
+ }
143
+ }
144
+
145
+ function isLowercaseSha256(value: unknown): value is string {
146
+ return typeof value === "string" && /^[0-9a-f]{64}$/.test(value);
147
+ }
@@ -0,0 +1,240 @@
1
+ import { isAbsolute } from "node:path";
2
+ import type { SessionRecord, SessionStore } from "../session-store.ts";
3
+ import {
4
+ validateAgentSessionRecord,
5
+ type AgentSessionRecord,
6
+ type AgentSessionStore,
7
+ } from "./registry.ts";
8
+ import {
9
+ scanTranscriptContinuation,
10
+ TranscriptCorruptionError,
11
+ TranscriptIdentityError,
12
+ TranscriptNotFoundError,
13
+ TranscriptUnavailableError,
14
+ } from "./transcript-scanner.ts";
15
+
16
+ export type LegacyRegistryImportStatus =
17
+ | "imported"
18
+ | "already_imported"
19
+ | "conflict"
20
+ | "skipped";
21
+
22
+ export type LegacyRegistryImportReason =
23
+ | "missing_transcript"
24
+ | "invalid_legacy_record"
25
+ | "transcript_unavailable"
26
+ | "transcript_corrupt"
27
+ | "transcript_identity_mismatch"
28
+ | "transcript_requires_recovery"
29
+ | "target_identity_conflict";
30
+
31
+ export interface LegacyRegistryImportEntry {
32
+ readonly agentSessionId: string;
33
+ readonly status: LegacyRegistryImportStatus;
34
+ readonly reason?: LegacyRegistryImportReason;
35
+ readonly detail?: string;
36
+ }
37
+
38
+ export interface LegacyRegistryImportResult {
39
+ readonly entries: readonly LegacyRegistryImportEntry[];
40
+ readonly imported: number;
41
+ readonly alreadyImported: number;
42
+ readonly conflicts: number;
43
+ readonly skipped: number;
44
+ }
45
+
46
+ /**
47
+ * Explicitly import the old file-per-session routing catalog into a v2 registry.
48
+ *
49
+ * A legacy row is importable only after its transcript has a complete v2 continuation
50
+ * boundary. This keeps the old routing catalog from becoming authority for fields it never
51
+ * stored (model, protocol, configuration, activation time, or canonical history).
52
+ */
53
+ export async function importLegacySessionRegistry(
54
+ source: SessionStore,
55
+ target: AgentSessionStore,
56
+ ): Promise<LegacyRegistryImportResult> {
57
+ const legacy = await source.list();
58
+ const entries: LegacyRegistryImportEntry[] = [];
59
+ for (const row of [...legacy].sort((a, b) => a.agentSessionId.localeCompare(b.agentSessionId))) {
60
+ entries.push(await importOne(row, target));
61
+ }
62
+ return Object.freeze({
63
+ entries: Object.freeze(entries.map((entry) => Object.freeze(entry))),
64
+ imported: entries.filter((entry) => entry.status === "imported").length,
65
+ alreadyImported: entries.filter((entry) => entry.status === "already_imported").length,
66
+ conflicts: entries.filter((entry) => entry.status === "conflict").length,
67
+ skipped: entries.filter((entry) => entry.status === "skipped").length,
68
+ });
69
+ }
70
+
71
+ async function importOne(
72
+ legacy: SessionRecord,
73
+ target: AgentSessionStore,
74
+ ): Promise<LegacyRegistryImportEntry> {
75
+ const invalid = validateLegacyRow(legacy);
76
+ if (invalid) return entry(legacy.agentSessionId || "<invalid>", "skipped", "invalid_legacy_record", invalid);
77
+ if (!legacy.transcriptPath) {
78
+ return entry(legacy.agentSessionId, "skipped", "missing_transcript", "legacy row has no transcript path");
79
+ }
80
+
81
+ let candidate: AgentSessionRecord;
82
+ try {
83
+ const scan = await scanTranscriptContinuation(legacy.transcriptPath, {
84
+ agentSessionId: legacy.agentSessionId,
85
+ });
86
+ if (scan.reduction.recovery.kind !== "clean" || scan.reduction.repairs.length > 0) {
87
+ return entry(
88
+ legacy.agentSessionId,
89
+ "skipped",
90
+ "transcript_requires_recovery",
91
+ "transcript must be clean and fully checkpointed before registry import",
92
+ );
93
+ }
94
+ const checkpoint = scan.reduction.checkpoint;
95
+ if (legacy.adapter !== checkpoint.adapterId
96
+ || legacy.mode !== checkpoint.mode
97
+ || legacy.internalSessionId !== checkpoint.internalSessionId) {
98
+ return entry(
99
+ legacy.agentSessionId,
100
+ "conflict",
101
+ "transcript_identity_mismatch",
102
+ "legacy routing fields disagree with transcript continuation authority",
103
+ );
104
+ }
105
+ candidate = recordFromLegacy(legacy, scan);
106
+ } catch (error) {
107
+ if (error instanceof TranscriptIdentityError) {
108
+ return entry(legacy.agentSessionId, "conflict", "transcript_identity_mismatch", error.message);
109
+ }
110
+ if (error instanceof TranscriptNotFoundError) {
111
+ return entry(legacy.agentSessionId, "skipped", "missing_transcript", error.message);
112
+ }
113
+ if (error instanceof TranscriptUnavailableError) {
114
+ return entry(legacy.agentSessionId, "skipped", "transcript_unavailable", error.message);
115
+ }
116
+ if (error instanceof TranscriptCorruptionError) {
117
+ return entry(legacy.agentSessionId, "skipped", "transcript_corrupt", error.message);
118
+ }
119
+ return entry(
120
+ legacy.agentSessionId,
121
+ "skipped",
122
+ "transcript_unavailable",
123
+ error instanceof Error ? error.message : String(error),
124
+ );
125
+ }
126
+
127
+ const existing = await target.getAgentSessionRecord(legacy.agentSessionId);
128
+ if (existing) {
129
+ return sameImportedLineage(existing, candidate)
130
+ ? entry(legacy.agentSessionId, "already_imported")
131
+ : entry(legacy.agentSessionId, "conflict", "target_identity_conflict", "target registry already contains another incarnation");
132
+ }
133
+
134
+ try {
135
+ await target.saveAgentSessionRecord(candidate, {
136
+ expectedRecordRevision: null,
137
+ expectedIncarnationId: null,
138
+ });
139
+ return entry(legacy.agentSessionId, "imported");
140
+ } catch (error) {
141
+ // Resolve a concurrent identical importer as idempotent; never overwrite a winner.
142
+ const winner = await target.getAgentSessionRecord(legacy.agentSessionId);
143
+ if (winner && sameImportedLineage(winner, candidate)) {
144
+ return entry(legacy.agentSessionId, "already_imported");
145
+ }
146
+ return entry(
147
+ legacy.agentSessionId,
148
+ "conflict",
149
+ "target_identity_conflict",
150
+ error instanceof Error ? error.message : String(error),
151
+ );
152
+ }
153
+ }
154
+
155
+ function recordFromLegacy(
156
+ legacy: SessionRecord,
157
+ scan: Awaited<ReturnType<typeof scanTranscriptContinuation>>,
158
+ ): AgentSessionRecord {
159
+ const checkpoint = scan.reduction.checkpoint;
160
+ const header = scan.header;
161
+ const updatedAt = Date.parse(legacy.updatedAt) > Date.parse(checkpoint.updatedAt)
162
+ ? legacy.updatedAt
163
+ : checkpoint.updatedAt;
164
+ const record: AgentSessionRecord = {
165
+ agentSessionId: checkpoint.agentSessionId,
166
+ incarnationId: checkpoint.incarnationId,
167
+ recordRevision: 1,
168
+ checkpoint,
169
+ adapterId: checkpoint.adapterId,
170
+ mode: checkpoint.mode,
171
+ internalSessionId: checkpoint.internalSessionId,
172
+ internalSessionActivatedAt: checkpoint.internalSessionActivatedAt,
173
+ internalSessionHistory: scan.reduction.internalSessionHistory,
174
+ ...(legacy.cwd === undefined ? {} : { cwd: legacy.cwd }),
175
+ ...(legacy.title === undefined ? {} : { title: legacy.title }),
176
+ model: checkpoint.model,
177
+ sessionConfiguration: checkpoint.sessionConfiguration,
178
+ protocol: checkpoint.protocol,
179
+ transcript: {
180
+ path: legacy.transcriptPath!,
181
+ transcriptId: header.transcriptId,
182
+ generation: header.generation,
183
+ preset: header.preset,
184
+ effectivePolicy: header.effectivePolicy,
185
+ effectiveLimits: header.effectiveLimits,
186
+ includeTruncationDigests: header.includeTruncationDigests,
187
+ },
188
+ auditLog: null,
189
+ createdAt: legacy.createdAt,
190
+ updatedAt,
191
+ lastOpenedAt: updatedAt,
192
+ };
193
+ validateAgentSessionRecord(record);
194
+ return record;
195
+ }
196
+
197
+ function sameImportedLineage(existing: AgentSessionRecord, candidate: AgentSessionRecord): boolean {
198
+ return existing.agentSessionId === candidate.agentSessionId
199
+ && existing.incarnationId === candidate.incarnationId
200
+ && existing.transcript?.transcriptId === candidate.transcript?.transcriptId
201
+ && existing.transcript?.generation === candidate.transcript?.generation;
202
+ }
203
+
204
+ function validateLegacyRow(row: SessionRecord): string | null {
205
+ if (!row || typeof row !== "object") return "legacy row must be an object";
206
+ if (typeof row.agentSessionId !== "string" || !row.agentSessionId.trim()) return "agentSessionId is invalid";
207
+ if (typeof row.adapter !== "string" || !row.adapter.trim()) return "adapter is invalid";
208
+ if (row.mode !== "normal" && row.mode !== "degraded") return "mode is invalid";
209
+ if (row.internalSessionId !== null && (typeof row.internalSessionId !== "string" || !row.internalSessionId.trim())) {
210
+ return "internalSessionId is invalid";
211
+ }
212
+ if (row.transcriptPath !== undefined && (typeof row.transcriptPath !== "string" || !isAbsolute(row.transcriptPath))) {
213
+ return "transcriptPath must be absolute";
214
+ }
215
+ if (row.cwd !== undefined && (typeof row.cwd !== "string" || !row.cwd)) return "cwd is invalid";
216
+ if (row.title !== undefined && (typeof row.title !== "string" || !row.title)) return "title is invalid";
217
+ if (!isIso(row.createdAt) || !isIso(row.updatedAt)) return "timestamps are invalid";
218
+ if (Date.parse(row.createdAt) > Date.parse(row.updatedAt)) return "createdAt is after updatedAt";
219
+ return null;
220
+ }
221
+
222
+ function isIso(value: unknown): value is string {
223
+ if (typeof value !== "string") return false;
224
+ const parsed = Date.parse(value);
225
+ return Number.isFinite(parsed) && new Date(parsed).toISOString() === value;
226
+ }
227
+
228
+ function entry(
229
+ agentSessionId: string,
230
+ status: LegacyRegistryImportStatus,
231
+ reason?: LegacyRegistryImportReason,
232
+ detail?: string,
233
+ ): LegacyRegistryImportEntry {
234
+ return {
235
+ agentSessionId,
236
+ status,
237
+ ...(reason === undefined ? {} : { reason }),
238
+ ...(detail === undefined ? {} : { detail }),
239
+ };
240
+ }
@@ -0,0 +1,81 @@
1
+ import type { AgentSessionCheckpoint } from "./checkpoint.ts";
2
+ import {
3
+ SessionMaintenanceInProgressError,
4
+ type AgentSessionRecord,
5
+ type AgentSessionStore,
6
+ } from "./registry.ts";
7
+ import { scanTranscriptContinuation } from "./transcript-scanner.ts";
8
+ import { ManagedAgentSessionAuthorityConflictError } from "./managed-load.ts";
9
+
10
+ export interface GetAgentSessionCheckpointOptions {
11
+ readonly includeDeleted?: boolean;
12
+ readonly source?: "resolved" | "registry_projection";
13
+ }
14
+
15
+ export interface ResolvedAgentSessionCheckpoint {
16
+ readonly checkpoint: AgentSessionCheckpoint;
17
+ readonly source: "transcript" | "registry_projection";
18
+ readonly authoritative: boolean;
19
+ }
20
+
21
+ /** Resolve continuation authority without starting a harness or acquiring writer ownership. */
22
+ export async function getManagedAgentSessionCheckpoint(
23
+ store: AgentSessionStore,
24
+ agentSessionId: string,
25
+ options: GetAgentSessionCheckpointOptions = {},
26
+ ): Promise<ResolvedAgentSessionCheckpoint | null> {
27
+ const [record, maintenance] = await Promise.all([
28
+ store.getAgentSessionRecord(agentSessionId),
29
+ store.getMaintenance(agentSessionId),
30
+ ]);
31
+ if (!record || (record.deletion && !options.includeDeleted)) return null;
32
+ if (maintenance) throw new SessionMaintenanceInProgressError(agentSessionId);
33
+ if (options.source === "registry_projection") {
34
+ return frozen(record.checkpoint, "registry_projection", record.transcript === null);
35
+ }
36
+ if (!availableTranscript(record)) {
37
+ return frozen(record.checkpoint, "registry_projection", record.transcript === null);
38
+ }
39
+
40
+ const scan = await scanTranscriptContinuation(record.transcript.path, {
41
+ agentSessionId,
42
+ transcriptId: record.transcript.transcriptId,
43
+ generation: record.transcript.generation,
44
+ });
45
+ assertAuthority(record, scan.reduction.checkpoint);
46
+ return frozen(scan.reduction.checkpoint, "transcript", true);
47
+ }
48
+
49
+ function availableTranscript(
50
+ record: AgentSessionRecord,
51
+ ): record is AgentSessionRecord & { readonly transcript: NonNullable<AgentSessionRecord["transcript"]> } {
52
+ return record.transcript !== null && record.deletion?.transcriptDeletedAt === undefined;
53
+ }
54
+
55
+ function assertAuthority(record: AgentSessionRecord, checkpoint: AgentSessionCheckpoint): void {
56
+ if (checkpoint.agentSessionId !== record.agentSessionId
57
+ || checkpoint.incarnationId !== record.incarnationId) {
58
+ throw new ManagedAgentSessionAuthorityConflictError(
59
+ "registry and transcript identify different logical session incarnations",
60
+ );
61
+ }
62
+ if (record.checkpoint.stateRevision > checkpoint.stateRevision) {
63
+ throw new ManagedAgentSessionAuthorityConflictError(
64
+ "registry checkpoint is newer than transcript authority and cannot be resolved offline",
65
+ );
66
+ }
67
+ if (record.checkpoint.stateRevision === checkpoint.stateRevision
68
+ && record.checkpoint.digest !== checkpoint.digest) {
69
+ throw new ManagedAgentSessionAuthorityConflictError(
70
+ "registry and transcript checkpoints disagree at the same revision",
71
+ );
72
+ }
73
+ }
74
+
75
+ function frozen(
76
+ checkpoint: AgentSessionCheckpoint,
77
+ source: ResolvedAgentSessionCheckpoint["source"],
78
+ authoritative: boolean,
79
+ ): ResolvedAgentSessionCheckpoint {
80
+ return Object.freeze({ checkpoint: structuredClone(checkpoint), source, authoritative });
81
+ }