@vm0/runner 3.3.2 → 3.5.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 +1108 -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,69 @@ 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
+ // Dispatch timestamp for E2E timing metrics
5632
+ apiStartTime: z6.number().optional()
5633
+ });
5634
+ var executionContextSchema = z6.object({
5635
+ runId: z6.string().uuid(),
5636
+ prompt: z6.string(),
5637
+ agentComposeVersionId: z6.string(),
5638
+ vars: z6.record(z6.string(), z6.string()).nullable(),
5639
+ secretNames: z6.array(z6.string()).nullable(),
5640
+ checkpointId: z6.string().uuid().nullable(),
5641
+ sandboxToken: z6.string(),
5556
5642
  // New fields for E2B parity:
5557
- workingDir: z5.string(),
5643
+ workingDir: z6.string(),
5558
5644
  storageManifest: storageManifestSchema.nullable(),
5559
- environment: z5.record(z5.string(), z5.string()).nullable(),
5645
+ environment: z6.record(z6.string(), z6.string()).nullable(),
5560
5646
  resumeSession: resumeSessionSchema.nullable(),
5561
- secretValues: z5.array(z5.string()).nullable(),
5562
- cliAgentType: z5.string(),
5647
+ secretValues: z6.array(z6.string()).nullable(),
5648
+ cliAgentType: z6.string(),
5563
5649
  // Experimental firewall configuration
5564
5650
  experimentalFirewall: experimentalFirewallSchema.optional(),
5565
5651
  // Debug flag to force real Claude in mock environments (internal use only)
5566
- debugNoMockClaude: z5.boolean().optional()
5652
+ debugNoMockClaude: z6.boolean().optional(),
5653
+ // Dispatch timestamp for E2E timing metrics
5654
+ apiStartTime: z6.number().optional()
5567
5655
  });
