@opengeni/contracts 0.32.0 → 0.36.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.
- package/dist/{chunk-GMOYIHF3.js → chunk-F4KMLKSL.js} +183 -16
- package/dist/chunk-F4KMLKSL.js.map +1 -0
- package/dist/google-drive.d.ts +82 -0
- package/dist/google-drive.js +61 -1
- package/dist/google-drive.js.map +1 -1
- package/dist/index.d.ts +90 -6
- package/dist/index.js +35 -1
- package/dist/workspace-instruction-policies.d.ts +231 -0
- package/dist/workspace-state.d.ts +218 -4
- package/package.json +1 -1
- package/src/google-drive.ts +66 -0
- package/src/index.ts +37 -14
- package/src/workspace-instruction-policies.ts +114 -0
- package/src/workspace-state.ts +112 -6
- package/dist/chunk-GMOYIHF3.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -2957,6 +2957,14 @@ export const FileResourceRef = z.object({
|
|
|
2957
2957
|
});
|
|
2958
2958
|
export type FileResourceRef = z.infer<typeof FileResourceRef>;
|
|
2959
2959
|
|
|
2960
|
+
/**
|
|
2961
|
+
* Private durable metadata carried on user history items. It contains only
|
|
2962
|
+
* stable file references, never file bytes, and is removed before model wire
|
|
2963
|
+
* serialization. Keeping the references beside the message lets a later turn
|
|
2964
|
+
* reconstruct the same typed attachment input after a model switch or retry.
|
|
2965
|
+
*/
|
|
2966
|
+
export const MODEL_ATTACHMENT_REFS_FIELD = "opengeni_attachment_refs" as const;
|
|
2967
|
+
|
|
2960
2968
|
export const ResourceRef = z.discriminatedUnion("kind", [RepositoryResourceRef, FileResourceRef]);
|
|
2961
2969
|
export type ResourceRef = z.infer<typeof ResourceRef>;
|
|
2962
2970
|
|
|
@@ -3043,10 +3051,12 @@ export function defaultRepositoryMountPath(uri: string): string {
|
|
|
3043
3051
|
}
|
|
3044
3052
|
|
|
3045
3053
|
/** Resolve the exact mount used by API normalization, manifests, and clone hooks. */
|
|
3054
|
+
export const DEFAULT_FILE_RESOURCE_MOUNT_ROOT = ".opengeni/files" as const;
|
|
3055
|
+
|
|
3046
3056
|
export function resourceMountPath(resource: ResourceRef): string {
|
|
3047
3057
|
if (resource.mountPath) return normalizeResourceMountPath(resource.mountPath);
|
|
3048
3058
|
return resource.kind === "file"
|
|
3049
|
-
? normalizeResourceMountPath(
|
|
3059
|
+
? normalizeResourceMountPath(`${DEFAULT_FILE_RESOURCE_MOUNT_ROOT}/${resource.fileId}`)
|
|
3050
3060
|
: defaultRepositoryMountPath(resource.uri);
|
|
3051
3061
|
}
|
|
3052
3062
|
|
|
@@ -3138,8 +3148,15 @@ export type KnowledgeSourceKind = z.infer<typeof KnowledgeSourceKind>;
|
|
|
3138
3148
|
export const DocumentSearchMode = z.enum(["hybrid", "vector", "keyword"]);
|
|
3139
3149
|
export type DocumentSearchMode = z.infer<typeof DocumentSearchMode>;
|
|
3140
3150
|
|
|
3151
|
+
// Durable document authority. Collections/bases are organizational metadata,
|
|
3152
|
+
// never an authorization boundary.
|
|
3153
|
+
export const DocumentAuthorityKind = z.enum(["organization", "workspace", "personal"]);
|
|
3154
|
+
export type DocumentAuthorityKind = z.infer<typeof DocumentAuthorityKind>;
|
|
3155
|
+
|
|
3141
3156
|
// 'workspace' documents are readable by anyone with workspace access;
|
|
3142
3157
|
// 'private' documents are readable only by the grant subject that created them.
|
|
3158
|
+
// Retained as a compatibility projection over authorityKind:
|
|
3159
|
+
// personal -> private; organization/workspace -> workspace.
|
|
3143
3160
|
export const DocumentVisibility = z.enum(["workspace", "private"]);
|
|
3144
3161
|
export type DocumentVisibility = z.infer<typeof DocumentVisibility>;
|
|
3145
3162
|
|
|
@@ -3198,6 +3215,9 @@ export const Document = z.object({
|
|
|
3198
3215
|
sourceUpdatedAt: z.string().nullable(),
|
|
3199
3216
|
sourceVersion: z.string().nullable(),
|
|
3200
3217
|
aclTags: z.array(z.string()),
|
|
3218
|
+
authorityKind: DocumentAuthorityKind,
|
|
3219
|
+
authorityWorkspaceId: z.string().uuid().nullable(),
|
|
3220
|
+
authoritySubjectId: z.string().nullable(),
|
|
3201
3221
|
visibility: DocumentVisibility,
|
|
3202
3222
|
createdBy: z.string().nullable(),
|
|
3203
3223
|
agentAccess: z.boolean(),
|
|
@@ -3212,6 +3232,9 @@ export type Document = z.infer<typeof Document>;
|
|
|
3212
3232
|
|
|
3213
3233
|
export const DocumentSearchResult = z.object({
|
|
3214
3234
|
chunkId: z.string().uuid(),
|
|
3235
|
+
// The workspace that ingested the document. Organization-authority results
|
|
3236
|
+
// may originate in another workspace in the same account; this identifier
|
|
3237
|
+
// is provenance and does not grant access to that workspace or its resources.
|
|
3215
3238
|
workspaceId: z.string().uuid(),
|
|
3216
3239
|
documentId: z.string().uuid(),
|
|
3217
3240
|
baseId: z.string().uuid(),
|
|
@@ -3233,9 +3256,17 @@ export const DocumentSearchResult = z.object({
|
|
|
3233
3256
|
sourceUpdatedAt: z.string().nullable(),
|
|
3234
3257
|
sourceVersion: z.string().nullable(),
|
|
3235
3258
|
aclTags: z.array(z.string()),
|
|
3259
|
+
authorityKind: DocumentAuthorityKind,
|
|
3260
|
+
authorityWorkspaceId: z.string().uuid().nullable(),
|
|
3261
|
+
authoritySubjectId: z.string().nullable(),
|
|
3236
3262
|
});
|
|
3237
3263
|
export type DocumentSearchResult = z.infer<typeof DocumentSearchResult>;
|
|
3238
3264
|
|
|
3265
|
+
export const DocumentSearchResponse = z.object({
|
|
3266
|
+
results: z.array(DocumentSearchResult),
|
|
3267
|
+
});
|
|
3268
|
+
export type DocumentSearchResponse = z.infer<typeof DocumentSearchResponse>;
|
|
3269
|
+
|
|
3239
3270
|
export const CreateDocumentBaseRequest = z.object({
|
|
3240
3271
|
name: z.string().min(1),
|
|
3241
3272
|
description: z.string().optional(),
|
|
@@ -3254,6 +3285,7 @@ export const AddDocumentRequest = z.object({
|
|
|
3254
3285
|
sourceUpdatedAt: z.string().datetime({ offset: true }).optional(),
|
|
3255
3286
|
sourceVersion: z.string().min(1).optional(),
|
|
3256
3287
|
aclTags: z.array(z.string().min(1)).optional(),
|
|
3288
|
+
authorityKind: DocumentAuthorityKind.optional(),
|
|
3257
3289
|
visibility: DocumentVisibility.optional(),
|
|
3258
3290
|
agentAccess: z.boolean().optional(),
|
|
3259
3291
|
});
|
|
@@ -3270,6 +3302,7 @@ export const CreateKnowledgeDropRequest = z
|
|
|
3270
3302
|
fileId: z.string().uuid().optional(),
|
|
3271
3303
|
filename: z.string().min(1).optional(),
|
|
3272
3304
|
title: z.string().min(1).optional(),
|
|
3305
|
+
authorityKind: DocumentAuthorityKind.optional(),
|
|
3273
3306
|
visibility: DocumentVisibility.optional(),
|
|
3274
3307
|
agentAccess: z.boolean().optional(),
|
|
3275
3308
|
})
|
|
@@ -8579,10 +8612,10 @@ export const HumanInputQuestion = z
|
|
|
8579
8612
|
options: z.array(HumanInputOption).max(20).default([]),
|
|
8580
8613
|
required: z.boolean().default(true),
|
|
8581
8614
|
allowOther: z.boolean().default(false),
|
|
8615
|
+
// Selection bounds only — agents invent useless text char mins/maxes.
|
|
8616
|
+
// Answer strings stay platform-capped on HumanInputAnswer (~8192).
|
|
8582
8617
|
validation: z
|
|
8583
8618
|
.object({
|
|
8584
|
-
minLength: z.number().int().nonnegative().max(8192).nullable().optional(),
|
|
8585
|
-
maxLength: z.number().int().positive().max(8192).nullable().optional(),
|
|
8586
8619
|
minSelections: z.number().int().nonnegative().max(20).nullable().optional(),
|
|
8587
8620
|
maxSelections: z.number().int().positive().max(20).nullable().optional(),
|
|
8588
8621
|
})
|
|
@@ -8621,17 +8654,6 @@ export const HumanInputQuestion = z
|
|
|
8621
8654
|
});
|
|
8622
8655
|
}
|
|
8623
8656
|
const validation = question.validation;
|
|
8624
|
-
if (
|
|
8625
|
-
validation?.minLength != null &&
|
|
8626
|
-
validation?.maxLength != null &&
|
|
8627
|
-
validation.minLength > validation.maxLength
|
|
8628
|
-
) {
|
|
8629
|
-
ctx.addIssue({
|
|
8630
|
-
code: "custom",
|
|
8631
|
-
path: ["validation"],
|
|
8632
|
-
message: "minLength exceeds maxLength",
|
|
8633
|
-
});
|
|
8634
|
-
}
|
|
8635
8657
|
if (
|
|
8636
8658
|
validation?.minSelections != null &&
|
|
8637
8659
|
validation?.maxSelections != null &&
|
|
@@ -9507,6 +9529,7 @@ export const ModelCapabilitiesV1 = /* @__PURE__ */ defineModelContractSchema(()
|
|
|
9507
9529
|
codeExecution: ModelCapabilityStateV1,
|
|
9508
9530
|
}),
|
|
9509
9531
|
inputModalities: z.array(z.enum(["text", "image", "audio"])),
|
|
9532
|
+
inputFileMediaTypes: z.array(z.string()).optional(),
|
|
9510
9533
|
outputModalities: z.array(z.enum(["text", "image", "audio"])),
|
|
9511
9534
|
transports: z.object({
|
|
9512
9535
|
sse: ModelCapabilityStateV1,
|
|
@@ -5,6 +5,7 @@ export const WORKSPACE_INSTRUCTION_POLICY_PROMPT_MAX_UTF8_BYTES = 131_072;
|
|
|
5
5
|
export const WORKSPACE_INSTRUCTION_POLICY_REASON_MAX_CHARS = 4_096;
|
|
6
6
|
export const WORKSPACE_INSTRUCTION_POLICY_ROLE_KEY_MAX_CHARS = 64;
|
|
7
7
|
export const WORKSPACE_INSTRUCTION_POLICY_SOURCE_ID_MAX_CHARS = 512;
|
|
8
|
+
export const WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_SOURCE_VERSION_MAX_CHARS = 256;
|
|
8
9
|
|
|
9
10
|
export const WorkspaceInstructionPolicyKind = z.enum(["charter", "policy"]);
|
|
10
11
|
export type WorkspaceInstructionPolicyKind = z.infer<typeof WorkspaceInstructionPolicyKind>;
|
|
@@ -130,6 +131,7 @@ export type WorkspaceInstructionPolicyRevisionIdentity = z.infer<
|
|
|
130
131
|
|
|
131
132
|
export const WorkspaceInstructionPolicyRevision = z.object({
|
|
132
133
|
...revisionIdentityShape,
|
|
134
|
+
operationId: z.string().uuid(),
|
|
133
135
|
accountId: z.string().uuid(),
|
|
134
136
|
workspaceId: z.string().uuid(),
|
|
135
137
|
...targetShape,
|
|
@@ -212,6 +214,7 @@ export type ResolvedWorkspaceInstructionPolicySnapshot = z.infer<
|
|
|
212
214
|
|
|
213
215
|
export const WorkspaceInstructionPolicyActivationEvent = z.object({
|
|
214
216
|
id: z.string().uuid(),
|
|
217
|
+
operationId: z.string().uuid(),
|
|
215
218
|
accountId: z.string().uuid(),
|
|
216
219
|
workspaceId: z.string().uuid(),
|
|
217
220
|
...targetShape,
|
|
@@ -229,6 +232,7 @@ export type WorkspaceInstructionPolicyActivationEvent = z.infer<
|
|
|
229
232
|
|
|
230
233
|
export const CreateWorkspaceInstructionPolicyDraftRequest = z
|
|
231
234
|
.object({
|
|
235
|
+
operationId: z.string().uuid().optional(),
|
|
232
236
|
kind: WorkspaceInstructionPolicyKind,
|
|
233
237
|
scope: WorkspaceInstructionPolicyScope,
|
|
234
238
|
roleKey: WorkspaceInstructionPolicyRoleKeyInput.nullable().default(null),
|
|
@@ -253,6 +257,7 @@ export type CreateWorkspaceInstructionPolicyDraftRequest = z.infer<
|
|
|
253
257
|
|
|
254
258
|
export const ImportLegacyWorkspaceInstructionPolicyDraftRequest = z
|
|
255
259
|
.object({
|
|
260
|
+
operationId: z.string().uuid().optional(),
|
|
256
261
|
supersedesRevisionId: z.string().uuid().nullable().default(null),
|
|
257
262
|
})
|
|
258
263
|
.strict();
|
|
@@ -305,7 +310,9 @@ export type WorkspaceInstructionPolicyDiffResponse = z.infer<
|
|
|
305
310
|
>;
|
|
306
311
|
|
|
307
312
|
export const ActivateWorkspaceInstructionPolicyRequest = z.object({
|
|
313
|
+
operationId: z.string().uuid().optional(),
|
|
308
314
|
expectedCurrentRevisionId: z.string().uuid().nullable(),
|
|
315
|
+
expectedActivationVersion: z.number().int().nonnegative().optional(),
|
|
309
316
|
reason: z.string().trim().min(1).max(WORKSPACE_INSTRUCTION_POLICY_REASON_MAX_CHARS),
|
|
310
317
|
});
|
|
311
318
|
export type ActivateWorkspaceInstructionPolicyRequest = z.infer<
|
|
@@ -313,8 +320,10 @@ export type ActivateWorkspaceInstructionPolicyRequest = z.infer<
|
|
|
313
320
|
>;
|
|
314
321
|
|
|
315
322
|
export const RollbackWorkspaceInstructionPolicyRequest = z.object({
|
|
323
|
+
operationId: z.string().uuid().optional(),
|
|
316
324
|
targetRevisionId: z.string().uuid(),
|
|
317
325
|
expectedCurrentRevisionId: z.string().uuid(),
|
|
326
|
+
expectedActivationVersion: z.number().int().positive().optional(),
|
|
318
327
|
reason: z.string().trim().min(1).max(WORKSPACE_INSTRUCTION_POLICY_REASON_MAX_CHARS),
|
|
319
328
|
});
|
|
320
329
|
export type RollbackWorkspaceInstructionPolicyRequest = z.infer<
|
|
@@ -337,3 +346,108 @@ export const WorkspaceInstructionPolicyConflictResponse = z.object({
|
|
|
337
346
|
export type WorkspaceInstructionPolicyConflictResponse = z.infer<
|
|
338
347
|
typeof WorkspaceInstructionPolicyConflictResponse
|
|
339
348
|
>;
|
|
349
|
+
|
|
350
|
+
export const WorkspaceInstructionPolicyOperationReuseResponse = z.object({
|
|
351
|
+
code: z.literal("WORKSPACE_INSTRUCTION_POLICY_OPERATION_REUSED"),
|
|
352
|
+
message: z.string(),
|
|
353
|
+
});
|
|
354
|
+
export type WorkspaceInstructionPolicyOperationReuseResponse = z.infer<
|
|
355
|
+
typeof WorkspaceInstructionPolicyOperationReuseResponse
|
|
356
|
+
>;
|
|
357
|
+
|
|
358
|
+
export const WorkspaceInstructionPolicyOnboardingProposalSource = z.object({
|
|
359
|
+
id: z.string().min(1).max(WORKSPACE_INSTRUCTION_POLICY_SOURCE_ID_MAX_CHARS),
|
|
360
|
+
version: z.string().min(1).max(WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_SOURCE_VERSION_MAX_CHARS),
|
|
361
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
362
|
+
});
|
|
363
|
+
export type WorkspaceInstructionPolicyOnboardingProposalSource = z.infer<
|
|
364
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalSource
|
|
365
|
+
>;
|
|
366
|
+
|
|
367
|
+
export const CreateWorkspaceInstructionPolicyOnboardingProposalRequest = z
|
|
368
|
+
.object({
|
|
369
|
+
operationId: z.string().uuid().optional(),
|
|
370
|
+
kind: WorkspaceInstructionPolicyKind,
|
|
371
|
+
scope: WorkspaceInstructionPolicyScope,
|
|
372
|
+
roleKey: WorkspaceInstructionPolicyRoleKeyInput.nullable().default(null),
|
|
373
|
+
// Content bounds are enforced by the domain layer so empty and oversized
|
|
374
|
+
// proposals retain their typed API outcomes instead of collapsing into a
|
|
375
|
+
// generic request-shape error.
|
|
376
|
+
content: z.string(),
|
|
377
|
+
sourceId: z.string().trim().min(1).max(WORKSPACE_INSTRUCTION_POLICY_SOURCE_ID_MAX_CHARS),
|
|
378
|
+
sourceVersion: z
|
|
379
|
+
.string()
|
|
380
|
+
.trim()
|
|
381
|
+
.min(1)
|
|
382
|
+
.max(WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_SOURCE_VERSION_MAX_CHARS),
|
|
383
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
384
|
+
expectedCurrentRevisionId: z.string().uuid().nullable(),
|
|
385
|
+
expectedActivationVersion: z.number().int().nonnegative(),
|
|
386
|
+
})
|
|
387
|
+
.superRefine(validateTarget);
|
|
388
|
+
export type CreateWorkspaceInstructionPolicyOnboardingProposalRequest = z.infer<
|
|
389
|
+
typeof CreateWorkspaceInstructionPolicyOnboardingProposalRequest
|
|
390
|
+
>;
|
|
391
|
+
|
|
392
|
+
export const WorkspaceInstructionPolicyOnboardingProposal = z.object({
|
|
393
|
+
id: z.string().uuid(),
|
|
394
|
+
operationId: z.string().uuid(),
|
|
395
|
+
accountId: z.string().uuid(),
|
|
396
|
+
workspaceId: z.string().uuid(),
|
|
397
|
+
...targetShape,
|
|
398
|
+
source: WorkspaceInstructionPolicyOnboardingProposalSource,
|
|
399
|
+
baseline: WorkspaceInstructionPolicyHead.nullable(),
|
|
400
|
+
draft: WorkspaceInstructionPolicyRevision,
|
|
401
|
+
status: z.literal("proposed"),
|
|
402
|
+
createdBySubjectId: z.string().min(1),
|
|
403
|
+
createdAt: z.string().datetime(),
|
|
404
|
+
});
|
|
405
|
+
export type WorkspaceInstructionPolicyOnboardingProposal = z.infer<
|
|
406
|
+
typeof WorkspaceInstructionPolicyOnboardingProposal
|
|
407
|
+
>;
|
|
408
|
+
|
|
409
|
+
export const WorkspaceInstructionPolicyOnboardingProposalListQuery = z.object({
|
|
410
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
411
|
+
});
|
|
412
|
+
export type WorkspaceInstructionPolicyOnboardingProposalListQuery = z.infer<
|
|
413
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalListQuery
|
|
414
|
+
>;
|
|
415
|
+
|
|
416
|
+
export const WorkspaceInstructionPolicyOnboardingProposalListResponse = z.object({
|
|
417
|
+
proposals: z.array(WorkspaceInstructionPolicyOnboardingProposal),
|
|
418
|
+
truncated: z.boolean(),
|
|
419
|
+
});
|
|
420
|
+
export type WorkspaceInstructionPolicyOnboardingProposalListResponse = z.infer<
|
|
421
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalListResponse
|
|
422
|
+
>;
|
|
423
|
+
|
|
424
|
+
export const WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse = z.object({
|
|
425
|
+
code: z.enum([
|
|
426
|
+
"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_EMPTY",
|
|
427
|
+
"WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_OVERSIZED",
|
|
428
|
+
]),
|
|
429
|
+
message: z.string(),
|
|
430
|
+
maxChars: z.number().int().positive(),
|
|
431
|
+
});
|
|
432
|
+
export type WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse = z.infer<
|
|
433
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse
|
|
434
|
+
>;
|
|
435
|
+
|
|
436
|
+
export const WorkspaceInstructionPolicyOnboardingProposalStaleResponse = z.object({
|
|
437
|
+
code: z.literal("WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_STALE"),
|
|
438
|
+
message: z.string(),
|
|
439
|
+
currentHead: WorkspaceInstructionPolicyHead.nullable(),
|
|
440
|
+
});
|
|
441
|
+
export type WorkspaceInstructionPolicyOnboardingProposalStaleResponse = z.infer<
|
|
442
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalStaleResponse
|
|
443
|
+
>;
|
|
444
|
+
|
|
445
|
+
export const WorkspaceInstructionPolicyOnboardingProposalConflictResponse = z.object({
|
|
446
|
+
code: z.literal("WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_CONFLICT"),
|
|
447
|
+
message: z.string(),
|
|
448
|
+
existingProposalId: z.string().uuid(),
|
|
449
|
+
existingDraftRevisionId: z.string().uuid(),
|
|
450
|
+
});
|
|
451
|
+
export type WorkspaceInstructionPolicyOnboardingProposalConflictResponse = z.infer<
|
|
452
|
+
typeof WorkspaceInstructionPolicyOnboardingProposalConflictResponse
|
|
453
|
+
>;
|
package/src/workspace-state.ts
CHANGED
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
WorkspaceInstructionPolicyKind,
|
|
5
5
|
WorkspaceInstructionPolicyProvenanceSource,
|
|
6
6
|
WorkspaceInstructionPolicyRoleKey,
|
|
7
|
+
WorkspaceInstructionPolicyRoleSource,
|
|
7
8
|
WorkspaceInstructionPolicyScope,
|
|
9
|
+
WorkspaceInstructionPolicySnapshotEntry,
|
|
8
10
|
} from "./workspace-instruction-policies";
|
|
9
11
|
|
|
10
12
|
export const WORKSPACE_STATE_MAX_ACTIVE_POLICY_HEADS = 32;
|
|
@@ -17,6 +19,9 @@ export const WORKSPACE_STATE_MEMORY_SAMPLE_LIMIT = 100;
|
|
|
17
19
|
|
|
18
20
|
const Count = z.number().int().nonnegative();
|
|
19
21
|
|
|
22
|
+
export const WorkspaceStateQuery = z.object({ attemptId: z.string().uuid().optional() }).strict();
|
|
23
|
+
export type WorkspaceStateQuery = z.infer<typeof WorkspaceStateQuery>;
|
|
24
|
+
|
|
20
25
|
export const WorkspaceStateDocumentStatusCounts = z
|
|
21
26
|
.object({
|
|
22
27
|
queued: Count,
|
|
@@ -196,6 +201,112 @@ export const WorkspaceStateKnowledge = z.discriminatedUnion("availability", [
|
|
|
196
201
|
]);
|
|
197
202
|
export type WorkspaceStateKnowledge = z.infer<typeof WorkspaceStateKnowledge>;
|
|
198
203
|
|
|
204
|
+
export const WorkspaceStateGovernanceDriftStatus = z.enum([
|
|
205
|
+
"identical",
|
|
206
|
+
"changed",
|
|
207
|
+
"superseded",
|
|
208
|
+
"missing",
|
|
209
|
+
"unavailable",
|
|
210
|
+
"truncated",
|
|
211
|
+
]);
|
|
212
|
+
export type WorkspaceStateGovernanceDriftStatus = z.infer<
|
|
213
|
+
typeof WorkspaceStateGovernanceDriftStatus
|
|
214
|
+
>;
|
|
215
|
+
|
|
216
|
+
const WorkspaceStatePolicySnapshotAvailable = z
|
|
217
|
+
.object({
|
|
218
|
+
status: z.literal("available"),
|
|
219
|
+
id: z.string().uuid(),
|
|
220
|
+
createdAt: z.string().datetime(),
|
|
221
|
+
entryHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
222
|
+
policyRole: WorkspaceInstructionPolicyRoleKey.nullable(),
|
|
223
|
+
roleSource: WorkspaceInstructionPolicyRoleSource,
|
|
224
|
+
entries: z.array(WorkspaceInstructionPolicySnapshotEntry).max(3),
|
|
225
|
+
})
|
|
226
|
+
.strict();
|
|
227
|
+
|
|
228
|
+
const WorkspaceStatePolicySnapshotMissing = z.object({ status: z.literal("missing") }).strict();
|
|
229
|
+
|
|
230
|
+
const WorkspaceStatePreferenceSnapshotAvailable = z
|
|
231
|
+
.object({
|
|
232
|
+
status: z.literal("available"),
|
|
233
|
+
id: z.string().uuid(),
|
|
234
|
+
createdAt: z.string().datetime(),
|
|
235
|
+
descriptorHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
236
|
+
descriptorCount: Count.max(64),
|
|
237
|
+
truncated: z.boolean(),
|
|
238
|
+
})
|
|
239
|
+
.strict();
|
|
240
|
+
|
|
241
|
+
const WorkspaceStatePreferenceSnapshotMissing = z.object({ status: z.literal("missing") }).strict();
|
|
242
|
+
|
|
243
|
+
const WorkspaceStateGovernanceDrift = z
|
|
244
|
+
.object({
|
|
245
|
+
overall: WorkspaceStateGovernanceDriftStatus,
|
|
246
|
+
policy: z
|
|
247
|
+
.object({
|
|
248
|
+
status: WorkspaceStateGovernanceDriftStatus,
|
|
249
|
+
snapshotHash: z
|
|
250
|
+
.string()
|
|
251
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
252
|
+
.nullable(),
|
|
253
|
+
currentHash: z
|
|
254
|
+
.string()
|
|
255
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
256
|
+
.nullable(),
|
|
257
|
+
snapshotTargetCount: Count,
|
|
258
|
+
currentTargetCount: Count,
|
|
259
|
+
})
|
|
260
|
+
.strict(),
|
|
261
|
+
preferences: z
|
|
262
|
+
.object({
|
|
263
|
+
status: WorkspaceStateGovernanceDriftStatus,
|
|
264
|
+
snapshotHash: z
|
|
265
|
+
.string()
|
|
266
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
267
|
+
.nullable(),
|
|
268
|
+
currentHash: z
|
|
269
|
+
.string()
|
|
270
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
271
|
+
.nullable(),
|
|
272
|
+
snapshotDescriptorCount: Count,
|
|
273
|
+
currentDescriptorCount: Count,
|
|
274
|
+
snapshotTruncated: z.boolean(),
|
|
275
|
+
currentTruncated: z.boolean(),
|
|
276
|
+
})
|
|
277
|
+
.strict(),
|
|
278
|
+
})
|
|
279
|
+
.strict();
|
|
280
|
+
|
|
281
|
+
export const WorkspaceStateAttemptGovernance = z.discriminatedUnion("status", [
|
|
282
|
+
z.object({ status: z.literal("not_requested") }).strict(),
|
|
283
|
+
z
|
|
284
|
+
.object({
|
|
285
|
+
status: z.literal("unavailable"),
|
|
286
|
+
reason: z.literal("attempt_not_found_or_not_authorized"),
|
|
287
|
+
driftStatus: z.literal("unavailable"),
|
|
288
|
+
})
|
|
289
|
+
.strict(),
|
|
290
|
+
z
|
|
291
|
+
.object({
|
|
292
|
+
status: z.literal("available"),
|
|
293
|
+
attemptId: z.string().uuid(),
|
|
294
|
+
executionGeneration: z.number().int().positive(),
|
|
295
|
+
acceptedAt: z.string().datetime(),
|
|
296
|
+
policySnapshot: z.discriminatedUnion("status", [
|
|
297
|
+
WorkspaceStatePolicySnapshotAvailable,
|
|
298
|
+
WorkspaceStatePolicySnapshotMissing,
|
|
299
|
+
]),
|
|
300
|
+
preferenceSnapshot: z.discriminatedUnion("status", [
|
|
301
|
+
WorkspaceStatePreferenceSnapshotAvailable,
|
|
302
|
+
WorkspaceStatePreferenceSnapshotMissing,
|
|
303
|
+
]),
|
|
304
|
+
drift: WorkspaceStateGovernanceDrift,
|
|
305
|
+
})
|
|
306
|
+
.strict(),
|
|
307
|
+
]);
|
|
308
|
+
export type WorkspaceStateAttemptGovernance = z.infer<typeof WorkspaceStateAttemptGovernance>;
|
|
309
|
+
|
|
199
310
|
export const WorkspaceStateResponse = z
|
|
200
311
|
.object({
|
|
201
312
|
workspaceId: z.string().uuid(),
|
|
@@ -208,12 +319,7 @@ export const WorkspaceStateResponse = z
|
|
|
208
319
|
capturedAt: z.string().datetime(),
|
|
209
320
|
})
|
|
210
321
|
.strict(),
|
|
211
|
-
|
|
212
|
-
.object({
|
|
213
|
-
status: z.literal("not_captured"),
|
|
214
|
-
reason: z.literal("workspace_instruction_policy_snapshot_not_implemented"),
|
|
215
|
-
})
|
|
216
|
-
.strict(),
|
|
322
|
+
attemptGovernance: WorkspaceStateAttemptGovernance,
|
|
217
323
|
})
|
|
218
324
|
.strict(),
|
|
219
325
|
policy: WorkspaceStatePolicy,
|