@vm0/runner 3.3.2 → 3.4.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 (2) hide show
  1. package/index.js +1047 -882
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -15,7 +15,8 @@ var SANDBOX_DEFAULTS = {
15
15
  max_concurrent: 1,
16
16
  vcpu: 2,
17
17
  memory_mb: 2048,
18
- poll_interval_ms: 5e3
18
+ poll_interval_ms: 3e4
19
+ // 30s fallback polling (push is primary)
19
20
  };
20
21
  var PROXY_DEFAULTS = {
21
22
  port: 8080
@@ -186,6 +187,89 @@ async function completeJob(apiUrl, context, exitCode, error) {
186
187
  }
187
188
  return response.json();
188
189
  }
190
+ async function getRealtimeToken(server, group) {
191
+ const headers = getAuthHeaders(server.token);
192
+ const response = await fetch(`${server.url}/api/runners/realtime/token`, {
193
+ method: "POST",
194
+ headers,
195
+ body: JSON.stringify({ group })
196
+ });
197
+ if (!response.ok) {
198
+ const errorData = await response.json();
199
+ throw new Error(
200
+ `Failed to get realtime token: ${errorData.error?.message || response.statusText}`
201
+ );
202
+ }
203
+ return response.json();
204
+ }
205
+
206
+ // src/lib/realtime/subscription.ts
207
+ import { z as z2 } from "zod";
208
+
209
+ // src/lib/realtime/client.ts
210
+ import Ably from "ably";
211
+ function createRealtimeClient(getToken) {
212
+ return new Ably.Realtime({
213
+ authCallback: (_tokenParams, callback) => {
214
+ getToken().then((tokenRequest) => {
215
+ callback(null, tokenRequest);
216
+ }).catch((error) => {
217
+ const errorInfo = {
218
+ name: "AuthError",
219
+ message: error instanceof Error ? error.message : "Token fetch failed",
220
+ code: 40100,
221
+ statusCode: 401
222
+ };
223
+ callback(errorInfo, null);
224
+ });
225
+ }
226
+ });
227
+ }
228
+ function getRunnerGroupChannelName(group) {
229
+ return `runner-group:${group}`;
230
+ }
231
+
232
+ // src/lib/realtime/subscription.ts
233
+ var JobNotificationSchema = z2.object({
234
+ runId: z2.string()
235
+ });
236
+ async function subscribeToJobs(server, group, onJob, onConnectionChange) {
237
+ const ablyClient = createRealtimeClient(async () => {
238
+ return getRealtimeToken(server, group);
239
+ });
240
+ const channelName = getRunnerGroupChannelName(group);
241
+ const channel = ablyClient.channels.get(channelName);
242
+ if (onConnectionChange) {
243
+ ablyClient.connection.on((stateChange) => {
244
+ onConnectionChange(stateChange.current, stateChange.reason?.message);
245
+ });
246
+ }
247
+ ablyClient.connection.on("failed", (stateChange) => {
248
+ console.error(
249
+ `Ably connection failed: ${stateChange.reason?.message || "Unknown error"}`
250
+ );
251
+ });
252
+ function handleMessage(message) {
253
+ if (message.name === "job") {
254
+ const result = JobNotificationSchema.safeParse(message.data);
255
+ if (result.success) {
256
+ onJob(result.data);
257
+ } else {
258
+ console.error(`Invalid job notification:`, result.error.issues);
259
+ }
260
+ }
261
+ }
262
+ await channel.subscribe(handleMessage);
263
+ console.log(`Subscribed to job notifications on ${channelName}`);
264
+ return {
265
+ cleanup: () => {
266
+ channel.unsubscribe();
267
+ ablyClient.close();
268
+ console.log(`Unsubscribed from ${channelName}`);
269
+ },
270
+ client: ablyClient
271
+ };
272
+ }
189
273
 
190
274
  // src/lib/executor.ts
191
275
  import path4 from "path";
@@ -1622,7 +1706,7 @@ var VsockClient = class {
1622
1706
  };
1623
1707
 
1624
1708
  // ../../packages/core/src/contracts/base.ts
1625
- import { z as z3 } from "zod";
1709
+ import { z as z4 } from "zod";
1626
1710
 
1627
1711
  // ../../node_modules/.pnpm/@ts-rest+core@3.53.0-rc.1_@types+node@24.3.0/node_modules/@ts-rest/core/index.esm.mjs
1628
1712
  var util;
@@ -5225,7 +5309,7 @@ var coerce = {
5225
5309
  date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
5226
5310
  };
5227
5311
  var NEVER = INVALID;
