@vm0/runner 3.3.1 → 3.4.0

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