@vm0/runner 3.11.1 → 3.11.3

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 +708 -531
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -33,6 +33,8 @@ var runtimePaths = {
33
33
  };
34
34
  var VM_WORKSPACE_PREFIX = "vm0-";
35
35
  var runnerPaths = {
36
+ /** Base directory used for snapshot generation (baseDir + /snapshot-gen) */
37
+ snapshotBaseDir: (baseDir) => path.join(baseDir, "snapshot-gen"),
36
38
  /** Overlay pool directory for pre-warmed VM overlays */
37
39
  overlayPool: (baseDir) => path.join(baseDir, "overlay-pool"),
38
40
  /** Workspaces directory for VM work directories */
@@ -41,16 +43,24 @@ var runnerPaths = {
41
43
  vmWorkDir: (baseDir, vmId) => path.join(baseDir, "workspaces", `${VM_WORKSPACE_PREFIX}${vmId}`),
42
44
  /** Runner status file */
43
45
  statusFile: (baseDir) => path.join(baseDir, "status.json"),
46
+ /** Snapshot generation work directory */
47
+ snapshotWorkDir: (baseDir) => path.join(baseDir, "workspaces", ".snapshot-work"),
44
48
  /** Check if a directory name is a VM workspace */
45
49
  isVmWorkspace: (dirname) => dirname.startsWith(VM_WORKSPACE_PREFIX),
46
50
  /** Extract vmId from workspace directory name */
47
51
  extractVmId: (dirname) => createVmId(dirname.replace(VM_WORKSPACE_PREFIX, ""))
48
52
  };
49
53
  var vmPaths = {
50
- /** Firecracker config file (used with --config-file --no-api) */
54
+ /** Firecracker config file (used with --config-file) */
51
55
  config: (workDir) => path.join(workDir, "config.json"),
52
- /** Vsock UDS for host-guest communication */
53
- vsock: (workDir) => path.join(workDir, "vsock.sock")
56
+ /** Vsock directory for host-guest communication */
57
+ vsockDir: (workDir) => path.join(workDir, "vsock"),
58
+ /** Vsock UDS path for host-guest communication */
59
+ vsock: (workDir) => path.join(workDir, "vsock", "vsock.sock"),
60
+ /** Firecracker API socket (used with --api-sock) */
61
+ apiSock: (workDir) => path.join(workDir, "api.sock"),
62
+ /** Overlay filesystem for VM writes */
63
+ overlay: (workDir) => path.join(workDir, "overlay.ext4")
54
64
  };
55
65
  var tempPaths = {
56
66
  /** Default proxy CA directory */
@@ -325,15 +335,16 @@ async function subscribeToJobs(server, group, onJob, onConnectionChange) {
325
335
  };
326
336
  }
327
337
 
338
+ // src/lib/executor.ts
339
+ import fs9 from "fs";
340
+
328
341
  // src/lib/firecracker/vm.ts
329
342
  import { spawn } from "child_process";
330
343
  import fs4 from "fs";
331
344
  import readline from "readline";
332
345
 
333
346
  // src/lib/firecracker/netns-pool.ts
334
- import { exec } from "child_process";
335
347
  import path2 from "path";
336
- import { promisify } from "util";
337
348
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
338
349
  import { z as z3 } from "zod";
339
350
 
@@ -377,9 +388,25 @@ async function withFileLock(path7, fn, options) {
377
388
  }
378
389
  }
379
390
 
380
- // src/lib/firecracker/netns-pool.ts
391
+ // src/lib/utils/exec.ts
392
+ import { exec } from "child_process";
393
+ import { promisify } from "util";
381
394
  var execAsync = promisify(exec);
382
- var logger = createLogger("NetnsPool");
395
+ async function execCommand(cmd, sudo = true) {
396
+ const fullCmd = sudo ? `sudo ${cmd}` : cmd;
397
+ try {
398
+ const { stdout } = await execAsync(fullCmd);
399
+ return stdout.trim();
400
+ } catch (error) {
401
+ const execError = error;
402
+ throw new Error(
403
+ `Command failed: ${fullCmd}
404
+ ${execError.stderr || execError.message}`
405
+ );
406
+ }
407
+ }
408
+
409
+ // src/lib/firecracker/netns.ts
383
410
  var SNAPSHOT_NETWORK = {
384
411
  /** TAP device name inside namespace (must match Firecracker config) */
385
412
  tapName: "vm0-tap",
@@ -394,14 +421,28 @@ var SNAPSHOT_NETWORK = {
394
421
  /** CIDR prefix length (for ip commands) */
395
422
  prefixLen: 29
396
423
  };
397
- var VETH_NS = "veth0";
398
- var NS_PREFIX = "vm0-ns-";
399
- var VETH_PREFIX = "vm0-ve-";
400
- var VETH_IP_PREFIX = "10.200";
401
424
  function generateSnapshotNetworkBootArgs() {
402
425
  const { guestIp, gatewayIp, netmask } = SNAPSHOT_NETWORK;
403
426
  return `ip=${guestIp}::${gatewayIp}:${netmask}:vm0-guest:eth0:off`;
404
427
  }
428
+ async function createNetnsWithTap(nsName, tap) {
429
+ await execCommand(`ip netns add ${nsName}`);
430
+ await execCommand(
431
+ `ip netns exec ${nsName} ip tuntap add ${tap.tapName} mode tap`
432
+ );
433
+ await execCommand(
434
+ `ip netns exec ${nsName} ip addr add ${tap.gatewayIpWithPrefix} dev ${tap.tapName}`
435
+ );
436
+ await execCommand(`ip netns exec ${nsName} ip link set ${tap.tapName} up`);
437
+ await execCommand(`ip netns exec ${nsName} ip link set lo up`);
438
+ }
439
+
440
+ // src/lib/firecracker/netns-pool.ts
441
+ var logger = createLogger("NetnsPool");
442
+ var VETH_NS = "veth0";
443
+ var NS_PREFIX = "vm0-ns-";
444
+ var VETH_PREFIX = "vm0-ve-";
445
+ var VETH_IP_PREFIX = "10.200";
405
446
  var MAX_RUNNERS = 64;
406
447
  var MAX_NAMESPACES_PER_RUNNER = 256;
407
448
  var NamespaceEntrySchema = z3.object({
@@ -459,19 +500,6 @@ var RegistryFile = class {
459
500
  });
460
501
  }
461
502
  };
462
- async function execCommand(cmd, sudo = true) {
463
- const fullCmd = sudo ? `sudo ${cmd}` : cmd;
464
- try {
465
- const { stdout } = await execAsync(fullCmd);
466
- return stdout.trim();
467
- } catch (error) {
468
- const execError = error;
469
- throw new Error(
470
- `Command failed: ${fullCmd}
471
- ${execError.stderr || execError.message}`
472
- );
473
- }
474
- }
475
503
  async function getDefaultInterface() {
476
504
  const result = await execCommand("ip route get 8.8.8.8", false);
477
505
  const match = result.match(/dev\s+(\S+)/);
@@ -694,16 +722,10 @@ var NetnsPool = class _NetnsPool {
694
722
  });
695
723
  logger.log(`Creating namespace ${name}...`);