5228
- var z2 = /* @__PURE__ */ Object.freeze({
5312
+ var z3 = /* @__PURE__ */ Object.freeze({
5229
5313
  __proto__: null,
5230
5314
  defaultErrorMap: errorMap,
5231
5315
  setErrorMap,
@@ -5355,29 +5439,29 @@ var zodMerge = (objectA, objectB) => {
5355
5439
  }
5356
5440
  return Object.assign({}, objectA, objectB);
5357
5441
  };
5358
- var ZodErrorSchema = z2.object({
5359
- name: z2.literal("ZodError"),
5360
- issues: z2.array(z2.object({
5361
- path: z2.array(z2.union([z2.string(), z2.number()])),
5362
- message: z2.string().optional(),
5363
- code: z2.nativeEnum(z2.ZodIssueCode)
5364
- }).catchall(z2.any()))
5365
- });
5366
- var RequestValidationErrorSchema = z2.object({
5367
- message: z2.literal("Request validation failed"),
5442
+ var ZodErrorSchema = z3.object({
5443
+ name: z3.literal("ZodError"),
5444
+ issues: z3.array(z3.object({
5445
+ path: z3.array(z3.union([z3.string(), z3.number()])),
5446
+ message: z3.string().optional(),
5447
+ code: z3.nativeEnum(z3.ZodIssueCode)
5448
+ }).catchall(z3.any()))
5449
+ });
5450
+ var RequestValidationErrorSchema = z3.object({
5451
+ message: z3.literal("Request validation failed"),
5368
5452
  pathParameterErrors: ZodErrorSchema.nullable(),
5369
5453
  headerErrors: ZodErrorSchema.nullable(),
5370
5454
  queryParameterErrors: ZodErrorSchema.nullable(),
5371
5455
  bodyErrors: ZodErrorSchema.nullable()
5372
5456
  });
5373
- var RequestValidationErrorSchemaWithoutMessage = z2.object({
5457
+ var RequestValidationErrorSchemaWithoutMessage = z3.object({
5374
5458
  // No message, express never had this implemented
5375
5459
  pathParameterErrors: ZodErrorSchema.nullable(),
5376
5460
  headerErrors: ZodErrorSchema.nullable(),
5377
5461
  queryParameterErrors: ZodErrorSchema.nullable(),
5378
5462
  bodyErrors: ZodErrorSchema.nullable()
5379
5463
  });
5380
- var RequestValidationErrorSchemaForNest = z2.object({
5464
+ var RequestValidationErrorSchemaForNest = z3.object({
5381
5465
  paramsResult: ZodErrorSchema.nullable(),
5382
5466
  headersResult: ZodErrorSchema.nullable(),
5383
5467
  queryResult: ZodErrorSchema.nullable(),
@@ -5451,61 +5535,61 @@ var initContract = () => {
5451
5535
  };
5452
5536
 
5453
5537
  // ../../packages/core/src/contracts/base.ts
5454
- var authHeadersSchema = z3.object({
5455
- authorization: z3.string().optional()
5538
+ var authHeadersSchema = z4.object({
5539
+ authorization: z4.string().optional()
5456
5540
  });
5457
5541
 
5458
5542
  // ../../packages/core/src/contracts/errors.ts
5459
- import { z as z4 } from "zod";
5460
- var apiErrorSchema = z4.object({
5461
- error: z4.object({
5462
- message: z4.string(),
5463
- code: z4.string()
5543
+ import { z as z5 } from "zod";
5544
+ var apiErrorSchema = z5.object({
5545
+ error: z5.object({
5546
+ message: z5.string(),
5547
+ code: z5.string()
5464
5548
  })
5465
5549
  });
5466
5550
 
5467
5551
  // ../../packages/core/src/contracts/composes.ts
5468
- import { z as z6 } from "zod";
5552
+ import { z as z7 } from "zod";
5469
5553
 
5470
5554
  // ../../packages/core/src/contracts/runners.ts
5471
- import { z as z5 } from "zod";
5555
+ import { z as z6 } from "zod";
5472
5556
  var c = initContract();
5473
- var firewallRuleSchema = z5.object({
5474
- domain: z5.string().optional(),
5475
- ip: z5.string().optional(),
5557
+ var firewallRuleSchema = z6.object({
5558
+ domain: z6.string().optional(),
5559
+ ip: z6.string().optional(),
5476
5560
  /** Terminal rule - value is the action (ALLOW or DENY) */
5477
- final: z5.enum(["ALLOW", "DENY"]).optional(),
5561
+ final: z6.enum(["ALLOW", "DENY"]).optional(),
5478
5562
  /** Action for domain/ip rules */
5479
- action: z5.enum(["ALLOW", "DENY"]).optional()
5563
+ action: z6.enum(["ALLOW", "DENY"]).optional()
5480
5564
  });
5481
- var experimentalFirewallSchema = z5.object({
5482
- enabled: z5.boolean(),
5483
- rules: z5.array(firewallRuleSchema).optional(),
5484
- experimental_mitm: z5.boolean().optional(),
5485
- experimental_seal_secrets: z5.boolean().optional()
5565
+ var experimentalFirewallSchema = z6.object({
5566
+ enabled: z6.boolean(),
5567
+ rules: z6.array(firewallRuleSchema).optional(),
5568
+ experimental_mitm: z6.boolean().optional(),
5569
+ experimental_seal_secrets: z6.boolean().optional()
5486
5570
  });
5487
- var runnerGroupSchema = z5.string().regex(
5571
+ var runnerGroupSchema = z6.string().regex(
5488
5572
  /^[a-z0-9-]+\/[a-z0-9-]+$/,
5489
5573
  "Runner group must be in scope/name format (e.g., acme/production)"
5490
5574
  );
5491
- var jobSchema = z5.object({
5492
- runId: z5.string().uuid(),
5493
- prompt: z5.string(),
5494
- agentComposeVersionId: z5.string(),
5495
- vars: z5.record(z5.string(), z5.string()).nullable(),
5496
- secretNames: z5.array(z5.string()).nullable(),
5497
- checkpointId: z5.string().uuid().nullable()
5575
+ var jobSchema = z6.object({
5576
+ runId: z6.string().uuid(),
5577
+ prompt: z6.string(),
5578
+ agentComposeVersionId: z6.string(),
5579
+ vars: z6.record(z6.string(), z6.string()).nullable(),
5580
+ secretNames: z6.array(z6.string()).nullable(),
5581
+ checkpointId: z6.string().uuid().nullable()
5498
5582
  });
5499
5583
  var runnersPollContract = c.router({
5500
5584
  poll: {
5501
5585
  method: "POST",
5502
5586
  path: "/api/runners/poll",
5503
5587
  headers: authHeadersSchema,
5504
- body: z5.object({
5588
+ body: z6.object({
5505
5589
  group: runnerGroupSchema
5506
5590
  }),
5507
5591
  responses: {
5508
- 200: z5.object({
5592
+ 200: z6.object({
5509
5593
  job: jobSchema.nullable()
5510
5594
  }),
5511
5595
  400: apiErrorSchema,
@@ -5515,65 +5599,65 @@ var runnersPollContract = c.router({
5515
5599
  summary: "Poll for pending jobs (long-polling with 30s timeout)"
5516
5600
  }
5517
5601
  });
5518
- var storageEntrySchema = z5.object({
5519
- mountPath: z5.string(),
5520
- archiveUrl: z5.string().nullable()
5602
+ var storageEntrySchema = z6.object({
5603
+ mountPath: z6.string(),
5604
+ archiveUrl: z6.string().nullable()
5521
5605
  });
5522
- var artifactEntrySchema = z5.object({
5523
- mountPath: z5.string(),
5524
- archiveUrl: z5.string().nullable(),
5525
- vasStorageName: z5.string(),
5526
- vasVersionId: z5.string()
5606
+ var artifactEntrySchema = z6.object({
5607
+ mountPath: z6.string(),
5608
+ archiveUrl: z6.string().nullable(),
5609
+ vasStorageName: z6.string(),
5610
+ vasVersionId: z6.string()
5527
5611
  });
5528
- var storageManifestSchema = z5.object({
5529
- storages: z5.array(storageEntrySchema),
5612
+ var storageManifestSchema = z6.object({
5613
+ storages: z6.array(storageEntrySchema),
5530
5614
  artifact: artifactEntrySchema.nullable()
5531
5615
  });
5532
- var resumeSessionSchema = z5.object({
5533
- sessionId: z5.string(),
5534
- sessionHistory: z5.string()
5616
+ var resumeSessionSchema = z6.object({
5617
+ sessionId: z6.string(),
5618
+ sessionHistory: z6.string()
5535
5619
  });
5536
- var storedExecutionContextSchema = z5.object({
5537
- workingDir: z5.string(),
5620
+ var storedExecutionContextSchema = z6.object({
5621
+ workingDir: z6.string(),
5538
5622
  storageManifest: storageManifestSchema.nullable(),
5539
- environment: z5.record(z5.string(), z5.string()).nullable(),
5623
+ environment: z6.record(z6.string(), z6.string()).nullable(),
5540
5624
  resumeSession: resumeSessionSchema.nullable(),
5541
- encryptedSecrets: z5.string().nullable(),
5625
+ encryptedSecrets: z6.string().nullable(),
5542
5626
  // AES-256-GCM encrypted secrets
5543
- cliAgentType: z5.string(),
5627
+ cliAgentType: z6.string(),
5544
5628
  experimentalFirewall: experimentalFirewallSchema.optional(),
5545
5629
  // Debug flag to force real Claude in mock environments (internal use only)
5546
- debugNoMockClaude: z5.boolean().optional()
5547
- });
5548
- var executionContextSchema = z5.object({
5549
- runId: z5.string().uuid(),
5550
- prompt: z5.string(),
5551
- agentComposeVersionId: z5.string(),
5552
- vars: z5.record(z5.string(), z5.string()).nullable(),
5553
- secretNames: z5.array(z5.string()).nullable(),
5554
- checkpointId: z5.string().uuid().nullable(),
5555
- sandboxToken: z5.string(),
5630
+ debugNoMockClaude: z6.boolean().optional()
5631
+ });
5632
+ var executionContextSchema = z6.object({
5633
+ runId: z6.string().uuid(),
5634
+ prompt: z6.string(),
5635
+ agentComposeVersionId: z6.string(),
5636
+ vars: z6.record(z6.string(), z6.string()).nullable(),
5637
+ secretNames: z6.array(z6.string()).nullable(),
5638
+ checkpointId: z6.string().uuid().nullable(),
5639
+ sandboxToken: z6.string(),
5556
5640
  // New fields for E2B parity:
5557
- workingDir: z5.string(),
5641
+ workingDir: z6.string(),
5558
5642
  storageManifest: storageManifestSchema.nullable(),
5559
- environment: z5.record(z5.string(), z5.string()).nullable(),
5643
+ environment: z6.record(z6.string(), z6.string()).nullable(),
5560
5644
  resumeSession: resumeSessionSchema.nullable(),
5561
- secretValues: z5.array(z5.string()).nullable(),
5562
- cliAgentType: z5.string(),
5645
+ secretValues: z6.array(z6.string()).nullable(),
5646
+ cliAgentType: z6.string(),
5563
5647
  // Experimental firewall configuration
5564
5648
  experimentalFirewall: experimentalFirewallSchema.optional(),
5565
5649
  // Debug flag to force real Claude in mock environments (internal use only)
5566
- debugNoMockClaude: z5.boolean().optional()
5650
+ debugNoMockClaude: z6.boolean().optional()
5567
5651
  });
5568
5652
  var runnersJobClaimContract = c.router({
5569
5653
  claim: {
5570
5654
  method: "POST",
5571
5655
  path: "/api/runners/jobs/:id/claim",
5572
5656
  headers: authHeadersSchema,
5573
- pathParams: z5.object({
5574
- id: z5.string().uuid()
5657
+ pathParams: z6.object({
5658
+ id: z6.string().uuid()
5575
5659
  }),
5576
- body: z5.object({}),
5660
+ body: z6.object({}),
5577
5661
  responses: {
5578
5662
  200: executionContextSchema,
5579
5663
  400: apiErrorSchema,
@@ -5591,75 +5675,75 @@ var runnersJobClaimContract = c.router({
5591
5675
 
5592
5676
  // ../../packages/core/src/contracts/composes.ts
5593
5677
  var c2 = initContract();
5594
- var composeVersionQuerySchema = z6.preprocess(
5678
+ var composeVersionQuerySchema = z7.preprocess(
5595
5679
  (val) => val === void 0 || val === null ? void 0 : String(val),
5596
- z6.string().min(1, "Missing version query parameter").regex(
5680
+ z7.string().min(1, "Missing version query parameter").regex(
5597
5681
  /^[a-f0-9]{8,64}$|^latest$/i,
5598
5682
  "Version must be 8-64 hex characters or 'latest'"
5599
5683
  )
5600
5684
  );
5601
- var agentNameSchema = z6.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
5685
+ var agentNameSchema = z7.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
5602
5686
  /^[a-zA-Z0-9][a-zA-Z0-9-]{1,62}[a-zA-Z0-9]$/,
5603
5687
  "Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
5604
5688
  );
5605
- var volumeConfigSchema = z6.object({
5606
- name: z6.string().min(1, "Volume name is required"),
5607
- version: z6.string().min(1, "Volume version is required")
5689
+ var volumeConfigSchema = z7.object({
5690
+ name: z7.string().min(1, "Volume name is required"),
5691
+ version: z7.string().min(1, "Volume version is required")
5608
5692
  });
5609
5693
  var SUPPORTED_APPS = ["github"];
5610
5694
  var SUPPORTED_APP_TAGS = ["latest", "dev"];
5611
5695
  var APP_NAME_REGEX = /^[a-z0-9-]+$/;
5612
- var appStringSchema = z6.string().superRefine((val, ctx) => {
5696
+ var appStringSchema = z7.string().superRefine((val, ctx) => {
5613
5697
  const [appName, tag] = val.split(":");
5614
5698
  if (!appName || !APP_NAME_REGEX.test(appName)) {
5615
5699
  ctx.addIssue({
5616
- code: z6.ZodIssueCode.custom,
5700
+ code: z7.ZodIssueCode.custom,
5617
5701
  message: "App name must contain only lowercase letters, numbers, and hyphens"
5618
5702
  });
5619
5703
  return;
5620
5704
  }
5621
5705
  if (!SUPPORTED_APPS.includes(appName)) {
5622
5706
  ctx.addIssue({
5623
- code: z6.ZodIssueCode.custom,
5707
+ code: z7.ZodIssueCode.custom,
5624
5708
  message: `Invalid app: "${appName}". Supported apps: ${SUPPORTED_APPS.join(", ")}`
5625
5709
  });
5626
5710
  return;
5627
5711
  }
5628
5712
  if (tag !== void 0 && !SUPPORTED_APP_TAGS.includes(tag)) {
5629
5713
  ctx.addIssue({
5630
- code: z6.ZodIssueCode.custom,
5714
+ code: z7.ZodIssueCode.custom,
5631
5715
  message: `Invalid app tag: "${tag}". Supported tags: ${SUPPORTED_APP_TAGS.join(", ")}`
5632
5716
  });
5633
5717
  }
5634
5718
  });
5635
- var agentDefinitionSchema = z6.object({
5636
- description: z6.string().optional(),
5637
- framework: z6.string().min(1, "Framework is required"),
5719
+ var agentDefinitionSchema = z7.object({
5720
+ description: z7.string().optional(),
5721
+ framework: z7.string().min(1, "Framework is required"),
5638
5722
  /**
5639
5723
  * Array of pre-installed apps/tools for the agent environment.
5640
5724
  * Format: "app" or "app:tag" (e.g., "github", "github:dev", "github:latest")
5641
5725
  * Default tag is "latest" if not specified.
5642
5726
  * Currently supported apps: "github" (includes GitHub CLI)
5643
5727
  */
5644
- apps: z6.array(appStringSchema).optional(),
5645
- volumes: z6.array(z6.string()).optional(),
5646
- environment: z6.record(z6.string(), z6.string()).optional(),
5728
+ apps: z7.array(appStringSchema).optional(),
5729
+ volumes: z7.array(z7.string()).optional(),
5730
+ environment: z7.record(z7.string(), z7.string()).optional(),
5647
5731
  /**
5648
5732
  * Path to instructions file (e.g., AGENTS.md).
5649
5733
  * Auto-uploaded as volume and mounted at /home/user/.claude/CLAUDE.md
5650
5734
  */
5651
- instructions: z6.string().min(1, "Instructions path cannot be empty").optional(),
5735
+ instructions: z7.string().min(1, "Instructions path cannot be empty").optional(),
5652
5736
  /**
5653
5737
  * Array of GitHub tree URLs for agent skills.
5654
5738
  * Each skill is auto-downloaded and mounted at /home/user/.claude/skills/{skillName}/
5655
5739
  */
5656
- skills: z6.array(z6.string()).optional(),
5740
+ skills: z7.array(z7.string()).optional(),
5657
5741
  /**
5658
5742
  * Route this agent to a self-hosted runner instead of E2B.
5659
5743
  * When specified, runs will be queued for the specified runner group.
5660
5744
  */
5661
- experimental_runner: z6.object({
5662
- group: z6.string().regex(
5745
+ experimental_runner: z7.object({
5746
+ group: z7.string().regex(
5663
5747
  /^[a-z0-9-]+\/[a-z0-9-]+$/,
5664
5748
  "Runner group must be in scope/name format (e.g., acme/production)"
5665
5749
  )
@@ -5674,32 +5758,32 @@ var agentDefinitionSchema = z6.object({
5674
5758
  * @deprecated Server-resolved field. User input is ignored.
5675
5759
  * @internal
5676
5760
  */
5677
- image: z6.string().optional(),
5761
+ image: z7.string().optional(),
5678
5762
  /**
5679
5763
  * @deprecated Server-resolved field. User input is ignored.
5680
5764
  * @internal
5681
5765
  */
5682
- working_dir: z6.string().optional()
5766
+ working_dir: z7.string().optional()
5683
5767
  });
5684
- var agentComposeContentSchema = z6.object({
5685
- version: z6.string().min(1, "Version is required"),
5686
- agents: z6.record(z6.string(), agentDefinitionSchema),
5687
- volumes: z6.record(z6.string(), volumeConfigSchema).optional()
5768
+ var agentComposeContentSchema = z7.object({
5769
+ version: z7.string().min(1, "Version is required"),
5770
+ agents: z7.record(z7.string(), agentDefinitionSchema),
5771
+ volumes: z7.record(z7.string(), volumeConfigSchema).optional()
5688
5772
  });
5689
- var composeResponseSchema = z6.object({
5690
- id: z6.string(),
5691
- name: z6.string(),
5692
- headVersionId: z6.string().nullable(),
5773
+ var composeResponseSchema = z7.object({
5774
+ id: z7.string(),
5775
+ name: z7.string(),
5776
+ headVersionId: z7.string().nullable(),
5693
5777
  content: agentComposeContentSchema.nullable(),
5694
- createdAt: z6.string(),
5695
- updatedAt: z6.string()
5778
+ createdAt: z7.string(),
5779
+ updatedAt: z7.string()
5696
5780
  });
5697
- var createComposeResponseSchema = z6.object({
5698
- composeId: z6.string(),
5699
- name: z6.string(),
5700
- versionId: z6.string(),
5701
- action: z6.enum(["created", "existing"]),
5702
- updatedAt: z6.string()
5781
+ var createComposeResponseSchema = z7.object({
5782
+ composeId: z7.string(),
5783
+ name: z7.string(),
5784
+ versionId: z7.string(),
5785
+ action: z7.enum(["created", "existing"]),
5786
+ updatedAt: z7.string()
5703
5787
  });
5704
5788
  var composesMainContract = c2.router({
5705
5789
  /**
@@ -5711,9 +5795,9 @@ var composesMainContract = c2.router({
5711
5795
  method: "GET",
5712
5796
  path: "/api/agent/composes",
5713
5797
  headers: authHeadersSchema,
5714
- query: z6.object({
5715
- name: z6.string().min(1, "Missing name query parameter"),
5716
- scope: z6.string().optional()
5798
+ query: z7.object({
5799
+ name: z7.string().min(1, "Missing name query parameter"),
5800
+ scope: z7.string().optional()
5717
5801
  }),
5718
5802
  responses: {
5719
5803
  200: composeResponseSchema,
@@ -5733,7 +5817,7 @@ var composesMainContract = c2.router({
5733
5817
  method: "POST",
5734
5818
  path: "/api/agent/composes",
5735
5819
  headers: authHeadersSchema,
5736
- body: z6.object({
5820
+ body: z7.object({
5737
5821
  content: agentComposeContentSchema
5738
5822
  }),
5739
5823
  responses: {
@@ -5754,8 +5838,8 @@ var composesByIdContract = c2.router({
5754
5838
  method: "GET",
5755
5839
  path: "/api/agent/composes/:id",
5756
5840
  headers: authHeadersSchema,
5757
- pathParams: z6.object({
5758
- id: z6.string().min(1, "Compose ID is required")
5841
+ pathParams: z7.object({
5842
+ id: z7.string().min(1, "Compose ID is required")
5759
5843
  }),
5760
5844
  responses: {
5761
5845
  200: composeResponseSchema,
@@ -5774,14 +5858,14 @@ var composesVersionsContract = c2.router({
5774
5858
  method: "GET",
5775
5859
  path: "/api/agent/composes/versions",
5776
5860
  headers: authHeadersSchema,
5777
- query: z6.object({
5778
- composeId: z6.string().min(1, "Missing composeId query parameter"),
5861
+ query: z7.object({
5862
+ composeId: z7.string().min(1, "Missing composeId query parameter"),
5779
5863
  version: composeVersionQuerySchema
5780
5864
  }),
5781
5865
  responses: {
5782
- 200: z6.object({
5783
- versionId: z6.string(),
5784
- tag: z6.string().optional()
5866
+ 200: z7.object({
5867
+ versionId: z7.string(),
5868
+ tag: z7.string().optional()
5785
5869
  }),
5786
5870
  400: apiErrorSchema,
5787
5871
  401: apiErrorSchema,
@@ -5790,10 +5874,10 @@ var composesVersionsContract = c2.router({
5790
5874
  summary: "Resolve version specifier to full version ID"
5791
5875
  }
5792
5876
  });
5793
- var composeListItemSchema = z6.object({
5794
- name: z6.string(),
5795
- headVersionId: z6.string().nullable(),
5796
- updatedAt: z6.string()
5877
+ var composeListItemSchema = z7.object({
5878
+ name: z7.string(),
5879
+ headVersionId: z7.string().nullable(),
5880
+ updatedAt: z7.string()
5797
5881
  });
5798
5882
  var composesListContract = c2.router({
5799
5883
  /**
@@ -5805,12 +5889,12 @@ var composesListContract = c2.router({
5805
5889
  method: "GET",
5806
5890
  path: "/api/agent/composes/list",
5807
5891
  headers: authHeadersSchema,
5808
- query: z6.object({
5809
- scope: z6.string().optional()
5892
+ query: z7.object({
5893
+ scope: z7.string().optional()
5810
5894
  }),
5811
5895
  responses: {
5812
- 200: z6.object({
5813
- composes: z6.array(composeListItemSchema)
5896
+ 200: z7.object({
5897
+ composes: z7.array(composeListItemSchema)
5814
5898
  }),
5815
5899
  400: apiErrorSchema,
5816
5900
  401: apiErrorSchema
@@ -5820,85 +5904,85 @@ var composesListContract = c2.router({
5820
5904
  });
5821
5905
 
5822
5906
  // ../../packages/core/src/contracts/runs.ts
5823
- import { z as z7 } from "zod";
5907
+ import { z as z8 } from "zod";
5824
5908
  var c3 = initContract();
5825
- var runStatusSchema = z7.enum([
5909
+ var runStatusSchema = z8.enum([
5826
5910
  "pending",
5827
5911
  "running",
5828
5912
  "completed",
5829
5913
  "failed",
5830
5914
  "timeout"
5831
5915
  ]);
5832
- var unifiedRunRequestSchema = z7.object({
5916
+ var unifiedRunRequestSchema = z8.object({
5833
5917
  // High-level shortcuts (mutually exclusive with each other)
5834
- checkpointId: z7.string().optional(),
5835
- sessionId: z7.string().optional(),
5918
+ checkpointId: z8.string().optional(),
5919
+ sessionId: z8.string().optional(),
5836
5920
  // Base parameters (can be used directly or overridden after shortcut expansion)
5837
- agentComposeId: z7.string().optional(),
5838
- agentComposeVersionId: z7.string().optional(),
5839
- conversationId: z7.string().optional(),
5840
- artifactName: z7.string().optional(),
5841
- artifactVersion: z7.string().optional(),
5842
- vars: z7.record(z7.string(), z7.string()).optional(),
5843
- secrets: z7.record(z7.string(), z7.string()).optional(),
5844
- volumeVersions: z7.record(z7.string(), z7.string()).optional(),
5921
+ agentComposeId: z8.string().optional(),
5922
+ agentComposeVersionId: z8.string().optional(),
5923
+ conversationId: z8.string().optional(),
5924
+ artifactName: z8.string().optional(),
5925
+ artifactVersion: z8.string().optional(),
5926
+ vars: z8.record(z8.string(), z8.string()).optional(),
5927
+ secrets: z8.record(z8.string(), z8.string()).optional(),
5928
+ volumeVersions: z8.record(z8.string(), z8.string()).optional(),
5845
5929
  // Debug flag to force real Claude in mock environments (internal use only)
5846
- debugNoMockClaude: z7.boolean().optional(),
5930
+ debugNoMockClaude: z8.boolean().optional(),
5847
5931
  // Model provider for automatic credential injection
5848
- modelProvider: z7.string().optional(),
5932
+ modelProvider: z8.string().optional(),
5849
5933
  // Required
5850
- prompt: z7.string().min(1, "Missing prompt")
5934
+ prompt: z8.string().min(1, "Missing prompt")
5851
5935
  });
5852
- var createRunResponseSchema = z7.object({
5853
- runId: z7.string(),
5936
+ var createRunResponseSchema = z8.object({
5937
+ runId: z8.string(),
5854
5938
  status: runStatusSchema,
5855
- sandboxId: z7.string().optional(),
5856
- output: z7.string().optional(),
5857
- error: z7.string().optional(),
5858
- executionTimeMs: z7.number().optional(),
5859
- createdAt: z7.string()
5860
- });
5861
- var getRunResponseSchema = z7.object({
5862
- runId: z7.string(),
5863
- agentComposeVersionId: z7.string(),
5939
+ sandboxId: z8.string().optional(),
5940
+ output: z8.string().optional(),
5941
+ error: z8.string().optional(),
5942
+ executionTimeMs: z8.number().optional(),
5943
+ createdAt: z8.string()
5944
+ });
5945
+ var getRunResponseSchema = z8.object({
5946
+ runId: z8.string(),
5947
+ agentComposeVersionId: z8.string(),
5864
5948
  status: runStatusSchema,
5865
- prompt: z7.string(),
5866
- vars: z7.record(z7.string(), z7.string()).optional(),
5867
- sandboxId: z7.string().optional(),
5868
- result: z7.object({
5869
- output: z7.string(),
5870
- executionTimeMs: z7.number()
5949
+ prompt: z8.string(),
5950
+ vars: z8.record(z8.string(), z8.string()).optional(),
5951
+ sandboxId: z8.string().optional(),
5952
+ result: z8.object({
5953
+ output: z8.string(),
5954
+ executionTimeMs: z8.number()
5871
5955
  }).optional(),
5872
- error: z7.string().optional(),
5873
- createdAt: z7.string(),
5874
- startedAt: z7.string().optional(),
5875
- completedAt: z7.string().optional()
5876
- });
5877
- var runEventSchema = z7.object({
5878
- sequenceNumber: z7.number(),
5879
- eventType: z7.string(),
5880
- eventData: z7.unknown(),
5881
- createdAt: z7.string()
5882
- });
5883
- var runResultSchema = z7.object({
5884
- checkpointId: z7.string(),
5885
- agentSessionId: z7.string(),
5886
- conversationId: z7.string(),
5887
- artifact: z7.record(z7.string(), z7.string()).optional(),
5956
+ error: z8.string().optional(),
5957
+ createdAt: z8.string(),
5958
+ startedAt: z8.string().optional(),
5959
+ completedAt: z8.string().optional()
5960
+ });
5961
+ var runEventSchema = z8.object({
5962
+ sequenceNumber: z8.number(),
5963
+ eventType: z8.string(),
5964
+ eventData: z8.unknown(),
5965
+ createdAt: z8.string()
5966
+ });
5967
+ var runResultSchema = z8.object({
5968
+ checkpointId: z8.string(),
5969
+ agentSessionId: z8.string(),
5970
+ conversationId: z8.string(),
5971
+ artifact: z8.record(z8.string(), z8.string()).optional(),
5888
5972
  // optional when run has no artifact
5889
- volumes: z7.record(z7.string(), z7.string()).optional()
5973
+ volumes: z8.record(z8.string(), z8.string()).optional()
5890
5974
  });
5891
- var runStateSchema = z7.object({
5975
+ var runStateSchema = z8.object({
5892
5976
  status: runStatusSchema,
5893
5977
  result: runResultSchema.optional(),
5894
- error: z7.string().optional()
5978
+ error: z8.string().optional()
5895
5979
  });
5896
- var eventsResponseSchema = z7.object({
5897
- events: z7.array(runEventSchema),
5898
- hasMore: z7.boolean(),
5899
- nextSequence: z7.number(),
5980
+ var eventsResponseSchema = z8.object({
5981
+ events: z8.array(runEventSchema),
5982
+ hasMore: z8.boolean(),
5983
+ nextSequence: z8.number(),
5900
5984
  run: runStateSchema,
5901
- framework: z7.string()
5985
+ framework: z8.string()
5902
5986
  });
5903
5987
  var runsMainContract = c3.router({
5904
5988
  /**
@@ -5929,8 +6013,8 @@ var runsByIdContract = c3.router({
5929
6013
  method: "GET",
5930
6014
  path: "/api/agent/runs/:id",
5931
6015
  headers: authHeadersSchema,
5932
- pathParams: z7.object({
5933
- id: z7.string().min(1, "Run ID is required")
6016
+ pathParams: z8.object({
6017
+ id: z8.string().min(1, "Run ID is required")
5934
6018
  }),
5935
6019
  responses: {
5936
6020
  200: getRunResponseSchema,
@@ -5950,12 +6034,12 @@ var runEventsContract = c3.router({
5950
6034
  method: "GET",
5951
6035
  path: "/api/agent/runs/:id/events",
5952
6036
  headers: authHeadersSchema,
5953
- pathParams: z7.object({
5954
- id: z7.string().min(1, "Run ID is required")
6037
+ pathParams: z8.object({
6038
+ id: z8.string().min(1, "Run ID is required")
5955
6039
  }),
5956
- query: z7.object({
5957
- since: z7.coerce.number().default(-1),
5958
- limit: z7.coerce.number().default(100)
6040
+ query: z8.object({
6041
+ since: z8.coerce.number().default(-1),
6042
+ limit: z8.coerce.number().default(100)
5959
6043
  }),
5960
6044
  responses: {
5961
6045
  200: eventsResponseSchema,
@@ -5965,50 +6049,50 @@ var runEventsContract = c3.router({
5965
6049
  summary: "Get agent run events"
5966
6050
  }
5967
6051
  });
5968
- var telemetryMetricSchema = z7.object({
5969
- ts: z7.string(),
5970
- cpu: z7.number(),
5971
- mem_used: z7.number(),
5972
- mem_total: z7.number(),
5973
- disk_used: z7.number(),
5974
- disk_total: z7.number()
6052
+ var telemetryMetricSchema = z8.object({
6053
+ ts: z8.string(),
6054
+ cpu: z8.number(),
6055
+ mem_used: z8.number(),
6056
+ mem_total: z8.number(),
6057
+ disk_used: z8.number(),
6058
+ disk_total: z8.number()
5975
6059
  });
5976
- var systemLogResponseSchema = z7.object({
5977
- systemLog: z7.string(),
5978
- hasMore: z7.boolean()
6060
+ var systemLogResponseSchema = z8.object({
6061
+ systemLog: z8.string(),
6062
+ hasMore: z8.boolean()
5979
6063
  });
5980
- var metricsResponseSchema = z7.object({
5981
- metrics: z7.array(telemetryMetricSchema),
5982
- hasMore: z7.boolean()
6064
+ var metricsResponseSchema = z8.object({
6065
+ metrics: z8.array(telemetryMetricSchema),
6066
+ hasMore: z8.boolean()
5983
6067
  });
5984
- var agentEventsResponseSchema = z7.object({
5985
- events: z7.array(runEventSchema),
5986
- hasMore: z7.boolean(),
5987
- framework: z7.string()
6068
+ var agentEventsResponseSchema = z8.object({
6069
+ events: z8.array(runEventSchema),
6070
+ hasMore: z8.boolean(),
6071
+ framework: z8.string()
5988
6072
  });
5989
- var networkLogEntrySchema = z7.object({
5990
- timestamp: z7.string(),
6073
+ var networkLogEntrySchema = z8.object({
6074
+ timestamp: z8.string(),
5991
6075
  // Common fields (all modes)
5992
- mode: z7.enum(["mitm", "sni"]).optional(),
5993
- action: z7.enum(["ALLOW", "DENY"]).optional(),
5994
- host: z7.string().optional(),
5995
- port: z7.number().optional(),
5996
- rule_matched: z7.string().nullable().optional(),
6076
+ mode: z8.enum(["mitm", "sni"]).optional(),
6077
+ action: z8.enum(["ALLOW", "DENY"]).optional(),
6078
+ host: z8.string().optional(),
6079
+ port: z8.number().optional(),
6080
+ rule_matched: z8.string().nullable().optional(),
5997
6081
  // MITM-only fields (optional)
5998
- method: z7.string().optional(),
5999
- url: z7.string().optional(),
6000
- status: z7.number().optional(),
6001
- latency_ms: z7.number().optional(),
6002
- request_size: z7.number().optional(),
6003
- response_size: z7.number().optional()
6082
+ method: z8.string().optional(),
6083
+ url: z8.string().optional(),
6084
+ status: z8.number().optional(),
6085
+ latency_ms: z8.number().optional(),
6086
+ request_size: z8.number().optional(),
6087
+ response_size: z8.number().optional()
6004
6088
  });
6005
- var networkLogsResponseSchema = z7.object({
6006
- networkLogs: z7.array(networkLogEntrySchema),
6007
- hasMore: z7.boolean()
6089
+ var networkLogsResponseSchema = z8.object({
6090
+ networkLogs: z8.array(networkLogEntrySchema),
6091
+ hasMore: z8.boolean()
6008
6092
  });
6009
- var telemetryResponseSchema = z7.object({
6010
- systemLog: z7.string(),
6011
- metrics: z7.array(telemetryMetricSchema)
6093
+ var telemetryResponseSchema = z8.object({
6094
+ systemLog: z8.string(),
6095
+ metrics: z8.array(telemetryMetricSchema)
6012
6096
  });
6013
6097
  var runTelemetryContract = c3.router({
6014
6098
  /**
@@ -6019,8 +6103,8 @@ var runTelemetryContract = c3.router({
6019
6103
  method: "GET",
6020
6104
  path: "/api/agent/runs/:id/telemetry",
6021
6105
  headers: authHeadersSchema,
6022
- pathParams: z7.object({
6023
- id: z7.string().min(1, "Run ID is required")
6106
+ pathParams: z8.object({
6107
+ id: z8.string().min(1, "Run ID is required")
6024
6108
  }),
6025
6109
  responses: {
6026
6110
  200: telemetryResponseSchema,
@@ -6039,13 +6123,13 @@ var runSystemLogContract = c3.router({
6039
6123
  method: "GET",
6040
6124
  path: "/api/agent/runs/:id/telemetry/system-log",
6041
6125
  headers: authHeadersSchema,
6042
- pathParams: z7.object({
6043
- id: z7.string().min(1, "Run ID is required")
6126
+ pathParams: z8.object({
6127
+ id: z8.string().min(1, "Run ID is required")
6044
6128
  }),
6045
- query: z7.object({
6046
- since: z7.coerce.number().optional(),
6047
- limit: z7.coerce.number().min(1).max(100).default(5),
6048
- order: z7.enum(["asc", "desc"]).default("desc")
6129
+ query: z8.object({
6130
+ since: z8.coerce.number().optional(),
6131
+ limit: z8.coerce.number().min(1).max(100).default(5),
6132
+ order: z8.enum(["asc", "desc"]).default("desc")
6049
6133
  }),
6050
6134
  responses: {
6051
6135
  200: systemLogResponseSchema,
@@ -6064,13 +6148,13 @@ var runMetricsContract = c3.router({
6064
6148
  method: "GET",
6065
6149
  path: "/api/agent/runs/:id/telemetry/metrics",
6066
6150
  headers: authHeadersSchema,
6067
- pathParams: z7.object({
6068
- id: z7.string().min(1, "Run ID is required")
6151
+ pathParams: z8.object({
6152
+ id: z8.string().min(1, "Run ID is required")
6069
6153
  }),
6070
- query: z7.object({
6071
- since: z7.coerce.number().optional(),
6072
- limit: z7.coerce.number().min(1).max(100).default(5),
6073
- order: z7.enum(["asc", "desc"]).default("desc")
6154
+ query: z8.object({
6155
+ since: z8.coerce.number().optional(),
6156
+ limit: z8.coerce.number().min(1).max(100).default(5),
6157
+ order: z8.enum(["asc", "desc"]).default("desc")
6074
6158
  }),
6075
6159
  responses: {
6076
6160
  200: metricsResponseSchema,
@@ -6089,13 +6173,13 @@ var runAgentEventsContract = c3.router({
6089
6173
  method: "GET",
6090
6174
  path: "/api/agent/runs/:id/telemetry/agent",
6091
6175
  headers: authHeadersSchema,
6092
- pathParams: z7.object({
6093
- id: z7.string().min(1, "Run ID is required")
6176
+ pathParams: z8.object({
6177
+ id: z8.string().min(1, "Run ID is required")
6094
6178
  }),
6095
- query: z7.object({
6096
- since: z7.coerce.number().optional(),
6097
- limit: z7.coerce.number().min(1).max(100).default(5),
6098
- order: z7.enum(["asc", "desc"]).default("desc")
6179
+ query: z8.object({
6180
+ since: z8.coerce.number().optional(),
6181
+ limit: z8.coerce.number().min(1).max(100).default(5),
6182
+ order: z8.enum(["asc", "desc"]).default("desc")
6099
6183
  }),
6100
6184
  responses: {
6101
6185
  200: agentEventsResponseSchema,
@@ -6114,13 +6198,13 @@ var runNetworkLogsContract = c3.router({
6114
6198
  method: "GET",
6115
6199
  path: "/api/agent/runs/:id/telemetry/network",
6116
6200
  headers: authHeadersSchema,
6117
- pathParams: z7.object({
6118
- id: z7.string().min(1, "Run ID is required")
6201
+ pathParams: z8.object({
6202
+ id: z8.string().min(1, "Run ID is required")
6119
6203
  }),
6120
- query: z7.object({
6121
- since: z7.coerce.number().optional(),
6122
- limit: z7.coerce.number().min(1).max(100).default(5),
6123
- order: z7.enum(["asc", "desc"]).default("desc")
6204
+ query: z8.object({
6205
+ since: z8.coerce.number().optional(),
6206
+ limit: z8.coerce.number().min(1).max(100).default(5),
6207
+ order: z8.enum(["asc", "desc"]).default("desc")
6124
6208
  }),
6125
6209
  responses: {
6126
6210
  200: networkLogsResponseSchema,
@@ -6132,20 +6216,20 @@ var runNetworkLogsContract = c3.router({
6132
6216
  });
6133
6217
 
6134
6218
  // ../../packages/core/src/contracts/storages.ts
6135
- import { z as z8 } from "zod";
6219
+ import { z as z9 } from "zod";
6136
6220
  var c4 = initContract();
6137
- var storageTypeSchema = z8.enum(["volume", "artifact"]);
6138
- var versionQuerySchema = z8.preprocess(
6221
+ var storageTypeSchema = z9.enum(["volume", "artifact"]);
6222
+ var versionQuerySchema = z9.preprocess(
6139
6223
  (val) => val === void 0 || val === null ? void 0 : String(val),
6140
- z8.string().regex(/^[a-f0-9]{8,64}$/i, "Version must be 8-64 hex characters").optional()
6224
+ z9.string().regex(/^[a-f0-9]{8,64}$/i, "Version must be 8-64 hex characters").optional()
6141
6225
  );
6142
- var uploadStorageResponseSchema = z8.object({
6143
- name: z8.string(),
6144
- versionId: z8.string(),
6145
- size: z8.number(),
6146
- fileCount: z8.number(),
6226
+ var uploadStorageResponseSchema = z9.object({
6227
+ name: z9.string(),
6228
+ versionId: z9.string(),
6229
+ size: z9.number(),
6230
+ fileCount: z9.number(),
6147
6231
  type: storageTypeSchema,
6148
- deduplicated: z8.boolean()
6232
+ deduplicated: z9.boolean()
6149
6233
  });
6150
6234
  var storagesContract = c4.router({
6151
6235
  /**
@@ -6187,8 +6271,8 @@ var storagesContract = c4.router({
6187
6271
  method: "GET",
6188
6272
  path: "/api/storages",
6189
6273
  headers: authHeadersSchema,
6190
- query: z8.object({
6191
- name: z8.string().min(1, "Storage name is required"),
6274
+ query: z9.object({
6275
+ name: z9.string().min(1, "Storage name is required"),
6192
6276
  version: versionQuerySchema
6193
6277
  }),
6194
6278
  responses: {
@@ -6205,41 +6289,41 @@ var storagesContract = c4.router({
6205
6289
  summary: "Download storage archive"
6206
6290
  }
6207
6291
  });
6208
- var fileEntryWithHashSchema = z8.object({
6209
- path: z8.string().min(1, "File path is required"),
6210
- hash: z8.string().length(64, "Hash must be SHA-256 (64 hex chars)"),
6211
- size: z8.number().int().min(0, "Size must be non-negative")
6292
+ var fileEntryWithHashSchema = z9.object({
6293
+ path: z9.string().min(1, "File path is required"),
6294
+ hash: z9.string().length(64, "Hash must be SHA-256 (64 hex chars)"),
6295
+ size: z9.number().int().min(0, "Size must be non-negative")
6212
6296
  });
6213
- var storageChangesSchema = z8.object({
6214
- added: z8.array(z8.string()),
6215
- modified: z8.array(z8.string()),
6216
- deleted: z8.array(z8.string())
6297
+ var storageChangesSchema = z9.object({
6298
+ added: z9.array(z9.string()),
6299
+ modified: z9.array(z9.string()),
6300
+ deleted: z9.array(z9.string())
6217
6301
  });
6218
- var presignedUploadSchema = z8.object({
6219
- key: z8.string(),
6220
- presignedUrl: z8.string().url()
6302
+ var presignedUploadSchema = z9.object({
6303
+ key: z9.string(),
6304
+ presignedUrl: z9.string().url()
6221
6305
  });
6222
6306
  var storagesPrepareContract = c4.router({
6223
6307
  prepare: {
6224
6308
  method: "POST",
6225
6309
  path: "/api/storages/prepare",
6226
6310
  headers: authHeadersSchema,
6227
- body: z8.object({
6228
- storageName: z8.string().min(1, "Storage name is required"),
6311
+ body: z9.object({
6312
+ storageName: z9.string().min(1, "Storage name is required"),
6229
6313
  storageType: storageTypeSchema,
6230
- files: z8.array(fileEntryWithHashSchema),
6231
- force: z8.boolean().optional(),
6232
- runId: z8.string().optional(),
6314
+ files: z9.array(fileEntryWithHashSchema),
6315
+ force: z9.boolean().optional(),
6316
+ runId: z9.string().optional(),
6233
6317
  // For sandbox auth
6234
- baseVersion: z8.string().optional(),
6318
+ baseVersion: z9.string().optional(),
6235
6319
  // For incremental uploads
6236
6320
  changes: storageChangesSchema.optional()
6237
6321
  }),
6238
6322
  responses: {
6239
- 200: z8.object({
6240
- versionId: z8.string(),
6241
- existing: z8.boolean(),
6242
- uploads: z8.object({
6323
+ 200: z9.object({
6324
+ versionId: z9.string(),
6325
+ existing: z9.boolean(),
6326
+ uploads: z9.object({
6243
6327
  archive: presignedUploadSchema,
6244
6328
  manifest: presignedUploadSchema
6245
6329
  }).optional()
@@ -6257,22 +6341,22 @@ var storagesCommitContract = c4.router({
6257
6341
  method: "POST",
6258
6342
  path: "/api/storages/commit",
6259
6343
  headers: authHeadersSchema,
6260
- body: z8.object({
6261
- storageName: z8.string().min(1, "Storage name is required"),
6344
+ body: z9.object({
6345
+ storageName: z9.string().min(1, "Storage name is required"),
6262
6346
  storageType: storageTypeSchema,
6263
- versionId: z8.string().min(1, "Version ID is required"),
6264
- files: z8.array(fileEntryWithHashSchema),
6265
- runId: z8.string().optional(),
6266
- message: z8.string().optional()
6347
+ versionId: z9.string().min(1, "Version ID is required"),
6348
+ files: z9.array(fileEntryWithHashSchema),
6349
+ runId: z9.string().optional(),
6350
+ message: z9.string().optional()
6267
6351
  }),
6268
6352
  responses: {
6269
- 200: z8.object({
6270
- success: z8.literal(true),
6271
- versionId: z8.string(),
6272
- storageName: z8.string(),
6273
- size: z8.number(),
6274
- fileCount: z8.number(),
6275
- deduplicated: z8.boolean().optional()
6353
+ 200: z9.object({
6354
+ success: z9.literal(true),
6355
+ versionId: z9.string(),
6356
+ storageName: z9.string(),
6357
+ size: z9.number(),
6358
+ fileCount: z9.number(),
6359
+ deduplicated: z9.boolean().optional()
6276
6360
  }),
6277
6361
  400: apiErrorSchema,
6278
6362
  401: apiErrorSchema,
@@ -6289,26 +6373,26 @@ var storagesDownloadContract = c4.router({
6289
6373
  method: "GET",
6290
6374
  path: "/api/storages/download",
6291
6375
  headers: authHeadersSchema,
6292
- query: z8.object({
6293
- name: z8.string().min(1, "Storage name is required"),
6376
+ query: z9.object({
6377
+ name: z9.string().min(1, "Storage name is required"),
6294
6378
  type: storageTypeSchema,
6295
6379
  version: versionQuerySchema
6296
6380
  }),
6297
6381
  responses: {
6298
6382
  // Normal response with presigned URL
6299
- 200: z8.union([
6300
- z8.object({
6301
- url: z8.string().url(),
6302
- versionId: z8.string(),
6303
- fileCount: z8.number(),
6304
- size: z8.number()
6383
+ 200: z9.union([
6384
+ z9.object({
6385
+ url: z9.string().url(),
6386
+ versionId: z9.string(),
6387
+ fileCount: z9.number(),
6388
+ size: z9.number()
6305
6389
  }),
6306
6390
  // Empty artifact response
6307
- z8.object({
6308
- empty: z8.literal(true),
6309
- versionId: z8.string(),
6310
- fileCount: z8.literal(0),
6311
- size: z8.literal(0)
6391
+ z9.object({
6392
+ empty: z9.literal(true),
6393
+ versionId: z9.string(),
6394
+ fileCount: z9.literal(0),
6395
+ size: z9.literal(0)
6312
6396
  })
6313
6397
  ]),
6314
6398
  400: apiErrorSchema,
@@ -6324,16 +6408,16 @@ var storagesListContract = c4.router({
6324
6408
  method: "GET",
6325
6409
  path: "/api/storages/list",
6326
6410
  headers: authHeadersSchema,
6327
- query: z8.object({
6411
+ query: z9.object({
6328
6412
  type: storageTypeSchema
6329
6413
  }),
6330
6414
  responses: {
6331
- 200: z8.array(
6332
- z8.object({
6333
- name: z8.string(),
6334
- size: z8.number(),
6335
- fileCount: z8.number(),
6336
- updatedAt: z8.string()
6415
+ 200: z9.array(
6416
+ z9.object({
6417
+ name: z9.string(),
6418
+ size: z9.number(),
6419
+ fileCount: z9.number(),
6420
+ updatedAt: z9.string()
6337
6421
  })
6338
6422
  ),
6339
6423
  401: apiErrorSchema,
@@ -6344,18 +6428,18 @@ var storagesListContract = c4.router({
6344
6428
  });
6345
6429
 
6346
6430
  // ../../packages/core/src/contracts/webhooks.ts
6347
- import { z as z9 } from "zod";
6431
+ import { z as z10 } from "zod";
6348
6432
  var c5 = initContract();
6349
- var agentEventSchema = z9.object({
6350
- type: z9.string(),
6351
- sequenceNumber: z9.number().int().nonnegative()
6433
+ var agentEventSchema = z10.object({
6434
+ type: z10.string(),
6435
+ sequenceNumber: z10.number().int().nonnegative()
6352
6436
  }).passthrough();
6353
- var artifactSnapshotSchema = z9.object({
6354
- artifactName: z9.string(),
6355
- artifactVersion: z9.string()
6437
+ var artifactSnapshotSchema = z10.object({
6438
+ artifactName: z10.string(),
6439
+ artifactVersion: z10.string()
6356
6440
  });
6357
- var volumeVersionsSnapshotSchema = z9.object({
6358
- versions: z9.record(z9.string(), z9.string())
6441
+ var volumeVersionsSnapshotSchema = z10.object({
6442
+ versions: z10.record(z10.string(), z10.string())
6359
6443
  });
6360
6444
  var webhookEventsContract = c5.router({
6361
6445
  /**
@@ -6366,15 +6450,15 @@ var webhookEventsContract = c5.router({
6366
6450
  method: "POST",
6367
6451
  path: "/api/webhooks/agent/events",
6368
6452
  headers: authHeadersSchema,
6369
- body: z9.object({
6370
- runId: z9.string().min(1, "runId is required"),
6371
- events: z9.array(agentEventSchema).min(1, "events array cannot be empty")
6453
+ body: z10.object({
6454
+ runId: z10.string().min(1, "runId is required"),
6455
+ events: z10.array(agentEventSchema).min(1, "events array cannot be empty")
6372
6456
  }),
6373
6457
  responses: {
6374
- 200: z9.object({
6375
- received: z9.number(),
6376
- firstSequence: z9.number(),
6377
- lastSequence: z9.number()
6458
+ 200: z10.object({
6459
+ received: z10.number(),
6460
+ firstSequence: z10.number(),
6461
+ lastSequence: z10.number()
6378
6462
  }),
6379
6463
  400: apiErrorSchema,
6380
6464
  401: apiErrorSchema,
@@ -6393,15 +6477,15 @@ var webhookCompleteContract = c5.router({
6393
6477
  method: "POST",
6394
6478
  path: "/api/webhooks/agent/complete",
6395
6479
  headers: authHeadersSchema,
6396
- body: z9.object({
6397
- runId: z9.string().min(1, "runId is required"),
6398
- exitCode: z9.number(),
6399
- error: z9.string().optional()
6480
+ body: z10.object({
6481
+ runId: z10.string().min(1, "runId is required"),
6482
+ exitCode: z10.number(),
6483
+ error: z10.string().optional()
6400
6484
  }),
6401
6485
  responses: {
6402
- 200: z9.object({
6403
- success: z9.boolean(),
6404
- status: z9.enum(["completed", "failed"])
6486
+ 200: z10.object({
6487
+ success: z10.boolean(),
6488
+ status: z10.enum(["completed", "failed"])
6405
6489
  }),
6406
6490
  400: apiErrorSchema,
6407
6491
  401: apiErrorSchema,
@@ -6420,21 +6504,21 @@ var webhookCheckpointsContract = c5.router({
6420
6504
  method: "POST",
6421
6505
  path: "/api/webhooks/agent/checkpoints",
6422
6506
  headers: authHeadersSchema,
6423
- body: z9.object({
6424
- runId: z9.string().min(1, "runId is required"),
6425
- cliAgentType: z9.string().min(1, "cliAgentType is required"),
6426
- cliAgentSessionId: z9.string().min(1, "cliAgentSessionId is required"),
6427
- cliAgentSessionHistory: z9.string().min(1, "cliAgentSessionHistory is required"),
6507
+ body: z10.object({
6508
+ runId: z10.string().min(1, "runId is required"),
6509
+ cliAgentType: z10.string().min(1, "cliAgentType is required"),
6510
+ cliAgentSessionId: z10.string().min(1, "cliAgentSessionId is required"),
6511
+ cliAgentSessionHistory: z10.string().min(1, "cliAgentSessionHistory is required"),
6428
6512
  artifactSnapshot: artifactSnapshotSchema.optional(),
6429
6513
  volumeVersionsSnapshot: volumeVersionsSnapshotSchema.optional()
6430
6514
  }),
6431
6515
  responses: {
6432
- 200: z9.object({
6433
- checkpointId: z9.string(),
6434
- agentSessionId: z9.string(),
6435
- conversationId: z9.string(),
6516
+ 200: z10.object({
6517
+ checkpointId: z10.string(),
6518
+ agentSessionId: z10.string(),
6519
+ conversationId: z10.string(),
6436
6520
  artifact: artifactSnapshotSchema.optional(),
6437
- volumes: z9.record(z9.string(), z9.string()).optional()
6521
+ volumes: z10.record(z10.string(), z10.string()).optional()
6438
6522
  }),
6439
6523
  400: apiErrorSchema,
6440
6524
  401: apiErrorSchema,
@@ -6453,12 +6537,12 @@ var webhookHeartbeatContract = c5.router({
6453
6537
  method: "POST",
6454
6538
  path: "/api/webhooks/agent/heartbeat",
6455
6539
  headers: authHeadersSchema,
6456
- body: z9.object({
6457
- runId: z9.string().min(1, "runId is required")
6540
+ body: z10.object({
6541
+ runId: z10.string().min(1, "runId is required")
6458
6542
  }),
6459
6543
  responses: {
6460
- 200: z9.object({
6461
- ok: z9.boolean()
6544
+ 200: z10.object({
6545
+ ok: z10.boolean()
6462
6546
  }),
6463
6547
  400: apiErrorSchema,
6464
6548
  401: apiErrorSchema,
@@ -6486,11 +6570,11 @@ var webhookStoragesContract = c5.router({
6486
6570
  contentType: "multipart/form-data",
6487
6571
  body: c5.type(),
6488
6572
  responses: {
6489
- 200: z9.object({
6490
- versionId: z9.string(),
6491
- storageName: z9.string(),
6492
- size: z9.number(),
6493
- fileCount: z9.number()
6573
+ 200: z10.object({
6574
+ versionId: z10.string(),
6575
+ storageName: z10.string(),
6576
+ size: z10.number(),
6577
+ fileCount: z10.number()
6494
6578
  }),
6495
6579
  400: apiErrorSchema,
6496
6580
  401: apiErrorSchema,
@@ -6520,17 +6604,17 @@ var webhookStoragesIncrementalContract = c5.router({
6520
6604
  contentType: "multipart/form-data",
6521
6605
  body: c5.type(),
6522
6606
  responses: {
6523
- 200: z9.object({
6524
- versionId: z9.string(),
6525
- storageName: z9.string(),
6526
- size: z9.number(),
6527
- fileCount: z9.number(),
6528
- incrementalStats: z9.object({
6529
- addedFiles: z9.number(),
6530
- modifiedFiles: z9.number(),
6531
- deletedFiles: z9.number(),
6532
- unchangedFiles: z9.number(),
6533
- bytesUploaded: z9.number()
6607
+ 200: z10.object({
6608
+ versionId: z10.string(),
6609
+ storageName: z10.string(),
6610
+ size: z10.number(),
6611
+ fileCount: z10.number(),
6612
+ incrementalStats: z10.object({
6613
+ addedFiles: z10.number(),
6614
+ modifiedFiles: z10.number(),
6615
+ deletedFiles: z10.number(),
6616
+ unchangedFiles: z10.number(),
6617
+ bytesUploaded: z10.number()
6534
6618
  }).optional()
6535
6619
  }),
6536
6620
  400: apiErrorSchema,
@@ -6541,36 +6625,36 @@ var webhookStoragesIncrementalContract = c5.router({
6541
6625
  summary: "Upload storage version incrementally from sandbox"
6542
6626
  }
6543
6627
  });
6544
- var metricDataSchema = z9.object({
6545
- ts: z9.string(),
6546
- cpu: z9.number(),
6547
- mem_used: z9.number(),
6548
- mem_total: z9.number(),
6549
- disk_used: z9.number(),
6550
- disk_total: z9.number()
6628
+ var metricDataSchema = z10.object({
6629
+ ts: z10.string(),
6630
+ cpu: z10.number(),
6631
+ mem_used: z10.number(),
6632
+ mem_total: z10.number(),
6633
+ disk_used: z10.number(),
6634
+ disk_total: z10.number()
6551
6635
  });
6552
- var sandboxOperationSchema = z9.object({
6553
- ts: z9.string(),
6554
- action_type: z9.string(),
6555
- duration_ms: z9.number(),
6556
- success: z9.boolean(),
6557
- error: z9.string().optional()
6636
+ var sandboxOperationSchema = z10.object({
6637
+ ts: z10.string(),
6638
+ action_type: z10.string(),
6639
+ duration_ms: z10.number(),
6640
+ success: z10.boolean(),
6641
+ error: z10.string().optional()
6558
6642
  });
6559
- var networkLogSchema = z9.object({
6560
- timestamp: z9.string(),
6643
+ var networkLogSchema = z10.object({
6644
+ timestamp: z10.string(),
6561
6645
  // Common fields (all modes)
6562
- mode: z9.enum(["mitm", "sni"]).optional(),
6563
- action: z9.enum(["ALLOW", "DENY"]).optional(),
6564
- host: z9.string().optional(),
6565
- port: z9.number().optional(),
6566
- rule_matched: z9.string().nullable().optional(),
6646
+ mode: z10.enum(["mitm", "sni"]).optional(),
6647
+ action: z10.enum(["ALLOW", "DENY"]).optional(),
6648
+ host: z10.string().optional(),
6649
+ port: z10.number().optional(),
6650
+ rule_matched: z10.string().nullable().optional(),
6567
6651
  // MITM-only fields (optional)
6568
- method: z9.string().optional(),
6569
- url: z9.string().optional(),
6570
- status: z9.number().optional(),
6571
- latency_ms: z9.number().optional(),
6572
- request_size: z9.number().optional(),
6573
- response_size: z9.number().optional()
6652
+ method: z10.string().optional(),
6653
+ url: z10.string().optional(),
6654
+ status: z10.number().optional(),
6655
+ latency_ms: z10.number().optional(),
6656
+ request_size: z10.number().optional(),
6657
+ response_size: z10.number().optional()
6574
6658
  });
6575
6659
  var webhookTelemetryContract = c5.router({
6576
6660
  /**
@@ -6581,17 +6665,17 @@ var webhookTelemetryContract = c5.router({
6581
6665
  method: "POST",
6582
6666
  path: "/api/webhooks/agent/telemetry",
6583
6667
  headers: authHeadersSchema,
6584
- body: z9.object({
6585
- runId: z9.string().min(1, "runId is required"),
6586
- systemLog: z9.string().optional(),
6587
- metrics: z9.array(metricDataSchema).optional(),
6588
- networkLogs: z9.array(networkLogSchema).optional(),
6589
- sandboxOperations: z9.array(sandboxOperationSchema).optional()
6668
+ body: z10.object({
6669
+ runId: z10.string().min(1, "runId is required"),
6670
+ systemLog: z10.string().optional(),
6671
+ metrics: z10.array(metricDataSchema).optional(),
6672
+ networkLogs: z10.array(networkLogSchema).optional(),
6673
+ sandboxOperations: z10.array(sandboxOperationSchema).optional()
6590
6674
  }),
6591
6675
  responses: {
6592
- 200: z9.object({
6593
- success: z9.boolean(),
6594
- id: z9.string()
6676
+ 200: z10.object({
6677
+ success: z10.boolean(),
6678
+ id: z10.string()
6595
6679
  }),
6596
6680
  400: apiErrorSchema,
6597
6681
  401: apiErrorSchema,
@@ -6606,21 +6690,21 @@ var webhookStoragesPrepareContract = c5.router({
6606
6690
  method: "POST",
6607
6691
  path: "/api/webhooks/agent/storages/prepare",
6608
6692
  headers: authHeadersSchema,
6609
- body: z9.object({
6610
- runId: z9.string().min(1, "runId is required"),
6693
+ body: z10.object({
6694
+ runId: z10.string().min(1, "runId is required"),
6611
6695
  // Required for webhook auth
6612
- storageName: z9.string().min(1, "Storage name is required"),
6696
+ storageName: z10.string().min(1, "Storage name is required"),
6613
6697
  storageType: storageTypeSchema,
6614
- files: z9.array(fileEntryWithHashSchema),
6615
- force: z9.boolean().optional(),
6616
- baseVersion: z9.string().optional(),
6698
+ files: z10.array(fileEntryWithHashSchema),
6699
+ force: z10.boolean().optional(),
6700
+ baseVersion: z10.string().optional(),
6617
6701
  changes: storageChangesSchema.optional()
6618
6702
  }),
6619
6703
  responses: {
6620
- 200: z9.object({
6621
- versionId: z9.string(),
6622
- existing: z9.boolean(),
6623
- uploads: z9.object({
6704
+ 200: z10.object({
6705
+ versionId: z10.string(),
6706
+ existing: z10.boolean(),
6707
+ uploads: z10.object({
6624
6708
  archive: presignedUploadSchema,
6625
6709
  manifest: presignedUploadSchema
6626
6710
  }).optional()
@@ -6638,23 +6722,23 @@ var webhookStoragesCommitContract = c5.router({
6638
6722
  method: "POST",
6639
6723
  path: "/api/webhooks/agent/storages/commit",
6640
6724
  headers: authHeadersSchema,
6641
- body: z9.object({
6642
- runId: z9.string().min(1, "runId is required"),
6725
+ body: z10.object({
6726
+ runId: z10.string().min(1, "runId is required"),
6643
6727
  // Required for webhook auth
6644
- storageName: z9.string().min(1, "Storage name is required"),
6728
+ storageName: z10.string().min(1, "Storage name is required"),
6645
6729
  storageType: storageTypeSchema,
6646
- versionId: z9.string().min(1, "Version ID is required"),
6647
- files: z9.array(fileEntryWithHashSchema),
6648
- message: z9.string().optional()
6730
+ versionId: z10.string().min(1, "Version ID is required"),
6731
+ files: z10.array(fileEntryWithHashSchema),
6732
+ message: z10.string().optional()
6649
6733
  }),
6650
6734
  responses: {
6651
- 200: z9.object({
6652
- success: z9.literal(true),
6653
- versionId: z9.string(),
6654
- storageName: z9.string(),
6655
- size: z9.number(),
6656
- fileCount: z9.number(),
6657
- deduplicated: z9.boolean().optional()
6735
+ 200: z10.object({
6736
+ success: z10.literal(true),
6737
+ versionId: z10.string(),
6738
+ storageName: z10.string(),
6739
+ size: z10.number(),
6740
+ fileCount: z10.number(),
6741
+ deduplicated: z10.boolean().optional()
6658
6742
  }),
6659
6743
  400: apiErrorSchema,
6660
6744
  401: apiErrorSchema,
@@ -6668,11 +6752,11 @@ var webhookStoragesCommitContract = c5.router({
6668
6752
  });
6669
6753
 
6670
6754
  // ../../packages/core/src/contracts/cli-auth.ts
6671
- import { z as z10 } from "zod";
6755
+ import { z as z11 } from "zod";
6672
6756
  var c6 = initContract();
6673
- var oauthErrorSchema = z10.object({
6674
- error: z10.string(),
6675
- error_description: z10.string()
6757
+ var oauthErrorSchema = z11.object({
6758
+ error: z11.string(),
6759
+ error_description: z11.string()
6676
6760
  });
6677
6761
  var cliAuthDeviceContract = c6.router({
6678
6762
  /**
@@ -6682,14 +6766,14 @@ var cliAuthDeviceContract = c6.router({
6682
6766
  create: {
6683
6767
  method: "POST",
6684
6768
  path: "/api/cli/auth/device",
6685
- body: z10.object({}).optional(),
6769
+ body: z11.object({}).optional(),
6686
6770
  responses: {
6687
- 200: z10.object({
6688
- device_code: z10.string(),
6689
- user_code: z10.string(),
6690
- verification_path: z10.string(),
6691
- expires_in: z10.number(),
6692
- interval: z10.number()
6771
+ 200: z11.object({
6772
+ device_code: z11.string(),
6773
+ user_code: z11.string(),
6774
+ verification_path: z11.string(),
6775
+ expires_in: z11.number(),
6776
+ interval: z11.number()
6693
6777
  }),
6694
6778
  500: oauthErrorSchema
6695
6779
  },
@@ -6704,16 +6788,16 @@ var cliAuthTokenContract = c6.router({
6704
6788
  exchange: {
6705
6789
  method: "POST",
6706
6790
  path: "/api/cli/auth/token",
6707
- body: z10.object({
6708
- device_code: z10.string().min(1, "device_code is required")
6791
+ body: z11.object({
6792
+ device_code: z11.string().min(1, "device_code is required")
6709
6793
  }),
6710
6794
  responses: {
6711
6795
  // Success - token issued
6712
- 200: z10.object({
6713
- access_token: z10.string(),
6714
- refresh_token: z10.string(),
6715
- token_type: z10.literal("Bearer"),
6716
- expires_in: z10.number()
6796
+ 200: z11.object({
6797
+ access_token: z11.string(),
6798
+ refresh_token: z11.string(),
6799
+ token_type: z11.literal("Bearer"),
6800
+ expires_in: z11.number()
6717
6801
  }),
6718
6802
  // Authorization pending
6719
6803
  202: oauthErrorSchema,
@@ -6726,7 +6810,7 @@ var cliAuthTokenContract = c6.router({
6726
6810
  });
6727
6811
 
6728
6812
  // ../../packages/core/src/contracts/auth.ts
6729
- import { z as z11 } from "zod";
6813
+ import { z as z12 } from "zod";
6730
6814
  var c7 = initContract();
6731
6815
  var authContract = c7.router({
6732
6816
  /**
@@ -6738,9 +6822,9 @@ var authContract = c7.router({
6738
6822
  path: "/api/auth/me",
6739
6823
  headers: authHeadersSchema,
6740
6824
  responses: {
6741
- 200: z11.object({
6742
- userId: z11.string(),
6743
- email: z11.string()
6825
+ 200: z12.object({
6826
+ userId: z12.string(),
6827
+ email: z12.string()
6744
6828
  }),
6745
6829
  401: apiErrorSchema,
6746
6830
  404: apiErrorSchema,
@@ -6751,18 +6835,18 @@ var authContract = c7.router({
6751
6835
  });
6752
6836
 
6753
6837
  // ../../packages/core/src/contracts/cron.ts
6754
- import { z as z12 } from "zod";
6838
+ import { z as z13 } from "zod";
6755
6839
  var c8 = initContract();
6756
- var cleanupResultSchema = z12.object({
6757
- runId: z12.string(),
6758
- sandboxId: z12.string().nullable(),
6759
- status: z12.enum(["cleaned", "error"]),
6760
- error: z12.string().optional()
6840
+ var cleanupResultSchema = z13.object({
6841
+ runId: z13.string(),
6842
+ sandboxId: z13.string().nullable(),
6843
+ status: z13.enum(["cleaned", "error"]),
6844
+ error: z13.string().optional()
6761
6845
  });
6762
- var cleanupResponseSchema = z12.object({
6763
- cleaned: z12.number(),
6764
- errors: z12.number(),
6765
- results: z12.array(cleanupResultSchema)
6846
+ var cleanupResponseSchema = z13.object({
6847
+ cleaned: z13.number(),
6848
+ errors: z13.number(),
6849
+ results: z13.array(cleanupResultSchema)
6766
6850
  });
6767
6851
  var cronCleanupSandboxesContract = c8.router({
6768
6852
  /**
@@ -6783,44 +6867,44 @@ var cronCleanupSandboxesContract = c8.router({
6783
6867
  });
6784
6868
 
6785
6869
  // ../../packages/core/src/contracts/proxy.ts
6786
- import { z as z13 } from "zod";
6787
- var proxyErrorSchema = z13.object({
6788
- error: z13.object({
6789
- message: z13.string(),
6790
- code: z13.enum([
6870
+ import { z as z14 } from "zod";
6871
+ var proxyErrorSchema = z14.object({
6872
+ error: z14.object({
6873
+ message: z14.string(),
6874
+ code: z14.enum([
6791
6875
  "UNAUTHORIZED",
6792
6876
  "BAD_REQUEST",
6793
6877
  "BAD_GATEWAY",
6794
6878
  "INTERNAL_ERROR"
6795
6879
  ]),
6796
- targetUrl: z13.string().optional()
6880
+ targetUrl: z14.string().optional()
6797
6881
  })
6798
6882
  });
6799
6883
 
6800
6884
  // ../../packages/core/src/contracts/scopes.ts
6801
- import { z as z14 } from "zod";
6885
+ import { z as z15 } from "zod";
6802
6886
  var c9 = initContract();
6803
- var scopeTypeSchema = z14.enum(["personal", "organization", "system"]);
6804
- var scopeSlugSchema = z14.string().min(3, "Scope slug must be at least 3 characters").max(64, "Scope slug must be at most 64 characters").regex(
6887
+ var scopeTypeSchema = z15.enum(["personal", "organization", "system"]);
6888
+ var scopeSlugSchema = z15.string().min(3, "Scope slug must be at least 3 characters").max(64, "Scope slug must be at most 64 characters").regex(
6805
6889
  /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]{1,2}$/,
6806
6890
  "Scope slug must contain only lowercase letters, numbers, and hyphens, and must start and end with an alphanumeric character"
6807
6891
  ).refine(
6808
6892
  (slug) => !slug.startsWith("vm0"),
6809
6893
  "Scope slug cannot start with 'vm0' (reserved)"
6810
6894
  ).transform((s) => s.toLowerCase());
6811
- var scopeResponseSchema = z14.object({
6812
- id: z14.string().uuid(),
6813
- slug: z14.string(),
6895
+ var scopeResponseSchema = z15.object({
6896
+ id: z15.string().uuid(),
6897
+ slug: z15.string(),
6814
6898
  type: scopeTypeSchema,
6815
- createdAt: z14.string(),
6816
- updatedAt: z14.string()
6899
+ createdAt: z15.string(),
6900
+ updatedAt: z15.string()
6817
6901
  });
6818
- var createScopeRequestSchema = z14.object({
6902
+ var createScopeRequestSchema = z15.object({
6819
6903
  slug: scopeSlugSchema
6820
6904
  });
6821
- var updateScopeRequestSchema = z14.object({
6905
+ var updateScopeRequestSchema = z15.object({
6822
6906
  slug: scopeSlugSchema,
6823
- force: z14.boolean().optional().default(false)
6907
+ force: z15.boolean().optional().default(false)
6824
6908
  });
6825
6909
  var scopeContract = c9.router({
6826
6910
  /**
@@ -6880,28 +6964,28 @@ var scopeContract = c9.router({
6880
6964
  });
6881
6965
 
6882
6966
  // ../../packages/core/src/contracts/credentials.ts
6883
- import { z as z15 } from "zod";
6967
+ import { z as z16 } from "zod";
6884
6968
  var c10 = initContract();
6885
- var credentialNameSchema = z15.string().min(1, "Credential name is required").max(255, "Credential name must be at most 255 characters").regex(
6969
+ var credentialNameSchema = z16.string().min(1, "Credential name is required").max(255, "Credential name must be at most 255 characters").regex(
6886
6970
  /^[A-Z][A-Z0-9_]*$/,
6887
6971
  "Credential name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_API_KEY)"
6888
6972
  );
6889
- var credentialTypeSchema = z15.enum(["user", "model-provider"]);
6890
- var credentialResponseSchema = z15.object({
6891
- id: z15.string().uuid(),
6892
- name: z15.string(),
6893
- description: z15.string().nullable(),
6973
+ var credentialTypeSchema = z16.enum(["user", "model-provider"]);
6974
+ var credentialResponseSchema = z16.object({
6975
+ id: z16.string().uuid(),
6976
+ name: z16.string(),
6977
+ description: z16.string().nullable(),
6894
6978
  type: credentialTypeSchema,
6895
- createdAt: z15.string(),
6896
- updatedAt: z15.string()
6979
+ createdAt: z16.string(),
6980
+ updatedAt: z16.string()
6897
6981
  });
6898
- var credentialListResponseSchema = z15.object({
6899
- credentials: z15.array(credentialResponseSchema)
6982
+ var credentialListResponseSchema = z16.object({
6983
+ credentials: z16.array(credentialResponseSchema)
6900
6984
  });
6901
- var setCredentialRequestSchema = z15.object({
6985
+ var setCredentialRequestSchema = z16.object({
6902
6986
  name: credentialNameSchema,
6903
- value: z15.string().min(1, "Credential value is required"),
6904
- description: z15.string().max(1e3).optional()
6987
+ value: z16.string().min(1, "Credential value is required"),
6988
+ description: z16.string().max(1e3).optional()
6905
6989
  });
6906
6990
  var credentialsMainContract = c10.router({
6907
6991
  /**
@@ -6947,7 +7031,7 @@ var credentialsByNameContract = c10.router({
6947
7031
  method: "GET",
6948
7032
  path: "/api/credentials/:name",
6949
7033
  headers: authHeadersSchema,
6950
- pathParams: z15.object({
7034
+ pathParams: z16.object({
6951
7035
  name: credentialNameSchema
6952
7036
  }),
6953
7037
  responses: {
@@ -6966,11 +7050,11 @@ var credentialsByNameContract = c10.router({
6966
7050
  method: "DELETE",
6967
7051
  path: "/api/credentials/:name",
6968
7052
  headers: authHeadersSchema,
6969
- pathParams: z15.object({
7053
+ pathParams: z16.object({
6970
7054
  name: credentialNameSchema
6971
7055
  }),
6972
7056
  responses: {
6973
- 204: z15.undefined(),
7057
+ 204: z16.undefined(),
6974
7058
  401: apiErrorSchema,
6975
7059
  404: apiErrorSchema,
6976
7060
  500: apiErrorSchema
@@ -6980,39 +7064,38 @@ var credentialsByNameContract = c10.router({
6980
7064
  });
6981
7065
 
6982
7066
  // ../../packages/core/src/contracts/model-providers.ts
6983
- import { z as z16 } from "zod";
7067
+ import { z as z17 } from "zod";
6984
7068
  var c11 = initContract();
6985
- var modelProviderTypeSchema = z16.enum([
7069
+ var modelProviderTypeSchema = z17.enum([
6986
7070
  "claude-code-oauth-token",
6987
- "anthropic-api-key",
6988
- "openai-api-key"
7071
+ "anthropic-api-key"
6989
7072
  ]);
6990
- var modelProviderFrameworkSchema = z16.enum(["claude-code", "codex"]);
6991
- var modelProviderResponseSchema = z16.object({
6992
- id: z16.string().uuid(),
7073
+ var modelProviderFrameworkSchema = z17.enum(["claude-code", "codex"]);
7074
+ var modelProviderResponseSchema = z17.object({
7075
+ id: z17.string().uuid(),
6993
7076
  type: modelProviderTypeSchema,
6994
7077
  framework: modelProviderFrameworkSchema,
6995
- credentialName: z16.string(),
6996
- isDefault: z16.boolean(),
6997
- createdAt: z16.string(),
6998
- updatedAt: z16.string()
7078
+ credentialName: z17.string(),
7079
+ isDefault: z17.boolean(),
7080
+ createdAt: z17.string(),
7081
+ updatedAt: z17.string()
6999
7082
  });
7000
- var modelProviderListResponseSchema = z16.object({
7001
- modelProviders: z16.array(modelProviderResponseSchema)
7083
+ var modelProviderListResponseSchema = z17.object({
7084
+ modelProviders: z17.array(modelProviderResponseSchema)
7002
7085
  });
7003
- var upsertModelProviderRequestSchema = z16.object({
7086
+ var upsertModelProviderRequestSchema = z17.object({
7004
7087
  type: modelProviderTypeSchema,
7005
- credential: z16.string().min(1, "Credential is required"),
7006
- convert: z16.boolean().optional()
7088
+ credential: z17.string().min(1, "Credential is required"),
7089
+ convert: z17.boolean().optional()
7007
7090
  });
7008
- var upsertModelProviderResponseSchema = z16.object({
7091
+ var upsertModelProviderResponseSchema = z17.object({
7009
7092
  provider: modelProviderResponseSchema,
7010
- created: z16.boolean()
7093
+ created: z17.boolean()
7011
7094
  });
7012
- var checkCredentialResponseSchema = z16.object({
7013
- exists: z16.boolean(),
7014
- credentialName: z16.string(),
7015
- currentType: z16.enum(["user", "model-provider"]).optional()
7095
+ var checkCredentialResponseSchema = z17.object({
7096
+ exists: z17.boolean(),
7097
+ credentialName: z17.string(),
7098
+ currentType: z17.enum(["user", "model-provider"]).optional()
7016
7099
  });
7017
7100
  var modelProvidersMainContract = c11.router({
7018
7101
  list: {
@@ -7047,7 +7130,7 @@ var modelProvidersCheckContract = c11.router({
7047
7130
  method: "GET",
7048
7131
  path: "/api/model-providers/check/:type",
7049
7132
  headers: authHeadersSchema,
7050
- pathParams: z16.object({
7133
+ pathParams: z17.object({
7051
7134
  type: modelProviderTypeSchema
7052
7135
  }),
7053
7136
  responses: {
@@ -7063,11 +7146,11 @@ var modelProvidersByTypeContract = c11.router({
7063
7146
  method: "DELETE",
7064
7147
  path: "/api/model-providers/:type",
7065
7148
  headers: authHeadersSchema,
7066
- pathParams: z16.object({
7149
+ pathParams: z17.object({
7067
7150
  type: modelProviderTypeSchema
7068
7151
  }),
7069
7152
  responses: {
7070
- 204: z16.undefined(),
7153
+ 204: z17.undefined(),
7071
7154
  401: apiErrorSchema,
7072
7155
  404: apiErrorSchema,
7073
7156
  500: apiErrorSchema
@@ -7080,10 +7163,10 @@ var modelProvidersConvertContract = c11.router({
7080
7163
  method: "POST",
7081
7164
  path: "/api/model-providers/:type/convert",
7082
7165
  headers: authHeadersSchema,
7083
- pathParams: z16.object({
7166
+ pathParams: z17.object({
7084
7167
  type: modelProviderTypeSchema
7085
7168
  }),
7086
- body: z16.undefined(),
7169
+ body: z17.undefined(),
7087
7170
  responses: {
7088
7171
  200: modelProviderResponseSchema,
7089
7172
  400: apiErrorSchema,
@@ -7099,10 +7182,10 @@ var modelProvidersSetDefaultContract = c11.router({
7099
7182
  method: "POST",
7100
7183
  path: "/api/model-providers/:type/set-default",
7101
7184
  headers: authHeadersSchema,
7102
- pathParams: z16.object({
7185
+ pathParams: z17.object({
7103
7186
  type: modelProviderTypeSchema
7104
7187
  }),
7105
- body: z16.undefined(),
7188
+ body: z17.undefined(),
7106
7189
  responses: {
7107
7190
  200: modelProviderResponseSchema,
7108
7191
  401: apiErrorSchema,
@@ -7114,40 +7197,40 @@ var modelProvidersSetDefaultContract = c11.router({
7114
7197
  });
7115
7198
 
7116
7199
  // ../../packages/core/src/contracts/sessions.ts
7117
- import { z as z17 } from "zod";
7200
+ import { z as z18 } from "zod";
7118
7201
  var c12 = initContract();
7119
- var sessionResponseSchema = z17.object({
7120
- id: z17.string(),
7121
- agentComposeId: z17.string(),
7122
- agentComposeVersionId: z17.string().nullable(),
7123
- conversationId: z17.string().nullable(),
7124
- artifactName: z17.string().nullable(),
7125
- vars: z17.record(z17.string(), z17.string()).nullable(),
7126
- secretNames: z17.array(z17.string()).nullable(),
7127
- volumeVersions: z17.record(z17.string(), z17.string()).nullable(),
7128
- createdAt: z17.string(),
7129
- updatedAt: z17.string()
7202
+ var sessionResponseSchema = z18.object({
7203
+ id: z18.string(),
7204
+ agentComposeId: z18.string(),
7205
+ agentComposeVersionId: z18.string().nullable(),
7206
+ conversationId: z18.string().nullable(),
7207
+ artifactName: z18.string().nullable(),
7208
+ vars: z18.record(z18.string(), z18.string()).nullable(),
7209
+ secretNames: z18.array(z18.string()).nullable(),
7210
+ volumeVersions: z18.record(z18.string(), z18.string()).nullable(),
7211
+ createdAt: z18.string(),
7212
+ updatedAt: z18.string()
7130
7213
  });
7131
- var agentComposeSnapshotSchema = z17.object({
7132
- agentComposeVersionId: z17.string(),
7133
- vars: z17.record(z17.string(), z17.string()).optional(),
7134
- secretNames: z17.array(z17.string()).optional()
7214
+ var agentComposeSnapshotSchema = z18.object({
7215
+ agentComposeVersionId: z18.string(),
7216
+ vars: z18.record(z18.string(), z18.string()).optional(),
7217
+ secretNames: z18.array(z18.string()).optional()
7135
7218
  });
7136
- var artifactSnapshotSchema2 = z17.object({
7137
- artifactName: z17.string(),
7138
- artifactVersion: z17.string()
7219
+ var artifactSnapshotSchema2 = z18.object({
7220
+ artifactName: z18.string(),
7221
+ artifactVersion: z18.string()
7139
7222
  });
7140
- var volumeVersionsSnapshotSchema2 = z17.object({
7141
- versions: z17.record(z17.string(), z17.string())
7223
+ var volumeVersionsSnapshotSchema2 = z18.object({
7224
+ versions: z18.record(z18.string(), z18.string())
7142
7225
  });
7143
- var checkpointResponseSchema = z17.object({
7144
- id: z17.string(),
7145
- runId: z17.string(),
7146
- conversationId: z17.string(),
7226
+ var checkpointResponseSchema = z18.object({
7227
+ id: z18.string(),
7228
+ runId: z18.string(),
7229
+ conversationId: z18.string(),
7147
7230
  agentComposeSnapshot: agentComposeSnapshotSchema,
7148
7231
  artifactSnapshot: artifactSnapshotSchema2.nullable(),
7149
7232
  volumeVersionsSnapshot: volumeVersionsSnapshotSchema2.nullable(),
7150
- createdAt: z17.string()
7233
+ createdAt: z18.string()
7151
7234
  });
7152
7235
  var sessionsByIdContract = c12.router({
7153
7236
  /**
@@ -7158,8 +7241,8 @@ var sessionsByIdContract = c12.router({
7158
7241
  method: "GET",
7159
7242
  path: "/api/agent/sessions/:id",
7160
7243
  headers: authHeadersSchema,
7161
- pathParams: z17.object({
7162
- id: z17.string().min(1, "Session ID is required")
7244
+ pathParams: z18.object({
7245
+ id: z18.string().min(1, "Session ID is required")
7163
7246
  }),
7164
7247
  responses: {
7165
7248
  200: sessionResponseSchema,
@@ -7179,8 +7262,8 @@ var checkpointsByIdContract = c12.router({
7179
7262
  method: "GET",
7180
7263
  path: "/api/agent/checkpoints/:id",
7181
7264
  headers: authHeadersSchema,
7182
- pathParams: z17.object({
7183
- id: z17.string().min(1, "Checkpoint ID is required")
7265
+ pathParams: z18.object({
7266
+ id: z18.string().min(1, "Checkpoint ID is required")
7184
7267
  }),
7185
7268
  responses: {
7186
7269
  200: checkpointResponseSchema,
@@ -7193,88 +7276,88 @@ var checkpointsByIdContract = c12.router({
7193
7276
  });
7194
7277
 
7195
7278
  // ../../packages/core/src/contracts/schedules.ts
7196
- import { z as z18 } from "zod";
7279
+ import { z as z19 } from "zod";
7197
7280
  var c13 = initContract();
7198
- var scheduleTriggerSchema = z18.object({
7199
- cron: z18.string().optional(),
7200
- at: z18.string().optional(),
7201
- timezone: z18.string().default("UTC")
7281
+ var scheduleTriggerSchema = z19.object({
7282
+ cron: z19.string().optional(),
7283
+ at: z19.string().optional(),
7284
+ timezone: z19.string().default("UTC")
7202
7285
  }).refine((data) => data.cron && !data.at || !data.cron && data.at, {
7203
7286
  message: "Exactly one of 'cron' or 'at' must be specified"
7204
7287
  });
7205
- var scheduleRunConfigSchema = z18.object({
7206
- agent: z18.string().min(1, "Agent reference required"),
7207
- prompt: z18.string().min(1, "Prompt required"),
7208
- vars: z18.record(z18.string(), z18.string()).optional(),
7209
- secrets: z18.record(z18.string(), z18.string()).optional(),
7210
- artifactName: z18.string().optional(),
7211
- artifactVersion: z18.string().optional(),
7212
- volumeVersions: z18.record(z18.string(), z18.string()).optional()
7288
+ var scheduleRunConfigSchema = z19.object({
7289
+ agent: z19.string().min(1, "Agent reference required"),
7290
+ prompt: z19.string().min(1, "Prompt required"),
7291
+ vars: z19.record(z19.string(), z19.string()).optional(),
7292
+ secrets: z19.record(z19.string(), z19.string()).optional(),
7293
+ artifactName: z19.string().optional(),
7294
+ artifactVersion: z19.string().optional(),
7295
+ volumeVersions: z19.record(z19.string(), z19.string()).optional()
7213
7296
  });
7214
- var scheduleDefinitionSchema = z18.object({
7297
+ var scheduleDefinitionSchema = z19.object({
7215
7298
  on: scheduleTriggerSchema,
7216
7299
  run: scheduleRunConfigSchema
7217
7300
  });
7218
- var scheduleYamlSchema = z18.object({
7219
- version: z18.literal("1.0"),
7220
- schedules: z18.record(z18.string(), scheduleDefinitionSchema)
7221
- });
7222
- var deployScheduleRequestSchema = z18.object({
7223
- name: z18.string().min(1).max(64, "Schedule name max 64 chars"),
7224
- cronExpression: z18.string().optional(),
7225
- atTime: z18.string().optional(),
7226
- timezone: z18.string().default("UTC"),
7227
- prompt: z18.string().min(1, "Prompt required"),
7228
- vars: z18.record(z18.string(), z18.string()).optional(),
7229
- secrets: z18.record(z18.string(), z18.string()).optional(),
7230
- artifactName: z18.string().optional(),
7231
- artifactVersion: z18.string().optional(),
7232
- volumeVersions: z18.record(z18.string(), z18.string()).optional(),
7301
+ var scheduleYamlSchema = z19.object({
7302
+ version: z19.literal("1.0"),
7303
+ schedules: z19.record(z19.string(), scheduleDefinitionSchema)
7304
+ });
7305
+ var deployScheduleRequestSchema = z19.object({
7306
+ name: z19.string().min(1).max(64, "Schedule name max 64 chars"),
7307
+ cronExpression: z19.string().optional(),
7308
+ atTime: z19.string().optional(),
7309
+ timezone: z19.string().default("UTC"),
7310
+ prompt: z19.string().min(1, "Prompt required"),
7311
+ vars: z19.record(z19.string(), z19.string()).optional(),
7312
+ secrets: z19.record(z19.string(), z19.string()).optional(),
7313
+ artifactName: z19.string().optional(),
7314
+ artifactVersion: z19.string().optional(),
7315
+ volumeVersions: z19.record(z19.string(), z19.string()).optional(),
7233
7316
  // Resolved agent compose ID (CLI resolves scope/name:version → composeId)
7234
- composeId: z18.string().uuid("Invalid compose ID")
7317
+ composeId: z19.string().uuid("Invalid compose ID")
7235
7318
  }).refine(
7236
7319
  (data) => data.cronExpression && !data.atTime || !data.cronExpression && data.atTime,
7237
7320
  {
7238
7321
  message: "Exactly one of 'cronExpression' or 'atTime' must be specified"
7239
7322
  }
7240
7323
  );
7241
- var scheduleResponseSchema = z18.object({
7242
- id: z18.string().uuid(),
7243
- composeId: z18.string().uuid(),
7244
- composeName: z18.string(),
7245
- scopeSlug: z18.string(),
7246
- name: z18.string(),
7247
- cronExpression: z18.string().nullable(),
7248
- atTime: z18.string().nullable(),
7249
- timezone: z18.string(),
7250
- prompt: z18.string(),
7251
- vars: z18.record(z18.string(), z18.string()).nullable(),
7324
+ var scheduleResponseSchema = z19.object({
7325
+ id: z19.string().uuid(),
7326
+ composeId: z19.string().uuid(),
7327
+ composeName: z19.string(),
7328
+ scopeSlug: z19.string(),
7329
+ name: z19.string(),
7330
+ cronExpression: z19.string().nullable(),
7331
+ atTime: z19.string().nullable(),
7332
+ timezone: z19.string(),
7333
+ prompt: z19.string(),
7334
+ vars: z19.record(z19.string(), z19.string()).nullable(),
7252
7335
  // Secret names only (values are never returned)
7253
- secretNames: z18.array(z18.string()).nullable(),
7254
- artifactName: z18.string().nullable(),
7255
- artifactVersion: z18.string().nullable(),
7256
- volumeVersions: z18.record(z18.string(), z18.string()).nullable(),
7257
- enabled: z18.boolean(),
7258
- nextRunAt: z18.string().nullable(),
7259
- createdAt: z18.string(),
7260
- updatedAt: z18.string()
7261
- });
7262
- var runSummarySchema = z18.object({
7263
- id: z18.string().uuid(),
7264
- status: z18.enum(["pending", "running", "completed", "failed", "timeout"]),
7265
- createdAt: z18.string(),
7266
- completedAt: z18.string().nullable(),
7267
- error: z18.string().nullable()
7268
- });
7269
- var scheduleRunsResponseSchema = z18.object({
7270
- runs: z18.array(runSummarySchema)
7271
- });
7272
- var scheduleListResponseSchema = z18.object({
7273
- schedules: z18.array(scheduleResponseSchema)
7274
- });
7275
- var deployScheduleResponseSchema = z18.object({
7336
+ secretNames: z19.array(z19.string()).nullable(),
7337
+ artifactName: z19.string().nullable(),
7338
+ artifactVersion: z19.string().nullable(),
7339
+ volumeVersions: z19.record(z19.string(), z19.string()).nullable(),
7340
+ enabled: z19.boolean(),
7341
+ nextRunAt: z19.string().nullable(),
7342
+ createdAt: z19.string(),
7343
+ updatedAt: z19.string()
7344
+ });
7345
+ var runSummarySchema = z19.object({
7346
+ id: z19.string().uuid(),
7347
+ status: z19.enum(["pending", "running", "completed", "failed", "timeout"]),
7348
+ createdAt: z19.string(),
7349
+ completedAt: z19.string().nullable(),
7350
+ error: z19.string().nullable()
7351
+ });
7352
+ var scheduleRunsResponseSchema = z19.object({
7353
+ runs: z19.array(runSummarySchema)
7354
+ });
7355
+ var scheduleListResponseSchema = z19.object({
7356
+ schedules: z19.array(scheduleResponseSchema)
7357
+ });
7358
+ var deployScheduleResponseSchema = z19.object({
7276
7359
  schedule: scheduleResponseSchema,
7277
- created: z18.boolean()
7360
+ created: z19.boolean()
7278
7361
  // true if created, false if updated
7279
7362
  });
7280
7363
  var schedulesMainContract = c13.router({
@@ -7324,11 +7407,11 @@ var schedulesByNameContract = c13.router({
7324
7407
  method: "GET",
7325
7408
  path: "/api/agent/schedules/:name",
7326
7409
  headers: authHeadersSchema,
7327
- pathParams: z18.object({
7328
- name: z18.string().min(1, "Schedule name required")
7410
+ pathParams: z19.object({
7411
+ name: z19.string().min(1, "Schedule name required")
7329
7412
  }),
7330
- query: z18.object({
7331
- composeId: z18.string().uuid("Compose ID required")
7413
+ query: z19.object({
7414
+ composeId: z19.string().uuid("Compose ID required")
7332
7415
  }),
7333
7416
  responses: {
7334
7417
  200: scheduleResponseSchema,
@@ -7345,14 +7428,14 @@ var schedulesByNameContract = c13.router({
7345
7428
  method: "DELETE",
7346
7429
  path: "/api/agent/schedules/:name",
7347
7430
  headers: authHeadersSchema,
7348
- pathParams: z18.object({
7349
- name: z18.string().min(1, "Schedule name required")
7431
+ pathParams: z19.object({
7432
+ name: z19.string().min(1, "Schedule name required")
7350
7433
  }),
7351
- query: z18.object({
7352
- composeId: z18.string().uuid("Compose ID required")
7434
+ query: z19.object({
7435
+ composeId: z19.string().uuid("Compose ID required")
7353
7436
  }),
7354
7437
  responses: {
7355
- 204: z18.undefined(),
7438
+ 204: z19.undefined(),
7356
7439
  401: apiErrorSchema,
7357
7440
  404: apiErrorSchema
7358
7441
  },
@@ -7368,11 +7451,11 @@ var schedulesEnableContract = c13.router({
7368
7451
  method: "POST",
7369
7452
  path: "/api/agent/schedules/:name/enable",
7370
7453
  headers: authHeadersSchema,
7371
- pathParams: z18.object({
7372
- name: z18.string().min(1, "Schedule name required")
7454
+ pathParams: z19.object({
7455
+ name: z19.string().min(1, "Schedule name required")
7373
7456
  }),
7374
- body: z18.object({
7375
- composeId: z18.string().uuid("Compose ID required")
7457
+ body: z19.object({
7458
+ composeId: z19.string().uuid("Compose ID required")
7376
7459
  }),
7377
7460
  responses: {
7378
7461
  200: scheduleResponseSchema,
@@ -7389,11 +7472,11 @@ var schedulesEnableContract = c13.router({
7389
7472
  method: "POST",
7390
7473
  path: "/api/agent/schedules/:name/disable",
7391
7474
  headers: authHeadersSchema,
7392
- pathParams: z18.object({
7393
- name: z18.string().min(1, "Schedule name required")
7475
+ pathParams: z19.object({
7476
+ name: z19.string().min(1, "Schedule name required")
7394
7477
  }),
7395
- body: z18.object({
7396
- composeId: z18.string().uuid("Compose ID required")
7478
+ body: z19.object({
7479
+ composeId: z19.string().uuid("Compose ID required")
7397
7480
  }),
7398
7481
  responses: {
7399
7482
  200: scheduleResponseSchema,
@@ -7412,12 +7495,12 @@ var scheduleRunsContract = c13.router({
7412
7495
  method: "GET",
7413
7496
  path: "/api/agent/schedules/:name/runs",
7414
7497
  headers: authHeadersSchema,
7415
- pathParams: z18.object({
7416
- name: z18.string().min(1, "Schedule name required")
7498
+ pathParams: z19.object({
7499
+ name: z19.string().min(1, "Schedule name required")
7417
7500
  }),
7418
- query: z18.object({
7419
- composeId: z18.string().uuid("Compose ID required"),
7420
- limit: z18.coerce.number().min(0).max(100).default(5)
7501
+ query: z19.object({
7502
+ composeId: z19.string().uuid("Compose ID required"),
7503
+ limit: z19.coerce.number().min(0).max(100).default(5)
7421
7504
  }),
7422
7505
  responses: {
7423
7506
  200: scheduleRunsResponseSchema,
@@ -7429,16 +7512,16 @@ var scheduleRunsContract = c13.router({
7429
7512
  });
7430
7513
 
7431
7514
  // ../../packages/core/src/contracts/realtime.ts
7432
- import { z as z19 } from "zod";
7515
+ import { z as z20 } from "zod";
7433
7516
  var c14 = initContract();
7434
- var ablyTokenRequestSchema = z19.object({
7435
- keyName: z19.string(),
7436
- ttl: z19.number().optional(),
7437
- timestamp: z19.number(),
7438
- capability: z19.string(),
7439
- clientId: z19.string().optional(),
7440
- nonce: z19.string(),
7441
- mac: z19.string()
7517
+ var ablyTokenRequestSchema = z20.object({
7518
+ keyName: z20.string(),
7519
+ ttl: z20.number().optional(),
7520
+ timestamp: z20.number(),
7521
+ capability: z20.string(),
7522
+ clientId: z20.string().optional(),
7523
+ nonce: z20.string(),
7524
+ mac: z20.string()
7442
7525
  });
7443
7526
  var realtimeTokenContract = c14.router({
7444
7527
  /**
@@ -7449,8 +7532,8 @@ var realtimeTokenContract = c14.router({
7449
7532
  method: "POST",
7450
7533
  path: "/api/realtime/token",
7451
7534
  headers: authHeadersSchema,
7452
- body: z19.object({
7453
- runId: z19.string().uuid("runId must be a valid UUID")
7535
+ body: z20.object({
7536
+ runId: z20.string().uuid("runId must be a valid UUID")
7454
7537
  }),
7455
7538
  responses: {
7456
7539
  200: ablyTokenRequestSchema,
@@ -7462,13 +7545,34 @@ var realtimeTokenContract = c14.router({
7462
7545
  summary: "Get Ably token for run event subscription"
7463
7546
  }
7464
7547
  });
7548
+ var runnerRealtimeTokenContract = c14.router({
7549
+ /**
7550
+ * POST /api/runners/realtime/token
7551
+ * Get an Ably token to subscribe to a runner group's job notification channel
7552
+ */
7553
+ create: {
7554
+ method: "POST",
7555
+ path: "/api/runners/realtime/token",
7556
+ headers: authHeadersSchema,
7557
+ body: z20.object({
7558
+ group: runnerGroupSchema
7559
+ }),
7560
+ responses: {
7561
+ 200: ablyTokenRequestSchema,
7562
+ 401: apiErrorSchema,
7563
+ 403: apiErrorSchema,
7564
+ 500: apiErrorSchema
7565
+ },
7566
+ summary: "Get Ably token for runner group job notifications"
7567
+ }
7568
+ });
7465
7569
 
7466
7570
  // ../../packages/core/src/contracts/platform.ts
7467
- import { z as z21 } from "zod";
7571
+ import { z as z22 } from "zod";
7468
7572
 
7469
7573
  // ../../packages/core/src/contracts/public/common.ts
7470
- import { z as z20 } from "zod";
7471
- var publicApiErrorTypeSchema = z20.enum([
7574
+ import { z as z21 } from "zod";
7575
+ var publicApiErrorTypeSchema = z21.enum([
7472
7576
  "api_error",
7473
7577
  // Internal server error (5xx)
7474
7578
  "invalid_request_error",
@@ -7482,40 +7586,40 @@ var publicApiErrorTypeSchema = z20.enum([
7482
7586
  "rate_limit_error"
7483
7587
  // Rate limit exceeded (429)
7484
7588
  ]);
7485
- var publicApiErrorSchema = z20.object({
7486
- error: z20.object({
7589
+ var publicApiErrorSchema = z21.object({
7590
+ error: z21.object({
7487
7591
  type: publicApiErrorTypeSchema,
7488
- code: z20.string(),
7489
- message: z20.string(),
7490
- param: z20.string().optional(),
7491
- docUrl: z20.string().url().optional()
7592
+ code: z21.string(),
7593
+ message: z21.string(),
7594
+ param: z21.string().optional(),
7595
+ docUrl: z21.string().url().optional()
7492
7596
  })
7493
7597
  });
7494
- var paginationSchema = z20.object({
7495
- hasMore: z20.boolean(),
7496
- nextCursor: z20.string().nullable()
7598
+ var paginationSchema = z21.object({
7599
+ hasMore: z21.boolean(),
7600
+ nextCursor: z21.string().nullable()
7497
7601
  });
7498
7602
  function createPaginatedResponseSchema(dataSchema) {
7499
- return z20.object({
7500
- data: z20.array(dataSchema),
7603
+ return z21.object({
7604
+ data: z21.array(dataSchema),
7501
7605
  pagination: paginationSchema
7502
7606
  });
7503
7607
  }
7504
- var listQuerySchema = z20.object({
7505
- cursor: z20.string().optional(),
7506
- limit: z20.coerce.number().min(1).max(100).default(20)
7608
+ var listQuerySchema = z21.object({
7609
+ cursor: z21.string().optional(),
7610
+ limit: z21.coerce.number().min(1).max(100).default(20)
7507
7611
  });
7508
- var requestIdSchema = z20.string().uuid();
7509
- var timestampSchema = z20.string().datetime();
7612
+ var requestIdSchema = z21.string().uuid();
7613
+ var timestampSchema = z21.string().datetime();
7510
7614
 
7511
7615
  // ../../packages/core/src/contracts/platform.ts
7512
7616
  var c15 = initContract();
7513
- var platformPaginationSchema = z21.object({
7514
- hasMore: z21.boolean(),
7515
- nextCursor: z21.string().nullable(),
7516
- totalPages: z21.number()
7617
+ var platformPaginationSchema = z22.object({
7618
+ hasMore: z22.boolean(),
7619
+ nextCursor: z22.string().nullable(),
7620
+ totalPages: z22.number()
7517
7621
  });
7518
- var platformLogStatusSchema = z21.enum([
7622
+ var platformLogStatusSchema = z22.enum([
7519
7623
  "pending",
7520
7624
  "running",
7521
7625
  "completed",
@@ -7523,28 +7627,28 @@ var platformLogStatusSchema = z21.enum([
7523
7627
  "timeout",
7524
7628
  "cancelled"
7525
7629
  ]);
7526
- var platformLogEntrySchema = z21.object({
7527
- id: z21.string().uuid()
7630
+ var platformLogEntrySchema = z22.object({
7631
+ id: z22.string().uuid()
7528
7632
  });
7529
- var platformLogsListResponseSchema = z21.object({
7530
- data: z21.array(platformLogEntrySchema),
7633
+ var platformLogsListResponseSchema = z22.object({
7634
+ data: z22.array(platformLogEntrySchema),
7531
7635
  pagination: platformPaginationSchema
7532
7636
  });
7533
- var artifactSchema = z21.object({
7534
- name: z21.string().nullable(),
7535
- version: z21.string().nullable()
7637
+ var artifactSchema = z22.object({
7638
+ name: z22.string().nullable(),
7639
+ version: z22.string().nullable()
7536
7640
  });
7537
- var platformLogDetailSchema = z21.object({
7538
- id: z21.string().uuid(),
7539
- sessionId: z21.string().nullable(),
7540
- agentName: z21.string(),
7541
- framework: z21.string().nullable(),
7641
+ var platformLogDetailSchema = z22.object({
7642
+ id: z22.string().uuid(),
7643
+ sessionId: z22.string().nullable(),
7644
+ agentName: z22.string(),
7645
+ framework: z22.string().nullable(),
7542
7646
  status: platformLogStatusSchema,
7543
- prompt: z21.string(),
7544
- error: z21.string().nullable(),
7545
- createdAt: z21.string(),
7546
- startedAt: z21.string().nullable(),
7547
- completedAt: z21.string().nullable(),
7647
+ prompt: z22.string(),
7648
+ error: z22.string().nullable(),
7649
+ createdAt: z22.string(),
7650
+ startedAt: z22.string().nullable(),
7651
+ completedAt: z22.string().nullable(),
7548
7652
  artifact: artifactSchema
7549
7653
  });
7550
7654
  var platformLogsListContract = c15.router({
@@ -7552,7 +7656,7 @@ var platformLogsListContract = c15.router({
7552
7656
  method: "GET",
7553
7657
  path: "/api/platform/logs",
7554
7658
  query: listQuerySchema.extend({
7555
- search: z21.string().optional()
7659
+ search: z22.string().optional()
7556
7660
  }),
7557
7661
  responses: {
7558
7662
  200: platformLogsListResponseSchema,
@@ -7565,8 +7669,8 @@ var platformLogsByIdContract = c15.router({
7565
7669
  getById: {
7566
7670
  method: "GET",
7567
7671
  path: "/api/platform/logs/:id",
7568
- pathParams: z21.object({
7569
- id: z21.string().uuid("Invalid log ID")
7672
+ pathParams: z22.object({
7673
+ id: z22.string().uuid("Invalid log ID")
7570
7674
  }),
7571
7675
  responses: {
7572
7676
  200: platformLogDetailSchema,
@@ -7576,17 +7680,17 @@ var platformLogsByIdContract = c15.router({
7576
7680
  summary: "Get agent run log details by ID"
7577
7681
  }
7578
7682
  });
7579
- var artifactDownloadResponseSchema = z21.object({
7580
- url: z21.string().url(),
7581
- expiresAt: z21.string()
7683
+ var artifactDownloadResponseSchema = z22.object({
7684
+ url: z22.string().url(),
7685
+ expiresAt: z22.string()
7582
7686
  });
7583
7687
  var platformArtifactDownloadContract = c15.router({
7584
7688
  getDownloadUrl: {
7585
7689
  method: "GET",
7586
7690
  path: "/api/platform/artifacts/download",
7587
- query: z21.object({
7588
- name: z21.string().min(1, "Artifact name is required"),
7589
- version: z21.string().optional()
7691
+ query: z22.object({
7692
+ name: z22.string().min(1, "Artifact name is required"),
7693
+ version: z22.string().optional()
7590
7694
  }),
7591
7695
  responses: {
7592
7696
  200: artifactDownloadResponseSchema,
@@ -7598,26 +7702,26 @@ var platformArtifactDownloadContract = c15.router({
7598
7702
  });
7599
7703
 
7600
7704
  // ../../packages/core/src/contracts/public/agents.ts
7601
- import { z as z22 } from "zod";
7705
+ import { z as z23 } from "zod";
7602
7706
  var c16 = initContract();
7603
- var publicAgentSchema = z22.object({
7604
- id: z22.string(),
7605
- name: z22.string(),
7606
- currentVersionId: z22.string().nullable(),
7707
+ var publicAgentSchema = z23.object({
7708
+ id: z23.string(),
7709
+ name: z23.string(),
7710
+ currentVersionId: z23.string().nullable(),
7607
7711
  createdAt: timestampSchema,
7608
7712
  updatedAt: timestampSchema
7609
7713
  });
7610
- var agentVersionSchema = z22.object({
7611
- id: z22.string(),
7612
- agentId: z22.string(),
7613
- versionNumber: z22.number(),
7714
+ var agentVersionSchema = z23.object({
7715
+ id: z23.string(),
7716
+ agentId: z23.string(),
7717
+ versionNumber: z23.number(),
7614
7718
  createdAt: timestampSchema
7615
7719
  });
7616
7720
  var publicAgentDetailSchema = publicAgentSchema;
7617
7721
  var paginatedAgentsSchema = createPaginatedResponseSchema(publicAgentSchema);
7618
7722
  var paginatedAgentVersionsSchema = createPaginatedResponseSchema(agentVersionSchema);
7619
7723
  var agentListQuerySchema = listQuerySchema.extend({
7620
- name: z22.string().optional()
7724
+ name: z23.string().optional()
7621
7725
  });
7622
7726
  var publicAgentsListContract = c16.router({
7623
7727
  list: {
@@ -7639,8 +7743,8 @@ var publicAgentByIdContract = c16.router({
7639
7743
  method: "GET",
7640
7744
  path: "/v1/agents/:id",
7641
7745
  headers: authHeadersSchema,
7642
- pathParams: z22.object({
7643
- id: z22.string().min(1, "Agent ID is required")
7746
+ pathParams: z23.object({
7747
+ id: z23.string().min(1, "Agent ID is required")
7644
7748
  }),
7645
7749
  responses: {
7646
7750
  200: publicAgentDetailSchema,
@@ -7657,8 +7761,8 @@ var publicAgentVersionsContract = c16.router({
7657
7761
  method: "GET",
7658
7762
  path: "/v1/agents/:id/versions",
7659
7763
  headers: authHeadersSchema,
7660
- pathParams: z22.object({
7661
- id: z22.string().min(1, "Agent ID is required")
7764
+ pathParams: z23.object({
7765
+ id: z23.string().min(1, "Agent ID is required")
7662
7766
  }),
7663
7767
  query: listQuerySchema,
7664
7768
  responses: {
@@ -7673,9 +7777,9 @@ var publicAgentVersionsContract = c16.router({
7673
7777
  });
7674
7778
 
7675
7779
  // ../../packages/core/src/contracts/public/runs.ts
7676
- import { z as z23 } from "zod";
7780
+ import { z as z24 } from "zod";
7677
7781
  var c17 = initContract();
7678
- var publicRunStatusSchema = z23.enum([
7782
+ var publicRunStatusSchema = z24.enum([
7679
7783
  "pending",
7680
7784
  "running",
7681
7785
  "completed",
@@ -7683,48 +7787,48 @@ var publicRunStatusSchema = z23.enum([
7683
7787
  "timeout",
7684
7788
  "cancelled"
7685
7789
  ]);
7686
- var publicRunSchema = z23.object({
7687
- id: z23.string(),
7688
- agentId: z23.string(),
7689
- agentName: z23.string(),
7790
+ var publicRunSchema = z24.object({
7791
+ id: z24.string(),
7792
+ agentId: z24.string(),
7793
+ agentName: z24.string(),
7690
7794
  status: publicRunStatusSchema,
7691
- prompt: z23.string(),
7795
+ prompt: z24.string(),
7692
7796
  createdAt: timestampSchema,
7693
7797
  startedAt: timestampSchema.nullable(),
7694
7798
  completedAt: timestampSchema.nullable()
7695
7799
  });
7696
7800
  var publicRunDetailSchema = publicRunSchema.extend({
7697
- error: z23.string().nullable(),
7698
- executionTimeMs: z23.number().nullable(),
7699
- checkpointId: z23.string().nullable(),
7700
- sessionId: z23.string().nullable(),
7701
- artifactName: z23.string().nullable(),
7702
- artifactVersion: z23.string().nullable(),
7703
- volumes: z23.record(z23.string(), z23.string()).optional()
7801
+ error: z24.string().nullable(),
7802
+ executionTimeMs: z24.number().nullable(),
7803
+ checkpointId: z24.string().nullable(),
7804
+ sessionId: z24.string().nullable(),
7805
+ artifactName: z24.string().nullable(),
7806
+ artifactVersion: z24.string().nullable(),
7807
+ volumes: z24.record(z24.string(), z24.string()).optional()
7704
7808
  });
7705
7809
  var paginatedRunsSchema = createPaginatedResponseSchema(publicRunSchema);
7706
- var createRunRequestSchema = z23.object({
7810
+ var createRunRequestSchema = z24.object({
7707
7811
  // Agent identification (one of: agent, agentId, sessionId, checkpointId)
7708
- agent: z23.string().optional(),
7812
+ agent: z24.string().optional(),
7709
7813
  // Agent name
7710
- agentId: z23.string().optional(),
7814
+ agentId: z24.string().optional(),
7711
7815
  // Agent ID
7712
- agentVersion: z23.string().optional(),
7816
+ agentVersion: z24.string().optional(),
7713
7817
  // Version specifier (e.g., "latest", "v1", specific ID)
7714
7818
  // Continue session
7715
- sessionId: z23.string().optional(),
7819
+ sessionId: z24.string().optional(),
7716
7820
  // Resume from checkpoint
7717
- checkpointId: z23.string().optional(),
7821
+ checkpointId: z24.string().optional(),
7718
7822
  // Required
7719
- prompt: z23.string().min(1, "Prompt is required"),
7823
+ prompt: z24.string().min(1, "Prompt is required"),
7720
7824
  // Optional configuration
7721
- variables: z23.record(z23.string(), z23.string()).optional(),
7722
- secrets: z23.record(z23.string(), z23.string()).optional(),
7723
- artifactName: z23.string().optional(),
7825
+ variables: z24.record(z24.string(), z24.string()).optional(),
7826
+ secrets: z24.record(z24.string(), z24.string()).optional(),
7827
+ artifactName: z24.string().optional(),
7724
7828
  // Artifact name to mount
7725
- artifactVersion: z23.string().optional(),
7829
+ artifactVersion: z24.string().optional(),
7726
7830
  // Artifact version (defaults to latest)
7727
- volumes: z23.record(z23.string(), z23.string()).optional()
7831
+ volumes: z24.record(z24.string(), z24.string()).optional()
7728
7832
  // volume_name -> version
7729
7833
  });
7730
7834
  var runListQuerySchema = listQuerySchema.extend({
@@ -7767,8 +7871,8 @@ var publicRunByIdContract = c17.router({
7767
7871
  method: "GET",
7768
7872
  path: "/v1/runs/:id",
7769
7873
  headers: authHeadersSchema,
7770
- pathParams: z23.object({
7771
- id: z23.string().min(1, "Run ID is required")
7874
+ pathParams: z24.object({
7875
+ id: z24.string().min(1, "Run ID is required")
7772
7876
  }),
7773
7877
  responses: {
7774
7878
  200: publicRunDetailSchema,
@@ -7785,10 +7889,10 @@ var publicRunCancelContract = c17.router({
7785
7889
  method: "POST",
7786
7890
  path: "/v1/runs/:id/cancel",
7787
7891
  headers: authHeadersSchema,
7788
- pathParams: z23.object({
7789
- id: z23.string().min(1, "Run ID is required")
7892
+ pathParams: z24.object({
7893
+ id: z24.string().min(1, "Run ID is required")
7790
7894
  }),
7791
- body: z23.undefined(),
7895
+ body: z24.undefined(),
7792
7896
  responses: {
7793
7897
  200: publicRunDetailSchema,
7794
7898
  400: publicApiErrorSchema,
@@ -7801,27 +7905,27 @@ var publicRunCancelContract = c17.router({
7801
7905
  description: "Cancel a pending or running execution"
7802
7906
  }
7803
7907
  });
7804
- var logEntrySchema = z23.object({
7908
+ var logEntrySchema = z24.object({
7805
7909
  timestamp: timestampSchema,
7806
- type: z23.enum(["agent", "system", "network"]),
7807
- level: z23.enum(["debug", "info", "warn", "error"]),
7808
- message: z23.string(),
7809
- metadata: z23.record(z23.string(), z23.unknown()).optional()
7910
+ type: z24.enum(["agent", "system", "network"]),
7911
+ level: z24.enum(["debug", "info", "warn", "error"]),
7912
+ message: z24.string(),
7913
+ metadata: z24.record(z24.string(), z24.unknown()).optional()
7810
7914
  });
7811
7915
  var paginatedLogsSchema = createPaginatedResponseSchema(logEntrySchema);
7812
7916
  var logsQuerySchema = listQuerySchema.extend({
7813
- type: z23.enum(["agent", "system", "network", "all"]).default("all"),
7917
+ type: z24.enum(["agent", "system", "network", "all"]).default("all"),
7814
7918
  since: timestampSchema.optional(),
7815
7919
  until: timestampSchema.optional(),
7816
- order: z23.enum(["asc", "desc"]).default("asc")
7920
+ order: z24.enum(["asc", "desc"]).default("asc")
7817
7921
  });
7818
7922
  var publicRunLogsContract = c17.router({
7819
7923
  getLogs: {
7820
7924
  method: "GET",
7821
7925
  path: "/v1/runs/:id/logs",
7822
7926
  headers: authHeadersSchema,
7823
- pathParams: z23.object({
7824
- id: z23.string().min(1, "Run ID is required")
7927
+ pathParams: z24.object({
7928
+ id: z24.string().min(1, "Run ID is required")
7825
7929
  }),
7826
7930
  query: logsQuerySchema,
7827
7931
  responses: {
@@ -7834,21 +7938,21 @@ var publicRunLogsContract = c17.router({
7834
7938
  description: "Get unified logs for a run. Combines agent, system, and network logs."
7835
7939
  }
7836
7940
  });
7837
- var metricPointSchema = z23.object({
7941
+ var metricPointSchema = z24.object({
7838
7942
  timestamp: timestampSchema,
7839
- cpuPercent: z23.number(),
7840
- memoryUsedMb: z23.number(),
7841
- memoryTotalMb: z23.number(),
7842
- diskUsedMb: z23.number(),
7843
- diskTotalMb: z23.number()
7844
- });
7845
- var metricsSummarySchema = z23.object({
7846
- avgCpuPercent: z23.number(),
7847
- maxMemoryUsedMb: z23.number(),
7848
- totalDurationMs: z23.number().nullable()
7849
- });
7850
- var metricsResponseSchema2 = z23.object({
7851
- data: z23.array(metricPointSchema),
7943
+ cpuPercent: z24.number(),
7944
+ memoryUsedMb: z24.number(),
7945
+ memoryTotalMb: z24.number(),
7946
+ diskUsedMb: z24.number(),
7947
+ diskTotalMb: z24.number()
7948
+ });
7949
+ var metricsSummarySchema = z24.object({
7950
+ avgCpuPercent: z24.number(),
7951
+ maxMemoryUsedMb: z24.number(),
7952
+ totalDurationMs: z24.number().nullable()
7953
+ });
7954
+ var metricsResponseSchema2 = z24.object({
7955
+ data: z24.array(metricPointSchema),
7852
7956
  summary: metricsSummarySchema
7853
7957
  });
7854
7958
  var publicRunMetricsContract = c17.router({
@@ -7856,8 +7960,8 @@ var publicRunMetricsContract = c17.router({
7856
7960
  method: "GET",
7857
7961
  path: "/v1/runs/:id/metrics",
7858
7962
  headers: authHeadersSchema,
7859
- pathParams: z23.object({
7860
- id: z23.string().min(1, "Run ID is required")
7963
+ pathParams: z24.object({
7964
+ id: z24.string().min(1, "Run ID is required")
7861
7965
  }),
7862
7966
  responses: {
7863
7967
  200: metricsResponseSchema2,
@@ -7869,7 +7973,7 @@ var publicRunMetricsContract = c17.router({
7869
7973
  description: "Get CPU, memory, and disk metrics for a run"
7870
7974
  }
7871
7975
  });
7872
- var sseEventTypeSchema = z23.enum([
7976
+ var sseEventTypeSchema = z24.enum([
7873
7977
  "status",
7874
7978
  // Run status change
7875
7979
  "output",
@@ -7881,10 +7985,10 @@ var sseEventTypeSchema = z23.enum([
7881
7985
  "heartbeat"
7882
7986
  // Keep-alive
7883
7987
  ]);
7884
- var sseEventSchema = z23.object({
7988
+ var sseEventSchema = z24.object({
7885
7989
  event: sseEventTypeSchema,
7886
- data: z23.unknown(),
7887
- id: z23.string().optional()
7990
+ data: z24.unknown(),
7991
+ id: z24.string().optional()
7888
7992
  // For Last-Event-ID reconnection
7889
7993
  });
7890
7994
  var publicRunEventsContract = c17.router({
@@ -7892,15 +7996,15 @@ var publicRunEventsContract = c17.router({
7892
7996
  method: "GET",
7893
7997
  path: "/v1/runs/:id/events",
7894
7998
  headers: authHeadersSchema,
7895
- pathParams: z23.object({
7896
- id: z23.string().min(1, "Run ID is required")
7999
+ pathParams: z24.object({
8000
+ id: z24.string().min(1, "Run ID is required")
7897
8001
  }),
7898
- query: z23.object({
7899
- lastEventId: z23.string().optional()
8002
+ query: z24.object({
8003
+ lastEventId: z24.string().optional()
7900
8004
  // For reconnection
7901
8005
  }),
7902
8006
  responses: {
7903
- 200: z23.any(),
8007
+ 200: z24.any(),
7904
8008
  // SSE stream - actual content is text/event-stream
7905
8009
  401: publicApiErrorSchema,
7906
8010
  404: publicApiErrorSchema,
@@ -7912,28 +8016,28 @@ var publicRunEventsContract = c17.router({
7912
8016
  });
7913
8017
 
7914
8018
  // ../../packages/core/src/contracts/public/artifacts.ts
7915
- import { z as z24 } from "zod";
8019
+ import { z as z25 } from "zod";
7916
8020
  var c18 = initContract();
7917
- var publicArtifactSchema = z24.object({
7918
- id: z24.string(),
7919
- name: z24.string(),
7920
- currentVersionId: z24.string().nullable(),
7921
- size: z24.number(),
8021
+ var publicArtifactSchema = z25.object({
8022
+ id: z25.string(),
8023
+ name: z25.string(),
8024
+ currentVersionId: z25.string().nullable(),
8025
+ size: z25.number(),
7922
8026
  // Total size in bytes
7923
- fileCount: z24.number(),
8027
+ fileCount: z25.number(),
7924
8028
  createdAt: timestampSchema,
7925
8029
  updatedAt: timestampSchema
7926
8030
  });
7927
- var artifactVersionSchema = z24.object({
7928
- id: z24.string(),
8031
+ var artifactVersionSchema = z25.object({
8032
+ id: z25.string(),
7929
8033
  // SHA-256 content hash
7930
- artifactId: z24.string(),
7931
- size: z24.number(),
8034
+ artifactId: z25.string(),
8035
+ size: z25.number(),
7932
8036
  // Size in bytes
7933
- fileCount: z24.number(),
7934
- message: z24.string().nullable(),
8037
+ fileCount: z25.number(),
8038
+ message: z25.string().nullable(),
7935
8039
  // Optional commit message
7936
- createdBy: z24.string(),
8040
+ createdBy: z25.string(),
7937
8041
  createdAt: timestampSchema
7938
8042
  });
7939
8043
  var publicArtifactDetailSchema = publicArtifactSchema.extend({
@@ -7963,8 +8067,8 @@ var publicArtifactByIdContract = c18.router({
7963
8067
  method: "GET",
7964
8068
  path: "/v1/artifacts/:id",
7965
8069
  headers: authHeadersSchema,
7966
- pathParams: z24.object({
7967
- id: z24.string().min(1, "Artifact ID is required")
8070
+ pathParams: z25.object({
8071
+ id: z25.string().min(1, "Artifact ID is required")
7968
8072
  }),
7969
8073
  responses: {
7970
8074
  200: publicArtifactDetailSchema,
@@ -7981,8 +8085,8 @@ var publicArtifactVersionsContract = c18.router({
7981
8085
  method: "GET",
7982
8086
  path: "/v1/artifacts/:id/versions",
7983
8087
  headers: authHeadersSchema,
7984
- pathParams: z24.object({
7985
- id: z24.string().min(1, "Artifact ID is required")
8088
+ pathParams: z25.object({
8089
+ id: z25.string().min(1, "Artifact ID is required")
7986
8090
  }),
7987
8091
  query: listQuerySchema,
7988
8092
  responses: {
@@ -8000,15 +8104,15 @@ var publicArtifactDownloadContract = c18.router({
8000
8104
  method: "GET",
8001
8105
  path: "/v1/artifacts/:id/download",
8002
8106
  headers: authHeadersSchema,
8003
- pathParams: z24.object({
8004
- id: z24.string().min(1, "Artifact ID is required")
8107
+ pathParams: z25.object({
8108
+ id: z25.string().min(1, "Artifact ID is required")
8005
8109
  }),
8006
- query: z24.object({
8007
- versionId: z24.string().optional()
8110
+ query: z25.object({
8111
+ versionId: z25.string().optional()
8008
8112
  // Defaults to current version
8009
8113
  }),
8010
8114
  responses: {
8011
- 302: z24.undefined(),
8115
+ 302: z25.undefined(),
8012
8116
  // Redirect to presigned URL
8013
8117
  401: publicApiErrorSchema,
8014
8118
  404: publicApiErrorSchema,
@@ -8020,28 +8124,28 @@ var publicArtifactDownloadContract = c18.router({
8020
8124
  });
8021
8125
 
8022
8126
  // ../../packages/core/src/contracts/public/volumes.ts
8023
- import { z as z25 } from "zod";
8127
+ import { z as z26 } from "zod";
8024
8128
  var c19 = initContract();
8025
- var publicVolumeSchema = z25.object({
8026
- id: z25.string(),
8027
- name: z25.string(),
8028
- currentVersionId: z25.string().nullable(),
8029
- size: z25.number(),
8129
+ var publicVolumeSchema = z26.object({
8130
+ id: z26.string(),
8131
+ name: z26.string(),
8132
+ currentVersionId: z26.string().nullable(),
8133
+ size: z26.number(),
8030
8134
  // Total size in bytes
8031
- fileCount: z25.number(),
8135
+ fileCount: z26.number(),
8032
8136
  createdAt: timestampSchema,
8033
8137
  updatedAt: timestampSchema
8034
8138
  });
8035
- var volumeVersionSchema = z25.object({
8036
- id: z25.string(),
8139
+ var volumeVersionSchema = z26.object({
8140
+ id: z26.string(),
8037
8141
  // SHA-256 content hash
8038
- volumeId: z25.string(),
8039
- size: z25.number(),
8142
+ volumeId: z26.string(),
8143
+ size: z26.number(),
8040
8144
  // Size in bytes
8041
- fileCount: z25.number(),
8042
- message: z25.string().nullable(),
8145
+ fileCount: z26.number(),
8146
+ message: z26.string().nullable(),
8043
8147
  // Optional commit message
8044
- createdBy: z25.string(),
8148
+ createdBy: z26.string(),
8045
8149
  createdAt: timestampSchema
8046
8150
  });
8047
8151
  var publicVolumeDetailSchema = publicVolumeSchema.extend({
@@ -8069,8 +8173,8 @@ var publicVolumeByIdContract = c19.router({
8069
8173
  method: "GET",
8070
8174
  path: "/v1/volumes/:id",
8071
8175
  headers: authHeadersSchema,
8072
- pathParams: z25.object({
8073
- id: z25.string().min(1, "Volume ID is required")
8176
+ pathParams: z26.object({
8177
+ id: z26.string().min(1, "Volume ID is required")
8074
8178
  }),
8075
8179
  responses: {
8076
8180
  200: publicVolumeDetailSchema,
@@ -8087,8 +8191,8 @@ var publicVolumeVersionsContract = c19.router({
8087
8191
  method: "GET",
8088
8192
  path: "/v1/volumes/:id/versions",
8089
8193
  headers: authHeadersSchema,
8090
- pathParams: z25.object({
8091
- id: z25.string().min(1, "Volume ID is required")
8194
+ pathParams: z26.object({
8195
+ id: z26.string().min(1, "Volume ID is required")
8092
8196
  }),
8093
8197
  query: listQuerySchema,
8094
8198
  responses: {
@@ -8106,15 +8210,15 @@ var publicVolumeDownloadContract = c19.router({
8106
8210
  method: "GET",
8107
8211
  path: "/v1/volumes/:id/download",
8108
8212
  headers: authHeadersSchema,
8109
- pathParams: z25.object({
8110
- id: z25.string().min(1, "Volume ID is required")
8213
+ pathParams: z26.object({
8214
+ id: z26.string().min(1, "Volume ID is required")
8111
8215
  }),
8112
- query: z25.object({
8113
- versionId: z25.string().optional()
8216
+ query: z26.object({
8217
+ versionId: z26.string().optional()
8114
8218
  // Defaults to current version
8115
8219
  }),
8116
8220
  responses: {
8117
- 302: z25.undefined(),
8221
+ 302: z26.undefined(),
8118
8222
  // Redirect to presigned URL
8119
8223
  401: publicApiErrorSchema,
8120
8224
  404: publicApiErrorSchema,
@@ -9743,18 +9847,27 @@ function setupSignalHandlers(state, handlers) {
9743
9847
  );
9744
9848
  state.mode = "draining";
9745
9849
  handlers.updateStatus();
9850
+ handlers.onDrain();
9746
9851
  }
9747
9852
  });
9748
9853
  }
9749
9854
 
9750
9855
  // src/lib/runner/runner.ts
9751
- var Runner = class {
9856
+ var Runner = class _Runner {
9752
9857
  config;
9753
9858
  statusFilePath;
9754
9859
  state;
9755
9860
  resources = null;
9756
- running = true;
9757
9861
  updateStatus;
9862
+ // Ably subscription
9863
+ subscription = null;
9864
+ // Queue for jobs received while at capacity (max 100 to prevent unbounded growth)
9865
+ static MAX_PENDING_QUEUE_SIZE = 100;
9866
+ pendingJobs = [];
9867
+ // Polling fallback interval
9868
+ pollInterval = null;
9869
+ // Shutdown coordination
9870
+ resolveShutdown = null;
9758
9871
  constructor(config, statusFilePath) {
9759
9872
  this.config = config;
9760
9873
  this.statusFilePath = statusFilePath;
@@ -9768,9 +9881,19 @@ var Runner = class {
9768
9881
  }
9769
9882
  async start() {
9770
9883
  this.resources = await setupEnvironment({ config: this.config });
9884
+ const shutdownPromise = new Promise((resolve) => {
9885
+ this.resolveShutdown = resolve;
9886
+ });
9771
9887
  setupSignalHandlers(this.state, {
9772
9888
  onShutdown: () => {
9773
- this.running = false;
9889
+ this.resolveShutdown?.();
9890
+ },
9891
+ onDrain: () => {
9892
+ this.pendingJobs.length = 0;
9893
+ if (this.state.activeRuns.size === 0) {
9894
+ console.log("[Maintenance] No active jobs, exiting immediately");
9895
+ this.resolveShutdown?.();
9896
+ }
9774
9897
  },
9775
9898
  updateStatus: this.updateStatus
9776
9899
  });
@@ -9782,7 +9905,36 @@ var Runner = class {
9782
9905
  console.log("Press Ctrl+C to stop");
9783
9906
  console.log("");
9784
9907
  this.updateStatus();
9785
- await this.runMainLoop();
9908
+ console.log("Checking for pending jobs...");
9909
+ await this.pollFallback();
9910
+ console.log("Connecting to realtime job notifications...");
9911
+ this.subscription = await subscribeToJobs(
9912
+ this.config.server,
9913
+ this.config.group,
9914
+ (notification) => {
9915
+ console.log(`Ably notification: ${notification.runId}`);
9916
+ this.processJob(notification.runId).catch(console.error);
9917
+ },
9918
+ (connectionState, reason) => {
9919
+ console.log(
9920
+ `Ably connection: ${connectionState}${reason ? ` (${reason})` : ""}`
9921
+ );
9922
+ }
9923
+ );
9924
+ console.log("Connected to realtime job notifications");
9925
+ this.pollInterval = setInterval(() => {
9926
+ this.pollFallback().catch(console.error);
9927
+ }, this.config.sandbox.poll_interval_ms);
9928
+ console.log(
9929
+ `Polling fallback enabled (every ${this.config.sandbox.poll_interval_ms / 1e3}s)`
9930
+ );
9931
+ await shutdownPromise;
9932
+ if (this.pollInterval) {
9933
+ clearInterval(this.pollInterval);
9934
+ }
9935
+ if (this.subscription) {
9936
+ this.subscription.cleanup();
9937
+ }
9786
9938
  if (this.state.jobPromises.size > 0) {
9787
9939
  console.log(
9788
9940
  `Waiting for ${this.state.jobPromises.size} active job(s) to complete...`
@@ -9795,50 +9947,52 @@ var Runner = class {
9795
9947
  console.log("Runner stopped");
9796
9948
  process.exit(0);
9797
9949
  }
9798
- async runMainLoop() {
9799
- while (this.running) {
9800
- if (this.state.mode === "draining") {
9801
- if (this.state.activeRuns.size === 0) {
9802
- console.log("[Maintenance] All jobs completed, exiting drain mode");
9803
- this.running = false;
9804
- break;
9805
- }
9806
- if (this.state.jobPromises.size > 0) {
9807
- await Promise.race(this.state.jobPromises);
9808
- this.updateStatus();
9809
- }
9810
- continue;
9811
- }
9812
- if (this.state.activeRuns.size >= this.config.sandbox.max_concurrent) {
9813
- if (this.state.jobPromises.size > 0) {
9814
- await Promise.race(this.state.jobPromises);
9815
- this.updateStatus();
9816
- }
9817
- continue;
9818
- }
9819
- try {
9820
- const job = await withRunnerTiming(
9821
- "poll",
9822
- () => pollForJob(this.config.server, this.config.group)
9823
- );
9824
- if (!job) {
9825
- await new Promise(
9826
- (resolve) => setTimeout(resolve, this.config.sandbox.poll_interval_ms)
9827
- );
9828
- continue;
9829
- }
9830
- console.log(`Found job: ${job.runId}`);
9950
+ /**
9951
+ * Poll for jobs as fallback mechanism.
9952
+ * Catches jobs that may have been missed by push notifications.
9953
+ */
9954
+ async pollFallback() {
9955
+ if (this.state.mode !== "running") return;
9956
+ if (this.state.activeRuns.size >= this.config.sandbox.max_concurrent)
9957
+ return;
9958
+ try {
9959
+ const job = await withRunnerTiming(
9960
+ "poll",
9961
+ () => pollForJob(this.config.server, this.config.group)
9962
+ );
9963
+ if (job) {
9964
+ console.log(`Poll fallback found job: ${job.runId}`);
9831
9965
  await this.processJob(job.runId);
9832
- } catch (error) {
9833
- console.error(
9834
- "Polling error:",
9835
- error instanceof Error ? error.message : "Unknown error"
9836
- );
9837
- await new Promise((resolve) => setTimeout(resolve, 2e3));
9838
9966
  }
9967
+ } catch (error) {
9968
+ console.error(
9969
+ `Poll fallback error:`,
9970
+ error instanceof Error ? error.message : "Unknown error"
9971
+ );
9839
9972
  }
9840
9973
  }
9974
+ /**
9975
+ * Process a job notification - claim and execute.
9976
+ */
9841
9977
  async processJob(runId) {
9978
+ if (this.state.mode !== "running") {
9979
+ console.log(`Not running (${this.state.mode}), ignoring job ${runId}`);
9980
+ return;
9981
+ }
9982
+ if (this.state.activeRuns.has(runId)) {
9983
+ return;
9984
+ }
9985
+ if (this.state.activeRuns.size >= this.config.sandbox.max_concurrent) {
9986
+ if (!this.pendingJobs.includes(runId) && this.pendingJobs.length < _Runner.MAX_PENDING_QUEUE_SIZE) {
9987
+ console.log(`At capacity, queueing job ${runId}`);
9988
+ this.pendingJobs.push(runId);
9989
+ } else if (this.pendingJobs.length >= _Runner.MAX_PENDING_QUEUE_SIZE) {
9990
+ console.log(
9991
+ `Pending queue full (${_Runner.MAX_PENDING_QUEUE_SIZE}), dropping job ${runId}`
9992
+ );
9993
+ }
9994
+ return;
9995
+ }
9842
9996
  try {
9843
9997
  const context = await withRunnerTiming(
9844
9998
  "claim",
@@ -9856,6 +10010,17 @@ var Runner = class {
9856
10010
  this.state.activeRuns.delete(context.runId);
9857
10011
  this.state.jobPromises.delete(jobPromise);
9858
10012
  this.updateStatus();
10013
+ if (this.state.mode === "draining" && this.state.activeRuns.size === 0) {
10014
+ console.log("[Maintenance] All jobs completed, exiting");
10015
+ this.resolveShutdown?.();
10016
+ return;
10017
+ }
10018
+ if (this.pendingJobs.length > 0 && this.state.mode === "running") {
10019
+ const nextJob = this.pendingJobs.shift();
10020
+ if (nextJob) {
10021
+ this.processJob(nextJob).catch(console.error);
10022
+ }
10023
+ }
9859
10024
  });
9860
10025
  this.state.jobPromises.add(jobPromise);
9861
10026
  } catch (error) {
@@ -10494,7 +10659,7 @@ var benchmarkCommand = new Command4("benchmark").description(
10494
10659
  });
10495
10660
 
10496
10661
  // src/index.ts
10497
- var version = true ? "3.3.2" : "0.1.0";
10662
+ var version = true ? "3.4.0" : "0.1.0";
10498
10663
  program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
10499
10664
  program.addCommand(startCommand);
10500
10665
  program.addCommand(doctorCommand);