5568
5656
  var runnersJobClaimContract = c.router({
5569
5657
  claim: {
5570
5658
  method: "POST",
5571
5659
  path: "/api/runners/jobs/:id/claim",
5572
5660
  headers: authHeadersSchema,
5573
- pathParams: z5.object({
5574
- id: z5.string().uuid()
5661
+ pathParams: z6.object({
5662
+ id: z6.string().uuid()
5575
5663
  }),
5576
- body: z5.object({}),
5664
+ body: z6.object({}),
5577
5665
  responses: {
5578
5666
  200: executionContextSchema,
5579
5667
  400: apiErrorSchema,
@@ -5591,75 +5679,75 @@ var runnersJobClaimContract = c.router({
5591
5679
 
5592
5680
  // ../../packages/core/src/contracts/composes.ts
5593
5681
  var c2 = initContract();
5594
- var composeVersionQuerySchema = z6.preprocess(
5682
+ var composeVersionQuerySchema = z7.preprocess(
5595
5683
  (val) => val === void 0 || val === null ? void 0 : String(val),
5596
- z6.string().min(1, "Missing version query parameter").regex(
5684
+ z7.string().min(1, "Missing version query parameter").regex(
5597
5685
  /^[a-f0-9]{8,64}$|^latest$/i,
5598
5686
  "Version must be 8-64 hex characters or 'latest'"
5599
5687
  )
5600
5688
  );
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(
5689
+ 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
5690
  /^[a-zA-Z0-9][a-zA-Z0-9-]{1,62}[a-zA-Z0-9]$/,
5603
5691
  "Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
5604
5692
  );
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")
5693
+ var volumeConfigSchema = z7.object({
5694
+ name: z7.string().min(1, "Volume name is required"),
5695
+ version: z7.string().min(1, "Volume version is required")
5608
5696
  });
5609
5697
  var SUPPORTED_APPS = ["github"];
5610
5698
  var SUPPORTED_APP_TAGS = ["latest", "dev"];
5611
5699
  var APP_NAME_REGEX = /^[a-z0-9-]+$/;
5612
- var appStringSchema = z6.string().superRefine((val, ctx) => {
5700
+ var appStringSchema = z7.string().superRefine((val, ctx) => {
5613
5701
  const [appName, tag] = val.split(":");
5614
5702
  if (!appName || !APP_NAME_REGEX.test(appName)) {
5615
5703
  ctx.addIssue({
5616
- code: z6.ZodIssueCode.custom,
5704
+ code: z7.ZodIssueCode.custom,
5617
5705
  message: "App name must contain only lowercase letters, numbers, and hyphens"
5618
5706
  });
5619
5707
  return;
5620
5708
  }
5621
5709
  if (!SUPPORTED_APPS.includes(appName)) {
5622
5710
  ctx.addIssue({
5623
- code: z6.ZodIssueCode.custom,
5711
+ code: z7.ZodIssueCode.custom,
5624
5712
  message: `Invalid app: "${appName}". Supported apps: ${SUPPORTED_APPS.join(", ")}`
5625
5713
  });
5626
5714
  return;
5627
5715
  }
5628
5716
  if (tag !== void 0 && !SUPPORTED_APP_TAGS.includes(tag)) {
5629
5717
  ctx.addIssue({
5630
- code: z6.ZodIssueCode.custom,
5718
+ code: z7.ZodIssueCode.custom,
5631
5719
  message: `Invalid app tag: "${tag}". Supported tags: ${SUPPORTED_APP_TAGS.join(", ")}`
5632
5720
  });
5633
5721
  }
5634
5722
  });
5635
- var agentDefinitionSchema = z6.object({
5636
- description: z6.string().optional(),
5637
- framework: z6.string().min(1, "Framework is required"),
5723
+ var agentDefinitionSchema = z7.object({
5724
+ description: z7.string().optional(),
5725
+ framework: z7.string().min(1, "Framework is required"),
5638
5726
  /**
5639
5727
  * Array of pre-installed apps/tools for the agent environment.
5640
5728
  * Format: "app" or "app:tag" (e.g., "github", "github:dev", "github:latest")
5641
5729
  * Default tag is "latest" if not specified.
5642
5730
  * Currently supported apps: "github" (includes GitHub CLI)
5643
5731
  */
5644
- apps: z6.array(appStringSchema).optional(),
5645
- volumes: z6.array(z6.string()).optional(),
5646
- environment: z6.record(z6.string(), z6.string()).optional(),
5732
+ apps: z7.array(appStringSchema).optional(),
5733
+ volumes: z7.array(z7.string()).optional(),
5734
+ environment: z7.record(z7.string(), z7.string()).optional(),
5647
5735
  /**
5648
5736
  * Path to instructions file (e.g., AGENTS.md).
5649
5737
  * Auto-uploaded as volume and mounted at /home/user/.claude/CLAUDE.md
5650
5738
  */
5651
- instructions: z6.string().min(1, "Instructions path cannot be empty").optional(),
5739
+ instructions: z7.string().min(1, "Instructions path cannot be empty").optional(),
5652
5740
  /**
5653
5741
  * Array of GitHub tree URLs for agent skills.
5654
5742
  * Each skill is auto-downloaded and mounted at /home/user/.claude/skills/{skillName}/
5655
5743
  */
5656
- skills: z6.array(z6.string()).optional(),
5744
+ skills: z7.array(z7.string()).optional(),
5657
5745
  /**
5658
5746
  * Route this agent to a self-hosted runner instead of E2B.
5659
5747
  * When specified, runs will be queued for the specified runner group.
5660
5748
  */
5661
- experimental_runner: z6.object({
5662
- group: z6.string().regex(
5749
+ experimental_runner: z7.object({
5750
+ group: z7.string().regex(
5663
5751
  /^[a-z0-9-]+\/[a-z0-9-]+$/,
5664
5752
  "Runner group must be in scope/name format (e.g., acme/production)"
5665
5753
  )
@@ -5674,32 +5762,32 @@ var agentDefinitionSchema = z6.object({
5674
5762
  * @deprecated Server-resolved field. User input is ignored.
5675
5763
  * @internal
5676
5764
  */
5677
- image: z6.string().optional(),
5765
+ image: z7.string().optional(),
5678
5766
  /**
5679
5767
  * @deprecated Server-resolved field. User input is ignored.
5680
5768
  * @internal
5681
5769
  */
5682
- working_dir: z6.string().optional()
5770
+ working_dir: z7.string().optional()
5683
5771
  });
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()
5772
+ var agentComposeContentSchema = z7.object({
5773
+ version: z7.string().min(1, "Version is required"),
5774
+ agents: z7.record(z7.string(), agentDefinitionSchema),
5775
+ volumes: z7.record(z7.string(), volumeConfigSchema).optional()
5688
5776
  });
5689
- var composeResponseSchema = z6.object({
5690
- id: z6.string(),
5691
- name: z6.string(),
5692
- headVersionId: z6.string().nullable(),
5777
+ var composeResponseSchema = z7.object({
5778
+ id: z7.string(),
5779
+ name: z7.string(),
5780
+ headVersionId: z7.string().nullable(),
5693
5781
  content: agentComposeContentSchema.nullable(),
5694
- createdAt: z6.string(),
5695
- updatedAt: z6.string()
5782
+ createdAt: z7.string(),
5783
+ updatedAt: z7.string()
5696
5784
  });
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()
5785
+ var createComposeResponseSchema = z7.object({
5786
+ composeId: z7.string(),
5787
+ name: z7.string(),
5788
+ versionId: z7.string(),
5789
+ action: z7.enum(["created", "existing"]),
5790
+ updatedAt: z7.string()
5703
5791
  });
5704
5792
  var composesMainContract = c2.router({
5705
5793
  /**
@@ -5711,9 +5799,9 @@ var composesMainContract = c2.router({
5711
5799
  method: "GET",
5712
5800
  path: "/api/agent/composes",
5713
5801
  headers: authHeadersSchema,
5714
- query: z6.object({
5715
- name: z6.string().min(1, "Missing name query parameter"),
5716
- scope: z6.string().optional()
5802
+ query: z7.object({
5803
+ name: z7.string().min(1, "Missing name query parameter"),
5804
+ scope: z7.string().optional()
5717
5805
  }),
5718
5806
  responses: {
5719
5807
  200: composeResponseSchema,
@@ -5733,7 +5821,7 @@ var composesMainContract = c2.router({
5733
5821
  method: "POST",
5734
5822
  path: "/api/agent/composes",
5735
5823
  headers: authHeadersSchema,
5736
- body: z6.object({
5824
+ body: z7.object({
5737
5825
  content: agentComposeContentSchema
5738
5826
  }),
5739
5827
  responses: {
@@ -5754,8 +5842,8 @@ var composesByIdContract = c2.router({
5754
5842
  method: "GET",
5755
5843
  path: "/api/agent/composes/:id",
5756
5844
  headers: authHeadersSchema,
5757
- pathParams: z6.object({
5758
- id: z6.string().min(1, "Compose ID is required")
5845
+ pathParams: z7.object({
5846
+ id: z7.string().min(1, "Compose ID is required")
5759
5847
  }),
5760
5848
  responses: {
5761
5849
  200: composeResponseSchema,
@@ -5774,14 +5862,14 @@ var composesVersionsContract = c2.router({
5774
5862
  method: "GET",
5775
5863
  path: "/api/agent/composes/versions",
5776
5864
  headers: authHeadersSchema,
5777
- query: z6.object({
5778
- composeId: z6.string().min(1, "Missing composeId query parameter"),
5865
+ query: z7.object({
5866
+ composeId: z7.string().min(1, "Missing composeId query parameter"),
5779
5867
  version: composeVersionQuerySchema
5780
5868
  }),
5781
5869
  responses: {
5782
- 200: z6.object({
5783
- versionId: z6.string(),
5784
- tag: z6.string().optional()
5870
+ 200: z7.object({
5871
+ versionId: z7.string(),
5872
+ tag: z7.string().optional()
5785
5873
  }),
5786
5874
  400: apiErrorSchema,
5787
5875
  401: apiErrorSchema,
@@ -5790,10 +5878,10 @@ var composesVersionsContract = c2.router({
5790
5878
  summary: "Resolve version specifier to full version ID"
5791
5879
  }
5792
5880
  });
5793
- var composeListItemSchema = z6.object({
5794
- name: z6.string(),
5795
- headVersionId: z6.string().nullable(),
5796
- updatedAt: z6.string()
5881
+ var composeListItemSchema = z7.object({
5882
+ name: z7.string(),
5883
+ headVersionId: z7.string().nullable(),
5884
+ updatedAt: z7.string()
5797
5885
  });
5798
5886
  var composesListContract = c2.router({
5799
5887
  /**
@@ -5805,12 +5893,12 @@ var composesListContract = c2.router({
5805
5893
  method: "GET",
5806
5894
  path: "/api/agent/composes/list",
5807
5895
  headers: authHeadersSchema,
5808
- query: z6.object({
5809
- scope: z6.string().optional()
5896
+ query: z7.object({
5897
+ scope: z7.string().optional()
5810
5898
  }),
5811
5899
  responses: {
5812
- 200: z6.object({
5813
- composes: z6.array(composeListItemSchema)
5900
+ 200: z7.object({
5901
+ composes: z7.array(composeListItemSchema)
5814
5902
  }),
5815
5903
  400: apiErrorSchema,
5816
5904
  401: apiErrorSchema
@@ -5820,87 +5908,116 @@ var composesListContract = c2.router({
5820
5908
  });
5821
5909
 
5822
5910
  // ../../packages/core/src/contracts/runs.ts
5823
- import { z as z7 } from "zod";
5911
+ import { z as z8 } from "zod";
5824
5912
  var c3 = initContract();
5825
- var runStatusSchema = z7.enum([
5913
+ var runStatusSchema = z8.enum([
5826
5914
  "pending",
5827
5915
  "running",
5828
5916
  "completed",
5829
5917
  "failed",
5830
5918
  "timeout"
5831
5919
  ]);
5832
- var unifiedRunRequestSchema = z7.object({
5920
+ var unifiedRunRequestSchema = z8.object({
5833
5921
  // High-level shortcuts (mutually exclusive with each other)
5834
- checkpointId: z7.string().optional(),
5835
- sessionId: z7.string().optional(),
5922
+ checkpointId: z8.string().optional(),
5923
+ sessionId: z8.string().optional(),
5836
5924
  // 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(),
5925
+ agentComposeId: z8.string().optional(),
5926
+ agentComposeVersionId: z8.string().optional(),
5927
+ conversationId: z8.string().optional(),
5928
+ artifactName: z8.string().optional(),
5929
+ artifactVersion: z8.string().optional(),
5930
+ vars: z8.record(z8.string(), z8.string()).optional(),
5931
+ secrets: z8.record(z8.string(), z8.string()).optional(),
5932
+ volumeVersions: z8.record(z8.string(), z8.string()).optional(),
5845
5933
  // Debug flag to force real Claude in mock environments (internal use only)
5846
- debugNoMockClaude: z7.boolean().optional(),
5934
+ debugNoMockClaude: z8.boolean().optional(),
5847
5935
  // Model provider for automatic credential injection
5848
- modelProvider: z7.string().optional(),
5936
+ modelProvider: z8.string().optional(),
5849
5937
  // Required
5850
- prompt: z7.string().min(1, "Missing prompt")
5938
+ prompt: z8.string().min(1, "Missing prompt")
5851
5939
  });
5852
- var createRunResponseSchema = z7.object({
5853
- runId: z7.string(),
5940
+ var createRunResponseSchema = z8.object({
5941
+ runId: z8.string(),
5854
5942
  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(),
5943
+ sandboxId: z8.string().optional(),
5944
+ output: z8.string().optional(),
5945
+ error: z8.string().optional(),
5946
+ executionTimeMs: z8.number().optional(),
5947
+ createdAt: z8.string()
5948
+ });
5949
+ var getRunResponseSchema = z8.object({
5950
+ runId: z8.string(),
5951
+ agentComposeVersionId: z8.string(),
5864
5952
  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()
5953
+ prompt: z8.string(),
5954
+ vars: z8.record(z8.string(), z8.string()).optional(),
5955
+ sandboxId: z8.string().optional(),
5956
+ result: z8.object({
5957
+ output: z8.string(),
5958
+ executionTimeMs: z8.number()
5871
5959
  }).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(),
5960
+ error: z8.string().optional(),
5961
+ createdAt: z8.string(),
5962
+ startedAt: z8.string().optional(),
5963
+ completedAt: z8.string().optional()
5964
+ });
5965
+ var runEventSchema = z8.object({
5966
+ sequenceNumber: z8.number(),
5967
+ eventType: z8.string(),
5968
+ eventData: z8.unknown(),
5969
+ createdAt: z8.string()
5970
+ });
5971
+ var runResultSchema = z8.object({
5972
+ checkpointId: z8.string(),
5973
+ agentSessionId: z8.string(),
5974
+ conversationId: z8.string(),
5975
+ artifact: z8.record(z8.string(), z8.string()).optional(),
5888
5976
  // optional when run has no artifact
5889
- volumes: z7.record(z7.string(), z7.string()).optional()
5977
+ volumes: z8.record(z8.string(), z8.string()).optional()
5890
5978
  });
5891
- var runStateSchema = z7.object({
5979
+ var runStateSchema = z8.object({
5892
5980
  status: runStatusSchema,
5893
5981
  result: runResultSchema.optional(),
5894
- error: z7.string().optional()
5982
+ error: z8.string().optional()
5895
5983
  });
5896
- var eventsResponseSchema = z7.object({
5897
- events: z7.array(runEventSchema),
5898
- hasMore: z7.boolean(),
5899
- nextSequence: z7.number(),
5984
+ var eventsResponseSchema = z8.object({
5985
+ events: z8.array(runEventSchema),
5986
+ hasMore: z8.boolean(),
5987
+ nextSequence: z8.number(),
5900
5988
  run: runStateSchema,
5901
- framework: z7.string()
5989
+ framework: z8.string()
5990
+ });
5991
+ var runListItemSchema = z8.object({
5992
+ id: z8.string(),
5993
+ agentName: z8.string(),
5994
+ status: runStatusSchema,
5995
+ prompt: z8.string(),
5996
+ createdAt: z8.string(),
5997
+ startedAt: z8.string().nullable()
5998
+ });
5999
+ var runsListResponseSchema = z8.object({
6000
+ runs: z8.array(runListItemSchema)
5902
6001
  });
5903
6002
  var runsMainContract = c3.router({
6003
+ /**
6004
+ * GET /api/agent/runs
6005
+ * List agent runs (pending and running by default)
6006
+ */
6007
+ list: {
6008
+ method: "GET",
6009
+ path: "/api/agent/runs",
6010
+ headers: authHeadersSchema,
6011
+ query: z8.object({
6012
+ status: runStatusSchema.optional(),
6013
+ limit: z8.coerce.number().min(1).max(100).default(50)
6014
+ }),
6015
+ responses: {
6016
+ 200: runsListResponseSchema,
6017
+ 401: apiErrorSchema
6018
+ },
6019
+ summary: "List agent runs"
6020
+ },
5904
6021
  /**
5905
6022
  * POST /api/agent/runs
5906
6023
  * Create and execute a new agent run
@@ -5929,8 +6046,8 @@ var runsByIdContract = c3.router({
5929
6046
  method: "GET",
5930
6047
  path: "/api/agent/runs/:id",
5931
6048
  headers: authHeadersSchema,
5932
- pathParams: z7.object({
5933
- id: z7.string().min(1, "Run ID is required")
6049
+ pathParams: z8.object({
6050
+ id: z8.string().min(1, "Run ID is required")
5934
6051
  }),
5935
6052
  responses: {
5936
6053
  200: getRunResponseSchema,
@@ -5941,6 +6058,33 @@ var runsByIdContract = c3.router({
5941
6058
  summary: "Get agent run by ID"
5942
6059
  }
5943
6060
  });
6061
+ var cancelRunResponseSchema = z8.object({
6062
+ id: z8.string(),
6063
+ status: z8.literal("cancelled"),
6064
+ message: z8.string()
6065
+ });
6066
+ var runsCancelContract = c3.router({
6067
+ /**
6068
+ * POST /api/agent/runs/:id/cancel
6069
+ * Cancel a pending or running run
6070
+ */
6071
+ cancel: {
6072
+ method: "POST",
6073
+ path: "/api/agent/runs/:id/cancel",
6074
+ headers: authHeadersSchema,
6075
+ pathParams: z8.object({
6076
+ id: z8.string().min(1, "Run ID is required")
6077
+ }),
6078
+ body: z8.undefined(),
6079
+ responses: {
6080
+ 200: cancelRunResponseSchema,
6081
+ 400: apiErrorSchema,
6082
+ 401: apiErrorSchema,
6083
+ 404: apiErrorSchema
6084
+ },
6085
+ summary: "Cancel a pending or running run"
6086
+ }
6087
+ });
5944
6088
  var runEventsContract = c3.router({
5945
6089
  /**
5946
6090
  * GET /api/agent/runs/:id/events
@@ -5950,12 +6094,12 @@ var runEventsContract = c3.router({
5950
6094
  method: "GET",
5951
6095
  path: "/api/agent/runs/:id/events",
5952
6096
  headers: authHeadersSchema,
5953
- pathParams: z7.object({
5954
- id: z7.string().min(1, "Run ID is required")
6097
+ pathParams: z8.object({
6098
+ id: z8.string().min(1, "Run ID is required")
5955
6099
  }),
5956
- query: z7.object({
5957
- since: z7.coerce.number().default(-1),
5958
- limit: z7.coerce.number().default(100)
6100
+ query: z8.object({
6101
+ since: z8.coerce.number().default(-1),
6102
+ limit: z8.coerce.number().default(100)
5959
6103
  }),
5960
6104
  responses: {
5961
6105
  200: eventsResponseSchema,
@@ -5965,50 +6109,50 @@ var runEventsContract = c3.router({
5965
6109
  summary: "Get agent run events"
5966
6110
  }
5967
6111
  });
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()
6112
+ var telemetryMetricSchema = z8.object({
6113
+ ts: z8.string(),
6114
+ cpu: z8.number(),
6115
+ mem_used: z8.number(),
6116
+ mem_total: z8.number(),
6117
+ disk_used: z8.number(),
6118
+ disk_total: z8.number()
5975
6119
  });
5976
- var systemLogResponseSchema = z7.object({
5977
- systemLog: z7.string(),
5978
- hasMore: z7.boolean()
6120
+ var systemLogResponseSchema = z8.object({
6121
+ systemLog: z8.string(),
6122
+ hasMore: z8.boolean()
5979
6123
  });
5980
- var metricsResponseSchema = z7.object({
5981
- metrics: z7.array(telemetryMetricSchema),
5982
- hasMore: z7.boolean()
6124
+ var metricsResponseSchema = z8.object({
6125
+ metrics: z8.array(telemetryMetricSchema),
6126
+ hasMore: z8.boolean()
5983
6127
  });
5984
- var agentEventsResponseSchema = z7.object({
5985
- events: z7.array(runEventSchema),
5986
- hasMore: z7.boolean(),
5987
- framework: z7.string()
6128
+ var agentEventsResponseSchema = z8.object({
6129
+ events: z8.array(runEventSchema),
6130
+ hasMore: z8.boolean(),
6131
+ framework: z8.string()
5988
6132
  });
5989
- var networkLogEntrySchema = z7.object({
5990
- timestamp: z7.string(),
6133
+ var networkLogEntrySchema = z8.object({
6134
+ timestamp: z8.string(),
5991
6135
  // 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(),
6136
+ mode: z8.enum(["mitm", "sni"]).optional(),
6137
+ action: z8.enum(["ALLOW", "DENY"]).optional(),
6138
+ host: z8.string().optional(),
6139
+ port: z8.number().optional(),
6140
+ rule_matched: z8.string().nullable().optional(),
5997
6141
  // 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()
6142
+ method: z8.string().optional(),
6143
+ url: z8.string().optional(),
6144
+ status: z8.number().optional(),
6145
+ latency_ms: z8.number().optional(),
6146
+ request_size: z8.number().optional(),
6147
+ response_size: z8.number().optional()
6004
6148
  });
6005
- var networkLogsResponseSchema = z7.object({
6006
- networkLogs: z7.array(networkLogEntrySchema),
6007
- hasMore: z7.boolean()
6149
+ var networkLogsResponseSchema = z8.object({
6150
+ networkLogs: z8.array(networkLogEntrySchema),
6151
+ hasMore: z8.boolean()
6008
6152
  });
6009
- var telemetryResponseSchema = z7.object({
6010
- systemLog: z7.string(),
6011
- metrics: z7.array(telemetryMetricSchema)
6153
+ var telemetryResponseSchema = z8.object({
6154
+ systemLog: z8.string(),
6155
+ metrics: z8.array(telemetryMetricSchema)
6012
6156
  });
6013
6157
  var runTelemetryContract = c3.router({
6014
6158
  /**
@@ -6019,8 +6163,8 @@ var runTelemetryContract = c3.router({
6019
6163
  method: "GET",
6020
6164
  path: "/api/agent/runs/:id/telemetry",
6021
6165
  headers: authHeadersSchema,
6022
- pathParams: z7.object({
6023
- id: z7.string().min(1, "Run ID is required")
6166
+ pathParams: z8.object({
6167
+ id: z8.string().min(1, "Run ID is required")
6024
6168
  }),
6025
6169
  responses: {
6026
6170
  200: telemetryResponseSchema,
@@ -6039,13 +6183,13 @@ var runSystemLogContract = c3.router({
6039
6183
  method: "GET",
6040
6184
  path: "/api/agent/runs/:id/telemetry/system-log",
6041
6185
  headers: authHeadersSchema,
6042
- pathParams: z7.object({
6043
- id: z7.string().min(1, "Run ID is required")
6186
+ pathParams: z8.object({
6187
+ id: z8.string().min(1, "Run ID is required")
6044
6188
  }),
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")
6189
+ query: z8.object({
6190
+ since: z8.coerce.number().optional(),
6191
+ limit: z8.coerce.number().min(1).max(100).default(5),
6192
+ order: z8.enum(["asc", "desc"]).default("desc")
6049
6193
  }),
6050
6194
  responses: {
6051
6195
  200: systemLogResponseSchema,
@@ -6064,13 +6208,13 @@ var runMetricsContract = c3.router({
6064
6208
  method: "GET",
6065
6209
  path: "/api/agent/runs/:id/telemetry/metrics",
6066
6210
  headers: authHeadersSchema,
6067
- pathParams: z7.object({
6068
- id: z7.string().min(1, "Run ID is required")
6211
+ pathParams: z8.object({
6212
+ id: z8.string().min(1, "Run ID is required")
6069
6213
  }),
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")
6214
+ query: z8.object({
6215
+ since: z8.coerce.number().optional(),
6216
+ limit: z8.coerce.number().min(1).max(100).default(5),
6217
+ order: z8.enum(["asc", "desc"]).default("desc")
6074
6218
  }),
6075
6219
  responses: {
6076
6220
  200: metricsResponseSchema,
@@ -6089,13 +6233,13 @@ var runAgentEventsContract = c3.router({
6089
6233
  method: "GET",
6090
6234
  path: "/api/agent/runs/:id/telemetry/agent",
6091
6235
  headers: authHeadersSchema,
6092
- pathParams: z7.object({
6093
- id: z7.string().min(1, "Run ID is required")
6236
+ pathParams: z8.object({
6237
+ id: z8.string().min(1, "Run ID is required")
6094
6238
  }),
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")
6239
+ query: z8.object({
6240
+ since: z8.coerce.number().optional(),
6241
+ limit: z8.coerce.number().min(1).max(100).default(5),
6242
+ order: z8.enum(["asc", "desc"]).default("desc")
6099
6243
  }),
6100
6244
  responses: {
6101
6245
  200: agentEventsResponseSchema,
@@ -6114,13 +6258,13 @@ var runNetworkLogsContract = c3.router({
6114
6258
  method: "GET",
6115
6259
  path: "/api/agent/runs/:id/telemetry/network",
6116
6260
  headers: authHeadersSchema,
6117
- pathParams: z7.object({
6118
- id: z7.string().min(1, "Run ID is required")
6261
+ pathParams: z8.object({
6262
+ id: z8.string().min(1, "Run ID is required")
6119
6263
  }),
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")
6264
+ query: z8.object({
6265
+ since: z8.coerce.number().optional(),
6266
+ limit: z8.coerce.number().min(1).max(100).default(5),
6267
+ order: z8.enum(["asc", "desc"]).default("desc")
6124
6268
  }),
6125
6269
  responses: {
6126
6270
  200: networkLogsResponseSchema,
@@ -6132,20 +6276,20 @@ var runNetworkLogsContract = c3.router({
6132
6276
  });
6133
6277
 
6134
6278
  // ../../packages/core/src/contracts/storages.ts
6135
- import { z as z8 } from "zod";
6279
+ import { z as z9 } from "zod";
6136
6280
  var c4 = initContract();
6137
- var storageTypeSchema = z8.enum(["volume", "artifact"]);
6138
- var versionQuerySchema = z8.preprocess(
6281
+ var storageTypeSchema = z9.enum(["volume", "artifact"]);
6282
+ var versionQuerySchema = z9.preprocess(
6139
6283
  (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()
6284
+ z9.string().regex(/^[a-f0-9]{8,64}$/i, "Version must be 8-64 hex characters").optional()
6141
6285
  );
6142
- var uploadStorageResponseSchema = z8.object({
6143
- name: z8.string(),
6144
- versionId: z8.string(),
6145
- size: z8.number(),
6146
- fileCount: z8.number(),
6286
+ var uploadStorageResponseSchema = z9.object({
6287
+ name: z9.string(),
6288
+ versionId: z9.string(),
6289
+ size: z9.number(),
6290
+ fileCount: z9.number(),
6147
6291
  type: storageTypeSchema,
6148
- deduplicated: z8.boolean()
6292
+ deduplicated: z9.boolean()
6149
6293
  });
6150
6294
  var storagesContract = c4.router({
6151
6295
  /**
@@ -6187,8 +6331,8 @@ var storagesContract = c4.router({
6187
6331
  method: "GET",
6188
6332
  path: "/api/storages",
6189
6333
  headers: authHeadersSchema,
6190
- query: z8.object({
6191
- name: z8.string().min(1, "Storage name is required"),
6334
+ query: z9.object({
6335
+ name: z9.string().min(1, "Storage name is required"),
6192
6336
  version: versionQuerySchema
6193
6337
  }),
6194
6338
  responses: {
@@ -6205,41 +6349,41 @@ var storagesContract = c4.router({
6205
6349
  summary: "Download storage archive"
6206
6350
  }
6207
6351
  });
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")
6352
+ var fileEntryWithHashSchema = z9.object({
6353
+ path: z9.string().min(1, "File path is required"),
6354
+ hash: z9.string().length(64, "Hash must be SHA-256 (64 hex chars)"),
6355
+ size: z9.number().int().min(0, "Size must be non-negative")
6212
6356
  });
6213
- var storageChangesSchema = z8.object({
6214
- added: z8.array(z8.string()),
6215
- modified: z8.array(z8.string()),
6216
- deleted: z8.array(z8.string())
6357
+ var storageChangesSchema = z9.object({
6358
+ added: z9.array(z9.string()),
6359
+ modified: z9.array(z9.string()),
6360
+ deleted: z9.array(z9.string())
6217
6361
  });
6218
- var presignedUploadSchema = z8.object({
6219
- key: z8.string(),
6220
- presignedUrl: z8.string().url()
6362
+ var presignedUploadSchema = z9.object({
6363
+ key: z9.string(),
6364
+ presignedUrl: z9.string().url()
6221
6365
  });
6222
6366
  var storagesPrepareContract = c4.router({
6223
6367
  prepare: {
6224
6368
  method: "POST",
6225
6369
  path: "/api/storages/prepare",
6226
6370
  headers: authHeadersSchema,
6227
- body: z8.object({
6228
- storageName: z8.string().min(1, "Storage name is required"),
6371
+ body: z9.object({
6372
+ storageName: z9.string().min(1, "Storage name is required"),
6229
6373
  storageType: storageTypeSchema,
6230
- files: z8.array(fileEntryWithHashSchema),
6231
- force: z8.boolean().optional(),
6232
- runId: z8.string().optional(),
6374
+ files: z9.array(fileEntryWithHashSchema),
6375
+ force: z9.boolean().optional(),
6376
+ runId: z9.string().optional(),
6233
6377
  // For sandbox auth
6234
- baseVersion: z8.string().optional(),
6378
+ baseVersion: z9.string().optional(),
6235
6379
  // For incremental uploads
6236
6380
  changes: storageChangesSchema.optional()
6237
6381
  }),
6238
6382
  responses: {
6239
- 200: z8.object({
6240
- versionId: z8.string(),
6241
- existing: z8.boolean(),
6242
- uploads: z8.object({
6383
+ 200: z9.object({
6384
+ versionId: z9.string(),
6385
+ existing: z9.boolean(),
6386
+ uploads: z9.object({
6243
6387
  archive: presignedUploadSchema,
6244
6388
  manifest: presignedUploadSchema
6245
6389
  }).optional()
@@ -6257,22 +6401,22 @@ var storagesCommitContract = c4.router({
6257
6401
  method: "POST",
6258
6402
  path: "/api/storages/commit",
6259
6403
  headers: authHeadersSchema,
6260
- body: z8.object({
6261
- storageName: z8.string().min(1, "Storage name is required"),
6404
+ body: z9.object({
6405
+ storageName: z9.string().min(1, "Storage name is required"),
6262
6406
  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()
6407
+ versionId: z9.string().min(1, "Version ID is required"),
6408
+ files: z9.array(fileEntryWithHashSchema),
6409
+ runId: z9.string().optional(),
6410
+ message: z9.string().optional()
6267
6411
  }),
6268
6412
  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()
6413
+ 200: z9.object({
6414
+ success: z9.literal(true),
6415
+ versionId: z9.string(),
6416
+ storageName: z9.string(),
6417
+ size: z9.number(),
6418
+ fileCount: z9.number(),
6419
+ deduplicated: z9.boolean().optional()
6276
6420
  }),
6277
6421
  400: apiErrorSchema,
6278
6422
  401: apiErrorSchema,
@@ -6289,26 +6433,26 @@ var storagesDownloadContract = c4.router({
6289
6433
  method: "GET",
6290
6434
  path: "/api/storages/download",
6291
6435
  headers: authHeadersSchema,
6292
- query: z8.object({
6293
- name: z8.string().min(1, "Storage name is required"),
6436
+ query: z9.object({
6437
+ name: z9.string().min(1, "Storage name is required"),
6294
6438
  type: storageTypeSchema,
6295
6439
  version: versionQuerySchema
6296
6440
  }),
6297
6441
  responses: {
6298
6442
  // 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()
6443
+ 200: z9.union([
6444
+ z9.object({
6445
+ url: z9.string().url(),
6446
+ versionId: z9.string(),
6447
+ fileCount: z9.number(),
6448
+ size: z9.number()
6305
6449
  }),
6306
6450
  // 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)
6451
+ z9.object({
6452
+ empty: z9.literal(true),
6453
+ versionId: z9.string(),
6454
+ fileCount: z9.literal(0),
6455
+ size: z9.literal(0)
6312
6456
  })
6313
6457
  ]),
6314
6458
  400: apiErrorSchema,
@@ -6324,16 +6468,16 @@ var storagesListContract = c4.router({
6324
6468
  method: "GET",
6325
6469
  path: "/api/storages/list",
6326
6470
  headers: authHeadersSchema,
6327
- query: z8.object({
6471
+ query: z9.object({
6328
6472
  type: storageTypeSchema
6329
6473
  }),
6330
6474
  responses: {
6331
- 200: z8.array(
6332
- z8.object({
6333
- name: z8.string(),
6334
- size: z8.number(),
6335
- fileCount: z8.number(),
6336
- updatedAt: z8.string()
6475
+ 200: z9.array(
6476
+ z9.object({
6477
+ name: z9.string(),
6478
+ size: z9.number(),
6479
+ fileCount: z9.number(),
6480
+ updatedAt: z9.string()
6337
6481
  })
6338
6482
  ),
6339
6483
  401: apiErrorSchema,
@@ -6344,18 +6488,18 @@ var storagesListContract = c4.router({
6344
6488
  });
6345
6489
 
6346
6490
  // ../../packages/core/src/contracts/webhooks.ts
6347
- import { z as z9 } from "zod";
6491
+ import { z as z10 } from "zod";
6348
6492
  var c5 = initContract();
6349
- var agentEventSchema = z9.object({
6350
- type: z9.string(),
6351
- sequenceNumber: z9.number().int().nonnegative()
6493
+ var agentEventSchema = z10.object({
6494
+ type: z10.string(),
6495
+ sequenceNumber: z10.number().int().nonnegative()
6352
6496
  }).passthrough();
6353
- var artifactSnapshotSchema = z9.object({
6354
- artifactName: z9.string(),
6355
- artifactVersion: z9.string()
6497
+ var artifactSnapshotSchema = z10.object({
6498
+ artifactName: z10.string(),
6499
+ artifactVersion: z10.string()
6356
6500
  });
6357
- var volumeVersionsSnapshotSchema = z9.object({
6358
- versions: z9.record(z9.string(), z9.string())
6501
+ var volumeVersionsSnapshotSchema = z10.object({
6502
+ versions: z10.record(z10.string(), z10.string())
6359
6503
  });
6360
6504
  var webhookEventsContract = c5.router({
6361
6505
  /**
@@ -6366,15 +6510,15 @@ var webhookEventsContract = c5.router({
6366
6510
  method: "POST",
6367
6511
  path: "/api/webhooks/agent/events",
6368
6512
  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")
6513
+ body: z10.object({
6514
+ runId: z10.string().min(1, "runId is required"),
6515
+ events: z10.array(agentEventSchema).min(1, "events array cannot be empty")
6372
6516
  }),
6373
6517
  responses: {
6374
- 200: z9.object({
6375
- received: z9.number(),
6376
- firstSequence: z9.number(),
6377
- lastSequence: z9.number()
6518
+ 200: z10.object({
6519
+ received: z10.number(),
6520
+ firstSequence: z10.number(),
6521
+ lastSequence: z10.number()
6378
6522
  }),
6379
6523
  400: apiErrorSchema,
6380
6524
  401: apiErrorSchema,
@@ -6393,15 +6537,15 @@ var webhookCompleteContract = c5.router({
6393
6537
  method: "POST",
6394
6538
  path: "/api/webhooks/agent/complete",
6395
6539
  headers: authHeadersSchema,
6396
- body: z9.object({
6397
- runId: z9.string().min(1, "runId is required"),
6398
- exitCode: z9.number(),
6399
- error: z9.string().optional()
6540
+ body: z10.object({
6541
+ runId: z10.string().min(1, "runId is required"),
6542
+ exitCode: z10.number(),
6543
+ error: z10.string().optional()
6400
6544
  }),
6401
6545
  responses: {
6402
- 200: z9.object({
6403
- success: z9.boolean(),
6404
- status: z9.enum(["completed", "failed"])
6546
+ 200: z10.object({
6547
+ success: z10.boolean(),
6548
+ status: z10.enum(["completed", "failed"])
6405
6549
  }),
6406
6550
  400: apiErrorSchema,
6407
6551
  401: apiErrorSchema,
@@ -6420,21 +6564,21 @@ var webhookCheckpointsContract = c5.router({
6420
6564
  method: "POST",
6421
6565
  path: "/api/webhooks/agent/checkpoints",
6422
6566
  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"),
6567
+ body: z10.object({
6568
+ runId: z10.string().min(1, "runId is required"),
6569
+ cliAgentType: z10.string().min(1, "cliAgentType is required"),
6570
+ cliAgentSessionId: z10.string().min(1, "cliAgentSessionId is required"),
6571
+ cliAgentSessionHistory: z10.string().min(1, "cliAgentSessionHistory is required"),
6428
6572
  artifactSnapshot: artifactSnapshotSchema.optional(),
6429
6573
  volumeVersionsSnapshot: volumeVersionsSnapshotSchema.optional()
6430
6574
  }),
6431
6575
  responses: {
6432
- 200: z9.object({
6433
- checkpointId: z9.string(),
6434
- agentSessionId: z9.string(),
6435
- conversationId: z9.string(),
6576
+ 200: z10.object({
6577
+ checkpointId: z10.string(),
6578
+ agentSessionId: z10.string(),
6579
+ conversationId: z10.string(),
6436
6580
  artifact: artifactSnapshotSchema.optional(),
6437
- volumes: z9.record(z9.string(), z9.string()).optional()
6581
+ volumes: z10.record(z10.string(), z10.string()).optional()
6438
6582
  }),
6439
6583
  400: apiErrorSchema,
6440
6584
  401: apiErrorSchema,
@@ -6453,12 +6597,12 @@ var webhookHeartbeatContract = c5.router({
6453
6597
  method: "POST",
6454
6598
  path: "/api/webhooks/agent/heartbeat",
6455
6599
  headers: authHeadersSchema,
6456
- body: z9.object({
6457
- runId: z9.string().min(1, "runId is required")
6600
+ body: z10.object({
6601
+ runId: z10.string().min(1, "runId is required")
6458
6602
  }),
6459
6603
  responses: {
6460
- 200: z9.object({
6461
- ok: z9.boolean()
6604
+ 200: z10.object({
6605
+ ok: z10.boolean()
6462
6606
  }),
6463
6607
  400: apiErrorSchema,
6464
6608
  401: apiErrorSchema,
@@ -6486,11 +6630,11 @@ var webhookStoragesContract = c5.router({
6486
6630
  contentType: "multipart/form-data",
6487
6631
  body: c5.type(),
6488
6632
  responses: {
6489
- 200: z9.object({
6490
- versionId: z9.string(),
6491
- storageName: z9.string(),
6492
- size: z9.number(),
6493
- fileCount: z9.number()
6633
+ 200: z10.object({
6634
+ versionId: z10.string(),
6635
+ storageName: z10.string(),
6636
+ size: z10.number(),
6637
+ fileCount: z10.number()
6494
6638
  }),
6495
6639
  400: apiErrorSchema,
6496
6640
  401: apiErrorSchema,
@@ -6520,17 +6664,17 @@ var webhookStoragesIncrementalContract = c5.router({
6520
6664
  contentType: "multipart/form-data",
6521
6665
  body: c5.type(),
6522
6666
  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()
6667
+ 200: z10.object({
6668
+ versionId: z10.string(),
6669
+ storageName: z10.string(),
6670
+ size: z10.number(),
6671
+ fileCount: z10.number(),
6672
+ incrementalStats: z10.object({
6673
+ addedFiles: z10.number(),
6674
+ modifiedFiles: z10.number(),
6675
+ deletedFiles: z10.number(),
6676
+ unchangedFiles: z10.number(),
6677
+ bytesUploaded: z10.number()
6534
6678
  }).optional()
6535
6679
  }),
6536
6680
  400: apiErrorSchema,
@@ -6541,36 +6685,36 @@ var webhookStoragesIncrementalContract = c5.router({
6541
6685
  summary: "Upload storage version incrementally from sandbox"
6542
6686
  }
6543
6687
  });
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()
6688
+ var metricDataSchema = z10.object({
6689
+ ts: z10.string(),
6690
+ cpu: z10.number(),
6691
+ mem_used: z10.number(),
6692
+ mem_total: z10.number(),
6693
+ disk_used: z10.number(),
6694
+ disk_total: z10.number()
6551
6695
  });
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()
6696
+ var sandboxOperationSchema = z10.object({
6697
+ ts: z10.string(),
6698
+ action_type: z10.string(),
6699
+ duration_ms: z10.number(),
6700
+ success: z10.boolean(),
6701
+ error: z10.string().optional()
6558
6702
  });
6559
- var networkLogSchema = z9.object({
6560
- timestamp: z9.string(),
6703
+ var networkLogSchema = z10.object({
6704
+ timestamp: z10.string(),
6561
6705
  // 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(),
6706
+ mode: z10.enum(["mitm", "sni"]).optional(),
6707
+ action: z10.enum(["ALLOW", "DENY"]).optional(),
6708
+ host: z10.string().optional(),
6709
+ port: z10.number().optional(),
6710
+ rule_matched: z10.string().nullable().optional(),
6567
6711
  // 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()
6712
+ method: z10.string().optional(),
6713
+ url: z10.string().optional(),
6714
+ status: z10.number().optional(),
6715
+ latency_ms: z10.number().optional(),
6716
+ request_size: z10.number().optional(),
6717
+ response_size: z10.number().optional()
6574
6718
  });
6575
6719
  var webhookTelemetryContract = c5.router({
6576
6720
  /**
@@ -6581,17 +6725,17 @@ var webhookTelemetryContract = c5.router({
6581
6725
  method: "POST",
6582
6726
  path: "/api/webhooks/agent/telemetry",
6583
6727
  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()
6728
+ body: z10.object({
6729
+ runId: z10.string().min(1, "runId is required"),
6730
+ systemLog: z10.string().optional(),
6731
+ metrics: z10.array(metricDataSchema).optional(),
6732
+ networkLogs: z10.array(networkLogSchema).optional(),
6733
+ sandboxOperations: z10.array(sandboxOperationSchema).optional()
6590
6734
  }),
6591
6735
  responses: {
6592
- 200: z9.object({
6593
- success: z9.boolean(),
6594
- id: z9.string()
6736
+ 200: z10.object({
6737
+ success: z10.boolean(),
6738
+ id: z10.string()
6595
6739
  }),
6596
6740
  400: apiErrorSchema,
6597
6741
  401: apiErrorSchema,
@@ -6606,21 +6750,21 @@ var webhookStoragesPrepareContract = c5.router({
6606
6750
  method: "POST",
6607
6751
  path: "/api/webhooks/agent/storages/prepare",
6608
6752
  headers: authHeadersSchema,
6609
- body: z9.object({
6610
- runId: z9.string().min(1, "runId is required"),
6753
+ body: z10.object({
6754
+ runId: z10.string().min(1, "runId is required"),
6611
6755
  // Required for webhook auth
6612
- storageName: z9.string().min(1, "Storage name is required"),
6756
+ storageName: z10.string().min(1, "Storage name is required"),
6613
6757
  storageType: storageTypeSchema,
6614
- files: z9.array(fileEntryWithHashSchema),
6615
- force: z9.boolean().optional(),
6616
- baseVersion: z9.string().optional(),
6758
+ files: z10.array(fileEntryWithHashSchema),
6759
+ force: z10.boolean().optional(),
6760
+ baseVersion: z10.string().optional(),
6617
6761
  changes: storageChangesSchema.optional()
6618
6762
  }),
6619
6763
  responses: {
6620
- 200: z9.object({
6621
- versionId: z9.string(),
6622
- existing: z9.boolean(),
6623
- uploads: z9.object({
6764
+ 200: z10.object({
6765
+ versionId: z10.string(),
6766
+ existing: z10.boolean(),
6767
+ uploads: z10.object({
6624
6768
  archive: presignedUploadSchema,
6625
6769
  manifest: presignedUploadSchema
6626
6770
  }).optional()
@@ -6638,23 +6782,23 @@ var webhookStoragesCommitContract = c5.router({
6638
6782
  method: "POST",
6639
6783
  path: "/api/webhooks/agent/storages/commit",
6640
6784
  headers: authHeadersSchema,
6641
- body: z9.object({
6642
- runId: z9.string().min(1, "runId is required"),
6785
+ body: z10.object({
6786
+ runId: z10.string().min(1, "runId is required"),
6643
6787
  // Required for webhook auth
6644
- storageName: z9.string().min(1, "Storage name is required"),
6788
+ storageName: z10.string().min(1, "Storage name is required"),
6645
6789
  storageType: storageTypeSchema,
6646
- versionId: z9.string().min(1, "Version ID is required"),
6647
- files: z9.array(fileEntryWithHashSchema),
6648
- message: z9.string().optional()
6790
+ versionId: z10.string().min(1, "Version ID is required"),
6791
+ files: z10.array(fileEntryWithHashSchema),
6792
+ message: z10.string().optional()
6649
6793
  }),
6650
6794
  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()
6795
+ 200: z10.object({
6796
+ success: z10.literal(true),
6797
+ versionId: z10.string(),
6798
+ storageName: z10.string(),
6799
+ size: z10.number(),
6800
+ fileCount: z10.number(),
6801
+ deduplicated: z10.boolean().optional()
6658
6802
  }),
6659
6803
  400: apiErrorSchema,
6660
6804
  401: apiErrorSchema,
@@ -6668,11 +6812,11 @@ var webhookStoragesCommitContract = c5.router({
6668
6812
  });
6669
6813
 
6670
6814
  // ../../packages/core/src/contracts/cli-auth.ts
6671
- import { z as z10 } from "zod";
6815
+ import { z as z11 } from "zod";
6672
6816
  var c6 = initContract();
6673
- var oauthErrorSchema = z10.object({
6674
- error: z10.string(),
6675
- error_description: z10.string()
6817
+ var oauthErrorSchema = z11.object({
6818
+ error: z11.string(),
6819
+ error_description: z11.string()
6676
6820
  });
6677
6821
  var cliAuthDeviceContract = c6.router({
6678
6822
  /**
@@ -6682,14 +6826,14 @@ var cliAuthDeviceContract = c6.router({
6682
6826
  create: {
6683
6827
  method: "POST",
6684
6828
  path: "/api/cli/auth/device",
6685
- body: z10.object({}).optional(),
6829
+ body: z11.object({}).optional(),
6686
6830
  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()
6831
+ 200: z11.object({
6832
+ device_code: z11.string(),
6833
+ user_code: z11.string(),
6834
+ verification_path: z11.string(),
6835
+ expires_in: z11.number(),
6836
+ interval: z11.number()
6693
6837
  }),
6694
6838
  500: oauthErrorSchema
6695
6839
  },
@@ -6704,16 +6848,16 @@ var cliAuthTokenContract = c6.router({
6704
6848
  exchange: {
6705
6849
  method: "POST",
6706
6850
  path: "/api/cli/auth/token",
6707
- body: z10.object({
6708
- device_code: z10.string().min(1, "device_code is required")
6851
+ body: z11.object({
6852
+ device_code: z11.string().min(1, "device_code is required")
6709
6853
  }),
6710
6854
  responses: {
6711
6855
  // 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()
6856
+ 200: z11.object({
6857
+ access_token: z11.string(),
6858
+ refresh_token: z11.string(),
6859
+ token_type: z11.literal("Bearer"),
6860
+ expires_in: z11.number()
6717
6861
  }),
6718
6862
  // Authorization pending
6719
6863
  202: oauthErrorSchema,
@@ -6726,7 +6870,7 @@ var cliAuthTokenContract = c6.router({
6726
6870
  });
6727
6871
 
6728
6872
  // ../../packages/core/src/contracts/auth.ts
6729
- import { z as z11 } from "zod";
6873
+ import { z as z12 } from "zod";
6730
6874
  var c7 = initContract();
6731
6875
  var authContract = c7.router({
6732
6876
  /**
@@ -6738,9 +6882,9 @@ var authContract = c7.router({
6738
6882
  path: "/api/auth/me",
6739
6883
  headers: authHeadersSchema,
6740
6884
  responses: {
6741
- 200: z11.object({
6742
- userId: z11.string(),
6743
- email: z11.string()
6885
+ 200: z12.object({
6886
+ userId: z12.string(),
6887
+ email: z12.string()
6744
6888
  }),
6745
6889
  401: apiErrorSchema,
6746
6890
  404: apiErrorSchema,
@@ -6751,18 +6895,18 @@ var authContract = c7.router({
6751
6895
  });
6752
6896
 
6753
6897
  // ../../packages/core/src/contracts/cron.ts
6754
- import { z as z12 } from "zod";
6898
+ import { z as z13 } from "zod";
6755
6899
  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()
6900
+ var cleanupResultSchema = z13.object({
6901
+ runId: z13.string(),
6902
+ sandboxId: z13.string().nullable(),
6903
+ status: z13.enum(["cleaned", "error"]),
6904
+ error: z13.string().optional()
6761
6905
  });
6762
- var cleanupResponseSchema = z12.object({
6763
- cleaned: z12.number(),
6764
- errors: z12.number(),
6765
- results: z12.array(cleanupResultSchema)
6906
+ var cleanupResponseSchema = z13.object({
6907
+ cleaned: z13.number(),
6908
+ errors: z13.number(),
6909
+ results: z13.array(cleanupResultSchema)
6766
6910
  });
6767
6911
  var cronCleanupSandboxesContract = c8.router({
6768
6912
  /**
@@ -6783,44 +6927,44 @@ var cronCleanupSandboxesContract = c8.router({
6783
6927
  });
6784
6928
 
6785
6929
  // ../../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([
6930
+ import { z as z14 } from "zod";
6931
+ var proxyErrorSchema = z14.object({
6932
+ error: z14.object({
6933
+ message: z14.string(),
6934
+ code: z14.enum([
6791
6935
  "UNAUTHORIZED",
6792
6936
  "BAD_REQUEST",
6793
6937
  "BAD_GATEWAY",
6794
6938
  "INTERNAL_ERROR"
6795
6939
  ]),
6796
- targetUrl: z13.string().optional()
6940
+ targetUrl: z14.string().optional()
6797
6941
  })
6798
6942
  });
6799
6943
 
6800
6944
  // ../../packages/core/src/contracts/scopes.ts
6801
- import { z as z14 } from "zod";
6945
+ import { z as z15 } from "zod";
6802
6946
  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(
6947
+ var scopeTypeSchema = z15.enum(["personal", "organization", "system"]);
6948
+ 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
6949
  /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]{1,2}$/,
6806
6950
  "Scope slug must contain only lowercase letters, numbers, and hyphens, and must start and end with an alphanumeric character"
6807
6951
  ).refine(
6808
6952
  (slug) => !slug.startsWith("vm0"),
6809
6953
  "Scope slug cannot start with 'vm0' (reserved)"
6810
6954
  ).transform((s) => s.toLowerCase());
6811
- var scopeResponseSchema = z14.object({
6812
- id: z14.string().uuid(),
6813
- slug: z14.string(),
6955
+ var scopeResponseSchema = z15.object({
6956
+ id: z15.string().uuid(),
6957
+ slug: z15.string(),
6814
6958
  type: scopeTypeSchema,
6815
- createdAt: z14.string(),
6816
- updatedAt: z14.string()
6959
+ createdAt: z15.string(),
6960
+ updatedAt: z15.string()
6817
6961
  });
6818
- var createScopeRequestSchema = z14.object({
6962
+ var createScopeRequestSchema = z15.object({
6819
6963
  slug: scopeSlugSchema
6820
6964
  });
6821
- var updateScopeRequestSchema = z14.object({
6965
+ var updateScopeRequestSchema = z15.object({
6822
6966
  slug: scopeSlugSchema,
6823
- force: z14.boolean().optional().default(false)
6967
+ force: z15.boolean().optional().default(false)
6824
6968
  });
6825
6969
  var scopeContract = c9.router({
6826
6970
  /**
@@ -6880,28 +7024,28 @@ var scopeContract = c9.router({
6880
7024
  });
6881
7025
 
6882
7026
  // ../../packages/core/src/contracts/credentials.ts
6883
- import { z as z15 } from "zod";
7027
+ import { z as z16 } from "zod";
6884
7028
  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(
7029
+ var credentialNameSchema = z16.string().min(1, "Credential name is required").max(255, "Credential name must be at most 255 characters").regex(
6886
7030
  /^[A-Z][A-Z0-9_]*$/,
6887
7031
  "Credential name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_API_KEY)"
6888
7032
  );
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(),
7033
+ var credentialTypeSchema = z16.enum(["user", "model-provider"]);
7034
+ var credentialResponseSchema = z16.object({
7035
+ id: z16.string().uuid(),
7036
+ name: z16.string(),
7037
+ description: z16.string().nullable(),
6894
7038
  type: credentialTypeSchema,
6895
- createdAt: z15.string(),
6896
- updatedAt: z15.string()
7039
+ createdAt: z16.string(),
7040
+ updatedAt: z16.string()
6897
7041
  });
6898
- var credentialListResponseSchema = z15.object({
6899
- credentials: z15.array(credentialResponseSchema)
7042
+ var credentialListResponseSchema = z16.object({
7043
+ credentials: z16.array(credentialResponseSchema)
6900
7044
  });
6901
- var setCredentialRequestSchema = z15.object({
7045
+ var setCredentialRequestSchema = z16.object({
6902
7046
  name: credentialNameSchema,
6903
- value: z15.string().min(1, "Credential value is required"),
6904
- description: z15.string().max(1e3).optional()
7047
+ value: z16.string().min(1, "Credential value is required"),
7048
+ description: z16.string().max(1e3).optional()
6905
7049
  });
6906
7050
  var credentialsMainContract = c10.router({
6907
7051
  /**
@@ -6947,7 +7091,7 @@ var credentialsByNameContract = c10.router({
6947
7091
  method: "GET",
6948
7092
  path: "/api/credentials/:name",
6949
7093
  headers: authHeadersSchema,
6950
- pathParams: z15.object({
7094
+ pathParams: z16.object({
6951
7095
  name: credentialNameSchema
6952
7096
  }),
6953
7097
  responses: {
@@ -6966,11 +7110,11 @@ var credentialsByNameContract = c10.router({
6966
7110
  method: "DELETE",
6967
7111
  path: "/api/credentials/:name",
6968
7112
  headers: authHeadersSchema,
6969
- pathParams: z15.object({
7113
+ pathParams: z16.object({
6970
7114
  name: credentialNameSchema
6971
7115
  }),
6972
7116
  responses: {
6973
- 204: z15.undefined(),
7117
+ 204: z16.undefined(),
6974
7118
  401: apiErrorSchema,
6975
7119
  404: apiErrorSchema,
6976
7120
  500: apiErrorSchema
@@ -6980,39 +7124,38 @@ var credentialsByNameContract = c10.router({
6980
7124
  });
6981
7125
 
6982
7126
  // ../../packages/core/src/contracts/model-providers.ts
6983
- import { z as z16 } from "zod";
7127
+ import { z as z17 } from "zod";
6984
7128
  var c11 = initContract();
6985
- var modelProviderTypeSchema = z16.enum([
7129
+ var modelProviderTypeSchema = z17.enum([
6986
7130
  "claude-code-oauth-token",
6987
- "anthropic-api-key",
6988
- "openai-api-key"
7131
+ "anthropic-api-key"
6989
7132
  ]);
6990
- var modelProviderFrameworkSchema = z16.enum(["claude-code", "codex"]);
6991
- var modelProviderResponseSchema = z16.object({
6992
- id: z16.string().uuid(),
7133
+ var modelProviderFrameworkSchema = z17.enum(["claude-code", "codex"]);
7134
+ var modelProviderResponseSchema = z17.object({
7135
+ id: z17.string().uuid(),
6993
7136
  type: modelProviderTypeSchema,
6994
7137
  framework: modelProviderFrameworkSchema,
6995
- credentialName: z16.string(),
6996
- isDefault: z16.boolean(),
6997
- createdAt: z16.string(),
6998
- updatedAt: z16.string()
7138
+ credentialName: z17.string(),
7139
+ isDefault: z17.boolean(),
7140
+ createdAt: z17.string(),
7141
+ updatedAt: z17.string()
6999
7142
  });
7000
- var modelProviderListResponseSchema = z16.object({
7001
- modelProviders: z16.array(modelProviderResponseSchema)
7143
+ var modelProviderListResponseSchema = z17.object({
7144
+ modelProviders: z17.array(modelProviderResponseSchema)
7002
7145
  });
7003
- var upsertModelProviderRequestSchema = z16.object({
7146
+ var upsertModelProviderRequestSchema = z17.object({
7004
7147
  type: modelProviderTypeSchema,
7005
- credential: z16.string().min(1, "Credential is required"),
7006
- convert: z16.boolean().optional()
7148
+ credential: z17.string().min(1, "Credential is required"),
7149
+ convert: z17.boolean().optional()
7007
7150
  });
7008
- var upsertModelProviderResponseSchema = z16.object({
7151
+ var upsertModelProviderResponseSchema = z17.object({
7009
7152
  provider: modelProviderResponseSchema,
7010
- created: z16.boolean()
7153
+ created: z17.boolean()
7011
7154
  });
7012
- var checkCredentialResponseSchema = z16.object({
7013
- exists: z16.boolean(),
7014
- credentialName: z16.string(),
7015
- currentType: z16.enum(["user", "model-provider"]).optional()
7155
+ var checkCredentialResponseSchema = z17.object({
7156
+ exists: z17.boolean(),
7157
+ credentialName: z17.string(),
7158
+ currentType: z17.enum(["user", "model-provider"]).optional()
7016
7159
  });
7017
7160
  var modelProvidersMainContract = c11.router({
7018
7161
  list: {
@@ -7047,7 +7190,7 @@ var modelProvidersCheckContract = c11.router({
7047
7190
  method: "GET",
7048
7191
  path: "/api/model-providers/check/:type",
7049
7192
  headers: authHeadersSchema,
7050
- pathParams: z16.object({
7193
+ pathParams: z17.object({
7051
7194
  type: modelProviderTypeSchema
7052
7195
  }),
7053
7196
  responses: {
@@ -7063,11 +7206,11 @@ var modelProvidersByTypeContract = c11.router({
7063
7206
  method: "DELETE",
7064
7207
  path: "/api/model-providers/:type",
7065
7208
  headers: authHeadersSchema,
7066
- pathParams: z16.object({
7209
+ pathParams: z17.object({
7067
7210
  type: modelProviderTypeSchema
7068
7211
  }),
7069
7212
  responses: {
7070
- 204: z16.undefined(),
7213
+ 204: z17.undefined(),
7071
7214
  401: apiErrorSchema,
7072
7215
  404: apiErrorSchema,
7073
7216
  500: apiErrorSchema
@@ -7080,10 +7223,10 @@ var modelProvidersConvertContract = c11.router({
7080
7223
  method: "POST",
7081
7224
  path: "/api/model-providers/:type/convert",
7082
7225
  headers: authHeadersSchema,
7083
- pathParams: z16.object({
7226
+ pathParams: z17.object({
7084
7227
  type: modelProviderTypeSchema
7085
7228
  }),
7086
- body: z16.undefined(),
7229
+ body: z17.undefined(),
7087
7230
  responses: {
7088
7231
  200: modelProviderResponseSchema,
7089
7232
  400: apiErrorSchema,
@@ -7099,10 +7242,10 @@ var modelProvidersSetDefaultContract = c11.router({
7099
7242
  method: "POST",
7100
7243
  path: "/api/model-providers/:type/set-default",
7101
7244
  headers: authHeadersSchema,
7102
- pathParams: z16.object({
7245
+ pathParams: z17.object({
7103
7246
  type: modelProviderTypeSchema
7104
7247
  }),
7105
- body: z16.undefined(),
7248
+ body: z17.undefined(),
7106
7249
  responses: {
7107
7250
  200: modelProviderResponseSchema,
7108
7251
  401: apiErrorSchema,
@@ -7114,40 +7257,40 @@ var modelProvidersSetDefaultContract = c11.router({
7114
7257
  });
7115
7258
 
7116
7259
  // ../../packages/core/src/contracts/sessions.ts
7117
- import { z as z17 } from "zod";
7260
+ import { z as z18 } from "zod";
7118
7261
  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()
7262
+ var sessionResponseSchema = z18.object({
7263
+ id: z18.string(),
7264
+ agentComposeId: z18.string(),
7265
+ agentComposeVersionId: z18.string().nullable(),
7266
+ conversationId: z18.string().nullable(),
7267
+ artifactName: z18.string().nullable(),
7268
+ vars: z18.record(z18.string(), z18.string()).nullable(),
7269
+ secretNames: z18.array(z18.string()).nullable(),
7270
+ volumeVersions: z18.record(z18.string(), z18.string()).nullable(),
7271
+ createdAt: z18.string(),
7272
+ updatedAt: z18.string()
7130
7273
  });
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()
7274
+ var agentComposeSnapshotSchema = z18.object({
7275
+ agentComposeVersionId: z18.string(),
7276
+ vars: z18.record(z18.string(), z18.string()).optional(),
7277
+ secretNames: z18.array(z18.string()).optional()
7135
7278
  });
7136
- var artifactSnapshotSchema2 = z17.object({
7137
- artifactName: z17.string(),
7138
- artifactVersion: z17.string()
7279
+ var artifactSnapshotSchema2 = z18.object({
7280
+ artifactName: z18.string(),
7281
+ artifactVersion: z18.string()
7139
7282
  });
7140
- var volumeVersionsSnapshotSchema2 = z17.object({
7141
- versions: z17.record(z17.string(), z17.string())
7283
+ var volumeVersionsSnapshotSchema2 = z18.object({
7284
+ versions: z18.record(z18.string(), z18.string())
7142
7285
  });
7143
- var checkpointResponseSchema = z17.object({
7144
- id: z17.string(),
7145
- runId: z17.string(),
7146
- conversationId: z17.string(),
7286
+ var checkpointResponseSchema = z18.object({
7287
+ id: z18.string(),
7288
+ runId: z18.string(),
7289
+ conversationId: z18.string(),
7147
7290
  agentComposeSnapshot: agentComposeSnapshotSchema,
7148
7291
  artifactSnapshot: artifactSnapshotSchema2.nullable(),
7149
7292
  volumeVersionsSnapshot: volumeVersionsSnapshotSchema2.nullable(),
7150
- createdAt: z17.string()
7293
+ createdAt: z18.string()
7151
7294
  });
7152
7295
  var sessionsByIdContract = c12.router({
7153
7296
  /**
@@ -7158,8 +7301,8 @@ var sessionsByIdContract = c12.router({
7158
7301
  method: "GET",
7159
7302
  path: "/api/agent/sessions/:id",
7160
7303
  headers: authHeadersSchema,
7161
- pathParams: z17.object({
7162
- id: z17.string().min(1, "Session ID is required")
7304
+ pathParams: z18.object({
7305
+ id: z18.string().min(1, "Session ID is required")
7163
7306
  }),
7164
7307
  responses: {
7165
7308
  200: sessionResponseSchema,
@@ -7179,8 +7322,8 @@ var checkpointsByIdContract = c12.router({
7179
7322
  method: "GET",
7180
7323
  path: "/api/agent/checkpoints/:id",
7181
7324
  headers: authHeadersSchema,
7182
- pathParams: z17.object({
7183
- id: z17.string().min(1, "Checkpoint ID is required")
7325
+ pathParams: z18.object({
7326
+ id: z18.string().min(1, "Checkpoint ID is required")
7184
7327
  }),
7185
7328
  responses: {
7186
7329
  200: checkpointResponseSchema,
@@ -7193,88 +7336,88 @@ var checkpointsByIdContract = c12.router({
7193
7336
  });
7194
7337
 
7195
7338
  // ../../packages/core/src/contracts/schedules.ts
7196
- import { z as z18 } from "zod";
7339
+ import { z as z19 } from "zod";
7197
7340
  var c13 = initContract();
7198
- var scheduleTriggerSchema = z18.object({
7199
- cron: z18.string().optional(),
7200
- at: z18.string().optional(),
7201
- timezone: z18.string().default("UTC")
7341
+ var scheduleTriggerSchema = z19.object({
7342
+ cron: z19.string().optional(),
7343
+ at: z19.string().optional(),
7344
+ timezone: z19.string().default("UTC")
7202
7345
  }).refine((data) => data.cron && !data.at || !data.cron && data.at, {
7203
7346
  message: "Exactly one of 'cron' or 'at' must be specified"
7204
7347
  });
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()
7348
+ var scheduleRunConfigSchema = z19.object({
7349
+ agent: z19.string().min(1, "Agent reference required"),
7350
+ prompt: z19.string().min(1, "Prompt required"),
7351
+ vars: z19.record(z19.string(), z19.string()).optional(),
7352
+ secrets: z19.record(z19.string(), z19.string()).optional(),
7353
+ artifactName: z19.string().optional(),
7354
+ artifactVersion: z19.string().optional(),
7355
+ volumeVersions: z19.record(z19.string(), z19.string()).optional()
7213
7356
  });
7214
- var scheduleDefinitionSchema = z18.object({
7357
+ var scheduleDefinitionSchema = z19.object({
7215
7358
  on: scheduleTriggerSchema,
7216
7359
  run: scheduleRunConfigSchema
7217
7360
  });
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(),
7361
+ var scheduleYamlSchema = z19.object({
7362
+ version: z19.literal("1.0"),
7363
+ schedules: z19.record(z19.string(), scheduleDefinitionSchema)
7364
+ });
7365
+ var deployScheduleRequestSchema = z19.object({
7366
+ name: z19.string().min(1).max(64, "Schedule name max 64 chars"),
7367
+ cronExpression: z19.string().optional(),
7368
+ atTime: z19.string().optional(),
7369
+ timezone: z19.string().default("UTC"),
7370
+ prompt: z19.string().min(1, "Prompt required"),
7371
+ vars: z19.record(z19.string(), z19.string()).optional(),
7372
+ secrets: z19.record(z19.string(), z19.string()).optional(),
7373
+ artifactName: z19.string().optional(),
7374
+ artifactVersion: z19.string().optional(),
7375
+ volumeVersions: z19.record(z19.string(), z19.string()).optional(),
7233
7376
  // Resolved agent compose ID (CLI resolves scope/name:version → composeId)
7234
- composeId: z18.string().uuid("Invalid compose ID")
7377
+ composeId: z19.string().uuid("Invalid compose ID")
7235
7378
  }).refine(
7236
7379
  (data) => data.cronExpression && !data.atTime || !data.cronExpression && data.atTime,
7237
7380
  {
7238
7381
  message: "Exactly one of 'cronExpression' or 'atTime' must be specified"
7239
7382
  }
7240
7383
  );
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(),
7384
+ var scheduleResponseSchema = z19.object({
7385
+ id: z19.string().uuid(),
7386
+ composeId: z19.string().uuid(),
7387
+ composeName: z19.string(),
7388
+ scopeSlug: z19.string(),
7389
+ name: z19.string(),
7390
+ cronExpression: z19.string().nullable(),
7391
+ atTime: z19.string().nullable(),
7392
+ timezone: z19.string(),
7393
+ prompt: z19.string(),
7394
+ vars: z19.record(z19.string(), z19.string()).nullable(),
7252
7395
  // 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({
7396
+ secretNames: z19.array(z19.string()).nullable(),
7397
+ artifactName: z19.string().nullable(),
7398
+ artifactVersion: z19.string().nullable(),
7399
+ volumeVersions: z19.record(z19.string(), z19.string()).nullable(),
7400
+ enabled: z19.boolean(),
7401
+ nextRunAt: z19.string().nullable(),
7402
+ createdAt: z19.string(),
7403
+ updatedAt: z19.string()
7404
+ });
7405
+ var runSummarySchema = z19.object({
7406
+ id: z19.string().uuid(),
7407
+ status: z19.enum(["pending", "running", "completed", "failed", "timeout"]),
7408
+ createdAt: z19.string(),
7409
+ completedAt: z19.string().nullable(),
7410
+ error: z19.string().nullable()
7411
+ });
7412
+ var scheduleRunsResponseSchema = z19.object({
7413
+ runs: z19.array(runSummarySchema)
7414
+ });
7415
+ var scheduleListResponseSchema = z19.object({
7416
+ schedules: z19.array(scheduleResponseSchema)
7417
+ });
7418
+ var deployScheduleResponseSchema = z19.object({
7276
7419
  schedule: scheduleResponseSchema,
7277
- created: z18.boolean()
7420
+ created: z19.boolean()
7278
7421
  // true if created, false if updated
7279
7422
  });
7280
7423
  var schedulesMainContract = c13.router({
@@ -7324,11 +7467,11 @@ var schedulesByNameContract = c13.router({
7324
7467
  method: "GET",
7325
7468
  path: "/api/agent/schedules/:name",
7326
7469
  headers: authHeadersSchema,
7327
- pathParams: z18.object({
7328
- name: z18.string().min(1, "Schedule name required")
7470
+ pathParams: z19.object({
7471
+ name: z19.string().min(1, "Schedule name required")
7329
7472
  }),
7330
- query: z18.object({
7331
- composeId: z18.string().uuid("Compose ID required")
7473
+ query: z19.object({
7474
+ composeId: z19.string().uuid("Compose ID required")
7332
7475
  }),
7333
7476
  responses: {
7334
7477
  200: scheduleResponseSchema,
@@ -7345,14 +7488,14 @@ var schedulesByNameContract = c13.router({
7345
7488
  method: "DELETE",
7346
7489
  path: "/api/agent/schedules/:name",
7347
7490
  headers: authHeadersSchema,
7348
- pathParams: z18.object({
7349
- name: z18.string().min(1, "Schedule name required")
7491
+ pathParams: z19.object({
7492
+ name: z19.string().min(1, "Schedule name required")
7350
7493
  }),
7351
- query: z18.object({
7352
- composeId: z18.string().uuid("Compose ID required")
7494
+ query: z19.object({
7495
+ composeId: z19.string().uuid("Compose ID required")
7353
7496
  }),
7354
7497
  responses: {
7355
- 204: z18.undefined(),
7498
+ 204: z19.undefined(),
7356
7499
  401: apiErrorSchema,
7357
7500
  404: apiErrorSchema
7358
7501
  },
@@ -7368,11 +7511,11 @@ var schedulesEnableContract = c13.router({
7368
7511
  method: "POST",
7369
7512
  path: "/api/agent/schedules/:name/enable",
7370
7513
  headers: authHeadersSchema,
7371
- pathParams: z18.object({
7372
- name: z18.string().min(1, "Schedule name required")
7514
+ pathParams: z19.object({
7515
+ name: z19.string().min(1, "Schedule name required")
7373
7516
  }),
7374
- body: z18.object({
7375
- composeId: z18.string().uuid("Compose ID required")
7517
+ body: z19.object({
7518
+ composeId: z19.string().uuid("Compose ID required")
7376
7519
  }),
7377
7520
  responses: {
7378
7521
  200: scheduleResponseSchema,
@@ -7389,11 +7532,11 @@ var schedulesEnableContract = c13.router({
7389
7532
  method: "POST",
7390
7533
  path: "/api/agent/schedules/:name/disable",
7391
7534
  headers: authHeadersSchema,
7392
- pathParams: z18.object({
7393
- name: z18.string().min(1, "Schedule name required")
7535
+ pathParams: z19.object({
7536
+ name: z19.string().min(1, "Schedule name required")
7394
7537
  }),
7395
- body: z18.object({
7396
- composeId: z18.string().uuid("Compose ID required")
7538
+ body: z19.object({
7539
+ composeId: z19.string().uuid("Compose ID required")
7397
7540
  }),
7398
7541
  responses: {
7399
7542
  200: scheduleResponseSchema,
@@ -7412,12 +7555,12 @@ var scheduleRunsContract = c13.router({
7412
7555
  method: "GET",
7413
7556
  path: "/api/agent/schedules/:name/runs",
7414
7557
  headers: authHeadersSchema,
7415
- pathParams: z18.object({
7416
- name: z18.string().min(1, "Schedule name required")
7558
+ pathParams: z19.object({
7559
+ name: z19.string().min(1, "Schedule name required")
7417
7560
  }),
7418
- query: z18.object({
7419
- composeId: z18.string().uuid("Compose ID required"),
7420
- limit: z18.coerce.number().min(0).max(100).default(5)
7561
+ query: z19.object({
7562
+ composeId: z19.string().uuid("Compose ID required"),
7563
+ limit: z19.coerce.number().min(0).max(100).default(5)
7421
7564
  }),
7422
7565
  responses: {
7423
7566
  200: scheduleRunsResponseSchema,
@@ -7429,16 +7572,16 @@ var scheduleRunsContract = c13.router({
7429
7572
  });
7430
7573
 
7431
7574
  // ../../packages/core/src/contracts/realtime.ts
7432
- import { z as z19 } from "zod";
7575
+ import { z as z20 } from "zod";
7433
7576
  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()
7577
+ var ablyTokenRequestSchema = z20.object({
7578
+ keyName: z20.string(),
7579
+ ttl: z20.number().optional(),
7580
+ timestamp: z20.number(),
7581
+ capability: z20.string(),
7582
+ clientId: z20.string().optional(),
7583
+ nonce: z20.string(),
7584
+ mac: z20.string()
7442
7585
  });
7443
7586
  var realtimeTokenContract = c14.router({
7444
7587
  /**
@@ -7449,8 +7592,8 @@ var realtimeTokenContract = c14.router({
7449
7592
  method: "POST",
7450
7593
  path: "/api/realtime/token",
7451
7594
  headers: authHeadersSchema,
7452
- body: z19.object({
7453
- runId: z19.string().uuid("runId must be a valid UUID")
7595
+ body: z20.object({
7596
+ runId: z20.string().uuid("runId must be a valid UUID")
7454
7597
  }),
7455
7598
  responses: {
7456
7599
  200: ablyTokenRequestSchema,
@@ -7462,13 +7605,34 @@ var realtimeTokenContract = c14.router({
7462
7605
  summary: "Get Ably token for run event subscription"
7463
7606
  }
7464
7607
  });
7608
+ var runnerRealtimeTokenContract = c14.router({
7609
+ /**
7610
+ * POST /api/runners/realtime/token
7611
+ * Get an Ably token to subscribe to a runner group's job notification channel
7612
+ */
7613
+ create: {
7614
+ method: "POST",
7615
+ path: "/api/runners/realtime/token",
7616
+ headers: authHeadersSchema,
7617
+ body: z20.object({
7618
+ group: runnerGroupSchema
7619
+ }),
7620
+ responses: {
7621
+ 200: ablyTokenRequestSchema,
7622
+ 401: apiErrorSchema,
7623
+ 403: apiErrorSchema,
7624
+ 500: apiErrorSchema
7625
+ },
7626
+ summary: "Get Ably token for runner group job notifications"
7627
+ }
7628
+ });
7465
7629
 
7466
7630
  // ../../packages/core/src/contracts/platform.ts
7467
- import { z as z21 } from "zod";
7631
+ import { z as z22 } from "zod";
7468
7632
 
7469
7633
  // ../../packages/core/src/contracts/public/common.ts
7470
- import { z as z20 } from "zod";
7471
- var publicApiErrorTypeSchema = z20.enum([
7634
+ import { z as z21 } from "zod";
7635
+ var publicApiErrorTypeSchema = z21.enum([
7472
7636
  "api_error",
7473
7637
  // Internal server error (5xx)
7474
7638
  "invalid_request_error",
@@ -7482,40 +7646,40 @@ var publicApiErrorTypeSchema = z20.enum([
7482
7646
  "rate_limit_error"
7483
7647
  // Rate limit exceeded (429)
7484
7648
  ]);
7485
- var publicApiErrorSchema = z20.object({
7486
- error: z20.object({
7649
+ var publicApiErrorSchema = z21.object({
7650
+ error: z21.object({
7487
7651
  type: publicApiErrorTypeSchema,
7488
- code: z20.string(),
7489
- message: z20.string(),
7490
- param: z20.string().optional(),
7491
- docUrl: z20.string().url().optional()
7652
+ code: z21.string(),
7653
+ message: z21.string(),
7654
+ param: z21.string().optional(),
7655
+ docUrl: z21.string().url().optional()
7492
7656
  })
7493
7657
  });
7494
- var paginationSchema = z20.object({
7495
- hasMore: z20.boolean(),
7496
- nextCursor: z20.string().nullable()
7658
+ var paginationSchema = z21.object({
7659
+ hasMore: z21.boolean(),
7660
+ nextCursor: z21.string().nullable()
7497
7661
  });
7498
7662
  function createPaginatedResponseSchema(dataSchema) {
7499
- return z20.object({
7500
- data: z20.array(dataSchema),
7663
+ return z21.object({
7664
+ data: z21.array(dataSchema),
7501
7665
  pagination: paginationSchema
7502
7666
  });
7503
7667
  }
7504
- var listQuerySchema = z20.object({
7505
- cursor: z20.string().optional(),
7506
- limit: z20.coerce.number().min(1).max(100).default(20)
7668
+ var listQuerySchema = z21.object({
7669
+ cursor: z21.string().optional(),
7670
+ limit: z21.coerce.number().min(1).max(100).default(20)
7507
7671
  });
7508
- var requestIdSchema = z20.string().uuid();
7509
- var timestampSchema = z20.string().datetime();
7672
+ var requestIdSchema = z21.string().uuid();
7673
+ var timestampSchema = z21.string().datetime();
7510
7674
 
7511
7675
  // ../../packages/core/src/contracts/platform.ts
7512
7676
  var c15 = initContract();
7513
- var platformPaginationSchema = z21.object({
7514
- hasMore: z21.boolean(),
7515
- nextCursor: z21.string().nullable(),
7516
- totalPages: z21.number()
7677
+ var platformPaginationSchema = z22.object({
7678
+ hasMore: z22.boolean(),
7679
+ nextCursor: z22.string().nullable(),
7680
+ totalPages: z22.number()
7517
7681
  });
7518
- var platformLogStatusSchema = z21.enum([
7682
+ var platformLogStatusSchema = z22.enum([
7519
7683
  "pending",
7520
7684
  "running",
7521
7685
  "completed",
@@ -7523,28 +7687,28 @@ var platformLogStatusSchema = z21.enum([
7523
7687
  "timeout",
7524
7688
  "cancelled"
7525
7689
  ]);
7526
- var platformLogEntrySchema = z21.object({
7527
- id: z21.string().uuid()
7690
+ var platformLogEntrySchema = z22.object({
7691
+ id: z22.string().uuid()
7528
7692
  });
7529
- var platformLogsListResponseSchema = z21.object({
7530
- data: z21.array(platformLogEntrySchema),
7693
+ var platformLogsListResponseSchema = z22.object({
7694
+ data: z22.array(platformLogEntrySchema),
7531
7695
  pagination: platformPaginationSchema
7532
7696
  });
7533
- var artifactSchema = z21.object({
7534
- name: z21.string().nullable(),
7535
- version: z21.string().nullable()
7697
+ var artifactSchema = z22.object({
7698
+ name: z22.string().nullable(),
7699
+ version: z22.string().nullable()
7536
7700
  });
7537
- var platformLogDetailSchema = z21.object({
7538
- id: z21.string().uuid(),
7539
- sessionId: z21.string().nullable(),
7540
- agentName: z21.string(),
7541
- framework: z21.string().nullable(),
7701
+ var platformLogDetailSchema = z22.object({
7702
+ id: z22.string().uuid(),
7703
+ sessionId: z22.string().nullable(),
7704
+ agentName: z22.string(),
7705
+ framework: z22.string().nullable(),
7542
7706
  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(),
7707
+ prompt: z22.string(),
7708
+ error: z22.string().nullable(),
7709
+ createdAt: z22.string(),
7710
+ startedAt: z22.string().nullable(),
7711
+ completedAt: z22.string().nullable(),
7548
7712
  artifact: artifactSchema
7549
7713
  });
7550
7714
  var platformLogsListContract = c15.router({
@@ -7552,7 +7716,7 @@ var platformLogsListContract = c15.router({
7552
7716
  method: "GET",
7553
7717
  path: "/api/platform/logs",
7554
7718
  query: listQuerySchema.extend({
7555
- search: z21.string().optional()
7719
+ search: z22.string().optional()
7556
7720
  }),
7557
7721
  responses: {
7558
7722
  200: platformLogsListResponseSchema,
@@ -7565,8 +7729,8 @@ var platformLogsByIdContract = c15.router({
7565
7729
  getById: {
7566
7730
  method: "GET",
7567
7731
  path: "/api/platform/logs/:id",
7568
- pathParams: z21.object({
7569
- id: z21.string().uuid("Invalid log ID")
7732
+ pathParams: z22.object({
7733
+ id: z22.string().uuid("Invalid log ID")
7570
7734
  }),
7571
7735
  responses: {
7572
7736
  200: platformLogDetailSchema,
@@ -7576,17 +7740,17 @@ var platformLogsByIdContract = c15.router({
7576
7740
  summary: "Get agent run log details by ID"
7577
7741
  }
7578
7742
  });
7579
- var artifactDownloadResponseSchema = z21.object({
7580
- url: z21.string().url(),
7581
- expiresAt: z21.string()
7743
+ var artifactDownloadResponseSchema = z22.object({
7744
+ url: z22.string().url(),
7745
+ expiresAt: z22.string()
7582
7746
  });
7583
7747
  var platformArtifactDownloadContract = c15.router({
7584
7748
  getDownloadUrl: {
7585
7749
  method: "GET",
7586
7750
  path: "/api/platform/artifacts/download",
7587
- query: z21.object({
7588
- name: z21.string().min(1, "Artifact name is required"),
7589
- version: z21.string().optional()
7751
+ query: z22.object({
7752
+ name: z22.string().min(1, "Artifact name is required"),
7753
+ version: z22.string().optional()
7590
7754
  }),
7591
7755
  responses: {
7592
7756
  200: artifactDownloadResponseSchema,
@@ -7598,26 +7762,26 @@ var platformArtifactDownloadContract = c15.router({
7598
7762
  });
7599
7763
 
7600
7764
  // ../../packages/core/src/contracts/public/agents.ts
7601
- import { z as z22 } from "zod";
7765
+ import { z as z23 } from "zod";
7602
7766
  var c16 = initContract();
7603
- var publicAgentSchema = z22.object({
7604
- id: z22.string(),
7605
- name: z22.string(),
7606
- currentVersionId: z22.string().nullable(),
7767
+ var publicAgentSchema = z23.object({
7768
+ id: z23.string(),
7769
+ name: z23.string(),
7770
+ currentVersionId: z23.string().nullable(),
7607
7771
  createdAt: timestampSchema,
7608
7772
  updatedAt: timestampSchema
7609
7773
  });
7610
- var agentVersionSchema = z22.object({
7611
- id: z22.string(),
7612
- agentId: z22.string(),
7613
- versionNumber: z22.number(),
7774
+ var agentVersionSchema = z23.object({
7775
+ id: z23.string(),
7776
+ agentId: z23.string(),
7777
+ versionNumber: z23.number(),
7614
7778
  createdAt: timestampSchema
7615
7779
  });
7616
7780
  var publicAgentDetailSchema = publicAgentSchema;
7617
7781
  var paginatedAgentsSchema = createPaginatedResponseSchema(publicAgentSchema);
7618
7782
  var paginatedAgentVersionsSchema = createPaginatedResponseSchema(agentVersionSchema);
7619
7783
  var agentListQuerySchema = listQuerySchema.extend({
7620
- name: z22.string().optional()
7784
+ name: z23.string().optional()
7621
7785
  });
7622
7786
  var publicAgentsListContract = c16.router({
7623
7787
  list: {
@@ -7639,8 +7803,8 @@ var publicAgentByIdContract = c16.router({
7639
7803
  method: "GET",
7640
7804
  path: "/v1/agents/:id",
7641
7805
  headers: authHeadersSchema,
7642
- pathParams: z22.object({
7643
- id: z22.string().min(1, "Agent ID is required")
7806
+ pathParams: z23.object({
7807
+ id: z23.string().min(1, "Agent ID is required")
7644
7808
  }),
7645
7809
  responses: {
7646
7810
  200: publicAgentDetailSchema,
@@ -7657,8 +7821,8 @@ var publicAgentVersionsContract = c16.router({
7657
7821
  method: "GET",
7658
7822
  path: "/v1/agents/:id/versions",
7659
7823
  headers: authHeadersSchema,
7660
- pathParams: z22.object({
7661
- id: z22.string().min(1, "Agent ID is required")
7824
+ pathParams: z23.object({
7825
+ id: z23.string().min(1, "Agent ID is required")
7662
7826
  }),
7663
7827
  query: listQuerySchema,
7664
7828
  responses: {
@@ -7673,9 +7837,9 @@ var publicAgentVersionsContract = c16.router({
7673
7837
  });
7674
7838
 
7675
7839
  // ../../packages/core/src/contracts/public/runs.ts
7676
- import { z as z23 } from "zod";
7840
+ import { z as z24 } from "zod";
7677
7841
  var c17 = initContract();
7678
- var publicRunStatusSchema = z23.enum([
7842
+ var publicRunStatusSchema = z24.enum([
7679
7843
  "pending",
7680
7844
  "running",
7681
7845
  "completed",
@@ -7683,48 +7847,48 @@ var publicRunStatusSchema = z23.enum([
7683
7847
  "timeout",
7684
7848
  "cancelled"
7685
7849
  ]);
7686
- var publicRunSchema = z23.object({
7687
- id: z23.string(),
7688
- agentId: z23.string(),
7689
- agentName: z23.string(),
7850
+ var publicRunSchema = z24.object({
7851
+ id: z24.string(),
7852
+ agentId: z24.string(),
7853
+ agentName: z24.string(),
7690
7854
  status: publicRunStatusSchema,
7691
- prompt: z23.string(),
7855
+ prompt: z24.string(),
7692
7856
  createdAt: timestampSchema,
7693
7857
  startedAt: timestampSchema.nullable(),
7694
7858
  completedAt: timestampSchema.nullable()
7695
7859
  });
7696
7860
  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()
7861
+ error: z24.string().nullable(),
7862
+ executionTimeMs: z24.number().nullable(),
7863
+ checkpointId: z24.string().nullable(),
7864
+ sessionId: z24.string().nullable(),
7865
+ artifactName: z24.string().nullable(),
7866
+ artifactVersion: z24.string().nullable(),
7867
+ volumes: z24.record(z24.string(), z24.string()).optional()
7704
7868
  });
7705
7869
  var paginatedRunsSchema = createPaginatedResponseSchema(publicRunSchema);
7706
- var createRunRequestSchema = z23.object({
7870
+ var createRunRequestSchema = z24.object({
7707
7871
  // Agent identification (one of: agent, agentId, sessionId, checkpointId)
7708
- agent: z23.string().optional(),
7872
+ agent: z24.string().optional(),
7709
7873
  // Agent name
7710
- agentId: z23.string().optional(),
7874
+ agentId: z24.string().optional(),
7711
7875
  // Agent ID
7712
- agentVersion: z23.string().optional(),
7876
+ agentVersion: z24.string().optional(),
7713
7877
  // Version specifier (e.g., "latest", "v1", specific ID)
7714
7878
  // Continue session
7715
- sessionId: z23.string().optional(),
7879
+ sessionId: z24.string().optional(),
7716
7880
  // Resume from checkpoint
7717
- checkpointId: z23.string().optional(),
7881
+ checkpointId: z24.string().optional(),
7718
7882
  // Required
7719
- prompt: z23.string().min(1, "Prompt is required"),
7883
+ prompt: z24.string().min(1, "Prompt is required"),
7720
7884
  // 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(),
7885
+ variables: z24.record(z24.string(), z24.string()).optional(),
7886
+ secrets: z24.record(z24.string(), z24.string()).optional(),
7887
+ artifactName: z24.string().optional(),
7724
7888
  // Artifact name to mount
7725
- artifactVersion: z23.string().optional(),
7889
+ artifactVersion: z24.string().optional(),
7726
7890
  // Artifact version (defaults to latest)
7727
- volumes: z23.record(z23.string(), z23.string()).optional()
7891
+ volumes: z24.record(z24.string(), z24.string()).optional()
7728
7892
  // volume_name -> version
7729
7893
  });
7730
7894
  var runListQuerySchema = listQuerySchema.extend({
@@ -7767,8 +7931,8 @@ var publicRunByIdContract = c17.router({
7767
7931
  method: "GET",
7768
7932
  path: "/v1/runs/:id",
7769
7933
  headers: authHeadersSchema,
7770
- pathParams: z23.object({
7771
- id: z23.string().min(1, "Run ID is required")
7934
+ pathParams: z24.object({
7935
+ id: z24.string().min(1, "Run ID is required")
7772
7936
  }),
7773
7937
  responses: {
7774
7938
  200: publicRunDetailSchema,
@@ -7785,10 +7949,10 @@ var publicRunCancelContract = c17.router({
7785
7949
  method: "POST",
7786
7950
  path: "/v1/runs/:id/cancel",
7787
7951
  headers: authHeadersSchema,
7788
- pathParams: z23.object({
7789
- id: z23.string().min(1, "Run ID is required")
7952
+ pathParams: z24.object({
7953
+ id: z24.string().min(1, "Run ID is required")
7790
7954
  }),
7791
- body: z23.undefined(),
7955
+ body: z24.undefined(),
7792
7956
  responses: {
7793
7957
  200: publicRunDetailSchema,
7794
7958
  400: publicApiErrorSchema,
@@ -7801,27 +7965,27 @@ var publicRunCancelContract = c17.router({
7801
7965
  description: "Cancel a pending or running execution"
7802
7966
  }
7803
7967
  });
7804
- var logEntrySchema = z23.object({
7968
+ var logEntrySchema = z24.object({
7805
7969
  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()
7970
+ type: z24.enum(["agent", "system", "network"]),
7971
+ level: z24.enum(["debug", "info", "warn", "error"]),
7972
+ message: z24.string(),
7973
+ metadata: z24.record(z24.string(), z24.unknown()).optional()
7810
7974
  });
7811
7975
  var paginatedLogsSchema = createPaginatedResponseSchema(logEntrySchema);
7812
7976
  var logsQuerySchema = listQuerySchema.extend({
7813
- type: z23.enum(["agent", "system", "network", "all"]).default("all"),
7977
+ type: z24.enum(["agent", "system", "network", "all"]).default("all"),
7814
7978
  since: timestampSchema.optional(),
7815
7979
  until: timestampSchema.optional(),
7816
- order: z23.enum(["asc", "desc"]).default("asc")
7980
+ order: z24.enum(["asc", "desc"]).default("asc")
7817
7981
  });
7818
7982
  var publicRunLogsContract = c17.router({
7819
7983
  getLogs: {
7820
7984
  method: "GET",
7821
7985
  path: "/v1/runs/:id/logs",
7822
7986
  headers: authHeadersSchema,
7823
- pathParams: z23.object({
7824
- id: z23.string().min(1, "Run ID is required")
7987
+ pathParams: z24.object({
7988
+ id: z24.string().min(1, "Run ID is required")
7825
7989
  }),
7826
7990
  query: logsQuerySchema,
7827
7991
  responses: {
@@ -7834,21 +7998,21 @@ var publicRunLogsContract = c17.router({
7834
7998
  description: "Get unified logs for a run. Combines agent, system, and network logs."
7835
7999
  }
7836
8000
  });
7837
- var metricPointSchema = z23.object({
8001
+ var metricPointSchema = z24.object({
7838
8002
  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),
8003
+ cpuPercent: z24.number(),
8004
+ memoryUsedMb: z24.number(),
8005
+ memoryTotalMb: z24.number(),
8006
+ diskUsedMb: z24.number(),
8007
+ diskTotalMb: z24.number()
8008
+ });
8009
+ var metricsSummarySchema = z24.object({
8010
+ avgCpuPercent: z24.number(),
8011
+ maxMemoryUsedMb: z24.number(),
8012
+ totalDurationMs: z24.number().nullable()
8013
+ });
8014
+ var metricsResponseSchema2 = z24.object({
8015
+ data: z24.array(metricPointSchema),
7852
8016
  summary: metricsSummarySchema
7853
8017
  });
7854
8018
  var publicRunMetricsContract = c17.router({
@@ -7856,8 +8020,8 @@ var publicRunMetricsContract = c17.router({
7856
8020
  method: "GET",
7857
8021
  path: "/v1/runs/:id/metrics",
7858
8022
  headers: authHeadersSchema,
7859
- pathParams: z23.object({
7860
- id: z23.string().min(1, "Run ID is required")
8023
+ pathParams: z24.object({
8024
+ id: z24.string().min(1, "Run ID is required")
7861
8025
  }),
7862
8026
  responses: {
7863
8027
  200: metricsResponseSchema2,
@@ -7869,7 +8033,7 @@ var publicRunMetricsContract = c17.router({
7869
8033
  description: "Get CPU, memory, and disk metrics for a run"
7870
8034
  }
7871
8035
  });
7872
- var sseEventTypeSchema = z23.enum([
8036
+ var sseEventTypeSchema = z24.enum([
7873
8037
  "status",
7874
8038
  // Run status change
7875
8039
  "output",
@@ -7881,10 +8045,10 @@ var sseEventTypeSchema = z23.enum([
7881
8045
  "heartbeat"
7882
8046
  // Keep-alive
7883
8047
  ]);
7884
- var sseEventSchema = z23.object({
8048
+ var sseEventSchema = z24.object({
7885
8049
  event: sseEventTypeSchema,
7886
- data: z23.unknown(),
7887
- id: z23.string().optional()
8050
+ data: z24.unknown(),
8051
+ id: z24.string().optional()
7888
8052
  // For Last-Event-ID reconnection
7889
8053
  });
7890
8054
  var publicRunEventsContract = c17.router({
@@ -7892,15 +8056,15 @@ var publicRunEventsContract = c17.router({
7892
8056
  method: "GET",
7893
8057
  path: "/v1/runs/:id/events",
7894
8058
  headers: authHeadersSchema,
7895
- pathParams: z23.object({
7896
- id: z23.string().min(1, "Run ID is required")
8059
+ pathParams: z24.object({
8060
+ id: z24.string().min(1, "Run ID is required")
7897
8061
  }),
7898
- query: z23.object({
7899
- lastEventId: z23.string().optional()
8062
+ query: z24.object({
8063
+ lastEventId: z24.string().optional()
7900
8064
  // For reconnection
7901
8065
  }),
7902
8066
  responses: {
7903
- 200: z23.any(),
8067
+ 200: z24.any(),
7904
8068
  // SSE stream - actual content is text/event-stream
7905
8069
  401: publicApiErrorSchema,
7906
8070
  404: publicApiErrorSchema,
@@ -7912,28 +8076,28 @@ var publicRunEventsContract = c17.router({
7912
8076
  });
7913
8077
 
7914
8078
  // ../../packages/core/src/contracts/public/artifacts.ts
7915
- import { z as z24 } from "zod";
8079
+ import { z as z25 } from "zod";
7916
8080
  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(),
8081
+ var publicArtifactSchema = z25.object({
8082
+ id: z25.string(),
8083
+ name: z25.string(),
8084
+ currentVersionId: z25.string().nullable(),
8085
+ size: z25.number(),
7922
8086
  // Total size in bytes
7923
- fileCount: z24.number(),
8087
+ fileCount: z25.number(),
7924
8088
  createdAt: timestampSchema,
7925
8089
  updatedAt: timestampSchema
7926
8090
  });
7927
- var artifactVersionSchema = z24.object({
7928
- id: z24.string(),
8091
+ var artifactVersionSchema = z25.object({
8092
+ id: z25.string(),
7929
8093
  // SHA-256 content hash
7930
- artifactId: z24.string(),
7931
- size: z24.number(),
8094
+ artifactId: z25.string(),
8095
+ size: z25.number(),
7932
8096
  // Size in bytes
7933
- fileCount: z24.number(),
7934
- message: z24.string().nullable(),
8097
+ fileCount: z25.number(),
8098
+ message: z25.string().nullable(),
7935
8099
  // Optional commit message
7936
- createdBy: z24.string(),
8100
+ createdBy: z25.string(),
7937
8101
  createdAt: timestampSchema
7938
8102
  });
7939
8103
  var publicArtifactDetailSchema = publicArtifactSchema.extend({
@@ -7963,8 +8127,8 @@ var publicArtifactByIdContract = c18.router({
7963
8127
  method: "GET",
7964
8128
  path: "/v1/artifacts/:id",
7965
8129
  headers: authHeadersSchema,
7966
- pathParams: z24.object({
7967
- id: z24.string().min(1, "Artifact ID is required")
8130
+ pathParams: z25.object({
8131
+ id: z25.string().min(1, "Artifact ID is required")
7968
8132
  }),
7969
8133
  responses: {
7970
8134
  200: publicArtifactDetailSchema,
@@ -7981,8 +8145,8 @@ var publicArtifactVersionsContract = c18.router({
7981
8145
  method: "GET",
7982
8146
  path: "/v1/artifacts/:id/versions",
7983
8147
  headers: authHeadersSchema,
7984
- pathParams: z24.object({
7985
- id: z24.string().min(1, "Artifact ID is required")
8148
+ pathParams: z25.object({
8149
+ id: z25.string().min(1, "Artifact ID is required")
7986
8150
  }),
7987
8151
  query: listQuerySchema,
7988
8152
  responses: {
@@ -8000,15 +8164,15 @@ var publicArtifactDownloadContract = c18.router({
8000
8164
  method: "GET",
8001
8165
  path: "/v1/artifacts/:id/download",
8002
8166
  headers: authHeadersSchema,
8003
- pathParams: z24.object({
8004
- id: z24.string().min(1, "Artifact ID is required")
8167
+ pathParams: z25.object({
8168
+ id: z25.string().min(1, "Artifact ID is required")
8005
8169
  }),
8006
- query: z24.object({
8007
- versionId: z24.string().optional()
8170
+ query: z25.object({
8171
+ versionId: z25.string().optional()
8008
8172
  // Defaults to current version
8009
8173
  }),
8010
8174
  responses: {
8011
- 302: z24.undefined(),
8175
+ 302: z25.undefined(),
8012
8176
  // Redirect to presigned URL
8013
8177
  401: publicApiErrorSchema,
8014
8178
  404: publicApiErrorSchema,
@@ -8020,28 +8184,28 @@ var publicArtifactDownloadContract = c18.router({
8020
8184
  });
8021
8185
 
8022
8186
  // ../../packages/core/src/contracts/public/volumes.ts
8023
- import { z as z25 } from "zod";
8187
+ import { z as z26 } from "zod";
8024
8188
  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(),
8189
+ var publicVolumeSchema = z26.object({
8190
+ id: z26.string(),
8191
+ name: z26.string(),
8192
+ currentVersionId: z26.string().nullable(),
8193
+ size: z26.number(),
8030
8194
  // Total size in bytes
8031
- fileCount: z25.number(),
8195
+ fileCount: z26.number(),
8032
8196
  createdAt: timestampSchema,
8033
8197
  updatedAt: timestampSchema
8034
8198
  });
8035
- var volumeVersionSchema = z25.object({
8036
- id: z25.string(),
8199
+ var volumeVersionSchema = z26.object({
8200
+ id: z26.string(),
8037
8201
  // SHA-256 content hash
8038
- volumeId: z25.string(),
8039
- size: z25.number(),
8202
+ volumeId: z26.string(),
8203
+ size: z26.number(),
8040
8204
  // Size in bytes
8041
- fileCount: z25.number(),
8042
- message: z25.string().nullable(),
8205
+ fileCount: z26.number(),
8206
+ message: z26.string().nullable(),
8043
8207
  // Optional commit message
8044
- createdBy: z25.string(),
8208
+ createdBy: z26.string(),
8045
8209
  createdAt: timestampSchema
8046
8210
  });
8047
8211
  var publicVolumeDetailSchema = publicVolumeSchema.extend({
@@ -8069,8 +8233,8 @@ var publicVolumeByIdContract = c19.router({
8069
8233
  method: "GET",
8070
8234
  path: "/v1/volumes/:id",
8071
8235
  headers: authHeadersSchema,
8072
- pathParams: z25.object({
8073
- id: z25.string().min(1, "Volume ID is required")
8236
+ pathParams: z26.object({
8237
+ id: z26.string().min(1, "Volume ID is required")
8074
8238
  }),
8075
8239
  responses: {
8076
8240
  200: publicVolumeDetailSchema,
@@ -8087,8 +8251,8 @@ var publicVolumeVersionsContract = c19.router({
8087
8251
  method: "GET",
8088
8252
  path: "/v1/volumes/:id/versions",
8089
8253
  headers: authHeadersSchema,
8090
- pathParams: z25.object({
8091
- id: z25.string().min(1, "Volume ID is required")
8254
+ pathParams: z26.object({
8255
+ id: z26.string().min(1, "Volume ID is required")
8092
8256
  }),
8093
8257
  query: listQuerySchema,
8094
8258
  responses: {
@@ -8106,15 +8270,15 @@ var publicVolumeDownloadContract = c19.router({
8106
8270
  method: "GET",
8107
8271
  path: "/v1/volumes/:id/download",
8108
8272
  headers: authHeadersSchema,
8109
- pathParams: z25.object({
8110
- id: z25.string().min(1, "Volume ID is required")
8273
+ pathParams: z26.object({
8274
+ id: z26.string().min(1, "Volume ID is required")
8111
8275
  }),
8112
- query: z25.object({
8113
- versionId: z25.string().optional()
8276
+ query: z26.object({
8277
+ versionId: z26.string().optional()
8114
8278
  // Defaults to current version
8115
8279
  }),
8116
8280
  responses: {
8117
- 302: z25.undefined(),
8281
+ 302: z26.undefined(),
8118
8282
  // Redirect to presigned URL
8119
8283
  401: publicApiErrorSchema,
8120
8284
  404: publicApiErrorSchema,
@@ -9172,6 +9336,7 @@ function buildEnvironmentVariables(context, apiUrl) {
9172
9336
  VM0_API_TOKEN: context.sandboxToken,
9173
9337
  VM0_PROMPT: context.prompt,
9174
9338
  VM0_WORKING_DIR: context.workingDir,
9339
+ VM0_API_START_TIME: context.apiStartTime?.toString() ?? "",
9175
9340
  CLI_AGENT_TYPE: context.cliAgentType || "claude-code"
9176
9341
  };
9177
9342
  const vercelBypass = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
@@ -9743,18 +9908,27 @@ function setupSignalHandlers(state, handlers) {
9743
9908
  );
9744
9909
  state.mode = "draining";
9745
9910
  handlers.updateStatus();
9911
+ handlers.onDrain();
9746
9912
  }
9747
9913
  });
9748
9914
  }
9749
9915
 
9750
9916
  // src/lib/runner/runner.ts
9751
- var Runner = class {
9917
+ var Runner = class _Runner {
9752
9918
  config;
9753
9919
  statusFilePath;
9754
9920
  state;
9755
9921
  resources = null;
9756
- running = true;
9757
9922
  updateStatus;
9923
+ // Ably subscription
9924
+ subscription = null;
9925
+ // Queue for jobs received while at capacity (max 100 to prevent unbounded growth)
9926
+ static MAX_PENDING_QUEUE_SIZE = 100;
9927
+ pendingJobs = [];
9928
+ // Polling fallback interval
9929
+ pollInterval = null;
9930
+ // Shutdown coordination
9931
+ resolveShutdown = null;
9758
9932
  constructor(config, statusFilePath) {
9759
9933
  this.config = config;
9760
9934
  this.statusFilePath = statusFilePath;
@@ -9768,9 +9942,19 @@ var Runner = class {
9768
9942
  }
9769
9943
  async start() {
9770
9944
  this.resources = await setupEnvironment({ config: this.config });
9945
+ const shutdownPromise = new Promise((resolve) => {
9946
+ this.resolveShutdown = resolve;
9947
+ });
9771
9948
  setupSignalHandlers(this.state, {
9772
9949
  onShutdown: () => {
9773
- this.running = false;
9950
+ this.resolveShutdown?.();
9951
+ },
9952
+ onDrain: () => {
9953
+ this.pendingJobs.length = 0;
9954
+ if (this.state.activeRuns.size === 0) {
9955
+ console.log("[Maintenance] No active jobs, exiting immediately");
9956
+ this.resolveShutdown?.();
9957
+ }
9774
9958
  },
9775
9959
  updateStatus: this.updateStatus
9776
9960
  });
@@ -9782,7 +9966,36 @@ var Runner = class {
9782
9966
  console.log("Press Ctrl+C to stop");
9783
9967
  console.log("");
9784
9968
  this.updateStatus();
9785
- await this.runMainLoop();
9969
+ console.log("Checking for pending jobs...");
9970
+ await this.pollFallback();
9971
+ console.log("Connecting to realtime job notifications...");
9972
+ this.subscription = await subscribeToJobs(
9973
+ this.config.server,
9974
+ this.config.group,
9975
+ (notification) => {
9976
+ console.log(`Ably notification: ${notification.runId}`);
9977
+ this.processJob(notification.runId).catch(console.error);
9978
+ },
9979
+ (connectionState, reason) => {
9980
+ console.log(
9981
+ `Ably connection: ${connectionState}${reason ? ` (${reason})` : ""}`
9982
+ );
9983
+ }
9984
+ );
9985
+ console.log("Connected to realtime job notifications");
9986
+ this.pollInterval = setInterval(() => {
9987
+ this.pollFallback().catch(console.error);
9988
+ }, this.config.sandbox.poll_interval_ms);
9989
+ console.log(
9990
+ `Polling fallback enabled (every ${this.config.sandbox.poll_interval_ms / 1e3}s)`
9991
+ );
9992
+ await shutdownPromise;
9993
+ if (this.pollInterval) {
9994
+ clearInterval(this.pollInterval);
9995
+ }
9996
+ if (this.subscription) {
9997
+ this.subscription.cleanup();
9998
+ }
9786
9999
  if (this.state.jobPromises.size > 0) {
9787
10000
  console.log(
9788
10001
  `Waiting for ${this.state.jobPromises.size} active job(s) to complete...`
@@ -9795,50 +10008,52 @@ var Runner = class {
9795
10008
  console.log("Runner stopped");
9796
10009
  process.exit(0);
9797
10010
  }
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}`);
10011
+ /**
10012
+ * Poll for jobs as fallback mechanism.
10013
+ * Catches jobs that may have been missed by push notifications.
10014
+ */
10015
+ async pollFallback() {
10016
+ if (this.state.mode !== "running") return;
10017
+ if (this.state.activeRuns.size >= this.config.sandbox.max_concurrent)
10018
+ return;
10019
+ try {
10020
+ const job = await withRunnerTiming(
10021
+ "poll",
10022
+ () => pollForJob(this.config.server, this.config.group)
10023
+ );
10024
+ if (job) {
10025
+ console.log(`Poll fallback found job: ${job.runId}`);
9831
10026
  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
10027
  }
10028
+ } catch (error) {
10029
+ console.error(
10030
+ `Poll fallback error:`,
10031
+ error instanceof Error ? error.message : "Unknown error"
10032
+ );
9839
10033
  }
9840
10034
  }
10035
+ /**
10036
+ * Process a job notification - claim and execute.
10037
+ */
9841
10038
  async processJob(runId) {
10039
+ if (this.state.mode !== "running") {
10040
+ console.log(`Not running (${this.state.mode}), ignoring job ${runId}`);
10041
+ return;
10042
+ }
10043
+ if (this.state.activeRuns.has(runId)) {
10044
+ return;
10045
+ }
10046
+ if (this.state.activeRuns.size >= this.config.sandbox.max_concurrent) {
10047
+ if (!this.pendingJobs.includes(runId) && this.pendingJobs.length < _Runner.MAX_PENDING_QUEUE_SIZE) {
10048
+ console.log(`At capacity, queueing job ${runId}`);
10049
+ this.pendingJobs.push(runId);
10050
+ } else if (this.pendingJobs.length >= _Runner.MAX_PENDING_QUEUE_SIZE) {
10051
+ console.log(
10052
+ `Pending queue full (${_Runner.MAX_PENDING_QUEUE_SIZE}), dropping job ${runId}`
10053
+ );
10054
+ }
10055
+ return;
10056
+ }
9842
10057
  try {
9843
10058
  const context = await withRunnerTiming(
9844
10059
  "claim",
@@ -9856,6 +10071,17 @@ var Runner = class {
9856
10071
  this.state.activeRuns.delete(context.runId);
9857
10072
  this.state.jobPromises.delete(jobPromise);
9858
10073
  this.updateStatus();
10074
+ if (this.state.mode === "draining" && this.state.activeRuns.size === 0) {
10075
+ console.log("[Maintenance] All jobs completed, exiting");
10076
+ this.resolveShutdown?.();
10077
+ return;
10078
+ }
10079
+ if (this.pendingJobs.length > 0 && this.state.mode === "running") {
10080
+ const nextJob = this.pendingJobs.shift();
10081
+ if (nextJob) {
10082
+ this.processJob(nextJob).catch(console.error);
10083
+ }
10084
+ }
9859
10085
  });
9860
10086
  this.state.jobPromises.add(jobPromise);
9861
10087
  } catch (error) {
@@ -10494,7 +10720,7 @@ var benchmarkCommand = new Command4("benchmark").description(
10494
10720
  });
10495
10721
 
10496
10722
  // src/index.ts
10497
- var version = true ? "3.3.2" : "0.1.0";
10723
+ var version = true ? "3.5.0" : "0.1.0";
10498
10724
  program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
10499
10725
  program.addCommand(startCommand);
10500
10726
  program.addCommand(doctorCommand);