@opengeni/contracts 0.40.0 → 0.50.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/atlassian.d.ts +278 -0
- package/dist/atlassian.js +57 -0
- package/dist/atlassian.js.map +1 -0
- package/dist/canonical-human-identities.d.ts +157 -0
- package/dist/canonical-human-identities.js +23 -0
- package/dist/canonical-human-identities.js.map +1 -0
- package/dist/{chunk-7JZMI22I.js → chunk-5UDNP7AO.js} +34 -2
- package/dist/chunk-5UDNP7AO.js.map +1 -0
- package/dist/chunk-BVGIYW7D.js +11 -0
- package/dist/chunk-BVGIYW7D.js.map +1 -0
- package/dist/chunk-CADSX6UN.js +1145 -0
- package/dist/chunk-CADSX6UN.js.map +1 -0
- package/dist/chunk-CM6BMECR.js +24 -0
- package/dist/chunk-CM6BMECR.js.map +1 -0
- package/dist/chunk-D2HKF2EF.js +1460 -0
- package/dist/chunk-D2HKF2EF.js.map +1 -0
- package/dist/chunk-JBCIY7QD.js +194 -0
- package/dist/chunk-JBCIY7QD.js.map +1 -0
- package/dist/chunk-JUFK3T4Q.js +80 -0
- package/dist/chunk-JUFK3T4Q.js.map +1 -0
- package/dist/chunk-LSB7GRLG.js +779 -0
- package/dist/chunk-LSB7GRLG.js.map +1 -0
- package/dist/chunk-LW7OH6CS.js +382 -0
- package/dist/chunk-LW7OH6CS.js.map +1 -0
- package/dist/chunk-M5ZGRVIQ.js +719 -0
- package/dist/chunk-M5ZGRVIQ.js.map +1 -0
- package/dist/chunk-MYBZRDTY.js +340 -0
- package/dist/chunk-MYBZRDTY.js.map +1 -0
- package/dist/chunk-Q6A7XT2N.js +16734 -0
- package/dist/chunk-Q6A7XT2N.js.map +1 -0
- package/dist/chunk-RIY7GYQS.js +1204 -0
- package/dist/chunk-RIY7GYQS.js.map +1 -0
- package/dist/chunk-TZ6YEYN4.js +386 -0
- package/dist/chunk-TZ6YEYN4.js.map +1 -0
- package/dist/chunk-Y3MLSLB4.js +392 -0
- package/dist/chunk-Y3MLSLB4.js.map +1 -0
- package/dist/chunk-YRKRZ6OF.js +134 -0
- package/dist/chunk-YRKRZ6OF.js.map +1 -0
- package/dist/codex-provider-account-authority.d.ts +23 -0
- package/dist/codex-provider-account-authority.js +23 -0
- package/dist/codex-provider-account-authority.js.map +1 -0
- package/dist/company-profile.d.ts +629 -0
- package/dist/document-artifact-commands.d.ts +282 -0
- package/dist/document-artifact-commands.js +54 -0
- package/dist/document-artifact-commands.js.map +1 -0
- package/dist/document-artifact-query.d.ts +2 -0
- package/dist/document-artifact-query.js +54 -0
- package/dist/document-artifact-query.js.map +1 -0
- package/dist/editable-artifact-binary.d.ts +56 -0
- package/dist/editable-artifact-causal-frontier.d.ts +12 -0
- package/dist/editable-artifact-causal-frontier.js +18 -0
- package/dist/editable-artifact-causal-frontier.js.map +1 -0
- package/dist/editable-artifact-codec-registry.d.ts +48 -0
- package/dist/editable-artifact-codec-registry.js +20 -0
- package/dist/editable-artifact-codec-registry.js.map +1 -0
- package/dist/editable-artifact-committed-transaction.d.ts +35 -0
- package/dist/editable-artifact-committed-transaction.js +19 -0
- package/dist/editable-artifact-committed-transaction.js.map +1 -0
- package/dist/editable-artifact-live.d.ts +276 -0
- package/dist/editable-artifact-live.js +907 -0
- package/dist/editable-artifact-live.js.map +1 -0
- package/dist/editable-artifact-serialized-commit.d.ts +53 -0
- package/dist/editable-artifact-serialized-commit.js +26 -0
- package/dist/editable-artifact-serialized-commit.js.map +1 -0
- package/dist/editable-artifact-versions.d.ts +6 -0
- package/dist/editable-artifact-versions.js +11 -0
- package/dist/editable-artifact-versions.js.map +1 -0
- package/dist/editable-artifacts.d.ts +46 -0
- package/dist/editable-artifacts.js +236 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/event-preview.d.ts +1 -1
- package/dist/google-drive.d.ts +114 -2
- package/dist/google-drive.js +72 -14
- package/dist/google-drive.js.map +1 -1
- package/dist/image-generation.d.ts +70 -0
- package/dist/index.d.ts +5661 -166
- package/dist/index.js +1438 -21
- package/dist/interaction.d.ts +8290 -0
- package/dist/knowledge.d.ts +543 -0
- package/dist/memory-slack-delivery.d.ts +397 -0
- package/dist/presentation-artifact-commands.d.ts +349 -0
- package/dist/presentation-artifact-commands.js +66 -0
- package/dist/presentation-artifact-commands.js.map +1 -0
- package/dist/presentation-artifact-query.d.ts +2 -0
- package/dist/presentation-artifact-query.js +66 -0
- package/dist/presentation-artifact-query.js.map +1 -0
- package/dist/retained-output.d.ts +24 -0
- package/dist/sandbox-snapshots.d.ts +9 -0
- package/dist/scoped-knowledge.d.ts +14 -13
- package/dist/slack-bot-scopes.d.ts +4 -0
- package/dist/slack-bot-scopes.js +3 -1
- package/dist/slack-task-policy.d.ts +294 -0
- package/dist/spreadsheet-artifact-commands.d.ts +101 -0
- package/dist/spreadsheet-artifact-commands.js +27 -0
- package/dist/spreadsheet-artifact-commands.js.map +1 -0
- package/dist/spreadsheet-artifact-date.d.ts +4 -0
- package/dist/spreadsheet-artifact-query.d.ts +120 -0
- package/dist/spreadsheet-artifact-query.js +48 -0
- package/dist/spreadsheet-artifact-query.js.map +1 -0
- package/dist/task-notes.d.ts +128 -0
- package/dist/tool-catalog.d.ts +576 -0
- package/dist/video-generation.d.ts +580 -0
- package/dist/video-generation.js +59 -0
- package/dist/video-generation.js.map +1 -0
- package/dist/workspace-learning-policy.d.ts +208 -0
- package/dist/xai-provider-account-authority.d.ts +23 -0
- package/dist/xai-provider-account-authority.js +9 -0
- package/dist/xai-provider-account-authority.js.map +1 -0
- package/package.json +73 -1
- package/src/artifacts.ts +1 -1
- package/src/atlassian.ts +160 -0
- package/src/canonical-human-identities.ts +93 -0
- package/src/codex-provider-account-authority.ts +37 -0
- package/src/company-profile.ts +306 -0
- package/src/document-artifact-commands.ts +1709 -0
- package/src/document-artifact-query.ts +2 -0
- package/src/editable-artifact-binary.ts +396 -0
- package/src/editable-artifact-causal-frontier.ts +154 -0
- package/src/editable-artifact-codec-registry.ts +261 -0
- package/src/editable-artifact-committed-transaction.ts +478 -0
- package/src/editable-artifact-live.ts +1379 -0
- package/src/editable-artifact-serialized-commit.ts +494 -0
- package/src/editable-artifact-versions.ts +8 -0
- package/src/editable-artifacts.ts +473 -0
- package/src/google-drive.ts +68 -15
- package/src/image-generation.ts +106 -0
- package/src/index.ts +2920 -326
- package/src/interaction.ts +3173 -0
- package/src/knowledge.ts +207 -0
- package/src/memory-slack-delivery.ts +183 -0
- package/src/presentation-artifact-commands.ts +2035 -0
- package/src/presentation-artifact-query.ts +2 -0
- package/src/retained-output.ts +149 -2
- package/src/sandbox-snapshots.ts +28 -1
- package/src/scoped-knowledge.ts +18 -4
- package/src/slack-bot-scopes.ts +34 -1
- package/src/slack-task-policy.ts +215 -0
- package/src/spreadsheet-artifact-commands.ts +999 -0
- package/src/spreadsheet-artifact-date.ts +21 -0
- package/src/spreadsheet-artifact-query.ts +1411 -0
- package/src/task-notes.ts +92 -0
- package/src/tool-catalog.ts +334 -0
- package/src/video-generation.ts +431 -0
- package/src/workspace-learning-policy.ts +233 -0
- package/src/xai-provider-account-authority.ts +37 -0
- package/dist/chunk-5HR2GPSC.js +0 -11031
- package/dist/chunk-5HR2GPSC.js.map +0 -1
- package/dist/chunk-7JZMI22I.js.map +0 -1
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
GENERATED_VIDEO_MAX_BYTES,
|
|
4
|
+
RETAINED_OUTPUT_MAX_PAGE_BYTES,
|
|
5
|
+
RetainedArtifactReferenceSchema,
|
|
6
|
+
} from "./retained-output";
|
|
7
|
+
|
|
8
|
+
export const VIDEO_GENERATION_SCHEMA_VERSION = 1 as const;
|
|
9
|
+
export const SEEDANCE_2_5_MODEL_ID = "bytedance/seedance-2.5" as const;
|
|
10
|
+
export const GROK_IMAGINE_VIDEO_1_5_MODEL_ID = "xai/grok-imagine-video-1.5" as const;
|
|
11
|
+
|
|
12
|
+
export const VideoGenerationSourceMode = z.enum([
|
|
13
|
+
"text",
|
|
14
|
+
"first_frame",
|
|
15
|
+
"first_and_last_frames",
|
|
16
|
+
"image_reference",
|
|
17
|
+
"video_reference",
|
|
18
|
+
]);
|
|
19
|
+
export type VideoGenerationSourceMode = z.infer<typeof VideoGenerationSourceMode>;
|
|
20
|
+
|
|
21
|
+
export const VideoGenerationResolution = z.enum(["480p", "720p"]);
|
|
22
|
+
export type VideoGenerationResolution = z.infer<typeof VideoGenerationResolution>;
|
|
23
|
+
|
|
24
|
+
export const VideoGenerationFundingSource = z.enum([
|
|
25
|
+
"opengeni_credits",
|
|
26
|
+
"workspace_gateway",
|
|
27
|
+
"supergrok_subscription",
|
|
28
|
+
]);
|
|
29
|
+
export type VideoGenerationFundingSource = z.infer<typeof VideoGenerationFundingSource>;
|
|
30
|
+
|
|
31
|
+
export const VideoGenerationAspectRatio = z.enum([
|
|
32
|
+
"16:9",
|
|
33
|
+
"4:3",
|
|
34
|
+
"1:1",
|
|
35
|
+
"3:4",
|
|
36
|
+
"9:16",
|
|
37
|
+
"21:9",
|
|
38
|
+
"adaptive",
|
|
39
|
+
]);
|
|
40
|
+
export type VideoGenerationAspectRatio = z.infer<typeof VideoGenerationAspectRatio>;
|
|
41
|
+
|
|
42
|
+
const SandboxVideoReferencePath = z
|
|
43
|
+
.string()
|
|
44
|
+
.min(1)
|
|
45
|
+
.max(1_024)
|
|
46
|
+
.refine((value) => value.startsWith("/workspace/"), {
|
|
47
|
+
message: "video references must use an absolute /workspace path",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const VideoGenerationSource = z.discriminatedUnion("mode", [
|
|
51
|
+
z.object({ mode: z.literal("text") }).strict(),
|
|
52
|
+
z
|
|
53
|
+
.object({
|
|
54
|
+
mode: z.literal("first_frame"),
|
|
55
|
+
imagePath: SandboxVideoReferencePath,
|
|
56
|
+
})
|
|
57
|
+
.strict(),
|
|
58
|
+
z
|
|
59
|
+
.object({
|
|
60
|
+
mode: z.literal("first_and_last_frames"),
|
|
61
|
+
firstFramePath: SandboxVideoReferencePath,
|
|
62
|
+
lastFramePath: SandboxVideoReferencePath,
|
|
63
|
+
})
|
|
64
|
+
.strict()
|
|
65
|
+
.refine((value) => value.firstFramePath !== value.lastFramePath, {
|
|
66
|
+
path: ["lastFramePath"],
|
|
67
|
+
message: "first and last frame paths must differ",
|
|
68
|
+
}),
|
|
69
|
+
z
|
|
70
|
+
.object({
|
|
71
|
+
mode: z.literal("image_reference"),
|
|
72
|
+
imagePath: SandboxVideoReferencePath,
|
|
73
|
+
})
|
|
74
|
+
.strict(),
|
|
75
|
+
z
|
|
76
|
+
.object({
|
|
77
|
+
mode: z.literal("video_reference"),
|
|
78
|
+
videoPath: SandboxVideoReferencePath,
|
|
79
|
+
})
|
|
80
|
+
.strict(),
|
|
81
|
+
]);
|
|
82
|
+
export type VideoGenerationSource = z.infer<typeof VideoGenerationSource>;
|
|
83
|
+
|
|
84
|
+
/** Stable provider-neutral function-tool input. Dynamic capability facts never enter this schema. */
|
|
85
|
+
export const GenerateVideoToolInput = z
|
|
86
|
+
.object({
|
|
87
|
+
prompt: z
|
|
88
|
+
.string()
|
|
89
|
+
.min(1)
|
|
90
|
+
.max(32_000)
|
|
91
|
+
.refine((value) => value.trim().length > 0),
|
|
92
|
+
modelId: z.string().min(1).max(256).optional(),
|
|
93
|
+
source: VideoGenerationSource.optional(),
|
|
94
|
+
durationSeconds: z.number().int().min(4).max(30).optional(),
|
|
95
|
+
aspectRatio: VideoGenerationAspectRatio.optional(),
|
|
96
|
+
resolution: VideoGenerationResolution.optional(),
|
|
97
|
+
generateAudio: z.boolean().optional(),
|
|
98
|
+
})
|
|
99
|
+
.strict();
|
|
100
|
+
export type GenerateVideoToolInput = z.infer<typeof GenerateVideoToolInput>;
|
|
101
|
+
|
|
102
|
+
export const GetVideoGenerationCapabilitiesToolInput = z.object({}).strict();
|
|
103
|
+
export type GetVideoGenerationCapabilitiesToolInput = z.infer<
|
|
104
|
+
typeof GetVideoGenerationCapabilitiesToolInput
|
|
105
|
+
>;
|
|
106
|
+
|
|
107
|
+
export const VideoGenerationModelCapability = z
|
|
108
|
+
.object({
|
|
109
|
+
modelId: z.string().min(1).max(256),
|
|
110
|
+
label: z.string().min(1).max(128),
|
|
111
|
+
providerLabel: z.string().min(1).max(128),
|
|
112
|
+
sourceModes: z.array(VideoGenerationSourceMode).min(1).max(5),
|
|
113
|
+
resolutions: z.array(VideoGenerationResolution).min(1).max(2),
|
|
114
|
+
aspectRatios: z.array(VideoGenerationAspectRatio).min(1).max(7),
|
|
115
|
+
duration: z
|
|
116
|
+
.object({
|
|
117
|
+
minSeconds: z.number().int().positive(),
|
|
118
|
+
maxSeconds: z.number().int().positive(),
|
|
119
|
+
stepSeconds: z.number().int().positive(),
|
|
120
|
+
})
|
|
121
|
+
.strict()
|
|
122
|
+
.refine((value) => value.maxSeconds >= value.minSeconds),
|
|
123
|
+
supportsAudio: z.boolean(),
|
|
124
|
+
})
|
|
125
|
+
.strict();
|
|
126
|
+
export type VideoGenerationModelCapability = z.infer<typeof VideoGenerationModelCapability>;
|
|
127
|
+
|
|
128
|
+
export const VideoGenerationCapabilities = z
|
|
129
|
+
.object({
|
|
130
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
131
|
+
capabilityRevision: z.string().min(1).max(128),
|
|
132
|
+
defaultModelId: z.string().min(1).max(256),
|
|
133
|
+
models: z.array(VideoGenerationModelCapability).min(1).max(16),
|
|
134
|
+
})
|
|
135
|
+
.strict()
|
|
136
|
+
.superRefine((value, ctx) => {
|
|
137
|
+
const ids = new Set(value.models.map((model) => model.modelId));
|
|
138
|
+
if (ids.size !== value.models.length) {
|
|
139
|
+
ctx.addIssue({
|
|
140
|
+
code: "custom",
|
|
141
|
+
path: ["models"],
|
|
142
|
+
message: "model ids must be unique",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (!ids.has(value.defaultModelId)) {
|
|
146
|
+
ctx.addIssue({
|
|
147
|
+
code: "custom",
|
|
148
|
+
path: ["defaultModelId"],
|
|
149
|
+
message: "default model must be present in the enabled model list",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
export type VideoGenerationCapabilities = z.infer<typeof VideoGenerationCapabilities>;
|
|
154
|
+
|
|
155
|
+
export const VideoGenerationPolicy = z
|
|
156
|
+
.object({
|
|
157
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
158
|
+
revision: z.number().int().nonnegative().safe(),
|
|
159
|
+
fundingSource: VideoGenerationFundingSource,
|
|
160
|
+
enabledModelIds: z.array(z.string().min(1).max(256)).max(16),
|
|
161
|
+
defaultModelId: z.string().min(1).max(256).nullable(),
|
|
162
|
+
})
|
|
163
|
+
.strict()
|
|
164
|
+
.superRefine((value, ctx) => {
|
|
165
|
+
const ids = new Set(value.enabledModelIds);
|
|
166
|
+
if (ids.size !== value.enabledModelIds.length) {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: "custom",
|
|
169
|
+
path: ["enabledModelIds"],
|
|
170
|
+
message: "enabled model ids must be unique",
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (value.defaultModelId !== null && !ids.has(value.defaultModelId)) {
|
|
174
|
+
ctx.addIssue({
|
|
175
|
+
code: "custom",
|
|
176
|
+
path: ["defaultModelId"],
|
|
177
|
+
message: "default model must be enabled",
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
export type VideoGenerationPolicy = z.infer<typeof VideoGenerationPolicy>;
|
|
182
|
+
|
|
183
|
+
export const UpdateVideoGenerationPolicyRequest = z
|
|
184
|
+
.object({
|
|
185
|
+
expectedRevision: z.number().int().nonnegative().safe(),
|
|
186
|
+
fundingSource: VideoGenerationFundingSource,
|
|
187
|
+
enabledModelIds: z.array(z.string().min(1).max(256)).max(16),
|
|
188
|
+
defaultModelId: z.string().min(1).max(256).nullable(),
|
|
189
|
+
})
|
|
190
|
+
.strict();
|
|
191
|
+
export type UpdateVideoGenerationPolicyRequest = z.infer<typeof UpdateVideoGenerationPolicyRequest>;
|
|
192
|
+
|
|
193
|
+
export const VideoGenerationFundingOption = z
|
|
194
|
+
.object({
|
|
195
|
+
source: VideoGenerationFundingSource,
|
|
196
|
+
label: z.string().min(1).max(128),
|
|
197
|
+
description: z.string().min(1).max(256),
|
|
198
|
+
available: z.boolean(),
|
|
199
|
+
unavailableReason: z.string().min(1).max(256).nullable(),
|
|
200
|
+
})
|
|
201
|
+
.strict()
|
|
202
|
+
.superRefine((value, ctx) => {
|
|
203
|
+
if (value.available !== (value.unavailableReason === null)) {
|
|
204
|
+
ctx.addIssue({
|
|
205
|
+
code: "custom",
|
|
206
|
+
path: ["unavailableReason"],
|
|
207
|
+
message: "available funding options cannot have an unavailable reason",
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
export type VideoGenerationFundingOption = z.infer<typeof VideoGenerationFundingOption>;
|
|
212
|
+
|
|
213
|
+
export const WorkspaceVideoGenerationSettings = z
|
|
214
|
+
.object({
|
|
215
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
216
|
+
policy: VideoGenerationPolicy,
|
|
217
|
+
fundingOptions: z.array(VideoGenerationFundingOption).length(3),
|
|
218
|
+
availableModels: z.array(VideoGenerationModelCapability).max(16),
|
|
219
|
+
capabilities: VideoGenerationCapabilities.nullable(),
|
|
220
|
+
})
|
|
221
|
+
.strict()
|
|
222
|
+
.superRefine((value, ctx) => {
|
|
223
|
+
if (
|
|
224
|
+
new Set(value.fundingOptions.map((option) => option.source)).size !== 3 ||
|
|
225
|
+
!value.fundingOptions.some((option) => option.source === "opengeni_credits") ||
|
|
226
|
+
!value.fundingOptions.some((option) => option.source === "workspace_gateway") ||
|
|
227
|
+
!value.fundingOptions.some((option) => option.source === "supergrok_subscription")
|
|
228
|
+
) {
|
|
229
|
+
ctx.addIssue({
|
|
230
|
+
code: "custom",
|
|
231
|
+
path: ["fundingOptions"],
|
|
232
|
+
message: "all funding sources must be described exactly once",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const selected = value.fundingOptions.find(
|
|
236
|
+
(option) => option.source === value.policy.fundingSource,
|
|
237
|
+
);
|
|
238
|
+
if (!selected) {
|
|
239
|
+
ctx.addIssue({
|
|
240
|
+
code: "custom",
|
|
241
|
+
path: ["fundingOptions"],
|
|
242
|
+
message: "the selected funding source must be described",
|
|
243
|
+
});
|
|
244
|
+
} else if (!selected.available && value.capabilities !== null) {
|
|
245
|
+
ctx.addIssue({
|
|
246
|
+
code: "custom",
|
|
247
|
+
path: ["capabilities"],
|
|
248
|
+
message: "unavailable funding cannot expose executable capabilities",
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
export type WorkspaceVideoGenerationSettings = z.infer<typeof WorkspaceVideoGenerationSettings>;
|
|
253
|
+
|
|
254
|
+
export const VideoGenerationAcceptedReceipt = z
|
|
255
|
+
.object({
|
|
256
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
257
|
+
status: z.literal("accepted"),
|
|
258
|
+
operationId: z.string().uuid(),
|
|
259
|
+
})
|
|
260
|
+
.strict();
|
|
261
|
+
export type VideoGenerationAcceptedReceipt = z.infer<typeof VideoGenerationAcceptedReceipt>;
|
|
262
|
+
|
|
263
|
+
export const VideoGenerationRejectedCode = z.enum([
|
|
264
|
+
"invalid_reference_path",
|
|
265
|
+
"reference_not_stable",
|
|
266
|
+
"reference_too_large",
|
|
267
|
+
"reference_media_type_mismatch",
|
|
268
|
+
"unsupported_reference_media",
|
|
269
|
+
]);
|
|
270
|
+
export type VideoGenerationRejectedCode = z.infer<typeof VideoGenerationRejectedCode>;
|
|
271
|
+
|
|
272
|
+
/** Deterministic pre-admission rejection: no provider request or durable operation was created. */
|
|
273
|
+
export const VideoGenerationRejectedResult = z
|
|
274
|
+
.object({
|
|
275
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
276
|
+
status: z.literal("rejected"),
|
|
277
|
+
code: VideoGenerationRejectedCode,
|
|
278
|
+
message: z.string().min(1).max(512),
|
|
279
|
+
operationCreated: z.literal(false),
|
|
280
|
+
})
|
|
281
|
+
.strict();
|
|
282
|
+
export type VideoGenerationRejectedResult = z.infer<typeof VideoGenerationRejectedResult>;
|
|
283
|
+
|
|
284
|
+
export const VideoGenerationToolResult = z.discriminatedUnion("status", [
|
|
285
|
+
VideoGenerationAcceptedReceipt,
|
|
286
|
+
VideoGenerationRejectedResult,
|
|
287
|
+
]);
|
|
288
|
+
export type VideoGenerationToolResult = z.infer<typeof VideoGenerationToolResult>;
|
|
289
|
+
|
|
290
|
+
export const GeneratedVideoFacts = z
|
|
291
|
+
.object({
|
|
292
|
+
durationSeconds: z.number().positive().max(120),
|
|
293
|
+
width: z.number().int().positive().max(8_192),
|
|
294
|
+
height: z.number().int().positive().max(8_192),
|
|
295
|
+
fps: z.number().positive().max(120),
|
|
296
|
+
hasAudio: z.boolean(),
|
|
297
|
+
videoCodec: z.literal("h264"),
|
|
298
|
+
audioCodec: z.literal("aac").nullable(),
|
|
299
|
+
})
|
|
300
|
+
.strict();
|
|
301
|
+
export type GeneratedVideoFacts = z.infer<typeof GeneratedVideoFacts>;
|
|
302
|
+
|
|
303
|
+
export const GeneratedVideoReceipt = z
|
|
304
|
+
.object({
|
|
305
|
+
type: z.literal("generated_video"),
|
|
306
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
307
|
+
operationId: z.string().uuid(),
|
|
308
|
+
artifact: RetainedArtifactReferenceSchema,
|
|
309
|
+
video: GeneratedVideoFacts,
|
|
310
|
+
sandboxPath: z
|
|
311
|
+
.string()
|
|
312
|
+
.max(256)
|
|
313
|
+
.regex(
|
|
314
|
+
/^\/workspace\/generated-videos\/generated-video-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.mp4$/,
|
|
315
|
+
),
|
|
316
|
+
})
|
|
317
|
+
.strict()
|
|
318
|
+
.superRefine((value, ctx) => {
|
|
319
|
+
if (
|
|
320
|
+
value.artifact.kind !== "generated_video" ||
|
|
321
|
+
value.artifact.contentType !== "video/mp4" ||
|
|
322
|
+
value.artifact.originalBytes <= 0 ||
|
|
323
|
+
value.artifact.originalBytes > GENERATED_VIDEO_MAX_BYTES ||
|
|
324
|
+
value.artifact.retention.policy !== "workspace_file" ||
|
|
325
|
+
value.artifact.retrieval.maxRangeBytes !== RETAINED_OUTPUT_MAX_PAGE_BYTES
|
|
326
|
+
) {
|
|
327
|
+
ctx.addIssue({
|
|
328
|
+
code: "custom",
|
|
329
|
+
path: ["artifact"],
|
|
330
|
+
message: "generated-video artifact metadata is invalid",
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (
|
|
334
|
+
value.artifact.dimensions?.width !== value.video.width ||
|
|
335
|
+
value.artifact.dimensions?.height !== value.video.height
|
|
336
|
+
) {
|
|
337
|
+
ctx.addIssue({
|
|
338
|
+
code: "custom",
|
|
339
|
+
path: ["video"],
|
|
340
|
+
message: "video dimensions must match the retained artifact",
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (
|
|
344
|
+
value.sandboxPath !==
|
|
345
|
+
`/workspace/generated-videos/generated-video-${value.artifact.artifactId}.mp4`
|
|
346
|
+
) {
|
|
347
|
+
ctx.addIssue({
|
|
348
|
+
code: "custom",
|
|
349
|
+
path: ["sandboxPath"],
|
|
350
|
+
message: "generated-video sandbox path does not match its artifact",
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
export type GeneratedVideoReceipt = z.infer<typeof GeneratedVideoReceipt>;
|
|
355
|
+
|
|
356
|
+
export const VideoGenerationTerminalFailureStatus = z.enum([
|
|
357
|
+
"provider_failed",
|
|
358
|
+
"retention_failed",
|
|
359
|
+
"cancelled_before_submit",
|
|
360
|
+
"outcome_unknown",
|
|
361
|
+
]);
|
|
362
|
+
export type VideoGenerationTerminalFailureStatus = z.infer<
|
|
363
|
+
typeof VideoGenerationTerminalFailureStatus
|
|
364
|
+
>;
|
|
365
|
+
|
|
366
|
+
export const MediaGenerationResult = z.discriminatedUnion("status", [
|
|
367
|
+
z
|
|
368
|
+
.object({
|
|
369
|
+
type: z.literal("media_generation_result"),
|
|
370
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
371
|
+
status: z.literal("ready"),
|
|
372
|
+
operationId: z.string().uuid(),
|
|
373
|
+
receipt: GeneratedVideoReceipt,
|
|
374
|
+
})
|
|
375
|
+
.strict()
|
|
376
|
+
.refine((value) => value.receipt.operationId === value.operationId, {
|
|
377
|
+
path: ["receipt", "operationId"],
|
|
378
|
+
message: "terminal receipt must match its operation",
|
|
379
|
+
}),
|
|
380
|
+
z
|
|
381
|
+
.object({
|
|
382
|
+
type: z.literal("media_generation_result"),
|
|
383
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
384
|
+
status: VideoGenerationTerminalFailureStatus,
|
|
385
|
+
operationId: z.string().uuid(),
|
|
386
|
+
boundedPublicReason: z.string().min(1).max(1_000),
|
|
387
|
+
})
|
|
388
|
+
.strict(),
|
|
389
|
+
]);
|
|
390
|
+
export type MediaGenerationResult = z.infer<typeof MediaGenerationResult>;
|
|
391
|
+
|
|
392
|
+
export const VideoGenerationPublicStatus = z.enum([
|
|
393
|
+
"preparing",
|
|
394
|
+
"prepared",
|
|
395
|
+
"accepted",
|
|
396
|
+
"provider_started",
|
|
397
|
+
"retaining",
|
|
398
|
+
"completed",
|
|
399
|
+
"provider_failed",
|
|
400
|
+
"cancelled_before_submit",
|
|
401
|
+
"outcome_unknown",
|
|
402
|
+
"retention_failed",
|
|
403
|
+
]);
|
|
404
|
+
export type VideoGenerationPublicStatus = z.infer<typeof VideoGenerationPublicStatus>;
|
|
405
|
+
|
|
406
|
+
export const VideoGenerationOperationSummary = z
|
|
407
|
+
.object({
|
|
408
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
409
|
+
operationId: z.string().uuid(),
|
|
410
|
+
modelId: z.string().min(1).max(256),
|
|
411
|
+
status: VideoGenerationPublicStatus,
|
|
412
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
413
|
+
updatedAt: z.string().datetime({ offset: true }),
|
|
414
|
+
terminal: MediaGenerationResult.nullable(),
|
|
415
|
+
})
|
|
416
|
+
.strict();
|
|
417
|
+
export type VideoGenerationOperationSummary = z.infer<typeof VideoGenerationOperationSummary>;
|
|
418
|
+
|
|
419
|
+
export const VideoArtifactPlaybackSource = z
|
|
420
|
+
.object({
|
|
421
|
+
schemaVersion: z.literal(VIDEO_GENERATION_SCHEMA_VERSION),
|
|
422
|
+
artifactId: z.string().uuid(),
|
|
423
|
+
url: z.string().url().max(8_192),
|
|
424
|
+
expiresAt: z.string().datetime({ offset: true }),
|
|
425
|
+
contentType: z.literal("video/mp4"),
|
|
426
|
+
sizeBytes: z.number().int().positive().max(GENERATED_VIDEO_MAX_BYTES),
|
|
427
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
428
|
+
acceptRanges: z.literal("bytes"),
|
|
429
|
+
})
|
|
430
|
+
.strict();
|
|
431
|
+
export type VideoArtifactPlaybackSource = z.infer<typeof VideoArtifactPlaybackSource>;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const WORKSPACE_LEARNING_POLICY_MAX_SOURCE_OVERRIDES = 256;
|
|
4
|
+
export const WORKSPACE_LEARNING_POLICY_SOURCE_KIND_MAX_CHARS = 96;
|
|
5
|
+
export const WORKSPACE_LEARNING_POLICY_SOURCE_ID_MAX_CHARS = 1_024;
|
|
6
|
+
export const WORKSPACE_LEARNING_POLICY_REASON_MAX_CHARS = 4_096;
|
|
7
|
+
export const WORKSPACE_LEARNING_POLICY_DEFAULT_OFF_REVISION_ID =
|
|
8
|
+
"workspace-learning-policy:default-off:v1";
|
|
9
|
+
|
|
10
|
+
export const WorkspaceLearningMode = z.enum(["off", "suggest", "automatic"]);
|
|
11
|
+
export type WorkspaceLearningMode = z.infer<typeof WorkspaceLearningMode>;
|
|
12
|
+
|
|
13
|
+
export const WorkspaceLearningOverrideMode = z.enum(["inherit", "off", "suggest", "automatic"]);
|
|
14
|
+
export type WorkspaceLearningOverrideMode = z.infer<typeof WorkspaceLearningOverrideMode>;
|
|
15
|
+
|
|
16
|
+
export function normalizeWorkspaceLearningSourceKind(value: string): string {
|
|
17
|
+
return value.normalize("NFKC").trim().toLowerCase().replace(/\s+/gu, "-").replace(/-+/g, "-");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const WorkspaceLearningSourceKind = z
|
|
21
|
+
.string()
|
|
22
|
+
.transform(normalizeWorkspaceLearningSourceKind)
|
|
23
|
+
.pipe(
|
|
24
|
+
z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.max(WORKSPACE_LEARNING_POLICY_SOURCE_KIND_MAX_CHARS)
|
|
28
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
29
|
+
);
|
|
30
|
+
export type WorkspaceLearningSourceKind = z.infer<typeof WorkspaceLearningSourceKind>;
|
|
31
|
+
|
|
32
|
+
export const WorkspaceLearningSourceId = z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1)
|
|
35
|
+
.max(WORKSPACE_LEARNING_POLICY_SOURCE_ID_MAX_CHARS)
|
|
36
|
+
.refine(
|
|
37
|
+
(value) => value.trim() === value,
|
|
38
|
+
"learning source ids must not contain edge whitespace",
|
|
39
|
+
);
|
|
40
|
+
export type WorkspaceLearningSourceId = z.infer<typeof WorkspaceLearningSourceId>;
|
|
41
|
+
|
|
42
|
+
export const WorkspaceLearningSourceRef = z.object({
|
|
43
|
+
kind: WorkspaceLearningSourceKind,
|
|
44
|
+
id: WorkspaceLearningSourceId,
|
|
45
|
+
});
|
|
46
|
+
export type WorkspaceLearningSourceRef = z.infer<typeof WorkspaceLearningSourceRef>;
|
|
47
|
+
|
|
48
|
+
export const WorkspaceLearningSourceOverrideInput = WorkspaceLearningSourceRef.extend({
|
|
49
|
+
mode: WorkspaceLearningOverrideMode,
|
|
50
|
+
});
|
|
51
|
+
export type WorkspaceLearningSourceOverrideInput = z.infer<
|
|
52
|
+
typeof WorkspaceLearningSourceOverrideInput
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
export const WorkspaceLearningSourceOverride = WorkspaceLearningSourceRef.extend({
|
|
56
|
+
mode: WorkspaceLearningMode,
|
|
57
|
+
});
|
|
58
|
+
export type WorkspaceLearningSourceOverride = z.infer<typeof WorkspaceLearningSourceOverride>;
|
|
59
|
+
|
|
60
|
+
export const WorkspaceLearningSourceOverrides = z
|
|
61
|
+
.array(WorkspaceLearningSourceOverride)
|
|
62
|
+
.max(WORKSPACE_LEARNING_POLICY_MAX_SOURCE_OVERRIDES);
|
|
63
|
+
export type WorkspaceLearningSourceOverrides = z.infer<typeof WorkspaceLearningSourceOverrides>;
|
|
64
|
+
|
|
65
|
+
export function workspaceLearningSourceKey(source: WorkspaceLearningSourceRef): string {
|
|
66
|
+
return `${source.kind}\u0000${source.id}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function compareUtf8(left: string, right: string): number {
|
|
70
|
+
const encoder = new TextEncoder();
|
|
71
|
+
const leftBytes = encoder.encode(left);
|
|
72
|
+
const rightBytes = encoder.encode(right);
|
|
73
|
+
const length = Math.min(leftBytes.length, rightBytes.length);
|
|
74
|
+
for (let index = 0; index < length; index += 1) {
|
|
75
|
+
if (leftBytes[index] !== rightBytes[index]) return leftBytes[index]! - rightBytes[index]!;
|
|
76
|
+
}
|
|
77
|
+
return leftBytes.length - rightBytes.length;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Canonicalize caller input before hashing or persistence. `inherit` is a
|
|
82
|
+
* request-only reset operation: inherited entries are deliberately absent from
|
|
83
|
+
* immutable revisions so the persisted policy stays sparse and transparent.
|
|
84
|
+
*/
|
|
85
|
+
export function canonicalizeWorkspaceLearningSourceOverrides(
|
|
86
|
+
input: readonly WorkspaceLearningSourceOverrideInput[],
|
|
87
|
+
): WorkspaceLearningSourceOverride[] {
|
|
88
|
+
if (input.length > WORKSPACE_LEARNING_POLICY_MAX_SOURCE_OVERRIDES) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`workspace learning policy supports at most ${WORKSPACE_LEARNING_POLICY_MAX_SOURCE_OVERRIDES} source overrides`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const seen = new Set<string>();
|
|
94
|
+
const canonical: WorkspaceLearningSourceOverride[] = [];
|
|
95
|
+
for (const candidate of input) {
|
|
96
|
+
const parsed = WorkspaceLearningSourceOverrideInput.parse(candidate);
|
|
97
|
+
const key = workspaceLearningSourceKey(parsed);
|
|
98
|
+
if (seen.has(key)) {
|
|
99
|
+
throw new Error(`duplicate workspace learning source override: ${parsed.kind}/${parsed.id}`);
|
|
100
|
+
}
|
|
101
|
+
seen.add(key);
|
|
102
|
+
if (parsed.mode !== "inherit") canonical.push(parsed as WorkspaceLearningSourceOverride);
|
|
103
|
+
}
|
|
104
|
+
canonical.sort((left, right) => {
|
|
105
|
+
const kindOrder = compareUtf8(left.kind, right.kind);
|
|
106
|
+
return kindOrder === 0 ? compareUtf8(left.id, right.id) : kindOrder;
|
|
107
|
+
});
|
|
108
|
+
return WorkspaceLearningSourceOverrides.parse(canonical);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const revisionIdentityShape = {
|
|
112
|
+
id: z.string().uuid(),
|
|
113
|
+
revision: z.number().int().positive(),
|
|
114
|
+
policyHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const WorkspaceLearningPolicyRevisionIdentity = z.object(revisionIdentityShape);
|
|
118
|
+
export type WorkspaceLearningPolicyRevisionIdentity = z.infer<
|
|
119
|
+
typeof WorkspaceLearningPolicyRevisionIdentity
|
|
120
|
+
>;
|
|
121
|
+
|
|
122
|
+
export const WorkspaceLearningPolicyRevision = z.object({
|
|
123
|
+
...revisionIdentityShape,
|
|
124
|
+
operationId: z.string().uuid(),
|
|
125
|
+
accountId: z.string().uuid(),
|
|
126
|
+
workspaceId: z.string().uuid(),
|
|
127
|
+
workspaceMode: WorkspaceLearningMode,
|
|
128
|
+
sourceOverrides: WorkspaceLearningSourceOverrides,
|
|
129
|
+
supersedesRevisionId: z.string().uuid().nullable(),
|
|
130
|
+
createdBySubjectId: z.string().min(1),
|
|
131
|
+
createdAt: z.string().datetime(),
|
|
132
|
+
});
|
|
133
|
+
export type WorkspaceLearningPolicyRevision = z.infer<typeof WorkspaceLearningPolicyRevision>;
|
|
134
|
+
|
|
135
|
+
export const WorkspaceLearningPolicyHead = z.object({
|
|
136
|
+
accountId: z.string().uuid(),
|
|
137
|
+
workspaceId: z.string().uuid(),
|
|
138
|
+
revisionId: z.string().uuid(),
|
|
139
|
+
revision: z.number().int().positive(),
|
|
140
|
+
policyHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
141
|
+
activationVersion: z.number().int().positive(),
|
|
142
|
+
activatedAt: z.string().datetime(),
|
|
143
|
+
});
|
|
144
|
+
export type WorkspaceLearningPolicyHead = z.infer<typeof WorkspaceLearningPolicyHead>;
|
|
145
|
+
|
|
146
|
+
export const WorkspaceLearningPolicyActivationType = z.enum(["activate", "rollback"]);
|
|
147
|
+
export type WorkspaceLearningPolicyActivationType = z.infer<
|
|
148
|
+
typeof WorkspaceLearningPolicyActivationType
|
|
149
|
+
>;
|
|
150
|
+
|
|
151
|
+
export const WorkspaceLearningPolicyActivationEvent = z.object({
|
|
152
|
+
id: z.string().uuid(),
|
|
153
|
+
operationId: z.string().uuid(),
|
|
154
|
+
accountId: z.string().uuid(),
|
|
155
|
+
workspaceId: z.string().uuid(),
|
|
156
|
+
type: WorkspaceLearningPolicyActivationType,
|
|
157
|
+
activationVersion: z.number().int().positive(),
|
|
158
|
+
oldRevision: WorkspaceLearningPolicyRevisionIdentity.nullable(),
|
|
159
|
+
newRevision: WorkspaceLearningPolicyRevisionIdentity,
|
|
160
|
+
actorSubjectId: z.string().min(1),
|
|
161
|
+
reason: z.string().min(1).max(WORKSPACE_LEARNING_POLICY_REASON_MAX_CHARS),
|
|
162
|
+
createdAt: z.string().datetime(),
|
|
163
|
+
});
|
|
164
|
+
export type WorkspaceLearningPolicyActivationEvent = z.infer<
|
|
165
|
+
typeof WorkspaceLearningPolicyActivationEvent
|
|
166
|
+
>;
|
|
167
|
+
|
|
168
|
+
export const WorkspaceLearningPolicySnapshot = z.object({
|
|
169
|
+
id: z.string().uuid(),
|
|
170
|
+
accountId: z.string().uuid(),
|
|
171
|
+
workspaceId: z.string().uuid(),
|
|
172
|
+
sessionId: z.string().uuid(),
|
|
173
|
+
turnId: z.string().uuid(),
|
|
174
|
+
attemptId: z.string().uuid(),
|
|
175
|
+
executionGeneration: z.number().int().positive(),
|
|
176
|
+
revision: WorkspaceLearningPolicyRevisionIdentity.nullable(),
|
|
177
|
+
activationVersion: z.number().int().nonnegative(),
|
|
178
|
+
activatedAt: z.string().datetime().nullable(),
|
|
179
|
+
workspaceMode: WorkspaceLearningMode,
|
|
180
|
+
sourceOverrides: WorkspaceLearningSourceOverrides,
|
|
181
|
+
snapshotHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
182
|
+
createdAt: z.string().datetime(),
|
|
183
|
+
});
|
|
184
|
+
export type WorkspaceLearningPolicySnapshot = z.infer<typeof WorkspaceLearningPolicySnapshot>;
|
|
185
|
+
|
|
186
|
+
export const WorkspaceLearningPolicyRouterContext = z.object({
|
|
187
|
+
mode: WorkspaceLearningMode,
|
|
188
|
+
snapshotId: z.string().uuid(),
|
|
189
|
+
revisionId: z.string().min(1).max(512),
|
|
190
|
+
});
|
|
191
|
+
export type WorkspaceLearningPolicyRouterContext = z.infer<
|
|
192
|
+
typeof WorkspaceLearningPolicyRouterContext
|
|
193
|
+
>;
|
|
194
|
+
|
|
195
|
+
export const WorkspaceLearningPolicyEffectiveMode = WorkspaceLearningPolicyRouterContext.extend({
|
|
196
|
+
inherited: z.boolean(),
|
|
197
|
+
source: WorkspaceLearningSourceRef,
|
|
198
|
+
policyRevision: WorkspaceLearningPolicyRevisionIdentity.nullable(),
|
|
199
|
+
activationVersion: z.number().int().nonnegative(),
|
|
200
|
+
snapshotHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
201
|
+
});
|
|
202
|
+
export type WorkspaceLearningPolicyEffectiveMode = z.infer<
|
|
203
|
+
typeof WorkspaceLearningPolicyEffectiveMode
|
|
204
|
+
>;
|
|
205
|
+
|
|
206
|
+
/** Stable router seam: resolve only from an immutable accepted-attempt snapshot. */
|
|
207
|
+
export function resolveWorkspaceLearningPolicyEffectiveMode(
|
|
208
|
+
snapshot: WorkspaceLearningPolicySnapshot,
|
|
209
|
+
source: WorkspaceLearningSourceRef,
|
|
210
|
+
): WorkspaceLearningPolicyEffectiveMode {
|
|
211
|
+
const parsedSnapshot = WorkspaceLearningPolicySnapshot.parse(snapshot);
|
|
212
|
+
const parsedSource = WorkspaceLearningSourceRef.parse(source);
|
|
213
|
+
const override = parsedSnapshot.sourceOverrides.find(
|
|
214
|
+
(candidate) => candidate.kind === parsedSource.kind && candidate.id === parsedSource.id,
|
|
215
|
+
);
|
|
216
|
+
return WorkspaceLearningPolicyEffectiveMode.parse({
|
|
217
|
+
mode: override?.mode ?? parsedSnapshot.workspaceMode,
|
|
218
|
+
inherited: override === undefined,
|
|
219
|
+
source: parsedSource,
|
|
220
|
+
policyRevision: parsedSnapshot.revision,
|
|
221
|
+
activationVersion: parsedSnapshot.activationVersion,
|
|
222
|
+
snapshotId: parsedSnapshot.id,
|
|
223
|
+
revisionId: parsedSnapshot.revision?.id ?? WORKSPACE_LEARNING_POLICY_DEFAULT_OFF_REVISION_ID,
|
|
224
|
+
snapshotHash: parsedSnapshot.snapshotHash,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Exact provider-neutral context consumed by the canonical durable-learning router. */
|
|
229
|
+
export function workspaceLearningPolicyRouterContext(
|
|
230
|
+
effectiveMode: WorkspaceLearningPolicyEffectiveMode,
|
|
231
|
+
): WorkspaceLearningPolicyRouterContext {
|
|
232
|
+
return WorkspaceLearningPolicyRouterContext.parse(effectiveMode);
|
|
233
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const PositiveSafeInteger = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Opaque authority frozen at an xAI provider-account acceptance boundary.
|
|
7
|
+
*
|
|
8
|
+
* This snapshot deliberately carries no organization, membership, credential,
|
|
9
|
+
* provider-account, subject, label, quota, token, or plan identity. User scope
|
|
10
|
+
* becomes executable only after exact live database revalidation against the
|
|
11
|
+
* separately stored causal subject and xAI subscription authority row.
|
|
12
|
+
*/
|
|
13
|
+
export const XaiProviderAccountAuthoritySnapshotV1 = z.discriminatedUnion("scope", [
|
|
14
|
+
z
|
|
15
|
+
.object({
|
|
16
|
+
version: z.literal(1),
|
|
17
|
+
scope: z.literal("workspace"),
|
|
18
|
+
})
|
|
19
|
+
.strict(),
|
|
20
|
+
z
|
|
21
|
+
.object({
|
|
22
|
+
version: z.literal(1),
|
|
23
|
+
scope: z.literal("user"),
|
|
24
|
+
authorityGeneration: PositiveSafeInteger,
|
|
25
|
+
})
|
|
26
|
+
.strict(),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
export type XaiProviderAccountAuthoritySnapshotV1 = z.infer<
|
|
30
|
+
typeof XaiProviderAccountAuthoritySnapshotV1
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
/** Explicit compatibility value for workspace-default accepted work. */
|
|
34
|
+
export const WORKSPACE_XAI_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1 = {
|
|
35
|
+
version: 1,
|
|
36
|
+
scope: "workspace",
|
|
37
|
+
} as const satisfies XaiProviderAccountAuthoritySnapshotV1;
|