@quantiya/codevibe-core 2.0.88 → 2.0.90

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,1151 @@
1
+ import { z } from 'zod';
2
+ import type { ConfirmDesktopSyncRetirementInput } from '../appsync/sync-session-retirement';
3
+ declare const scopeSchema: z.ZodObject<{
4
+ sessionId: z.ZodString;
5
+ sessionGenerationId: z.ZodString;
6
+ expectedSessionKeyGen: z.ZodString;
7
+ }, "strict", z.ZodTypeAny, {
8
+ sessionId: string;
9
+ sessionGenerationId: string;
10
+ expectedSessionKeyGen: string;
11
+ }, {
12
+ sessionId: string;
13
+ sessionGenerationId: string;
14
+ expectedSessionKeyGen: string;
15
+ }>;
16
+ declare const stableSchema: z.ZodObject<{
17
+ userId: z.ZodString;
18
+ environment: z.ZodEnum<["development", "production"]>;
19
+ deviceId: z.ZodString;
20
+ nativeThreadId: z.ZodString;
21
+ }, "strict", z.ZodTypeAny, {
22
+ deviceId: string;
23
+ environment: "production" | "development";
24
+ userId: string;
25
+ nativeThreadId: string;
26
+ }, {
27
+ deviceId: string;
28
+ environment: "production" | "development";
29
+ userId: string;
30
+ nativeThreadId: string;
31
+ }>;
32
+ declare const ownerSchema: z.ZodObject<{
33
+ token: z.ZodString;
34
+ pid: z.ZodNumber;
35
+ host: z.ZodString;
36
+ scope: z.ZodObject<{
37
+ sessionId: z.ZodString;
38
+ sessionGenerationId: z.ZodString;
39
+ expectedSessionKeyGen: z.ZodString;
40
+ }, "strict", z.ZodTypeAny, {
41
+ sessionId: string;
42
+ sessionGenerationId: string;
43
+ expectedSessionKeyGen: string;
44
+ }, {
45
+ sessionId: string;
46
+ sessionGenerationId: string;
47
+ expectedSessionKeyGen: string;
48
+ }>;
49
+ }, "strict", z.ZodTypeAny, {
50
+ host: string;
51
+ pid: number;
52
+ token: string;
53
+ scope: {
54
+ sessionId: string;
55
+ sessionGenerationId: string;
56
+ expectedSessionKeyGen: string;
57
+ };
58
+ }, {
59
+ host: string;
60
+ pid: number;
61
+ token: string;
62
+ scope: {
63
+ sessionId: string;
64
+ sessionGenerationId: string;
65
+ expectedSessionKeyGen: string;
66
+ };
67
+ }>;
68
+ declare const eventSchema: z.ZodObject<{
69
+ eventId: z.ZodEffects<z.ZodString, string, string>;
70
+ timestamp: z.ZodString;
71
+ sessionId: z.ZodString;
72
+ sessionGenerationId: z.ZodNullable<z.ZodString>;
73
+ syncLifecycleVersion: z.ZodOptional<z.ZodLiteral<1>>;
74
+ source: z.ZodLiteral<"MOBILE">;
75
+ type: z.ZodEnum<["USER_PROMPT", "PROMPT_RESPONSE"]>;
76
+ payloadJson: z.ZodString;
77
+ }, "strict", z.ZodTypeAny, {
78
+ source: "MOBILE";
79
+ eventId: string;
80
+ sessionId: string;
81
+ sessionGenerationId: string | null;
82
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
83
+ timestamp: string;
84
+ payloadJson: string;
85
+ syncLifecycleVersion?: 1 | undefined;
86
+ }, {
87
+ source: "MOBILE";
88
+ eventId: string;
89
+ sessionId: string;
90
+ sessionGenerationId: string | null;
91
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
92
+ timestamp: string;
93
+ payloadJson: string;
94
+ syncLifecycleVersion?: 1 | undefined;
95
+ }>;
96
+ declare const controlSchema: z.ZodObject<{
97
+ key: z.ZodString;
98
+ scope: z.ZodObject<{
99
+ sessionId: z.ZodString;
100
+ sessionGenerationId: z.ZodString;
101
+ expectedSessionKeyGen: z.ZodString;
102
+ }, "strict", z.ZodTypeAny, {
103
+ sessionId: string;
104
+ sessionGenerationId: string;
105
+ expectedSessionKeyGen: string;
106
+ }, {
107
+ sessionId: string;
108
+ sessionGenerationId: string;
109
+ expectedSessionKeyGen: string;
110
+ }>;
111
+ nativeInstanceId: z.ZodString;
112
+ threadId: z.ZodString;
113
+ turnId: z.ZodString;
114
+ itemId: z.ZodString;
115
+ kind: z.ZodEnum<["async", "command", "file"]>;
116
+ detailsJson: z.ZodString;
117
+ raiseJson: z.ZodString;
118
+ state: z.ZodEnum<["OPEN", "PAUSED", "UNCERTAIN", "RESOLVED", "SESSION_ENDED", "REHOMED"]>;
119
+ cloudResolved: z.ZodBoolean;
120
+ nativeResolutionSha256: z.ZodNullable<z.ZodString>;
121
+ nativeResolutionJson: z.ZodNullable<z.ZodString>;
122
+ answerEventId: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
123
+ }, "strict", z.ZodTypeAny, {
124
+ kind: "file" | "command" | "async";
125
+ key: string;
126
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
127
+ turnId: string;
128
+ scope: {
129
+ sessionId: string;
130
+ sessionGenerationId: string;
131
+ expectedSessionKeyGen: string;
132
+ };
133
+ nativeInstanceId: string;
134
+ threadId: string;
135
+ itemId: string;
136
+ detailsJson: string;
137
+ raiseJson: string;
138
+ cloudResolved: boolean;
139
+ nativeResolutionSha256: string | null;
140
+ nativeResolutionJson: string | null;
141
+ answerEventId: string | null;
142
+ }, {
143
+ kind: "file" | "command" | "async";
144
+ key: string;
145
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
146
+ turnId: string;
147
+ scope: {
148
+ sessionId: string;
149
+ sessionGenerationId: string;
150
+ expectedSessionKeyGen: string;
151
+ };
152
+ nativeInstanceId: string;
153
+ threadId: string;
154
+ itemId: string;
155
+ detailsJson: string;
156
+ raiseJson: string;
157
+ cloudResolved: boolean;
158
+ nativeResolutionSha256: string | null;
159
+ nativeResolutionJson: string | null;
160
+ answerEventId: string | null;
161
+ }>;
162
+ declare const recordSchema: z.ZodObject<{
163
+ version: z.ZodLiteral<1>;
164
+ stable: z.ZodObject<{
165
+ userId: z.ZodString;
166
+ environment: z.ZodEnum<["development", "production"]>;
167
+ deviceId: z.ZodString;
168
+ nativeThreadId: z.ZodString;
169
+ }, "strict", z.ZodTypeAny, {
170
+ deviceId: string;
171
+ environment: "production" | "development";
172
+ userId: string;
173
+ nativeThreadId: string;
174
+ }, {
175
+ deviceId: string;
176
+ environment: "production" | "development";
177
+ userId: string;
178
+ nativeThreadId: string;
179
+ }>;
180
+ revision: z.ZodNumber;
181
+ owner: z.ZodObject<{
182
+ token: z.ZodString;
183
+ pid: z.ZodNumber;
184
+ host: z.ZodString;
185
+ scope: z.ZodObject<{
186
+ sessionId: z.ZodString;
187
+ sessionGenerationId: z.ZodString;
188
+ expectedSessionKeyGen: z.ZodString;
189
+ }, "strict", z.ZodTypeAny, {
190
+ sessionId: string;
191
+ sessionGenerationId: string;
192
+ expectedSessionKeyGen: string;
193
+ }, {
194
+ sessionId: string;
195
+ sessionGenerationId: string;
196
+ expectedSessionKeyGen: string;
197
+ }>;
198
+ }, "strict", z.ZodTypeAny, {
199
+ host: string;
200
+ pid: number;
201
+ token: string;
202
+ scope: {
203
+ sessionId: string;
204
+ sessionGenerationId: string;
205
+ expectedSessionKeyGen: string;
206
+ };
207
+ }, {
208
+ host: string;
209
+ pid: number;
210
+ token: string;
211
+ scope: {
212
+ sessionId: string;
213
+ sessionGenerationId: string;
214
+ expectedSessionKeyGen: string;
215
+ };
216
+ }>;
217
+ handoffTo: z.ZodNullable<z.ZodString>;
218
+ scopes: z.ZodArray<z.ZodObject<{
219
+ scope: z.ZodObject<{
220
+ sessionId: z.ZodString;
221
+ sessionGenerationId: z.ZodString;
222
+ expectedSessionKeyGen: z.ZodString;
223
+ }, "strict", z.ZodTypeAny, {
224
+ sessionId: string;
225
+ sessionGenerationId: string;
226
+ expectedSessionKeyGen: string;
227
+ }, {
228
+ sessionId: string;
229
+ sessionGenerationId: string;
230
+ expectedSessionKeyGen: string;
231
+ }>;
232
+ state: z.ZodEnum<["OPEN", "CLOSED"]>;
233
+ closureReason: z.ZodOptional<z.ZodEnum<["TERMINAL", "BACKEND_REPLACED"]>>;
234
+ }, "strict", z.ZodTypeAny, {
235
+ state: "CLOSED" | "OPEN";
236
+ scope: {
237
+ sessionId: string;
238
+ sessionGenerationId: string;
239
+ expectedSessionKeyGen: string;
240
+ };
241
+ closureReason?: "TERMINAL" | "BACKEND_REPLACED" | undefined;
242
+ }, {
243
+ state: "CLOSED" | "OPEN";
244
+ scope: {
245
+ sessionId: string;
246
+ sessionGenerationId: string;
247
+ expectedSessionKeyGen: string;
248
+ };
249
+ closureReason?: "TERMINAL" | "BACKEND_REPLACED" | undefined;
250
+ }>, "many">;
251
+ entries: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
252
+ kind: z.ZodLiteral<"INPUT">;
253
+ phase: z.ZodEnum<["PREPARED", "ATTEMPTED", "UNCERTAIN", "RECEIPTED"]>;
254
+ bodyJson: z.ZodString;
255
+ event: z.ZodObject<{
256
+ eventId: z.ZodEffects<z.ZodString, string, string>;
257
+ timestamp: z.ZodString;
258
+ sessionId: z.ZodString;
259
+ sessionGenerationId: z.ZodNullable<z.ZodString>;
260
+ syncLifecycleVersion: z.ZodOptional<z.ZodLiteral<1>>;
261
+ source: z.ZodLiteral<"MOBILE">;
262
+ type: z.ZodEnum<["USER_PROMPT", "PROMPT_RESPONSE"]>;
263
+ payloadJson: z.ZodString;
264
+ }, "strict", z.ZodTypeAny, {
265
+ source: "MOBILE";
266
+ eventId: string;
267
+ sessionId: string;
268
+ sessionGenerationId: string | null;
269
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
270
+ timestamp: string;
271
+ payloadJson: string;
272
+ syncLifecycleVersion?: 1 | undefined;
273
+ }, {
274
+ source: "MOBILE";
275
+ eventId: string;
276
+ sessionId: string;
277
+ sessionGenerationId: string | null;
278
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
279
+ timestamp: string;
280
+ payloadJson: string;
281
+ syncLifecycleVersion?: 1 | undefined;
282
+ }>;
283
+ eventSha256: z.ZodString;
284
+ scope: z.ZodObject<{
285
+ sessionId: z.ZodString;
286
+ sessionGenerationId: z.ZodString;
287
+ expectedSessionKeyGen: z.ZodString;
288
+ }, "strict", z.ZodTypeAny, {
289
+ sessionId: string;
290
+ sessionGenerationId: string;
291
+ expectedSessionKeyGen: string;
292
+ }, {
293
+ sessionId: string;
294
+ sessionGenerationId: string;
295
+ expectedSessionKeyGen: string;
296
+ }>;
297
+ binding: z.ZodObject<{
298
+ kind: z.ZodEnum<["user", "async", "approval"]>;
299
+ threadId: z.ZodString;
300
+ nativeId: z.ZodString;
301
+ turnId: z.ZodNullable<z.ZodString>;
302
+ intentSha256: z.ZodString;
303
+ receiptMatchSha256: z.ZodString;
304
+ approval: z.ZodNullable<z.ZodObject<{
305
+ nativeInstanceId: z.ZodString;
306
+ requestId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
307
+ method: z.ZodEnum<["command", "file"]>;
308
+ decision: z.ZodEnum<["accept", "cancel", "decline"]>;
309
+ detailsSha256: z.ZodString;
310
+ }, "strict", z.ZodTypeAny, {
311
+ method: "file" | "command";
312
+ decision: "accept" | "cancel" | "decline";
313
+ nativeInstanceId: string;
314
+ requestId: string | number;
315
+ detailsSha256: string;
316
+ }, {
317
+ method: "file" | "command";
318
+ decision: "accept" | "cancel" | "decline";
319
+ nativeInstanceId: string;
320
+ requestId: string | number;
321
+ detailsSha256: string;
322
+ }>>;
323
+ }, "strict", z.ZodTypeAny, {
324
+ kind: "user" | "approval" | "async";
325
+ turnId: string | null;
326
+ approval: {
327
+ method: "file" | "command";
328
+ decision: "accept" | "cancel" | "decline";
329
+ nativeInstanceId: string;
330
+ requestId: string | number;
331
+ detailsSha256: string;
332
+ } | null;
333
+ threadId: string;
334
+ nativeId: string;
335
+ intentSha256: string;
336
+ receiptMatchSha256: string;
337
+ }, {
338
+ kind: "user" | "approval" | "async";
339
+ turnId: string | null;
340
+ approval: {
341
+ method: "file" | "command";
342
+ decision: "accept" | "cancel" | "decline";
343
+ nativeInstanceId: string;
344
+ requestId: string | number;
345
+ detailsSha256: string;
346
+ } | null;
347
+ threadId: string;
348
+ nativeId: string;
349
+ intentSha256: string;
350
+ receiptMatchSha256: string;
351
+ }>;
352
+ controlKey: z.ZodNullable<z.ZodString>;
353
+ cloudAck: z.ZodEnum<["MISSING", "EXECUTED"]>;
354
+ nativeReceiptSha256: z.ZodNullable<z.ZodString>;
355
+ }, "strict", z.ZodTypeAny, {
356
+ kind: "INPUT";
357
+ phase: "ATTEMPTED" | "UNCERTAIN" | "PREPARED" | "RECEIPTED";
358
+ event: {
359
+ source: "MOBILE";
360
+ eventId: string;
361
+ sessionId: string;
362
+ sessionGenerationId: string | null;
363
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
364
+ timestamp: string;
365
+ payloadJson: string;
366
+ syncLifecycleVersion?: 1 | undefined;
367
+ };
368
+ scope: {
369
+ sessionId: string;
370
+ sessionGenerationId: string;
371
+ expectedSessionKeyGen: string;
372
+ };
373
+ eventSha256: string;
374
+ bodyJson: string;
375
+ binding: {
376
+ kind: "user" | "approval" | "async";
377
+ turnId: string | null;
378
+ approval: {
379
+ method: "file" | "command";
380
+ decision: "accept" | "cancel" | "decline";
381
+ nativeInstanceId: string;
382
+ requestId: string | number;
383
+ detailsSha256: string;
384
+ } | null;
385
+ threadId: string;
386
+ nativeId: string;
387
+ intentSha256: string;
388
+ receiptMatchSha256: string;
389
+ };
390
+ controlKey: string | null;
391
+ cloudAck: "EXECUTED" | "MISSING";
392
+ nativeReceiptSha256: string | null;
393
+ }, {
394
+ kind: "INPUT";
395
+ phase: "ATTEMPTED" | "UNCERTAIN" | "PREPARED" | "RECEIPTED";
396
+ event: {
397
+ source: "MOBILE";
398
+ eventId: string;
399
+ sessionId: string;
400
+ sessionGenerationId: string | null;
401
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
402
+ timestamp: string;
403
+ payloadJson: string;
404
+ syncLifecycleVersion?: 1 | undefined;
405
+ };
406
+ scope: {
407
+ sessionId: string;
408
+ sessionGenerationId: string;
409
+ expectedSessionKeyGen: string;
410
+ };
411
+ eventSha256: string;
412
+ bodyJson: string;
413
+ binding: {
414
+ kind: "user" | "approval" | "async";
415
+ turnId: string | null;
416
+ approval: {
417
+ method: "file" | "command";
418
+ decision: "accept" | "cancel" | "decline";
419
+ nativeInstanceId: string;
420
+ requestId: string | number;
421
+ detailsSha256: string;
422
+ } | null;
423
+ threadId: string;
424
+ nativeId: string;
425
+ intentSha256: string;
426
+ receiptMatchSha256: string;
427
+ };
428
+ controlKey: string | null;
429
+ cloudAck: "EXECUTED" | "MISSING";
430
+ nativeReceiptSha256: string | null;
431
+ }>, z.ZodObject<{
432
+ event: z.ZodObject<Omit<{
433
+ eventId: z.ZodEffects<z.ZodString, string, string>;
434
+ timestamp: z.ZodString;
435
+ sessionId: z.ZodString;
436
+ sessionGenerationId: z.ZodNullable<z.ZodString>;
437
+ syncLifecycleVersion: z.ZodOptional<z.ZodLiteral<1>>;
438
+ source: z.ZodLiteral<"MOBILE">;
439
+ type: z.ZodEnum<["USER_PROMPT", "PROMPT_RESPONSE"]>;
440
+ payloadJson: z.ZodString;
441
+ }, "payloadJson">, "strict", z.ZodTypeAny, {
442
+ source: "MOBILE";
443
+ eventId: string;
444
+ sessionId: string;
445
+ sessionGenerationId: string | null;
446
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
447
+ timestamp: string;
448
+ syncLifecycleVersion?: 1 | undefined;
449
+ }, {
450
+ source: "MOBILE";
451
+ eventId: string;
452
+ sessionId: string;
453
+ sessionGenerationId: string | null;
454
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
455
+ timestamp: string;
456
+ syncLifecycleVersion?: 1 | undefined;
457
+ }>;
458
+ kind: z.ZodLiteral<"RETIRED_EVIDENCE">;
459
+ outcome: z.ZodEnum<["NATIVE_CONFIRMED", "NOT_SENT", "UNKNOWN"]>;
460
+ eventSha256: z.ZodString;
461
+ scope: z.ZodObject<{
462
+ sessionId: z.ZodString;
463
+ sessionGenerationId: z.ZodString;
464
+ expectedSessionKeyGen: z.ZodString;
465
+ }, "strict", z.ZodTypeAny, {
466
+ sessionId: string;
467
+ sessionGenerationId: string;
468
+ expectedSessionKeyGen: string;
469
+ }, {
470
+ sessionId: string;
471
+ sessionGenerationId: string;
472
+ expectedSessionKeyGen: string;
473
+ }>;
474
+ binding: z.ZodObject<{
475
+ kind: z.ZodEnum<["user", "async", "approval"]>;
476
+ threadId: z.ZodString;
477
+ nativeId: z.ZodString;
478
+ turnId: z.ZodNullable<z.ZodString>;
479
+ intentSha256: z.ZodString;
480
+ receiptMatchSha256: z.ZodString;
481
+ approval: z.ZodNullable<z.ZodObject<{
482
+ nativeInstanceId: z.ZodString;
483
+ requestId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
484
+ method: z.ZodEnum<["command", "file"]>;
485
+ decision: z.ZodEnum<["accept", "cancel", "decline"]>;
486
+ detailsSha256: z.ZodString;
487
+ }, "strict", z.ZodTypeAny, {
488
+ method: "file" | "command";
489
+ decision: "accept" | "cancel" | "decline";
490
+ nativeInstanceId: string;
491
+ requestId: string | number;
492
+ detailsSha256: string;
493
+ }, {
494
+ method: "file" | "command";
495
+ decision: "accept" | "cancel" | "decline";
496
+ nativeInstanceId: string;
497
+ requestId: string | number;
498
+ detailsSha256: string;
499
+ }>>;
500
+ }, "strict", z.ZodTypeAny, {
501
+ kind: "user" | "approval" | "async";
502
+ turnId: string | null;
503
+ approval: {
504
+ method: "file" | "command";
505
+ decision: "accept" | "cancel" | "decline";
506
+ nativeInstanceId: string;
507
+ requestId: string | number;
508
+ detailsSha256: string;
509
+ } | null;
510
+ threadId: string;
511
+ nativeId: string;
512
+ intentSha256: string;
513
+ receiptMatchSha256: string;
514
+ }, {
515
+ kind: "user" | "approval" | "async";
516
+ turnId: string | null;
517
+ approval: {
518
+ method: "file" | "command";
519
+ decision: "accept" | "cancel" | "decline";
520
+ nativeInstanceId: string;
521
+ requestId: string | number;
522
+ detailsSha256: string;
523
+ } | null;
524
+ threadId: string;
525
+ nativeId: string;
526
+ intentSha256: string;
527
+ receiptMatchSha256: string;
528
+ }>;
529
+ controlKey: z.ZodNullable<z.ZodString>;
530
+ cloudAck: z.ZodEnum<["MISSING", "EXECUTED"]>;
531
+ nativeReceiptSha256: z.ZodNullable<z.ZodString>;
532
+ }, "strict", z.ZodTypeAny, {
533
+ kind: "RETIRED_EVIDENCE";
534
+ outcome: "NATIVE_CONFIRMED" | "NOT_SENT" | "UNKNOWN";
535
+ event: {
536
+ source: "MOBILE";
537
+ eventId: string;
538
+ sessionId: string;
539
+ sessionGenerationId: string | null;
540
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
541
+ timestamp: string;
542
+ syncLifecycleVersion?: 1 | undefined;
543
+ };
544
+ scope: {
545
+ sessionId: string;
546
+ sessionGenerationId: string;
547
+ expectedSessionKeyGen: string;
548
+ };
549
+ eventSha256: string;
550
+ binding: {
551
+ kind: "user" | "approval" | "async";
552
+ turnId: string | null;
553
+ approval: {
554
+ method: "file" | "command";
555
+ decision: "accept" | "cancel" | "decline";
556
+ nativeInstanceId: string;
557
+ requestId: string | number;
558
+ detailsSha256: string;
559
+ } | null;
560
+ threadId: string;
561
+ nativeId: string;
562
+ intentSha256: string;
563
+ receiptMatchSha256: string;
564
+ };
565
+ controlKey: string | null;
566
+ cloudAck: "EXECUTED" | "MISSING";
567
+ nativeReceiptSha256: string | null;
568
+ }, {
569
+ kind: "RETIRED_EVIDENCE";
570
+ outcome: "NATIVE_CONFIRMED" | "NOT_SENT" | "UNKNOWN";
571
+ event: {
572
+ source: "MOBILE";
573
+ eventId: string;
574
+ sessionId: string;
575
+ sessionGenerationId: string | null;
576
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
577
+ timestamp: string;
578
+ syncLifecycleVersion?: 1 | undefined;
579
+ };
580
+ scope: {
581
+ sessionId: string;
582
+ sessionGenerationId: string;
583
+ expectedSessionKeyGen: string;
584
+ };
585
+ eventSha256: string;
586
+ binding: {
587
+ kind: "user" | "approval" | "async";
588
+ turnId: string | null;
589
+ approval: {
590
+ method: "file" | "command";
591
+ decision: "accept" | "cancel" | "decline";
592
+ nativeInstanceId: string;
593
+ requestId: string | number;
594
+ detailsSha256: string;
595
+ } | null;
596
+ threadId: string;
597
+ nativeId: string;
598
+ intentSha256: string;
599
+ receiptMatchSha256: string;
600
+ };
601
+ controlKey: string | null;
602
+ cloudAck: "EXECUTED" | "MISSING";
603
+ nativeReceiptSha256: string | null;
604
+ }>]>, "many">;
605
+ controls: z.ZodArray<z.ZodObject<{
606
+ key: z.ZodString;
607
+ scope: z.ZodObject<{
608
+ sessionId: z.ZodString;
609
+ sessionGenerationId: z.ZodString;
610
+ expectedSessionKeyGen: z.ZodString;
611
+ }, "strict", z.ZodTypeAny, {
612
+ sessionId: string;
613
+ sessionGenerationId: string;
614
+ expectedSessionKeyGen: string;
615
+ }, {
616
+ sessionId: string;
617
+ sessionGenerationId: string;
618
+ expectedSessionKeyGen: string;
619
+ }>;
620
+ nativeInstanceId: z.ZodString;
621
+ threadId: z.ZodString;
622
+ turnId: z.ZodString;
623
+ itemId: z.ZodString;
624
+ kind: z.ZodEnum<["async", "command", "file"]>;
625
+ detailsJson: z.ZodString;
626
+ raiseJson: z.ZodString;
627
+ state: z.ZodEnum<["OPEN", "PAUSED", "UNCERTAIN", "RESOLVED", "SESSION_ENDED", "REHOMED"]>;
628
+ cloudResolved: z.ZodBoolean;
629
+ nativeResolutionSha256: z.ZodNullable<z.ZodString>;
630
+ nativeResolutionJson: z.ZodNullable<z.ZodString>;
631
+ answerEventId: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
632
+ }, "strict", z.ZodTypeAny, {
633
+ kind: "file" | "command" | "async";
634
+ key: string;
635
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
636
+ turnId: string;
637
+ scope: {
638
+ sessionId: string;
639
+ sessionGenerationId: string;
640
+ expectedSessionKeyGen: string;
641
+ };
642
+ nativeInstanceId: string;
643
+ threadId: string;
644
+ itemId: string;
645
+ detailsJson: string;
646
+ raiseJson: string;
647
+ cloudResolved: boolean;
648
+ nativeResolutionSha256: string | null;
649
+ nativeResolutionJson: string | null;
650
+ answerEventId: string | null;
651
+ }, {
652
+ kind: "file" | "command" | "async";
653
+ key: string;
654
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
655
+ turnId: string;
656
+ scope: {
657
+ sessionId: string;
658
+ sessionGenerationId: string;
659
+ expectedSessionKeyGen: string;
660
+ };
661
+ nativeInstanceId: string;
662
+ threadId: string;
663
+ itemId: string;
664
+ detailsJson: string;
665
+ raiseJson: string;
666
+ cloudResolved: boolean;
667
+ nativeResolutionSha256: string | null;
668
+ nativeResolutionJson: string | null;
669
+ answerEventId: string | null;
670
+ }>, "many">;
671
+ diagnostic: z.ZodObject<{
672
+ nativeConfirmedCloudAckMissing: z.ZodNumber;
673
+ notSent: z.ZodNumber;
674
+ }, "strict", z.ZodTypeAny, {
675
+ nativeConfirmedCloudAckMissing: number;
676
+ notSent: number;
677
+ }, {
678
+ nativeConfirmedCloudAckMissing: number;
679
+ notSent: number;
680
+ }>;
681
+ }, "strict", z.ZodTypeAny, {
682
+ owner: {
683
+ host: string;
684
+ pid: number;
685
+ token: string;
686
+ scope: {
687
+ sessionId: string;
688
+ sessionGenerationId: string;
689
+ expectedSessionKeyGen: string;
690
+ };
691
+ };
692
+ entries: ({
693
+ kind: "INPUT";
694
+ phase: "ATTEMPTED" | "UNCERTAIN" | "PREPARED" | "RECEIPTED";
695
+ event: {
696
+ source: "MOBILE";
697
+ eventId: string;
698
+ sessionId: string;
699
+ sessionGenerationId: string | null;
700
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
701
+ timestamp: string;
702
+ payloadJson: string;
703
+ syncLifecycleVersion?: 1 | undefined;
704
+ };
705
+ scope: {
706
+ sessionId: string;
707
+ sessionGenerationId: string;
708
+ expectedSessionKeyGen: string;
709
+ };
710
+ eventSha256: string;
711
+ bodyJson: string;
712
+ binding: {
713
+ kind: "user" | "approval" | "async";
714
+ turnId: string | null;
715
+ approval: {
716
+ method: "file" | "command";
717
+ decision: "accept" | "cancel" | "decline";
718
+ nativeInstanceId: string;
719
+ requestId: string | number;
720
+ detailsSha256: string;
721
+ } | null;
722
+ threadId: string;
723
+ nativeId: string;
724
+ intentSha256: string;
725
+ receiptMatchSha256: string;
726
+ };
727
+ controlKey: string | null;
728
+ cloudAck: "EXECUTED" | "MISSING";
729
+ nativeReceiptSha256: string | null;
730
+ } | {
731
+ kind: "RETIRED_EVIDENCE";
732
+ outcome: "NATIVE_CONFIRMED" | "NOT_SENT" | "UNKNOWN";
733
+ event: {
734
+ source: "MOBILE";
735
+ eventId: string;
736
+ sessionId: string;
737
+ sessionGenerationId: string | null;
738
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
739
+ timestamp: string;
740
+ syncLifecycleVersion?: 1 | undefined;
741
+ };
742
+ scope: {
743
+ sessionId: string;
744
+ sessionGenerationId: string;
745
+ expectedSessionKeyGen: string;
746
+ };
747
+ eventSha256: string;
748
+ binding: {
749
+ kind: "user" | "approval" | "async";
750
+ turnId: string | null;
751
+ approval: {
752
+ method: "file" | "command";
753
+ decision: "accept" | "cancel" | "decline";
754
+ nativeInstanceId: string;
755
+ requestId: string | number;
756
+ detailsSha256: string;
757
+ } | null;
758
+ threadId: string;
759
+ nativeId: string;
760
+ intentSha256: string;
761
+ receiptMatchSha256: string;
762
+ };
763
+ controlKey: string | null;
764
+ cloudAck: "EXECUTED" | "MISSING";
765
+ nativeReceiptSha256: string | null;
766
+ })[];
767
+ version: 1;
768
+ revision: number;
769
+ stable: {
770
+ deviceId: string;
771
+ environment: "production" | "development";
772
+ userId: string;
773
+ nativeThreadId: string;
774
+ };
775
+ handoffTo: string | null;
776
+ scopes: {
777
+ state: "CLOSED" | "OPEN";
778
+ scope: {
779
+ sessionId: string;
780
+ sessionGenerationId: string;
781
+ expectedSessionKeyGen: string;
782
+ };
783
+ closureReason?: "TERMINAL" | "BACKEND_REPLACED" | undefined;
784
+ }[];
785
+ controls: {
786
+ kind: "file" | "command" | "async";
787
+ key: string;
788
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
789
+ turnId: string;
790
+ scope: {
791
+ sessionId: string;
792
+ sessionGenerationId: string;
793
+ expectedSessionKeyGen: string;
794
+ };
795
+ nativeInstanceId: string;
796
+ threadId: string;
797
+ itemId: string;
798
+ detailsJson: string;
799
+ raiseJson: string;
800
+ cloudResolved: boolean;
801
+ nativeResolutionSha256: string | null;
802
+ nativeResolutionJson: string | null;
803
+ answerEventId: string | null;
804
+ }[];
805
+ diagnostic: {
806
+ nativeConfirmedCloudAckMissing: number;
807
+ notSent: number;
808
+ };
809
+ }, {
810
+ owner: {
811
+ host: string;
812
+ pid: number;
813
+ token: string;
814
+ scope: {
815
+ sessionId: string;
816
+ sessionGenerationId: string;
817
+ expectedSessionKeyGen: string;
818
+ };
819
+ };
820
+ entries: ({
821
+ kind: "INPUT";
822
+ phase: "ATTEMPTED" | "UNCERTAIN" | "PREPARED" | "RECEIPTED";
823
+ event: {
824
+ source: "MOBILE";
825
+ eventId: string;
826
+ sessionId: string;
827
+ sessionGenerationId: string | null;
828
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
829
+ timestamp: string;
830
+ payloadJson: string;
831
+ syncLifecycleVersion?: 1 | undefined;
832
+ };
833
+ scope: {
834
+ sessionId: string;
835
+ sessionGenerationId: string;
836
+ expectedSessionKeyGen: string;
837
+ };
838
+ eventSha256: string;
839
+ bodyJson: string;
840
+ binding: {
841
+ kind: "user" | "approval" | "async";
842
+ turnId: string | null;
843
+ approval: {
844
+ method: "file" | "command";
845
+ decision: "accept" | "cancel" | "decline";
846
+ nativeInstanceId: string;
847
+ requestId: string | number;
848
+ detailsSha256: string;
849
+ } | null;
850
+ threadId: string;
851
+ nativeId: string;
852
+ intentSha256: string;
853
+ receiptMatchSha256: string;
854
+ };
855
+ controlKey: string | null;
856
+ cloudAck: "EXECUTED" | "MISSING";
857
+ nativeReceiptSha256: string | null;
858
+ } | {
859
+ kind: "RETIRED_EVIDENCE";
860
+ outcome: "NATIVE_CONFIRMED" | "NOT_SENT" | "UNKNOWN";
861
+ event: {
862
+ source: "MOBILE";
863
+ eventId: string;
864
+ sessionId: string;
865
+ sessionGenerationId: string | null;
866
+ type: "USER_PROMPT" | "PROMPT_RESPONSE";
867
+ timestamp: string;
868
+ syncLifecycleVersion?: 1 | undefined;
869
+ };
870
+ scope: {
871
+ sessionId: string;
872
+ sessionGenerationId: string;
873
+ expectedSessionKeyGen: string;
874
+ };
875
+ eventSha256: string;
876
+ binding: {
877
+ kind: "user" | "approval" | "async";
878
+ turnId: string | null;
879
+ approval: {
880
+ method: "file" | "command";
881
+ decision: "accept" | "cancel" | "decline";
882
+ nativeInstanceId: string;
883
+ requestId: string | number;
884
+ detailsSha256: string;
885
+ } | null;
886
+ threadId: string;
887
+ nativeId: string;
888
+ intentSha256: string;
889
+ receiptMatchSha256: string;
890
+ };
891
+ controlKey: string | null;
892
+ cloudAck: "EXECUTED" | "MISSING";
893
+ nativeReceiptSha256: string | null;
894
+ })[];
895
+ version: 1;
896
+ revision: number;
897
+ stable: {
898
+ deviceId: string;
899
+ environment: "production" | "development";
900
+ userId: string;
901
+ nativeThreadId: string;
902
+ };
903
+ handoffTo: string | null;
904
+ scopes: {
905
+ state: "CLOSED" | "OPEN";
906
+ scope: {
907
+ sessionId: string;
908
+ sessionGenerationId: string;
909
+ expectedSessionKeyGen: string;
910
+ };
911
+ closureReason?: "TERMINAL" | "BACKEND_REPLACED" | undefined;
912
+ }[];
913
+ controls: {
914
+ kind: "file" | "command" | "async";
915
+ key: string;
916
+ state: "PAUSED" | "RESOLVED" | "UNCERTAIN" | "OPEN" | "SESSION_ENDED" | "REHOMED";
917
+ turnId: string;
918
+ scope: {
919
+ sessionId: string;
920
+ sessionGenerationId: string;
921
+ expectedSessionKeyGen: string;
922
+ };
923
+ nativeInstanceId: string;
924
+ threadId: string;
925
+ itemId: string;
926
+ detailsJson: string;
927
+ raiseJson: string;
928
+ cloudResolved: boolean;
929
+ nativeResolutionSha256: string | null;
930
+ nativeResolutionJson: string | null;
931
+ answerEventId: string | null;
932
+ }[];
933
+ diagnostic: {
934
+ nativeConfirmedCloudAckMissing: number;
935
+ notSent: number;
936
+ };
937
+ }>;
938
+ declare const intentSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
939
+ kind: z.ZodLiteral<"user">;
940
+ threadId: z.ZodString;
941
+ clientId: z.ZodEffects<z.ZodString, string, string>;
942
+ contentJson: z.ZodString;
943
+ }, "strict", z.ZodTypeAny, {
944
+ kind: "user";
945
+ threadId: string;
946
+ clientId: string;
947
+ contentJson: string;
948
+ }, {
949
+ kind: "user";
950
+ threadId: string;
951
+ clientId: string;
952
+ contentJson: string;
953
+ }>, z.ZodObject<{
954
+ kind: z.ZodLiteral<"async">;
955
+ threadId: z.ZodString;
956
+ questionItemId: z.ZodString;
957
+ output: z.ZodString;
958
+ }, "strict", z.ZodTypeAny, {
959
+ kind: "async";
960
+ output: string;
961
+ threadId: string;
962
+ questionItemId: string;
963
+ }, {
964
+ kind: "async";
965
+ output: string;
966
+ threadId: string;
967
+ questionItemId: string;
968
+ }>, z.ZodObject<{
969
+ kind: z.ZodLiteral<"approval">;
970
+ threadId: z.ZodString;
971
+ turnId: z.ZodString;
972
+ itemId: z.ZodString;
973
+ nativeInstanceId: z.ZodString;
974
+ requestId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
975
+ method: z.ZodEnum<["command", "file"]>;
976
+ decision: z.ZodEnum<["accept", "cancel", "decline"]>;
977
+ detailsSha256: z.ZodString;
978
+ }, "strict", z.ZodTypeAny, {
979
+ method: "file" | "command";
980
+ kind: "approval";
981
+ decision: "accept" | "cancel" | "decline";
982
+ turnId: string;
983
+ nativeInstanceId: string;
984
+ requestId: string | number;
985
+ detailsSha256: string;
986
+ threadId: string;
987
+ itemId: string;
988
+ }, {
989
+ method: "file" | "command";
990
+ kind: "approval";
991
+ decision: "accept" | "cancel" | "decline";
992
+ turnId: string;
993
+ nativeInstanceId: string;
994
+ requestId: string | number;
995
+ detailsSha256: string;
996
+ threadId: string;
997
+ itemId: string;
998
+ }>]>;
999
+ export type CodexNativeScope = z.infer<typeof scopeSchema>;
1000
+ export type CodexNativeStableIdentity = z.infer<typeof stableSchema>;
1001
+ export type CodexNativeOwner = z.infer<typeof ownerSchema>;
1002
+ export type CodexNativeEvent = z.infer<typeof eventSchema>;
1003
+ export type CodexNativeControl = z.infer<typeof controlSchema>;
1004
+ export type CodexNativeIntent = z.infer<typeof intentSchema>;
1005
+ export type CodexNativeState = z.infer<typeof recordSchema>;
1006
+ export type CodexNativeEntry = CodexNativeState['entries'][number];
1007
+ export interface CodexNativeStateOptions {
1008
+ identity: CodexNativeStableIdentity;
1009
+ /** Stable installed data path. Private tests may supply their recorded root. */
1010
+ root?: string;
1011
+ readPrivateKey(): Promise<string | null>;
1012
+ assertAccount(): void;
1013
+ /** Caller must use the existing authenticated canonical Session read. */
1014
+ assertActiveScope(scope: CodexNativeScope): Promise<void>;
1015
+ }
1016
+ export declare class CodexNativeStateError extends Error {
1017
+ readonly code: string;
1018
+ constructor(code: string);
1019
+ }
1020
+ /** Exact JSON input, never a terminal-label catalogue. Mutable cloud delivery
1021
+ * status is intentionally outside the immutable input identity. */
1022
+ export declare function snapshotCodexNativeEvent(value: {
1023
+ eventId: string;
1024
+ timestamp: string;
1025
+ sessionId: string;
1026
+ sessionGenerationId?: string | null;
1027
+ syncLifecycleVersion?: number;
1028
+ source: string;
1029
+ type: string;
1030
+ content?: string | null;
1031
+ metadata?: unknown;
1032
+ attachments?: unknown;
1033
+ isEncrypted?: boolean | null;
1034
+ promptId?: string;
1035
+ encryptionVersion?: number;
1036
+ }): CodexNativeEvent;
1037
+ export declare class CodexNativeStateStore {
1038
+ private readonly options;
1039
+ readonly file: string;
1040
+ private readonly stable;
1041
+ private readonly root;
1042
+ private readonly context;
1043
+ private ingressClosed;
1044
+ private claimedOwnerToken;
1045
+ constructor(options: CodexNativeStateOptions);
1046
+ private directory;
1047
+ private locked;
1048
+ private validate;
1049
+ private read;
1050
+ private write;
1051
+ private owned;
1052
+ private mutate;
1053
+ private open;
1054
+ private active;
1055
+ /** First owner or exact successor. A live writer must explicitly close/join
1056
+ * and authorize this token. ESRCH on the recorded same-host PID is required
1057
+ * for crash takeover; age,heartbeat lag and unknown PID state never suffice. */
1058
+ claim(value: CodexNativeOwner): Promise<void>;
1059
+ snapshot(owner: CodexNativeOwner): Promise<CodexNativeState>;
1060
+ close(owner: CodexNativeOwner, reason?: 'TERMINAL' | 'BACKEND_REPLACED'): Promise<void>;
1061
+ private endControls;
1062
+ authorizeHandoff(owner: CodexNativeOwner, nextToken: string, join: () => Promise<void>): Promise<void>;
1063
+ putControl(owner: CodexNativeOwner, value: CodexNativeControl): Promise<void>;
1064
+ /** Only a live backend-row replacement can re-home presentation. The old
1065
+ * scope/input remains closed and unchanged;its exact E1 closure must already
1066
+ * be acknowledged. A normal terminal resume is never re-home authority. */
1067
+ rehomeControl(owner: CodexNativeOwner, previousKey: string, value: CodexNativeControl): Promise<void>;
1068
+ pauseControl(owner: CodexNativeOwner, controlKey: string, paused: boolean): Promise<void>;
1069
+ /** Approval preemption and answer reservation share one durable lock. An
1070
+ * answer committed first is no longer pausable; it is not a handler error.
1071
+ * Conversely a pause committed first still prevents prepare from sending. */
1072
+ pauseOpenQuestions(owner: CodexNativeOwner): Promise<void>;
1073
+ prepare(owner: CodexNativeOwner, value: CodexNativeEvent, intentValue: CodexNativeIntent, controlKey?: string | null): Promise<'COMMITTED' | 'DUPLICATE'>;
1074
+ /** Shared eligibility for every saved input, including async questions and
1075
+ * native approvals. A closed/paused control is normal retained work, not
1076
+ * authority to send or an error that may monopolize the recovery queue. */
1077
+ private preparedIntent;
1078
+ /** Local read-only preflight before decode or cloud DELIVERED. Do not poll
1079
+ * the backend for permanently retained closed controls on every tick.
1080
+ * prepare/beginAttempt retain their independent canonical active-scope
1081
+ * checks; this read cannot authorize a send. */
1082
+ canAttempt(owner: CodexNativeOwner, eventId: string): Promise<boolean>;
1083
+ /** The only initial-attempt gate. A successful return is an intent to send
1084
+ * ONCE,not a native acknowledgement. The caller must not retry a failed RPC. */
1085
+ beginAttempt(owner: CodexNativeOwner, eventId: string): Promise<CodexNativeIntent | null>;
1086
+ markUncertain(owner: CodexNativeOwner, eventId: string): Promise<void>;
1087
+ /** Only the current dispatcher may release its reservation BEFORE entering
1088
+ * send. A crash or any call into native send must retain ATTEMPTED/UNCERTAIN;
1089
+ * neither a failed RPC nor a missing receipt is proof that nothing was sent.
1090
+ * Exact owner,scope and body prevent releasing another admission's attempt. */
1091
+ deferUnsentAttempt(owner: CodexNativeOwner, eventId: string, intent: CodexNativeIntent): Promise<void>;
1092
+ /** Persisted original native receipts can reconcile under a successor,even
1093
+ * when the lost turn/start response never supplied a turn ID. No RPC retry. */
1094
+ reconcile(owner: CodexNativeOwner, eventId: string, receipt: {
1095
+ threadId: string;
1096
+ turnId: string;
1097
+ item: unknown;
1098
+ }): Promise<void>;
1099
+ acknowledgeControlClosure(owner: CodexNativeOwner, controlKey: string, receipt: unknown): Promise<void>;
1100
+ /** Invoke the existing public SDK lifecycle with the exact retained owner.
1101
+ * Its true result means verified resolution,including publication recovery;
1102
+ * it is not converted into a fabricated wire receipt or native execution. */
1103
+ resolveControl(owner: CodexNativeOwner, controlKey: string, resolve: (input: {
1104
+ sessionId: string;
1105
+ promptId: string;
1106
+ ownerToken: string;
1107
+ }) => Promise<boolean>): Promise<boolean>;
1108
+ /** Structured output can originate from another native client. It may close
1109
+ * this exact question,but must not mark a mobile Event executed by inference. */
1110
+ observeQuestionResolution(owner: CodexNativeOwner, controlKey: string, receipt: {
1111
+ threadId: string;
1112
+ turnId: string;
1113
+ item: unknown;
1114
+ }): Promise<void>;
1115
+ /** Only an exact signed status receipt can record cloud execution. Native
1116
+ * proof is independently required;an RPC write or DELIVERED is not enough. */
1117
+ acknowledgeInputExecution(owner: CodexNativeOwner, eventId: string, value: unknown): Promise<void>;
1118
+ private approvalResolution;
1119
+ /** A resolved native dialog closes its presentation,but is not by itself
1120
+ * proof that this mobile decision won a competing desktop response. */
1121
+ observeApprovalResolution(owner: CodexNativeOwner, controlKey: string, receipt: {
1122
+ nativeInstanceId: string;
1123
+ message: unknown;
1124
+ }): Promise<void>;
1125
+ /** An exact terminal native item can close presentation after a missed
1126
+ * callback notification. It does NOT prove which mobile decision won,so
1127
+ * this deliberately supplies no serverRequest/resolved proof to an input. */
1128
+ observeApprovalTerminalItem(owner: CodexNativeOwner, controlKey: string, receipt: {
1129
+ nativeInstanceId: string;
1130
+ message: unknown;
1131
+ }): Promise<void>;
1132
+ /** The native resolved notice plus an exact matching typed outcome is
1133
+ * required. An RPC/socket write,model prose,or opposite desktop outcome
1134
+ * cannot manufacture execution. Cancel also requires native interruption. */
1135
+ reconcileApproval(owner: CodexNativeOwner, eventId: string, receipt: {
1136
+ nativeInstanceId: string;
1137
+ resolved?: unknown;
1138
+ completed: unknown;
1139
+ turnCompleted?: unknown;
1140
+ }): Promise<void>;
1141
+ /** No cached proof. Snapshot comparison after the network await prevents a
1142
+ * fresh authority result from authorizing a different cleanup target set. */
1143
+ retirePayloads(owner: CodexNativeOwner, scope: CodexNativeScope, join: () => Promise<void>, confirm: (input: ConfirmDesktopSyncRetirementInput) => Promise<unknown>): Promise<number>;
1144
+ private requireClosed;
1145
+ pruneSettled(owner: CodexNativeOwner, scope: CodexNativeScope, confirm: (input: ConfirmDesktopSyncRetirementInput) => Promise<unknown>): Promise<number>;
1146
+ /** Remove the last empty per-thread owner record only after every remaining
1147
+ * closed scope has fresh retirement authority. Pending/native-control state
1148
+ * makes this a refusal,not an eviction policy or a background cleanup task. */
1149
+ removeSettled(owner: CodexNativeOwner, join: () => Promise<void>, confirm: (input: ConfirmDesktopSyncRetirementInput) => Promise<unknown>): Promise<void>;
1150
+ }
1151
+ export {};