@tansr/protocol 0.2.0 → 0.3.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.
@@ -0,0 +1,568 @@
1
+ /** Generated by scripts/sdk2/generate-terminal-wire.mjs. Schema SHA256 8c84ad5ba1461207dd0d9f11871989aeb8b971f6557c39ca4e06a690e191f9d9. */
2
+ export declare const PERSISTENCE_CUSTODY_CONTRACT: "persistence-custody-handoff-v1";
3
+ export declare const PERSISTENCE_CUSTODY_CAPABILITY: "persistence-custody-handoff-v1";
4
+ export declare const PERSISTENCE_CUSTODY_SCHEMA_SHA256: "8c84ad5ba1461207dd0d9f11871989aeb8b971f6557c39ca4e06a690e191f9d9";
5
+ export declare const PERSISTENCE_CUSTODY_SCHEMA_REVISION: "2026-10-21.v1";
6
+ export declare const PERSISTENCE_CUSTODY_TOOL_NAME: "TansrPersistenceCustodyHandoffV1";
7
+ export declare const PERSISTENCE_CUSTODY_DEFAULT_MIGRATION_BUDGET: Readonly<{
8
+ readonly bytes: 1073741824;
9
+ readonly objects: 1048576;
10
+ }>;
11
+ export declare const PERSISTENCE_CUSTODY_TOOL_DEFINITION_SHA256: "7f3b94cb801bf29be071674cdab0450855e70c55ab44bea27508c30dfbebb5e7";
12
+ export type PersistenceCustodyIdentity = {
13
+ readonly applicationScopeId: PersistenceCustodyId;
14
+ readonly endUserId: PersistenceCustodyLegacyId;
15
+ readonly sourceId: PersistenceCustodyMemoryIdentifier;
16
+ readonly sourceGeneration: PersistenceCustodySequence;
17
+ readonly domainKey: PersistenceCustodyMemoryIdentifier;
18
+ };
19
+ export type PersistenceCustodyId = string;
20
+ export type PersistenceCustodyLegacyId = string;
21
+ export type PersistenceCustodyMemoryIdentifier = string;
22
+ export type PersistenceCustodySequence = string;
23
+ export type PersistenceCustodyRoot = {
24
+ readonly commitRoot: PersistenceCustodyDigest;
25
+ readonly generation: PersistenceCustodySequence;
26
+ readonly body: PersistenceCustodyBodyPlan;
27
+ readonly index: PersistenceCustodyIndexRoot;
28
+ };
29
+ export type PersistenceCustodyDigest = string;
30
+ export type PersistenceCustodyBodyPlan = {
31
+ readonly byteLength: number;
32
+ readonly sha256: PersistenceCustodyDigest;
33
+ readonly blockCount: number;
34
+ readonly pageHashes: readonly (PersistenceCustodyDigest)[];
35
+ };
36
+ export type PersistenceCustodyIndexRoot = {
37
+ readonly root: PersistenceCustodyDigest;
38
+ readonly count: PersistenceCustodySequence;
39
+ };
40
+ export type PersistenceCustodyCapacityLimits = {
41
+ readonly activeTransfers: number;
42
+ readonly stagingBytes: number;
43
+ readonly receiptEntries: number;
44
+ readonly transferFacts: number;
45
+ readonly objects: number;
46
+ readonly retainedBytes: number;
47
+ };
48
+ export type PersistenceCustodyCapacityUsed = {
49
+ readonly activeTransfers: number;
50
+ readonly stagingBytes: number;
51
+ readonly receiptEntries: number;
52
+ readonly transferFacts: number;
53
+ readonly objects: number;
54
+ readonly retainedBytes: number;
55
+ readonly reservedBytes: number;
56
+ readonly reservedObjects: number;
57
+ readonly reservedReceiptEntries: number;
58
+ };
59
+ export type PersistenceCustodyEntry = {
60
+ readonly primaryKey: PersistenceCustodyDigest;
61
+ readonly secondaryKey: PersistenceCustodyDigest;
62
+ readonly value: PersistenceCustodyRef;
63
+ };
64
+ export type PersistenceCustodyRef = {
65
+ readonly sha256: PersistenceCustodyDigest;
66
+ readonly byteLength: number;
67
+ };
68
+ export type PersistenceCustodyBeginRequest = {
69
+ readonly contract: PersistenceCustodyOriginalContract;
70
+ readonly sourceId: PersistenceCustodyMemoryIdentifier;
71
+ readonly sourceGeneration: PersistenceCustodySequence;
72
+ readonly domainKey: PersistenceCustodyMemoryIdentifier;
73
+ readonly action: "begin";
74
+ readonly transferId: PersistenceCustodyId;
75
+ readonly intentSha256: PersistenceCustodyDigest;
76
+ readonly expected: PersistenceCustodyExpected;
77
+ readonly body: PersistenceCustodyBodyPlan;
78
+ readonly index: PersistenceCustodyIndexPlan;
79
+ readonly declared: PersistenceCustodyDeclared;
80
+ };
81
+ export type PersistenceCustodyContract = "persistence-custody-handoff-v1";
82
+ export type PersistenceCustodyExpected = ({
83
+ readonly commitRoot: PersistenceCustodyDigest;
84
+ readonly generation: PersistenceCustodySequence;
85
+ readonly bodyEtag: PersistenceCustodyDigest;
86
+ readonly indexRoot: PersistenceCustodyDigest;
87
+ readonly indexCount: PersistenceCustodySequence;
88
+ }) | (null);
89
+ export type PersistenceCustodyIndexPlan = {
90
+ readonly entryCount: number;
91
+ readonly addedCount: number;
92
+ readonly pageHashes: readonly (PersistenceCustodyDigest)[];
93
+ };
94
+ export type PersistenceCustodyDeclared = {
95
+ readonly objects: number;
96
+ readonly bytes: number;
97
+ };
98
+ export type PersistenceCustodyOwner = {
99
+ readonly scope: PersistenceCustodyScope;
100
+ readonly sessionId: PersistenceCustodyLegacyId;
101
+ readonly binding: PersistenceCustodyExecutionBinding;
102
+ };
103
+ export type PersistenceCustodyScope = {
104
+ readonly applicationScopeId: PersistenceCustodyId;
105
+ readonly endUserId: PersistenceCustodyLegacyId;
106
+ readonly authorizationRevision: PersistenceCustodySequence;
107
+ };
108
+ export type PersistenceCustodyExecutionBinding = {
109
+ readonly bindingId: PersistenceCustodyId;
110
+ readonly revision: PersistenceCustodySequence;
111
+ readonly target: PersistenceCustodyExecutionTarget;
112
+ };
113
+ export type PersistenceCustodyExecutionTarget = {
114
+ readonly executorId: PersistenceCustodyId;
115
+ readonly connectionId: PersistenceCustodyId;
116
+ readonly connectionRevision: PersistenceCustodySequence;
117
+ readonly workspaceId: PersistenceCustodyId;
118
+ readonly workspaceRevision: PersistenceCustodySequence;
119
+ readonly interpreter?: PersistenceCustodyExecutionInterpreter;
120
+ };
121
+ export type PersistenceCustodyExecutionInterpreter = {
122
+ readonly id: PersistenceCustodyId;
123
+ readonly revision: PersistenceCustodyId;
124
+ readonly hostShell: "posix" | "powershell";
125
+ };
126
+ export type PersistenceCustodyTransfer = (PersistenceCustodyUnknownTransfer) | (PersistenceCustodyStagingTransfer) | (PersistenceCustodyCommittedTransfer) | (PersistenceCustodyRejectedTransfer);
127
+ export type PersistenceCustodyUnknownTransfer = {
128
+ readonly transferId: PersistenceCustodyId;
129
+ readonly intentSha256: PersistenceCustodyDigest;
130
+ readonly status: "unknown";
131
+ readonly progress: null;
132
+ readonly result: null;
133
+ readonly rejection: null;
134
+ };
135
+ export type PersistenceCustodyStagingTransfer = {
136
+ readonly transferId: PersistenceCustodyId;
137
+ readonly intentSha256: PersistenceCustodyDigest;
138
+ readonly status: "staging";
139
+ readonly progress: PersistenceCustodyProgress;
140
+ readonly result: null;
141
+ readonly rejection: null;
142
+ };
143
+ export type PersistenceCustodyProgress = {
144
+ readonly pagesReady: string;
145
+ readonly bodyReady: string;
146
+ readonly valuesReady: string;
147
+ readonly receivedBytes: number;
148
+ };
149
+ export type PersistenceCustodyCommittedTransfer = {
150
+ readonly transferId: PersistenceCustodyId;
151
+ readonly intentSha256: PersistenceCustodyDigest;
152
+ readonly status: "committed";
153
+ readonly progress: null;
154
+ readonly result: PersistenceCustodyRoot;
155
+ readonly rejection: null;
156
+ };
157
+ export type PersistenceCustodyRejectedTransfer = {
158
+ readonly transferId: PersistenceCustodyId;
159
+ readonly intentSha256: PersistenceCustodyDigest;
160
+ readonly status: "rejected";
161
+ readonly progress: null;
162
+ readonly result: null;
163
+ readonly rejection: PersistenceCustodyRejection;
164
+ };
165
+ export type PersistenceCustodyRejection = {
166
+ readonly code: "revision_conflict" | "request_conflict" | "invalid_request" | "integrity_mismatch";
167
+ readonly observedRoot: (PersistenceCustodyRoot) | (null);
168
+ };
169
+ export type PersistenceCustodyOriginalContract = "terminal-persistence-v1";
170
+ export type PersistenceCustodySchemaRevision = "2026-10-21.v1";
171
+ export type PersistenceCustodyCapability = "persistence-custody-handoff-v1";
172
+ export type PersistenceCustodyLimits = {
173
+ readonly maxControlBytes: 32768;
174
+ readonly maxObjectChunkBytes: 12288;
175
+ readonly maxPageRecords: 32;
176
+ readonly maxReceiptEntries: 1048576;
177
+ readonly maxTransferFacts: 262144;
178
+ readonly maxRetainedBytes: 1073741824;
179
+ readonly maxTransferMetadataBytes: 524288;
180
+ };
181
+ export type PersistenceCustodyMode = "terminal" | "cloud";
182
+ export type PersistenceCustodyCustody = {
183
+ readonly custodyId: PersistenceCustodyId;
184
+ readonly custodyRevision: PersistenceCustodySequence;
185
+ readonly mode: PersistenceCustodyMode;
186
+ };
187
+ export type PersistenceCustodyDestination = {
188
+ readonly custodyId: PersistenceCustodyId;
189
+ readonly mode: PersistenceCustodyMode;
190
+ };
191
+ export type PersistenceCustodyObjectKind = "body-block" | "body-page" | "index-page" | "receipt-value" | "custody-control" | "custody-transfer" | "legacy-control" | "legacy-file";
192
+ export type PersistenceCustodyObjectRef = {
193
+ readonly kind: PersistenceCustodyObjectKind;
194
+ readonly sha256: PersistenceCustodyDigest;
195
+ readonly byteLength: number;
196
+ };
197
+ export type PersistenceCustodyControlState = {
198
+ readonly format: "terminal-persistence-control-v1";
199
+ readonly capacity: PersistenceCustodyCapacityUsed;
200
+ readonly limits: PersistenceCustodyCapacityLimits;
201
+ };
202
+ export type PersistenceCustodyTransferObject = {
203
+ readonly kind: "body-block" | "body-page" | "index-page" | "receipt-value";
204
+ readonly sha256: PersistenceCustodyDigest;
205
+ readonly byteLength: number;
206
+ };
207
+ export type PersistenceCustodyTransferObjects = readonly (PersistenceCustodyTransferObject)[];
208
+ export type PersistenceCustodyPersistedTransfer = (PersistenceCustodyStagingTransfer) | (PersistenceCustodyCommittedTransfer) | (PersistenceCustodyRejectedTransfer);
209
+ export type PersistenceCustodyTransferMetadata = {
210
+ readonly begin: PersistenceCustodyBeginRequest;
211
+ readonly owner: PersistenceCustodyOwner;
212
+ readonly baseRoot: (PersistenceCustodyRoot) | (null);
213
+ readonly transfer: PersistenceCustodyPersistedTransfer;
214
+ readonly received: PersistenceCustodyTransferObjects;
215
+ readonly reused: PersistenceCustodyTransferObjects;
216
+ readonly reservedBytes: number;
217
+ readonly reservedObjects: number;
218
+ readonly reservedEntries: number;
219
+ readonly stagingBytes: number;
220
+ };
221
+ export type PersistenceCustodyRootRecord = {
222
+ readonly kind: "root";
223
+ readonly root: (PersistenceCustodyRoot) | (null);
224
+ readonly controlRef: PersistenceCustodyObjectRef;
225
+ };
226
+ export type PersistenceCustodyReceiptIndexRecord = {
227
+ readonly kind: "receipt-index";
228
+ readonly ordinal: PersistenceCustodySequence;
229
+ readonly entry: PersistenceCustodyEntry;
230
+ };
231
+ export type PersistenceCustodyTransferRecord = {
232
+ readonly kind: "transfer";
233
+ readonly transferId: PersistenceCustodyId;
234
+ readonly intentSha256: PersistenceCustodyDigest;
235
+ readonly status: "staging" | "committed" | "rejected";
236
+ readonly metadataRef: PersistenceCustodyObjectRef;
237
+ };
238
+ export type PersistenceCustodyObjectRecord = {
239
+ readonly kind: "object";
240
+ readonly object: PersistenceCustodyObjectRef;
241
+ };
242
+ export type PersistenceCustodyLegacyDomain = "session" | "commands" | "budget" | "events" | "capture" | "rollback" | "deletion";
243
+ export type PersistenceCustodyLegacyCodec = "tansr-journal-v1" | "sdk2-host-commands-v1" | "sdk2-host-budget-v1" | "sdk2-events-v1" | "sdk2-spool-v1" | "sdk2-spool-v2" | "sdk2-offload-rollback-v1";
244
+ export type PersistenceCustodyLegacyFileRole = "session-meta" | "journal" | "manifest" | "segment" | "attachment" | "checkpoint" | "family-contract" | "session-index" | "rollback-import" | "commands-database" | "budget-database" | "events-database" | "capture-database" | "rollback-receipt" | "deletion-tombstone";
245
+ export type PersistenceCustodyLegacyTable = "meta" | "journal" | "manifest" | "segment" | "attachment" | "checkpoint" | "host_command_meta" | "host_command" | "budget_meta" | "budget_catalog" | "budget_claim" | "budget_counter" | "budget_claim_physical" | "event_meta" | "event_stream" | "event_row" | "spool_meta" | "capture_ops" | "entries" | "holds" | "rollback" | "tombstone";
246
+ export type PersistenceCustodyLegacySqlCell = ({
247
+ readonly type: "text";
248
+ readonly value: string;
249
+ }) | ({
250
+ readonly type: "integer";
251
+ readonly decimal: string;
252
+ }) | ({
253
+ readonly type: "blob";
254
+ readonly base64: string;
255
+ }) | ({
256
+ readonly type: "null";
257
+ });
258
+ export type PersistenceCustodyLegacyControlRecord = {
259
+ readonly kind: "legacy-control";
260
+ readonly domain: PersistenceCustodyLegacyDomain;
261
+ readonly codec: PersistenceCustodyLegacyCodec;
262
+ readonly relativePath: string;
263
+ readonly table: PersistenceCustodyLegacyTable;
264
+ readonly originalKey: readonly (PersistenceCustodyLegacySqlCell)[];
265
+ readonly originalDigest: (PersistenceCustodyDigest) | (null);
266
+ readonly state: "settled" | "pending" | "deleted";
267
+ readonly payload: PersistenceCustodyObjectRef;
268
+ };
269
+ export type PersistenceCustodyLegacyFileRecord = {
270
+ readonly kind: "legacy-file";
271
+ readonly role: PersistenceCustodyLegacyFileRole;
272
+ readonly relativePath: string;
273
+ readonly payload: PersistenceCustodyObjectRef;
274
+ };
275
+ export type PersistenceCustodyLegacyRootRecord = {
276
+ readonly kind: "legacy-root";
277
+ readonly sourceRootId: PersistenceCustodyId;
278
+ readonly stopProofId: PersistenceCustodyId;
279
+ readonly writerFence: PersistenceCustodySequence;
280
+ readonly inventoryFormat: "legacy-serve-v1";
281
+ readonly domains: readonly (PersistenceCustodyLegacyDomain)[];
282
+ };
283
+ export type PersistenceCustodyRecord = (PersistenceCustodyRootRecord) | (PersistenceCustodyReceiptIndexRecord) | (PersistenceCustodyTransferRecord) | (PersistenceCustodyObjectRecord) | (PersistenceCustodyLegacyControlRecord) | (PersistenceCustodyLegacyFileRecord) | (PersistenceCustodyLegacyRootRecord);
284
+ export type PersistenceCustodyMigrationBudget = {
285
+ readonly bytes: number;
286
+ readonly objects: number;
287
+ };
288
+ export type PersistenceCustodyRootProof = {
289
+ readonly originFormat: "terminal-persistence-v1" | "legacy-serve-v1";
290
+ readonly fixedRoot: PersistenceCustodyDigest;
291
+ readonly originalCommitRoot: (PersistenceCustodyDigest) | (null);
292
+ readonly indexRoot: (PersistenceCustodyDigest) | (null);
293
+ readonly indexCount: PersistenceCustodySequence;
294
+ readonly inventoryDigest: PersistenceCustodyDigest;
295
+ readonly records: number;
296
+ readonly objects: number;
297
+ readonly bytes: number;
298
+ };
299
+ export type PersistenceCustodyCursor = {
300
+ readonly operationId: PersistenceCustodyId;
301
+ readonly intentSha256: PersistenceCustodyDigest;
302
+ readonly fixedRoot: PersistenceCustodyDigest;
303
+ readonly inventoryDigest: PersistenceCustodyDigest;
304
+ readonly index: PersistenceCustodySequence;
305
+ readonly previousDigest: PersistenceCustodyDigest;
306
+ };
307
+ export type PersistenceCustodyPage = {
308
+ readonly index: PersistenceCustodySequence;
309
+ readonly previousDigest: PersistenceCustodyDigest;
310
+ readonly sha256: PersistenceCustodyDigest;
311
+ readonly records: readonly (PersistenceCustodyRecord)[];
312
+ readonly complete: boolean;
313
+ };
314
+ export type PersistenceCustodyObjectChunk = {
315
+ readonly object: PersistenceCustodyObjectRef;
316
+ readonly offset: number;
317
+ readonly byteLength: number;
318
+ readonly base64: string;
319
+ readonly payloadDigest: PersistenceCustodyDigest;
320
+ };
321
+ export type PersistenceCustodyPhase = "prepared" | "staged" | "verified" | "published" | "aborted";
322
+ export type PersistenceCustodyTicket = {
323
+ readonly operationId: PersistenceCustodyId;
324
+ readonly intentSha256: PersistenceCustodyDigest;
325
+ readonly identity: PersistenceCustodyIdentity;
326
+ readonly phase: PersistenceCustodyPhase;
327
+ readonly source: PersistenceCustodyCustody;
328
+ readonly destination: PersistenceCustodyDestination;
329
+ readonly writerFence: PersistenceCustodySequence;
330
+ readonly proof: PersistenceCustodyRootProof;
331
+ readonly selectedCustody: PersistenceCustodyCustody;
332
+ };
333
+ export type PersistenceCustodyWriterClaim = {
334
+ readonly operationId: PersistenceCustodyDigest;
335
+ readonly intentSha256: PersistenceCustodyDigest;
336
+ readonly claimId: PersistenceCustodyId;
337
+ readonly writerFence: PersistenceCustodySequence;
338
+ readonly status: "active" | "unknown" | "settled";
339
+ readonly selectedCustody: PersistenceCustodyCustody;
340
+ readonly responseDigest: (PersistenceCustodyDigest) | (null);
341
+ };
342
+ export type PersistenceCustodyWriterSettlement = ({
343
+ readonly state: "committed";
344
+ readonly responseDigest: PersistenceCustodyDigest;
345
+ }) | ({
346
+ readonly state: "rolled-back";
347
+ });
348
+ export type PersistenceCustodyPrepareRequest = {
349
+ readonly contract: PersistenceCustodyContract;
350
+ readonly identity: PersistenceCustodyIdentity;
351
+ readonly operationId: PersistenceCustodyId;
352
+ readonly intentSha256: PersistenceCustodyDigest;
353
+ readonly action: "prepare";
354
+ readonly source: PersistenceCustodyCustody;
355
+ readonly destination: PersistenceCustodyDestination;
356
+ readonly expectedWriterFence: PersistenceCustodySequence;
357
+ readonly expectedRoot: (PersistenceCustodyDigest) | (null);
358
+ };
359
+ export type PersistenceCustodyPrepareResponse = {
360
+ readonly contract: PersistenceCustodyContract;
361
+ readonly identity: PersistenceCustodyIdentity;
362
+ readonly operationId: PersistenceCustodyId;
363
+ readonly intentSha256: PersistenceCustodyDigest;
364
+ readonly action: "prepare";
365
+ readonly ticket: PersistenceCustodyTicket;
366
+ };
367
+ export type PersistenceCustodyExportPageRequest = {
368
+ readonly contract: PersistenceCustodyContract;
369
+ readonly identity: PersistenceCustodyIdentity;
370
+ readonly operationId: PersistenceCustodyId;
371
+ readonly intentSha256: PersistenceCustodyDigest;
372
+ readonly action: "export-page";
373
+ readonly cursor: (PersistenceCustodyCursor) | (null);
374
+ readonly limit: number;
375
+ };
376
+ export type PersistenceCustodyExportPageResponse = {
377
+ readonly contract: PersistenceCustodyContract;
378
+ readonly identity: PersistenceCustodyIdentity;
379
+ readonly operationId: PersistenceCustodyId;
380
+ readonly intentSha256: PersistenceCustodyDigest;
381
+ readonly action: "export-page";
382
+ readonly proof: PersistenceCustodyRootProof;
383
+ readonly page: PersistenceCustodyPage;
384
+ readonly nextCursor: (PersistenceCustodyCursor) | (null);
385
+ };
386
+ export type PersistenceCustodyExportObjectRequest = {
387
+ readonly contract: PersistenceCustodyContract;
388
+ readonly identity: PersistenceCustodyIdentity;
389
+ readonly operationId: PersistenceCustodyId;
390
+ readonly intentSha256: PersistenceCustodyDigest;
391
+ readonly action: "export-object";
392
+ readonly object: PersistenceCustodyObjectRef;
393
+ readonly offset: number;
394
+ readonly length: number;
395
+ };
396
+ export type PersistenceCustodyExportObjectResponse = {
397
+ readonly contract: PersistenceCustodyContract;
398
+ readonly identity: PersistenceCustodyIdentity;
399
+ readonly operationId: PersistenceCustodyId;
400
+ readonly intentSha256: PersistenceCustodyDigest;
401
+ readonly action: "export-object";
402
+ readonly chunk: PersistenceCustodyObjectChunk;
403
+ };
404
+ export type PersistenceCustodyImportPageRequest = {
405
+ readonly contract: PersistenceCustodyContract;
406
+ readonly identity: PersistenceCustodyIdentity;
407
+ readonly operationId: PersistenceCustodyId;
408
+ readonly intentSha256: PersistenceCustodyDigest;
409
+ readonly action: "import-page";
410
+ readonly proof: PersistenceCustodyRootProof;
411
+ readonly page: PersistenceCustodyPage;
412
+ };
413
+ export type PersistenceCustodyImportPageResponse = {
414
+ readonly contract: PersistenceCustodyContract;
415
+ readonly identity: PersistenceCustodyIdentity;
416
+ readonly operationId: PersistenceCustodyId;
417
+ readonly intentSha256: PersistenceCustodyDigest;
418
+ readonly action: "import-page";
419
+ readonly ticket: PersistenceCustodyTicket;
420
+ readonly pageDigest: PersistenceCustodyDigest;
421
+ };
422
+ export type PersistenceCustodyImportObjectRequest = {
423
+ readonly contract: PersistenceCustodyContract;
424
+ readonly identity: PersistenceCustodyIdentity;
425
+ readonly operationId: PersistenceCustodyId;
426
+ readonly intentSha256: PersistenceCustodyDigest;
427
+ readonly action: "import-object";
428
+ readonly chunk: PersistenceCustodyObjectChunk;
429
+ };
430
+ export type PersistenceCustodyImportObjectResponse = {
431
+ readonly contract: PersistenceCustodyContract;
432
+ readonly identity: PersistenceCustodyIdentity;
433
+ readonly operationId: PersistenceCustodyId;
434
+ readonly intentSha256: PersistenceCustodyDigest;
435
+ readonly action: "import-object";
436
+ readonly ticket: PersistenceCustodyTicket;
437
+ readonly object: PersistenceCustodyObjectRef;
438
+ readonly nextOffset: number;
439
+ };
440
+ export type PersistenceCustodyVerifyRequest = {
441
+ readonly contract: PersistenceCustodyContract;
442
+ readonly identity: PersistenceCustodyIdentity;
443
+ readonly operationId: PersistenceCustodyId;
444
+ readonly intentSha256: PersistenceCustodyDigest;
445
+ readonly action: "verify";
446
+ readonly proof: PersistenceCustodyRootProof;
447
+ };
448
+ export type PersistenceCustodyVerifyResponse = {
449
+ readonly contract: PersistenceCustodyContract;
450
+ readonly identity: PersistenceCustodyIdentity;
451
+ readonly operationId: PersistenceCustodyId;
452
+ readonly intentSha256: PersistenceCustodyDigest;
453
+ readonly action: "verify";
454
+ readonly ticket: PersistenceCustodyTicket;
455
+ };
456
+ export type PersistenceCustodyCutoverRequest = {
457
+ readonly contract: PersistenceCustodyContract;
458
+ readonly identity: PersistenceCustodyIdentity;
459
+ readonly operationId: PersistenceCustodyId;
460
+ readonly intentSha256: PersistenceCustodyDigest;
461
+ readonly action: "cutover";
462
+ readonly proof: PersistenceCustodyRootProof;
463
+ readonly expectedWriterFence: PersistenceCustodySequence;
464
+ readonly expectedCustodyRevision: PersistenceCustodySequence;
465
+ };
466
+ export type PersistenceCustodyCutoverResponse = {
467
+ readonly contract: PersistenceCustodyContract;
468
+ readonly identity: PersistenceCustodyIdentity;
469
+ readonly operationId: PersistenceCustodyId;
470
+ readonly intentSha256: PersistenceCustodyDigest;
471
+ readonly action: "cutover";
472
+ readonly ticket: PersistenceCustodyTicket;
473
+ };
474
+ export type PersistenceCustodyQueryRequest = {
475
+ readonly contract: PersistenceCustodyContract;
476
+ readonly identity: PersistenceCustodyIdentity;
477
+ readonly operationId: PersistenceCustodyId;
478
+ readonly intentSha256: PersistenceCustodyDigest;
479
+ readonly action: "query";
480
+ };
481
+ export type PersistenceCustodyQueryResponse = {
482
+ readonly contract: PersistenceCustodyContract;
483
+ readonly identity: PersistenceCustodyIdentity;
484
+ readonly operationId: PersistenceCustodyId;
485
+ readonly intentSha256: PersistenceCustodyDigest;
486
+ readonly action: "query";
487
+ readonly preparing: boolean;
488
+ readonly ticket: (PersistenceCustodyTicket) | (null);
489
+ };
490
+ export type PersistenceCustodyAbortRequest = {
491
+ readonly contract: PersistenceCustodyContract;
492
+ readonly identity: PersistenceCustodyIdentity;
493
+ readonly operationId: PersistenceCustodyId;
494
+ readonly intentSha256: PersistenceCustodyDigest;
495
+ readonly action: "abort";
496
+ readonly expectedWriterFence: PersistenceCustodySequence;
497
+ readonly expectedCustodyRevision: PersistenceCustodySequence;
498
+ };
499
+ export type PersistenceCustodyAbortResponse = {
500
+ readonly contract: PersistenceCustodyContract;
501
+ readonly identity: PersistenceCustodyIdentity;
502
+ readonly operationId: PersistenceCustodyId;
503
+ readonly intentSha256: PersistenceCustodyDigest;
504
+ readonly action: "abort";
505
+ readonly ticket: PersistenceCustodyTicket;
506
+ };
507
+ export type PersistenceCustodyWriterClaimRequest = {
508
+ readonly contract: PersistenceCustodyContract;
509
+ readonly identity: PersistenceCustodyIdentity;
510
+ readonly operationId: PersistenceCustodyDigest;
511
+ readonly intentSha256: PersistenceCustodyDigest;
512
+ readonly action: "writer-claim";
513
+ readonly custody: PersistenceCustodyCustody;
514
+ readonly expectedWriterFence: PersistenceCustodySequence;
515
+ };
516
+ export type PersistenceCustodyWriterClaimResponse = {
517
+ readonly contract: PersistenceCustodyContract;
518
+ readonly identity: PersistenceCustodyIdentity;
519
+ readonly operationId: PersistenceCustodyDigest;
520
+ readonly intentSha256: PersistenceCustodyDigest;
521
+ readonly action: "writer-claim";
522
+ readonly claim: PersistenceCustodyWriterClaim;
523
+ };
524
+ export type PersistenceCustodyWriterQueryRequest = {
525
+ readonly contract: PersistenceCustodyContract;
526
+ readonly identity: PersistenceCustodyIdentity;
527
+ readonly operationId: PersistenceCustodyDigest;
528
+ readonly intentSha256: PersistenceCustodyDigest;
529
+ readonly action: "writer-query";
530
+ readonly custody: PersistenceCustodyCustody;
531
+ };
532
+ export type PersistenceCustodyWriterQueryResponse = {
533
+ readonly contract: PersistenceCustodyContract;
534
+ readonly identity: PersistenceCustodyIdentity;
535
+ readonly operationId: PersistenceCustodyDigest;
536
+ readonly intentSha256: PersistenceCustodyDigest;
537
+ readonly action: "writer-query";
538
+ readonly claim: (PersistenceCustodyWriterClaim) | (null);
539
+ };
540
+ export type PersistenceCustodyWriterFinishRequest = {
541
+ readonly contract: PersistenceCustodyContract;
542
+ readonly identity: PersistenceCustodyIdentity;
543
+ readonly operationId: PersistenceCustodyDigest;
544
+ readonly intentSha256: PersistenceCustodyDigest;
545
+ readonly action: "writer-finish";
546
+ readonly claimId: PersistenceCustodyId;
547
+ readonly custody: PersistenceCustodyCustody;
548
+ readonly writerFence: PersistenceCustodySequence;
549
+ readonly settlement: PersistenceCustodyWriterSettlement;
550
+ };
551
+ export type PersistenceCustodyWriterFinishResponse = {
552
+ readonly contract: PersistenceCustodyContract;
553
+ readonly identity: PersistenceCustodyIdentity;
554
+ readonly operationId: PersistenceCustodyDigest;
555
+ readonly intentSha256: PersistenceCustodyDigest;
556
+ readonly action: "writer-finish";
557
+ readonly claim: PersistenceCustodyWriterClaim;
558
+ };
559
+ export type PersistenceCustodyRequest = (PersistenceCustodyPrepareRequest) | (PersistenceCustodyExportPageRequest) | (PersistenceCustodyExportObjectRequest) | (PersistenceCustodyImportPageRequest) | (PersistenceCustodyImportObjectRequest) | (PersistenceCustodyVerifyRequest) | (PersistenceCustodyCutoverRequest) | (PersistenceCustodyQueryRequest) | (PersistenceCustodyAbortRequest) | (PersistenceCustodyWriterClaimRequest) | (PersistenceCustodyWriterQueryRequest) | (PersistenceCustodyWriterFinishRequest);
560
+ export type PersistenceCustodyResponse = (PersistenceCustodyPrepareResponse) | (PersistenceCustodyExportPageResponse) | (PersistenceCustodyExportObjectResponse) | (PersistenceCustodyImportPageResponse) | (PersistenceCustodyImportObjectResponse) | (PersistenceCustodyVerifyResponse) | (PersistenceCustodyCutoverResponse) | (PersistenceCustodyQueryResponse) | (PersistenceCustodyAbortResponse) | (PersistenceCustodyWriterClaimResponse) | (PersistenceCustodyWriterQueryResponse) | (PersistenceCustodyWriterFinishResponse);
561
+ export type PersistenceCustodyCapabilitiesResponse = {
562
+ readonly contract: PersistenceCustodyContract;
563
+ readonly capability: PersistenceCustodyCapability;
564
+ readonly installed: boolean;
565
+ readonly schemaRevision: PersistenceCustodySchemaRevision;
566
+ readonly limits: PersistenceCustodyLimits;
567
+ readonly writerAuthority: "shared-cas" | "unavailable";
568
+ };
@@ -0,0 +1,8 @@
1
+ /** Generated by scripts/sdk2/generate-terminal-wire.mjs. Schema SHA256 8c84ad5ba1461207dd0d9f11871989aeb8b971f6557c39ca4e06a690e191f9d9. */
2
+ export const PERSISTENCE_CUSTODY_CONTRACT = "persistence-custody-handoff-v1";
3
+ export const PERSISTENCE_CUSTODY_CAPABILITY = "persistence-custody-handoff-v1";
4
+ export const PERSISTENCE_CUSTODY_SCHEMA_SHA256 = "8c84ad5ba1461207dd0d9f11871989aeb8b971f6557c39ca4e06a690e191f9d9";
5
+ export const PERSISTENCE_CUSTODY_SCHEMA_REVISION = "2026-10-21.v1";
6
+ export const PERSISTENCE_CUSTODY_TOOL_NAME = "TansrPersistenceCustodyHandoffV1";
7
+ export const PERSISTENCE_CUSTODY_DEFAULT_MIGRATION_BUDGET = Object.freeze({ "bytes": 1073741824, "objects": 1048576 });
8
+ export const PERSISTENCE_CUSTODY_TOOL_DEFINITION_SHA256 = "7f3b94cb801bf29be071674cdab0450855e70c55ab44bea27508c30dfbebb5e7";
@@ -0,0 +1,28 @@
1
+ /** PST-SERVE-01 已会签目录摘要字节。只组织原值,不授予权限、不生成业务身份。 */
2
+ import { encodeCanonical } from './canonical/index.js';
3
+ const bytes = (value) => encodeCanonical(value, { maxBytes: 32768 });
4
+ /** 原业务根与控制摘要固定一个快照;源/目的托管位置不参与业务身份。 */
5
+ export function persistenceCustodySnapshotBytes(identity, root) {
6
+ return bytes(['PST-CUSTODY-SNAPSHOT', identity, root]);
7
+ }
8
+ /** 空目录初值。目录非空,第一项必须为与 fixedRoot 相符的原根描述。 */
9
+ export function persistenceCustodyInventorySeedBytes(identity, originFormat, fixedRoot) {
10
+ return bytes(['PST-CUSTODY-DIRECTORY', identity, originFormat, fixedRoot]);
11
+ }
12
+ /** 每项链式摘要;index 为全目录原序号,从 "0" 开始,与分页大小无关。 */
13
+ export function persistenceCustodyRecordBytes(index, previousDigest, record) {
14
+ return bytes(['PST-CUSTODY-RECORD', index, previousDigest, record]);
15
+ }
16
+ /** 管理意图摘要排除传输 envelope 与 operationId,本键重试不得换意图。 */
17
+ export function persistenceCustodyPrepareIntentBytes(request) {
18
+ return bytes({ identity: request.identity, source: request.source, destination: request.destination,
19
+ expectedWriterFence: request.expectedWriterFence, expectedRoot: request.expectedRoot });
20
+ }
21
+ /** 原 PST 请求本身定义 intentSha256;原字节不受托管迁移改写。 */
22
+ export function persistenceCustodyWriterIntentBytes(originalRequest) {
23
+ return bytes(originalRequest);
24
+ }
25
+ /** 写者认领 operationId = SHA256(本函数返回的 canonical 字节)。 */
26
+ export function persistenceCustodyWriterOperationBytes(originalRequest) {
27
+ return bytes(['PST-CUSTODY', originalRequest]);
28
+ }