@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.
Files changed (148) hide show
  1. package/dist/atlassian.d.ts +278 -0
  2. package/dist/atlassian.js +57 -0
  3. package/dist/atlassian.js.map +1 -0
  4. package/dist/canonical-human-identities.d.ts +157 -0
  5. package/dist/canonical-human-identities.js +23 -0
  6. package/dist/canonical-human-identities.js.map +1 -0
  7. package/dist/{chunk-7JZMI22I.js → chunk-5UDNP7AO.js} +34 -2
  8. package/dist/chunk-5UDNP7AO.js.map +1 -0
  9. package/dist/chunk-BVGIYW7D.js +11 -0
  10. package/dist/chunk-BVGIYW7D.js.map +1 -0
  11. package/dist/chunk-CADSX6UN.js +1145 -0
  12. package/dist/chunk-CADSX6UN.js.map +1 -0
  13. package/dist/chunk-CM6BMECR.js +24 -0
  14. package/dist/chunk-CM6BMECR.js.map +1 -0
  15. package/dist/chunk-D2HKF2EF.js +1460 -0
  16. package/dist/chunk-D2HKF2EF.js.map +1 -0
  17. package/dist/chunk-JBCIY7QD.js +194 -0
  18. package/dist/chunk-JBCIY7QD.js.map +1 -0
  19. package/dist/chunk-JUFK3T4Q.js +80 -0
  20. package/dist/chunk-JUFK3T4Q.js.map +1 -0
  21. package/dist/chunk-LSB7GRLG.js +779 -0
  22. package/dist/chunk-LSB7GRLG.js.map +1 -0
  23. package/dist/chunk-LW7OH6CS.js +382 -0
  24. package/dist/chunk-LW7OH6CS.js.map +1 -0
  25. package/dist/chunk-M5ZGRVIQ.js +719 -0
  26. package/dist/chunk-M5ZGRVIQ.js.map +1 -0
  27. package/dist/chunk-MYBZRDTY.js +340 -0
  28. package/dist/chunk-MYBZRDTY.js.map +1 -0
  29. package/dist/chunk-Q6A7XT2N.js +16734 -0
  30. package/dist/chunk-Q6A7XT2N.js.map +1 -0
  31. package/dist/chunk-RIY7GYQS.js +1204 -0
  32. package/dist/chunk-RIY7GYQS.js.map +1 -0
  33. package/dist/chunk-TZ6YEYN4.js +386 -0
  34. package/dist/chunk-TZ6YEYN4.js.map +1 -0
  35. package/dist/chunk-Y3MLSLB4.js +392 -0
  36. package/dist/chunk-Y3MLSLB4.js.map +1 -0
  37. package/dist/chunk-YRKRZ6OF.js +134 -0
  38. package/dist/chunk-YRKRZ6OF.js.map +1 -0
  39. package/dist/codex-provider-account-authority.d.ts +23 -0
  40. package/dist/codex-provider-account-authority.js +23 -0
  41. package/dist/codex-provider-account-authority.js.map +1 -0
  42. package/dist/company-profile.d.ts +629 -0
  43. package/dist/document-artifact-commands.d.ts +282 -0
  44. package/dist/document-artifact-commands.js +54 -0
  45. package/dist/document-artifact-commands.js.map +1 -0
  46. package/dist/document-artifact-query.d.ts +2 -0
  47. package/dist/document-artifact-query.js +54 -0
  48. package/dist/document-artifact-query.js.map +1 -0
  49. package/dist/editable-artifact-binary.d.ts +56 -0
  50. package/dist/editable-artifact-causal-frontier.d.ts +12 -0
  51. package/dist/editable-artifact-causal-frontier.js +18 -0
  52. package/dist/editable-artifact-causal-frontier.js.map +1 -0
  53. package/dist/editable-artifact-codec-registry.d.ts +48 -0
  54. package/dist/editable-artifact-codec-registry.js +20 -0
  55. package/dist/editable-artifact-codec-registry.js.map +1 -0
  56. package/dist/editable-artifact-committed-transaction.d.ts +35 -0
  57. package/dist/editable-artifact-committed-transaction.js +19 -0
  58. package/dist/editable-artifact-committed-transaction.js.map +1 -0
  59. package/dist/editable-artifact-live.d.ts +276 -0
  60. package/dist/editable-artifact-live.js +907 -0
  61. package/dist/editable-artifact-live.js.map +1 -0
  62. package/dist/editable-artifact-serialized-commit.d.ts +53 -0
  63. package/dist/editable-artifact-serialized-commit.js +26 -0
  64. package/dist/editable-artifact-serialized-commit.js.map +1 -0
  65. package/dist/editable-artifact-versions.d.ts +6 -0
  66. package/dist/editable-artifact-versions.js +11 -0
  67. package/dist/editable-artifact-versions.js.map +1 -0
  68. package/dist/editable-artifacts.d.ts +46 -0
  69. package/dist/editable-artifacts.js +236 -0
  70. package/dist/editable-artifacts.js.map +1 -0
  71. package/dist/event-preview.d.ts +1 -1
  72. package/dist/google-drive.d.ts +114 -2
  73. package/dist/google-drive.js +72 -14
  74. package/dist/google-drive.js.map +1 -1
  75. package/dist/image-generation.d.ts +70 -0
  76. package/dist/index.d.ts +5661 -166
  77. package/dist/index.js +1438 -21
  78. package/dist/interaction.d.ts +8290 -0
  79. package/dist/knowledge.d.ts +543 -0
  80. package/dist/memory-slack-delivery.d.ts +397 -0
  81. package/dist/presentation-artifact-commands.d.ts +349 -0
  82. package/dist/presentation-artifact-commands.js +66 -0
  83. package/dist/presentation-artifact-commands.js.map +1 -0
  84. package/dist/presentation-artifact-query.d.ts +2 -0
  85. package/dist/presentation-artifact-query.js +66 -0
  86. package/dist/presentation-artifact-query.js.map +1 -0
  87. package/dist/retained-output.d.ts +24 -0
  88. package/dist/sandbox-snapshots.d.ts +9 -0
  89. package/dist/scoped-knowledge.d.ts +14 -13
  90. package/dist/slack-bot-scopes.d.ts +4 -0
  91. package/dist/slack-bot-scopes.js +3 -1
  92. package/dist/slack-task-policy.d.ts +294 -0
  93. package/dist/spreadsheet-artifact-commands.d.ts +101 -0
  94. package/dist/spreadsheet-artifact-commands.js +27 -0
  95. package/dist/spreadsheet-artifact-commands.js.map +1 -0
  96. package/dist/spreadsheet-artifact-date.d.ts +4 -0
  97. package/dist/spreadsheet-artifact-query.d.ts +120 -0
  98. package/dist/spreadsheet-artifact-query.js +48 -0
  99. package/dist/spreadsheet-artifact-query.js.map +1 -0
  100. package/dist/task-notes.d.ts +128 -0
  101. package/dist/tool-catalog.d.ts +576 -0
  102. package/dist/video-generation.d.ts +580 -0
  103. package/dist/video-generation.js +59 -0
  104. package/dist/video-generation.js.map +1 -0
  105. package/dist/workspace-learning-policy.d.ts +208 -0
  106. package/dist/xai-provider-account-authority.d.ts +23 -0
  107. package/dist/xai-provider-account-authority.js +9 -0
  108. package/dist/xai-provider-account-authority.js.map +1 -0
  109. package/package.json +73 -1
  110. package/src/artifacts.ts +1 -1
  111. package/src/atlassian.ts +160 -0
  112. package/src/canonical-human-identities.ts +93 -0
  113. package/src/codex-provider-account-authority.ts +37 -0
  114. package/src/company-profile.ts +306 -0
  115. package/src/document-artifact-commands.ts +1709 -0
  116. package/src/document-artifact-query.ts +2 -0
  117. package/src/editable-artifact-binary.ts +396 -0
  118. package/src/editable-artifact-causal-frontier.ts +154 -0
  119. package/src/editable-artifact-codec-registry.ts +261 -0
  120. package/src/editable-artifact-committed-transaction.ts +478 -0
  121. package/src/editable-artifact-live.ts +1379 -0
  122. package/src/editable-artifact-serialized-commit.ts +494 -0
  123. package/src/editable-artifact-versions.ts +8 -0
  124. package/src/editable-artifacts.ts +473 -0
  125. package/src/google-drive.ts +68 -15
  126. package/src/image-generation.ts +106 -0
  127. package/src/index.ts +2920 -326
  128. package/src/interaction.ts +3173 -0
  129. package/src/knowledge.ts +207 -0
  130. package/src/memory-slack-delivery.ts +183 -0
  131. package/src/presentation-artifact-commands.ts +2035 -0
  132. package/src/presentation-artifact-query.ts +2 -0
  133. package/src/retained-output.ts +149 -2
  134. package/src/sandbox-snapshots.ts +28 -1
  135. package/src/scoped-knowledge.ts +18 -4
  136. package/src/slack-bot-scopes.ts +34 -1
  137. package/src/slack-task-policy.ts +215 -0
  138. package/src/spreadsheet-artifact-commands.ts +999 -0
  139. package/src/spreadsheet-artifact-date.ts +21 -0
  140. package/src/spreadsheet-artifact-query.ts +1411 -0
  141. package/src/task-notes.ts +92 -0
  142. package/src/tool-catalog.ts +334 -0
  143. package/src/video-generation.ts +431 -0
  144. package/src/workspace-learning-policy.ts +233 -0
  145. package/src/xai-provider-account-authority.ts +37 -0
  146. package/dist/chunk-5HR2GPSC.js +0 -11031
  147. package/dist/chunk-5HR2GPSC.js.map +0 -1
  148. package/dist/chunk-7JZMI22I.js.map +0 -1
