@opengeni/contracts 0.1.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/index.js ADDED
@@ -0,0 +1,1295 @@
1
+ // src/index.ts
2
+ import { z } from "zod";
3
+ var SessionStatus = z.enum([
4
+ "queued",
5
+ "running",
6
+ "idle",
7
+ "requires_action",
8
+ "failed",
9
+ "cancelled"
10
+ ]);
11
+ var SandboxBackend = z.enum(["docker", "modal", "local", "none"]);
12
+ var ReasoningEffort = z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]);
13
+ var ErrorCode = z.enum([
14
+ "unauthenticated",
15
+ "forbidden",
16
+ "not_found",
17
+ "validation_failed",
18
+ "conflict",
19
+ "idempotency_conflict",
20
+ "limit_exceeded",
21
+ "provider_verification_failed",
22
+ "upstream_unavailable",
23
+ "internal_error"
24
+ ]);
25
+ var ErrorEnvelope = z.object({
26
+ error: z.object({
27
+ code: ErrorCode,
28
+ message: z.string(),
29
+ requestId: z.string().optional(),
30
+ details: z.record(z.string(), z.unknown()).optional()
31
+ })
32
+ });
33
+ var PageInfo = z.object({
34
+ limit: z.number().int().positive(),
35
+ nextCursor: z.string().nullable(),
36
+ hasMore: z.boolean()
37
+ });
38
+ function paginated(item) {
39
+ return z.object({
40
+ data: z.array(item),
41
+ page: PageInfo
42
+ });
43
+ }
44
+ var Permission = z.enum([
45
+ "account:read",
46
+ "account:admin",
47
+ "members:manage",
48
+ "workspace:create",
49
+ "billing:read",
50
+ "billing:manage",
51
+ "workspace:read",
52
+ "workspace:admin",
53
+ "sessions:create",
54
+ "sessions:read",
55
+ "sessions:control",
56
+ "files:upload",
57
+ "files:read",
58
+ "documents:manage",
59
+ "documents:search",
60
+ "scheduled_tasks:manage",
61
+ "scheduled_tasks:run",
62
+ "github:manage",
63
+ "github:use",
64
+ "api_keys:manage",
65
+ "environments:manage",
66
+ "environments:use",
67
+ "goals:manage"
68
+ ]);
69
+ var ProductAccessMode = z.enum(["local", "configured", "managed"]);
70
+ var BillingMode = z.enum(["disabled", "stripe"]);
71
+ var EntitlementsMode = z.enum(["none", "static", "managed"]);
72
+ var UsageLimitsMode = z.enum(["none", "static", "managed"]);
73
+ var AccountRole = z.enum(["owner", "admin", "member"]);
74
+ var ManagedAccount = z.object({
75
+ id: z.string().uuid(),
76
+ name: z.string(),
77
+ externalSource: z.string().nullable(),
78
+ externalId: z.string().nullable(),
79
+ createdAt: z.string(),
80
+ updatedAt: z.string()
81
+ });
82
+ var Workspace = z.object({
83
+ id: z.string().uuid(),
84
+ accountId: z.string().uuid(),
85
+ name: z.string(),
86
+ slug: z.string().nullable(),
87
+ externalSource: z.string().nullable(),
88
+ externalId: z.string().nullable(),
89
+ // Per-workspace agent persona template (white-label override). null means
90
+ // the deployment default (OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE /
91
+ // DEFAULT_AGENT_INSTRUCTIONS) is used. The runtime always injects the
92
+ // non-bypassable CORE (goal-loop ownership + environment block), so an
93
+ // override restyles the persona without dropping that contract.
94
+ agentInstructions: z.string().nullable(),
95
+ createdAt: z.string(),
96
+ updatedAt: z.string()
97
+ });
98
+ var AccountGrant = z.object({
99
+ accountId: z.string().uuid(),
100
+ subjectId: z.string().min(1),
101
+ subjectLabel: z.string().optional(),
102
+ role: AccountRole.optional(),
103
+ permissions: z.array(Permission),
104
+ metadata: z.record(z.string(), z.unknown()).optional()
105
+ });
106
+ var AccessGrant = z.object({
107
+ workspaceId: z.string().uuid(),
108
+ accountId: z.string().uuid(),
109
+ subjectId: z.string().min(1),
110
+ subjectLabel: z.string().optional(),
111
+ permissions: z.array(Permission),
112
+ metadata: z.record(z.string(), z.unknown()).optional()
113
+ });
114
+ var AccessContext = z.object({
115
+ mode: ProductAccessMode,
116
+ subjectId: z.string().min(1),
117
+ subjectLabel: z.string().optional(),
118
+ accountGrants: z.array(AccountGrant),
119
+ workspaceGrants: z.array(AccessGrant),
120
+ defaultAccountId: z.string().uuid().nullable(),
121
+ defaultWorkspaceId: z.string().uuid().nullable()
122
+ });
123
+ var DelegatedAccessTokenPayload = z.object({
124
+ accountId: z.string().uuid(),
125
+ workspaceId: z.string().uuid(),
126
+ subjectId: z.string().min(1),
127
+ subjectLabel: z.string().optional(),
128
+ permissions: z.array(Permission).min(1),
129
+ // Worker-asserted session scope for first-party MCP calls (HMAC-signed, not
130
+ // agent-controlled); enables session-scoped tools such as goal management.
131
+ sessionId: z.string().uuid().optional(),
132
+ exp: z.number().int().positive()
133
+ });
134
+ async function signDelegatedAccessToken(secret, payload) {
135
+ const encodedPayload = base64UrlEncode(JSON.stringify(DelegatedAccessTokenPayload.parse(payload)));
136
+ const signature = await hmacSha256Base64Url(secret, encodedPayload);
137
+ return `ogd_${encodedPayload}.${signature}`;
138
+ }
139
+ async function verifyDelegatedAccessToken(secret, token, nowSeconds = Math.floor(Date.now() / 1e3)) {
140
+ if (!token.startsWith("ogd_")) {
141
+ return null;
142
+ }
143
+ const withoutPrefix = token.slice("ogd_".length);
144
+ const dot = withoutPrefix.lastIndexOf(".");
145
+ if (dot <= 0) {
146
+ return null;
147
+ }
148
+ const encodedPayload = withoutPrefix.slice(0, dot);
149
+ const signature = withoutPrefix.slice(dot + 1);
150
+ const expected = await hmacSha256Base64Url(secret, encodedPayload);
151
+ if (!constantTimeEqual(signature, expected)) {
152
+ return null;
153
+ }
154
+ const payload = DelegatedAccessTokenPayload.safeParse(JSON.parse(base64UrlDecode(encodedPayload)));
155
+ if (!payload.success || payload.data.exp < nowSeconds) {
156
+ return null;
157
+ }
158
+ return payload.data;
159
+ }
160
+ var CreateWorkspaceRequest = z.object({
161
+ accountId: z.string().uuid().optional(),
162
+ name: z.string().min(1),
163
+ slug: z.string().min(1).optional(),
164
+ externalSource: z.string().min(1).optional(),
165
+ externalId: z.string().min(1).optional(),
166
+ // White-label persona override for this workspace's agent. null/omitted uses
167
+ // the deployment default template.
168
+ agentInstructions: z.string().min(1).nullable().optional()
169
+ });
170
+ var UpdateWorkspaceRequest = z.object({
171
+ name: z.string().min(1).optional(),
172
+ slug: z.string().min(1).nullable().optional(),
173
+ // White-label persona override. Pass null to clear it back to the deployment
174
+ // default; omit to leave it unchanged.
175
+ agentInstructions: z.string().min(1).nullable().optional()
176
+ });
177
+ var ApiKey = z.object({
178
+ id: z.string().uuid(),
179
+ accountId: z.string().uuid(),
180
+ workspaceId: z.string().uuid().nullable(),
181
+ name: z.string(),
182
+ prefix: z.string(),
183
+ permissions: z.array(Permission),
184
+ expiresAt: z.string().nullable(),
185
+ revokedAt: z.string().nullable(),
186
+ lastUsedAt: z.string().nullable(),
187
+ createdAt: z.string(),
188
+ updatedAt: z.string()
189
+ });
190
+ var CreateApiKeyRequest = z.object({
191
+ name: z.string().min(1),
192
+ workspaceId: z.string().uuid().optional(),
193
+ permissions: z.array(Permission).min(1),
194
+ expiresAt: z.string().datetime({ offset: true }).optional()
195
+ });
196
+ var CreateApiKeyResponse = z.object({
197
+ apiKey: ApiKey,
198
+ token: z.string().min(1)
199
+ });
200
+ var UsageEventType = z.enum([
201
+ "agent_run.created",
202
+ "agent_run.completed",
203
+ "model.tokens",
204
+ "model.cost",
205
+ "file.uploaded",
206
+ "file.deleted",
207
+ "document.indexed",
208
+ "scheduled_task.fired",
209
+ "api_key.request"
210
+ ]);
211
+ var UsageEvent = z.object({
212
+ id: z.string().uuid(),
213
+ workspaceId: z.string().uuid(),
214
+ accountId: z.string().uuid(),
215
+ subjectId: z.string().nullable(),
216
+ eventType: UsageEventType,
217
+ quantity: z.number(),
218
+ unit: z.string(),
219
+ sourceResourceType: z.string().nullable(),
220
+ sourceResourceId: z.string().nullable(),
221
+ idempotencyKey: z.string(),
222
+ occurredAt: z.string(),
223
+ recordedAt: z.string(),
224
+ exportedToBillingAt: z.string().nullable(),
225
+ billingProviderEventId: z.string().nullable()
226
+ });
227
+ var LimitAction = z.enum([
228
+ "agent_run:create",
229
+ "tokens:consume",
230
+ "file:upload",
231
+ "document:index",
232
+ "schedule:create",
233
+ "workspace:create",
234
+ "api_key:create"
235
+ ]);
236
+ var StaticUsageLimits = z.object({
237
+ maxWorkspacesPerAccount: z.number().int().positive().optional(),
238
+ maxApiKeysPerWorkspace: z.number().int().positive().optional(),
239
+ maxSchedulesPerWorkspace: z.number().int().positive().optional(),
240
+ maxFileUploadBytes: z.number().int().positive().optional(),
241
+ maxMonthlyAgentRunsPerWorkspace: z.number().int().positive().optional(),
242
+ maxMonthlyTokensPerWorkspace: z.number().int().positive().optional(),
243
+ maxMonthlyCostMicrosPerAccount: z.number().int().positive().optional(),
244
+ maxDocumentIndexedChunksPerWorkspace: z.number().int().positive().optional()
245
+ });
246
+ var EntitlementValue = z.union([z.boolean(), z.string(), z.number(), z.array(z.string())]);
247
+ var Entitlements = z.record(z.string().min(1), EntitlementValue);
248
+ var LimitDecision = z.discriminatedUnion("allowed", [
249
+ z.object({ allowed: z.literal(true) }),
250
+ z.object({ allowed: z.literal(false), code: z.string(), message: z.string() })
251
+ ]);
252
+ var BillingBalance = z.object({
253
+ accountId: z.string().uuid(),
254
+ balanceMicros: z.number().int(),
255
+ currency: z.literal("usd"),
256
+ updatedAt: z.string()
257
+ });
258
+ var CreateCheckoutRequest = z.object({
259
+ accountId: z.string().uuid().optional(),
260
+ amountUsd: z.number().min(5).max(1e4).refine(
261
+ (value) => Number.isFinite(value) && Math.abs(value - Math.round(value * 100) / 100) < 1e-9,
262
+ { message: "amountUsd must use cent precision" }
263
+ ),
264
+ successUrl: z.string().url().optional(),
265
+ cancelUrl: z.string().url().optional()
266
+ });
267
+ var CreateCheckoutResponse = z.object({
268
+ checkoutSessionId: z.string(),
269
+ url: z.string().url()
270
+ });
271
+ var RepositoryResourceRef = z.object({
272
+ kind: z.literal("repository"),
273
+ uri: z.string().min(1),
274
+ ref: z.string().min(1),
275
+ mountPath: z.string().min(1).optional(),
276
+ subpath: z.string().min(1).optional(),
277
+ githubInstallationId: z.number().int().positive().optional(),
278
+ githubRepositoryId: z.number().int().positive().optional()
279
+ });
280
+ var FileResourceRef = z.object({
281
+ kind: z.literal("file"),
282
+ fileId: z.string().uuid(),
283
+ mountPath: z.string().min(1).optional()
284
+ });
285
+ var ResourceRef = z.discriminatedUnion("kind", [RepositoryResourceRef, FileResourceRef]);
286
+ var FileStatus = z.enum(["pending_upload", "ready", "failed", "expired", "deleted"]);
287
+ var FileUploadStatus = z.enum(["pending", "completed", "expired", "failed"]);
288
+ var FileAsset = z.object({
289
+ id: z.string().uuid(),
290
+ workspaceId: z.string().uuid(),
291
+ status: FileStatus,
292
+ filename: z.string(),
293
+ safeFilename: z.string(),
294
+ contentType: z.string(),
295
+ sizeBytes: z.number().int().nonnegative(),
296
+ sha256: z.string().nullable(),
297
+ bucket: z.string(),
298
+ objectKey: z.string(),
299
+ createdAt: z.string(),
300
+ updatedAt: z.string()
301
+ });
302
+ var CreateFileUploadRequest = z.object({
303
+ filename: z.string().min(1),
304
+ contentType: z.string().min(1),
305
+ sizeBytes: z.number().int().positive(),
306
+ sha256: z.string().min(1).optional()
307
+ });
308
+ var CreateFileUploadResponse = z.object({
309
+ fileId: z.string().uuid(),
310
+ uploadId: z.string().uuid(),
311
+ putUrl: z.string().url(),
312
+ requiredHeaders: z.record(z.string(), z.string()),
313
+ expiresAt: z.string(),
314
+ maxSizeBytes: z.number().int().positive()
315
+ });
316
+ var CompleteFileUploadResponse = z.object({
317
+ file: FileAsset
318
+ });
319
+ var FileDownloadUrlResponse = z.object({
320
+ url: z.string().url(),
321
+ expiresAt: z.string()
322
+ });
323
+ var DocumentStatus = z.enum(["queued", "indexing", "ready", "failed"]);
324
+ var DocumentBase = z.object({
325
+ id: z.string().uuid(),
326
+ workspaceId: z.string().uuid(),
327
+ name: z.string(),
328
+ description: z.string().nullable(),
329
+ createdAt: z.string(),
330
+ updatedAt: z.string()
331
+ });
332
+ var Document = z.object({
333
+ id: z.string().uuid(),
334
+ workspaceId: z.string().uuid(),
335
+ baseId: z.string().uuid(),
336
+ fileId: z.string().uuid(),
337
+ status: DocumentStatus,
338
+ title: z.string(),
339
+ parser: z.string(),
340
+ chunkCount: z.number().int().nonnegative(),
341
+ error: z.string().nullable(),
342
+ createdAt: z.string(),
343
+ updatedAt: z.string()
344
+ });
345
+ var DocumentSearchResult = z.object({
346
+ chunkId: z.string().uuid(),
347
+ workspaceId: z.string().uuid(),
348
+ documentId: z.string().uuid(),
349
+ baseId: z.string().uuid(),
350
+ fileId: z.string().uuid(),
351
+ title: z.string(),
352
+ text: z.string(),
353
+ score: z.number(),
354
+ chunkIndex: z.number().int().nonnegative(),
355
+ metadata: z.record(z.string(), z.unknown())
356
+ });
357
+ var CreateDocumentBaseRequest = z.object({
358
+ name: z.string().min(1),
359
+ description: z.string().optional()
360
+ });
361
+ var AddDocumentRequest = z.object({
362
+ fileId: z.string().uuid()
363
+ });
364
+ var DocumentSearchRequest = z.object({
365
+ query: z.string().min(1),
366
+ limit: z.number().int().positive().max(20).default(5)
367
+ });
368
+ var ToolRef = z.object({
369
+ kind: z.literal("mcp"),
370
+ id: z.string().min(1)
371
+ });
372
+ var ResourceRefConflictError = class extends Error {
373
+ constructor(message) {
374
+ super(message);
375
+ this.name = "ResourceRefConflictError";
376
+ }
377
+ };
378
+ function mergeToolRefs(existing, additions) {
379
+ const seen = /* @__PURE__ */ new Set();
380
+ const out = [];
381
+ for (const tool of [...existing, ...additions]) {
382
+ const key = `${tool.kind}:${tool.id}`;
383
+ if (seen.has(key)) {
384
+ continue;
385
+ }
386
+ seen.add(key);
387
+ out.push(tool);
388
+ }
389
+ return out;
390
+ }
391
+ function mergeResourceRefs(existing, additions, options = {}) {
392
+ const out = [...existing];
393
+ const mountPaths = new Map(existing.flatMap((resource) => resource.mountPath ? [[resource.mountPath, stableJson(resource)]] : []));
394
+ const identities = new Map(existing.map((resource) => [resourceIdentityKey(resource), stableJson(resource)]));
395
+ const exact = new Set(existing.map(stableJson));
396
+ for (const resource of additions) {
397
+ const serialized = stableJson(resource);
398
+ if (exact.has(serialized)) {
399
+ continue;
400
+ }
401
+ if (options.rejectConflicts) {
402
+ const existingAtMount = resource.mountPath ? mountPaths.get(resource.mountPath) : void 0;
403
+ if (existingAtMount && existingAtMount !== serialized) {
404
+ throw new ResourceRefConflictError(`resource mount path is already attached: ${resource.mountPath}`);
405
+ }
406
+ const identity = resourceIdentityKey(resource);
407
+ const existingIdentity = identities.get(identity);
408
+ if (existingIdentity && existingIdentity !== serialized) {
409
+ throw new ResourceRefConflictError(`resource is already attached with different settings: ${identity}`);
410
+ }
411
+ }
412
+ out.push(resource);
413
+ exact.add(serialized);
414
+ identities.set(resourceIdentityKey(resource), serialized);
415
+ if (resource.mountPath) {
416
+ mountPaths.set(resource.mountPath, serialized);
417
+ }
418
+ }
419
+ return out;
420
+ }
421
+ function reasoningEffortForMetadata(metadata, fallback) {
422
+ const value = metadata.reasoningEffort;
423
+ return value === "none" || value === "minimal" || value === "low" || value === "medium" || value === "high" || value === "xhigh" ? value : fallback;
424
+ }
425
+ function stableJson(value) {
426
+ return JSON.stringify(sortJson(value));
427
+ }
428
+ function resourceIdentityKey(resource) {
429
+ if (resource.kind === "file") {
430
+ return `file:${resource.fileId}`;
431
+ }
432
+ return `repository:${resource.uri}`;
433
+ }
434
+ function sortJson(value) {
435
+ if (Array.isArray(value)) {
436
+ return value.map(sortJson);
437
+ }
438
+ if (value && typeof value === "object") {
439
+ return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, nested]) => [key, sortJson(nested)]));
440
+ }
441
+ return value;
442
+ }
443
+ var SessionTurnStatus = z.enum(["queued", "running", "requires_action", "completed", "failed", "cancelled"]);
444
+ var SessionTurnSource = z.enum(["user", "scheduled_task", "api", "goal"]);
445
+ var SessionGoalStatus = z.enum(["active", "paused", "completed"]);
446
+ var SessionGoalCreatedBy = z.enum(["api", "agent", "scheduled_task"]);
447
+ var SessionGoalPausedReason = z.enum([
448
+ "agent",
449
+ "user_interrupt",
450
+ "api",
451
+ "no_progress",
452
+ "max_auto_continuations",
453
+ "limits"
454
+ ]);
455
+ var SessionGoal = z.object({
456
+ id: z.string().uuid(),
457
+ accountId: z.string().uuid(),
458
+ workspaceId: z.string().uuid(),
459
+ sessionId: z.string().uuid(),
460
+ status: SessionGoalStatus,
461
+ text: z.string(),
462
+ successCriteria: z.string().nullable(),
463
+ evidence: z.string().nullable(),
464
+ rationale: z.string().nullable(),
465
+ pausedReason: z.string().nullable(),
466
+ createdBy: SessionGoalCreatedBy,
467
+ version: z.number().int().positive(),
468
+ autoContinuations: z.number().int().nonnegative(),
469
+ noProgressStreak: z.number().int().nonnegative(),
470
+ maxAutoContinuations: z.number().int().positive().nullable(),
471
+ metadata: z.record(z.string(), z.unknown()),
472
+ createdAt: z.string(),
473
+ updatedAt: z.string()
474
+ });
475
+ var GoalSpec = z.object({
476
+ text: z.string().min(1),
477
+ successCriteria: z.string().min(1).optional(),
478
+ maxAutoContinuations: z.number().int().positive().optional()
479
+ });
480
+ var UpdateSessionGoalRequest = z.object({
481
+ status: z.enum(["paused", "active"]),
482
+ rationale: z.string().min(1).optional()
483
+ });
484
+ var ClearSessionContextRequest = z.object({
485
+ confirm: z.literal(true)
486
+ });
487
+ var CLEARED_RUN_STATE_MARKER = "$opengeniCleared";
488
+ var CLEARED_RUN_STATE_BLOB = JSON.stringify({ [CLEARED_RUN_STATE_MARKER]: true });
489
+ function isClearedRunStateBlob(serialized) {
490
+ if (!serialized) {
491
+ return false;
492
+ }
493
+ try {
494
+ const parsed = JSON.parse(serialized);
495
+ return typeof parsed === "object" && parsed !== null && parsed[CLEARED_RUN_STATE_MARKER] === true;
496
+ } catch {
497
+ return false;
498
+ }
499
+ }
500
+ var CompactSessionContextRequest = z.object({}).strict();
501
+ var CompactSessionContextResult = z.object({
502
+ // queued: a client-side (Azure) compaction will run before the next turn.
503
+ // noop: nothing to do (server-managed provider, mode off, or no history).
504
+ status: z.enum(["queued", "noop"]),
505
+ message: z.string()
506
+ });
507
+ var SessionTurn = z.object({
508
+ id: z.string().uuid(),
509
+ workspaceId: z.string().uuid(),
510
+ sessionId: z.string().uuid(),
511
+ triggerEventId: z.string().uuid(),
512
+ temporalWorkflowId: z.string(),
513
+ status: SessionTurnStatus,
514
+ source: SessionTurnSource,
515
+ position: z.number().int().positive(),
516
+ prompt: z.string().min(1),
517
+ resources: z.array(ResourceRef),
518
+ tools: z.array(ToolRef),
519
+ model: z.string().min(1),
520
+ reasoningEffort: ReasoningEffort,
521
+ sandboxBackend: SandboxBackend,
522
+ metadata: z.record(z.string(), z.unknown()),
523
+ startedAt: z.string().nullable(),
524
+ finishedAt: z.string().nullable(),
525
+ createdAt: z.string(),
526
+ updatedAt: z.string()
527
+ });
528
+ var UpdateSessionTurnRequest = z.object({
529
+ prompt: z.string().min(1).optional(),
530
+ resources: z.array(ResourceRef).optional(),
531
+ tools: z.array(ToolRef).optional(),
532
+ model: z.string().min(1).optional(),
533
+ reasoningEffort: ReasoningEffort.optional(),
534
+ sandboxBackend: SandboxBackend.optional(),
535
+ metadata: z.record(z.string(), z.unknown()).optional()
536
+ });
537
+ var ReorderSessionTurnsRequest = z.object({
538
+ turnIds: z.array(z.string().uuid()).min(1)
539
+ });
540
+ var WorkspaceEnvironmentVariableName = z.string().regex(/^[A-Z][A-Z0-9_]*$/).max(128);
541
+ var WorkspaceEnvironmentVariableMetadata = z.object({
542
+ name: WorkspaceEnvironmentVariableName,
543
+ version: z.number().int().positive(),
544
+ createdAt: z.string(),
545
+ updatedAt: z.string()
546
+ });
547
+ var WorkspaceEnvironment = z.object({
548
+ id: z.string().uuid(),
549
+ accountId: z.string().uuid(),
550
+ workspaceId: z.string().uuid(),
551
+ name: z.string(),
552
+ description: z.string().nullable(),
553
+ variables: z.array(WorkspaceEnvironmentVariableMetadata),
554
+ createdAt: z.string(),
555
+ updatedAt: z.string()
556
+ });
557
+ var CreateWorkspaceEnvironmentRequest = z.object({
558
+ name: z.string().min(1).max(120),
559
+ description: z.string().max(2e3).optional(),
560
+ variables: z.array(z.object({
561
+ name: WorkspaceEnvironmentVariableName,
562
+ value: z.string().min(1).max(32768)
563
+ })).default([])
564
+ });
565
+ var UpdateWorkspaceEnvironmentRequest = z.object({
566
+ name: z.string().min(1).max(120).optional(),
567
+ description: z.string().max(2e3).nullable().optional()
568
+ });
569
+ var SetWorkspaceEnvironmentVariableRequest = z.object({
570
+ value: z.string().min(1).max(32768)
571
+ });
572
+ var ScheduledTaskStatus = z.enum(["active", "paused"]);
573
+ var ScheduledTaskRunStatus = z.enum(["queued", "dispatched", "failed"]);
574
+ var ScheduledTaskRunMode = z.enum(["new_session_per_run", "reusable_session"]);
575
+ var ScheduledTaskOverlapPolicy = z.enum(["allow_concurrent", "skip", "buffer_one"]);
576
+ var ScheduledTaskTriggerType = z.enum(["scheduled", "manual"]);
577
+ var ScheduledTaskScheduleSpec = z.discriminatedUnion("type", [
578
+ z.object({
579
+ type: z.literal("once"),
580
+ runAt: z.string().datetime({ offset: true }),
581
+ timeZone: z.string().min(1).default("UTC")
582
+ }),
583
+ z.object({
584
+ type: z.literal("interval"),
585
+ everySeconds: z.number().int().positive(),
586
+ startAt: z.string().datetime({ offset: true }).optional(),
587
+ endAt: z.string().datetime({ offset: true }).optional()
588
+ }),
589
+ z.object({
590
+ type: z.literal("calendar"),
591
+ timeZone: z.string().min(1).default("UTC"),
592
+ hour: z.number().int().min(0).max(23),
593
+ minute: z.number().int().min(0).max(59),
594
+ daysOfWeek: z.array(z.enum(["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"])).min(1).optional()
595
+ })
596
+ ]);
597
+ var ScheduledTaskAgentConfig = z.object({
598
+ prompt: z.string().min(1),
599
+ resources: z.array(ResourceRef).default([]),
600
+ tools: z.array(ToolRef).default([]),
601
+ metadata: z.record(z.string(), z.unknown()).default({}),
602
+ model: z.string().min(1).optional(),
603
+ reasoningEffort: ReasoningEffort.optional(),
604
+ sandboxBackend: SandboxBackend.optional(),
605
+ goal: GoalSpec.optional()
606
+ });
607
+ var ScheduledTask = z.object({
608
+ id: z.string().uuid(),
609
+ accountId: z.string().uuid(),
610
+ workspaceId: z.string().uuid(),
611
+ name: z.string(),
612
+ status: ScheduledTaskStatus,
613
+ schedule: ScheduledTaskScheduleSpec,
614
+ temporalScheduleId: z.string(),
615
+ runMode: ScheduledTaskRunMode,
616
+ overlapPolicy: ScheduledTaskOverlapPolicy,
617
+ agentConfig: ScheduledTaskAgentConfig,
618
+ reusableSessionId: z.string().uuid().nullable(),
619
+ environmentId: z.string().uuid().nullable(),
620
+ metadata: z.record(z.string(), z.unknown()),
621
+ createdAt: z.string(),
622
+ updatedAt: z.string()
623
+ });
624
+ var ScheduledTaskRun = z.object({
625
+ id: z.string().uuid(),
626
+ accountId: z.string().uuid(),
627
+ workspaceId: z.string().uuid(),
628
+ taskId: z.string().uuid(),
629
+ status: ScheduledTaskRunStatus,
630
+ triggerType: ScheduledTaskTriggerType,
631
+ scheduledAt: z.string().nullable(),
632
+ firedAt: z.string(),
633
+ sessionId: z.string().uuid().nullable(),
634
+ triggerEventId: z.string().uuid().nullable(),
635
+ error: z.string().nullable(),
636
+ createdAt: z.string(),
637
+ updatedAt: z.string()
638
+ });
639
+ var CreateScheduledTaskRequest = z.object({
640
+ name: z.string().min(1),
641
+ schedule: ScheduledTaskScheduleSpec,
642
+ runMode: ScheduledTaskRunMode.default("new_session_per_run"),
643
+ overlapPolicy: ScheduledTaskOverlapPolicy.default("allow_concurrent"),
644
+ agentConfig: ScheduledTaskAgentConfig,
645
+ status: ScheduledTaskStatus.default("active"),
646
+ environmentId: z.string().uuid().nullable().optional(),
647
+ metadata: z.record(z.string(), z.unknown()).default({})
648
+ });
649
+ var UpdateScheduledTaskRequest = z.object({
650
+ name: z.string().min(1).optional(),
651
+ schedule: ScheduledTaskScheduleSpec.optional(),
652
+ runMode: ScheduledTaskRunMode.optional(),
653
+ overlapPolicy: ScheduledTaskOverlapPolicy.optional(),
654
+ agentConfig: ScheduledTaskAgentConfig.optional(),
655
+ status: ScheduledTaskStatus.optional(),
656
+ environmentId: z.string().uuid().nullable().optional(),
657
+ metadata: z.record(z.string(), z.unknown()).optional()
658
+ });
659
+ var TriggerScheduledTaskRequest = z.object({
660
+ triggerId: z.string().min(1).max(128).optional()
661
+ });
662
+ var CapabilityPackConnectorAuthModel = z.enum([
663
+ "oauth2_authorization_code_pkce",
664
+ "oauth2_authorization_code",
665
+ "api_key",
666
+ "credential_ref"
667
+ ]);
668
+ var CapabilityPackConnector = z.object({
669
+ id: z.string().min(1),
670
+ name: z.string().min(1),
671
+ category: z.string().min(1),
672
+ authModel: CapabilityPackConnectorAuthModel,
673
+ providers: z.array(z.string().min(1)).default([]),
674
+ scopes: z.array(z.string().min(1)).default([]),
675
+ required: z.boolean().default(false),
676
+ metadata: z.record(z.string(), z.unknown()).default({})
677
+ });
678
+ var CapabilityPackKnowledge = z.object({
679
+ type: z.literal("document_base"),
680
+ id: z.string().min(1),
681
+ name: z.string().min(1),
682
+ description: z.string().nullable().default(null),
683
+ required: z.boolean().default(false)
684
+ });
685
+ var CapabilityPackScheduledTaskTemplate = z.object({
686
+ id: z.string().min(1),
687
+ name: z.string().min(1),
688
+ description: z.string().min(1),
689
+ defaultSchedule: ScheduledTaskScheduleSpec,
690
+ defaultRunMode: ScheduledTaskRunMode.default("new_session_per_run"),
691
+ defaultOverlapPolicy: ScheduledTaskOverlapPolicy.default("skip"),
692
+ // Optional default agent prompt so registered pack manifests can ship fully
693
+ // instantiable templates; built-in packs may instead build prompts in code.
694
+ prompt: z.string().min(1).optional()
695
+ });
696
+ var CapabilityPackSkillFile = z.object({
697
+ path: z.string().min(1).max(512).refine(isSafePackSkillRelativePath, {
698
+ message: "skill file path must be a safe relative POSIX path without '..' segments"
699
+ }),
700
+ content: z.string().max(256 * 1024)
701
+ });
702
+ var CapabilityPackSkill = z.object({
703
+ name: z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, {
704
+ message: "skill name must be a single path segment of letters, digits, '.', '_' or '-'"
705
+ }),
706
+ description: z.string().min(1).max(2048).optional(),
707
+ files: z.array(CapabilityPackSkillFile).min(1).max(64)
708
+ }).superRefine((skill, ctx) => {
709
+ const seen = /* @__PURE__ */ new Set();
710
+ skill.files.forEach((file, index) => {
711
+ if (seen.has(file.path)) {
712
+ ctx.addIssue({ code: "custom", message: `duplicate skill file path: ${file.path}`, path: ["files", index, "path"] });
713
+ }
714
+ seen.add(file.path);
715
+ });
716
+ if (!skill.files.some((file) => file.path === "SKILL.md")) {
717
+ ctx.addIssue({ code: "custom", message: "skill must include a top-level SKILL.md file", path: ["files"] });
718
+ }
719
+ });
720
+ function isSafePackSkillRelativePath(path) {
721
+ if (path.startsWith("/") || path.includes("\\")) {
722
+ return false;
723
+ }
724
+ return path.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
725
+ }
726
+ var CapabilityPack = z.object({
727
+ id: z.string().min(1),
728
+ name: z.string().min(1),
729
+ description: z.string().min(1),
730
+ role: z.string().min(1),
731
+ category: z.string().min(1),
732
+ version: z.string().min(1),
733
+ // Container image ref (digest-pinned recommended) the pack's sessions run
734
+ // in. At most one enabled pack per workspace may declare one; with none,
735
+ // sessions use the deployment-wide image settings.
736
+ sandboxImage: z.string().trim().min(1).max(512).optional(),
737
+ // Skills delivered into the sandbox skill index when the pack is enabled.
738
+ skills: z.array(CapabilityPackSkill).max(32).superRefine((skills, ctx) => {
739
+ const seen = /* @__PURE__ */ new Set();
740
+ skills.forEach((skill, index) => {
741
+ const key = skill.name.toLowerCase();
742
+ if (seen.has(key)) {
743
+ ctx.addIssue({ code: "custom", message: `duplicate pack skill name: ${skill.name}`, path: [index, "name"] });
744
+ }
745
+ seen.add(key);
746
+ });
747
+ }).default([]),
748
+ tools: z.array(ToolRef).default([]),
749
+ connectors: z.array(CapabilityPackConnector).default([]),
750
+ knowledge: z.array(CapabilityPackKnowledge).default([]),
751
+ scheduledTaskTemplates: z.array(CapabilityPackScheduledTaskTemplate).default([]),
752
+ environment: z.object({
753
+ description: z.string().min(1),
754
+ requiredVariables: z.array(WorkspaceEnvironmentVariableName).default([]),
755
+ required: z.boolean().default(false)
756
+ }).optional(),
757
+ metadata: z.record(z.string(), z.unknown()).default({})
758
+ });
759
+ var RegisterCapabilityPackRequest = CapabilityPack;
760
+ var WorkspaceRegisteredPack = z.object({
761
+ accountId: z.string().uuid(),
762
+ workspaceId: z.string().uuid(),
763
+ pack: CapabilityPack,
764
+ createdAt: z.string(),
765
+ updatedAt: z.string()
766
+ });
767
+ var PackInstallationStatus = z.enum(["active", "disabled"]);
768
+ var PackInstallation = z.object({
769
+ id: z.string().uuid(),
770
+ accountId: z.string().uuid(),
771
+ workspaceId: z.string().uuid(),
772
+ packId: z.string().min(1),
773
+ status: PackInstallationStatus,
774
+ metadata: z.record(z.string(), z.unknown()),
775
+ enabledAt: z.string(),
776
+ updatedAt: z.string()
777
+ });
778
+ var EnablePackRequest = z.object({
779
+ environmentId: z.string().uuid().optional(),
780
+ metadata: z.record(z.string(), z.unknown()).default({})
781
+ });
782
+ var SocialProvider = z.enum([
783
+ "x",
784
+ "linkedin",
785
+ "instagram",
786
+ "facebook",
787
+ "tiktok",
788
+ "youtube",
789
+ "custom"
790
+ ]);
791
+ var SocialConnectionStatus = z.enum(["connected", "needs_reauth", "disabled"]);
792
+ var SocialConnection = z.object({
793
+ id: z.string().uuid(),
794
+ accountId: z.string().uuid(),
795
+ workspaceId: z.string().uuid(),
796
+ provider: SocialProvider,
797
+ accountHandle: z.string().min(1),
798
+ accountName: z.string().nullable(),
799
+ externalAccountId: z.string().nullable(),
800
+ status: SocialConnectionStatus,
801
+ scopes: z.array(z.string()),
802
+ credentialRef: z.string().nullable(),
803
+ tokenMetadata: z.record(z.string(), z.unknown()),
804
+ metadata: z.record(z.string(), z.unknown()),
805
+ createdAt: z.string(),
806
+ updatedAt: z.string()
807
+ });
808
+ var CreateSocialConnectionRequest = z.object({
809
+ provider: SocialProvider,
810
+ accountHandle: z.string().min(1),
811
+ accountName: z.string().min(1).optional(),
812
+ externalAccountId: z.string().min(1).optional(),
813
+ status: SocialConnectionStatus.default("connected"),
814
+ scopes: z.array(z.string().min(1)).default([]),
815
+ credentialRef: z.string().min(1).optional(),
816
+ tokenMetadata: z.record(z.string(), z.unknown()).default({}),
817
+ metadata: z.record(z.string(), z.unknown()).default({})
818
+ });
819
+ var SocialPost = z.object({
820
+ id: z.string().uuid(),
821
+ accountId: z.string().uuid(),
822
+ workspaceId: z.string().uuid(),
823
+ connectionId: z.string().uuid(),
824
+ provider: SocialProvider,
825
+ externalPostId: z.string().nullable(),
826
+ url: z.string().url().nullable(),
827
+ authorHandle: z.string().nullable(),
828
+ text: z.string(),
829
+ publishedAt: z.string(),
830
+ metrics: z.record(z.string(), z.number()),
831
+ raw: z.record(z.string(), z.unknown()),
832
+ createdAt: z.string()
833
+ });
834
+ var CreateSocialPostRequest = z.object({
835
+ connectionId: z.string().uuid(),
836
+ externalPostId: z.string().min(1).optional(),
837
+ url: z.string().url().optional(),
838
+ authorHandle: z.string().min(1).optional(),
839
+ text: z.string().min(1),
840
+ publishedAt: z.string().datetime({ offset: true }),
841
+ metrics: z.record(z.string(), z.number()).default({}),
842
+ raw: z.record(z.string(), z.unknown()).default({})
843
+ });
844
+ var MarketingDailyAnalysisTaskRequest = z.object({
845
+ name: z.string().min(1).optional(),
846
+ connectionIds: z.array(z.string().uuid()).default([]),
847
+ documentBaseIds: z.array(z.string().uuid()).default([]),
848
+ timeZone: z.string().min(1).default("UTC"),
849
+ hour: z.number().int().min(0).max(23).default(9),
850
+ minute: z.number().int().min(0).max(59).default(0),
851
+ promptInstructions: z.string().min(1).optional(),
852
+ status: ScheduledTaskStatus.default("active"),
853
+ runMode: ScheduledTaskRunMode.default("new_session_per_run"),
854
+ overlapPolicy: ScheduledTaskOverlapPolicy.default("skip")
855
+ });
856
+ var CapabilityKind = z.enum(["pack", "mcp", "api", "skill", "plugin"]);
857
+ var CapabilitySource = z.enum(["built_in", "configured", "public_registry", "manual"]);
858
+ var CapabilityInstallationStatus = z.enum(["active", "disabled"]);
859
+ var CapabilityRuntime = z.object({
860
+ available: z.boolean().default(false),
861
+ mcpServerId: z.string().min(1).optional(),
862
+ transport: z.string().min(1).optional(),
863
+ notes: z.string().nullable().default(null)
864
+ });
865
+ var CapabilityCatalogItem = z.object({
866
+ id: z.string().min(1),
867
+ accountId: z.string().uuid().optional(),
868
+ workspaceId: z.string().uuid().optional(),
869
+ kind: CapabilityKind,
870
+ source: CapabilitySource,
871
+ name: z.string().min(1),
872
+ description: z.string().nullable().default(null),
873
+ category: z.string().min(1).default("custom"),
874
+ tags: z.array(z.string().min(1)).default([]),
875
+ homepageUrl: z.string().url().nullable().default(null),
876
+ endpointUrl: z.string().url().nullable().default(null),
877
+ installUrl: z.string().url().nullable().default(null),
878
+ authModel: z.string().min(1).nullable().default(null),
879
+ tools: z.array(ToolRef).default([]),
880
+ runtime: CapabilityRuntime.default({ available: false, notes: null }),
881
+ enabled: z.boolean().default(false),
882
+ enabledReason: z.string().nullable().default(null),
883
+ metadata: z.record(z.string(), z.unknown()).default({}),
884
+ createdAt: z.string().optional(),
885
+ updatedAt: z.string().optional()
886
+ });
887
+ var CapabilityInstallation = z.object({
888
+ id: z.string().uuid(),
889
+ accountId: z.string().uuid(),
890
+ workspaceId: z.string().uuid(),
891
+ capabilityId: z.string().min(1),
892
+ kind: CapabilityKind,
893
+ status: CapabilityInstallationStatus,
894
+ config: z.record(z.string(), z.unknown()),
895
+ metadata: z.record(z.string(), z.unknown()),
896
+ enabledAt: z.string(),
897
+ updatedAt: z.string()
898
+ });
899
+ var CreateCapabilityCatalogItemRequest = z.object({
900
+ id: z.string().min(1).optional(),
901
+ kind: CapabilityKind.exclude(["pack"]),
902
+ source: CapabilitySource.default("manual"),
903
+ name: z.string().min(1),
904
+ description: z.string().min(1).optional(),
905
+ category: z.string().min(1).default("custom"),
906
+ tags: z.array(z.string().min(1)).default([]),
907
+ homepageUrl: z.string().url().optional(),
908
+ endpointUrl: z.string().url().optional(),
909
+ installUrl: z.string().url().optional(),
910
+ authModel: z.string().min(1).optional(),
911
+ metadata: z.record(z.string(), z.unknown()).default({})
912
+ });
913
+ var EnableCapabilityRequest = z.object({
914
+ config: z.record(z.string(), z.unknown()).default({}),
915
+ metadata: z.record(z.string(), z.unknown()).default({}),
916
+ /**
917
+ * Credential headers for remote MCP capabilities (for example an
918
+ * Authorization bearer token). Values are encrypted at rest with the
919
+ * workspace-environments key, injected only into the runtime MCP client,
920
+ * and never returned by the API — responses expose header names only.
921
+ */
922
+ headers: z.record(z.string(), z.string()).default({}),
923
+ /**
924
+ * Initial environment attachment for kind=pack capabilities. Mirrors the
925
+ * dedicated POST /packs/:id/enable body: required to enable an
926
+ * environment.required pack through the unified capability-enable path,
927
+ * optional otherwise. Ignored by non-pack capabilities.
928
+ */
929
+ environmentId: z.string().uuid().optional()
930
+ });
931
+ var CapabilityCatalogResponse = z.object({
932
+ items: z.array(CapabilityCatalogItem),
933
+ installations: z.array(CapabilityInstallation)
934
+ });
935
+ var DiscoverMcpCapabilitiesResponse = z.object({
936
+ items: z.array(CapabilityCatalogItem),
937
+ source: z.literal("official_mcp_registry"),
938
+ sourceUrl: z.string().url()
939
+ });
940
+ var Session = z.object({
941
+ id: z.string().uuid(),
942
+ workspaceId: z.string().uuid(),
943
+ accountId: z.string().uuid(),
944
+ status: SessionStatus,
945
+ initialMessage: z.string(),
946
+ resources: z.array(ResourceRef),
947
+ tools: z.array(ToolRef),
948
+ metadata: z.record(z.string(), z.unknown()),
949
+ model: z.string(),
950
+ sandboxBackend: SandboxBackend,
951
+ environmentId: z.string().uuid().nullable(),
952
+ // Non-default first-party MCP token permissions (manager-style sessions);
953
+ // null means the fixed worker default set.
954
+ firstPartyMcpPermissions: z.array(Permission).nullable(),
955
+ // The manager session that spawned this one via session_create (set only
956
+ // when the creating grant carried a worker-signed sessionId claim); null for
957
+ // direct API creates and scheduled-task runs. When set, this session's
958
+ // terminal-for-now transitions wake the parent.
959
+ parentSessionId: z.string().uuid().nullable(),
960
+ // Workspace-scoped CREATE idempotency key the session was created under (the
961
+ // dedup target collapsing double-submit/retry races to one session); null
962
+ // when the create carried no key.
963
+ createIdempotencyKey: z.string().nullable(),
964
+ temporalWorkflowId: z.string().nullable(),
965
+ activeTurnId: z.string().uuid().nullable(),
966
+ // Actual input tokens of the last model call of the most recent turn; the
967
+ // pre-turn client-side context-compaction trigger reads it as its budget
968
+ // signal. Null until a turn with usage has completed.
969
+ lastInputTokens: z.number().int().nonnegative().nullable(),
970
+ lastSequence: z.number().int().nonnegative(),
971
+ createdAt: z.string(),
972
+ updatedAt: z.string()
973
+ });
974
+ var SessionEventType = z.enum([
975
+ "session.created",
976
+ "session.status.changed",
977
+ "session.requiresAction",
978
+ "session.context.compacted",
979
+ "session.context.cleared",
980
+ "user.message",
981
+ "user.interrupt",
982
+ "user.approvalDecision",
983
+ "turn.queued",
984
+ "turn.updated",
985
+ "turn.started",
986
+ "turn.completed",
987
+ "turn.failed",
988
+ "turn.cancelled",
989
+ "turn.preempted",
990
+ "agent.message.delta",
991
+ "agent.message.completed",
992
+ "agent.reasoning.delta",
993
+ "agent.toolCall.created",
994
+ "agent.toolCall.output",
995
+ "agent.updated",
996
+ "sandbox.operation.started",
997
+ "sandbox.operation.completed",
998
+ "sandbox.operation.failed",
999
+ "sandbox.command.output.delta",
1000
+ "artifact.created",
1001
+ "goal.set",
1002
+ "goal.updated",
1003
+ "goal.completed",
1004
+ "goal.paused",
1005
+ "goal.resumed",
1006
+ "goal.continuation"
1007
+ ]);
1008
+ var SessionEvent = z.object({
1009
+ id: z.string().uuid(),
1010
+ workspaceId: z.string().uuid(),
1011
+ sessionId: z.string().uuid(),
1012
+ sequence: z.number().int().positive(),
1013
+ type: SessionEventType,
1014
+ payload: z.unknown().default({}),
1015
+ occurredAt: z.string(),
1016
+ clientEventId: z.string().min(1).nullable().optional(),
1017
+ turnId: z.string().uuid().nullable().optional()
1018
+ });
1019
+ var CreateSessionRequest = z.object({
1020
+ initialMessage: z.string().min(1),
1021
+ resources: z.array(ResourceRef).default([]),
1022
+ tools: z.array(ToolRef).default([]),
1023
+ metadata: z.record(z.string(), z.unknown()).default({}),
1024
+ model: z.string().min(1).optional(),
1025
+ reasoningEffort: ReasoningEffort.optional(),
1026
+ sandboxBackend: SandboxBackend.optional(),
1027
+ // Workspace environment attachment is fixed at session creation; follow-up
1028
+ // user.message events cannot switch or add one.
1029
+ environmentId: z.string().uuid().optional(),
1030
+ goal: GoalSpec.optional(),
1031
+ clientEventId: z.string().min(1).optional(),
1032
+ // Workspace-scoped CREATE idempotency key: collapses concurrent/retried
1033
+ // create calls carrying the same key to a single session (partial unique
1034
+ // index on (workspace_id, create_idempotency_key)). Distinct from
1035
+ // clientEventId, whose uniqueness is per-session and so cannot dedup the
1036
+ // creation of a brand-new session. Absent means no create-dedup (each call
1037
+ // is an independent create).
1038
+ idempotencyKey: z.string().min(1).max(200).optional(),
1039
+ // Permissions the session's first-party MCP token should carry instead of
1040
+ // the fixed worker default — how an operator hands a manager-style session
1041
+ // the orchestration/environment/github tools. Capped at creation: every
1042
+ // requested permission must be held by the creating grant (no escalation).
1043
+ firstPartyMcpPermissions: z.array(Permission).optional()
1044
+ });
1045
+ var ClientSessionEvent = z.discriminatedUnion("type", [
1046
+ z.object({
1047
+ type: z.literal("user.message"),
1048
+ clientEventId: z.string().min(1).optional(),
1049
+ payload: z.object({
1050
+ text: z.string().min(1),
1051
+ resources: z.array(ResourceRef).default([]),
1052
+ tools: z.array(ToolRef).default([]),
1053
+ model: z.string().min(1).optional(),
1054
+ reasoningEffort: ReasoningEffort.optional()
1055
+ })
1056
+ }),
1057
+ z.object({
1058
+ type: z.literal("user.interrupt"),
1059
+ clientEventId: z.string().min(1).optional(),
1060
+ payload: z.object({ reason: z.string().optional() }).default({})
1061
+ }),
1062
+ z.object({
1063
+ type: z.literal("user.approvalDecision"),
1064
+ clientEventId: z.string().min(1).optional(),
1065
+ payload: z.object({
1066
+ approvalId: z.string().min(1),
1067
+ decision: z.enum(["approve", "reject"]),
1068
+ message: z.string().optional()
1069
+ })
1070
+ })
1071
+ ]);
1072
+ var SessionBusMessage = z.object({
1073
+ workspaceId: z.string().uuid(),
1074
+ sessionId: z.string().uuid(),
1075
+ events: z.array(SessionEvent).min(1)
1076
+ });
1077
+ var GitHubAppManifestCreate = z.object({
1078
+ appName: z.string().optional(),
1079
+ organization: z.string().optional(),
1080
+ public: z.boolean().default(false),
1081
+ includeCiPermissions: z.boolean().default(true)
1082
+ });
1083
+ var GitHubRepository = z.object({
1084
+ id: z.number().int(),
1085
+ installationId: z.number().int(),
1086
+ fullName: z.string(),
1087
+ name: z.string(),
1088
+ private: z.boolean(),
1089
+ htmlUrl: z.string(),
1090
+ cloneUrl: z.string(),
1091
+ defaultBranch: z.string(),
1092
+ accountLogin: z.string(),
1093
+ accountType: z.string().nullable()
1094
+ });
1095
+ var ClientAuthConfig = z.discriminatedUnion("mode", [
1096
+ z.object({
1097
+ mode: z.literal("none")
1098
+ }),
1099
+ z.object({
1100
+ mode: z.literal("deploymentKey"),
1101
+ headerName: z.literal("x-opengeni-access-key")
1102
+ }),
1103
+ z.object({
1104
+ mode: z.literal("configuredToken"),
1105
+ headerName: z.literal("authorization"),
1106
+ scheme: z.literal("bearer")
1107
+ }),
1108
+ z.object({
1109
+ mode: z.literal("managedSession"),
1110
+ session: z.literal("cookie")
1111
+ })
1112
+ ]);
1113
+ var ClientConfig = z.object({
1114
+ deploymentRevision: z.string(),
1115
+ defaultModel: z.string(),
1116
+ allowedModels: z.array(z.string()).min(1),
1117
+ defaultReasoningEffort: ReasoningEffort,
1118
+ allowedReasoningEfforts: z.array(ReasoningEffort).min(1),
1119
+ mcpServers: z.array(z.object({
1120
+ id: z.string(),
1121
+ name: z.string()
1122
+ })).default([]),
1123
+ fileUploads: z.object({
1124
+ enabled: z.boolean(),
1125
+ maxSizeBytes: z.number().int().positive()
1126
+ }),
1127
+ productAccessMode: ProductAccessMode,
1128
+ auth: ClientAuthConfig.default({ mode: "none" })
1129
+ });
1130
+ function base64UrlEncode(value) {
1131
+ return Buffer.from(value, "utf8").toString("base64url");
1132
+ }
1133
+ function base64UrlDecode(value) {
1134
+ return Buffer.from(value, "base64url").toString("utf8");
1135
+ }
1136
+ async function hmacSha256Base64Url(secret, value) {
1137
+ const key = await crypto.subtle.importKey(
1138
+ "raw",
1139
+ new TextEncoder().encode(secret),
1140
+ { name: "HMAC", hash: "SHA-256" },
1141
+ false,
1142
+ ["sign"]
1143
+ );
1144
+ const signature = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(value));
1145
+ return Buffer.from(signature).toString("base64url");
1146
+ }
1147
+ function constantTimeEqual(actual, expected) {
1148
+ const actualBytes = new TextEncoder().encode(actual);
1149
+ const expectedBytes = new TextEncoder().encode(expected);
1150
+ if (actualBytes.length !== expectedBytes.length) {
1151
+ return false;
1152
+ }
1153
+ let diff = 0;
1154
+ for (let index = 0; index < actualBytes.length; index += 1) {
1155
+ diff |= actualBytes[index] ^ expectedBytes[index];
1156
+ }
1157
+ return diff === 0;
1158
+ }
1159
+ export {
1160
+ AccessContext,
1161
+ AccessGrant,
1162
+ AccountGrant,
1163
+ AccountRole,
1164
+ AddDocumentRequest,
1165
+ ApiKey,
1166
+ BillingBalance,
1167
+ BillingMode,
1168
+ CLEARED_RUN_STATE_BLOB,
1169
+ CLEARED_RUN_STATE_MARKER,
1170
+ CapabilityCatalogItem,
1171
+ CapabilityCatalogResponse,
1172
+ CapabilityInstallation,
1173
+ CapabilityInstallationStatus,
1174
+ CapabilityKind,
1175
+ CapabilityPack,
1176
+ CapabilityPackConnector,
1177
+ CapabilityPackConnectorAuthModel,
1178
+ CapabilityPackKnowledge,
1179
+ CapabilityPackScheduledTaskTemplate,
1180
+ CapabilityPackSkill,
1181
+ CapabilityPackSkillFile,
1182
+ CapabilityRuntime,
1183
+ CapabilitySource,
1184
+ ClearSessionContextRequest,
1185
+ ClientAuthConfig,
1186
+ ClientConfig,
1187
+ ClientSessionEvent,
1188
+ CompactSessionContextRequest,
1189
+ CompactSessionContextResult,
1190
+ CompleteFileUploadResponse,
1191
+ CreateApiKeyRequest,
1192
+ CreateApiKeyResponse,
1193
+ CreateCapabilityCatalogItemRequest,
1194
+ CreateCheckoutRequest,
1195
+ CreateCheckoutResponse,
1196
+ CreateDocumentBaseRequest,
1197
+ CreateFileUploadRequest,
1198
+ CreateFileUploadResponse,
1199
+ CreateScheduledTaskRequest,
1200
+ CreateSessionRequest,
1201
+ CreateSocialConnectionRequest,
1202
+ CreateSocialPostRequest,
1203
+ CreateWorkspaceEnvironmentRequest,
1204
+ CreateWorkspaceRequest,
1205
+ DelegatedAccessTokenPayload,
1206
+ DiscoverMcpCapabilitiesResponse,
1207
+ Document,
1208
+ DocumentBase,
1209
+ DocumentSearchRequest,
1210
+ DocumentSearchResult,
1211
+ DocumentStatus,
1212
+ EnableCapabilityRequest,
1213
+ EnablePackRequest,
1214
+ EntitlementValue,
1215
+ Entitlements,
1216
+ EntitlementsMode,
1217
+ ErrorCode,
1218
+ ErrorEnvelope,
1219
+ FileAsset,
1220
+ FileDownloadUrlResponse,
1221
+ FileResourceRef,
1222
+ FileStatus,
1223
+ FileUploadStatus,
1224
+ GitHubAppManifestCreate,
1225
+ GitHubRepository,
1226
+ GoalSpec,
1227
+ LimitAction,
1228
+ LimitDecision,
1229
+ ManagedAccount,
1230
+ MarketingDailyAnalysisTaskRequest,
1231
+ PackInstallation,
1232
+ PackInstallationStatus,
1233
+ PageInfo,
1234
+ Permission,
1235
+ ProductAccessMode,
1236
+ ReasoningEffort,
1237
+ RegisterCapabilityPackRequest,
1238
+ ReorderSessionTurnsRequest,
1239
+ RepositoryResourceRef,
1240
+ ResourceRef,
1241
+ ResourceRefConflictError,
1242
+ SandboxBackend,
1243
+ ScheduledTask,
1244
+ ScheduledTaskAgentConfig,
1245
+ ScheduledTaskOverlapPolicy,
1246
+ ScheduledTaskRun,
1247
+ ScheduledTaskRunMode,
1248
+ ScheduledTaskRunStatus,
1249
+ ScheduledTaskScheduleSpec,
1250
+ ScheduledTaskStatus,
1251
+ ScheduledTaskTriggerType,
1252
+ Session,
1253
+ SessionBusMessage,
1254
+ SessionEvent,
1255
+ SessionEventType,
1256
+ SessionGoal,
1257
+ SessionGoalCreatedBy,
1258
+ SessionGoalPausedReason,
1259
+ SessionGoalStatus,
1260
+ SessionStatus,
1261
+ SessionTurn,
1262
+ SessionTurnSource,
1263
+ SessionTurnStatus,
1264
+ SetWorkspaceEnvironmentVariableRequest,
1265
+ SocialConnection,
1266
+ SocialConnectionStatus,
1267
+ SocialPost,
1268
+ SocialProvider,
1269
+ StaticUsageLimits,
1270
+ ToolRef,
1271
+ TriggerScheduledTaskRequest,
1272
+ UpdateScheduledTaskRequest,
1273
+ UpdateSessionGoalRequest,
1274
+ UpdateSessionTurnRequest,
1275
+ UpdateWorkspaceEnvironmentRequest,
1276
+ UpdateWorkspaceRequest,
1277
+ UsageEvent,
1278
+ UsageEventType,
1279
+ UsageLimitsMode,
1280
+ Workspace,
1281
+ WorkspaceEnvironment,
1282
+ WorkspaceEnvironmentVariableMetadata,
1283
+ WorkspaceEnvironmentVariableName,
1284
+ WorkspaceRegisteredPack,
1285
+ isClearedRunStateBlob,
1286
+ mergeResourceRefs,
1287
+ mergeToolRefs,
1288
+ paginated,
1289
+ reasoningEffortForMetadata,
1290
+ resourceIdentityKey,
1291
+ signDelegatedAccessToken,
1292
+ stableJson,
1293
+ verifyDelegatedAccessToken
1294
+ };
1295
+ //# sourceMappingURL=index.js.map