696
724
  try {
697
- await execCommand(`ip netns add ${name}`);
698
- await execCommand(
699
- `ip netns exec ${name} ip tuntap add ${SNAPSHOT_NETWORK.tapName} mode tap`
700
- );
701
- await execCommand(
702
- `ip netns exec ${name} ip addr add ${SNAPSHOT_NETWORK.gatewayIp}/${SNAPSHOT_NETWORK.prefixLen} dev ${SNAPSHOT_NETWORK.tapName}`
703
- );
704
- await execCommand(
705
- `ip netns exec ${name} ip link set ${SNAPSHOT_NETWORK.tapName} up`
706
- );
725
+ await createNetnsWithTap(name, {
726
+ tapName: SNAPSHOT_NETWORK.tapName,
727
+ gatewayIpWithPrefix: `${SNAPSHOT_NETWORK.gatewayIp}/${SNAPSHOT_NETWORK.prefixLen}`
728
+ });
707
729
  await execCommand(
708
730
  `ip link add ${vethHost} type veth peer name ${VETH_NS} netns ${name}`
709
731
  );
@@ -711,7 +733,6 @@ var NetnsPool = class _NetnsPool {
711
733
  `ip netns exec ${name} ip addr add ${vethNsIp}/30 dev ${VETH_NS}`
712
734
  );
713
735
  await execCommand(`ip netns exec ${name} ip link set ${VETH_NS} up`);
714
- await execCommand(`ip netns exec ${name} ip link set lo up`);
715
736
  await execCommand(`ip addr add ${vethHostIp}/30 dev ${vethHost}`);
716
737
  await execCommand(`ip link set ${vethHost} up`);
717
738
  await execCommand(
@@ -1068,6 +1089,36 @@ var FirecrackerClient = class {
1068
1089
  constructor(socketPath) {
1069
1090
  this.socketPath = socketPath;
1070
1091
  }
1092
+ /**
1093
+ * Configure machine settings (vCPUs, memory)
1094
+ */
1095
+ async configureMachine(config) {
1096
+ await this.put("/machine-config", config);
1097
+ }
1098
+ /**
1099
+ * Configure boot source (kernel, boot args)
1100
+ */
1101
+ async configureBootSource(config) {
1102
+ await this.put("/boot-source", config);
1103
+ }
1104
+ /**
1105
+ * Configure network interface
1106
+ */
1107
+ async configureNetworkInterface(config) {
1108
+ await this.put(`/network-interfaces/${config.iface_id}`, config);
1109
+ }
1110
+ /**
1111
+ * Configure vsock device
1112
+ */
1113
+ async configureVsock(config) {
1114
+ await this.put("/vsock", config);
1115
+ }
1116
+ /**
1117
+ * Start the VM instance
1118
+ */
1119
+ async startInstance() {
1120
+ await this.put("/actions", { action_type: "InstanceStart" });
1121
+ }
1071
1122
  /**
1072
1123
  * Pause the VM
1073
1124
  *
@@ -1164,17 +1215,27 @@ var FirecrackerClient = class {
1164
1215
  */
1165
1216
  request(method, path7, body, timeoutMs = 3e4) {
1166
1217
  return new Promise((resolve, reject) => {
1218
+ const bodyStr = body !== void 0 ? JSON.stringify(body) : void 0;
1219
+ const headers = {
1220
+ Accept: "application/json",
1221
+ // Disable keep-alive to prevent pipelining issues
1222
+ Connection: "close"
1223
+ };
1224
+ if (bodyStr !== void 0) {
1225
+ headers["Content-Type"] = "application/json";
1226
+ headers["Content-Length"] = Buffer.byteLength(bodyStr);
1227
+ }
1167
1228
  const options = {
1168
1229
  socketPath: this.socketPath,
1169
- path: `http://localhost${path7}`,
1230
+ path: path7,
1170
1231
  method,
1171
- headers: {
1172
- "Content-Type": "application/json",
1173
- Accept: "application/json"
1174
- },
1175
- timeout: timeoutMs
1232
+ headers,
1233
+ timeout: timeoutMs,
1234
+ // Disable agent to ensure fresh connection for each request
1235
+ // Firecracker's single-threaded API can have issues with pipelined requests
1236
+ agent: false
1176
1237
  };
1177
- logger3.log(`${method} ${path7}${body ? " " + JSON.stringify(body) : ""}`);
1238
+ logger3.log(`${method} ${path7}${bodyStr ? " " + bodyStr : ""}`);
1178
1239
  const req = http.request(options, (res) => {
1179
1240
  let data = "";
1180
1241
  res.on("data", (chunk) => {
@@ -1204,8 +1265,8 @@ var FirecrackerClient = class {
1204
1265
  req.on("error", (err) => {
1205
1266
  reject(err);
1206
1267
  });
1207
- if (body) {
1208
- req.write(JSON.stringify(body));
1268
+ if (bodyStr !== void 0) {
1269
+ req.write(bodyStr);
1209
1270
  }
1210
1271
  req.end();
1211
1272
  });
@@ -1218,6 +1279,58 @@ var FirecrackerClient = class {
1218
1279
  }
1219
1280
  };
1220
1281
 
1282
+ // src/lib/firecracker/config.ts
1283
+ function buildBootArgs() {
1284
+ const networkBootArgs = generateSnapshotNetworkBootArgs();
1285
+ return `console=ttyS0 reboot=k panic=1 pci=off nomodules random.trust_cpu=on quiet loglevel=0 nokaslr audit=0 numa=off mitigations=off noresume init=/sbin/vm-init ${networkBootArgs}`;
1286
+ }
1287
+ function buildFirecrackerConfig(params) {
1288
+ const bootArgs = buildBootArgs();
1289
+ return {
1290
+ "boot-source": {
1291
+ kernel_image_path: params.kernelPath,
1292
+ boot_args: bootArgs
1293
+ },
1294
+ drives: [
1295
+ // Base drive (squashfs, read-only, shared across VMs)
1296
+ // Mounted as /dev/vda inside the VM
1297
+ {
1298
+ drive_id: "rootfs",
1299
+ path_on_host: params.rootfsPath,
1300
+ is_root_device: true,
1301
+ is_read_only: true
1302
+ },
1303
+ // Overlay drive (ext4, read-write, per-VM)
1304
+ // Mounted as /dev/vdb inside the VM
1305
+ // The vm-init script combines these using overlayfs
1306
+ {
1307
+ drive_id: "overlay",
1308
+ path_on_host: params.overlayPath,
1309
+ is_root_device: false,
1310
+ is_read_only: false
1311
+ }
1312
+ ],
1313
+ "machine-config": {
1314
+ vcpu_count: params.vcpus,
1315
+ mem_size_mib: params.memoryMb
1316
+ },
1317
+ "network-interfaces": [
1318
+ {
1319
+ // Network interface uses fixed config from SNAPSHOT_NETWORK
1320
+ // TAP device is inside the namespace, created by netns-pool
1321
+ iface_id: "eth0",
1322
+ guest_mac: SNAPSHOT_NETWORK.guestMac,
1323
+ host_dev_name: SNAPSHOT_NETWORK.tapName
1324
+ }
1325
+ ],
1326
+ // Guest CID 3 is the standard guest identifier (CID 0=hypervisor, 1=local, 2=host)
1327
+ vsock: {
1328
+ guest_cid: 3,
1329
+ uds_path: params.vsockPath
1330
+ }
1331
+ };
1332
+ }
1333
+
1221
1334
  // src/lib/firecracker/vm.ts
1222
1335
  var logger4 = createLogger("VM");
1223
1336
  var FirecrackerVM = class {
@@ -1282,7 +1395,6 @@ var FirecrackerVM = class {
1282
1395
  throw new Error(`Cannot start VM in state: ${this.state}`);
1283
1396
  }
1284
1397
  try {
1285
- fs4.mkdirSync(this.workDir, { recursive: true });
1286
1398
  logger4.log(`[VM ${this.config.vmId}] Acquiring resources...`);
1287
1399
  const results = await Promise.allSettled([
1288
1400
  acquireOverlay(),
@@ -1458,74 +1570,23 @@ var FirecrackerVM = class {
1458
1570
  }
1459
1571
  /**
1460
1572
  * Build Firecracker configuration object
1461
- *
1462
- * Creates the JSON configuration for Firecracker's --config-file option.
1463
- * Boot args:
1464
- * - console=ttyS0: serial console output
1465
- * - reboot=k: use keyboard controller for reboot
1466
- * - panic=1: reboot after 1 second on kernel panic
1467
- * - pci=off: disable PCI bus (not needed in microVM)
1468
- * - nomodules: skip module loading (not needed in microVM)
1469
- * - random.trust_cpu=on: trust CPU RNG, skip entropy wait
1470
- * - quiet loglevel=0: minimize kernel log output
1471
- * - nokaslr: disable kernel address space randomization
1472
- * - audit=0: disable kernel auditing
1473
- * - numa=off: disable NUMA (single node)
1474
- * - mitigations=off: disable CPU vulnerability mitigations
1475
- * - noresume: skip hibernation resume check
1476
- * - init=/sbin/vm-init: use vm-init (Rust binary) for filesystem setup and vsock-agent
1477
- * - ip=...: network configuration (fixed IPs from SNAPSHOT_NETWORK)
1478
1573
  */
1479
1574
  buildConfig() {
1480
1575
  if (!this.netns || !this.vmOverlayPath) {
1481
1576
  throw new Error("VM not properly initialized");
1482
1577
  }
1483
- const networkBootArgs = generateSnapshotNetworkBootArgs();
1484
- const bootArgs = `console=ttyS0 reboot=k panic=1 pci=off nomodules random.trust_cpu=on quiet loglevel=0 nokaslr audit=0 numa=off mitigations=off noresume init=/sbin/vm-init ${networkBootArgs}`;
1485
- logger4.log(`[VM ${this.config.vmId}] Boot args: ${bootArgs}`);
1486
- return {
1487
- "boot-source": {
1488
- kernel_image_path: this.config.kernelPath,
1489
- boot_args: bootArgs
1490
- },
1491
- drives: [
1492
- // Base drive (squashfs, read-only, shared across VMs)
1493
- // Mounted as /dev/vda inside the VM
1494
- {
1495
- drive_id: "rootfs",
1496
- path_on_host: this.config.rootfsPath,
1497
- is_root_device: true,
1498
- is_read_only: true
1499
- },
1500
- // Overlay drive (ext4, read-write, per-VM)
1501
- // Mounted as /dev/vdb inside the VM
1502
- // The vm-init script combines these using overlayfs
1503
- {
1504
- drive_id: "overlay",
1505
- path_on_host: this.vmOverlayPath,
1506
- is_root_device: false,
1507
- is_read_only: false
1508
- }
1509
- ],
1510
- "machine-config": {
1511
- vcpu_count: this.config.vcpus,
1512
- mem_size_mib: this.config.memoryMb
1513
- },
1514
- "network-interfaces": [
1515
- {
1516
- // Network interface uses fixed config from SNAPSHOT_NETWORK
1517
- // TAP device is inside the namespace, created by netns-pool
1518
- iface_id: "eth0",
1519
- guest_mac: SNAPSHOT_NETWORK.guestMac,
1520
- host_dev_name: SNAPSHOT_NETWORK.tapName
1521
- }
1522
- ],
1523
- // Guest CID 3 is the standard guest identifier (CID 0=hypervisor, 1=local, 2=host)
1524
- vsock: {
1525
- guest_cid: 3,
1526
- uds_path: this.vsockPath
1527
- }
1528
- };
1578
+ const config = buildFirecrackerConfig({
1579
+ kernelPath: this.config.kernelPath,
1580
+ rootfsPath: this.config.rootfsPath,
1581
+ overlayPath: this.vmOverlayPath,
1582
+ vsockPath: this.vsockPath,
1583
+ vcpus: this.config.vcpus,
1584
+ memoryMb: this.config.memoryMb
1585
+ });
1586
+ logger4.log(
1587
+ `[VM ${this.config.vmId}] Boot args: ${config["boot-source"].boot_args}`
1588
+ );
1589
+ return config;
1529
1590
  }
1530
1591
  /**
1531
1592
  * Stop the VM
@@ -2224,6 +2285,20 @@ var VsockClient = class {
2224
2285
  }
2225
2286
  this.cachedExits.clear();
2226
2287
  }
2288
+ /**
2289
+ * Send raw bytes directly to the socket (for testing only)
2290
+ *
2291
+ * This allows tests to send malformed messages to verify the agent's
2292
+ * protocol error handling (e.g., oversized messages).
2293
+ *
2294
+ * @internal This method is only for testing purposes
2295
+ */
2296
+ sendRawForTesting(data) {
2297
+ if (!this.connected || !this.socket) {
2298
+ throw new Error("Not connected - call waitForGuestConnection() first");
2299
+ }
2300
+ this.socket.write(data);
2301
+ }
2227
2302
  };
2228
2303
 
2229
2304
  // ../../packages/core/src/contracts/base.ts
@@ -7644,57 +7719,159 @@ var credentialsByNameContract = c10.router({
7644
7719
  }
7645
7720
  });
7646
7721
 
7647
- // ../../packages/core/src/contracts/model-providers.ts
7722
+ // ../../packages/core/src/contracts/secrets.ts
7648
7723
  import { z as z18 } from "zod";
7649
7724
  var c11 = initContract();
7650
- var modelProviderTypeSchema = z18.enum([
7725
+ var secretNameSchema = z18.string().min(1, "Secret name is required").max(255, "Secret name must be at most 255 characters").regex(
7726
+ /^[A-Z][A-Z0-9_]*$/,
7727
+ "Secret name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_API_KEY)"
7728
+ );
7729
+ var secretTypeSchema = z18.enum(["user", "model-provider"]);
7730
+ var secretResponseSchema = z18.object({
7731
+ id: z18.string().uuid(),
7732
+ name: z18.string(),
7733
+ description: z18.string().nullable(),
7734
+ type: secretTypeSchema,
7735
+ createdAt: z18.string(),
7736
+ updatedAt: z18.string()
7737
+ });
7738
+ var secretListResponseSchema = z18.object({
7739
+ secrets: z18.array(secretResponseSchema)
7740
+ });
7741
+ var setSecretRequestSchema = z18.object({
7742
+ name: secretNameSchema,
7743
+ value: z18.string().min(1, "Secret value is required"),
7744
+ description: z18.string().max(1e3).optional()
7745
+ });
7746
+ var secretsMainContract = c11.router({
7747
+ /**
7748
+ * GET /api/secrets
7749
+ * List all secrets for the current user's scope (metadata only)
7750
+ */
7751
+ list: {
7752
+ method: "GET",
7753
+ path: "/api/secrets",
7754
+ headers: authHeadersSchema,
7755
+ responses: {
7756
+ 200: secretListResponseSchema,
7757
+ 401: apiErrorSchema,
7758
+ 500: apiErrorSchema
7759
+ },
7760
+ summary: "List all secrets (metadata only)"
7761
+ },
7762
+ /**
7763
+ * PUT /api/secrets
7764
+ * Create or update a secret
7765
+ */
7766
+ set: {
7767
+ method: "PUT",
7768
+ path: "/api/secrets",
7769
+ headers: authHeadersSchema,
7770
+ body: setSecretRequestSchema,
7771
+ responses: {
7772
+ 200: secretResponseSchema,
7773
+ 201: secretResponseSchema,
7774
+ 400: apiErrorSchema,
7775
+ 401: apiErrorSchema,
7776
+ 500: apiErrorSchema
7777
+ },
7778
+ summary: "Create or update a secret"
7779
+ }
7780
+ });
7781
+ var secretsByNameContract = c11.router({
7782
+ /**
7783
+ * GET /api/secrets/:name
7784
+ * Get a secret by name (metadata only)
7785
+ */
7786
+ get: {
7787
+ method: "GET",
7788
+ path: "/api/secrets/:name",
7789
+ headers: authHeadersSchema,
7790
+ pathParams: z18.object({
7791
+ name: secretNameSchema
7792
+ }),
7793
+ responses: {
7794
+ 200: secretResponseSchema,
7795
+ 401: apiErrorSchema,
7796
+ 404: apiErrorSchema,
7797
+ 500: apiErrorSchema
7798
+ },
7799
+ summary: "Get secret metadata by name"
7800
+ },
7801
+ /**
7802
+ * DELETE /api/secrets/:name
7803
+ * Delete a secret by name
7804
+ */
7805
+ delete: {
7806
+ method: "DELETE",
7807
+ path: "/api/secrets/:name",
7808
+ headers: authHeadersSchema,
7809
+ pathParams: z18.object({
7810
+ name: secretNameSchema
7811
+ }),
7812
+ responses: {
7813
+ 204: c11.noBody(),
7814
+ 401: apiErrorSchema,
7815
+ 404: apiErrorSchema,
7816
+ 500: apiErrorSchema
7817
+ },
7818
+ summary: "Delete a secret"
7819
+ }
7820
+ });
7821
+
7822
+ // ../../packages/core/src/contracts/model-providers.ts
7823
+ import { z as z19 } from "zod";
7824
+ var c12 = initContract();
7825
+ var modelProviderTypeSchema = z19.enum([
7651
7826
  "claude-code-oauth-token",
7652
7827
  "anthropic-api-key",
7653
7828
  "openrouter-api-key",
7654
7829
  "moonshot-api-key",
7655
7830
  "minimax-api-key",
7831
+ "deepseek-api-key",
7832
+ "zai-api-key",
7656
7833
  "aws-bedrock"
7657
7834
  ]);
7658
- var modelProviderFrameworkSchema = z18.enum(["claude-code", "codex"]);
7659
- var modelProviderResponseSchema = z18.object({
7660
- id: z18.string().uuid(),
7835
+ var modelProviderFrameworkSchema = z19.enum(["claude-code", "codex"]);
7836
+ var modelProviderResponseSchema = z19.object({
7837
+ id: z19.string().uuid(),
7661
7838
  type: modelProviderTypeSchema,
7662
7839
  framework: modelProviderFrameworkSchema,
7663
- credentialName: z18.string().nullable(),
7840
+ credentialName: z19.string().nullable(),
7664
7841
  // Legacy single-credential (deprecated for multi-auth)
7665
- authMethod: z18.string().nullable(),
7842
+ authMethod: z19.string().nullable(),
7666
7843
  // For multi-auth providers
7667
- credentialNames: z18.array(z18.string()).nullable(),
7844
+ credentialNames: z19.array(z19.string()).nullable(),
7668
7845
  // For multi-auth providers
7669
- isDefault: z18.boolean(),
7670
- selectedModel: z18.string().nullable(),
7671
- createdAt: z18.string(),
7672
- updatedAt: z18.string()
7846
+ isDefault: z19.boolean(),
7847
+ selectedModel: z19.string().nullable(),
7848
+ createdAt: z19.string(),
7849
+ updatedAt: z19.string()
7673
7850
  });
7674
- var modelProviderListResponseSchema = z18.object({
7675
- modelProviders: z18.array(modelProviderResponseSchema)
7851
+ var modelProviderListResponseSchema = z19.object({
7852
+ modelProviders: z19.array(modelProviderResponseSchema)
7676
7853
  });
7677
- var upsertModelProviderRequestSchema = z18.object({
7854
+ var upsertModelProviderRequestSchema = z19.object({
7678
7855
  type: modelProviderTypeSchema,
7679
- credential: z18.string().min(1).optional(),
7856
+ credential: z19.string().min(1).optional(),
7680
7857
  // Legacy single credential
7681
- authMethod: z18.string().optional(),
7858
+ authMethod: z19.string().optional(),
7682
7859
  // For multi-auth providers
7683
- credentials: z18.record(z18.string(), z18.string()).optional(),
7860
+ credentials: z19.record(z19.string(), z19.string()).optional(),
7684
7861
  // For multi-auth providers
7685
- convert: z18.boolean().optional(),
7686
- selectedModel: z18.string().optional()
7862
+ convert: z19.boolean().optional(),
7863
+ selectedModel: z19.string().optional()
7687
7864
  });
7688
- var upsertModelProviderResponseSchema = z18.object({
7865
+ var upsertModelProviderResponseSchema = z19.object({
7689
7866
  provider: modelProviderResponseSchema,
7690
- created: z18.boolean()
7867
+ created: z19.boolean()
7691
7868
  });
7692
- var checkCredentialResponseSchema = z18.object({
7693
- exists: z18.boolean(),
7694
- credentialName: z18.string(),
7695
- currentType: z18.enum(["user", "model-provider"]).optional()
7869
+ var checkCredentialResponseSchema = z19.object({
7870
+ exists: z19.boolean(),
7871
+ credentialName: z19.string(),
7872
+ currentType: z19.enum(["user", "model-provider"]).optional()
7696
7873
  });
7697
- var modelProvidersMainContract = c11.router({
7874
+ var modelProvidersMainContract = c12.router({
7698
7875
  list: {
7699
7876
  method: "GET",
7700
7877
  path: "/api/model-providers",
@@ -7722,12 +7899,12 @@ var modelProvidersMainContract = c11.router({
7722
7899
  summary: "Create or update a model provider"
7723
7900
  }
7724
7901
  });
7725
- var modelProvidersCheckContract = c11.router({
7902
+ var modelProvidersCheckContract = c12.router({
7726
7903
  check: {
7727
7904
  method: "GET",
7728
7905
  path: "/api/model-providers/check/:type",
7729
7906
  headers: authHeadersSchema,
7730
- pathParams: z18.object({
7907
+ pathParams: z19.object({
7731
7908
  type: modelProviderTypeSchema
7732
7909
  }),
7733
7910
  responses: {
@@ -7738,16 +7915,16 @@ var modelProvidersCheckContract = c11.router({
7738
7915
  summary: "Check if credential exists for a model provider type"
7739
7916
  }
7740
7917
  });
7741
- var modelProvidersByTypeContract = c11.router({
7918
+ var modelProvidersByTypeContract = c12.router({
7742
7919
  delete: {
7743
7920
  method: "DELETE",
7744
7921
  path: "/api/model-providers/:type",
7745
7922
  headers: authHeadersSchema,
7746
- pathParams: z18.object({
7923
+ pathParams: z19.object({
7747
7924
  type: modelProviderTypeSchema
7748
7925
  }),
7749
7926
  responses: {
7750
- 204: c11.noBody(),
7927
+ 204: c12.noBody(),
7751
7928
  401: apiErrorSchema,
7752
7929
  404: apiErrorSchema,
7753
7930
  500: apiErrorSchema
@@ -7755,15 +7932,15 @@ var modelProvidersByTypeContract = c11.router({
7755
7932
  summary: "Delete a model provider"
7756
7933
  }
7757
7934
  });
7758
- var modelProvidersConvertContract = c11.router({
7935
+ var modelProvidersConvertContract = c12.router({
7759
7936
  convert: {
7760
7937
  method: "POST",
7761
7938
  path: "/api/model-providers/:type/convert",
7762
7939
  headers: authHeadersSchema,
7763
- pathParams: z18.object({
7940
+ pathParams: z19.object({
7764
7941
  type: modelProviderTypeSchema
7765
7942
  }),
7766
- body: z18.undefined(),
7943
+ body: z19.undefined(),
7767
7944
  responses: {
7768
7945
  200: modelProviderResponseSchema,
7769
7946
  400: apiErrorSchema,
@@ -7774,15 +7951,15 @@ var modelProvidersConvertContract = c11.router({
7774
7951
  summary: "Convert existing user credential to model provider"
7775
7952
  }
7776
7953
  });
7777
- var modelProvidersSetDefaultContract = c11.router({
7954
+ var modelProvidersSetDefaultContract = c12.router({
7778
7955
  setDefault: {
7779
7956
  method: "POST",
7780
7957
  path: "/api/model-providers/:type/set-default",
7781
7958
  headers: authHeadersSchema,
7782
- pathParams: z18.object({
7959
+ pathParams: z19.object({
7783
7960
  type: modelProviderTypeSchema
7784
7961
  }),
7785
- body: z18.undefined(),
7962
+ body: z19.undefined(),
7786
7963
  responses: {
7787
7964
  200: modelProviderResponseSchema,
7788
7965
  401: apiErrorSchema,
@@ -7792,15 +7969,15 @@ var modelProvidersSetDefaultContract = c11.router({
7792
7969
  summary: "Set a model provider as default for its framework"
7793
7970
  }
7794
7971
  });
7795
- var updateModelRequestSchema = z18.object({
7796
- selectedModel: z18.string().optional()
7972
+ var updateModelRequestSchema = z19.object({
7973
+ selectedModel: z19.string().optional()
7797
7974
  });
7798
- var modelProvidersUpdateModelContract = c11.router({
7975
+ var modelProvidersUpdateModelContract = c12.router({
7799
7976
  updateModel: {
7800
7977
  method: "PATCH",
7801
7978
  path: "/api/model-providers/:type/model",
7802
7979
  headers: authHeadersSchema,
7803
- pathParams: z18.object({
7980
+ pathParams: z19.object({
7804
7981
  type: modelProviderTypeSchema
7805
7982
  }),
7806
7983
  body: updateModelRequestSchema,
@@ -7815,42 +7992,42 @@ var modelProvidersUpdateModelContract = c11.router({
7815
7992
  });
7816
7993
 
7817
7994
  // ../../packages/core/src/contracts/sessions.ts
7818
- import { z as z19 } from "zod";
7819
- var c12 = initContract();
7820
- var sessionResponseSchema = z19.object({
7821
- id: z19.string(),
7822
- agentComposeId: z19.string(),
7823
- agentComposeVersionId: z19.string().nullable(),
7824
- conversationId: z19.string().nullable(),
7825
- artifactName: z19.string().nullable(),
7826
- vars: z19.record(z19.string(), z19.string()).nullable(),
7827
- secretNames: z19.array(z19.string()).nullable(),
7828
- volumeVersions: z19.record(z19.string(), z19.string()).nullable(),
7829
- createdAt: z19.string(),
7830
- updatedAt: z19.string()
7995
+ import { z as z20 } from "zod";
7996
+ var c13 = initContract();
7997
+ var sessionResponseSchema = z20.object({
7998
+ id: z20.string(),
7999
+ agentComposeId: z20.string(),
8000
+ agentComposeVersionId: z20.string().nullable(),
8001
+ conversationId: z20.string().nullable(),
8002
+ artifactName: z20.string().nullable(),
8003
+ vars: z20.record(z20.string(), z20.string()).nullable(),
8004
+ secretNames: z20.array(z20.string()).nullable(),
8005
+ volumeVersions: z20.record(z20.string(), z20.string()).nullable(),
8006
+ createdAt: z20.string(),
8007
+ updatedAt: z20.string()
7831
8008
  });
7832
- var agentComposeSnapshotSchema = z19.object({
7833
- agentComposeVersionId: z19.string(),
7834
- vars: z19.record(z19.string(), z19.string()).optional(),
7835
- secretNames: z19.array(z19.string()).optional()
8009
+ var agentComposeSnapshotSchema = z20.object({
8010
+ agentComposeVersionId: z20.string(),
8011
+ vars: z20.record(z20.string(), z20.string()).optional(),
8012
+ secretNames: z20.array(z20.string()).optional()
7836
8013
  });
7837
- var artifactSnapshotSchema2 = z19.object({
7838
- artifactName: z19.string(),
7839
- artifactVersion: z19.string()
8014
+ var artifactSnapshotSchema2 = z20.object({
8015
+ artifactName: z20.string(),
8016
+ artifactVersion: z20.string()
7840
8017
  });
7841
- var volumeVersionsSnapshotSchema2 = z19.object({
7842
- versions: z19.record(z19.string(), z19.string())
8018
+ var volumeVersionsSnapshotSchema2 = z20.object({
8019
+ versions: z20.record(z20.string(), z20.string())
7843
8020
  });
7844
- var checkpointResponseSchema = z19.object({
7845
- id: z19.string(),
7846
- runId: z19.string(),
7847
- conversationId: z19.string(),
8021
+ var checkpointResponseSchema = z20.object({
8022
+ id: z20.string(),
8023
+ runId: z20.string(),
8024
+ conversationId: z20.string(),
7848
8025
  agentComposeSnapshot: agentComposeSnapshotSchema,
7849
8026
  artifactSnapshot: artifactSnapshotSchema2.nullable(),
7850
8027
  volumeVersionsSnapshot: volumeVersionsSnapshotSchema2.nullable(),
7851
- createdAt: z19.string()
8028
+ createdAt: z20.string()
7852
8029
  });
7853
- var sessionsByIdContract = c12.router({
8030
+ var sessionsByIdContract = c13.router({
7854
8031
  /**
7855
8032
  * GET /api/agent/sessions/:id
7856
8033
  * Get session by ID
@@ -7859,8 +8036,8 @@ var sessionsByIdContract = c12.router({
7859
8036
  method: "GET",
7860
8037
  path: "/api/agent/sessions/:id",
7861
8038
  headers: authHeadersSchema,
7862
- pathParams: z19.object({
7863
- id: z19.string().min(1, "Session ID is required")
8039
+ pathParams: z20.object({
8040
+ id: z20.string().min(1, "Session ID is required")
7864
8041
  }),
7865
8042
  responses: {
7866
8043
  200: sessionResponseSchema,
@@ -7871,7 +8048,7 @@ var sessionsByIdContract = c12.router({
7871
8048
  summary: "Get session by ID"
7872
8049
  }
7873
8050
  });
7874
- var checkpointsByIdContract = c12.router({
8051
+ var checkpointsByIdContract = c13.router({
7875
8052
  /**
7876
8053
  * GET /api/agent/checkpoints/:id
7877
8054
  * Get checkpoint by ID
@@ -7880,8 +8057,8 @@ var checkpointsByIdContract = c12.router({
7880
8057
  method: "GET",
7881
8058
  path: "/api/agent/checkpoints/:id",
7882
8059
  headers: authHeadersSchema,
7883
- pathParams: z19.object({
7884
- id: z19.string().min(1, "Checkpoint ID is required")
8060
+ pathParams: z20.object({
8061
+ id: z20.string().min(1, "Checkpoint ID is required")
7885
8062
  }),
7886
8063
  responses: {
7887
8064
  200: checkpointResponseSchema,
@@ -7894,93 +8071,93 @@ var checkpointsByIdContract = c12.router({
7894
8071
  });
7895
8072
 
7896
8073
  // ../../packages/core/src/contracts/schedules.ts
7897
- import { z as z20 } from "zod";
7898
- var c13 = initContract();
7899
- var scheduleTriggerSchema = z20.object({
7900
- cron: z20.string().optional(),
7901
- at: z20.string().optional(),
7902
- timezone: z20.string().default("UTC")
8074
+ import { z as z21 } from "zod";
8075
+ var c14 = initContract();
8076
+ var scheduleTriggerSchema = z21.object({
8077
+ cron: z21.string().optional(),
8078
+ at: z21.string().optional(),
8079
+ timezone: z21.string().default("UTC")
7903
8080
  }).refine((data) => data.cron && !data.at || !data.cron && data.at, {
7904
8081
  message: "Exactly one of 'cron' or 'at' must be specified"
7905
8082
  });
7906
- var scheduleRunConfigSchema = z20.object({
7907
- agent: z20.string().min(1, "Agent reference required"),
7908
- prompt: z20.string().min(1, "Prompt required"),
7909
- vars: z20.record(z20.string(), z20.string()).optional(),
7910
- secrets: z20.record(z20.string(), z20.string()).optional(),
7911
- artifactName: z20.string().optional(),
7912
- artifactVersion: z20.string().optional(),
7913
- volumeVersions: z20.record(z20.string(), z20.string()).optional()
8083
+ var scheduleRunConfigSchema = z21.object({
8084
+ agent: z21.string().min(1, "Agent reference required"),
8085
+ prompt: z21.string().min(1, "Prompt required"),
8086
+ vars: z21.record(z21.string(), z21.string()).optional(),
8087
+ secrets: z21.record(z21.string(), z21.string()).optional(),
8088
+ artifactName: z21.string().optional(),
8089
+ artifactVersion: z21.string().optional(),
8090
+ volumeVersions: z21.record(z21.string(), z21.string()).optional()
7914
8091
  });
7915
- var scheduleDefinitionSchema = z20.object({
8092
+ var scheduleDefinitionSchema = z21.object({
7916
8093
  on: scheduleTriggerSchema,
7917
8094
  run: scheduleRunConfigSchema
7918
8095
  });
7919
- var scheduleYamlSchema = z20.object({
7920
- version: z20.literal("1.0"),
7921
- schedules: z20.record(z20.string(), scheduleDefinitionSchema)
7922
- });
7923
- var deployScheduleRequestSchema = z20.object({
7924
- name: z20.string().min(1).max(64, "Schedule name max 64 chars"),
7925
- cronExpression: z20.string().optional(),
7926
- atTime: z20.string().optional(),
7927
- timezone: z20.string().default("UTC"),
7928
- prompt: z20.string().min(1, "Prompt required"),
7929
- vars: z20.record(z20.string(), z20.string()).optional(),
7930
- secrets: z20.record(z20.string(), z20.string()).optional(),
7931
- artifactName: z20.string().optional(),
7932
- artifactVersion: z20.string().optional(),
7933
- volumeVersions: z20.record(z20.string(), z20.string()).optional(),
8096
+ var scheduleYamlSchema = z21.object({
8097
+ version: z21.literal("1.0"),
8098
+ schedules: z21.record(z21.string(), scheduleDefinitionSchema)
8099
+ });
8100
+ var deployScheduleRequestSchema = z21.object({
8101
+ name: z21.string().min(1).max(64, "Schedule name max 64 chars"),
8102
+ cronExpression: z21.string().optional(),
8103
+ atTime: z21.string().optional(),
8104
+ timezone: z21.string().default("UTC"),
8105
+ prompt: z21.string().min(1, "Prompt required"),
8106
+ vars: z21.record(z21.string(), z21.string()).optional(),
8107
+ secrets: z21.record(z21.string(), z21.string()).optional(),
8108
+ artifactName: z21.string().optional(),
8109
+ artifactVersion: z21.string().optional(),
8110
+ volumeVersions: z21.record(z21.string(), z21.string()).optional(),
7934
8111
  // Resolved agent compose ID (CLI resolves scope/name:version → composeId)
7935
- composeId: z20.string().uuid("Invalid compose ID")
8112
+ composeId: z21.string().uuid("Invalid compose ID")
7936
8113
  }).refine(
7937
8114
  (data) => data.cronExpression && !data.atTime || !data.cronExpression && data.atTime,
7938
8115
  {
7939
8116
  message: "Exactly one of 'cronExpression' or 'atTime' must be specified"
7940
8117
  }
7941
8118
  );
7942
- var scheduleResponseSchema = z20.object({
7943
- id: z20.string().uuid(),
7944
- composeId: z20.string().uuid(),
7945
- composeName: z20.string(),
7946
- scopeSlug: z20.string(),
7947
- name: z20.string(),
7948
- cronExpression: z20.string().nullable(),
7949
- atTime: z20.string().nullable(),
7950
- timezone: z20.string(),
7951
- prompt: z20.string(),
7952
- vars: z20.record(z20.string(), z20.string()).nullable(),
8119
+ var scheduleResponseSchema = z21.object({
8120
+ id: z21.string().uuid(),
8121
+ composeId: z21.string().uuid(),
8122
+ composeName: z21.string(),
8123
+ scopeSlug: z21.string(),
8124
+ name: z21.string(),
8125
+ cronExpression: z21.string().nullable(),
8126
+ atTime: z21.string().nullable(),
8127
+ timezone: z21.string(),
8128
+ prompt: z21.string(),
8129
+ vars: z21.record(z21.string(), z21.string()).nullable(),
7953
8130
  // Secret names only (values are never returned)
7954
- secretNames: z20.array(z20.string()).nullable(),
7955
- artifactName: z20.string().nullable(),
7956
- artifactVersion: z20.string().nullable(),
7957
- volumeVersions: z20.record(z20.string(), z20.string()).nullable(),
7958
- enabled: z20.boolean(),
7959
- nextRunAt: z20.string().nullable(),
7960
- lastRunAt: z20.string().nullable(),
7961
- retryStartedAt: z20.string().nullable(),
7962
- createdAt: z20.string(),
7963
- updatedAt: z20.string()
7964
- });
7965
- var runSummarySchema = z20.object({
7966
- id: z20.string().uuid(),
7967
- status: z20.enum(["pending", "running", "completed", "failed", "timeout"]),
7968
- createdAt: z20.string(),
7969
- completedAt: z20.string().nullable(),
7970
- error: z20.string().nullable()
7971
- });
7972
- var scheduleRunsResponseSchema = z20.object({
7973
- runs: z20.array(runSummarySchema)
7974
- });
7975
- var scheduleListResponseSchema = z20.object({
7976
- schedules: z20.array(scheduleResponseSchema)
7977
- });
7978
- var deployScheduleResponseSchema = z20.object({
8131
+ secretNames: z21.array(z21.string()).nullable(),
8132
+ artifactName: z21.string().nullable(),
8133
+ artifactVersion: z21.string().nullable(),
8134
+ volumeVersions: z21.record(z21.string(), z21.string()).nullable(),
8135
+ enabled: z21.boolean(),
8136
+ nextRunAt: z21.string().nullable(),
8137
+ lastRunAt: z21.string().nullable(),
8138
+ retryStartedAt: z21.string().nullable(),
8139
+ createdAt: z21.string(),
8140
+ updatedAt: z21.string()
8141
+ });
8142
+ var runSummarySchema = z21.object({
8143
+ id: z21.string().uuid(),
8144
+ status: z21.enum(["pending", "running", "completed", "failed", "timeout"]),
8145
+ createdAt: z21.string(),
8146
+ completedAt: z21.string().nullable(),
8147
+ error: z21.string().nullable()
8148
+ });
8149
+ var scheduleRunsResponseSchema = z21.object({
8150
+ runs: z21.array(runSummarySchema)
8151
+ });
8152
+ var scheduleListResponseSchema = z21.object({
8153
+ schedules: z21.array(scheduleResponseSchema)
8154
+ });
8155
+ var deployScheduleResponseSchema = z21.object({
7979
8156
  schedule: scheduleResponseSchema,
7980
- created: z20.boolean()
8157
+ created: z21.boolean()
7981
8158
  // true if created, false if updated
7982
8159
  });
7983
- var schedulesMainContract = c13.router({
8160
+ var schedulesMainContract = c14.router({
7984
8161
  /**
7985
8162
  * POST /api/agent/schedules
7986
8163
  * Deploy (create or update) a schedule
@@ -8018,7 +8195,7 @@ var schedulesMainContract = c13.router({
8018
8195
  summary: "List all schedules"
8019
8196
  }
8020
8197
  });
8021
- var schedulesByNameContract = c13.router({
8198
+ var schedulesByNameContract = c14.router({
8022
8199
  /**
8023
8200
  * GET /api/agent/schedules/:name
8024
8201
  * Get schedule by name
@@ -8027,11 +8204,11 @@ var schedulesByNameContract = c13.router({
8027
8204
  method: "GET",
8028
8205
  path: "/api/agent/schedules/:name",
8029
8206
  headers: authHeadersSchema,
8030
- pathParams: z20.object({
8031
- name: z20.string().min(1, "Schedule name required")
8207
+ pathParams: z21.object({
8208
+ name: z21.string().min(1, "Schedule name required")
8032
8209
  }),
8033
- query: z20.object({
8034
- composeId: z20.string().uuid("Compose ID required")
8210
+ query: z21.object({
8211
+ composeId: z21.string().uuid("Compose ID required")
8035
8212
  }),
8036
8213
  responses: {
8037
8214
  200: scheduleResponseSchema,
@@ -8048,21 +8225,21 @@ var schedulesByNameContract = c13.router({
8048
8225
  method: "DELETE",
8049
8226
  path: "/api/agent/schedules/:name",
8050
8227
  headers: authHeadersSchema,
8051
- pathParams: z20.object({
8052
- name: z20.string().min(1, "Schedule name required")
8228
+ pathParams: z21.object({
8229
+ name: z21.string().min(1, "Schedule name required")
8053
8230
  }),
8054
- query: z20.object({
8055
- composeId: z20.string().uuid("Compose ID required")
8231
+ query: z21.object({
8232
+ composeId: z21.string().uuid("Compose ID required")
8056
8233
  }),
8057
8234
  responses: {
8058
- 204: c13.noBody(),
8235
+ 204: c14.noBody(),
8059
8236
  401: apiErrorSchema,
8060
8237
  404: apiErrorSchema
8061
8238
  },
8062
8239
  summary: "Delete schedule"
8063
8240
  }
8064
8241
  });
8065
- var schedulesEnableContract = c13.router({
8242
+ var schedulesEnableContract = c14.router({
8066
8243
  /**
8067
8244
  * POST /api/agent/schedules/:name/enable
8068
8245
  * Enable a disabled schedule
@@ -8071,11 +8248,11 @@ var schedulesEnableContract = c13.router({
8071
8248
  method: "POST",
8072
8249
  path: "/api/agent/schedules/:name/enable",
8073
8250
  headers: authHeadersSchema,
8074
- pathParams: z20.object({
8075
- name: z20.string().min(1, "Schedule name required")
8251
+ pathParams: z21.object({
8252
+ name: z21.string().min(1, "Schedule name required")
8076
8253
  }),
8077
- body: z20.object({
8078
- composeId: z20.string().uuid("Compose ID required")
8254
+ body: z21.object({
8255
+ composeId: z21.string().uuid("Compose ID required")
8079
8256
  }),
8080
8257
  responses: {
8081
8258
  200: scheduleResponseSchema,
@@ -8092,11 +8269,11 @@ var schedulesEnableContract = c13.router({
8092
8269
  method: "POST",
8093
8270
  path: "/api/agent/schedules/:name/disable",
8094
8271
  headers: authHeadersSchema,
8095
- pathParams: z20.object({
8096
- name: z20.string().min(1, "Schedule name required")
8272
+ pathParams: z21.object({
8273
+ name: z21.string().min(1, "Schedule name required")
8097
8274
  }),
8098
- body: z20.object({
8099
- composeId: z20.string().uuid("Compose ID required")
8275
+ body: z21.object({
8276
+ composeId: z21.string().uuid("Compose ID required")
8100
8277
  }),
8101
8278
  responses: {
8102
8279
  200: scheduleResponseSchema,
@@ -8106,7 +8283,7 @@ var schedulesEnableContract = c13.router({
8106
8283
  summary: "Disable schedule"
8107
8284
  }
8108
8285
  });
8109
- var scheduleRunsContract = c13.router({
8286
+ var scheduleRunsContract = c14.router({
8110
8287
  /**
8111
8288
  * GET /api/agent/schedules/:name/runs
8112
8289
  * List recent runs for a schedule
@@ -8115,12 +8292,12 @@ var scheduleRunsContract = c13.router({
8115
8292
  method: "GET",
8116
8293
  path: "/api/agent/schedules/:name/runs",
8117
8294
  headers: authHeadersSchema,
8118
- pathParams: z20.object({
8119
- name: z20.string().min(1, "Schedule name required")
8295
+ pathParams: z21.object({
8296
+ name: z21.string().min(1, "Schedule name required")
8120
8297
  }),
8121
- query: z20.object({
8122
- composeId: z20.string().uuid("Compose ID required"),
8123
- limit: z20.coerce.number().min(0).max(100).default(5)
8298
+ query: z21.object({
8299
+ composeId: z21.string().uuid("Compose ID required"),
8300
+ limit: z21.coerce.number().min(0).max(100).default(5)
8124
8301
  }),
8125
8302
  responses: {
8126
8303
  200: scheduleRunsResponseSchema,
@@ -8132,18 +8309,18 @@ var scheduleRunsContract = c13.router({
8132
8309
  });
8133
8310
 
8134
8311
  // ../../packages/core/src/contracts/realtime.ts
8135
- import { z as z21 } from "zod";
8136
- var c14 = initContract();
8137
- var ablyTokenRequestSchema = z21.object({
8138
- keyName: z21.string(),
8139
- ttl: z21.number().optional(),
8140
- timestamp: z21.number(),
8141
- capability: z21.string(),
8142
- clientId: z21.string().optional(),
8143
- nonce: z21.string(),
8144
- mac: z21.string()
8145
- });
8146
- var realtimeTokenContract = c14.router({
8312
+ import { z as z22 } from "zod";
8313
+ var c15 = initContract();
8314
+ var ablyTokenRequestSchema = z22.object({
8315
+ keyName: z22.string(),
8316
+ ttl: z22.number().optional(),
8317
+ timestamp: z22.number(),
8318
+ capability: z22.string(),
8319
+ clientId: z22.string().optional(),
8320
+ nonce: z22.string(),
8321
+ mac: z22.string()
8322
+ });
8323
+ var realtimeTokenContract = c15.router({
8147
8324
  /**
8148
8325
  * POST /api/realtime/token
8149
8326
  * Get an Ably token to subscribe to a run's events channel
@@ -8152,8 +8329,8 @@ var realtimeTokenContract = c14.router({
8152
8329
  method: "POST",
8153
8330
  path: "/api/realtime/token",
8154
8331
  headers: authHeadersSchema,
8155
- body: z21.object({
8156
- runId: z21.string().uuid("runId must be a valid UUID")
8332
+ body: z22.object({
8333
+ runId: z22.string().uuid("runId must be a valid UUID")
8157
8334
  }),
8158
8335
  responses: {
8159
8336
  200: ablyTokenRequestSchema,
@@ -8165,7 +8342,7 @@ var realtimeTokenContract = c14.router({
8165
8342
  summary: "Get Ably token for run event subscription"
8166
8343
  }
8167
8344
  });
8168
- var runnerRealtimeTokenContract = c14.router({
8345
+ var runnerRealtimeTokenContract = c15.router({
8169
8346
  /**
8170
8347
  * POST /api/runners/realtime/token
8171
8348
  * Get an Ably token to subscribe to a runner group's job notification channel
@@ -8174,7 +8351,7 @@ var runnerRealtimeTokenContract = c14.router({
8174
8351
  method: "POST",
8175
8352
  path: "/api/runners/realtime/token",
8176
8353
  headers: authHeadersSchema,
8177
- body: z21.object({
8354
+ body: z22.object({
8178
8355
  group: runnerGroupSchema
8179
8356
  }),
8180
8357
  responses: {
@@ -8188,11 +8365,11 @@ var runnerRealtimeTokenContract = c14.router({
8188
8365
  });
8189
8366
 
8190
8367
  // ../../packages/core/src/contracts/platform.ts
8191
- import { z as z23 } from "zod";
8368
+ import { z as z24 } from "zod";
8192
8369
 
8193
8370
  // ../../packages/core/src/contracts/public/common.ts
8194
- import { z as z22 } from "zod";
8195
- var publicApiErrorTypeSchema = z22.enum([
8371
+ import { z as z23 } from "zod";
8372
+ var publicApiErrorTypeSchema = z23.enum([
8196
8373
  "api_error",
8197
8374
  // Internal server error (5xx)
8198
8375
  "invalid_request_error",
@@ -8206,40 +8383,40 @@ var publicApiErrorTypeSchema = z22.enum([
8206
8383
  "rate_limit_error"
8207
8384
  // Rate limit exceeded (429)
8208
8385
  ]);
8209
- var publicApiErrorSchema = z22.object({
8210
- error: z22.object({
8386
+ var publicApiErrorSchema = z23.object({
8387
+ error: z23.object({
8211
8388
  type: publicApiErrorTypeSchema,
8212
- code: z22.string(),
8213
- message: z22.string(),
8214
- param: z22.string().optional(),
8215
- docUrl: z22.string().url().optional()
8389
+ code: z23.string(),
8390
+ message: z23.string(),
8391
+ param: z23.string().optional(),
8392
+ docUrl: z23.string().url().optional()
8216
8393
  })
8217
8394
  });
8218
- var paginationSchema = z22.object({
8219
- hasMore: z22.boolean(),
8220
- nextCursor: z22.string().nullable()
8395
+ var paginationSchema = z23.object({
8396
+ hasMore: z23.boolean(),
8397
+ nextCursor: z23.string().nullable()
8221
8398
  });
8222
8399
  function createPaginatedResponseSchema(dataSchema) {
8223
- return z22.object({
8224
- data: z22.array(dataSchema),
8400
+ return z23.object({
8401
+ data: z23.array(dataSchema),
8225
8402
  pagination: paginationSchema
8226
8403
  });
8227
8404
  }
8228
- var listQuerySchema = z22.object({
8229
- cursor: z22.string().optional(),
8230
- limit: z22.coerce.number().min(1).max(100).default(20)
8405
+ var listQuerySchema = z23.object({
8406
+ cursor: z23.string().optional(),
8407
+ limit: z23.coerce.number().min(1).max(100).default(20)
8231
8408
  });
8232
- var requestIdSchema = z22.string().uuid();
8233
- var timestampSchema = z22.string().datetime();
8409
+ var requestIdSchema = z23.string().uuid();
8410
+ var timestampSchema = z23.string().datetime();
8234
8411
 
8235
8412
  // ../../packages/core/src/contracts/platform.ts
8236
- var c15 = initContract();
8237
- var platformPaginationSchema = z23.object({
8238
- hasMore: z23.boolean(),
8239
- nextCursor: z23.string().nullable(),
8240
- totalPages: z23.number()
8413
+ var c16 = initContract();
8414
+ var platformPaginationSchema = z24.object({
8415
+ hasMore: z24.boolean(),
8416
+ nextCursor: z24.string().nullable(),
8417
+ totalPages: z24.number()
8241
8418
  });
8242
- var platformLogStatusSchema = z23.enum([
8419
+ var platformLogStatusSchema = z24.enum([
8243
8420
  "pending",
8244
8421
  "running",
8245
8422
  "completed",
@@ -8247,41 +8424,41 @@ var platformLogStatusSchema = z23.enum([
8247
8424
  "timeout",
8248
8425
  "cancelled"
8249
8426
  ]);
8250
- var platformLogEntrySchema = z23.object({
8251
- id: z23.string().uuid(),
8252
- sessionId: z23.string().nullable(),
8253
- agentName: z23.string(),
8254
- framework: z23.string().nullable(),
8427
+ var platformLogEntrySchema = z24.object({
8428
+ id: z24.string().uuid(),
8429
+ sessionId: z24.string().nullable(),
8430
+ agentName: z24.string(),
8431
+ framework: z24.string().nullable(),
8255
8432
  status: platformLogStatusSchema,
8256
- createdAt: z23.string()
8433
+ createdAt: z24.string()
8257
8434
  });
8258
- var platformLogsListResponseSchema = z23.object({
8259
- data: z23.array(platformLogEntrySchema),
8435
+ var platformLogsListResponseSchema = z24.object({
8436
+ data: z24.array(platformLogEntrySchema),
8260
8437
  pagination: platformPaginationSchema
8261
8438
  });
8262
- var artifactSchema = z23.object({
8263
- name: z23.string().nullable(),
8264
- version: z23.string().nullable()
8439
+ var artifactSchema = z24.object({
8440
+ name: z24.string().nullable(),
8441
+ version: z24.string().nullable()
8265
8442
  });
8266
- var platformLogDetailSchema = z23.object({
8267
- id: z23.string().uuid(),
8268
- sessionId: z23.string().nullable(),
8269
- agentName: z23.string(),
8270
- framework: z23.string().nullable(),
8443
+ var platformLogDetailSchema = z24.object({
8444
+ id: z24.string().uuid(),
8445
+ sessionId: z24.string().nullable(),
8446
+ agentName: z24.string(),
8447
+ framework: z24.string().nullable(),
8271
8448
  status: platformLogStatusSchema,
8272
- prompt: z23.string(),
8273
- error: z23.string().nullable(),
8274
- createdAt: z23.string(),
8275
- startedAt: z23.string().nullable(),
8276
- completedAt: z23.string().nullable(),
8449
+ prompt: z24.string(),
8450
+ error: z24.string().nullable(),
8451
+ createdAt: z24.string(),
8452
+ startedAt: z24.string().nullable(),
8453
+ completedAt: z24.string().nullable(),
8277
8454
  artifact: artifactSchema
8278
8455
  });
8279
- var platformLogsListContract = c15.router({
8456
+ var platformLogsListContract = c16.router({
8280
8457
  list: {
8281
8458
  method: "GET",
8282
8459
  path: "/api/platform/logs",
8283
8460
  query: listQuerySchema.extend({
8284
- search: z23.string().optional()
8461
+ search: z24.string().optional()
8285
8462
  }),
8286
8463
  responses: {
8287
8464
  200: platformLogsListResponseSchema,
@@ -8290,12 +8467,12 @@ var platformLogsListContract = c15.router({
8290
8467
  summary: "List agent run logs with pagination"
8291
8468
  }
8292
8469
  });
8293
- var platformLogsByIdContract = c15.router({
8470
+ var platformLogsByIdContract = c16.router({
8294
8471
  getById: {
8295
8472
  method: "GET",
8296
8473
  path: "/api/platform/logs/:id",
8297
- pathParams: z23.object({
8298
- id: z23.string().uuid("Invalid log ID")
8474
+ pathParams: z24.object({
8475
+ id: z24.string().uuid("Invalid log ID")
8299
8476
  }),
8300
8477
  responses: {
8301
8478
  200: platformLogDetailSchema,
@@ -8305,17 +8482,17 @@ var platformLogsByIdContract = c15.router({
8305
8482
  summary: "Get agent run log details by ID"
8306
8483
  }
8307
8484
  });
8308
- var artifactDownloadResponseSchema = z23.object({
8309
- url: z23.string().url(),
8310
- expiresAt: z23.string()
8485
+ var artifactDownloadResponseSchema = z24.object({
8486
+ url: z24.string().url(),
8487
+ expiresAt: z24.string()
8311
8488
  });
8312
- var platformArtifactDownloadContract = c15.router({
8489
+ var platformArtifactDownloadContract = c16.router({
8313
8490
  getDownloadUrl: {
8314
8491
  method: "GET",
8315
8492
  path: "/api/platform/artifacts/download",
8316
- query: z23.object({
8317
- name: z23.string().min(1, "Artifact name is required"),
8318
- version: z23.string().optional()
8493
+ query: z24.object({
8494
+ name: z24.string().min(1, "Artifact name is required"),
8495
+ version: z24.string().optional()
8319
8496
  }),
8320
8497
  responses: {
8321
8498
  200: artifactDownloadResponseSchema,
@@ -8327,29 +8504,29 @@ var platformArtifactDownloadContract = c15.router({
8327
8504
  });
8328
8505
 
8329
8506
  // ../../packages/core/src/contracts/llm.ts
8330
- import { z as z24 } from "zod";
8331
- var c16 = initContract();
8332
- var messageRoleSchema = z24.enum(["user", "assistant", "system"]);
8333
- var chatMessageSchema = z24.object({
8507
+ import { z as z25 } from "zod";
8508
+ var c17 = initContract();
8509
+ var messageRoleSchema = z25.enum(["user", "assistant", "system"]);
8510
+ var chatMessageSchema = z25.object({
8334
8511
  role: messageRoleSchema,
8335
- content: z24.string()
8512
+ content: z25.string()
8336
8513
  });
8337
- var tokenUsageSchema = z24.object({
8338
- promptTokens: z24.number(),
8339
- completionTokens: z24.number(),
8340
- totalTokens: z24.number()
8514
+ var tokenUsageSchema = z25.object({
8515
+ promptTokens: z25.number(),
8516
+ completionTokens: z25.number(),
8517
+ totalTokens: z25.number()
8341
8518
  });
8342
- var llmChatRequestSchema = z24.object({
8343
- model: z24.string().min(1).optional(),
8344
- messages: z24.array(chatMessageSchema).min(1, "At least one message is required"),
8345
- stream: z24.boolean().optional().default(false)
8519
+ var llmChatRequestSchema = z25.object({
8520
+ model: z25.string().min(1).optional(),
8521
+ messages: z25.array(chatMessageSchema).min(1, "At least one message is required"),
8522
+ stream: z25.boolean().optional().default(false)
8346
8523
  });
8347
- var llmChatResponseSchema = z24.object({
8348
- content: z24.string(),
8349
- model: z24.string(),
8524
+ var llmChatResponseSchema = z25.object({
8525
+ content: z25.string(),
8526
+ model: z25.string(),
8350
8527
  usage: tokenUsageSchema
8351
8528
  });
8352
- var llmChatContract = c16.router({
8529
+ var llmChatContract = c17.router({
8353
8530
  chat: {
8354
8531
  method: "POST",
8355
8532
  path: "/api/llm/chat",
@@ -8365,28 +8542,28 @@ var llmChatContract = c16.router({
8365
8542
  });
8366
8543
 
8367
8544
  // ../../packages/core/src/contracts/public/agents.ts
8368
- import { z as z25 } from "zod";
8369
- var c17 = initContract();
8370
- var publicAgentSchema = z25.object({
8371
- id: z25.string(),
8372
- name: z25.string(),
8373
- currentVersionId: z25.string().nullable(),
8545
+ import { z as z26 } from "zod";
8546
+ var c18 = initContract();
8547
+ var publicAgentSchema = z26.object({
8548
+ id: z26.string(),
8549
+ name: z26.string(),
8550
+ currentVersionId: z26.string().nullable(),
8374
8551
  createdAt: timestampSchema,
8375
8552
  updatedAt: timestampSchema
8376
8553
  });
8377
- var agentVersionSchema = z25.object({
8378
- id: z25.string(),
8379
- agentId: z25.string(),
8380
- versionNumber: z25.number(),
8554
+ var agentVersionSchema = z26.object({
8555
+ id: z26.string(),
8556
+ agentId: z26.string(),
8557
+ versionNumber: z26.number(),
8381
8558
  createdAt: timestampSchema
8382
8559
  });
8383
8560
  var publicAgentDetailSchema = publicAgentSchema;
8384
8561
  var paginatedAgentsSchema = createPaginatedResponseSchema(publicAgentSchema);
8385
8562
  var paginatedAgentVersionsSchema = createPaginatedResponseSchema(agentVersionSchema);
8386
8563
  var agentListQuerySchema = listQuerySchema.extend({
8387
- name: z25.string().optional()
8564
+ name: z26.string().optional()
8388
8565
  });
8389
- var publicAgentsListContract = c17.router({
8566
+ var publicAgentsListContract = c18.router({
8390
8567
  list: {
8391
8568
  method: "GET",
8392
8569
  path: "/v1/agents",
@@ -8401,13 +8578,13 @@ var publicAgentsListContract = c17.router({
8401
8578
  description: "List all agents in the current scope with pagination. Use the `name` query parameter to filter by agent name."
8402
8579
  }
8403
8580
  });
8404
- var publicAgentByIdContract = c17.router({
8581
+ var publicAgentByIdContract = c18.router({
8405
8582
  get: {
8406
8583
  method: "GET",
8407
8584
  path: "/v1/agents/:id",
8408
8585
  headers: authHeadersSchema,
8409
- pathParams: z25.object({
8410
- id: z25.string().min(1, "Agent ID is required")
8586
+ pathParams: z26.object({
8587
+ id: z26.string().min(1, "Agent ID is required")
8411
8588
  }),
8412
8589
  responses: {
8413
8590
  200: publicAgentDetailSchema,
@@ -8419,13 +8596,13 @@ var publicAgentByIdContract = c17.router({
8419
8596
  description: "Get agent details by ID"
8420
8597
  }
8421
8598
  });
8422
- var publicAgentVersionsContract = c17.router({
8599
+ var publicAgentVersionsContract = c18.router({
8423
8600
  list: {
8424
8601
  method: "GET",
8425
8602
  path: "/v1/agents/:id/versions",
8426
8603
  headers: authHeadersSchema,
8427
- pathParams: z25.object({
8428
- id: z25.string().min(1, "Agent ID is required")
8604
+ pathParams: z26.object({
8605
+ id: z26.string().min(1, "Agent ID is required")
8429
8606
  }),
8430
8607
  query: listQuerySchema,
8431
8608
  responses: {
@@ -8440,9 +8617,9 @@ var publicAgentVersionsContract = c17.router({
8440
8617
  });
8441
8618
 
8442
8619
  // ../../packages/core/src/contracts/public/runs.ts
8443
- import { z as z26 } from "zod";
8444
- var c18 = initContract();
8445
- var publicRunStatusSchema = z26.enum([
8620
+ import { z as z27 } from "zod";
8621
+ var c19 = initContract();
8622
+ var publicRunStatusSchema = z27.enum([
8446
8623
  "pending",
8447
8624
  "running",
8448
8625
  "completed",
@@ -8450,54 +8627,54 @@ var publicRunStatusSchema = z26.enum([
8450
8627
  "timeout",
8451
8628
  "cancelled"
8452
8629
  ]);
8453
- var publicRunSchema = z26.object({
8454
- id: z26.string(),
8455
- agentId: z26.string(),
8456
- agentName: z26.string(),
8630
+ var publicRunSchema = z27.object({
8631
+ id: z27.string(),
8632
+ agentId: z27.string(),
8633
+ agentName: z27.string(),
8457
8634
  status: publicRunStatusSchema,
8458
- prompt: z26.string(),
8635
+ prompt: z27.string(),
8459
8636
  createdAt: timestampSchema,
8460
8637
  startedAt: timestampSchema.nullable(),
8461
8638
  completedAt: timestampSchema.nullable()
8462
8639
  });
8463
8640
  var publicRunDetailSchema = publicRunSchema.extend({
8464
- error: z26.string().nullable(),
8465
- executionTimeMs: z26.number().nullable(),
8466
- checkpointId: z26.string().nullable(),
8467
- sessionId: z26.string().nullable(),
8468
- artifactName: z26.string().nullable(),
8469
- artifactVersion: z26.string().nullable(),
8470
- volumes: z26.record(z26.string(), z26.string()).optional()
8641
+ error: z27.string().nullable(),
8642
+ executionTimeMs: z27.number().nullable(),
8643
+ checkpointId: z27.string().nullable(),
8644
+ sessionId: z27.string().nullable(),
8645
+ artifactName: z27.string().nullable(),
8646
+ artifactVersion: z27.string().nullable(),
8647
+ volumes: z27.record(z27.string(), z27.string()).optional()
8471
8648
  });
8472
8649
  var paginatedRunsSchema = createPaginatedResponseSchema(publicRunSchema);
8473
- var createRunRequestSchema = z26.object({
8650
+ var createRunRequestSchema = z27.object({
8474
8651
  // Agent identification (one of: agent, agentId, sessionId, checkpointId)
8475
- agent: z26.string().optional(),
8652
+ agent: z27.string().optional(),
8476
8653
  // Agent name
8477
- agentId: z26.string().optional(),
8654
+ agentId: z27.string().optional(),
8478
8655
  // Agent ID
8479
- agentVersion: z26.string().optional(),
8656
+ agentVersion: z27.string().optional(),
8480
8657
  // Version specifier (e.g., "latest", "v1", specific ID)
8481
8658
  // Continue session
8482
- sessionId: z26.string().optional(),
8659
+ sessionId: z27.string().optional(),
8483
8660
  // Resume from checkpoint
8484
- checkpointId: z26.string().optional(),
8661
+ checkpointId: z27.string().optional(),
8485
8662
  // Required
8486
- prompt: z26.string().min(1, "Prompt is required"),
8663
+ prompt: z27.string().min(1, "Prompt is required"),
8487
8664
  // Optional configuration
8488
- variables: z26.record(z26.string(), z26.string()).optional(),
8489
- secrets: z26.record(z26.string(), z26.string()).optional(),
8490
- artifactName: z26.string().optional(),
8665
+ variables: z27.record(z27.string(), z27.string()).optional(),
8666
+ secrets: z27.record(z27.string(), z27.string()).optional(),
8667
+ artifactName: z27.string().optional(),
8491
8668
  // Artifact name to mount
8492
- artifactVersion: z26.string().optional(),
8669
+ artifactVersion: z27.string().optional(),
8493
8670
  // Artifact version (defaults to latest)
8494
- volumes: z26.record(z26.string(), z26.string()).optional()
8671
+ volumes: z27.record(z27.string(), z27.string()).optional()
8495
8672
  // volume_name -> version
8496
8673
  });
8497
8674
  var runListQuerySchema = listQuerySchema.extend({
8498
8675
  status: publicRunStatusSchema.optional()
8499
8676
  });
8500
- var publicRunsListContract = c18.router({
8677
+ var publicRunsListContract = c19.router({
8501
8678
  list: {
8502
8679
  method: "GET",
8503
8680
  path: "/v1/runs",
@@ -8529,13 +8706,13 @@ var publicRunsListContract = c18.router({
8529
8706
  description: "Create and execute a new agent run. Returns 202 Accepted as runs execute asynchronously."
8530
8707
  }
8531
8708
  });
8532
- var publicRunByIdContract = c18.router({
8709
+ var publicRunByIdContract = c19.router({
8533
8710
  get: {
8534
8711
  method: "GET",
8535
8712
  path: "/v1/runs/:id",
8536
8713
  headers: authHeadersSchema,
8537
- pathParams: z26.object({
8538
- id: z26.string().min(1, "Run ID is required")
8714
+ pathParams: z27.object({
8715
+ id: z27.string().min(1, "Run ID is required")
8539
8716
  }),
8540
8717
  responses: {
8541
8718
  200: publicRunDetailSchema,
@@ -8547,15 +8724,15 @@ var publicRunByIdContract = c18.router({
8547
8724
  description: "Get run details by ID"
8548
8725
  }
8549
8726
  });
8550
- var publicRunCancelContract = c18.router({
8727
+ var publicRunCancelContract = c19.router({
8551
8728
  cancel: {
8552
8729
  method: "POST",
8553
8730
  path: "/v1/runs/:id/cancel",
8554
8731
  headers: authHeadersSchema,
8555
- pathParams: z26.object({
8556
- id: z26.string().min(1, "Run ID is required")
8732
+ pathParams: z27.object({
8733
+ id: z27.string().min(1, "Run ID is required")
8557
8734
  }),
8558
- body: z26.undefined(),
8735
+ body: z27.undefined(),
8559
8736
  responses: {
8560
8737
  200: publicRunDetailSchema,
8561
8738
  400: publicApiErrorSchema,
@@ -8568,27 +8745,27 @@ var publicRunCancelContract = c18.router({
8568
8745
  description: "Cancel a pending or running execution"
8569
8746
  }
8570
8747
  });
8571
- var logEntrySchema = z26.object({
8748
+ var logEntrySchema = z27.object({
8572
8749
  timestamp: timestampSchema,
8573
- type: z26.enum(["agent", "system", "network"]),
8574
- level: z26.enum(["debug", "info", "warn", "error"]),
8575
- message: z26.string(),
8576
- metadata: z26.record(z26.string(), z26.unknown()).optional()
8750
+ type: z27.enum(["agent", "system", "network"]),
8751
+ level: z27.enum(["debug", "info", "warn", "error"]),
8752
+ message: z27.string(),
8753
+ metadata: z27.record(z27.string(), z27.unknown()).optional()
8577
8754
  });
8578
8755
  var paginatedLogsSchema = createPaginatedResponseSchema(logEntrySchema);
8579
8756
  var logsQuerySchema = listQuerySchema.extend({
8580
- type: z26.enum(["agent", "system", "network", "all"]).default("all"),
8757
+ type: z27.enum(["agent", "system", "network", "all"]).default("all"),
8581
8758
  since: timestampSchema.optional(),
8582
8759
  until: timestampSchema.optional(),
8583
- order: z26.enum(["asc", "desc"]).default("asc")
8760
+ order: z27.enum(["asc", "desc"]).default("asc")
8584
8761
  });
8585
- var publicRunLogsContract = c18.router({
8762
+ var publicRunLogsContract = c19.router({
8586
8763
  getLogs: {
8587
8764
  method: "GET",
8588
8765
  path: "/v1/runs/:id/logs",
8589
8766
  headers: authHeadersSchema,
8590
- pathParams: z26.object({
8591
- id: z26.string().min(1, "Run ID is required")
8767
+ pathParams: z27.object({
8768
+ id: z27.string().min(1, "Run ID is required")
8592
8769
  }),
8593
8770
  query: logsQuerySchema,
8594
8771
  responses: {
@@ -8601,30 +8778,30 @@ var publicRunLogsContract = c18.router({
8601
8778
  description: "Get unified logs for a run. Combines agent, system, and network logs."
8602
8779
  }
8603
8780
  });
8604
- var metricPointSchema = z26.object({
8781
+ var metricPointSchema = z27.object({
8605
8782
  timestamp: timestampSchema,
8606
- cpuPercent: z26.number(),
8607
- memoryUsedMb: z26.number(),
8608
- memoryTotalMb: z26.number(),
8609
- diskUsedMb: z26.number(),
8610
- diskTotalMb: z26.number()
8611
- });
8612
- var metricsSummarySchema = z26.object({
8613
- avgCpuPercent: z26.number(),
8614
- maxMemoryUsedMb: z26.number(),
8615
- totalDurationMs: z26.number().nullable()
8616
- });
8617
- var metricsResponseSchema2 = z26.object({
8618
- data: z26.array(metricPointSchema),
8783
+ cpuPercent: z27.number(),
8784
+ memoryUsedMb: z27.number(),
8785
+ memoryTotalMb: z27.number(),
8786
+ diskUsedMb: z27.number(),
8787
+ diskTotalMb: z27.number()
8788
+ });
8789
+ var metricsSummarySchema = z27.object({
8790
+ avgCpuPercent: z27.number(),
8791
+ maxMemoryUsedMb: z27.number(),
8792
+ totalDurationMs: z27.number().nullable()
8793
+ });
8794
+ var metricsResponseSchema2 = z27.object({
8795
+ data: z27.array(metricPointSchema),
8619
8796
  summary: metricsSummarySchema
8620
8797
  });
8621
- var publicRunMetricsContract = c18.router({
8798
+ var publicRunMetricsContract = c19.router({
8622
8799
  getMetrics: {
8623
8800
  method: "GET",
8624
8801
  path: "/v1/runs/:id/metrics",
8625
8802
  headers: authHeadersSchema,
8626
- pathParams: z26.object({
8627
- id: z26.string().min(1, "Run ID is required")
8803
+ pathParams: z27.object({
8804
+ id: z27.string().min(1, "Run ID is required")
8628
8805
  }),
8629
8806
  responses: {
8630
8807
  200: metricsResponseSchema2,
@@ -8636,7 +8813,7 @@ var publicRunMetricsContract = c18.router({
8636
8813
  description: "Get CPU, memory, and disk metrics for a run"
8637
8814
  }
8638
8815
  });
8639
- var sseEventTypeSchema = z26.enum([
8816
+ var sseEventTypeSchema = z27.enum([
8640
8817
  "status",
8641
8818
  // Run status change
8642
8819
  "output",
@@ -8648,26 +8825,26 @@ var sseEventTypeSchema = z26.enum([
8648
8825
  "heartbeat"
8649
8826
  // Keep-alive
8650
8827
  ]);
8651
- var sseEventSchema = z26.object({
8828
+ var sseEventSchema = z27.object({
8652
8829
  event: sseEventTypeSchema,
8653
- data: z26.unknown(),
8654
- id: z26.string().optional()
8830
+ data: z27.unknown(),
8831
+ id: z27.string().optional()
8655
8832
  // For Last-Event-ID reconnection
8656
8833
  });
8657
- var publicRunEventsContract = c18.router({
8834
+ var publicRunEventsContract = c19.router({
8658
8835
  streamEvents: {
8659
8836
  method: "GET",
8660
8837
  path: "/v1/runs/:id/events",
8661
8838
  headers: authHeadersSchema,
8662
- pathParams: z26.object({
8663
- id: z26.string().min(1, "Run ID is required")
8839
+ pathParams: z27.object({
8840
+ id: z27.string().min(1, "Run ID is required")
8664
8841
  }),
8665
- query: z26.object({
8666
- lastEventId: z26.string().optional()
8842
+ query: z27.object({
8843
+ lastEventId: z27.string().optional()
8667
8844
  // For reconnection
8668
8845
  }),
8669
8846
  responses: {
8670
- 200: z26.any(),
8847
+ 200: z27.any(),
8671
8848
  // SSE stream - actual content is text/event-stream
8672
8849
  401: publicApiErrorSchema,
8673
8850
  404: publicApiErrorSchema,
@@ -8679,28 +8856,28 @@ var publicRunEventsContract = c18.router({
8679
8856
  });
8680
8857
 
8681
8858
  // ../../packages/core/src/contracts/public/artifacts.ts
8682
- import { z as z27 } from "zod";
8683
- var c19 = initContract();
8684
- var publicArtifactSchema = z27.object({
8685
- id: z27.string(),
8686
- name: z27.string(),
8687
- currentVersionId: z27.string().nullable(),
8688
- size: z27.number(),
8859
+ import { z as z28 } from "zod";
8860
+ var c20 = initContract();
8861
+ var publicArtifactSchema = z28.object({
8862
+ id: z28.string(),
8863
+ name: z28.string(),
8864
+ currentVersionId: z28.string().nullable(),
8865
+ size: z28.number(),
8689
8866
  // Total size in bytes
8690
- fileCount: z27.number(),
8867
+ fileCount: z28.number(),
8691
8868
  createdAt: timestampSchema,
8692
8869
  updatedAt: timestampSchema
8693
8870
  });
8694
- var artifactVersionSchema = z27.object({
8695
- id: z27.string(),
8871
+ var artifactVersionSchema = z28.object({
8872
+ id: z28.string(),
8696
8873
  // SHA-256 content hash
8697
- artifactId: z27.string(),
8698
- size: z27.number(),
8874
+ artifactId: z28.string(),
8875
+ size: z28.number(),
8699
8876
  // Size in bytes
8700
- fileCount: z27.number(),
8701
- message: z27.string().nullable(),
8877
+ fileCount: z28.number(),
8878
+ message: z28.string().nullable(),
8702
8879
  // Optional commit message
8703
- createdBy: z27.string(),
8880
+ createdBy: z28.string(),
8704
8881
  createdAt: timestampSchema
8705
8882
  });
8706
8883
  var publicArtifactDetailSchema = publicArtifactSchema.extend({
@@ -8710,7 +8887,7 @@ var paginatedArtifactsSchema = createPaginatedResponseSchema(publicArtifactSchem
8710
8887
  var paginatedArtifactVersionsSchema = createPaginatedResponseSchema(
8711
8888
  artifactVersionSchema
8712
8889
  );
8713
- var publicArtifactsListContract = c19.router({
8890
+ var publicArtifactsListContract = c20.router({
8714
8891
  list: {
8715
8892
  method: "GET",
8716
8893
  path: "/v1/artifacts",
@@ -8725,13 +8902,13 @@ var publicArtifactsListContract = c19.router({
8725
8902
  description: "List all artifacts in the current scope with pagination"
8726
8903
  }
8727
8904
  });
8728
- var publicArtifactByIdContract = c19.router({
8905
+ var publicArtifactByIdContract = c20.router({
8729
8906
  get: {
8730
8907
  method: "GET",
8731
8908
  path: "/v1/artifacts/:id",
8732
8909
  headers: authHeadersSchema,
8733
- pathParams: z27.object({
8734
- id: z27.string().min(1, "Artifact ID is required")
8910
+ pathParams: z28.object({
8911
+ id: z28.string().min(1, "Artifact ID is required")
8735
8912
  }),
8736
8913
  responses: {
8737
8914
  200: publicArtifactDetailSchema,
@@ -8743,13 +8920,13 @@ var publicArtifactByIdContract = c19.router({
8743
8920
  description: "Get artifact details by ID"
8744
8921
  }
8745
8922
  });
8746
- var publicArtifactVersionsContract = c19.router({
8923
+ var publicArtifactVersionsContract = c20.router({
8747
8924
  list: {
8748
8925
  method: "GET",
8749
8926
  path: "/v1/artifacts/:id/versions",
8750
8927
  headers: authHeadersSchema,
8751
- pathParams: z27.object({
8752
- id: z27.string().min(1, "Artifact ID is required")
8928
+ pathParams: z28.object({
8929
+ id: z28.string().min(1, "Artifact ID is required")
8753
8930
  }),
8754
8931
  query: listQuerySchema,
8755
8932
  responses: {
@@ -8762,20 +8939,20 @@ var publicArtifactVersionsContract = c19.router({
8762
8939
  description: "List all versions of an artifact with pagination"
8763
8940
  }
8764
8941
  });
8765
- var publicArtifactDownloadContract = c19.router({
8942
+ var publicArtifactDownloadContract = c20.router({
8766
8943
  download: {
8767
8944
  method: "GET",
8768
8945
  path: "/v1/artifacts/:id/download",
8769
8946
  headers: authHeadersSchema,
8770
- pathParams: z27.object({
8771
- id: z27.string().min(1, "Artifact ID is required")
8947
+ pathParams: z28.object({
8948
+ id: z28.string().min(1, "Artifact ID is required")
8772
8949
  }),
8773
- query: z27.object({
8774
- versionId: z27.string().optional()
8950
+ query: z28.object({
8951
+ versionId: z28.string().optional()
8775
8952
  // Defaults to current version
8776
8953
  }),
8777
8954
  responses: {
8778
- 302: z27.undefined(),
8955
+ 302: z28.undefined(),
8779
8956
  // Redirect to presigned URL
8780
8957
  401: publicApiErrorSchema,
8781
8958
  404: publicApiErrorSchema,
@@ -8787,28 +8964,28 @@ var publicArtifactDownloadContract = c19.router({
8787
8964
  });
8788
8965
 
8789
8966
  // ../../packages/core/src/contracts/public/volumes.ts
8790
- import { z as z28 } from "zod";
8791
- var c20 = initContract();
8792
- var publicVolumeSchema = z28.object({
8793
- id: z28.string(),
8794
- name: z28.string(),
8795
- currentVersionId: z28.string().nullable(),
8796
- size: z28.number(),
8967
+ import { z as z29 } from "zod";
8968
+ var c21 = initContract();
8969
+ var publicVolumeSchema = z29.object({
8970
+ id: z29.string(),
8971
+ name: z29.string(),
8972
+ currentVersionId: z29.string().nullable(),
8973
+ size: z29.number(),
8797
8974
  // Total size in bytes
8798
- fileCount: z28.number(),
8975
+ fileCount: z29.number(),
8799
8976
  createdAt: timestampSchema,
8800
8977
  updatedAt: timestampSchema
8801
8978
  });
8802
- var volumeVersionSchema = z28.object({
8803
- id: z28.string(),
8979
+ var volumeVersionSchema = z29.object({
8980
+ id: z29.string(),
8804
8981
  // SHA-256 content hash
8805
- volumeId: z28.string(),
8806
- size: z28.number(),
8982
+ volumeId: z29.string(),
8983
+ size: z29.number(),
8807
8984
  // Size in bytes
8808
- fileCount: z28.number(),
8809
- message: z28.string().nullable(),
8985
+ fileCount: z29.number(),
8986
+ message: z29.string().nullable(),
8810
8987
  // Optional commit message
8811
- createdBy: z28.string(),
8988
+ createdBy: z29.string(),
8812
8989
  createdAt: timestampSchema
8813
8990
  });
8814
8991
  var publicVolumeDetailSchema = publicVolumeSchema.extend({
@@ -8816,7 +8993,7 @@ var publicVolumeDetailSchema = publicVolumeSchema.extend({
8816
8993
  });
8817
8994
  var paginatedVolumesSchema = createPaginatedResponseSchema(publicVolumeSchema);
8818
8995
  var paginatedVolumeVersionsSchema = createPaginatedResponseSchema(volumeVersionSchema);
8819
- var publicVolumesListContract = c20.router({
8996
+ var publicVolumesListContract = c21.router({
8820
8997
  list: {
8821
8998
  method: "GET",
8822
8999
  path: "/v1/volumes",
@@ -8831,13 +9008,13 @@ var publicVolumesListContract = c20.router({
8831
9008
  description: "List all volumes in the current scope with pagination"
8832
9009
  }
8833
9010
  });
8834
- var publicVolumeByIdContract = c20.router({
9011
+ var publicVolumeByIdContract = c21.router({
8835
9012
  get: {
8836
9013
  method: "GET",
8837
9014
  path: "/v1/volumes/:id",
8838
9015
  headers: authHeadersSchema,
8839
- pathParams: z28.object({
8840
- id: z28.string().min(1, "Volume ID is required")
9016
+ pathParams: z29.object({
9017
+ id: z29.string().min(1, "Volume ID is required")
8841
9018
  }),
8842
9019
  responses: {
8843
9020
  200: publicVolumeDetailSchema,
@@ -8849,13 +9026,13 @@ var publicVolumeByIdContract = c20.router({
8849
9026
  description: "Get volume details by ID"
8850
9027
  }
8851
9028
  });
8852
- var publicVolumeVersionsContract = c20.router({
9029
+ var publicVolumeVersionsContract = c21.router({
8853
9030
  list: {
8854
9031
  method: "GET",
8855
9032
  path: "/v1/volumes/:id/versions",
8856
9033
  headers: authHeadersSchema,
8857
- pathParams: z28.object({
8858
- id: z28.string().min(1, "Volume ID is required")
9034
+ pathParams: z29.object({
9035
+ id: z29.string().min(1, "Volume ID is required")
8859
9036
  }),
8860
9037
  query: listQuerySchema,
8861
9038
  responses: {
@@ -8868,20 +9045,20 @@ var publicVolumeVersionsContract = c20.router({
8868
9045
  description: "List all versions of a volume with pagination"
8869
9046
  }
8870
9047
  });
8871
- var publicVolumeDownloadContract = c20.router({
9048
+ var publicVolumeDownloadContract = c21.router({
8872
9049
  download: {
8873
9050
  method: "GET",
8874
9051
  path: "/v1/volumes/:id/download",
8875
9052
  headers: authHeadersSchema,
8876
- pathParams: z28.object({
8877
- id: z28.string().min(1, "Volume ID is required")
9053
+ pathParams: z29.object({
9054
+ id: z29.string().min(1, "Volume ID is required")
8878
9055
  }),
8879
- query: z28.object({
8880
- versionId: z28.string().optional()
9056
+ query: z29.object({
9057
+ versionId: z29.string().optional()
8881
9058
  // Defaults to current version
8882
9059
  }),
8883
9060
  responses: {
8884
- 302: z28.undefined(),
9061
+ 302: z29.undefined(),
8885
9062
  // Redirect to presigned URL
8886
9063
  401: publicApiErrorSchema,
8887
9064
  404: publicApiErrorSchema,
@@ -10026,6 +10203,13 @@ async function executeJob(context, config, options = {}) {
10026
10203
  firecrackerBinary: config.firecracker.binary,
10027
10204
  workDir: runnerPaths.vmWorkDir(config.base_dir, vmId)
10028
10205
  };
10206
+ fs9.mkdirSync(vmConfig.workDir, { recursive: true });
10207
+ fs9.mkdirSync(vmPaths.vsockDir(vmConfig.workDir), { recursive: true });
10208
+ const vsockPath = vmPaths.vsock(vmConfig.workDir);
10209
+ vsockClient = new VsockClient(vsockPath);
10210
+ const guest = vsockClient;
10211
+ logger9.log(`Starting vsock listener: ${vsockPath}`);
10212
+ const guestConnectionPromise = guest.waitForGuestConnection(3e4);
10029
10213
  logger9.log(`Creating VM ${vmId}...`);
10030
10214
  vm = new FirecrackerVM(vmConfig);
10031
10215
  await withSandboxTiming("vm_create", () => vm.start());
@@ -10037,10 +10221,6 @@ async function executeJob(context, config, options = {}) {
10037
10221
  logger9.log(
10038
10222
  `VM ${vmId} started, guest IP: ${guestIp}, veth NS IP: ${vethNsIp}`
10039
10223
  );
10040
- const vsockPath = vm.getVsockPath();
10041
- vsockClient = new VsockClient(vsockPath);
10042
- const guest = vsockClient;
10043
- logger9.log(`Using vsock for guest communication: ${vsockPath}`);
10044
10224
  const envJson = JSON.stringify(
10045
10225
  buildEnvironmentVariables(context, config.server.url)
10046
10226
  );
@@ -10058,10 +10238,7 @@ async function executeJob(context, config, options = {}) {
10058
10238
  });
10059
10239
  }
10060
10240
  logger9.log(`Waiting for guest connection...`);
10061
- await withSandboxTiming(
10062
- "guest_wait",
10063
- () => guest.waitForGuestConnection(3e4)
10064
- );
10241
+ await withSandboxTiming("guest_wait", () => guestConnectionPromise);
10065
10242
  logger9.log(`Guest client ready`);
10066
10243
  if (context.storageManifest) {
10067
10244
  await withSandboxTiming(
@@ -10264,7 +10441,7 @@ async function isPortInUse(port) {
10264
10441
  }
10265
10442
 
10266
10443
  // src/lib/runner/runner-lock.ts
10267
- import fs9 from "fs";
10444
+ import fs10 from "fs";
10268
10445
  import path5 from "path";
10269
10446
  var logger11 = createLogger("RunnerLock");
10270
10447
  var DEFAULT_PID_FILE = runtimePaths.runnerPid;
@@ -10283,9 +10460,9 @@ function isProcessRunning(pid) {
10283
10460
  function acquireRunnerLock(options = {}) {
10284
10461
  const pidFile = options.pidFile ?? DEFAULT_PID_FILE;
10285
10462
  const runDir = path5.dirname(pidFile);
10286
- fs9.mkdirSync(runDir, { recursive: true });
10287
- if (fs9.existsSync(pidFile)) {
10288
- const pidStr = fs9.readFileSync(pidFile, "utf-8").trim();
10463
+ fs10.mkdirSync(runDir, { recursive: true });
10464
+ if (fs10.existsSync(pidFile)) {
10465
+ const pidStr = fs10.readFileSync(pidFile, "utf-8").trim();
10289
10466
  const pid = parseInt(pidStr, 10);
10290
10467
  if (!isNaN(pid) && isProcessRunning(pid)) {
10291
10468
  logger11.error(`Error: Another runner is already running (PID ${pid})`);
@@ -10297,16 +10474,16 @@ function acquireRunnerLock(options = {}) {
10297
10474
  } else {
10298
10475
  logger11.log(`Cleaning up stale PID file (PID ${pid} not running)`);
10299
10476
  }
10300
- fs9.unlinkSync(pidFile);
10477
+ fs10.unlinkSync(pidFile);
10301
10478
  }
10302
- fs9.writeFileSync(pidFile, process.pid.toString());
10479
+ fs10.writeFileSync(pidFile, process.pid.toString());
10303
10480
  currentPidFile = pidFile;
10304
10481
  logger11.log(`Runner lock acquired (PID ${process.pid})`);
10305
10482
  }
10306
10483
  function releaseRunnerLock() {
10307
10484
  const pidFile = currentPidFile ?? DEFAULT_PID_FILE;
10308
- if (fs9.existsSync(pidFile)) {
10309
- fs9.unlinkSync(pidFile);
10485
+ if (fs10.existsSync(pidFile)) {
10486
+ fs10.unlinkSync(pidFile);
10310
10487
  logger11.log("Runner lock released");
10311
10488
  }
10312
10489
  currentPidFile = null;
@@ -11178,7 +11355,7 @@ var benchmarkCommand = new Command4("benchmark").description(
11178
11355
  });
11179
11356
 
11180
11357
  // src/index.ts
11181
- var version = true ? "3.11.1" : "0.1.0";
11358
+ var version = true ? "3.11.3" : "0.1.0";
11182
11359
  program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
11183
11360
  program.addCommand(startCommand);
11184
11361
  program.addCommand(doctorCommand);