@@ -0,0 +1,719 @@
1
+ // src/video-generation.ts
2
+ import { z as z2 } from "zod";
3
+
4
+ // src/retained-output.ts
5
+ import { z } from "zod";
6
+ var RETAINED_OUTPUT_MAX_PAGE_BYTES = 1024 * 1024;
7
+ var RETAINED_OUTPUT_DEFAULT_PAGE_BYTES = 256 * 1024;
8
+ var RETAINED_OUTPUT_RECEIPT_MAX_BYTES = 2 * 1024;
9
+ var COMPUTER_SCREENSHOT_MAX_BYTES = 32 * 1024 * 1024;
10
+ var COMPUTER_SCREENSHOT_MAX_DIMENSION = 16384;
11
+ var COMPUTER_SCREENSHOT_MAX_PIXELS = 67108864;
12
+ var COMPUTER_SCREENSHOT_RETENTION_MS = 30 * 24 * 60 * 60 * 1e3;
13
+ var COMPUTER_SCREENSHOT_WORKSPACE_QUOTA_BYTES = 5 * 1024 * 1024 * 1024;
14
+ var GENERATED_IMAGE_MAX_BYTES = 64 * 1024 * 1024;
15
+ var GENERATED_VIDEO_MAX_BYTES = 512 * 1024 * 1024;
16
+ var encoder = new TextEncoder();
17
+ var LOWERCASE_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
18
+ var LOWERCASE_SHA256 = /^[0-9a-f]{64}$/;
19
+ var CANONICAL_MEDIA_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,62}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,62}$/;
20
+ var WORKSPACE_RETRIEVAL_PATH = /^\/v1\/workspaces\/([0-9a-f-]+)\/artifacts\/([0-9a-f-]+)\/content$/;
21
+ var SESSION_RETRIEVAL_PATH = /^\/v1\/workspaces\/([0-9a-f-]+)\/sessions\/([0-9a-f-]+)\/artifacts\/([0-9a-f-]+)\/content$/;
22
+ var RetainedOutputKind = z.enum([
23
+ "tool_result",
24
+ "assistant_completion",
25
+ "internal_update",
26
+ "event_media",
27
+ "computer_screenshot",
28
+ "generated_image",
29
+ "generated_video",
30
+ "file"
31
+ ]);
32
+ var RetainedOutputUnavailableReason = z.enum([
33
+ "not_retained",
34
+ "pending",
35
+ "failed",
36
+ "expired",
37
+ "deleted",
38
+ "missing_storage",
39
+ "storage_write_failed",
40
+ "quota_exceeded",
41
+ "invalid_content",
42
+ "oversized",
43
+ "unsupported"
44
+ ]);
45
+ var RetainedOutputUnavailableEvidenceSchema = z.object({
46
+ available: z.literal(false),
47
+ reason: RetainedOutputUnavailableReason
48
+ }).strict();
49
+ var RetainedArtifactReferenceSchema = z.object({
50
+ available: z.literal(true),
51
+ artifactId: z.string().regex(LOWERCASE_UUID),
52
+ kind: RetainedOutputKind,
53
+ contentType: z.string().max(127).regex(CANONICAL_MEDIA_TYPE),
54
+ originalBytes: z.number().int().nonnegative().safe(),
55
+ sha256: z.string().regex(LOWERCASE_SHA256),
56
+ retainedAt: z.string().datetime({ offset: true }),
57
+ dimensions: z.object({
58
+ width: z.number().int().positive().max(COMPUTER_SCREENSHOT_MAX_DIMENSION),
59
+ height: z.number().int().positive().max(COMPUTER_SCREENSHOT_MAX_DIMENSION)
60
+ }).strict().optional(),
61
+ retention: z.union([
62
+ z.object({
63
+ policy: z.literal("workspace_file"),
64
+ expiresAt: z.null()
65
+ }).strict(),
66
+ z.object({
67
+ policy: z.literal("session_screenshot"),
68
+ expiresAt: z.string().datetime({ offset: true })
69
+ }).strict()
70
+ ]),
71
+ retrieval: z.object({
72
+ method: z.literal("GET"),
73
+ path: z.string().max(256),
74
+ acceptRanges: z.literal("bytes"),
75
+ maxRangeBytes: z.number().int().positive().max(RETAINED_OUTPUT_MAX_PAGE_BYTES)
76
+ }).strict()
77
+ }).strict().superRefine((value, ctx) => {
78
+ const workspaceMatch = WORKSPACE_RETRIEVAL_PATH.exec(value.retrieval.path);
79
+ const sessionMatch = SESSION_RETRIEVAL_PATH.exec(value.retrieval.path);
80
+ const workspaceId = workspaceMatch?.[1] ?? sessionMatch?.[1];
81
+ const sessionId = sessionMatch?.[2];
82
+ const artifactId = workspaceMatch?.[2] ?? sessionMatch?.[3];
83
+ if (!workspaceId || !LOWERCASE_UUID.test(workspaceId) || sessionId !== void 0 && !LOWERCASE_UUID.test(sessionId) || artifactId !== value.artifactId) {
84
+ ctx.addIssue({
85
+ code: "custom",
86
+ path: ["retrieval", "path"],
87
+ message: "retrieval path must be a workspace/session API content path for this artifact"
88
+ });
89
+ }
90
+ if (value.kind === "computer_screenshot" || value.kind === "generated_image" || value.kind === "generated_video") {
91
+ if (!value.dimensions) {
92
+ ctx.addIssue({
93
+ code: "custom",
94
+ path: ["dimensions"],
95
+ message: `${value.kind} receipts require exact dimensions`
96
+ });
97
+ } else if (value.dimensions.width * value.dimensions.height > COMPUTER_SCREENSHOT_MAX_PIXELS) {
98
+ ctx.addIssue({
99
+ code: "custom",
100
+ path: ["dimensions"],
101
+ message: `${value.kind} dimensions exceed the pixel limit`
102
+ });
103
+ }
104
+ }
105
+ if (value.kind === "generated_image") {
106
+ if (value.retention.policy !== "workspace_file" || !workspaceMatch || sessionMatch) {
107
+ ctx.addIssue({
108
+ code: "custom",
109
+ path: ["retention"],
110
+ message: "generated images require permanent workspace-file retrieval"
111
+ });
112
+ }
113
+ if (!["image/png", "image/jpeg", "image/webp"].includes(value.contentType) || value.originalBytes <= 0 || value.originalBytes > GENERATED_IMAGE_MAX_BYTES) {
114
+ ctx.addIssue({
115
+ code: "custom",
116
+ path: ["contentType"],
117
+ message: "generated image media metadata is invalid"
118
+ });
119
+ }
120
+ }
121
+ if (value.kind === "generated_video") {
122
+ if (value.retention.policy !== "workspace_file" || !workspaceMatch || sessionMatch) {
123
+ ctx.addIssue({
124
+ code: "custom",
125
+ path: ["retention"],
126
+ message: "generated videos require permanent workspace-file retrieval"
127
+ });
128
+ }
129
+ if (value.contentType !== "video/mp4" || value.originalBytes <= 0 || value.originalBytes > GENERATED_VIDEO_MAX_BYTES) {
130
+ ctx.addIssue({
131
+ code: "custom",
132
+ path: ["contentType"],
133
+ message: "generated video media metadata is invalid"
134
+ });
135
+ }
136
+ }
137
+ if (value.kind === "computer_screenshot") {
138
+ if (value.retention.policy !== "session_screenshot" || !sessionMatch) {
139
+ ctx.addIssue({
140
+ code: "custom",
141
+ path: ["retention"],
142
+ message: "computer screenshots require session-scoped expiring retrieval"
143
+ });
144
+ }
145
+ }
146
+ if (encoder.encode(JSON.stringify(value)).byteLength > RETAINED_OUTPUT_RECEIPT_MAX_BYTES) {
147
+ ctx.addIssue({
148
+ code: "custom",
149
+ message: "retained-output receipt exceeds its byte envelope"
150
+ });
151
+ }
152
+ });
153
+ var RetainedOutputEvidenceSchema = z.discriminatedUnion("available", [
154
+ RetainedOutputUnavailableEvidenceSchema,
155
+ RetainedArtifactReferenceSchema
156
+ ]);
157
+ var RetainedArtifactUnavailableSchema = z.object({
158
+ available: z.literal(false),
159
+ artifactId: z.string().regex(LOWERCASE_UUID),
160
+ reason: RetainedOutputUnavailableReason
161
+ }).strict();
162
+ var RetainedArtifactMetadataSchema = z.union([
163
+ RetainedArtifactReferenceSchema,
164
+ RetainedArtifactUnavailableSchema
165
+ ]);
166
+ function retainedArtifactReferenceFromFile(file, kind = "file") {
167
+ if (file.status !== "ready" || !file.sha256) return null;
168
+ const value = {
169
+ available: true,
170
+ artifactId: file.id,
171
+ kind,
172
+ contentType: canonicalRetainedContentType(file.contentType),
173
+ originalBytes: file.sizeBytes,
174
+ sha256: file.sha256,
175
+ retainedAt: file.updatedAt,
176
+ retention: {
177
+ policy: "workspace_file",
178
+ expiresAt: null
179
+ },
180
+ retrieval: {
181
+ method: "GET",
182
+ path: `/v1/workspaces/${file.workspaceId}/artifacts/${file.id}/content`,
183
+ acceptRanges: "bytes",
184
+ maxRangeBytes: RETAINED_OUTPUT_MAX_PAGE_BYTES
185
+ }
186
+ };
187
+ const parsed = RetainedArtifactReferenceSchema.safeParse(value);
188
+ return parsed.success ? parsed.data : null;
189
+ }
190
+ function retainedScreenshotReferenceFromFile(file) {
191
+ if (file.status !== "ready" || !file.sha256 || file.sizeBytes <= 0) return null;
192
+ const value = {
193
+ available: true,
194
+ artifactId: file.id,
195
+ kind: "computer_screenshot",
196
+ contentType: canonicalRetainedContentType(file.contentType),
197
+ originalBytes: file.sizeBytes,
198
+ sha256: file.sha256,
199
+ retainedAt: file.updatedAt,
200
+ dimensions: { width: file.width, height: file.height },
201
+ retention: {
202
+ policy: "session_screenshot",
203
+ expiresAt: file.expiresAt
204
+ },
205
+ retrieval: {
206
+ method: "GET",
207
+ path: `/v1/workspaces/${file.workspaceId}/sessions/${file.sessionId}/artifacts/${file.id}/content`,
208
+ acceptRanges: "bytes",
209
+ maxRangeBytes: RETAINED_OUTPUT_MAX_PAGE_BYTES
210
+ }
211
+ };
212
+ const parsed = RetainedArtifactReferenceSchema.safeParse(value);
213
+ return parsed.success ? parsed.data : null;
214
+ }
215
+ function retainedGeneratedImageReferenceFromFile(file) {
216
+ if (file.status !== "ready" || !file.sha256 || file.sizeBytes <= 0 || file.sizeBytes > GENERATED_IMAGE_MAX_BYTES) {
217
+ return null;
218
+ }
219
+ const value = {
220
+ available: true,
221
+ artifactId: file.id,
222
+ kind: "generated_image",
223
+ contentType: canonicalRetainedContentType(file.contentType),
224
+ originalBytes: file.sizeBytes,
225
+ sha256: file.sha256,
226
+ retainedAt: file.updatedAt,
227
+ dimensions: { width: file.width, height: file.height },
228
+ retention: {
229
+ policy: "workspace_file",
230
+ expiresAt: null
231
+ },
232
+ retrieval: {
233
+ method: "GET",
234
+ path: `/v1/workspaces/${file.workspaceId}/artifacts/${file.id}/content`,
235
+ acceptRanges: "bytes",
236
+ maxRangeBytes: RETAINED_OUTPUT_MAX_PAGE_BYTES
237
+ }
238
+ };
239
+ const parsed = RetainedArtifactReferenceSchema.safeParse(value);
240
+ return parsed.success ? parsed.data : null;
241
+ }
242
+ function retainedGeneratedVideoReferenceFromFile(file) {
243
+ if (file.status !== "ready" || file.contentType !== "video/mp4" || !file.sha256 || file.sizeBytes <= 0 || file.sizeBytes > GENERATED_VIDEO_MAX_BYTES) {
244
+ return null;
245
+ }
246
+ const value = {
247
+ available: true,
248
+ artifactId: file.id,
249
+ kind: "generated_video",
250
+ contentType: "video/mp4",
251
+ originalBytes: file.sizeBytes,
252
+ sha256: file.sha256,
253
+ retainedAt: file.updatedAt,
254
+ dimensions: { width: file.width, height: file.height },
255
+ retention: {
256
+ policy: "workspace_file",
257
+ expiresAt: null
258
+ },
259
+ retrieval: {
260
+ method: "GET",
261
+ path: `/v1/workspaces/${file.workspaceId}/artifacts/${file.id}/content`,
262
+ acceptRanges: "bytes",
263
+ maxRangeBytes: RETAINED_OUTPUT_MAX_PAGE_BYTES
264
+ }
265
+ };
266
+ const parsed = RetainedArtifactReferenceSchema.safeParse(value);
267
+ return parsed.success ? parsed.data : null;
268
+ }
269
+ function canonicalRetainedContentType(value) {
270
+ const mediaType = value.split(";", 1)[0]?.trim().toLowerCase() ?? "";
271
+ return CANONICAL_MEDIA_TYPE.test(mediaType) ? mediaType : "application/octet-stream";
272
+ }
273
+ function validateRetainedOutputEvidence(value) {
274
+ const parsed = RetainedOutputEvidenceSchema.safeParse(value);
275
+ return parsed.success ? parsed.data : null;
276
+ }
277
+ function retainedOutputUnavailable(reason = "not_retained") {
278
+ return { available: false, reason };
279
+ }
280
+ function resolveRetainedOutputRange(rangeHeader, totalBytes, maxPageBytes = RETAINED_OUTPUT_DEFAULT_PAGE_BYTES) {
281
+ assertRangeInputs(totalBytes, maxPageBytes);
282
+ if (rangeHeader === null || rangeHeader === void 0 || rangeHeader === "") {
283
+ if (totalBytes === 0) {
284
+ return {
285
+ kind: "empty",
286
+ length: 0,
287
+ totalBytes: 0,
288
+ status: 200,
289
+ contentRange: null,
290
+ acceptRanges: "bytes"
291
+ };
292
+ }
293
+ const end = Math.min(totalBytes - 1, maxPageBytes - 1);
294
+ const partial = end + 1 < totalBytes;
295
+ return resolvedRange(0, end, totalBytes, partial ? 206 : 200);
296
+ }
297
+ if (rangeHeader.length > 128 || /[^\x20-\x7e]/.test(rangeHeader)) {
298
+ return invalidRange("malformed", maxPageBytes);
299
+ }
300
+ if (rangeHeader.includes(",")) {
301
+ return invalidRange("multipart_not_supported", maxPageBytes);
302
+ }
303
+ const match = /^bytes=(\d*)-(\d*)$/.exec(rangeHeader);
304
+ if (!match || !match[1] && !match[2]) {
305
+ return invalidRange("malformed", maxPageBytes);
306
+ }
307
+ const first = parseRangeInteger(match[1]);
308
+ const second = parseRangeInteger(match[2]);
309
+ if (first === "overflow" || second === "overflow") {
310
+ return invalidRange("numeric_overflow", maxPageBytes);
311
+ }
312
+ if (first === null) {
313
+ const suffixLength = second;
314
+ if (suffixLength === null) return invalidRange("malformed", maxPageBytes);
315
+ if (suffixLength === 0) return unsatisfiableRange("zero_suffix", totalBytes);
316
+ if (suffixLength > maxPageBytes) return invalidRange("range_too_large", maxPageBytes);
317
+ if (totalBytes === 0) return unsatisfiableRange("empty_artifact", totalBytes);
318
+ const length = Math.min(suffixLength, totalBytes);
319
+ return resolvedRange(totalBytes - length, totalBytes - 1, totalBytes, 206);
320
+ }
321
+ if (totalBytes === 0) return unsatisfiableRange("empty_artifact", totalBytes);
322
+ if (first >= totalBytes) return unsatisfiableRange("start_out_of_bounds", totalBytes);
323
+ if (second === null) {
324
+ const end = Math.min(totalBytes - 1, first + maxPageBytes - 1);
325
+ return resolvedRange(first, end, totalBytes, 206);
326
+ }
327
+ if (second < first) return unsatisfiableRange("end_before_start", totalBytes);
328
+ if (second - first >= maxPageBytes) {
329
+ return invalidRange("range_too_large", maxPageBytes);
330
+ }
331
+ return resolvedRange(first, Math.min(second, totalBytes - 1), totalBytes, 206);
332
+ }
333
+ function assertRangeInputs(totalBytes, maxPageBytes) {
334
+ if (!Number.isSafeInteger(totalBytes) || totalBytes < 0) {
335
+ throw new RangeError("totalBytes must be a nonnegative safe integer");
336
+ }
337
+ if (!Number.isSafeInteger(maxPageBytes) || maxPageBytes <= 0 || maxPageBytes > RETAINED_OUTPUT_MAX_PAGE_BYTES) {
338
+ throw new RangeError(
339
+ `maxPageBytes must be an integer between 1 and ${RETAINED_OUTPUT_MAX_PAGE_BYTES}`
340
+ );
341
+ }
342
+ }
343
+ function parseRangeInteger(value) {
344
+ if (!value) return null;
345
+ if (value.length > 16) return "overflow";
346
+ const parsed = Number(value);
347
+ return Number.isSafeInteger(parsed) ? parsed : "overflow";
348
+ }
349
+ function resolvedRange(start, end, totalBytes, status) {
350
+ return {
351
+ kind: "range",
352
+ start,
353
+ end,
354
+ length: end - start + 1,
355
+ totalBytes,
356
+ status,
357
+ contentRange: status === 206 ? `bytes ${start}-${end}/${totalBytes}` : null,
358
+ acceptRanges: "bytes"
359
+ };
360
+ }
361
+ function invalidRange(reason, maxPageBytes) {
362
+ return { kind: "invalid", reason, maxPageBytes };
363
+ }
364
+ function unsatisfiableRange(reason, totalBytes) {
365
+ return {
366
+ kind: "unsatisfiable",
367
+ reason,
368
+ totalBytes,
369
+ contentRange: `bytes */${totalBytes}`
370
+ };
371
+ }
372
+
373
+ // src/video-generation.ts
374
+ var VIDEO_GENERATION_SCHEMA_VERSION = 1;
375
+ var SEEDANCE_2_5_MODEL_ID = "bytedance/seedance-2.5";
376
+ var GROK_IMAGINE_VIDEO_1_5_MODEL_ID = "xai/grok-imagine-video-1.5";
377
+ var VideoGenerationSourceMode = z2.enum([
378
+ "text",
379
+ "first_frame",
380
+ "first_and_last_frames",
381
+ "image_reference",
382
+ "video_reference"
383
+ ]);
384
+ var VideoGenerationResolution = z2.enum(["480p", "720p"]);
385
+ var VideoGenerationFundingSource = z2.enum([
386
+ "opengeni_credits",
387
+ "workspace_gateway",
388
+ "supergrok_subscription"
389
+ ]);
390
+ var VideoGenerationAspectRatio = z2.enum([
391
+ "16:9",
392
+ "4:3",
393
+ "1:1",
394
+ "3:4",
395
+ "9:16",
396
+ "21:9",
397
+ "adaptive"
398
+ ]);
399
+ var SandboxVideoReferencePath = z2.string().min(1).max(1024).refine((value) => value.startsWith("/workspace/"), {
400
+ message: "video references must use an absolute /workspace path"
401
+ });
402
+ var VideoGenerationSource = z2.discriminatedUnion("mode", [
403
+ z2.object({ mode: z2.literal("text") }).strict(),
404
+ z2.object({
405
+ mode: z2.literal("first_frame"),
406
+ imagePath: SandboxVideoReferencePath
407
+ }).strict(),
408
+ z2.object({
409
+ mode: z2.literal("first_and_last_frames"),
410
+ firstFramePath: SandboxVideoReferencePath,
411
+ lastFramePath: SandboxVideoReferencePath
412
+ }).strict().refine((value) => value.firstFramePath !== value.lastFramePath, {
413
+ path: ["lastFramePath"],
414
+ message: "first and last frame paths must differ"
415
+ }),
416
+ z2.object({
417
+ mode: z2.literal("image_reference"),
418
+ imagePath: SandboxVideoReferencePath
419
+ }).strict(),
420
+ z2.object({
421
+ mode: z2.literal("video_reference"),
422
+ videoPath: SandboxVideoReferencePath
423
+ }).strict()
424
+ ]);
425
+ var GenerateVideoToolInput = z2.object({
426
+ prompt: z2.string().min(1).max(32e3).refine((value) => value.trim().length > 0),
427
+ modelId: z2.string().min(1).max(256).optional(),
428
+ source: VideoGenerationSource.optional(),
429
+ durationSeconds: z2.number().int().min(4).max(30).optional(),
430
+ aspectRatio: VideoGenerationAspectRatio.optional(),
431
+ resolution: VideoGenerationResolution.optional(),
432
+ generateAudio: z2.boolean().optional()
433
+ }).strict();
434
+ var GetVideoGenerationCapabilitiesToolInput = z2.object({}).strict();
435
+ var VideoGenerationModelCapability = z2.object({
436
+ modelId: z2.string().min(1).max(256),
437
+ label: z2.string().min(1).max(128),
438
+ providerLabel: z2.string().min(1).max(128),
439
+ sourceModes: z2.array(VideoGenerationSourceMode).min(1).max(5),
440
+ resolutions: z2.array(VideoGenerationResolution).min(1).max(2),
441
+ aspectRatios: z2.array(VideoGenerationAspectRatio).min(1).max(7),
442
+ duration: z2.object({
443
+ minSeconds: z2.number().int().positive(),
444
+ maxSeconds: z2.number().int().positive(),
445
+ stepSeconds: z2.number().int().positive()
446
+ }).strict().refine((value) => value.maxSeconds >= value.minSeconds),
447
+ supportsAudio: z2.boolean()
448
+ }).strict();
449
+ var VideoGenerationCapabilities = z2.object({
450
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
451
+ capabilityRevision: z2.string().min(1).max(128),
452
+ defaultModelId: z2.string().min(1).max(256),
453
+ models: z2.array(VideoGenerationModelCapability).min(1).max(16)
454
+ }).strict().superRefine((value, ctx) => {
455
+ const ids = new Set(value.models.map((model) => model.modelId));
456
+ if (ids.size !== value.models.length) {
457
+ ctx.addIssue({
458
+ code: "custom",
459
+ path: ["models"],
460
+ message: "model ids must be unique"
461
+ });
462
+ }
463
+ if (!ids.has(value.defaultModelId)) {
464
+ ctx.addIssue({
465
+ code: "custom",
466
+ path: ["defaultModelId"],
467
+ message: "default model must be present in the enabled model list"
468
+ });
469
+ }
470
+ });
471
+ var VideoGenerationPolicy = z2.object({
472
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
473
+ revision: z2.number().int().nonnegative().safe(),
474
+ fundingSource: VideoGenerationFundingSource,
475
+ enabledModelIds: z2.array(z2.string().min(1).max(256)).max(16),
476
+ defaultModelId: z2.string().min(1).max(256).nullable()
477
+ }).strict().superRefine((value, ctx) => {
478
+ const ids = new Set(value.enabledModelIds);
479
+ if (ids.size !== value.enabledModelIds.length) {
480
+ ctx.addIssue({
481
+ code: "custom",
482
+ path: ["enabledModelIds"],
483
+ message: "enabled model ids must be unique"
484
+ });
485
+ }
486
+ if (value.defaultModelId !== null && !ids.has(value.defaultModelId)) {
487
+ ctx.addIssue({
488
+ code: "custom",
489
+ path: ["defaultModelId"],
490
+ message: "default model must be enabled"
491
+ });
492
+ }
493
+ });
494
+ var UpdateVideoGenerationPolicyRequest = z2.object({
495
+ expectedRevision: z2.number().int().nonnegative().safe(),
496
+ fundingSource: VideoGenerationFundingSource,
497
+ enabledModelIds: z2.array(z2.string().min(1).max(256)).max(16),
498
+ defaultModelId: z2.string().min(1).max(256).nullable()
499
+ }).strict();
500
+ var VideoGenerationFundingOption = z2.object({
501
+ source: VideoGenerationFundingSource,
502
+ label: z2.string().min(1).max(128),
503
+ description: z2.string().min(1).max(256),
504
+ available: z2.boolean(),
505
+ unavailableReason: z2.string().min(1).max(256).nullable()
506
+ }).strict().superRefine((value, ctx) => {
507
+ if (value.available !== (value.unavailableReason === null)) {
508
+ ctx.addIssue({
509
+ code: "custom",
510
+ path: ["unavailableReason"],
511
+ message: "available funding options cannot have an unavailable reason"
512
+ });
513
+ }
514
+ });
515
+ var WorkspaceVideoGenerationSettings = z2.object({
516
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
517
+ policy: VideoGenerationPolicy,
518
+ fundingOptions: z2.array(VideoGenerationFundingOption).length(3),
519
+ availableModels: z2.array(VideoGenerationModelCapability).max(16),
520
+ capabilities: VideoGenerationCapabilities.nullable()
521
+ }).strict().superRefine((value, ctx) => {
522
+ if (new Set(value.fundingOptions.map((option) => option.source)).size !== 3 || !value.fundingOptions.some((option) => option.source === "opengeni_credits") || !value.fundingOptions.some((option) => option.source === "workspace_gateway") || !value.fundingOptions.some((option) => option.source === "supergrok_subscription")) {
523
+ ctx.addIssue({
524
+ code: "custom",
525
+ path: ["fundingOptions"],
526
+ message: "all funding sources must be described exactly once"
527
+ });
528
+ }
529
+ const selected = value.fundingOptions.find(
530
+ (option) => option.source === value.policy.fundingSource
531
+ );
532
+ if (!selected) {
533
+ ctx.addIssue({
534
+ code: "custom",
535
+ path: ["fundingOptions"],
536
+ message: "the selected funding source must be described"
537
+ });
538
+ } else if (!selected.available && value.capabilities !== null) {
539
+ ctx.addIssue({
540
+ code: "custom",
541
+ path: ["capabilities"],
542
+ message: "unavailable funding cannot expose executable capabilities"
543
+ });
544
+ }
545
+ });
546
+ var VideoGenerationAcceptedReceipt = z2.object({
547
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
548
+ status: z2.literal("accepted"),
549
+ operationId: z2.string().uuid()
550
+ }).strict();
551
+ var VideoGenerationRejectedCode = z2.enum([
552
+ "invalid_reference_path",
553
+ "reference_not_stable",
554
+ "reference_too_large",
555
+ "reference_media_type_mismatch",
556
+ "unsupported_reference_media"
557
+ ]);
558
+ var VideoGenerationRejectedResult = z2.object({
559
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
560
+ status: z2.literal("rejected"),
561
+ code: VideoGenerationRejectedCode,
562
+ message: z2.string().min(1).max(512),
563
+ operationCreated: z2.literal(false)
564
+ }).strict();
565
+ var VideoGenerationToolResult = z2.discriminatedUnion("status", [
566
+ VideoGenerationAcceptedReceipt,
567
+ VideoGenerationRejectedResult
568
+ ]);
569
+ var GeneratedVideoFacts = z2.object({
570
+ durationSeconds: z2.number().positive().max(120),
571
+ width: z2.number().int().positive().max(8192),
572
+ height: z2.number().int().positive().max(8192),
573
+ fps: z2.number().positive().max(120),
574
+ hasAudio: z2.boolean(),
575
+ videoCodec: z2.literal("h264"),
576
+ audioCodec: z2.literal("aac").nullable()
577
+ }).strict();
578
+ var GeneratedVideoReceipt = z2.object({
579
+ type: z2.literal("generated_video"),
580
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
581
+ operationId: z2.string().uuid(),
582
+ artifact: RetainedArtifactReferenceSchema,
583
+ video: GeneratedVideoFacts,
584
+ sandboxPath: z2.string().max(256).regex(
585
+ /^\/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$/
586
+ )
587
+ }).strict().superRefine((value, ctx) => {
588
+ if (value.artifact.kind !== "generated_video" || value.artifact.contentType !== "video/mp4" || value.artifact.originalBytes <= 0 || value.artifact.originalBytes > GENERATED_VIDEO_MAX_BYTES || value.artifact.retention.policy !== "workspace_file" || value.artifact.retrieval.maxRangeBytes !== RETAINED_OUTPUT_MAX_PAGE_BYTES) {
589
+ ctx.addIssue({
590
+ code: "custom",
591
+ path: ["artifact"],
592
+ message: "generated-video artifact metadata is invalid"
593
+ });
594
+ }
595
+ if (value.artifact.dimensions?.width !== value.video.width || value.artifact.dimensions?.height !== value.video.height) {
596
+ ctx.addIssue({
597
+ code: "custom",
598
+ path: ["video"],
599
+ message: "video dimensions must match the retained artifact"
600
+ });
601
+ }
602
+ if (value.sandboxPath !== `/workspace/generated-videos/generated-video-${value.artifact.artifactId}.mp4`) {
603
+ ctx.addIssue({
604
+ code: "custom",
605
+ path: ["sandboxPath"],
606
+ message: "generated-video sandbox path does not match its artifact"
607
+ });
608
+ }
609
+ });
610
+ var VideoGenerationTerminalFailureStatus = z2.enum([
611
+ "provider_failed",
612
+ "retention_failed",
613
+ "cancelled_before_submit",
614
+ "outcome_unknown"
615
+ ]);
616
+ var MediaGenerationResult = z2.discriminatedUnion("status", [
617
+ z2.object({
618
+ type: z2.literal("media_generation_result"),
619
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
620
+ status: z2.literal("ready"),
621
+ operationId: z2.string().uuid(),
622
+ receipt: GeneratedVideoReceipt
623
+ }).strict().refine((value) => value.receipt.operationId === value.operationId, {
624
+ path: ["receipt", "operationId"],
625
+ message: "terminal receipt must match its operation"
626
+ }),
627
+ z2.object({
628
+ type: z2.literal("media_generation_result"),
629
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
630
+ status: VideoGenerationTerminalFailureStatus,
631
+ operationId: z2.string().uuid(),
632
+ boundedPublicReason: z2.string().min(1).max(1e3)
633
+ }).strict()
634
+ ]);
635
+ var VideoGenerationPublicStatus = z2.enum([
636
+ "preparing",
637
+ "prepared",
638
+ "accepted",
639
+ "provider_started",
640
+ "retaining",
641
+ "completed",
642
+ "provider_failed",
643
+ "cancelled_before_submit",
644
+ "outcome_unknown",
645
+ "retention_failed"
646
+ ]);
647
+ var VideoGenerationOperationSummary = z2.object({
648
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
649
+ operationId: z2.string().uuid(),
650
+ modelId: z2.string().min(1).max(256),
651
+ status: VideoGenerationPublicStatus,
652
+ createdAt: z2.string().datetime({ offset: true }),
653
+ updatedAt: z2.string().datetime({ offset: true }),
654
+ terminal: MediaGenerationResult.nullable()
655
+ }).strict();
656
+ var VideoArtifactPlaybackSource = z2.object({
657
+ schemaVersion: z2.literal(VIDEO_GENERATION_SCHEMA_VERSION),
658
+ artifactId: z2.string().uuid(),
659
+ url: z2.string().url().max(8192),
660
+ expiresAt: z2.string().datetime({ offset: true }),
661
+ contentType: z2.literal("video/mp4"),
662
+ sizeBytes: z2.number().int().positive().max(GENERATED_VIDEO_MAX_BYTES),
663
+ sha256: z2.string().regex(/^[0-9a-f]{64}$/),
664
+ acceptRanges: z2.literal("bytes")
665
+ }).strict();
666
+
667
+ export {
668
+ RETAINED_OUTPUT_MAX_PAGE_BYTES,
669
+ RETAINED_OUTPUT_DEFAULT_PAGE_BYTES,
670
+ RETAINED_OUTPUT_RECEIPT_MAX_BYTES,
671
+ COMPUTER_SCREENSHOT_MAX_BYTES,
672
+ COMPUTER_SCREENSHOT_MAX_DIMENSION,
673
+ COMPUTER_SCREENSHOT_MAX_PIXELS,
674
+ COMPUTER_SCREENSHOT_RETENTION_MS,
675
+ COMPUTER_SCREENSHOT_WORKSPACE_QUOTA_BYTES,
676
+ GENERATED_IMAGE_MAX_BYTES,
677
+ GENERATED_VIDEO_MAX_BYTES,
678
+ RetainedOutputKind,
679
+ RetainedOutputUnavailableReason,
680
+ RetainedArtifactReferenceSchema,
681
+ RetainedOutputEvidenceSchema,
682
+ RetainedArtifactUnavailableSchema,
683
+ RetainedArtifactMetadataSchema,
684
+ retainedArtifactReferenceFromFile,
685
+ retainedScreenshotReferenceFromFile,
686
+ retainedGeneratedImageReferenceFromFile,
687
+ retainedGeneratedVideoReferenceFromFile,
688
+ validateRetainedOutputEvidence,
689
+ retainedOutputUnavailable,
690
+ resolveRetainedOutputRange,
691
+ VIDEO_GENERATION_SCHEMA_VERSION,
692
+ SEEDANCE_2_5_MODEL_ID,
693
+ GROK_IMAGINE_VIDEO_1_5_MODEL_ID,
694
+ VideoGenerationSourceMode,
695
+ VideoGenerationResolution,
696
+ VideoGenerationFundingSource,
697
+ VideoGenerationAspectRatio,
698
+ VideoGenerationSource,
699
+ GenerateVideoToolInput,
700
+ GetVideoGenerationCapabilitiesToolInput,
701
+ VideoGenerationModelCapability,
702
+ VideoGenerationCapabilities,
703
+ VideoGenerationPolicy,
704
+ UpdateVideoGenerationPolicyRequest,
705
+ VideoGenerationFundingOption,
706
+ WorkspaceVideoGenerationSettings,
707
+ VideoGenerationAcceptedReceipt,
708
+ VideoGenerationRejectedCode,
709
+ VideoGenerationRejectedResult,
710
+ VideoGenerationToolResult,
711
+ GeneratedVideoFacts,
712
+ GeneratedVideoReceipt,
713
+ VideoGenerationTerminalFailureStatus,
714
+ MediaGenerationResult,
715
+ VideoGenerationPublicStatus,
716
+ VideoGenerationOperationSummary,
717
+ VideoArtifactPlaybackSource
718
+ };
719
+ //# sourceMappingURL=chunk-M5ZGRVIQ.js.map