@opengeni/contracts 0.31.1 → 0.35.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.
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS = 262144;
3
+ export declare const WORKSPACE_INSTRUCTION_POLICY_PROMPT_MAX_UTF8_BYTES = 131072;
3
4
  export declare const WORKSPACE_INSTRUCTION_POLICY_REASON_MAX_CHARS = 4096;
4
5
  export declare const WORKSPACE_INSTRUCTION_POLICY_ROLE_KEY_MAX_CHARS = 64;
5
6
  export declare const WORKSPACE_INSTRUCTION_POLICY_SOURCE_ID_MAX_CHARS = 512;
@@ -38,6 +39,15 @@ export type WorkspaceInstructionPolicyRoleKey = z.infer<typeof WorkspaceInstruct
38
39
  * at ingress so activation uniqueness and every client use the same key.
39
40
  */
40
41
  export declare function normalizeWorkspaceInstructionPolicyRoleKey(value: string): string;
42
+ export declare const WorkspaceInstructionPolicyRoleKeyInput: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
43
+ export type WorkspaceInstructionPolicyRoleKeyInput = z.infer<typeof WorkspaceInstructionPolicyRoleKeyInput>;
44
+ export declare const WorkspaceInstructionPolicyRoleSource: z.ZodEnum<{
45
+ invalid_metadata_fallback: "invalid_metadata_fallback";
46
+ metadata_fallback: "metadata_fallback";
47
+ none: "none";
48
+ session_binding: "session_binding";
49
+ }>;
50
+ export type WorkspaceInstructionPolicyRoleSource = z.infer<typeof WorkspaceInstructionPolicyRoleSource>;
41
51
  export declare const WorkspaceInstructionPolicyTarget: z.ZodObject<{
42
52
  kind: z.ZodEnum<{
43
53
  charter: "charter";
@@ -79,6 +89,7 @@ export declare const WorkspaceInstructionPolicyRevision: z.ZodObject<{
79
89
  id: z.ZodString;
80
90
  revision: z.ZodNumber;
81
91
  contentHash: z.ZodString;
92
+ operationId: z.ZodString;
82
93
  accountId: z.ZodString;
83
94
  workspaceId: z.ZodString;
84
95
  content: z.ZodString;
@@ -114,6 +125,156 @@ export declare const WorkspaceInstructionPolicyHead: z.ZodObject<{
114
125
  activatedAt: z.ZodString;
115
126
  }, z.core.$strip>;
116
127
  export type WorkspaceInstructionPolicyHead = z.infer<typeof WorkspaceInstructionPolicyHead>;
128
+ export declare const WorkspaceInstructionPolicySnapshotProvenance: z.ZodObject<{
129
+ source: z.ZodEnum<{
130
+ human: "human";
131
+ knowledge_proposal: "knowledge_proposal";
132
+ legacy_import: "legacy_import";
133
+ onboarding: "onboarding";
134
+ }>;
135
+ sourceIdHash: z.ZodNullable<z.ZodString>;
136
+ }, z.core.$strip>;
137
+ export type WorkspaceInstructionPolicySnapshotProvenance = z.infer<typeof WorkspaceInstructionPolicySnapshotProvenance>;
138
+ export declare const WorkspaceInstructionPolicySnapshotEntry: z.ZodObject<{
139
+ kind: z.ZodEnum<{
140
+ charter: "charter";
141
+ policy: "policy";
142
+ }>;
143
+ scope: z.ZodEnum<{
144
+ global: "global";
145
+ role: "role";
146
+ }>;
147
+ roleKey: z.ZodNullable<z.ZodString>;
148
+ revisionId: z.ZodString;
149
+ revision: z.ZodNumber;
150
+ contentHash: z.ZodString;
151
+ activationVersion: z.ZodNumber;
152
+ activatedAt: z.ZodString;
153
+ provenance: z.ZodObject<{
154
+ source: z.ZodEnum<{
155
+ human: "human";
156
+ knowledge_proposal: "knowledge_proposal";
157
+ legacy_import: "legacy_import";
158
+ onboarding: "onboarding";
159
+ }>;
160
+ sourceIdHash: z.ZodNullable<z.ZodString>;
161
+ }, z.core.$strip>;
162
+ }, z.core.$strip>;
163
+ export type WorkspaceInstructionPolicySnapshotEntry = z.infer<typeof WorkspaceInstructionPolicySnapshotEntry>;
164
+ export declare const WorkspaceInstructionPolicySnapshot: z.ZodObject<{
165
+ id: z.ZodString;
166
+ workspaceId: z.ZodString;
167
+ sessionId: z.ZodString;
168
+ turnId: z.ZodString;
169
+ attemptId: z.ZodString;
170
+ executionGeneration: z.ZodNumber;
171
+ policyRole: z.ZodNullable<z.ZodString>;
172
+ roleSource: z.ZodEnum<{
173
+ invalid_metadata_fallback: "invalid_metadata_fallback";
174
+ metadata_fallback: "metadata_fallback";
175
+ none: "none";
176
+ session_binding: "session_binding";
177
+ }>;
178
+ entryHash: z.ZodString;
179
+ entries: z.ZodArray<z.ZodObject<{
180
+ kind: z.ZodEnum<{
181
+ charter: "charter";
182
+ policy: "policy";
183
+ }>;
184
+ scope: z.ZodEnum<{
185
+ global: "global";
186
+ role: "role";
187
+ }>;
188
+ roleKey: z.ZodNullable<z.ZodString>;
189
+ revisionId: z.ZodString;
190
+ revision: z.ZodNumber;
191
+ contentHash: z.ZodString;
192
+ activationVersion: z.ZodNumber;
193
+ activatedAt: z.ZodString;
194
+ provenance: z.ZodObject<{
195
+ source: z.ZodEnum<{
196
+ human: "human";
197
+ knowledge_proposal: "knowledge_proposal";
198
+ legacy_import: "legacy_import";
199
+ onboarding: "onboarding";
200
+ }>;
201
+ sourceIdHash: z.ZodNullable<z.ZodString>;
202
+ }, z.core.$strip>;
203
+ }, z.core.$strip>>;
204
+ createdAt: z.ZodString;
205
+ }, z.core.$strip>;
206
+ export type WorkspaceInstructionPolicySnapshot = z.infer<typeof WorkspaceInstructionPolicySnapshot>;
207
+ export declare const ResolvedWorkspaceInstructionPolicySnapshotEntry: z.ZodObject<{
208
+ kind: z.ZodEnum<{
209
+ charter: "charter";
210
+ policy: "policy";
211
+ }>;
212
+ scope: z.ZodEnum<{
213
+ global: "global";
214
+ role: "role";
215
+ }>;
216
+ roleKey: z.ZodNullable<z.ZodString>;
217
+ revisionId: z.ZodString;
218
+ revision: z.ZodNumber;
219
+ contentHash: z.ZodString;
220
+ activationVersion: z.ZodNumber;
221
+ activatedAt: z.ZodString;
222
+ provenance: z.ZodObject<{
223
+ source: z.ZodEnum<{
224
+ human: "human";
225
+ knowledge_proposal: "knowledge_proposal";
226
+ legacy_import: "legacy_import";
227
+ onboarding: "onboarding";
228
+ }>;
229
+ sourceIdHash: z.ZodNullable<z.ZodString>;
230
+ }, z.core.$strip>;
231
+ content: z.ZodString;
232
+ }, z.core.$strip>;
233
+ export type ResolvedWorkspaceInstructionPolicySnapshotEntry = z.infer<typeof ResolvedWorkspaceInstructionPolicySnapshotEntry>;
234
+ export declare const ResolvedWorkspaceInstructionPolicySnapshot: z.ZodObject<{
235
+ id: z.ZodString;
236
+ workspaceId: z.ZodString;
237
+ sessionId: z.ZodString;
238
+ turnId: z.ZodString;
239
+ attemptId: z.ZodString;
240
+ executionGeneration: z.ZodNumber;
241
+ policyRole: z.ZodNullable<z.ZodString>;
242
+ roleSource: z.ZodEnum<{
243
+ invalid_metadata_fallback: "invalid_metadata_fallback";
244
+ metadata_fallback: "metadata_fallback";
245
+ none: "none";
246
+ session_binding: "session_binding";
247
+ }>;
248
+ entryHash: z.ZodString;
249
+ createdAt: z.ZodString;
250
+ entries: z.ZodArray<z.ZodObject<{
251
+ kind: z.ZodEnum<{
252
+ charter: "charter";
253
+ policy: "policy";
254
+ }>;
255
+ scope: z.ZodEnum<{
256
+ global: "global";
257
+ role: "role";
258
+ }>;
259
+ roleKey: z.ZodNullable<z.ZodString>;
260
+ revisionId: z.ZodString;
261
+ revision: z.ZodNumber;
262
+ contentHash: z.ZodString;
263
+ activationVersion: z.ZodNumber;
264
+ activatedAt: z.ZodString;
265
+ provenance: z.ZodObject<{
266
+ source: z.ZodEnum<{
267
+ human: "human";
268
+ knowledge_proposal: "knowledge_proposal";
269
+ legacy_import: "legacy_import";
270
+ onboarding: "onboarding";
271
+ }>;
272
+ sourceIdHash: z.ZodNullable<z.ZodString>;
273
+ }, z.core.$strip>;
274
+ content: z.ZodString;
275
+ }, z.core.$strip>>;
276
+ }, z.core.$strip>;
277
+ export type ResolvedWorkspaceInstructionPolicySnapshot = z.infer<typeof ResolvedWorkspaceInstructionPolicySnapshot>;
117
278
  export declare const WorkspaceInstructionPolicyActivationEvent: z.ZodObject<{
118
279
  kind: z.ZodEnum<{
119
280
  charter: "charter";
@@ -125,6 +286,7 @@ export declare const WorkspaceInstructionPolicyActivationEvent: z.ZodObject<{
125
286
  }>;
126
287
  roleKey: z.ZodNullable<z.ZodString>;
127
288
  id: z.ZodString;
289
+ operationId: z.ZodString;
128
290
  accountId: z.ZodString;
129
291
  workspaceId: z.ZodString;
130
292
  type: z.ZodEnum<{
@@ -148,6 +310,7 @@ export declare const WorkspaceInstructionPolicyActivationEvent: z.ZodObject<{
148
310
  }, z.core.$strip>;
149
311
  export type WorkspaceInstructionPolicyActivationEvent = z.infer<typeof WorkspaceInstructionPolicyActivationEvent>;
150
312
  export declare const CreateWorkspaceInstructionPolicyDraftRequest: z.ZodObject<{
313
+ operationId: z.ZodOptional<z.ZodString>;
151
314
  kind: z.ZodEnum<{
152
315
  charter: "charter";
153
316
  policy: "policy";
@@ -168,6 +331,7 @@ export declare const CreateWorkspaceInstructionPolicyDraftRequest: z.ZodObject<{
168
331
  }, z.core.$strip>;
169
332
  export type CreateWorkspaceInstructionPolicyDraftRequest = z.infer<typeof CreateWorkspaceInstructionPolicyDraftRequest>;
170
333
  export declare const ImportLegacyWorkspaceInstructionPolicyDraftRequest: z.ZodObject<{
334
+ operationId: z.ZodOptional<z.ZodString>;
171
335
  supersedesRevisionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
172
336
  }, z.core.$strict>;
173
337
  export type ImportLegacyWorkspaceInstructionPolicyDraftRequest = z.infer<typeof ImportLegacyWorkspaceInstructionPolicyDraftRequest>;
@@ -199,6 +363,7 @@ export declare const WorkspaceInstructionPolicyListResponse: z.ZodObject<{
199
363
  id: z.ZodString;
200
364
  revision: z.ZodNumber;
201
365
  contentHash: z.ZodString;
366
+ operationId: z.ZodString;
202
367
  accountId: z.ZodString;
203
368
  workspaceId: z.ZodString;
204
369
  content: z.ZodString;
@@ -243,6 +408,7 @@ export declare const WorkspaceInstructionPolicyListResponse: z.ZodObject<{
243
408
  }>;
244
409
  roleKey: z.ZodNullable<z.ZodString>;
245
410
  id: z.ZodString;
411
+ operationId: z.ZodString;
246
412
  accountId: z.ZodString;
247
413
  workspaceId: z.ZodString;
248
414
  type: z.ZodEnum<{
@@ -286,6 +452,7 @@ export declare const WorkspaceInstructionPolicyDiffResponse: z.ZodObject<{
286
452
  id: z.ZodString;
287
453
  revision: z.ZodNumber;
288
454
  contentHash: z.ZodString;
455
+ operationId: z.ZodString;
289
456
  accountId: z.ZodString;
290
457
  workspaceId: z.ZodString;
291
458
  content: z.ZodString;
@@ -315,6 +482,7 @@ export declare const WorkspaceInstructionPolicyDiffResponse: z.ZodObject<{
315
482
  id: z.ZodString;
316
483
  revision: z.ZodNumber;
317
484
  contentHash: z.ZodString;
485
+ operationId: z.ZodString;
318
486
  accountId: z.ZodString;
319
487
  workspaceId: z.ZodString;
320
488
  content: z.ZodString;
@@ -336,13 +504,17 @@ export declare const WorkspaceInstructionPolicyDiffResponse: z.ZodObject<{
336
504
  }, z.core.$strip>;
337
505
  export type WorkspaceInstructionPolicyDiffResponse = z.infer<typeof WorkspaceInstructionPolicyDiffResponse>;
338
506
  export declare const ActivateWorkspaceInstructionPolicyRequest: z.ZodObject<{
507
+ operationId: z.ZodOptional<z.ZodString>;
339
508
  expectedCurrentRevisionId: z.ZodNullable<z.ZodString>;
509
+ expectedActivationVersion: z.ZodOptional<z.ZodNumber>;
340
510
  reason: z.ZodString;
341
511
  }, z.core.$strip>;
342
512
  export type ActivateWorkspaceInstructionPolicyRequest = z.infer<typeof ActivateWorkspaceInstructionPolicyRequest>;
343
513
  export declare const RollbackWorkspaceInstructionPolicyRequest: z.ZodObject<{
514
+ operationId: z.ZodOptional<z.ZodString>;
344
515
  targetRevisionId: z.ZodString;
345
516
  expectedCurrentRevisionId: z.ZodString;
517
+ expectedActivationVersion: z.ZodOptional<z.ZodNumber>;
346
518
  reason: z.ZodString;
347
519
  }, z.core.$strip>;
348
520
  export type RollbackWorkspaceInstructionPolicyRequest = z.infer<typeof RollbackWorkspaceInstructionPolicyRequest>;
@@ -375,6 +547,7 @@ export declare const WorkspaceInstructionPolicyActivationResponse: z.ZodObject<{
375
547
  }>;
376
548
  roleKey: z.ZodNullable<z.ZodString>;
377
549
  id: z.ZodString;
550
+ operationId: z.ZodString;
378
551
  accountId: z.ZodString;
379
552
  workspaceId: z.ZodString;
380
553
  type: z.ZodEnum<{
@@ -420,3 +593,8 @@ export declare const WorkspaceInstructionPolicyConflictResponse: z.ZodObject<{
420
593
  }, z.core.$strip>>;
421
594
  }, z.core.$strip>;
422
595
  export type WorkspaceInstructionPolicyConflictResponse = z.infer<typeof WorkspaceInstructionPolicyConflictResponse>;
596
+ export declare const WorkspaceInstructionPolicyOperationReuseResponse: z.ZodObject<{
597
+ code: z.ZodLiteral<"WORKSPACE_INSTRUCTION_POLICY_OPERATION_REUSED">;
598
+ message: z.ZodString;
599
+ }, z.core.$strip>;
600
+ export type WorkspaceInstructionPolicyOperationReuseResponse = z.infer<typeof WorkspaceInstructionPolicyOperationReuseResponse>;
@@ -6,6 +6,10 @@ export declare const WORKSPACE_STATE_MAX_GAPS = 16;
6
6
  export declare const WORKSPACE_STATE_BASE_NAME_MAX_CHARS = 160;
7
7
  export declare const WORKSPACE_STATE_TOPIC_MAX_CHARS = 96;
8
8
  export declare const WORKSPACE_STATE_MEMORY_SAMPLE_LIMIT = 100;
9
+ export declare const WorkspaceStateQuery: z.ZodObject<{
10
+ attemptId: z.ZodOptional<z.ZodString>;
11
+ }, z.core.$strict>;
12
+ export type WorkspaceStateQuery = z.infer<typeof WorkspaceStateQuery>;
9
13
  export declare const WorkspaceStateDocumentStatusCounts: z.ZodObject<{
10
14
  queued: z.ZodNumber;
11
15
  indexing: z.ZodNumber;
@@ -364,6 +368,118 @@ export declare const WorkspaceStateKnowledge: z.ZodDiscriminatedUnion<[z.ZodObje
364
368
  requiredPermission: z.ZodLiteral<"documents:search">;
365
369
  }, z.core.$strict>], "availability">;
366
370
  export type WorkspaceStateKnowledge = z.infer<typeof WorkspaceStateKnowledge>;
371
+ export declare const WorkspaceStateGovernanceDriftStatus: z.ZodEnum<{
372
+ changed: "changed";
373
+ identical: "identical";
374
+ missing: "missing";
375
+ superseded: "superseded";
376
+ truncated: "truncated";
377
+ unavailable: "unavailable";
378
+ }>;
379
+ export type WorkspaceStateGovernanceDriftStatus = z.infer<typeof WorkspaceStateGovernanceDriftStatus>;
380
+ export declare const WorkspaceStateAttemptGovernance: z.ZodDiscriminatedUnion<[z.ZodObject<{
381
+ status: z.ZodLiteral<"not_requested">;
382
+ }, z.core.$strict>, z.ZodObject<{
383
+ status: z.ZodLiteral<"unavailable">;
384
+ reason: z.ZodLiteral<"attempt_not_found_or_not_authorized">;
385
+ driftStatus: z.ZodLiteral<"unavailable">;
386
+ }, z.core.$strict>, z.ZodObject<{
387
+ status: z.ZodLiteral<"available">;
388
+ attemptId: z.ZodString;
389
+ executionGeneration: z.ZodNumber;
390
+ acceptedAt: z.ZodString;
391
+ policySnapshot: z.ZodDiscriminatedUnion<[z.ZodObject<{
392
+ status: z.ZodLiteral<"available">;
393
+ id: z.ZodString;
394
+ createdAt: z.ZodString;
395
+ entryHash: z.ZodString;
396
+ policyRole: z.ZodNullable<z.ZodString>;
397
+ roleSource: z.ZodEnum<{
398
+ invalid_metadata_fallback: "invalid_metadata_fallback";
399
+ metadata_fallback: "metadata_fallback";
400
+ none: "none";
401
+ session_binding: "session_binding";
402
+ }>;
403
+ entries: z.ZodArray<z.ZodObject<{
404
+ kind: z.ZodEnum<{
405
+ charter: "charter";
406
+ policy: "policy";
407
+ }>;
408
+ scope: z.ZodEnum<{
409
+ global: "global";
410
+ role: "role";
411
+ }>;
412
+ roleKey: z.ZodNullable<z.ZodString>;
413
+ revisionId: z.ZodString;
414
+ revision: z.ZodNumber;
415
+ contentHash: z.ZodString;
416
+ activationVersion: z.ZodNumber;
417
+ activatedAt: z.ZodString;
418
+ provenance: z.ZodObject<{
419
+ source: z.ZodEnum<{
420
+ human: "human";
421
+ knowledge_proposal: "knowledge_proposal";
422
+ legacy_import: "legacy_import";
423
+ onboarding: "onboarding";
424
+ }>;
425
+ sourceIdHash: z.ZodNullable<z.ZodString>;
426
+ }, z.core.$strip>;
427
+ }, z.core.$strip>>;
428
+ }, z.core.$strict>, z.ZodObject<{
429
+ status: z.ZodLiteral<"missing">;
430
+ }, z.core.$strict>], "status">;
431
+ preferenceSnapshot: z.ZodDiscriminatedUnion<[z.ZodObject<{
432
+ status: z.ZodLiteral<"available">;
433
+ id: z.ZodString;
434
+ createdAt: z.ZodString;
435
+ descriptorHash: z.ZodString;
436
+ descriptorCount: z.ZodNumber;
437
+ truncated: z.ZodBoolean;
438
+ }, z.core.$strict>, z.ZodObject<{
439
+ status: z.ZodLiteral<"missing">;
440
+ }, z.core.$strict>], "status">;
441
+ drift: z.ZodObject<{
442
+ overall: z.ZodEnum<{
443
+ changed: "changed";
444
+ identical: "identical";
445
+ missing: "missing";
446
+ superseded: "superseded";
447
+ truncated: "truncated";
448
+ unavailable: "unavailable";
449
+ }>;
450
+ policy: z.ZodObject<{
451
+ status: z.ZodEnum<{
452
+ changed: "changed";
453
+ identical: "identical";
454
+ missing: "missing";
455
+ superseded: "superseded";
456
+ truncated: "truncated";
457
+ unavailable: "unavailable";
458
+ }>;
459
+ snapshotHash: z.ZodNullable<z.ZodString>;
460
+ currentHash: z.ZodNullable<z.ZodString>;
461
+ snapshotTargetCount: z.ZodNumber;
462
+ currentTargetCount: z.ZodNumber;
463
+ }, z.core.$strict>;
464
+ preferences: z.ZodObject<{
465
+ status: z.ZodEnum<{
466
+ changed: "changed";
467
+ identical: "identical";
468
+ missing: "missing";
469
+ superseded: "superseded";
470
+ truncated: "truncated";
471
+ unavailable: "unavailable";
472
+ }>;
473
+ snapshotHash: z.ZodNullable<z.ZodString>;
474
+ currentHash: z.ZodNullable<z.ZodString>;
475
+ snapshotDescriptorCount: z.ZodNumber;
476
+ currentDescriptorCount: z.ZodNumber;
477
+ snapshotTruncated: z.ZodBoolean;
478
+ currentTruncated: z.ZodBoolean;
479
+ }, z.core.$strict>;
480
+ }, z.core.$strict>;
481
+ }, z.core.$strict>], "status">;
482
+ export type WorkspaceStateAttemptGovernance = z.infer<typeof WorkspaceStateAttemptGovernance>;
367
483
  export declare const WorkspaceStateResponse: z.ZodObject<{
368
484
  workspaceId: z.ZodString;
369
485
  generatedAt: z.ZodString;
@@ -372,10 +488,108 @@ export declare const WorkspaceStateResponse: z.ZodObject<{
372
488
  source: z.ZodLiteral<"read_time_projection">;
373
489
  capturedAt: z.ZodString;
374
490
  }, z.core.$strict>;
375
- policySnapshot: z.ZodObject<{
376
- status: z.ZodLiteral<"not_captured">;
377
- reason: z.ZodLiteral<"workspace_instruction_policy_snapshot_not_implemented">;
378
- }, z.core.$strict>;
491
+ attemptGovernance: z.ZodDiscriminatedUnion<[z.ZodObject<{
492
+ status: z.ZodLiteral<"not_requested">;
493
+ }, z.core.$strict>, z.ZodObject<{
494
+ status: z.ZodLiteral<"unavailable">;
495
+ reason: z.ZodLiteral<"attempt_not_found_or_not_authorized">;
496
+ driftStatus: z.ZodLiteral<"unavailable">;
497
+ }, z.core.$strict>, z.ZodObject<{
498
+ status: z.ZodLiteral<"available">;
499
+ attemptId: z.ZodString;
500
+ executionGeneration: z.ZodNumber;
501
+ acceptedAt: z.ZodString;
502
+ policySnapshot: z.ZodDiscriminatedUnion<[z.ZodObject<{
503
+ status: z.ZodLiteral<"available">;
504
+ id: z.ZodString;
505
+ createdAt: z.ZodString;
506
+ entryHash: z.ZodString;
507
+ policyRole: z.ZodNullable<z.ZodString>;
508
+ roleSource: z.ZodEnum<{
509
+ invalid_metadata_fallback: "invalid_metadata_fallback";
510
+ metadata_fallback: "metadata_fallback";
511
+ none: "none";
512
+ session_binding: "session_binding";
513
+ }>;
514
+ entries: z.ZodArray<z.ZodObject<{
515
+ kind: z.ZodEnum<{
516
+ charter: "charter";
517
+ policy: "policy";
518
+ }>;
519
+ scope: z.ZodEnum<{
520
+ global: "global";
521
+ role: "role";
522
+ }>;
523
+ roleKey: z.ZodNullable<z.ZodString>;
524
+ revisionId: z.ZodString;
525
+ revision: z.ZodNumber;
526
+ contentHash: z.ZodString;
527
+ activationVersion: z.ZodNumber;
528
+ activatedAt: z.ZodString;
529
+ provenance: z.ZodObject<{
530
+ source: z.ZodEnum<{
531
+ human: "human";
532
+ knowledge_proposal: "knowledge_proposal";
533
+ legacy_import: "legacy_import";
534
+ onboarding: "onboarding";
535
+ }>;
536
+ sourceIdHash: z.ZodNullable<z.ZodString>;
537
+ }, z.core.$strip>;
538
+ }, z.core.$strip>>;
539
+ }, z.core.$strict>, z.ZodObject<{
540
+ status: z.ZodLiteral<"missing">;
541
+ }, z.core.$strict>], "status">;
542
+ preferenceSnapshot: z.ZodDiscriminatedUnion<[z.ZodObject<{
543
+ status: z.ZodLiteral<"available">;
544
+ id: z.ZodString;
545
+ createdAt: z.ZodString;
546
+ descriptorHash: z.ZodString;
547
+ descriptorCount: z.ZodNumber;
548
+ truncated: z.ZodBoolean;
549
+ }, z.core.$strict>, z.ZodObject<{
550
+ status: z.ZodLiteral<"missing">;
551
+ }, z.core.$strict>], "status">;
552
+ drift: z.ZodObject<{
553
+ overall: z.ZodEnum<{
554
+ changed: "changed";
555
+ identical: "identical";
556
+ missing: "missing";
557
+ superseded: "superseded";
558
+ truncated: "truncated";
559
+ unavailable: "unavailable";
560
+ }>;
561
+ policy: z.ZodObject<{
562
+ status: z.ZodEnum<{
563
+ changed: "changed";
564
+ identical: "identical";
565
+ missing: "missing";
566
+ superseded: "superseded";
567
+ truncated: "truncated";
568
+ unavailable: "unavailable";
569
+ }>;
570
+ snapshotHash: z.ZodNullable<z.ZodString>;
571
+ currentHash: z.ZodNullable<z.ZodString>;
572
+ snapshotTargetCount: z.ZodNumber;
573
+ currentTargetCount: z.ZodNumber;
574
+ }, z.core.$strict>;
575
+ preferences: z.ZodObject<{
576
+ status: z.ZodEnum<{
577
+ changed: "changed";
578
+ identical: "identical";
579
+ missing: "missing";
580
+ superseded: "superseded";
581
+ truncated: "truncated";
582
+ unavailable: "unavailable";
583
+ }>;
584
+ snapshotHash: z.ZodNullable<z.ZodString>;
585
+ currentHash: z.ZodNullable<z.ZodString>;
586
+ snapshotDescriptorCount: z.ZodNumber;
587
+ currentDescriptorCount: z.ZodNumber;
588
+ snapshotTruncated: z.ZodBoolean;
589
+ currentTruncated: z.ZodBoolean;
590
+ }, z.core.$strict>;
591
+ }, z.core.$strict>;
592
+ }, z.core.$strict>], "status">;
379
593
  }, z.core.$strict>;
380
594
  policy: z.ZodObject<{
381
595
  authority: z.ZodLiteral<"workspace_instruction_policy_heads">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/contracts",
3
- "version": "0.31.1",
3
+ "version": "0.35.0",
4
4
  "description": "Shared zod schemas and wire-contract types for the OpenGeni API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -3,6 +3,8 @@ import { z } from "zod";
3
3
  import { ConnectionMetadata } from "./index";
4
4
 
5
5
  export const GOOGLE_DRIVE_PROVIDER_DOMAIN = "googleapis.com" as const;
6
+ export const GOOGLE_DRIVE_FULL_SCOPE = "https://www.googleapis.com/auth/drive" as const;
7
+ export const GOOGLE_DRIVE_FILE_SCOPE = "https://www.googleapis.com/auth/drive.file" as const;
6
8
  export const GOOGLE_DRIVE_METADATA_READONLY_SCOPE =
7
9
  "https://www.googleapis.com/auth/drive.metadata.readonly" as const;
8
10
  export const GOOGLE_DRIVE_READONLY_SCOPE =
@@ -10,6 +12,57 @@ export const GOOGLE_DRIVE_READONLY_SCOPE =
10
12
  export const GOOGLE_DRIVE_CREDENTIAL_ROLE = "google_drive_metadata" as const;
11
13
  export const GOOGLE_DRIVE_CREDENTIAL_LABEL = "Google Drive metadata browser" as const;
12
14
 
15
+ export const GoogleDriveOAuthCapability = z.enum([
16
+ "picker_file_read",
17
+ "source_metadata_discovery",
18
+ "source_content_read",
19
+ "recursive_source_sync",
20
+ ]);
21
+ export type GoogleDriveOAuthCapability = z.infer<typeof GoogleDriveOAuthCapability>;
22
+
23
+ export type GoogleDriveOAuthScopeDecision = {
24
+ accessMode: "metadata_readonly" | "readonly" | null;
25
+ capabilities: GoogleDriveOAuthCapability[];
26
+ };
27
+
28
+ /**
29
+ * Converts exact Google OAuth grants into the Drive capabilities OpenGeni may
30
+ * rely on. Unknown or malformed grants add no authority. In particular,
31
+ * drive.file covers only files explicitly opened or shared with the app and
32
+ * never authorizes arbitrary recursive descendant discovery.
33
+ */
34
+ export function googleDriveOAuthScopeDecision(
35
+ grantedScopes: readonly string[],
36
+ ): GoogleDriveOAuthScopeDecision {
37
+ const granted = new Set(grantedScopes);
38
+ const hasFullDrive = granted.has(GOOGLE_DRIVE_FULL_SCOPE);
39
+ const hasSourceContentRead = hasFullDrive || granted.has(GOOGLE_DRIVE_READONLY_SCOPE);
40
+ const hasSourceMetadataDiscovery =
41
+ hasSourceContentRead || granted.has(GOOGLE_DRIVE_METADATA_READONLY_SCOPE);
42
+ const hasPickerFileRead = hasSourceContentRead || granted.has(GOOGLE_DRIVE_FILE_SCOPE);
43
+ const capabilities: GoogleDriveOAuthCapability[] = [];
44
+ if (hasPickerFileRead) capabilities.push("picker_file_read");
45
+ if (hasSourceMetadataDiscovery) capabilities.push("source_metadata_discovery");
46
+ if (hasSourceContentRead) {
47
+ capabilities.push("source_content_read", "recursive_source_sync");
48
+ }
49
+ return {
50
+ accessMode: hasSourceContentRead
51
+ ? "readonly"
52
+ : hasSourceMetadataDiscovery
53
+ ? "metadata_readonly"
54
+ : null,
55
+ capabilities,
56
+ };
57
+ }
58
+
59
+ export function googleDriveScopesAllowCapability(
60
+ grantedScopes: readonly string[],
61
+ capability: GoogleDriveOAuthCapability,
62
+ ): boolean {
63
+ return googleDriveOAuthScopeDecision(grantedScopes).capabilities.includes(capability);
64
+ }
65
+
13
66
  export const GoogleDriveTargetScope = z.enum(["user", "workspace", "organization"]);
14
67
  export type GoogleDriveTargetScope = z.infer<typeof GoogleDriveTargetScope>;
15
68
 
@@ -19,6 +72,59 @@ export type GoogleDriveSyncCadence = z.infer<typeof GoogleDriveSyncCadence>;
19
72
  export const GoogleDriveReadPolicy = z.enum(["allow", "ask", "block"]);
20
73
  export type GoogleDriveReadPolicy = z.infer<typeof GoogleDriveReadPolicy>;
21
74
 
75
+ export const GoogleDriveConnectionLifecycleState = z.enum([
76
+ "active",
77
+ "paused",
78
+ "token_revoked",
79
+ "app_removed",
80
+ "disconnected",
81
+ "reconnect_required",
82
+ "reconsent_required",
83
+ ]);
84
+ export type GoogleDriveConnectionLifecycleState = z.infer<
85
+ typeof GoogleDriveConnectionLifecycleState
86
+ >;
87
+
88
+ const GoogleDriveLifecycleObservedAt = z.string().datetime({ offset: true });
89
+ export const GoogleDriveConnectionLifecycle = z.discriminatedUnion("state", [
90
+ z.object({
91
+ state: z.literal("active"),
92
+ recoverable: z.literal(true),
93
+ observedAt: GoogleDriveLifecycleObservedAt,
94
+ }),
95
+ z.object({
96
+ state: z.literal("paused"),
97
+ recoverable: z.literal(true),
98
+ observedAt: GoogleDriveLifecycleObservedAt,
99
+ }),
100
+ z.object({
101
+ state: z.literal("token_revoked"),
102
+ recoverable: z.literal(true),
103
+ observedAt: GoogleDriveLifecycleObservedAt,
104
+ }),
105
+ z.object({
106
+ state: z.literal("app_removed"),
107
+ recoverable: z.literal(false),
108
+ observedAt: GoogleDriveLifecycleObservedAt,
109
+ }),
110
+ z.object({
111
+ state: z.literal("disconnected"),
112
+ recoverable: z.literal(true),
113
+ observedAt: GoogleDriveLifecycleObservedAt,
114
+ }),
115
+ z.object({
116
+ state: z.literal("reconnect_required"),
117
+ recoverable: z.literal(true),
118
+ observedAt: GoogleDriveLifecycleObservedAt,
119
+ }),
120
+ z.object({
121
+ state: z.literal("reconsent_required"),
122
+ recoverable: z.literal(true),
123
+ observedAt: GoogleDriveLifecycleObservedAt,
124
+ }),
125
+ ]);
126
+ export type GoogleDriveConnectionLifecycle = z.infer<typeof GoogleDriveConnectionLifecycle>;
127
+
22
128
  export const GoogleDriveSelectedSource = z.object({
23
129
  id: z.string().min(1).max(256),
24
130
  name: z.string().min(1).max(1024),
@@ -40,6 +146,7 @@ export const GoogleDriveConnectionMetadata = z
40
146
  googleDisplayName: z.string().min(1).max(512).nullable(),
41
147
  verifiedAt: z.string().datetime({ offset: true }),
42
148
  accessMode: z.enum(["metadata_readonly", "readonly"]),
149
+ lifecycle: GoogleDriveConnectionLifecycle.optional(),
43
150
  selectedSources: z.array(GoogleDriveSelectedSource).max(100).optional(),
44
151
  /** @deprecated Read `selectedSources`; retained while existing connections migrate. */
45
152
  selectedSource: GoogleDriveSelectedSource.nullable().optional(),
@@ -58,6 +165,18 @@ export const GoogleDriveOAuthStartResponse = z.object({
58
165
  });
59
166
  export type GoogleDriveOAuthStartResponse = z.infer<typeof GoogleDriveOAuthStartResponse>;
60
167
 
168
+ export const GoogleDriveLifecycleActionRequest = z.object({
169
+ action: z.enum(["pause", "resume"]),
170
+ expectedVersion: z.number().int().positive(),
171
+ });
172
+ export type GoogleDriveLifecycleActionRequest = z.infer<typeof GoogleDriveLifecycleActionRequest>;
173
+
174
+ export const GoogleDriveDisconnectRequest = z.object({
175
+ expectedVersion: z.number().int().positive(),
176
+ idempotencyKey: z.string().trim().min(1).max(200),
177
+ });
178
+ export type GoogleDriveDisconnectRequest = z.infer<typeof GoogleDriveDisconnectRequest>;
179
+
61
180
  export const GoogleDriveBrowseItem = z.object({
62
181
  id: z.string().min(1).max(256),
63
182
  name: z.string().min(1).max(1024),