@vm0/runner 3.0.1 → 3.0.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.
- package/index.js +985 -913
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1103,7 +1103,7 @@ var FirecrackerVM = class {
|
|
|
1103
1103
|
mem_size_mib: this.config.memoryMb
|
|
1104
1104
|
});
|
|
1105
1105
|
const networkBootArgs = generateNetworkBootArgs(this.networkConfig);
|
|
1106
|
-
const bootArgs = `console=ttyS0 reboot=k panic=1 pci=off init=/sbin/overlay-init ${networkBootArgs}`;
|
|
1106
|
+
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/overlay-init ${networkBootArgs}`;
|
|
1107
1107
|
console.log(`[VM ${this.config.vmId}] Boot args: ${bootArgs}`);
|
|
1108
1108
|
await this.client.setBootSource({
|
|
1109
1109
|
kernel_image_path: this.config.kernelPath,
|
|
@@ -1226,7 +1226,6 @@ import * as net from "net";
|
|
|
1226
1226
|
import * as fs4 from "fs";
|
|
1227
1227
|
import * as crypto from "crypto";
|
|
1228
1228
|
var VSOCK_PORT = 1e3;
|
|
1229
|
-
var CONNECT_TIMEOUT_MS = 5e3;
|
|
1230
1229
|
var HEADER_SIZE = 4;
|
|
1231
1230
|
var MAX_MESSAGE_SIZE = 1024 * 1024;
|
|
1232
1231
|
var DEFAULT_EXEC_TIMEOUT_MS = 3e5;
|
|
@@ -1261,90 +1260,6 @@ var VsockClient = class {
|
|
|
1261
1260
|
constructor(vsockPath) {
|
|
1262
1261
|
this.vsockPath = vsockPath;
|
|
1263
1262
|
}
|
|
1264
|
-
/**
|
|
1265
|
-
* Connect to the guest agent via vsock
|
|
1266
|
-
*/
|
|
1267
|
-
async connect() {
|
|
1268
|
-
if (this.connected && this.socket) {
|
|
1269
|
-
return;
|
|
1270
|
-
}
|
|
1271
|
-
return new Promise((resolve, reject) => {
|
|
1272
|
-
if (!fs4.existsSync(this.vsockPath)) {
|
|
1273
|
-
reject(new Error(`Vsock socket not found: ${this.vsockPath}`));
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
const socket = net.createConnection(this.vsockPath);
|
|
1277
|
-
const decoder = new Decoder();
|
|
1278
|
-
let fcConnected = false;
|
|
1279
|
-
let gotReady = false;
|
|
1280
|
-
let pingId = null;
|
|
1281
|
-
let connectionEstablished = false;
|
|
1282
|
-
const timeout = setTimeout(() => {
|
|
1283
|
-
socket.destroy();
|
|
1284
|
-
reject(new Error("Vsock connection timeout"));
|
|
1285
|
-
}, CONNECT_TIMEOUT_MS);
|
|
1286
|
-
socket.on("connect", () => {
|
|
1287
|
-
socket.write(`CONNECT ${VSOCK_PORT}
|
|
1288
|
-
`);
|
|
1289
|
-
});
|
|
1290
|
-
socket.on("data", (data) => {
|
|
1291
|
-
if (!fcConnected) {
|
|
1292
|
-
const str = data.toString();
|
|
1293
|
-
if (str.startsWith("OK ")) {
|
|
1294
|
-
fcConnected = true;
|
|
1295
|
-
} else {
|
|
1296
|
-
clearTimeout(timeout);
|
|
1297
|
-
socket.destroy();
|
|
1298
|
-
reject(new Error(`Firecracker connect failed: ${str.trim()}`));
|
|
1299
|
-
}
|
|
1300
|
-
return;
|
|
1301
|
-
}
|
|
1302
|
-
try {
|
|
1303
|
-
for (const msg of decoder.decode(data)) {
|
|
1304
|
-
if (!connectionEstablished) {
|
|
1305
|
-
if (!gotReady && msg.type === "ready") {
|
|
1306
|
-
gotReady = true;
|
|
1307
|
-
pingId = crypto.randomUUID();
|
|
1308
|
-
const ping = { type: "ping", id: pingId, payload: {} };
|
|
1309
|
-
socket.write(encode(ping));
|
|
1310
|
-
} else if (msg.type === "pong" && msg.id === pingId) {
|
|
1311
|
-
clearTimeout(timeout);
|
|
1312
|
-
this.socket = socket;
|
|
1313
|
-
this.connected = true;
|
|
1314
|
-
connectionEstablished = true;
|
|
1315
|
-
resolve();
|
|
1316
|
-
}
|
|
1317
|
-
} else {
|
|
1318
|
-
this.handleMessage(msg);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
} catch (e) {
|
|
1322
|
-
clearTimeout(timeout);
|
|
1323
|
-
socket.destroy();
|
|
1324
|
-
reject(new Error(`Failed to parse message: ${e}`));
|
|
1325
|
-
}
|
|
1326
|
-
});
|
|
1327
|
-
socket.on("error", (err) => {
|
|
1328
|
-
clearTimeout(timeout);
|
|
1329
|
-
this.connected = false;
|
|
1330
|
-
this.socket = null;
|
|
1331
|
-
reject(new Error(`Vsock error: ${err.message}`));
|
|
1332
|
-
});
|
|
1333
|
-
socket.on("close", () => {
|
|
1334
|
-
clearTimeout(timeout);
|
|
1335
|
-
this.connected = false;
|
|
1336
|
-
this.socket = null;
|
|
1337
|
-
if (!gotReady) {
|
|
1338
|
-
reject(new Error("Vsock closed before ready"));
|
|
1339
|
-
}
|
|
1340
|
-
for (const [id, req] of this.pendingRequests) {
|
|
1341
|
-
clearTimeout(req.timeout);
|
|
1342
|
-
req.reject(new Error("Connection closed"));
|
|
1343
|
-
this.pendingRequests.delete(id);
|
|
1344
|
-
}
|
|
1345
|
-
});
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
1263
|
/**
|
|
1349
1264
|
* Handle incoming message and route to pending request
|
|
1350
1265
|
*/
|
|
@@ -1360,9 +1275,8 @@ var VsockClient = class {
|
|
|
1360
1275
|
* Send a request and wait for response
|
|
1361
1276
|
*/
|
|
1362
1277
|
async request(type, payload, timeoutMs) {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
throw new Error("Not connected");
|
|
1278
|
+
if (!this.connected || !this.socket) {
|
|
1279
|
+
throw new Error("Not connected - call waitForGuestConnection() first");
|
|
1366
1280
|
}
|
|
1367
1281
|
const id = crypto.randomUUID();
|
|
1368
1282
|
const msg = { type, id, payload };
|
|
@@ -1486,24 +1400,113 @@ var VsockClient = class {
|
|
|
1486
1400
|
}
|
|
1487
1401
|
}
|
|
1488
1402
|
/**
|
|
1489
|
-
* Wait for
|
|
1403
|
+
* Wait for guest to connect (Guest-initiated mode)
|
|
1404
|
+
*
|
|
1405
|
+
* Instead of polling, this listens on "{vsockPath}_{port}" and waits
|
|
1406
|
+
* for the guest to actively connect. This provides zero-latency
|
|
1407
|
+
* notification when the guest is ready.
|
|
1408
|
+
*
|
|
1409
|
+
* Flow:
|
|
1410
|
+
* 1. Host creates UDS server at "{vsockPath}_{port}"
|
|
1411
|
+
* 2. Guest boots and vsock-agent connects to CID=2, port
|
|
1412
|
+
* 3. Firecracker forwards connection to Host's UDS
|
|
1413
|
+
* 4. Host accepts, receives "ready", sends ping/pong
|
|
1490
1414
|
*/
|
|
1491
|
-
async
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1415
|
+
async waitForGuestConnection(timeoutMs = 3e4) {
|
|
1416
|
+
if (this.connected && this.socket) {
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
const listenerPath = `${this.vsockPath}_${VSOCK_PORT}`;
|
|
1420
|
+
if (fs4.existsSync(listenerPath)) {
|
|
1421
|
+
fs4.unlinkSync(listenerPath);
|
|
1422
|
+
}
|
|
1423
|
+
return new Promise((resolve, reject) => {
|
|
1424
|
+
const server = net.createServer();
|
|
1425
|
+
const decoder = new Decoder();
|
|
1426
|
+
let settled = false;
|
|
1427
|
+
const timeout = setTimeout(() => {
|
|
1428
|
+
if (!settled) {
|
|
1429
|
+
settled = true;
|
|
1430
|
+
server.close();
|
|
1431
|
+
if (fs4.existsSync(listenerPath)) {
|
|
1432
|
+
fs4.unlinkSync(listenerPath);
|
|
1433
|
+
}
|
|
1434
|
+
reject(new Error(`Guest connection timeout after ${timeoutMs}ms`));
|
|
1435
|
+
}
|
|
1436
|
+
}, timeoutMs);
|
|
1437
|
+
const cleanup = (err) => {
|
|
1438
|
+
if (!settled) {
|
|
1439
|
+
settled = true;
|
|
1440
|
+
clearTimeout(timeout);
|
|
1441
|
+
server.close();
|
|
1442
|
+
if (fs4.existsSync(listenerPath)) {
|
|
1443
|
+
fs4.unlinkSync(listenerPath);
|
|
1444
|
+
}
|
|
1445
|
+
reject(err);
|
|
1503
1446
|
}
|
|
1447
|
+
};
|
|
1448
|
+
server.on("error", (err) => {
|
|
1449
|
+
cleanup(new Error(`Server error: ${err.message}`));
|
|
1504
1450
|
});
|
|
1505
|
-
|
|
1506
|
-
|
|
1451
|
+
server.on("connection", (socket) => {
|
|
1452
|
+
server.close();
|
|
1453
|
+
let State;
|
|
1454
|
+
((State2) => {
|
|
1455
|
+
State2[State2["WaitingForReady"] = 0] = "WaitingForReady";
|
|
1456
|
+
State2[State2["WaitingForPong"] = 1] = "WaitingForPong";
|
|
1457
|
+
State2[State2["Connected"] = 2] = "Connected";
|
|
1458
|
+
})(State || (State = {}));
|
|
1459
|
+
let state = 0 /* WaitingForReady */;
|
|
1460
|
+
let pingId = null;
|
|
1461
|
+
socket.on("data", (data) => {
|
|
1462
|
+
try {
|
|
1463
|
+
for (const msg of decoder.decode(data)) {
|
|
1464
|
+
if (state === 0 /* WaitingForReady */ && msg.type === "ready") {
|
|
1465
|
+
state = 1 /* WaitingForPong */;
|
|
1466
|
+
pingId = crypto.randomUUID();
|
|
1467
|
+
socket.write(encode({ type: "ping", id: pingId, payload: {} }));
|
|
1468
|
+
} else if (state === 1 /* WaitingForPong */ && msg.type === "pong" && msg.id === pingId) {
|
|
1469
|
+
if (settled) {
|
|
1470
|
+
socket.destroy();
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
settled = true;
|
|
1474
|
+
clearTimeout(timeout);
|
|
1475
|
+
if (fs4.existsSync(listenerPath)) {
|
|
1476
|
+
fs4.unlinkSync(listenerPath);
|
|
1477
|
+
}
|
|
1478
|
+
state = 2 /* Connected */;
|
|
1479
|
+
this.socket = socket;
|
|
1480
|
+
this.connected = true;
|
|
1481
|
+
resolve();
|
|
1482
|
+
} else if (state === 2 /* Connected */) {
|
|
1483
|
+
this.handleMessage(msg);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
} catch (e) {
|
|
1487
|
+
cleanup(new Error(`Failed to parse message: ${e}`));
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
socket.on("error", (err) => {
|
|
1491
|
+
cleanup(new Error(`Socket error: ${err.message}`));
|
|
1492
|
+
});
|
|
1493
|
+
socket.on("close", () => {
|
|
1494
|
+
if (!settled) {
|
|
1495
|
+
cleanup(new Error("Guest disconnected before ready"));
|
|
1496
|
+
}
|
|
1497
|
+
this.connected = false;
|
|
1498
|
+
this.socket = null;
|
|
1499
|
+
const pending = Array.from(this.pendingRequests.values());
|
|
1500
|
+
this.pendingRequests.clear();
|
|
1501
|
+
for (const req of pending) {
|
|
1502
|
+
clearTimeout(req.timeout);
|
|
1503
|
+
req.reject(new Error("Connection closed"));
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
server.listen(listenerPath, () => {
|
|
1508
|
+
});
|
|
1509
|
+
});
|
|
1507
1510
|
}
|
|
1508
1511
|
/**
|
|
1509
1512
|
* Create a directory on the remote VM
|
|
@@ -1533,14 +1536,18 @@ var VsockClient = class {
|
|
|
1533
1536
|
this.socket = null;
|
|
1534
1537
|
}
|
|
1535
1538
|
this.connected = false;
|
|
1536
|
-
|
|
1539
|
+
const pending = Array.from(this.pendingRequests.values());
|
|
1540
|
+
this.pendingRequests.clear();
|
|
1541
|
+
for (const req of pending) {
|
|
1537
1542
|
clearTimeout(req.timeout);
|
|
1538
1543
|
req.reject(new Error("Connection closed"));
|
|
1539
|
-
this.pendingRequests.delete(id);
|
|
1540
1544
|
}
|
|
1541
1545
|
}
|
|
1542
1546
|
};
|
|
1543
1547
|
|
|
1548
|
+
// ../../packages/core/src/contracts/base.ts
|
|
1549
|
+
import { z as z3 } from "zod";
|
|
1550
|
+
|
|
1544
1551
|
// ../../node_modules/.pnpm/@ts-rest+core@3.53.0-rc.1_@types+node@24.3.0/node_modules/@ts-rest/core/index.esm.mjs
|
|
1545
1552
|
var util;
|
|
1546
1553
|
(function(util2) {
|
|
@@ -5367,56 +5374,62 @@ var initContract = () => {
|
|
|
5367
5374
|
};
|
|
5368
5375
|
};
|
|
5369
5376
|
|
|
5377
|
+
// ../../packages/core/src/contracts/base.ts
|
|
5378
|
+
var authHeadersSchema = z3.object({
|
|
5379
|
+
authorization: z3.string().optional()
|
|
5380
|
+
});
|
|
5381
|
+
|
|
5370
5382
|
// ../../packages/core/src/contracts/errors.ts
|
|
5371
|
-
import { z as
|
|
5372
|
-
var apiErrorSchema =
|
|
5373
|
-
error:
|
|
5374
|
-
message:
|
|
5375
|
-
code:
|
|
5383
|
+
import { z as z4 } from "zod";
|
|
5384
|
+
var apiErrorSchema = z4.object({
|
|
5385
|
+
error: z4.object({
|
|
5386
|
+
message: z4.string(),
|
|
5387
|
+
code: z4.string()
|
|
5376
5388
|
})
|
|
5377
5389
|
});
|
|
5378
5390
|
|
|
5379
5391
|
// ../../packages/core/src/contracts/composes.ts
|
|
5380
|
-
import { z as
|
|
5392
|
+
import { z as z6 } from "zod";
|
|
5381
5393
|
|
|
5382
5394
|
// ../../packages/core/src/contracts/runners.ts
|
|
5383
|
-
import { z as
|
|
5395
|
+
import { z as z5 } from "zod";
|
|
5384
5396
|
var c = initContract();
|
|
5385
|
-
var firewallRuleSchema =
|
|
5386
|
-
domain:
|
|
5387
|
-
ip:
|
|
5397
|
+
var firewallRuleSchema = z5.object({
|
|
5398
|
+
domain: z5.string().optional(),
|
|
5399
|
+
ip: z5.string().optional(),
|
|
5388
5400
|
/** Terminal rule - value is the action (ALLOW or DENY) */
|
|
5389
|
-
final:
|
|
5401
|
+
final: z5.enum(["ALLOW", "DENY"]).optional(),
|
|
5390
5402
|
/** Action for domain/ip rules */
|
|
5391
|
-
action:
|
|
5403
|
+
action: z5.enum(["ALLOW", "DENY"]).optional()
|
|
5392
5404
|
});
|
|
5393
|
-
var experimentalFirewallSchema =
|
|
5394
|
-
enabled:
|
|
5395
|
-
rules:
|
|
5396
|
-
experimental_mitm:
|
|
5397
|
-
experimental_seal_secrets:
|
|
5405
|
+
var experimentalFirewallSchema = z5.object({
|
|
5406
|
+
enabled: z5.boolean(),
|
|
5407
|
+
rules: z5.array(firewallRuleSchema).optional(),
|
|
5408
|
+
experimental_mitm: z5.boolean().optional(),
|
|
5409
|
+
experimental_seal_secrets: z5.boolean().optional()
|
|
5398
5410
|
});
|
|
5399
|
-
var runnerGroupSchema =
|
|
5411
|
+
var runnerGroupSchema = z5.string().regex(
|
|
5400
5412
|
/^[a-z0-9-]+\/[a-z0-9-]+$/,
|
|
5401
5413
|
"Runner group must be in scope/name format (e.g., acme/production)"
|
|
5402
5414
|
);
|
|
5403
|
-
var jobSchema =
|
|
5404
|
-
runId:
|
|
5405
|
-
prompt:
|
|
5406
|
-
agentComposeVersionId:
|
|
5407
|
-
vars:
|
|
5408
|
-
secretNames:
|
|
5409
|
-
checkpointId:
|
|
5415
|
+
var jobSchema = z5.object({
|
|
5416
|
+
runId: z5.string().uuid(),
|
|
5417
|
+
prompt: z5.string(),
|
|
5418
|
+
agentComposeVersionId: z5.string(),
|
|
5419
|
+
vars: z5.record(z5.string(), z5.string()).nullable(),
|
|
5420
|
+
secretNames: z5.array(z5.string()).nullable(),
|
|
5421
|
+
checkpointId: z5.string().uuid().nullable()
|
|
5410
5422
|
});
|
|
5411
5423
|
var runnersPollContract = c.router({
|
|
5412
5424
|
poll: {
|
|
5413
5425
|
method: "POST",
|
|
5414
5426
|
path: "/api/runners/poll",
|
|
5415
|
-
|
|
5427
|
+
headers: authHeadersSchema,
|
|
5428
|
+
body: z5.object({
|
|
5416
5429
|
group: runnerGroupSchema
|
|
5417
5430
|
}),
|
|
5418
5431
|
responses: {
|
|
5419
|
-
200:
|
|
5432
|
+
200: z5.object({
|
|
5420
5433
|
job: jobSchema.nullable()
|
|
5421
5434
|
}),
|
|
5422
5435
|
400: apiErrorSchema,
|
|
@@ -5426,64 +5439,65 @@ var runnersPollContract = c.router({
|
|
|
5426
5439
|
summary: "Poll for pending jobs (long-polling with 30s timeout)"
|
|
5427
5440
|
}
|
|
5428
5441
|
});
|
|
5429
|
-
var storageEntrySchema =
|
|
5430
|
-
mountPath:
|
|
5431
|
-
archiveUrl:
|
|
5442
|
+
var storageEntrySchema = z5.object({
|
|
5443
|
+
mountPath: z5.string(),
|
|
5444
|
+
archiveUrl: z5.string().nullable()
|
|
5432
5445
|
});
|
|
5433
|
-
var artifactEntrySchema =
|
|
5434
|
-
mountPath:
|
|
5435
|
-
archiveUrl:
|
|
5436
|
-
vasStorageName:
|
|
5437
|
-
vasVersionId:
|
|
5446
|
+
var artifactEntrySchema = z5.object({
|
|
5447
|
+
mountPath: z5.string(),
|
|
5448
|
+
archiveUrl: z5.string().nullable(),
|
|
5449
|
+
vasStorageName: z5.string(),
|
|
5450
|
+
vasVersionId: z5.string()
|
|
5438
5451
|
});
|
|
5439
|
-
var storageManifestSchema =
|
|
5440
|
-
storages:
|
|
5452
|
+
var storageManifestSchema = z5.object({
|
|
5453
|
+
storages: z5.array(storageEntrySchema),
|
|
5441
5454
|
artifact: artifactEntrySchema.nullable()
|
|
5442
5455
|
});
|
|
5443
|
-
var resumeSessionSchema =
|
|
5444
|
-
sessionId:
|
|
5445
|
-
sessionHistory:
|
|
5456
|
+
var resumeSessionSchema = z5.object({
|
|
5457
|
+
sessionId: z5.string(),
|
|
5458
|
+
sessionHistory: z5.string()
|
|
5446
5459
|
});
|
|
5447
|
-
var storedExecutionContextSchema =
|
|
5448
|
-
workingDir:
|
|
5460
|
+
var storedExecutionContextSchema = z5.object({
|
|
5461
|
+
workingDir: z5.string(),
|
|
5449
5462
|
storageManifest: storageManifestSchema.nullable(),
|
|
5450
|
-
environment:
|
|
5463
|
+
environment: z5.record(z5.string(), z5.string()).nullable(),
|
|
5451
5464
|
resumeSession: resumeSessionSchema.nullable(),
|
|
5452
|
-
encryptedSecrets:
|
|
5465
|
+
encryptedSecrets: z5.string().nullable(),
|
|
5453
5466
|
// AES-256-GCM encrypted secrets
|
|
5454
|
-
cliAgentType:
|
|
5467
|
+
cliAgentType: z5.string(),
|
|
5455
5468
|
experimentalFirewall: experimentalFirewallSchema.optional(),
|
|
5456
5469
|
// Debug flag to force real Claude in mock environments (internal use only)
|
|
5457
|
-
debugNoMockClaude:
|
|
5458
|
-
});
|
|
5459
|
-
var executionContextSchema =
|
|
5460
|
-
runId:
|
|
5461
|
-
prompt:
|
|
5462
|
-
agentComposeVersionId:
|
|
5463
|
-
vars:
|
|
5464
|
-
secretNames:
|
|
5465
|
-
checkpointId:
|
|
5466
|
-
sandboxToken:
|
|
5470
|
+
debugNoMockClaude: z5.boolean().optional()
|
|
5471
|
+
});
|
|
5472
|
+
var executionContextSchema = z5.object({
|
|
5473
|
+
runId: z5.string().uuid(),
|
|
5474
|
+
prompt: z5.string(),
|
|
5475
|
+
agentComposeVersionId: z5.string(),
|
|
5476
|
+
vars: z5.record(z5.string(), z5.string()).nullable(),
|
|
5477
|
+
secretNames: z5.array(z5.string()).nullable(),
|
|
5478
|
+
checkpointId: z5.string().uuid().nullable(),
|
|
5479
|
+
sandboxToken: z5.string(),
|
|
5467
5480
|
// New fields for E2B parity:
|
|
5468
|
-
workingDir:
|
|
5481
|
+
workingDir: z5.string(),
|
|
5469
5482
|
storageManifest: storageManifestSchema.nullable(),
|
|
5470
|
-
environment:
|
|
5483
|
+
environment: z5.record(z5.string(), z5.string()).nullable(),
|
|
5471
5484
|
resumeSession: resumeSessionSchema.nullable(),
|
|
5472
|
-
secretValues:
|
|
5473
|
-
cliAgentType:
|
|
5485
|
+
secretValues: z5.array(z5.string()).nullable(),
|
|
5486
|
+
cliAgentType: z5.string(),
|
|
5474
5487
|
// Experimental firewall configuration
|
|
5475
5488
|
experimentalFirewall: experimentalFirewallSchema.optional(),
|
|
5476
5489
|
// Debug flag to force real Claude in mock environments (internal use only)
|
|
5477
|
-
debugNoMockClaude:
|
|
5490
|
+
debugNoMockClaude: z5.boolean().optional()
|
|
5478
5491
|
});
|
|
5479
5492
|
var runnersJobClaimContract = c.router({
|
|
5480
5493
|
claim: {
|
|
5481
5494
|
method: "POST",
|
|
5482
5495
|
path: "/api/runners/jobs/:id/claim",
|
|
5483
|
-
|
|
5484
|
-
|
|
5496
|
+
headers: authHeadersSchema,
|
|
5497
|
+
pathParams: z5.object({
|
|
5498
|
+
id: z5.string().uuid()
|
|
5485
5499
|
}),
|
|
5486
|
-
body:
|
|
5500
|
+
body: z5.object({}),
|
|
5487
5501
|
responses: {
|
|
5488
5502
|
200: executionContextSchema,
|
|
5489
5503
|
400: apiErrorSchema,
|
|
@@ -5501,85 +5515,82 @@ var runnersJobClaimContract = c.router({
|
|
|
5501
5515
|
|
|
5502
5516
|
// ../../packages/core/src/contracts/composes.ts
|
|
5503
5517
|
var c2 = initContract();
|
|
5504
|
-
var composeVersionQuerySchema =
|
|
5518
|
+
var composeVersionQuerySchema = z6.preprocess(
|
|
5505
5519
|
(val) => val === void 0 || val === null ? void 0 : String(val),
|
|
5506
|
-
|
|
5520
|
+
z6.string().min(1, "Missing version query parameter").regex(
|
|
5507
5521
|
/^[a-f0-9]{8,64}$|^latest$/i,
|
|
5508
5522
|
"Version must be 8-64 hex characters or 'latest'"
|
|
5509
5523
|
)
|
|
5510
5524
|
);
|
|
5511
|
-
var agentNameSchema =
|
|
5525
|
+
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(
|
|
5512
5526
|
/^[a-zA-Z0-9][a-zA-Z0-9-]{1,62}[a-zA-Z0-9]$/,
|
|
5513
5527
|
"Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
|
|
5514
5528
|
);
|
|
5515
|
-
var volumeConfigSchema =
|
|
5516
|
-
name:
|
|
5517
|
-
version:
|
|
5529
|
+
var volumeConfigSchema = z6.object({
|
|
5530
|
+
name: z6.string().min(1, "Volume name is required"),
|
|
5531
|
+
version: z6.string().min(1, "Volume version is required")
|
|
5518
5532
|
});
|
|
5519
5533
|
var SUPPORTED_APPS = ["github"];
|
|
5520
5534
|
var SUPPORTED_APP_TAGS = ["latest", "dev"];
|
|
5521
5535
|
var APP_NAME_REGEX = /^[a-z0-9-]+$/;
|
|
5522
|
-
var appStringSchema =
|
|
5536
|
+
var appStringSchema = z6.string().superRefine((val, ctx) => {
|
|
5523
5537
|
const [appName, tag] = val.split(":");
|
|
5524
5538
|
if (!appName || !APP_NAME_REGEX.test(appName)) {
|
|
5525
5539
|
ctx.addIssue({
|
|
5526
|
-
code:
|
|
5540
|
+
code: z6.ZodIssueCode.custom,
|
|
5527
5541
|
message: "App name must contain only lowercase letters, numbers, and hyphens"
|
|
5528
5542
|
});
|
|
5529
5543
|
return;
|
|
5530
5544
|
}
|
|
5531
5545
|
if (!SUPPORTED_APPS.includes(appName)) {
|
|
5532
5546
|
ctx.addIssue({
|
|
5533
|
-
code:
|
|
5547
|
+
code: z6.ZodIssueCode.custom,
|
|
5534
5548
|
message: `Invalid app: "${appName}". Supported apps: ${SUPPORTED_APPS.join(", ")}`
|
|
5535
5549
|
});
|
|
5536
5550
|
return;
|
|
5537
5551
|
}
|
|
5538
5552
|
if (tag !== void 0 && !SUPPORTED_APP_TAGS.includes(tag)) {
|
|
5539
5553
|
ctx.addIssue({
|
|
5540
|
-
code:
|
|
5554
|
+
code: z6.ZodIssueCode.custom,
|
|
5541
5555
|
message: `Invalid app tag: "${tag}". Supported tags: ${SUPPORTED_APP_TAGS.join(", ")}`
|
|
5542
5556
|
});
|
|
5543
5557
|
}
|
|
5544
5558
|
});
|
|
5545
|
-
var
|
|
5546
|
-
|
|
5547
|
-
);
|
|
5548
|
-
var agentDefinitionSchema = z5.object({
|
|
5549
|
-
description: z5.string().optional(),
|
|
5559
|
+
var agentDefinitionSchema = z6.object({
|
|
5560
|
+
description: z6.string().optional(),
|
|
5550
5561
|
/**
|
|
5551
5562
|
* @deprecated Use `apps` field instead for pre-installed tools.
|
|
5552
5563
|
* This field will be removed in a future version.
|
|
5553
5564
|
*/
|
|
5554
|
-
image:
|
|
5555
|
-
framework:
|
|
5565
|
+
image: z6.string().optional(),
|
|
5566
|
+
framework: z6.string().min(1, "Framework is required"),
|
|
5556
5567
|
/**
|
|
5557
5568
|
* Array of pre-installed apps/tools for the agent environment.
|
|
5558
5569
|
* Format: "app" or "app:tag" (e.g., "github", "github:dev", "github:latest")
|
|
5559
5570
|
* Default tag is "latest" if not specified.
|
|
5560
5571
|
* Currently supported apps: "github" (includes GitHub CLI)
|
|
5561
5572
|
*/
|
|
5562
|
-
apps:
|
|
5563
|
-
volumes:
|
|
5564
|
-
working_dir:
|
|
5573
|
+
apps: z6.array(appStringSchema).optional(),
|
|
5574
|
+
volumes: z6.array(z6.string()).optional(),
|
|
5575
|
+
working_dir: z6.string().optional(),
|
|
5565
5576
|
// Optional when provider supports auto-config
|
|
5566
|
-
environment:
|
|
5577
|
+
environment: z6.record(z6.string(), z6.string()).optional(),
|
|
5567
5578
|
/**
|
|
5568
5579
|
* Path to instructions file (e.g., AGENTS.md).
|
|
5569
5580
|
* Auto-uploaded as volume and mounted at /home/user/.claude/CLAUDE.md
|
|
5570
5581
|
*/
|
|
5571
|
-
instructions:
|
|
5582
|
+
instructions: z6.string().min(1, "Instructions path cannot be empty").optional(),
|
|
5572
5583
|
/**
|
|
5573
5584
|
* Array of GitHub tree URLs for agent skills.
|
|
5574
5585
|
* Each skill is auto-downloaded and mounted at /home/user/.claude/skills/{skillName}/
|
|
5575
5586
|
*/
|
|
5576
|
-
skills:
|
|
5587
|
+
skills: z6.array(z6.string()).optional(),
|
|
5577
5588
|
/**
|
|
5578
5589
|
* Route this agent to a self-hosted runner instead of E2B.
|
|
5579
5590
|
* When specified, runs will be queued for the specified runner group.
|
|
5580
5591
|
*/
|
|
5581
|
-
experimental_runner:
|
|
5582
|
-
group:
|
|
5592
|
+
experimental_runner: z6.object({
|
|
5593
|
+
group: z6.string().regex(
|
|
5583
5594
|
/^[a-z0-9-]+\/[a-z0-9-]+$/,
|
|
5584
5595
|
"Runner group must be in scope/name format (e.g., acme/production)"
|
|
5585
5596
|
)
|
|
@@ -5589,37 +5600,27 @@ var agentDefinitionSchema = z5.object({
|
|
|
5589
5600
|
* Requires experimental_runner to be configured.
|
|
5590
5601
|
* When enabled, filters outbound traffic by domain/IP rules.
|
|
5591
5602
|
*/
|
|
5592
|
-
experimental_firewall: experimentalFirewallSchema.optional()
|
|
5593
|
-
/**
|
|
5594
|
-
* Array of secret names to inject from the scope's secret store.
|
|
5595
|
-
* Each entry must be a non-empty string.
|
|
5596
|
-
*/
|
|
5597
|
-
experimental_secrets: nonEmptyStringArraySchema.optional(),
|
|
5598
|
-
/**
|
|
5599
|
-
* Array of variable names to inject from the scope's variable store.
|
|
5600
|
-
* Each entry must be a non-empty string.
|
|
5601
|
-
*/
|
|
5602
|
-
experimental_vars: nonEmptyStringArraySchema.optional()
|
|
5603
|
+
experimental_firewall: experimentalFirewallSchema.optional()
|
|
5603
5604
|
});
|
|
5604
|
-
var agentComposeContentSchema =
|
|
5605
|
-
version:
|
|
5606
|
-
agents:
|
|
5607
|
-
volumes:
|
|
5605
|
+
var agentComposeContentSchema = z6.object({
|
|
5606
|
+
version: z6.string().min(1, "Version is required"),
|
|
5607
|
+
agents: z6.record(z6.string(), agentDefinitionSchema),
|
|
5608
|
+
volumes: z6.record(z6.string(), volumeConfigSchema).optional()
|
|
5608
5609
|
});
|
|
5609
|
-
var composeResponseSchema =
|
|
5610
|
-
id:
|
|
5611
|
-
name:
|
|
5612
|
-
headVersionId:
|
|
5610
|
+
var composeResponseSchema = z6.object({
|
|
5611
|
+
id: z6.string(),
|
|
5612
|
+
name: z6.string(),
|
|
5613
|
+
headVersionId: z6.string().nullable(),
|
|
5613
5614
|
content: agentComposeContentSchema.nullable(),
|
|
5614
|
-
createdAt:
|
|
5615
|
-
updatedAt:
|
|
5615
|
+
createdAt: z6.string(),
|
|
5616
|
+
updatedAt: z6.string()
|
|
5616
5617
|
});
|
|
5617
|
-
var createComposeResponseSchema =
|
|
5618
|
-
composeId:
|
|
5619
|
-
name:
|
|
5620
|
-
versionId:
|
|
5621
|
-
action:
|
|
5622
|
-
updatedAt:
|
|
5618
|
+
var createComposeResponseSchema = z6.object({
|
|
5619
|
+
composeId: z6.string(),
|
|
5620
|
+
name: z6.string(),
|
|
5621
|
+
versionId: z6.string(),
|
|
5622
|
+
action: z6.enum(["created", "existing"]),
|
|
5623
|
+
updatedAt: z6.string()
|
|
5623
5624
|
});
|
|
5624
5625
|
var composesMainContract = c2.router({
|
|
5625
5626
|
/**
|
|
@@ -5630,9 +5631,10 @@ var composesMainContract = c2.router({
|
|
|
5630
5631
|
getByName: {
|
|
5631
5632
|
method: "GET",
|
|
5632
5633
|
path: "/api/agent/composes",
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5634
|
+
headers: authHeadersSchema,
|
|
5635
|
+
query: z6.object({
|
|
5636
|
+
name: z6.string().min(1, "Missing name query parameter"),
|
|
5637
|
+
scope: z6.string().optional()
|
|
5636
5638
|
}),
|
|
5637
5639
|
responses: {
|
|
5638
5640
|
200: composeResponseSchema,
|
|
@@ -5651,7 +5653,8 @@ var composesMainContract = c2.router({
|
|
|
5651
5653
|
create: {
|
|
5652
5654
|
method: "POST",
|
|
5653
5655
|
path: "/api/agent/composes",
|
|
5654
|
-
|
|
5656
|
+
headers: authHeadersSchema,
|
|
5657
|
+
body: z6.object({
|
|
5655
5658
|
content: agentComposeContentSchema
|
|
5656
5659
|
}),
|
|
5657
5660
|
responses: {
|
|
@@ -5671,8 +5674,9 @@ var composesByIdContract = c2.router({
|
|
|
5671
5674
|
getById: {
|
|
5672
5675
|
method: "GET",
|
|
5673
5676
|
path: "/api/agent/composes/:id",
|
|
5674
|
-
|
|
5675
|
-
|
|
5677
|
+
headers: authHeadersSchema,
|
|
5678
|
+
pathParams: z6.object({
|
|
5679
|
+
id: z6.string().min(1, "Compose ID is required")
|
|
5676
5680
|
}),
|
|
5677
5681
|
responses: {
|
|
5678
5682
|
200: composeResponseSchema,
|
|
@@ -5690,14 +5694,15 @@ var composesVersionsContract = c2.router({
|
|
|
5690
5694
|
resolveVersion: {
|
|
5691
5695
|
method: "GET",
|
|
5692
5696
|
path: "/api/agent/composes/versions",
|
|
5693
|
-
|
|
5694
|
-
|
|
5697
|
+
headers: authHeadersSchema,
|
|
5698
|
+
query: z6.object({
|
|
5699
|
+
composeId: z6.string().min(1, "Missing composeId query parameter"),
|
|
5695
5700
|
version: composeVersionQuerySchema
|
|
5696
5701
|
}),
|
|
5697
5702
|
responses: {
|
|
5698
|
-
200:
|
|
5699
|
-
versionId:
|
|
5700
|
-
tag:
|
|
5703
|
+
200: z6.object({
|
|
5704
|
+
versionId: z6.string(),
|
|
5705
|
+
tag: z6.string().optional()
|
|
5701
5706
|
}),
|
|
5702
5707
|
400: apiErrorSchema,
|
|
5703
5708
|
401: apiErrorSchema,
|
|
@@ -5706,10 +5711,10 @@ var composesVersionsContract = c2.router({
|
|
|
5706
5711
|
summary: "Resolve version specifier to full version ID"
|
|
5707
5712
|
}
|
|
5708
5713
|
});
|
|
5709
|
-
var composeListItemSchema =
|
|
5710
|
-
name:
|
|
5711
|
-
headVersionId:
|
|
5712
|
-
updatedAt:
|
|
5714
|
+
var composeListItemSchema = z6.object({
|
|
5715
|
+
name: z6.string(),
|
|
5716
|
+
headVersionId: z6.string().nullable(),
|
|
5717
|
+
updatedAt: z6.string()
|
|
5713
5718
|
});
|
|
5714
5719
|
var composesListContract = c2.router({
|
|
5715
5720
|
/**
|
|
@@ -5720,12 +5725,13 @@ var composesListContract = c2.router({
|
|
|
5720
5725
|
list: {
|
|
5721
5726
|
method: "GET",
|
|
5722
5727
|
path: "/api/agent/composes/list",
|
|
5723
|
-
|
|
5724
|
-
|
|
5728
|
+
headers: authHeadersSchema,
|
|
5729
|
+
query: z6.object({
|
|
5730
|
+
scope: z6.string().optional()
|
|
5725
5731
|
}),
|
|
5726
5732
|
responses: {
|
|
5727
|
-
200:
|
|
5728
|
-
composes:
|
|
5733
|
+
200: z6.object({
|
|
5734
|
+
composes: z6.array(composeListItemSchema)
|
|
5729
5735
|
}),
|
|
5730
5736
|
400: apiErrorSchema,
|
|
5731
5737
|
401: apiErrorSchema
|
|
@@ -5735,85 +5741,85 @@ var composesListContract = c2.router({
|
|
|
5735
5741
|
});
|
|
5736
5742
|
|
|
5737
5743
|
// ../../packages/core/src/contracts/runs.ts
|
|
5738
|
-
import { z as
|
|
5744
|
+
import { z as z7 } from "zod";
|
|
5739
5745
|
var c3 = initContract();
|
|
5740
|
-
var runStatusSchema =
|
|
5746
|
+
var runStatusSchema = z7.enum([
|
|
5741
5747
|
"pending",
|
|
5742
5748
|
"running",
|
|
5743
5749
|
"completed",
|
|
5744
5750
|
"failed",
|
|
5745
5751
|
"timeout"
|
|
5746
5752
|
]);
|
|
5747
|
-
var unifiedRunRequestSchema =
|
|
5753
|
+
var unifiedRunRequestSchema = z7.object({
|
|
5748
5754
|
// High-level shortcuts (mutually exclusive with each other)
|
|
5749
|
-
checkpointId:
|
|
5750
|
-
sessionId:
|
|
5755
|
+
checkpointId: z7.string().optional(),
|
|
5756
|
+
sessionId: z7.string().optional(),
|
|
5751
5757
|
// Base parameters (can be used directly or overridden after shortcut expansion)
|
|
5752
|
-
agentComposeId:
|
|
5753
|
-
agentComposeVersionId:
|
|
5754
|
-
conversationId:
|
|
5755
|
-
artifactName:
|
|
5756
|
-
artifactVersion:
|
|
5757
|
-
vars:
|
|
5758
|
-
secrets:
|
|
5759
|
-
volumeVersions:
|
|
5758
|
+
agentComposeId: z7.string().optional(),
|
|
5759
|
+
agentComposeVersionId: z7.string().optional(),
|
|
5760
|
+
conversationId: z7.string().optional(),
|
|
5761
|
+
artifactName: z7.string().optional(),
|
|
5762
|
+
artifactVersion: z7.string().optional(),
|
|
5763
|
+
vars: z7.record(z7.string(), z7.string()).optional(),
|
|
5764
|
+
secrets: z7.record(z7.string(), z7.string()).optional(),
|
|
5765
|
+
volumeVersions: z7.record(z7.string(), z7.string()).optional(),
|
|
5760
5766
|
// Debug flag to force real Claude in mock environments (internal use only)
|
|
5761
|
-
debugNoMockClaude:
|
|
5767
|
+
debugNoMockClaude: z7.boolean().optional(),
|
|
5762
5768
|
// Model provider for automatic credential injection
|
|
5763
|
-
modelProvider:
|
|
5769
|
+
modelProvider: z7.string().optional(),
|
|
5764
5770
|
// Required
|
|
5765
|
-
prompt:
|
|
5771
|
+
prompt: z7.string().min(1, "Missing prompt")
|
|
5766
5772
|
});
|
|
5767
|
-
var createRunResponseSchema =
|
|
5768
|
-
runId:
|
|
5773
|
+
var createRunResponseSchema = z7.object({
|
|
5774
|
+
runId: z7.string(),
|
|
5769
5775
|
status: runStatusSchema,
|
|
5770
|
-
sandboxId:
|
|
5771
|
-
output:
|
|
5772
|
-
error:
|
|
5773
|
-
executionTimeMs:
|
|
5774
|
-
createdAt:
|
|
5775
|
-
});
|
|
5776
|
-
var getRunResponseSchema =
|
|
5777
|
-
runId:
|
|
5778
|
-
agentComposeVersionId:
|
|
5776
|
+
sandboxId: z7.string().optional(),
|
|
5777
|
+
output: z7.string().optional(),
|
|
5778
|
+
error: z7.string().optional(),
|
|
5779
|
+
executionTimeMs: z7.number().optional(),
|
|
5780
|
+
createdAt: z7.string()
|
|
5781
|
+
});
|
|
5782
|
+
var getRunResponseSchema = z7.object({
|
|
5783
|
+
runId: z7.string(),
|
|
5784
|
+
agentComposeVersionId: z7.string(),
|
|
5779
5785
|
status: runStatusSchema,
|
|
5780
|
-
prompt:
|
|
5781
|
-
vars:
|
|
5782
|
-
sandboxId:
|
|
5783
|
-
result:
|
|
5784
|
-
output:
|
|
5785
|
-
executionTimeMs:
|
|
5786
|
+
prompt: z7.string(),
|
|
5787
|
+
vars: z7.record(z7.string(), z7.string()).optional(),
|
|
5788
|
+
sandboxId: z7.string().optional(),
|
|
5789
|
+
result: z7.object({
|
|
5790
|
+
output: z7.string(),
|
|
5791
|
+
executionTimeMs: z7.number()
|
|
5786
5792
|
}).optional(),
|
|
5787
|
-
error:
|
|
5788
|
-
createdAt:
|
|
5789
|
-
startedAt:
|
|
5790
|
-
completedAt:
|
|
5791
|
-
});
|
|
5792
|
-
var runEventSchema =
|
|
5793
|
-
sequenceNumber:
|
|
5794
|
-
eventType:
|
|
5795
|
-
eventData:
|
|
5796
|
-
createdAt:
|
|
5797
|
-
});
|
|
5798
|
-
var runResultSchema =
|
|
5799
|
-
checkpointId:
|
|
5800
|
-
agentSessionId:
|
|
5801
|
-
conversationId:
|
|
5802
|
-
artifact:
|
|
5793
|
+
error: z7.string().optional(),
|
|
5794
|
+
createdAt: z7.string(),
|
|
5795
|
+
startedAt: z7.string().optional(),
|
|
5796
|
+
completedAt: z7.string().optional()
|
|
5797
|
+
});
|
|
5798
|
+
var runEventSchema = z7.object({
|
|
5799
|
+
sequenceNumber: z7.number(),
|
|
5800
|
+
eventType: z7.string(),
|
|
5801
|
+
eventData: z7.unknown(),
|
|
5802
|
+
createdAt: z7.string()
|
|
5803
|
+
});
|
|
5804
|
+
var runResultSchema = z7.object({
|
|
5805
|
+
checkpointId: z7.string(),
|
|
5806
|
+
agentSessionId: z7.string(),
|
|
5807
|
+
conversationId: z7.string(),
|
|
5808
|
+
artifact: z7.record(z7.string(), z7.string()).optional(),
|
|
5803
5809
|
// optional when run has no artifact
|
|
5804
|
-
volumes:
|
|
5810
|
+
volumes: z7.record(z7.string(), z7.string()).optional()
|
|
5805
5811
|
});
|
|
5806
|
-
var runStateSchema =
|
|
5812
|
+
var runStateSchema = z7.object({
|
|
5807
5813
|
status: runStatusSchema,
|
|
5808
5814
|
result: runResultSchema.optional(),
|
|
5809
|
-
error:
|
|
5815
|
+
error: z7.string().optional()
|
|
5810
5816
|
});
|
|
5811
|
-
var eventsResponseSchema =
|
|
5812
|
-
events:
|
|
5813
|
-
hasMore:
|
|
5814
|
-
nextSequence:
|
|
5817
|
+
var eventsResponseSchema = z7.object({
|
|
5818
|
+
events: z7.array(runEventSchema),
|
|
5819
|
+
hasMore: z7.boolean(),
|
|
5820
|
+
nextSequence: z7.number(),
|
|
5815
5821
|
run: runStateSchema,
|
|
5816
|
-
framework:
|
|
5822
|
+
framework: z7.string()
|
|
5817
5823
|
});
|
|
5818
5824
|
var runsMainContract = c3.router({
|
|
5819
5825
|
/**
|
|
@@ -5823,6 +5829,7 @@ var runsMainContract = c3.router({
|
|
|
5823
5829
|
create: {
|
|
5824
5830
|
method: "POST",
|
|
5825
5831
|
path: "/api/agent/runs",
|
|
5832
|
+
headers: authHeadersSchema,
|
|
5826
5833
|
body: unifiedRunRequestSchema,
|
|
5827
5834
|
responses: {
|
|
5828
5835
|
201: createRunResponseSchema,
|
|
@@ -5841,8 +5848,9 @@ var runsByIdContract = c3.router({
|
|
|
5841
5848
|
getById: {
|
|
5842
5849
|
method: "GET",
|
|
5843
5850
|
path: "/api/agent/runs/:id",
|
|
5844
|
-
|
|
5845
|
-
|
|
5851
|
+
headers: authHeadersSchema,
|
|
5852
|
+
pathParams: z7.object({
|
|
5853
|
+
id: z7.string().min(1, "Run ID is required")
|
|
5846
5854
|
}),
|
|
5847
5855
|
responses: {
|
|
5848
5856
|
200: getRunResponseSchema,
|
|
@@ -5861,12 +5869,13 @@ var runEventsContract = c3.router({
|
|
|
5861
5869
|
getEvents: {
|
|
5862
5870
|
method: "GET",
|
|
5863
5871
|
path: "/api/agent/runs/:id/events",
|
|
5864
|
-
|
|
5865
|
-
|
|
5872
|
+
headers: authHeadersSchema,
|
|
5873
|
+
pathParams: z7.object({
|
|
5874
|
+
id: z7.string().min(1, "Run ID is required")
|
|
5866
5875
|
}),
|
|
5867
|
-
query:
|
|
5868
|
-
since:
|
|
5869
|
-
limit:
|
|
5876
|
+
query: z7.object({
|
|
5877
|
+
since: z7.coerce.number().default(-1),
|
|
5878
|
+
limit: z7.coerce.number().default(100)
|
|
5870
5879
|
}),
|
|
5871
5880
|
responses: {
|
|
5872
5881
|
200: eventsResponseSchema,
|
|
@@ -5876,50 +5885,50 @@ var runEventsContract = c3.router({
|
|
|
5876
5885
|
summary: "Get agent run events"
|
|
5877
5886
|
}
|
|
5878
5887
|
});
|
|
5879
|
-
var telemetryMetricSchema =
|
|
5880
|
-
ts:
|
|
5881
|
-
cpu:
|
|
5882
|
-
mem_used:
|
|
5883
|
-
mem_total:
|
|
5884
|
-
disk_used:
|
|
5885
|
-
disk_total:
|
|
5888
|
+
var telemetryMetricSchema = z7.object({
|
|
5889
|
+
ts: z7.string(),
|
|
5890
|
+
cpu: z7.number(),
|
|
5891
|
+
mem_used: z7.number(),
|
|
5892
|
+
mem_total: z7.number(),
|
|
5893
|
+
disk_used: z7.number(),
|
|
5894
|
+
disk_total: z7.number()
|
|
5886
5895
|
});
|
|
5887
|
-
var systemLogResponseSchema =
|
|
5888
|
-
systemLog:
|
|
5889
|
-
hasMore:
|
|
5896
|
+
var systemLogResponseSchema = z7.object({
|
|
5897
|
+
systemLog: z7.string(),
|
|
5898
|
+
hasMore: z7.boolean()
|
|
5890
5899
|
});
|
|
5891
|
-
var metricsResponseSchema =
|
|
5892
|
-
metrics:
|
|
5893
|
-
hasMore:
|
|
5900
|
+
var metricsResponseSchema = z7.object({
|
|
5901
|
+
metrics: z7.array(telemetryMetricSchema),
|
|
5902
|
+
hasMore: z7.boolean()
|
|
5894
5903
|
});
|
|
5895
|
-
var agentEventsResponseSchema =
|
|
5896
|
-
events:
|
|
5897
|
-
hasMore:
|
|
5898
|
-
framework:
|
|
5904
|
+
var agentEventsResponseSchema = z7.object({
|
|
5905
|
+
events: z7.array(runEventSchema),
|
|
5906
|
+
hasMore: z7.boolean(),
|
|
5907
|
+
framework: z7.string()
|
|
5899
5908
|
});
|
|
5900
|
-
var networkLogEntrySchema =
|
|
5901
|
-
timestamp:
|
|
5909
|
+
var networkLogEntrySchema = z7.object({
|
|
5910
|
+
timestamp: z7.string(),
|
|
5902
5911
|
// Common fields (all modes)
|
|
5903
|
-
mode:
|
|
5904
|
-
action:
|
|
5905
|
-
host:
|
|
5906
|
-
port:
|
|
5907
|
-
rule_matched:
|
|
5912
|
+
mode: z7.enum(["mitm", "sni"]).optional(),
|
|
5913
|
+
action: z7.enum(["ALLOW", "DENY"]).optional(),
|
|
5914
|
+
host: z7.string().optional(),
|
|
5915
|
+
port: z7.number().optional(),
|
|
5916
|
+
rule_matched: z7.string().nullable().optional(),
|
|
5908
5917
|
// MITM-only fields (optional)
|
|
5909
|
-
method:
|
|
5910
|
-
url:
|
|
5911
|
-
status:
|
|
5912
|
-
latency_ms:
|
|
5913
|
-
request_size:
|
|
5914
|
-
response_size:
|
|
5918
|
+
method: z7.string().optional(),
|
|
5919
|
+
url: z7.string().optional(),
|
|
5920
|
+
status: z7.number().optional(),
|
|
5921
|
+
latency_ms: z7.number().optional(),
|
|
5922
|
+
request_size: z7.number().optional(),
|
|
5923
|
+
response_size: z7.number().optional()
|
|
5915
5924
|
});
|
|
5916
|
-
var networkLogsResponseSchema =
|
|
5917
|
-
networkLogs:
|
|
5918
|
-
hasMore:
|
|
5925
|
+
var networkLogsResponseSchema = z7.object({
|
|
5926
|
+
networkLogs: z7.array(networkLogEntrySchema),
|
|
5927
|
+
hasMore: z7.boolean()
|
|
5919
5928
|
});
|
|
5920
|
-
var telemetryResponseSchema =
|
|
5921
|
-
systemLog:
|
|
5922
|
-
metrics:
|
|
5929
|
+
var telemetryResponseSchema = z7.object({
|
|
5930
|
+
systemLog: z7.string(),
|
|
5931
|
+
metrics: z7.array(telemetryMetricSchema)
|
|
5923
5932
|
});
|
|
5924
5933
|
var runTelemetryContract = c3.router({
|
|
5925
5934
|
/**
|
|
@@ -5929,8 +5938,9 @@ var runTelemetryContract = c3.router({
|
|
|
5929
5938
|
getTelemetry: {
|
|
5930
5939
|
method: "GET",
|
|
5931
5940
|
path: "/api/agent/runs/:id/telemetry",
|
|
5932
|
-
|
|
5933
|
-
|
|
5941
|
+
headers: authHeadersSchema,
|
|
5942
|
+
pathParams: z7.object({
|
|
5943
|
+
id: z7.string().min(1, "Run ID is required")
|
|
5934
5944
|
}),
|
|
5935
5945
|
responses: {
|
|
5936
5946
|
200: telemetryResponseSchema,
|
|
@@ -5948,13 +5958,14 @@ var runSystemLogContract = c3.router({
|
|
|
5948
5958
|
getSystemLog: {
|
|
5949
5959
|
method: "GET",
|
|
5950
5960
|
path: "/api/agent/runs/:id/telemetry/system-log",
|
|
5951
|
-
|
|
5952
|
-
|
|
5961
|
+
headers: authHeadersSchema,
|
|
5962
|
+
pathParams: z7.object({
|
|
5963
|
+
id: z7.string().min(1, "Run ID is required")
|
|
5953
5964
|
}),
|
|
5954
|
-
query:
|
|
5955
|
-
since:
|
|
5956
|
-
limit:
|
|
5957
|
-
order:
|
|
5965
|
+
query: z7.object({
|
|
5966
|
+
since: z7.coerce.number().optional(),
|
|
5967
|
+
limit: z7.coerce.number().min(1).max(100).default(5),
|
|
5968
|
+
order: z7.enum(["asc", "desc"]).default("desc")
|
|
5958
5969
|
}),
|
|
5959
5970
|
responses: {
|
|
5960
5971
|
200: systemLogResponseSchema,
|
|
@@ -5972,13 +5983,14 @@ var runMetricsContract = c3.router({
|
|
|
5972
5983
|
getMetrics: {
|
|
5973
5984
|
method: "GET",
|
|
5974
5985
|
path: "/api/agent/runs/:id/telemetry/metrics",
|
|
5975
|
-
|
|
5976
|
-
|
|
5986
|
+
headers: authHeadersSchema,
|
|
5987
|
+
pathParams: z7.object({
|
|
5988
|
+
id: z7.string().min(1, "Run ID is required")
|
|
5977
5989
|
}),
|
|
5978
|
-
query:
|
|
5979
|
-
since:
|
|
5980
|
-
limit:
|
|
5981
|
-
order:
|
|
5990
|
+
query: z7.object({
|
|
5991
|
+
since: z7.coerce.number().optional(),
|
|
5992
|
+
limit: z7.coerce.number().min(1).max(100).default(5),
|
|
5993
|
+
order: z7.enum(["asc", "desc"]).default("desc")
|
|
5982
5994
|
}),
|
|
5983
5995
|
responses: {
|
|
5984
5996
|
200: metricsResponseSchema,
|
|
@@ -5996,13 +6008,14 @@ var runAgentEventsContract = c3.router({
|
|
|
5996
6008
|
getAgentEvents: {
|
|
5997
6009
|
method: "GET",
|
|
5998
6010
|
path: "/api/agent/runs/:id/telemetry/agent",
|
|
5999
|
-
|
|
6000
|
-
|
|
6011
|
+
headers: authHeadersSchema,
|
|
6012
|
+
pathParams: z7.object({
|
|
6013
|
+
id: z7.string().min(1, "Run ID is required")
|
|
6001
6014
|
}),
|
|
6002
|
-
query:
|
|
6003
|
-
since:
|
|
6004
|
-
limit:
|
|
6005
|
-
order:
|
|
6015
|
+
query: z7.object({
|
|
6016
|
+
since: z7.coerce.number().optional(),
|
|
6017
|
+
limit: z7.coerce.number().min(1).max(100).default(5),
|
|
6018
|
+
order: z7.enum(["asc", "desc"]).default("desc")
|
|
6006
6019
|
}),
|
|
6007
6020
|
responses: {
|
|
6008
6021
|
200: agentEventsResponseSchema,
|
|
@@ -6020,13 +6033,14 @@ var runNetworkLogsContract = c3.router({
|
|
|
6020
6033
|
getNetworkLogs: {
|
|
6021
6034
|
method: "GET",
|
|
6022
6035
|
path: "/api/agent/runs/:id/telemetry/network",
|
|
6023
|
-
|
|
6024
|
-
|
|
6036
|
+
headers: authHeadersSchema,
|
|
6037
|
+
pathParams: z7.object({
|
|
6038
|
+
id: z7.string().min(1, "Run ID is required")
|
|
6025
6039
|
}),
|
|
6026
|
-
query:
|
|
6027
|
-
since:
|
|
6028
|
-
limit:
|
|
6029
|
-
order:
|
|
6040
|
+
query: z7.object({
|
|
6041
|
+
since: z7.coerce.number().optional(),
|
|
6042
|
+
limit: z7.coerce.number().min(1).max(100).default(5),
|
|
6043
|
+
order: z7.enum(["asc", "desc"]).default("desc")
|
|
6030
6044
|
}),
|
|
6031
6045
|
responses: {
|
|
6032
6046
|
200: networkLogsResponseSchema,
|
|
@@ -6038,20 +6052,20 @@ var runNetworkLogsContract = c3.router({
|
|
|
6038
6052
|
});
|
|
6039
6053
|
|
|
6040
6054
|
// ../../packages/core/src/contracts/storages.ts
|
|
6041
|
-
import { z as
|
|
6055
|
+
import { z as z8 } from "zod";
|
|
6042
6056
|
var c4 = initContract();
|
|
6043
|
-
var storageTypeSchema =
|
|
6044
|
-
var versionQuerySchema =
|
|
6057
|
+
var storageTypeSchema = z8.enum(["volume", "artifact"]);
|
|
6058
|
+
var versionQuerySchema = z8.preprocess(
|
|
6045
6059
|
(val) => val === void 0 || val === null ? void 0 : String(val),
|
|
6046
|
-
|
|
6060
|
+
z8.string().regex(/^[a-f0-9]{8,64}$/i, "Version must be 8-64 hex characters").optional()
|
|
6047
6061
|
);
|
|
6048
|
-
var uploadStorageResponseSchema =
|
|
6049
|
-
name:
|
|
6050
|
-
versionId:
|
|
6051
|
-
size:
|
|
6052
|
-
fileCount:
|
|
6062
|
+
var uploadStorageResponseSchema = z8.object({
|
|
6063
|
+
name: z8.string(),
|
|
6064
|
+
versionId: z8.string(),
|
|
6065
|
+
size: z8.number(),
|
|
6066
|
+
fileCount: z8.number(),
|
|
6053
6067
|
type: storageTypeSchema,
|
|
6054
|
-
deduplicated:
|
|
6068
|
+
deduplicated: z8.boolean()
|
|
6055
6069
|
});
|
|
6056
6070
|
var storagesContract = c4.router({
|
|
6057
6071
|
/**
|
|
@@ -6068,6 +6082,7 @@ var storagesContract = c4.router({
|
|
|
6068
6082
|
upload: {
|
|
6069
6083
|
method: "POST",
|
|
6070
6084
|
path: "/api/storages",
|
|
6085
|
+
headers: authHeadersSchema,
|
|
6071
6086
|
contentType: "multipart/form-data",
|
|
6072
6087
|
body: c4.type(),
|
|
6073
6088
|
responses: {
|
|
@@ -6091,8 +6106,9 @@ var storagesContract = c4.router({
|
|
|
6091
6106
|
download: {
|
|
6092
6107
|
method: "GET",
|
|
6093
6108
|
path: "/api/storages",
|
|
6094
|
-
|
|
6095
|
-
|
|
6109
|
+
headers: authHeadersSchema,
|
|
6110
|
+
query: z8.object({
|
|
6111
|
+
name: z8.string().min(1, "Storage name is required"),
|
|
6096
6112
|
version: versionQuerySchema
|
|
6097
6113
|
}),
|
|
6098
6114
|
responses: {
|
|
@@ -6109,40 +6125,41 @@ var storagesContract = c4.router({
|
|
|
6109
6125
|
summary: "Download storage archive"
|
|
6110
6126
|
}
|
|
6111
6127
|
});
|
|
6112
|
-
var fileEntryWithHashSchema =
|
|
6113
|
-
path:
|
|
6114
|
-
hash:
|
|
6115
|
-
size:
|
|
6128
|
+
var fileEntryWithHashSchema = z8.object({
|
|
6129
|
+
path: z8.string().min(1, "File path is required"),
|
|
6130
|
+
hash: z8.string().length(64, "Hash must be SHA-256 (64 hex chars)"),
|
|
6131
|
+
size: z8.number().int().min(0, "Size must be non-negative")
|
|
6116
6132
|
});
|
|
6117
|
-
var storageChangesSchema =
|
|
6118
|
-
added:
|
|
6119
|
-
modified:
|
|
6120
|
-
deleted:
|
|
6133
|
+
var storageChangesSchema = z8.object({
|
|
6134
|
+
added: z8.array(z8.string()),
|
|
6135
|
+
modified: z8.array(z8.string()),
|
|
6136
|
+
deleted: z8.array(z8.string())
|
|
6121
6137
|
});
|
|
6122
|
-
var presignedUploadSchema =
|
|
6123
|
-
key:
|
|
6124
|
-
presignedUrl:
|
|
6138
|
+
var presignedUploadSchema = z8.object({
|
|
6139
|
+
key: z8.string(),
|
|
6140
|
+
presignedUrl: z8.string().url()
|
|
6125
6141
|
});
|
|
6126
6142
|
var storagesPrepareContract = c4.router({
|
|
6127
6143
|
prepare: {
|
|
6128
6144
|
method: "POST",
|
|
6129
6145
|
path: "/api/storages/prepare",
|
|
6130
|
-
|
|
6131
|
-
|
|
6146
|
+
headers: authHeadersSchema,
|
|
6147
|
+
body: z8.object({
|
|
6148
|
+
storageName: z8.string().min(1, "Storage name is required"),
|
|
6132
6149
|
storageType: storageTypeSchema,
|
|
6133
|
-
files:
|
|
6134
|
-
force:
|
|
6135
|
-
runId:
|
|
6150
|
+
files: z8.array(fileEntryWithHashSchema),
|
|
6151
|
+
force: z8.boolean().optional(),
|
|
6152
|
+
runId: z8.string().optional(),
|
|
6136
6153
|
// For sandbox auth
|
|
6137
|
-
baseVersion:
|
|
6154
|
+
baseVersion: z8.string().optional(),
|
|
6138
6155
|
// For incremental uploads
|
|
6139
6156
|
changes: storageChangesSchema.optional()
|
|
6140
6157
|
}),
|
|
6141
6158
|
responses: {
|
|
6142
|
-
200:
|
|
6143
|
-
versionId:
|
|
6144
|
-
existing:
|
|
6145
|
-
uploads:
|
|
6159
|
+
200: z8.object({
|
|
6160
|
+
versionId: z8.string(),
|
|
6161
|
+
existing: z8.boolean(),
|
|
6162
|
+
uploads: z8.object({
|
|
6146
6163
|
archive: presignedUploadSchema,
|
|
6147
6164
|
manifest: presignedUploadSchema
|
|
6148
6165
|
}).optional()
|
|
@@ -6159,22 +6176,23 @@ var storagesCommitContract = c4.router({
|
|
|
6159
6176
|
commit: {
|
|
6160
6177
|
method: "POST",
|
|
6161
6178
|
path: "/api/storages/commit",
|
|
6162
|
-
|
|
6163
|
-
|
|
6179
|
+
headers: authHeadersSchema,
|
|
6180
|
+
body: z8.object({
|
|
6181
|
+
storageName: z8.string().min(1, "Storage name is required"),
|
|
6164
6182
|
storageType: storageTypeSchema,
|
|
6165
|
-
versionId:
|
|
6166
|
-
files:
|
|
6167
|
-
runId:
|
|
6168
|
-
message:
|
|
6183
|
+
versionId: z8.string().min(1, "Version ID is required"),
|
|
6184
|
+
files: z8.array(fileEntryWithHashSchema),
|
|
6185
|
+
runId: z8.string().optional(),
|
|
6186
|
+
message: z8.string().optional()
|
|
6169
6187
|
}),
|
|
6170
6188
|
responses: {
|
|
6171
|
-
200:
|
|
6172
|
-
success:
|
|
6173
|
-
versionId:
|
|
6174
|
-
storageName:
|
|
6175
|
-
size:
|
|
6176
|
-
fileCount:
|
|
6177
|
-
deduplicated:
|
|
6189
|
+
200: z8.object({
|
|
6190
|
+
success: z8.literal(true),
|
|
6191
|
+
versionId: z8.string(),
|
|
6192
|
+
storageName: z8.string(),
|
|
6193
|
+
size: z8.number(),
|
|
6194
|
+
fileCount: z8.number(),
|
|
6195
|
+
deduplicated: z8.boolean().optional()
|
|
6178
6196
|
}),
|
|
6179
6197
|
400: apiErrorSchema,
|
|
6180
6198
|
401: apiErrorSchema,
|
|
@@ -6190,26 +6208,27 @@ var storagesDownloadContract = c4.router({
|
|
|
6190
6208
|
download: {
|
|
6191
6209
|
method: "GET",
|
|
6192
6210
|
path: "/api/storages/download",
|
|
6193
|
-
|
|
6194
|
-
|
|
6211
|
+
headers: authHeadersSchema,
|
|
6212
|
+
query: z8.object({
|
|
6213
|
+
name: z8.string().min(1, "Storage name is required"),
|
|
6195
6214
|
type: storageTypeSchema,
|
|
6196
6215
|
version: versionQuerySchema
|
|
6197
6216
|
}),
|
|
6198
6217
|
responses: {
|
|
6199
6218
|
// Normal response with presigned URL
|
|
6200
|
-
200:
|
|
6201
|
-
|
|
6202
|
-
url:
|
|
6203
|
-
versionId:
|
|
6204
|
-
fileCount:
|
|
6205
|
-
size:
|
|
6219
|
+
200: z8.union([
|
|
6220
|
+
z8.object({
|
|
6221
|
+
url: z8.string().url(),
|
|
6222
|
+
versionId: z8.string(),
|
|
6223
|
+
fileCount: z8.number(),
|
|
6224
|
+
size: z8.number()
|
|
6206
6225
|
}),
|
|
6207
6226
|
// Empty artifact response
|
|
6208
|
-
|
|
6209
|
-
empty:
|
|
6210
|
-
versionId:
|
|
6211
|
-
fileCount:
|
|
6212
|
-
size:
|
|
6227
|
+
z8.object({
|
|
6228
|
+
empty: z8.literal(true),
|
|
6229
|
+
versionId: z8.string(),
|
|
6230
|
+
fileCount: z8.literal(0),
|
|
6231
|
+
size: z8.literal(0)
|
|
6213
6232
|
})
|
|
6214
6233
|
]),
|
|
6215
6234
|
400: apiErrorSchema,
|
|
@@ -6224,16 +6243,17 @@ var storagesListContract = c4.router({
|
|
|
6224
6243
|
list: {
|
|
6225
6244
|
method: "GET",
|
|
6226
6245
|
path: "/api/storages/list",
|
|
6227
|
-
|
|
6246
|
+
headers: authHeadersSchema,
|
|
6247
|
+
query: z8.object({
|
|
6228
6248
|
type: storageTypeSchema
|
|
6229
6249
|
}),
|
|
6230
6250
|
responses: {
|
|
6231
|
-
200:
|
|
6232
|
-
|
|
6233
|
-
name:
|
|
6234
|
-
size:
|
|
6235
|
-
fileCount:
|
|
6236
|
-
updatedAt:
|
|
6251
|
+
200: z8.array(
|
|
6252
|
+
z8.object({
|
|
6253
|
+
name: z8.string(),
|
|
6254
|
+
size: z8.number(),
|
|
6255
|
+
fileCount: z8.number(),
|
|
6256
|
+
updatedAt: z8.string()
|
|
6237
6257
|
})
|
|
6238
6258
|
),
|
|
6239
6259
|
401: apiErrorSchema,
|
|
@@ -6244,18 +6264,18 @@ var storagesListContract = c4.router({
|
|
|
6244
6264
|
});
|
|
6245
6265
|
|
|
6246
6266
|
// ../../packages/core/src/contracts/webhooks.ts
|
|
6247
|
-
import { z as
|
|
6267
|
+
import { z as z9 } from "zod";
|
|
6248
6268
|
var c5 = initContract();
|
|
6249
|
-
var agentEventSchema =
|
|
6250
|
-
type:
|
|
6251
|
-
sequenceNumber:
|
|
6269
|
+
var agentEventSchema = z9.object({
|
|
6270
|
+
type: z9.string(),
|
|
6271
|
+
sequenceNumber: z9.number().int().nonnegative()
|
|
6252
6272
|
}).passthrough();
|
|
6253
|
-
var artifactSnapshotSchema =
|
|
6254
|
-
artifactName:
|
|
6255
|
-
artifactVersion:
|
|
6273
|
+
var artifactSnapshotSchema = z9.object({
|
|
6274
|
+
artifactName: z9.string(),
|
|
6275
|
+
artifactVersion: z9.string()
|
|
6256
6276
|
});
|
|
6257
|
-
var volumeVersionsSnapshotSchema =
|
|
6258
|
-
versions:
|
|
6277
|
+
var volumeVersionsSnapshotSchema = z9.object({
|
|
6278
|
+
versions: z9.record(z9.string(), z9.string())
|
|
6259
6279
|
});
|
|
6260
6280
|
var webhookEventsContract = c5.router({
|
|
6261
6281
|
/**
|
|
@@ -6265,15 +6285,16 @@ var webhookEventsContract = c5.router({
|
|
|
6265
6285
|
send: {
|
|
6266
6286
|
method: "POST",
|
|
6267
6287
|
path: "/api/webhooks/agent/events",
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6288
|
+
headers: authHeadersSchema,
|
|
6289
|
+
body: z9.object({
|
|
6290
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6291
|
+
events: z9.array(agentEventSchema).min(1, "events array cannot be empty")
|
|
6271
6292
|
}),
|
|
6272
6293
|
responses: {
|
|
6273
|
-
200:
|
|
6274
|
-
received:
|
|
6275
|
-
firstSequence:
|
|
6276
|
-
lastSequence:
|
|
6294
|
+
200: z9.object({
|
|
6295
|
+
received: z9.number(),
|
|
6296
|
+
firstSequence: z9.number(),
|
|
6297
|
+
lastSequence: z9.number()
|
|
6277
6298
|
}),
|
|
6278
6299
|
400: apiErrorSchema,
|
|
6279
6300
|
401: apiErrorSchema,
|
|
@@ -6291,15 +6312,16 @@ var webhookCompleteContract = c5.router({
|
|
|
6291
6312
|
complete: {
|
|
6292
6313
|
method: "POST",
|
|
6293
6314
|
path: "/api/webhooks/agent/complete",
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6315
|
+
headers: authHeadersSchema,
|
|
6316
|
+
body: z9.object({
|
|
6317
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6318
|
+
exitCode: z9.number(),
|
|
6319
|
+
error: z9.string().optional()
|
|
6298
6320
|
}),
|
|
6299
6321
|
responses: {
|
|
6300
|
-
200:
|
|
6301
|
-
success:
|
|
6302
|
-
status:
|
|
6322
|
+
200: z9.object({
|
|
6323
|
+
success: z9.boolean(),
|
|
6324
|
+
status: z9.enum(["completed", "failed"])
|
|
6303
6325
|
}),
|
|
6304
6326
|
400: apiErrorSchema,
|
|
6305
6327
|
401: apiErrorSchema,
|
|
@@ -6317,21 +6339,22 @@ var webhookCheckpointsContract = c5.router({
|
|
|
6317
6339
|
create: {
|
|
6318
6340
|
method: "POST",
|
|
6319
6341
|
path: "/api/webhooks/agent/checkpoints",
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6342
|
+
headers: authHeadersSchema,
|
|
6343
|
+
body: z9.object({
|
|
6344
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6345
|
+
cliAgentType: z9.string().min(1, "cliAgentType is required"),
|
|
6346
|
+
cliAgentSessionId: z9.string().min(1, "cliAgentSessionId is required"),
|
|
6347
|
+
cliAgentSessionHistory: z9.string().min(1, "cliAgentSessionHistory is required"),
|
|
6325
6348
|
artifactSnapshot: artifactSnapshotSchema.optional(),
|
|
6326
6349
|
volumeVersionsSnapshot: volumeVersionsSnapshotSchema.optional()
|
|
6327
6350
|
}),
|
|
6328
6351
|
responses: {
|
|
6329
|
-
200:
|
|
6330
|
-
checkpointId:
|
|
6331
|
-
agentSessionId:
|
|
6332
|
-
conversationId:
|
|
6352
|
+
200: z9.object({
|
|
6353
|
+
checkpointId: z9.string(),
|
|
6354
|
+
agentSessionId: z9.string(),
|
|
6355
|
+
conversationId: z9.string(),
|
|
6333
6356
|
artifact: artifactSnapshotSchema.optional(),
|
|
6334
|
-
volumes:
|
|
6357
|
+
volumes: z9.record(z9.string(), z9.string()).optional()
|
|
6335
6358
|
}),
|
|
6336
6359
|
400: apiErrorSchema,
|
|
6337
6360
|
401: apiErrorSchema,
|
|
@@ -6349,12 +6372,13 @@ var webhookHeartbeatContract = c5.router({
|
|
|
6349
6372
|
send: {
|
|
6350
6373
|
method: "POST",
|
|
6351
6374
|
path: "/api/webhooks/agent/heartbeat",
|
|
6352
|
-
|
|
6353
|
-
|
|
6375
|
+
headers: authHeadersSchema,
|
|
6376
|
+
body: z9.object({
|
|
6377
|
+
runId: z9.string().min(1, "runId is required")
|
|
6354
6378
|
}),
|
|
6355
6379
|
responses: {
|
|
6356
|
-
200:
|
|
6357
|
-
ok:
|
|
6380
|
+
200: z9.object({
|
|
6381
|
+
ok: z9.boolean()
|
|
6358
6382
|
}),
|
|
6359
6383
|
400: apiErrorSchema,
|
|
6360
6384
|
401: apiErrorSchema,
|
|
@@ -6378,14 +6402,15 @@ var webhookStoragesContract = c5.router({
|
|
|
6378
6402
|
upload: {
|
|
6379
6403
|
method: "POST",
|
|
6380
6404
|
path: "/api/webhooks/agent/storages",
|
|
6405
|
+
headers: authHeadersSchema,
|
|
6381
6406
|
contentType: "multipart/form-data",
|
|
6382
6407
|
body: c5.type(),
|
|
6383
6408
|
responses: {
|
|
6384
|
-
200:
|
|
6385
|
-
versionId:
|
|
6386
|
-
storageName:
|
|
6387
|
-
size:
|
|
6388
|
-
fileCount:
|
|
6409
|
+
200: z9.object({
|
|
6410
|
+
versionId: z9.string(),
|
|
6411
|
+
storageName: z9.string(),
|
|
6412
|
+
size: z9.number(),
|
|
6413
|
+
fileCount: z9.number()
|
|
6389
6414
|
}),
|
|
6390
6415
|
400: apiErrorSchema,
|
|
6391
6416
|
401: apiErrorSchema,
|
|
@@ -6411,20 +6436,21 @@ var webhookStoragesIncrementalContract = c5.router({
|
|
|
6411
6436
|
upload: {
|
|
6412
6437
|
method: "POST",
|
|
6413
6438
|
path: "/api/webhooks/agent/storages/incremental",
|
|
6439
|
+
headers: authHeadersSchema,
|
|
6414
6440
|
contentType: "multipart/form-data",
|
|
6415
6441
|
body: c5.type(),
|
|
6416
6442
|
responses: {
|
|
6417
|
-
200:
|
|
6418
|
-
versionId:
|
|
6419
|
-
storageName:
|
|
6420
|
-
size:
|
|
6421
|
-
fileCount:
|
|
6422
|
-
incrementalStats:
|
|
6423
|
-
addedFiles:
|
|
6424
|
-
modifiedFiles:
|
|
6425
|
-
deletedFiles:
|
|
6426
|
-
unchangedFiles:
|
|
6427
|
-
bytesUploaded:
|
|
6443
|
+
200: z9.object({
|
|
6444
|
+
versionId: z9.string(),
|
|
6445
|
+
storageName: z9.string(),
|
|
6446
|
+
size: z9.number(),
|
|
6447
|
+
fileCount: z9.number(),
|
|
6448
|
+
incrementalStats: z9.object({
|
|
6449
|
+
addedFiles: z9.number(),
|
|
6450
|
+
modifiedFiles: z9.number(),
|
|
6451
|
+
deletedFiles: z9.number(),
|
|
6452
|
+
unchangedFiles: z9.number(),
|
|
6453
|
+
bytesUploaded: z9.number()
|
|
6428
6454
|
}).optional()
|
|
6429
6455
|
}),
|
|
6430
6456
|
400: apiErrorSchema,
|
|
@@ -6435,36 +6461,36 @@ var webhookStoragesIncrementalContract = c5.router({
|
|
|
6435
6461
|
summary: "Upload storage version incrementally from sandbox"
|
|
6436
6462
|
}
|
|
6437
6463
|
});
|
|
6438
|
-
var metricDataSchema =
|
|
6439
|
-
ts:
|
|
6440
|
-
cpu:
|
|
6441
|
-
mem_used:
|
|
6442
|
-
mem_total:
|
|
6443
|
-
disk_used:
|
|
6444
|
-
disk_total:
|
|
6464
|
+
var metricDataSchema = z9.object({
|
|
6465
|
+
ts: z9.string(),
|
|
6466
|
+
cpu: z9.number(),
|
|
6467
|
+
mem_used: z9.number(),
|
|
6468
|
+
mem_total: z9.number(),
|
|
6469
|
+
disk_used: z9.number(),
|
|
6470
|
+
disk_total: z9.number()
|
|
6445
6471
|
});
|
|
6446
|
-
var sandboxOperationSchema =
|
|
6447
|
-
ts:
|
|
6448
|
-
action_type:
|
|
6449
|
-
duration_ms:
|
|
6450
|
-
success:
|
|
6451
|
-
error:
|
|
6472
|
+
var sandboxOperationSchema = z9.object({
|
|
6473
|
+
ts: z9.string(),
|
|
6474
|
+
action_type: z9.string(),
|
|
6475
|
+
duration_ms: z9.number(),
|
|
6476
|
+
success: z9.boolean(),
|
|
6477
|
+
error: z9.string().optional()
|
|
6452
6478
|
});
|
|
6453
|
-
var networkLogSchema =
|
|
6454
|
-
timestamp:
|
|
6479
|
+
var networkLogSchema = z9.object({
|
|
6480
|
+
timestamp: z9.string(),
|
|
6455
6481
|
// Common fields (all modes)
|
|
6456
|
-
mode:
|
|
6457
|
-
action:
|
|
6458
|
-
host:
|
|
6459
|
-
port:
|
|
6460
|
-
rule_matched:
|
|
6482
|
+
mode: z9.enum(["mitm", "sni"]).optional(),
|
|
6483
|
+
action: z9.enum(["ALLOW", "DENY"]).optional(),
|
|
6484
|
+
host: z9.string().optional(),
|
|
6485
|
+
port: z9.number().optional(),
|
|
6486
|
+
rule_matched: z9.string().nullable().optional(),
|
|
6461
6487
|
// MITM-only fields (optional)
|
|
6462
|
-
method:
|
|
6463
|
-
url:
|
|
6464
|
-
status:
|
|
6465
|
-
latency_ms:
|
|
6466
|
-
request_size:
|
|
6467
|
-
response_size:
|
|
6488
|
+
method: z9.string().optional(),
|
|
6489
|
+
url: z9.string().optional(),
|
|
6490
|
+
status: z9.number().optional(),
|
|
6491
|
+
latency_ms: z9.number().optional(),
|
|
6492
|
+
request_size: z9.number().optional(),
|
|
6493
|
+
response_size: z9.number().optional()
|
|
6468
6494
|
});
|
|
6469
6495
|
var webhookTelemetryContract = c5.router({
|
|
6470
6496
|
/**
|
|
@@ -6474,17 +6500,18 @@ var webhookTelemetryContract = c5.router({
|
|
|
6474
6500
|
send: {
|
|
6475
6501
|
method: "POST",
|
|
6476
6502
|
path: "/api/webhooks/agent/telemetry",
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6503
|
+
headers: authHeadersSchema,
|
|
6504
|
+
body: z9.object({
|
|
6505
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6506
|
+
systemLog: z9.string().optional(),
|
|
6507
|
+
metrics: z9.array(metricDataSchema).optional(),
|
|
6508
|
+
networkLogs: z9.array(networkLogSchema).optional(),
|
|
6509
|
+
sandboxOperations: z9.array(sandboxOperationSchema).optional()
|
|
6483
6510
|
}),
|
|
6484
6511
|
responses: {
|
|
6485
|
-
200:
|
|
6486
|
-
success:
|
|
6487
|
-
id:
|
|
6512
|
+
200: z9.object({
|
|
6513
|
+
success: z9.boolean(),
|
|
6514
|
+
id: z9.string()
|
|
6488
6515
|
}),
|
|
6489
6516
|
400: apiErrorSchema,
|
|
6490
6517
|
401: apiErrorSchema,
|
|
@@ -6498,21 +6525,22 @@ var webhookStoragesPrepareContract = c5.router({
|
|
|
6498
6525
|
prepare: {
|
|
6499
6526
|
method: "POST",
|
|
6500
6527
|
path: "/api/webhooks/agent/storages/prepare",
|
|
6501
|
-
|
|
6502
|
-
|
|
6528
|
+
headers: authHeadersSchema,
|
|
6529
|
+
body: z9.object({
|
|
6530
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6503
6531
|
// Required for webhook auth
|
|
6504
|
-
storageName:
|
|
6532
|
+
storageName: z9.string().min(1, "Storage name is required"),
|
|
6505
6533
|
storageType: storageTypeSchema,
|
|
6506
|
-
files:
|
|
6507
|
-
force:
|
|
6508
|
-
baseVersion:
|
|
6534
|
+
files: z9.array(fileEntryWithHashSchema),
|
|
6535
|
+
force: z9.boolean().optional(),
|
|
6536
|
+
baseVersion: z9.string().optional(),
|
|
6509
6537
|
changes: storageChangesSchema.optional()
|
|
6510
6538
|
}),
|
|
6511
6539
|
responses: {
|
|
6512
|
-
200:
|
|
6513
|
-
versionId:
|
|
6514
|
-
existing:
|
|
6515
|
-
uploads:
|
|
6540
|
+
200: z9.object({
|
|
6541
|
+
versionId: z9.string(),
|
|
6542
|
+
existing: z9.boolean(),
|
|
6543
|
+
uploads: z9.object({
|
|
6516
6544
|
archive: presignedUploadSchema,
|
|
6517
6545
|
manifest: presignedUploadSchema
|
|
6518
6546
|
}).optional()
|
|
@@ -6529,23 +6557,24 @@ var webhookStoragesCommitContract = c5.router({
|
|
|
6529
6557
|
commit: {
|
|
6530
6558
|
method: "POST",
|
|
6531
6559
|
path: "/api/webhooks/agent/storages/commit",
|
|
6532
|
-
|
|
6533
|
-
|
|
6560
|
+
headers: authHeadersSchema,
|
|
6561
|
+
body: z9.object({
|
|
6562
|
+
runId: z9.string().min(1, "runId is required"),
|
|
6534
6563
|
// Required for webhook auth
|
|
6535
|
-
storageName:
|
|
6564
|
+
storageName: z9.string().min(1, "Storage name is required"),
|
|
6536
6565
|
storageType: storageTypeSchema,
|
|
6537
|
-
versionId:
|
|
6538
|
-
files:
|
|
6539
|
-
message:
|
|
6566
|
+
versionId: z9.string().min(1, "Version ID is required"),
|
|
6567
|
+
files: z9.array(fileEntryWithHashSchema),
|
|
6568
|
+
message: z9.string().optional()
|
|
6540
6569
|
}),
|
|
6541
6570
|
responses: {
|
|
6542
|
-
200:
|
|
6543
|
-
success:
|
|
6544
|
-
versionId:
|
|
6545
|
-
storageName:
|
|
6546
|
-
size:
|
|
6547
|
-
fileCount:
|
|
6548
|
-
deduplicated:
|
|
6571
|
+
200: z9.object({
|
|
6572
|
+
success: z9.literal(true),
|
|
6573
|
+
versionId: z9.string(),
|
|
6574
|
+
storageName: z9.string(),
|
|
6575
|
+
size: z9.number(),
|
|
6576
|
+
fileCount: z9.number(),
|
|
6577
|
+
deduplicated: z9.boolean().optional()
|
|
6549
6578
|
}),
|
|
6550
6579
|
400: apiErrorSchema,
|
|
6551
6580
|
401: apiErrorSchema,
|
|
@@ -6559,11 +6588,11 @@ var webhookStoragesCommitContract = c5.router({
|
|
|
6559
6588
|
});
|
|
6560
6589
|
|
|
6561
6590
|
// ../../packages/core/src/contracts/cli-auth.ts
|
|
6562
|
-
import { z as
|
|
6591
|
+
import { z as z10 } from "zod";
|
|
6563
6592
|
var c6 = initContract();
|
|
6564
|
-
var oauthErrorSchema =
|
|
6565
|
-
error:
|
|
6566
|
-
error_description:
|
|
6593
|
+
var oauthErrorSchema = z10.object({
|
|
6594
|
+
error: z10.string(),
|
|
6595
|
+
error_description: z10.string()
|
|
6567
6596
|
});
|
|
6568
6597
|
var cliAuthDeviceContract = c6.router({
|
|
6569
6598
|
/**
|
|
@@ -6573,14 +6602,14 @@ var cliAuthDeviceContract = c6.router({
|
|
|
6573
6602
|
create: {
|
|
6574
6603
|
method: "POST",
|
|
6575
6604
|
path: "/api/cli/auth/device",
|
|
6576
|
-
body:
|
|
6605
|
+
body: z10.object({}).optional(),
|
|
6577
6606
|
responses: {
|
|
6578
|
-
200:
|
|
6579
|
-
device_code:
|
|
6580
|
-
user_code:
|
|
6581
|
-
verification_url:
|
|
6582
|
-
expires_in:
|
|
6583
|
-
interval:
|
|
6607
|
+
200: z10.object({
|
|
6608
|
+
device_code: z10.string(),
|
|
6609
|
+
user_code: z10.string(),
|
|
6610
|
+
verification_url: z10.string(),
|
|
6611
|
+
expires_in: z10.number(),
|
|
6612
|
+
interval: z10.number()
|
|
6584
6613
|
}),
|
|
6585
6614
|
500: oauthErrorSchema
|
|
6586
6615
|
},
|
|
@@ -6595,16 +6624,16 @@ var cliAuthTokenContract = c6.router({
|
|
|
6595
6624
|
exchange: {
|
|
6596
6625
|
method: "POST",
|
|
6597
6626
|
path: "/api/cli/auth/token",
|
|
6598
|
-
body:
|
|
6599
|
-
device_code:
|
|
6627
|
+
body: z10.object({
|
|
6628
|
+
device_code: z10.string().min(1, "device_code is required")
|
|
6600
6629
|
}),
|
|
6601
6630
|
responses: {
|
|
6602
6631
|
// Success - token issued
|
|
6603
|
-
200:
|
|
6604
|
-
access_token:
|
|
6605
|
-
refresh_token:
|
|
6606
|
-
token_type:
|
|
6607
|
-
expires_in:
|
|
6632
|
+
200: z10.object({
|
|
6633
|
+
access_token: z10.string(),
|
|
6634
|
+
refresh_token: z10.string(),
|
|
6635
|
+
token_type: z10.literal("Bearer"),
|
|
6636
|
+
expires_in: z10.number()
|
|
6608
6637
|
}),
|
|
6609
6638
|
// Authorization pending
|
|
6610
6639
|
202: oauthErrorSchema,
|
|
@@ -6617,7 +6646,7 @@ var cliAuthTokenContract = c6.router({
|
|
|
6617
6646
|
});
|
|
6618
6647
|
|
|
6619
6648
|
// ../../packages/core/src/contracts/auth.ts
|
|
6620
|
-
import { z as
|
|
6649
|
+
import { z as z11 } from "zod";
|
|
6621
6650
|
var c7 = initContract();
|
|
6622
6651
|
var authContract = c7.router({
|
|
6623
6652
|
/**
|
|
@@ -6627,10 +6656,11 @@ var authContract = c7.router({
|
|
|
6627
6656
|
me: {
|
|
6628
6657
|
method: "GET",
|
|
6629
6658
|
path: "/api/auth/me",
|
|
6659
|
+
headers: authHeadersSchema,
|
|
6630
6660
|
responses: {
|
|
6631
|
-
200:
|
|
6632
|
-
userId:
|
|
6633
|
-
email:
|
|
6661
|
+
200: z11.object({
|
|
6662
|
+
userId: z11.string(),
|
|
6663
|
+
email: z11.string()
|
|
6634
6664
|
}),
|
|
6635
6665
|
401: apiErrorSchema,
|
|
6636
6666
|
404: apiErrorSchema,
|
|
@@ -6641,18 +6671,18 @@ var authContract = c7.router({
|
|
|
6641
6671
|
});
|
|
6642
6672
|
|
|
6643
6673
|
// ../../packages/core/src/contracts/cron.ts
|
|
6644
|
-
import { z as
|
|
6674
|
+
import { z as z12 } from "zod";
|
|
6645
6675
|
var c8 = initContract();
|
|
6646
|
-
var cleanupResultSchema =
|
|
6647
|
-
runId:
|
|
6648
|
-
sandboxId:
|
|
6649
|
-
status:
|
|
6650
|
-
error:
|
|
6676
|
+
var cleanupResultSchema = z12.object({
|
|
6677
|
+
runId: z12.string(),
|
|
6678
|
+
sandboxId: z12.string().nullable(),
|
|
6679
|
+
status: z12.enum(["cleaned", "error"]),
|
|
6680
|
+
error: z12.string().optional()
|
|
6651
6681
|
});
|
|
6652
|
-
var cleanupResponseSchema =
|
|
6653
|
-
cleaned:
|
|
6654
|
-
errors:
|
|
6655
|
-
results:
|
|
6682
|
+
var cleanupResponseSchema = z12.object({
|
|
6683
|
+
cleaned: z12.number(),
|
|
6684
|
+
errors: z12.number(),
|
|
6685
|
+
results: z12.array(cleanupResultSchema)
|
|
6656
6686
|
});
|
|
6657
6687
|
var cronCleanupSandboxesContract = c8.router({
|
|
6658
6688
|
/**
|
|
@@ -6662,6 +6692,7 @@ var cronCleanupSandboxesContract = c8.router({
|
|
|
6662
6692
|
cleanup: {
|
|
6663
6693
|
method: "GET",
|
|
6664
6694
|
path: "/api/cron/cleanup-sandboxes",
|
|
6695
|
+
headers: authHeadersSchema,
|
|
6665
6696
|
responses: {
|
|
6666
6697
|
200: cleanupResponseSchema,
|
|
6667
6698
|
401: apiErrorSchema,
|
|
@@ -6672,46 +6703,46 @@ var cronCleanupSandboxesContract = c8.router({
|
|
|
6672
6703
|
});
|
|
6673
6704
|
|
|
6674
6705
|
// ../../packages/core/src/contracts/proxy.ts
|
|
6675
|
-
import { z as
|
|
6676
|
-
var proxyErrorSchema =
|
|
6677
|
-
error:
|
|
6678
|
-
message:
|
|
6679
|
-
code:
|
|
6706
|
+
import { z as z13 } from "zod";
|
|
6707
|
+
var proxyErrorSchema = z13.object({
|
|
6708
|
+
error: z13.object({
|
|
6709
|
+
message: z13.string(),
|
|
6710
|
+
code: z13.enum([
|
|
6680
6711
|
"UNAUTHORIZED",
|
|
6681
6712
|
"BAD_REQUEST",
|
|
6682
6713
|
"BAD_GATEWAY",
|
|
6683
6714
|
"INTERNAL_ERROR"
|
|
6684
6715
|
]),
|
|
6685
|
-
targetUrl:
|
|
6716
|
+
targetUrl: z13.string().optional()
|
|
6686
6717
|
})
|
|
6687
6718
|
});
|
|
6688
6719
|
|
|
6689
6720
|
// ../../packages/core/src/contracts/scopes.ts
|
|
6690
|
-
import { z as
|
|
6721
|
+
import { z as z14 } from "zod";
|
|
6691
6722
|
var c9 = initContract();
|
|
6692
|
-
var scopeTypeSchema =
|
|
6693
|
-
var scopeSlugSchema =
|
|
6723
|
+
var scopeTypeSchema = z14.enum(["personal", "organization", "system"]);
|
|
6724
|
+
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(
|
|
6694
6725
|
/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]{1,2}$/,
|
|
6695
6726
|
"Scope slug must contain only lowercase letters, numbers, and hyphens, and must start and end with an alphanumeric character"
|
|
6696
6727
|
).refine(
|
|
6697
6728
|
(slug) => !slug.startsWith("vm0"),
|
|
6698
6729
|
"Scope slug cannot start with 'vm0' (reserved)"
|
|
6699
6730
|
).transform((s) => s.toLowerCase());
|
|
6700
|
-
var scopeResponseSchema =
|
|
6701
|
-
id:
|
|
6702
|
-
slug:
|
|
6731
|
+
var scopeResponseSchema = z14.object({
|
|
6732
|
+
id: z14.string().uuid(),
|
|
6733
|
+
slug: z14.string(),
|
|
6703
6734
|
type: scopeTypeSchema,
|
|
6704
|
-
displayName:
|
|
6705
|
-
createdAt:
|
|
6706
|
-
updatedAt:
|
|
6735
|
+
displayName: z14.string().nullable(),
|
|
6736
|
+
createdAt: z14.string(),
|
|
6737
|
+
updatedAt: z14.string()
|
|
6707
6738
|
});
|
|
6708
|
-
var createScopeRequestSchema =
|
|
6739
|
+
var createScopeRequestSchema = z14.object({
|
|
6709
6740
|
slug: scopeSlugSchema,
|
|
6710
|
-
displayName:
|
|
6741
|
+
displayName: z14.string().max(128).optional()
|
|
6711
6742
|
});
|
|
6712
|
-
var updateScopeRequestSchema =
|
|
6743
|
+
var updateScopeRequestSchema = z14.object({
|
|
6713
6744
|
slug: scopeSlugSchema,
|
|
6714
|
-
force:
|
|
6745
|
+
force: z14.boolean().optional().default(false)
|
|
6715
6746
|
});
|
|
6716
6747
|
var scopeContract = c9.router({
|
|
6717
6748
|
/**
|
|
@@ -6721,6 +6752,7 @@ var scopeContract = c9.router({
|
|
|
6721
6752
|
get: {
|
|
6722
6753
|
method: "GET",
|
|
6723
6754
|
path: "/api/scope",
|
|
6755
|
+
headers: authHeadersSchema,
|
|
6724
6756
|
responses: {
|
|
6725
6757
|
200: scopeResponseSchema,
|
|
6726
6758
|
401: apiErrorSchema,
|
|
@@ -6736,6 +6768,7 @@ var scopeContract = c9.router({
|
|
|
6736
6768
|
create: {
|
|
6737
6769
|
method: "POST",
|
|
6738
6770
|
path: "/api/scope",
|
|
6771
|
+
headers: authHeadersSchema,
|
|
6739
6772
|
body: createScopeRequestSchema,
|
|
6740
6773
|
responses: {
|
|
6741
6774
|
201: scopeResponseSchema,
|
|
@@ -6753,6 +6786,7 @@ var scopeContract = c9.router({
|
|
|
6753
6786
|
update: {
|
|
6754
6787
|
method: "PUT",
|
|
6755
6788
|
path: "/api/scope",
|
|
6789
|
+
headers: authHeadersSchema,
|
|
6756
6790
|
body: updateScopeRequestSchema,
|
|
6757
6791
|
responses: {
|
|
6758
6792
|
200: scopeResponseSchema,
|
|
@@ -6768,28 +6802,28 @@ var scopeContract = c9.router({
|
|
|
6768
6802
|
});
|
|
6769
6803
|
|
|
6770
6804
|
// ../../packages/core/src/contracts/credentials.ts
|
|
6771
|
-
import { z as
|
|
6805
|
+
import { z as z15 } from "zod";
|
|
6772
6806
|
var c10 = initContract();
|
|
6773
|
-
var credentialNameSchema =
|
|
6807
|
+
var credentialNameSchema = z15.string().min(1, "Credential name is required").max(255, "Credential name must be at most 255 characters").regex(
|
|
6774
6808
|
/^[A-Z][A-Z0-9_]*$/,
|
|
6775
6809
|
"Credential name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_API_KEY)"
|
|
6776
6810
|
);
|
|
6777
|
-
var credentialTypeSchema =
|
|
6778
|
-
var credentialResponseSchema =
|
|
6779
|
-
id:
|
|
6780
|
-
name:
|
|
6781
|
-
description:
|
|
6811
|
+
var credentialTypeSchema = z15.enum(["user", "model-provider"]);
|
|
6812
|
+
var credentialResponseSchema = z15.object({
|
|
6813
|
+
id: z15.string().uuid(),
|
|
6814
|
+
name: z15.string(),
|
|
6815
|
+
description: z15.string().nullable(),
|
|
6782
6816
|
type: credentialTypeSchema,
|
|
6783
|
-
createdAt:
|
|
6784
|
-
updatedAt:
|
|
6817
|
+
createdAt: z15.string(),
|
|
6818
|
+
updatedAt: z15.string()
|
|
6785
6819
|
});
|
|
6786
|
-
var credentialListResponseSchema =
|
|
6787
|
-
credentials:
|
|
6820
|
+
var credentialListResponseSchema = z15.object({
|
|
6821
|
+
credentials: z15.array(credentialResponseSchema)
|
|
6788
6822
|
});
|
|
6789
|
-
var setCredentialRequestSchema =
|
|
6823
|
+
var setCredentialRequestSchema = z15.object({
|
|
6790
6824
|
name: credentialNameSchema,
|
|
6791
|
-
value:
|
|
6792
|
-
description:
|
|
6825
|
+
value: z15.string().min(1, "Credential value is required"),
|
|
6826
|
+
description: z15.string().max(1e3).optional()
|
|
6793
6827
|
});
|
|
6794
6828
|
var credentialsMainContract = c10.router({
|
|
6795
6829
|
/**
|
|
@@ -6799,6 +6833,7 @@ var credentialsMainContract = c10.router({
|
|
|
6799
6833
|
list: {
|
|
6800
6834
|
method: "GET",
|
|
6801
6835
|
path: "/api/credentials",
|
|
6836
|
+
headers: authHeadersSchema,
|
|
6802
6837
|
responses: {
|
|
6803
6838
|
200: credentialListResponseSchema,
|
|
6804
6839
|
401: apiErrorSchema,
|
|
@@ -6813,6 +6848,7 @@ var credentialsMainContract = c10.router({
|
|
|
6813
6848
|
set: {
|
|
6814
6849
|
method: "PUT",
|
|
6815
6850
|
path: "/api/credentials",
|
|
6851
|
+
headers: authHeadersSchema,
|
|
6816
6852
|
body: setCredentialRequestSchema,
|
|
6817
6853
|
responses: {
|
|
6818
6854
|
200: credentialResponseSchema,
|
|
@@ -6832,7 +6868,8 @@ var credentialsByNameContract = c10.router({
|
|
|
6832
6868
|
get: {
|
|
6833
6869
|
method: "GET",
|
|
6834
6870
|
path: "/api/credentials/:name",
|
|
6835
|
-
|
|
6871
|
+
headers: authHeadersSchema,
|
|
6872
|
+
pathParams: z15.object({
|
|
6836
6873
|
name: credentialNameSchema
|
|
6837
6874
|
}),
|
|
6838
6875
|
responses: {
|
|
@@ -6850,11 +6887,12 @@ var credentialsByNameContract = c10.router({
|
|
|
6850
6887
|
delete: {
|
|
6851
6888
|
method: "DELETE",
|
|
6852
6889
|
path: "/api/credentials/:name",
|
|
6853
|
-
|
|
6890
|
+
headers: authHeadersSchema,
|
|
6891
|
+
pathParams: z15.object({
|
|
6854
6892
|
name: credentialNameSchema
|
|
6855
6893
|
}),
|
|
6856
6894
|
responses: {
|
|
6857
|
-
204:
|
|
6895
|
+
204: z15.undefined(),
|
|
6858
6896
|
401: apiErrorSchema,
|
|
6859
6897
|
404: apiErrorSchema,
|
|
6860
6898
|
500: apiErrorSchema
|
|
@@ -6864,44 +6902,45 @@ var credentialsByNameContract = c10.router({
|
|
|
6864
6902
|
});
|
|
6865
6903
|
|
|
6866
6904
|
// ../../packages/core/src/contracts/model-providers.ts
|
|
6867
|
-
import { z as
|
|
6905
|
+
import { z as z16 } from "zod";
|
|
6868
6906
|
var c11 = initContract();
|
|
6869
|
-
var modelProviderTypeSchema =
|
|
6907
|
+
var modelProviderTypeSchema = z16.enum([
|
|
6870
6908
|
"claude-code-oauth-token",
|
|
6871
6909
|
"anthropic-api-key",
|
|
6872
6910
|
"openai-api-key"
|
|
6873
6911
|
]);
|
|
6874
|
-
var modelProviderFrameworkSchema =
|
|
6875
|
-
var modelProviderResponseSchema =
|
|
6876
|
-
id:
|
|
6912
|
+
var modelProviderFrameworkSchema = z16.enum(["claude-code", "codex"]);
|
|
6913
|
+
var modelProviderResponseSchema = z16.object({
|
|
6914
|
+
id: z16.string().uuid(),
|
|
6877
6915
|
type: modelProviderTypeSchema,
|
|
6878
6916
|
framework: modelProviderFrameworkSchema,
|
|
6879
|
-
credentialName:
|
|
6880
|
-
isDefault:
|
|
6881
|
-
createdAt:
|
|
6882
|
-
updatedAt:
|
|
6917
|
+
credentialName: z16.string(),
|
|
6918
|
+
isDefault: z16.boolean(),
|
|
6919
|
+
createdAt: z16.string(),
|
|
6920
|
+
updatedAt: z16.string()
|
|
6883
6921
|
});
|
|
6884
|
-
var modelProviderListResponseSchema =
|
|
6885
|
-
modelProviders:
|
|
6922
|
+
var modelProviderListResponseSchema = z16.object({
|
|
6923
|
+
modelProviders: z16.array(modelProviderResponseSchema)
|
|
6886
6924
|
});
|
|
6887
|
-
var upsertModelProviderRequestSchema =
|
|
6925
|
+
var upsertModelProviderRequestSchema = z16.object({
|
|
6888
6926
|
type: modelProviderTypeSchema,
|
|
6889
|
-
credential:
|
|
6890
|
-
convert:
|
|
6927
|
+
credential: z16.string().min(1, "Credential is required"),
|
|
6928
|
+
convert: z16.boolean().optional()
|
|
6891
6929
|
});
|
|
6892
|
-
var upsertModelProviderResponseSchema =
|
|
6930
|
+
var upsertModelProviderResponseSchema = z16.object({
|
|
6893
6931
|
provider: modelProviderResponseSchema,
|
|
6894
|
-
created:
|
|
6932
|
+
created: z16.boolean()
|
|
6895
6933
|
});
|
|
6896
|
-
var checkCredentialResponseSchema =
|
|
6897
|
-
exists:
|
|
6898
|
-
credentialName:
|
|
6899
|
-
currentType:
|
|
6934
|
+
var checkCredentialResponseSchema = z16.object({
|
|
6935
|
+
exists: z16.boolean(),
|
|
6936
|
+
credentialName: z16.string(),
|
|
6937
|
+
currentType: z16.enum(["user", "model-provider"]).optional()
|
|
6900
6938
|
});
|
|
6901
6939
|
var modelProvidersMainContract = c11.router({
|
|
6902
6940
|
list: {
|
|
6903
6941
|
method: "GET",
|
|
6904
6942
|
path: "/api/model-providers",
|
|
6943
|
+
headers: authHeadersSchema,
|
|
6905
6944
|
responses: {
|
|
6906
6945
|
200: modelProviderListResponseSchema,
|
|
6907
6946
|
401: apiErrorSchema,
|
|
@@ -6912,6 +6951,7 @@ var modelProvidersMainContract = c11.router({
|
|
|
6912
6951
|
upsert: {
|
|
6913
6952
|
method: "PUT",
|
|
6914
6953
|
path: "/api/model-providers",
|
|
6954
|
+
headers: authHeadersSchema,
|
|
6915
6955
|
body: upsertModelProviderRequestSchema,
|
|
6916
6956
|
responses: {
|
|
6917
6957
|
200: upsertModelProviderResponseSchema,
|
|
@@ -6928,7 +6968,8 @@ var modelProvidersCheckContract = c11.router({
|
|
|
6928
6968
|
check: {
|
|
6929
6969
|
method: "GET",
|
|
6930
6970
|
path: "/api/model-providers/check/:type",
|
|
6931
|
-
|
|
6971
|
+
headers: authHeadersSchema,
|
|
6972
|
+
pathParams: z16.object({
|
|
6932
6973
|
type: modelProviderTypeSchema
|
|
6933
6974
|
}),
|
|
6934
6975
|
responses: {
|
|
@@ -6943,11 +6984,12 @@ var modelProvidersByTypeContract = c11.router({
|
|
|
6943
6984
|
delete: {
|
|
6944
6985
|
method: "DELETE",
|
|
6945
6986
|
path: "/api/model-providers/:type",
|
|
6946
|
-
|
|
6987
|
+
headers: authHeadersSchema,
|
|
6988
|
+
pathParams: z16.object({
|
|
6947
6989
|
type: modelProviderTypeSchema
|
|
6948
6990
|
}),
|
|
6949
6991
|
responses: {
|
|
6950
|
-
204:
|
|
6992
|
+
204: z16.undefined(),
|
|
6951
6993
|
401: apiErrorSchema,
|
|
6952
6994
|
404: apiErrorSchema,
|
|
6953
6995
|
500: apiErrorSchema
|
|
@@ -6959,10 +7001,11 @@ var modelProvidersConvertContract = c11.router({
|
|
|
6959
7001
|
convert: {
|
|
6960
7002
|
method: "POST",
|
|
6961
7003
|
path: "/api/model-providers/:type/convert",
|
|
6962
|
-
|
|
7004
|
+
headers: authHeadersSchema,
|
|
7005
|
+
pathParams: z16.object({
|
|
6963
7006
|
type: modelProviderTypeSchema
|
|
6964
7007
|
}),
|
|
6965
|
-
body:
|
|
7008
|
+
body: z16.undefined(),
|
|
6966
7009
|
responses: {
|
|
6967
7010
|
200: modelProviderResponseSchema,
|
|
6968
7011
|
400: apiErrorSchema,
|
|
@@ -6977,10 +7020,11 @@ var modelProvidersSetDefaultContract = c11.router({
|
|
|
6977
7020
|
setDefault: {
|
|
6978
7021
|
method: "POST",
|
|
6979
7022
|
path: "/api/model-providers/:type/set-default",
|
|
6980
|
-
|
|
7023
|
+
headers: authHeadersSchema,
|
|
7024
|
+
pathParams: z16.object({
|
|
6981
7025
|
type: modelProviderTypeSchema
|
|
6982
7026
|
}),
|
|
6983
|
-
body:
|
|
7027
|
+
body: z16.undefined(),
|
|
6984
7028
|
responses: {
|
|
6985
7029
|
200: modelProviderResponseSchema,
|
|
6986
7030
|
401: apiErrorSchema,
|
|
@@ -6992,40 +7036,40 @@ var modelProvidersSetDefaultContract = c11.router({
|
|
|
6992
7036
|
});
|
|
6993
7037
|
|
|
6994
7038
|
// ../../packages/core/src/contracts/sessions.ts
|
|
6995
|
-
import { z as
|
|
7039
|
+
import { z as z17 } from "zod";
|
|
6996
7040
|
var c12 = initContract();
|
|
6997
|
-
var sessionResponseSchema =
|
|
6998
|
-
id:
|
|
6999
|
-
agentComposeId:
|
|
7000
|
-
agentComposeVersionId:
|
|
7001
|
-
conversationId:
|
|
7002
|
-
artifactName:
|
|
7003
|
-
vars:
|
|
7004
|
-
secretNames:
|
|
7005
|
-
volumeVersions:
|
|
7006
|
-
createdAt:
|
|
7007
|
-
updatedAt:
|
|
7041
|
+
var sessionResponseSchema = z17.object({
|
|
7042
|
+
id: z17.string(),
|
|
7043
|
+
agentComposeId: z17.string(),
|
|
7044
|
+
agentComposeVersionId: z17.string().nullable(),
|
|
7045
|
+
conversationId: z17.string().nullable(),
|
|
7046
|
+
artifactName: z17.string().nullable(),
|
|
7047
|
+
vars: z17.record(z17.string(), z17.string()).nullable(),
|
|
7048
|
+
secretNames: z17.array(z17.string()).nullable(),
|
|
7049
|
+
volumeVersions: z17.record(z17.string(), z17.string()).nullable(),
|
|
7050
|
+
createdAt: z17.string(),
|
|
7051
|
+
updatedAt: z17.string()
|
|
7008
7052
|
});
|
|
7009
|
-
var agentComposeSnapshotSchema =
|
|
7010
|
-
agentComposeVersionId:
|
|
7011
|
-
vars:
|
|
7012
|
-
secretNames:
|
|
7053
|
+
var agentComposeSnapshotSchema = z17.object({
|
|
7054
|
+
agentComposeVersionId: z17.string(),
|
|
7055
|
+
vars: z17.record(z17.string(), z17.string()).optional(),
|
|
7056
|
+
secretNames: z17.array(z17.string()).optional()
|
|
7013
7057
|
});
|
|
7014
|
-
var artifactSnapshotSchema2 =
|
|
7015
|
-
artifactName:
|
|
7016
|
-
artifactVersion:
|
|
7058
|
+
var artifactSnapshotSchema2 = z17.object({
|
|
7059
|
+
artifactName: z17.string(),
|
|
7060
|
+
artifactVersion: z17.string()
|
|
7017
7061
|
});
|
|
7018
|
-
var volumeVersionsSnapshotSchema2 =
|
|
7019
|
-
versions:
|
|
7062
|
+
var volumeVersionsSnapshotSchema2 = z17.object({
|
|
7063
|
+
versions: z17.record(z17.string(), z17.string())
|
|
7020
7064
|
});
|
|
7021
|
-
var checkpointResponseSchema =
|
|
7022
|
-
id:
|
|
7023
|
-
runId:
|
|
7024
|
-
conversationId:
|
|
7065
|
+
var checkpointResponseSchema = z17.object({
|
|
7066
|
+
id: z17.string(),
|
|
7067
|
+
runId: z17.string(),
|
|
7068
|
+
conversationId: z17.string(),
|
|
7025
7069
|
agentComposeSnapshot: agentComposeSnapshotSchema,
|
|
7026
7070
|
artifactSnapshot: artifactSnapshotSchema2.nullable(),
|
|
7027
7071
|
volumeVersionsSnapshot: volumeVersionsSnapshotSchema2.nullable(),
|
|
7028
|
-
createdAt:
|
|
7072
|
+
createdAt: z17.string()
|
|
7029
7073
|
});
|
|
7030
7074
|
var sessionsByIdContract = c12.router({
|
|
7031
7075
|
/**
|
|
@@ -7035,8 +7079,9 @@ var sessionsByIdContract = c12.router({
|
|
|
7035
7079
|
getById: {
|
|
7036
7080
|
method: "GET",
|
|
7037
7081
|
path: "/api/agent/sessions/:id",
|
|
7038
|
-
|
|
7039
|
-
|
|
7082
|
+
headers: authHeadersSchema,
|
|
7083
|
+
pathParams: z17.object({
|
|
7084
|
+
id: z17.string().min(1, "Session ID is required")
|
|
7040
7085
|
}),
|
|
7041
7086
|
responses: {
|
|
7042
7087
|
200: sessionResponseSchema,
|
|
@@ -7055,8 +7100,9 @@ var checkpointsByIdContract = c12.router({
|
|
|
7055
7100
|
getById: {
|
|
7056
7101
|
method: "GET",
|
|
7057
7102
|
path: "/api/agent/checkpoints/:id",
|
|
7058
|
-
|
|
7059
|
-
|
|
7103
|
+
headers: authHeadersSchema,
|
|
7104
|
+
pathParams: z17.object({
|
|
7105
|
+
id: z17.string().min(1, "Checkpoint ID is required")
|
|
7060
7106
|
}),
|
|
7061
7107
|
responses: {
|
|
7062
7108
|
200: checkpointResponseSchema,
|
|
@@ -7069,88 +7115,88 @@ var checkpointsByIdContract = c12.router({
|
|
|
7069
7115
|
});
|
|
7070
7116
|
|
|
7071
7117
|
// ../../packages/core/src/contracts/schedules.ts
|
|
7072
|
-
import { z as
|
|
7118
|
+
import { z as z18 } from "zod";
|
|
7073
7119
|
var c13 = initContract();
|
|
7074
|
-
var scheduleTriggerSchema =
|
|
7075
|
-
cron:
|
|
7076
|
-
at:
|
|
7077
|
-
timezone:
|
|
7120
|
+
var scheduleTriggerSchema = z18.object({
|
|
7121
|
+
cron: z18.string().optional(),
|
|
7122
|
+
at: z18.string().optional(),
|
|
7123
|
+
timezone: z18.string().default("UTC")
|
|
7078
7124
|
}).refine((data) => data.cron && !data.at || !data.cron && data.at, {
|
|
7079
7125
|
message: "Exactly one of 'cron' or 'at' must be specified"
|
|
7080
7126
|
});
|
|
7081
|
-
var scheduleRunConfigSchema =
|
|
7082
|
-
agent:
|
|
7083
|
-
prompt:
|
|
7084
|
-
vars:
|
|
7085
|
-
secrets:
|
|
7086
|
-
artifactName:
|
|
7087
|
-
artifactVersion:
|
|
7088
|
-
volumeVersions:
|
|
7127
|
+
var scheduleRunConfigSchema = z18.object({
|
|
7128
|
+
agent: z18.string().min(1, "Agent reference required"),
|
|
7129
|
+
prompt: z18.string().min(1, "Prompt required"),
|
|
7130
|
+
vars: z18.record(z18.string(), z18.string()).optional(),
|
|
7131
|
+
secrets: z18.record(z18.string(), z18.string()).optional(),
|
|
7132
|
+
artifactName: z18.string().optional(),
|
|
7133
|
+
artifactVersion: z18.string().optional(),
|
|
7134
|
+
volumeVersions: z18.record(z18.string(), z18.string()).optional()
|
|
7089
7135
|
});
|
|
7090
|
-
var scheduleDefinitionSchema =
|
|
7136
|
+
var scheduleDefinitionSchema = z18.object({
|
|
7091
7137
|
on: scheduleTriggerSchema,
|
|
7092
7138
|
run: scheduleRunConfigSchema
|
|
7093
7139
|
});
|
|
7094
|
-
var scheduleYamlSchema =
|
|
7095
|
-
version:
|
|
7096
|
-
schedules:
|
|
7097
|
-
});
|
|
7098
|
-
var deployScheduleRequestSchema =
|
|
7099
|
-
name:
|
|
7100
|
-
cronExpression:
|
|
7101
|
-
atTime:
|
|
7102
|
-
timezone:
|
|
7103
|
-
prompt:
|
|
7104
|
-
vars:
|
|
7105
|
-
secrets:
|
|
7106
|
-
artifactName:
|
|
7107
|
-
artifactVersion:
|
|
7108
|
-
volumeVersions:
|
|
7140
|
+
var scheduleYamlSchema = z18.object({
|
|
7141
|
+
version: z18.literal("1.0"),
|
|
7142
|
+
schedules: z18.record(z18.string(), scheduleDefinitionSchema)
|
|
7143
|
+
});
|
|
7144
|
+
var deployScheduleRequestSchema = z18.object({
|
|
7145
|
+
name: z18.string().min(1).max(64, "Schedule name max 64 chars"),
|
|
7146
|
+
cronExpression: z18.string().optional(),
|
|
7147
|
+
atTime: z18.string().optional(),
|
|
7148
|
+
timezone: z18.string().default("UTC"),
|
|
7149
|
+
prompt: z18.string().min(1, "Prompt required"),
|
|
7150
|
+
vars: z18.record(z18.string(), z18.string()).optional(),
|
|
7151
|
+
secrets: z18.record(z18.string(), z18.string()).optional(),
|
|
7152
|
+
artifactName: z18.string().optional(),
|
|
7153
|
+
artifactVersion: z18.string().optional(),
|
|
7154
|
+
volumeVersions: z18.record(z18.string(), z18.string()).optional(),
|
|
7109
7155
|
// Resolved agent compose ID (CLI resolves scope/name:version → composeId)
|
|
7110
|
-
composeId:
|
|
7156
|
+
composeId: z18.string().uuid("Invalid compose ID")
|
|
7111
7157
|
}).refine(
|
|
7112
7158
|
(data) => data.cronExpression && !data.atTime || !data.cronExpression && data.atTime,
|
|
7113
7159
|
{
|
|
7114
7160
|
message: "Exactly one of 'cronExpression' or 'atTime' must be specified"
|
|
7115
7161
|
}
|
|
7116
7162
|
);
|
|
7117
|
-
var scheduleResponseSchema =
|
|
7118
|
-
id:
|
|
7119
|
-
composeId:
|
|
7120
|
-
composeName:
|
|
7121
|
-
scopeSlug:
|
|
7122
|
-
name:
|
|
7123
|
-
cronExpression:
|
|
7124
|
-
atTime:
|
|
7125
|
-
timezone:
|
|
7126
|
-
prompt:
|
|
7127
|
-
vars:
|
|
7163
|
+
var scheduleResponseSchema = z18.object({
|
|
7164
|
+
id: z18.string().uuid(),
|
|
7165
|
+
composeId: z18.string().uuid(),
|
|
7166
|
+
composeName: z18.string(),
|
|
7167
|
+
scopeSlug: z18.string(),
|
|
7168
|
+
name: z18.string(),
|
|
7169
|
+
cronExpression: z18.string().nullable(),
|
|
7170
|
+
atTime: z18.string().nullable(),
|
|
7171
|
+
timezone: z18.string(),
|
|
7172
|
+
prompt: z18.string(),
|
|
7173
|
+
vars: z18.record(z18.string(), z18.string()).nullable(),
|
|
7128
7174
|
// Secret names only (values are never returned)
|
|
7129
|
-
secretNames:
|
|
7130
|
-
artifactName:
|
|
7131
|
-
artifactVersion:
|
|
7132
|
-
volumeVersions:
|
|
7133
|
-
enabled:
|
|
7134
|
-
nextRunAt:
|
|
7135
|
-
createdAt:
|
|
7136
|
-
updatedAt:
|
|
7137
|
-
});
|
|
7138
|
-
var runSummarySchema =
|
|
7139
|
-
id:
|
|
7140
|
-
status:
|
|
7141
|
-
createdAt:
|
|
7142
|
-
completedAt:
|
|
7143
|
-
error:
|
|
7144
|
-
});
|
|
7145
|
-
var scheduleRunsResponseSchema =
|
|
7146
|
-
runs:
|
|
7147
|
-
});
|
|
7148
|
-
var scheduleListResponseSchema =
|
|
7149
|
-
schedules:
|
|
7150
|
-
});
|
|
7151
|
-
var deployScheduleResponseSchema =
|
|
7175
|
+
secretNames: z18.array(z18.string()).nullable(),
|
|
7176
|
+
artifactName: z18.string().nullable(),
|
|
7177
|
+
artifactVersion: z18.string().nullable(),
|
|
7178
|
+
volumeVersions: z18.record(z18.string(), z18.string()).nullable(),
|
|
7179
|
+
enabled: z18.boolean(),
|
|
7180
|
+
nextRunAt: z18.string().nullable(),
|
|
7181
|
+
createdAt: z18.string(),
|
|
7182
|
+
updatedAt: z18.string()
|
|
7183
|
+
});
|
|
7184
|
+
var runSummarySchema = z18.object({
|
|
7185
|
+
id: z18.string().uuid(),
|
|
7186
|
+
status: z18.enum(["pending", "running", "completed", "failed", "timeout"]),
|
|
7187
|
+
createdAt: z18.string(),
|
|
7188
|
+
completedAt: z18.string().nullable(),
|
|
7189
|
+
error: z18.string().nullable()
|
|
7190
|
+
});
|
|
7191
|
+
var scheduleRunsResponseSchema = z18.object({
|
|
7192
|
+
runs: z18.array(runSummarySchema)
|
|
7193
|
+
});
|
|
7194
|
+
var scheduleListResponseSchema = z18.object({
|
|
7195
|
+
schedules: z18.array(scheduleResponseSchema)
|
|
7196
|
+
});
|
|
7197
|
+
var deployScheduleResponseSchema = z18.object({
|
|
7152
7198
|
schedule: scheduleResponseSchema,
|
|
7153
|
-
created:
|
|
7199
|
+
created: z18.boolean()
|
|
7154
7200
|
// true if created, false if updated
|
|
7155
7201
|
});
|
|
7156
7202
|
var schedulesMainContract = c13.router({
|
|
@@ -7161,6 +7207,7 @@ var schedulesMainContract = c13.router({
|
|
|
7161
7207
|
deploy: {
|
|
7162
7208
|
method: "POST",
|
|
7163
7209
|
path: "/api/agent/schedules",
|
|
7210
|
+
headers: authHeadersSchema,
|
|
7164
7211
|
body: deployScheduleRequestSchema,
|
|
7165
7212
|
responses: {
|
|
7166
7213
|
200: deployScheduleResponseSchema,
|
|
@@ -7182,6 +7229,7 @@ var schedulesMainContract = c13.router({
|
|
|
7182
7229
|
list: {
|
|
7183
7230
|
method: "GET",
|
|
7184
7231
|
path: "/api/agent/schedules",
|
|
7232
|
+
headers: authHeadersSchema,
|
|
7185
7233
|
responses: {
|
|
7186
7234
|
200: scheduleListResponseSchema,
|
|
7187
7235
|
401: apiErrorSchema
|
|
@@ -7197,11 +7245,12 @@ var schedulesByNameContract = c13.router({
|
|
|
7197
7245
|
getByName: {
|
|
7198
7246
|
method: "GET",
|
|
7199
7247
|
path: "/api/agent/schedules/:name",
|
|
7200
|
-
|
|
7201
|
-
|
|
7248
|
+
headers: authHeadersSchema,
|
|
7249
|
+
pathParams: z18.object({
|
|
7250
|
+
name: z18.string().min(1, "Schedule name required")
|
|
7202
7251
|
}),
|
|
7203
|
-
query:
|
|
7204
|
-
composeId:
|
|
7252
|
+
query: z18.object({
|
|
7253
|
+
composeId: z18.string().uuid("Compose ID required")
|
|
7205
7254
|
}),
|
|
7206
7255
|
responses: {
|
|
7207
7256
|
200: scheduleResponseSchema,
|
|
@@ -7217,14 +7266,15 @@ var schedulesByNameContract = c13.router({
|
|
|
7217
7266
|
delete: {
|
|
7218
7267
|
method: "DELETE",
|
|
7219
7268
|
path: "/api/agent/schedules/:name",
|
|
7220
|
-
|
|
7221
|
-
|
|
7269
|
+
headers: authHeadersSchema,
|
|
7270
|
+
pathParams: z18.object({
|
|
7271
|
+
name: z18.string().min(1, "Schedule name required")
|
|
7222
7272
|
}),
|
|
7223
|
-
query:
|
|
7224
|
-
composeId:
|
|
7273
|
+
query: z18.object({
|
|
7274
|
+
composeId: z18.string().uuid("Compose ID required")
|
|
7225
7275
|
}),
|
|
7226
7276
|
responses: {
|
|
7227
|
-
204:
|
|
7277
|
+
204: z18.undefined(),
|
|
7228
7278
|
401: apiErrorSchema,
|
|
7229
7279
|
404: apiErrorSchema
|
|
7230
7280
|
},
|
|
@@ -7239,11 +7289,12 @@ var schedulesEnableContract = c13.router({
|
|
|
7239
7289
|
enable: {
|
|
7240
7290
|
method: "POST",
|
|
7241
7291
|
path: "/api/agent/schedules/:name/enable",
|
|
7242
|
-
|
|
7243
|
-
|
|
7292
|
+
headers: authHeadersSchema,
|
|
7293
|
+
pathParams: z18.object({
|
|
7294
|
+
name: z18.string().min(1, "Schedule name required")
|
|
7244
7295
|
}),
|
|
7245
|
-
body:
|
|
7246
|
-
composeId:
|
|
7296
|
+
body: z18.object({
|
|
7297
|
+
composeId: z18.string().uuid("Compose ID required")
|
|
7247
7298
|
}),
|
|
7248
7299
|
responses: {
|
|
7249
7300
|
200: scheduleResponseSchema,
|
|
@@ -7259,11 +7310,12 @@ var schedulesEnableContract = c13.router({
|
|
|
7259
7310
|
disable: {
|
|
7260
7311
|
method: "POST",
|
|
7261
7312
|
path: "/api/agent/schedules/:name/disable",
|
|
7262
|
-
|
|
7263
|
-
|
|
7313
|
+
headers: authHeadersSchema,
|
|
7314
|
+
pathParams: z18.object({
|
|
7315
|
+
name: z18.string().min(1, "Schedule name required")
|
|
7264
7316
|
}),
|
|
7265
|
-
body:
|
|
7266
|
-
composeId:
|
|
7317
|
+
body: z18.object({
|
|
7318
|
+
composeId: z18.string().uuid("Compose ID required")
|
|
7267
7319
|
}),
|
|
7268
7320
|
responses: {
|
|
7269
7321
|
200: scheduleResponseSchema,
|
|
@@ -7281,12 +7333,13 @@ var scheduleRunsContract = c13.router({
|
|
|
7281
7333
|
listRuns: {
|
|
7282
7334
|
method: "GET",
|
|
7283
7335
|
path: "/api/agent/schedules/:name/runs",
|
|
7284
|
-
|
|
7285
|
-
|
|
7336
|
+
headers: authHeadersSchema,
|
|
7337
|
+
pathParams: z18.object({
|
|
7338
|
+
name: z18.string().min(1, "Schedule name required")
|
|
7286
7339
|
}),
|
|
7287
|
-
query:
|
|
7288
|
-
composeId:
|
|
7289
|
-
limit:
|
|
7340
|
+
query: z18.object({
|
|
7341
|
+
composeId: z18.string().uuid("Compose ID required"),
|
|
7342
|
+
limit: z18.coerce.number().min(0).max(100).default(5)
|
|
7290
7343
|
}),
|
|
7291
7344
|
responses: {
|
|
7292
7345
|
200: scheduleRunsResponseSchema,
|
|
@@ -7298,16 +7351,16 @@ var scheduleRunsContract = c13.router({
|
|
|
7298
7351
|
});
|
|
7299
7352
|
|
|
7300
7353
|
// ../../packages/core/src/contracts/realtime.ts
|
|
7301
|
-
import { z as
|
|
7354
|
+
import { z as z19 } from "zod";
|
|
7302
7355
|
var c14 = initContract();
|
|
7303
|
-
var ablyTokenRequestSchema =
|
|
7304
|
-
keyName:
|
|
7305
|
-
ttl:
|
|
7306
|
-
timestamp:
|
|
7307
|
-
capability:
|
|
7308
|
-
clientId:
|
|
7309
|
-
nonce:
|
|
7310
|
-
mac:
|
|
7356
|
+
var ablyTokenRequestSchema = z19.object({
|
|
7357
|
+
keyName: z19.string(),
|
|
7358
|
+
ttl: z19.number().optional(),
|
|
7359
|
+
timestamp: z19.number(),
|
|
7360
|
+
capability: z19.string(),
|
|
7361
|
+
clientId: z19.string().optional(),
|
|
7362
|
+
nonce: z19.string(),
|
|
7363
|
+
mac: z19.string()
|
|
7311
7364
|
});
|
|
7312
7365
|
var realtimeTokenContract = c14.router({
|
|
7313
7366
|
/**
|
|
@@ -7317,8 +7370,9 @@ var realtimeTokenContract = c14.router({
|
|
|
7317
7370
|
create: {
|
|
7318
7371
|
method: "POST",
|
|
7319
7372
|
path: "/api/realtime/token",
|
|
7320
|
-
|
|
7321
|
-
|
|
7373
|
+
headers: authHeadersSchema,
|
|
7374
|
+
body: z19.object({
|
|
7375
|
+
runId: z19.string().uuid("runId must be a valid UUID")
|
|
7322
7376
|
}),
|
|
7323
7377
|
responses: {
|
|
7324
7378
|
200: ablyTokenRequestSchema,
|
|
@@ -7332,8 +7386,8 @@ var realtimeTokenContract = c14.router({
|
|
|
7332
7386
|
});
|
|
7333
7387
|
|
|
7334
7388
|
// ../../packages/core/src/contracts/public/common.ts
|
|
7335
|
-
import { z as
|
|
7336
|
-
var publicApiErrorTypeSchema =
|
|
7389
|
+
import { z as z20 } from "zod";
|
|
7390
|
+
var publicApiErrorTypeSchema = z20.enum([
|
|
7337
7391
|
"api_error",
|
|
7338
7392
|
// Internal server error (5xx)
|
|
7339
7393
|
"invalid_request_error",
|
|
@@ -7345,58 +7399,59 @@ var publicApiErrorTypeSchema = z19.enum([
|
|
|
7345
7399
|
"conflict_error"
|
|
7346
7400
|
// Resource conflict (409)
|
|
7347
7401
|
]);
|
|
7348
|
-
var publicApiErrorSchema =
|
|
7349
|
-
error:
|
|
7402
|
+
var publicApiErrorSchema = z20.object({
|
|
7403
|
+
error: z20.object({
|
|
7350
7404
|
type: publicApiErrorTypeSchema,
|
|
7351
|
-
code:
|
|
7352
|
-
message:
|
|
7353
|
-
param:
|
|
7354
|
-
doc_url:
|
|
7405
|
+
code: z20.string(),
|
|
7406
|
+
message: z20.string(),
|
|
7407
|
+
param: z20.string().optional(),
|
|
7408
|
+
doc_url: z20.string().url().optional()
|
|
7355
7409
|
})
|
|
7356
7410
|
});
|
|
7357
|
-
var paginationSchema =
|
|
7358
|
-
has_more:
|
|
7359
|
-
next_cursor:
|
|
7411
|
+
var paginationSchema = z20.object({
|
|
7412
|
+
has_more: z20.boolean(),
|
|
7413
|
+
next_cursor: z20.string().nullable()
|
|
7360
7414
|
});
|
|
7361
7415
|
function createPaginatedResponseSchema(dataSchema) {
|
|
7362
|
-
return
|
|
7363
|
-
data:
|
|
7416
|
+
return z20.object({
|
|
7417
|
+
data: z20.array(dataSchema),
|
|
7364
7418
|
pagination: paginationSchema
|
|
7365
7419
|
});
|
|
7366
7420
|
}
|
|
7367
|
-
var listQuerySchema =
|
|
7368
|
-
cursor:
|
|
7369
|
-
limit:
|
|
7421
|
+
var listQuerySchema = z20.object({
|
|
7422
|
+
cursor: z20.string().optional(),
|
|
7423
|
+
limit: z20.coerce.number().min(1).max(100).default(20)
|
|
7370
7424
|
});
|
|
7371
|
-
var requestIdSchema =
|
|
7372
|
-
var timestampSchema =
|
|
7425
|
+
var requestIdSchema = z20.string().uuid();
|
|
7426
|
+
var timestampSchema = z20.string().datetime();
|
|
7373
7427
|
|
|
7374
7428
|
// ../../packages/core/src/contracts/public/agents.ts
|
|
7375
|
-
import { z as
|
|
7429
|
+
import { z as z21 } from "zod";
|
|
7376
7430
|
var c15 = initContract();
|
|
7377
|
-
var publicAgentSchema =
|
|
7378
|
-
id:
|
|
7379
|
-
name:
|
|
7380
|
-
current_version_id:
|
|
7431
|
+
var publicAgentSchema = z21.object({
|
|
7432
|
+
id: z21.string(),
|
|
7433
|
+
name: z21.string(),
|
|
7434
|
+
current_version_id: z21.string().nullable(),
|
|
7381
7435
|
created_at: timestampSchema,
|
|
7382
7436
|
updated_at: timestampSchema
|
|
7383
7437
|
});
|
|
7384
|
-
var agentVersionSchema =
|
|
7385
|
-
id:
|
|
7386
|
-
agent_id:
|
|
7387
|
-
version_number:
|
|
7438
|
+
var agentVersionSchema = z21.object({
|
|
7439
|
+
id: z21.string(),
|
|
7440
|
+
agent_id: z21.string(),
|
|
7441
|
+
version_number: z21.number(),
|
|
7388
7442
|
created_at: timestampSchema
|
|
7389
7443
|
});
|
|
7390
7444
|
var publicAgentDetailSchema = publicAgentSchema;
|
|
7391
7445
|
var paginatedAgentsSchema = createPaginatedResponseSchema(publicAgentSchema);
|
|
7392
7446
|
var paginatedAgentVersionsSchema = createPaginatedResponseSchema(agentVersionSchema);
|
|
7393
7447
|
var agentListQuerySchema = listQuerySchema.extend({
|
|
7394
|
-
name:
|
|
7448
|
+
name: z21.string().optional()
|
|
7395
7449
|
});
|
|
7396
7450
|
var publicAgentsListContract = c15.router({
|
|
7397
7451
|
list: {
|
|
7398
7452
|
method: "GET",
|
|
7399
7453
|
path: "/v1/agents",
|
|
7454
|
+
headers: authHeadersSchema,
|
|
7400
7455
|
query: agentListQuerySchema,
|
|
7401
7456
|
responses: {
|
|
7402
7457
|
200: paginatedAgentsSchema,
|
|
@@ -7411,8 +7466,9 @@ var publicAgentByIdContract = c15.router({
|
|
|
7411
7466
|
get: {
|
|
7412
7467
|
method: "GET",
|
|
7413
7468
|
path: "/v1/agents/:id",
|
|
7414
|
-
|
|
7415
|
-
|
|
7469
|
+
headers: authHeadersSchema,
|
|
7470
|
+
pathParams: z21.object({
|
|
7471
|
+
id: z21.string().min(1, "Agent ID is required")
|
|
7416
7472
|
}),
|
|
7417
7473
|
responses: {
|
|
7418
7474
|
200: publicAgentDetailSchema,
|
|
@@ -7428,8 +7484,9 @@ var publicAgentVersionsContract = c15.router({
|
|
|
7428
7484
|
list: {
|
|
7429
7485
|
method: "GET",
|
|
7430
7486
|
path: "/v1/agents/:id/versions",
|
|
7431
|
-
|
|
7432
|
-
|
|
7487
|
+
headers: authHeadersSchema,
|
|
7488
|
+
pathParams: z21.object({
|
|
7489
|
+
id: z21.string().min(1, "Agent ID is required")
|
|
7433
7490
|
}),
|
|
7434
7491
|
query: listQuerySchema,
|
|
7435
7492
|
responses: {
|
|
@@ -7444,9 +7501,9 @@ var publicAgentVersionsContract = c15.router({
|
|
|
7444
7501
|
});
|
|
7445
7502
|
|
|
7446
7503
|
// ../../packages/core/src/contracts/public/runs.ts
|
|
7447
|
-
import { z as
|
|
7504
|
+
import { z as z22 } from "zod";
|
|
7448
7505
|
var c16 = initContract();
|
|
7449
|
-
var publicRunStatusSchema =
|
|
7506
|
+
var publicRunStatusSchema = z22.enum([
|
|
7450
7507
|
"pending",
|
|
7451
7508
|
"running",
|
|
7452
7509
|
"completed",
|
|
@@ -7454,52 +7511,52 @@ var publicRunStatusSchema = z21.enum([
|
|
|
7454
7511
|
"timeout",
|
|
7455
7512
|
"cancelled"
|
|
7456
7513
|
]);
|
|
7457
|
-
var publicRunSchema =
|
|
7458
|
-
id:
|
|
7459
|
-
agent_id:
|
|
7460
|
-
agent_name:
|
|
7514
|
+
var publicRunSchema = z22.object({
|
|
7515
|
+
id: z22.string(),
|
|
7516
|
+
agent_id: z22.string(),
|
|
7517
|
+
agent_name: z22.string(),
|
|
7461
7518
|
status: publicRunStatusSchema,
|
|
7462
|
-
prompt:
|
|
7519
|
+
prompt: z22.string(),
|
|
7463
7520
|
created_at: timestampSchema,
|
|
7464
7521
|
started_at: timestampSchema.nullable(),
|
|
7465
7522
|
completed_at: timestampSchema.nullable()
|
|
7466
7523
|
});
|
|
7467
7524
|
var publicRunDetailSchema = publicRunSchema.extend({
|
|
7468
|
-
error:
|
|
7469
|
-
execution_time_ms:
|
|
7470
|
-
checkpoint_id:
|
|
7471
|
-
session_id:
|
|
7472
|
-
artifact_name:
|
|
7473
|
-
artifact_version:
|
|
7474
|
-
volumes:
|
|
7525
|
+
error: z22.string().nullable(),
|
|
7526
|
+
execution_time_ms: z22.number().nullable(),
|
|
7527
|
+
checkpoint_id: z22.string().nullable(),
|
|
7528
|
+
session_id: z22.string().nullable(),
|
|
7529
|
+
artifact_name: z22.string().nullable(),
|
|
7530
|
+
artifact_version: z22.string().nullable(),
|
|
7531
|
+
volumes: z22.record(z22.string(), z22.string()).optional()
|
|
7475
7532
|
});
|
|
7476
7533
|
var paginatedRunsSchema = createPaginatedResponseSchema(publicRunSchema);
|
|
7477
|
-
var createRunRequestSchema =
|
|
7534
|
+
var createRunRequestSchema = z22.object({
|
|
7478
7535
|
// Agent identification (one of: agent, agent_id, session_id, checkpoint_id)
|
|
7479
|
-
agent:
|
|
7536
|
+
agent: z22.string().optional(),
|
|
7480
7537
|
// Agent name
|
|
7481
|
-
agent_id:
|
|
7538
|
+
agent_id: z22.string().optional(),
|
|
7482
7539
|
// Agent ID
|
|
7483
|
-
agent_version:
|
|
7540
|
+
agent_version: z22.string().optional(),
|
|
7484
7541
|
// Version specifier (e.g., "latest", "v1", specific ID)
|
|
7485
7542
|
// Continue session
|
|
7486
|
-
session_id:
|
|
7543
|
+
session_id: z22.string().optional(),
|
|
7487
7544
|
// Resume from checkpoint
|
|
7488
|
-
checkpoint_id:
|
|
7545
|
+
checkpoint_id: z22.string().optional(),
|
|
7489
7546
|
// Required
|
|
7490
|
-
prompt:
|
|
7547
|
+
prompt: z22.string().min(1, "Prompt is required"),
|
|
7491
7548
|
// Optional configuration
|
|
7492
|
-
variables:
|
|
7493
|
-
secrets:
|
|
7494
|
-
artifact_name:
|
|
7549
|
+
variables: z22.record(z22.string(), z22.string()).optional(),
|
|
7550
|
+
secrets: z22.record(z22.string(), z22.string()).optional(),
|
|
7551
|
+
artifact_name: z22.string().optional(),
|
|
7495
7552
|
// Artifact name to mount
|
|
7496
|
-
artifact_version:
|
|
7553
|
+
artifact_version: z22.string().optional(),
|
|
7497
7554
|
// Artifact version (defaults to latest)
|
|
7498
|
-
volumes:
|
|
7555
|
+
volumes: z22.record(z22.string(), z22.string()).optional()
|
|
7499
7556
|
// volume_name -> version
|
|
7500
7557
|
});
|
|
7501
7558
|
var runListQuerySchema = listQuerySchema.extend({
|
|
7502
|
-
agent_id:
|
|
7559
|
+
agent_id: z22.string().optional(),
|
|
7503
7560
|
status: publicRunStatusSchema.optional(),
|
|
7504
7561
|
since: timestampSchema.optional()
|
|
7505
7562
|
});
|
|
@@ -7507,6 +7564,7 @@ var publicRunsListContract = c16.router({
|
|
|
7507
7564
|
list: {
|
|
7508
7565
|
method: "GET",
|
|
7509
7566
|
path: "/v1/runs",
|
|
7567
|
+
headers: authHeadersSchema,
|
|
7510
7568
|
query: runListQuerySchema,
|
|
7511
7569
|
responses: {
|
|
7512
7570
|
200: paginatedRunsSchema,
|
|
@@ -7519,6 +7577,7 @@ var publicRunsListContract = c16.router({
|
|
|
7519
7577
|
create: {
|
|
7520
7578
|
method: "POST",
|
|
7521
7579
|
path: "/v1/runs",
|
|
7580
|
+
headers: authHeadersSchema,
|
|
7522
7581
|
body: createRunRequestSchema,
|
|
7523
7582
|
responses: {
|
|
7524
7583
|
202: publicRunDetailSchema,
|
|
@@ -7536,8 +7595,9 @@ var publicRunByIdContract = c16.router({
|
|
|
7536
7595
|
get: {
|
|
7537
7596
|
method: "GET",
|
|
7538
7597
|
path: "/v1/runs/:id",
|
|
7539
|
-
|
|
7540
|
-
|
|
7598
|
+
headers: authHeadersSchema,
|
|
7599
|
+
pathParams: z22.object({
|
|
7600
|
+
id: z22.string().min(1, "Run ID is required")
|
|
7541
7601
|
}),
|
|
7542
7602
|
responses: {
|
|
7543
7603
|
200: publicRunDetailSchema,
|
|
@@ -7553,10 +7613,11 @@ var publicRunCancelContract = c16.router({
|
|
|
7553
7613
|
cancel: {
|
|
7554
7614
|
method: "POST",
|
|
7555
7615
|
path: "/v1/runs/:id/cancel",
|
|
7556
|
-
|
|
7557
|
-
|
|
7616
|
+
headers: authHeadersSchema,
|
|
7617
|
+
pathParams: z22.object({
|
|
7618
|
+
id: z22.string().min(1, "Run ID is required")
|
|
7558
7619
|
}),
|
|
7559
|
-
body:
|
|
7620
|
+
body: z22.undefined(),
|
|
7560
7621
|
responses: {
|
|
7561
7622
|
200: publicRunDetailSchema,
|
|
7562
7623
|
400: publicApiErrorSchema,
|
|
@@ -7569,26 +7630,27 @@ var publicRunCancelContract = c16.router({
|
|
|
7569
7630
|
description: "Cancel a pending or running execution"
|
|
7570
7631
|
}
|
|
7571
7632
|
});
|
|
7572
|
-
var logEntrySchema =
|
|
7633
|
+
var logEntrySchema = z22.object({
|
|
7573
7634
|
timestamp: timestampSchema,
|
|
7574
|
-
type:
|
|
7575
|
-
level:
|
|
7576
|
-
message:
|
|
7577
|
-
metadata:
|
|
7635
|
+
type: z22.enum(["agent", "system", "network"]),
|
|
7636
|
+
level: z22.enum(["debug", "info", "warn", "error"]),
|
|
7637
|
+
message: z22.string(),
|
|
7638
|
+
metadata: z22.record(z22.string(), z22.unknown()).optional()
|
|
7578
7639
|
});
|
|
7579
7640
|
var paginatedLogsSchema = createPaginatedResponseSchema(logEntrySchema);
|
|
7580
7641
|
var logsQuerySchema = listQuerySchema.extend({
|
|
7581
|
-
type:
|
|
7642
|
+
type: z22.enum(["agent", "system", "network", "all"]).default("all"),
|
|
7582
7643
|
since: timestampSchema.optional(),
|
|
7583
7644
|
until: timestampSchema.optional(),
|
|
7584
|
-
order:
|
|
7645
|
+
order: z22.enum(["asc", "desc"]).default("asc")
|
|
7585
7646
|
});
|
|
7586
7647
|
var publicRunLogsContract = c16.router({
|
|
7587
7648
|
getLogs: {
|
|
7588
7649
|
method: "GET",
|
|
7589
7650
|
path: "/v1/runs/:id/logs",
|
|
7590
|
-
|
|
7591
|
-
|
|
7651
|
+
headers: authHeadersSchema,
|
|
7652
|
+
pathParams: z22.object({
|
|
7653
|
+
id: z22.string().min(1, "Run ID is required")
|
|
7592
7654
|
}),
|
|
7593
7655
|
query: logsQuerySchema,
|
|
7594
7656
|
responses: {
|
|
@@ -7601,29 +7663,30 @@ var publicRunLogsContract = c16.router({
|
|
|
7601
7663
|
description: "Get unified logs for a run. Combines agent, system, and network logs."
|
|
7602
7664
|
}
|
|
7603
7665
|
});
|
|
7604
|
-
var metricPointSchema =
|
|
7666
|
+
var metricPointSchema = z22.object({
|
|
7605
7667
|
timestamp: timestampSchema,
|
|
7606
|
-
cpu_percent:
|
|
7607
|
-
memory_used_mb:
|
|
7608
|
-
memory_total_mb:
|
|
7609
|
-
disk_used_mb:
|
|
7610
|
-
disk_total_mb:
|
|
7611
|
-
});
|
|
7612
|
-
var metricsSummarySchema =
|
|
7613
|
-
avg_cpu_percent:
|
|
7614
|
-
max_memory_used_mb:
|
|
7615
|
-
total_duration_ms:
|
|
7616
|
-
});
|
|
7617
|
-
var metricsResponseSchema2 =
|
|
7618
|
-
data:
|
|
7668
|
+
cpu_percent: z22.number(),
|
|
7669
|
+
memory_used_mb: z22.number(),
|
|
7670
|
+
memory_total_mb: z22.number(),
|
|
7671
|
+
disk_used_mb: z22.number(),
|
|
7672
|
+
disk_total_mb: z22.number()
|
|
7673
|
+
});
|
|
7674
|
+
var metricsSummarySchema = z22.object({
|
|
7675
|
+
avg_cpu_percent: z22.number(),
|
|
7676
|
+
max_memory_used_mb: z22.number(),
|
|
7677
|
+
total_duration_ms: z22.number().nullable()
|
|
7678
|
+
});
|
|
7679
|
+
var metricsResponseSchema2 = z22.object({
|
|
7680
|
+
data: z22.array(metricPointSchema),
|
|
7619
7681
|
summary: metricsSummarySchema
|
|
7620
7682
|
});
|
|
7621
7683
|
var publicRunMetricsContract = c16.router({
|
|
7622
7684
|
getMetrics: {
|
|
7623
7685
|
method: "GET",
|
|
7624
7686
|
path: "/v1/runs/:id/metrics",
|
|
7625
|
-
|
|
7626
|
-
|
|
7687
|
+
headers: authHeadersSchema,
|
|
7688
|
+
pathParams: z22.object({
|
|
7689
|
+
id: z22.string().min(1, "Run ID is required")
|
|
7627
7690
|
}),
|
|
7628
7691
|
responses: {
|
|
7629
7692
|
200: metricsResponseSchema2,
|
|
@@ -7635,7 +7698,7 @@ var publicRunMetricsContract = c16.router({
|
|
|
7635
7698
|
description: "Get CPU, memory, and disk metrics for a run"
|
|
7636
7699
|
}
|
|
7637
7700
|
});
|
|
7638
|
-
var sseEventTypeSchema =
|
|
7701
|
+
var sseEventTypeSchema = z22.enum([
|
|
7639
7702
|
"status",
|
|
7640
7703
|
// Run status change
|
|
7641
7704
|
"output",
|
|
@@ -7647,25 +7710,26 @@ var sseEventTypeSchema = z21.enum([
|
|
|
7647
7710
|
"heartbeat"
|
|
7648
7711
|
// Keep-alive
|
|
7649
7712
|
]);
|
|
7650
|
-
var sseEventSchema =
|
|
7713
|
+
var sseEventSchema = z22.object({
|
|
7651
7714
|
event: sseEventTypeSchema,
|
|
7652
|
-
data:
|
|
7653
|
-
id:
|
|
7715
|
+
data: z22.unknown(),
|
|
7716
|
+
id: z22.string().optional()
|
|
7654
7717
|
// For Last-Event-ID reconnection
|
|
7655
7718
|
});
|
|
7656
7719
|
var publicRunEventsContract = c16.router({
|
|
7657
7720
|
streamEvents: {
|
|
7658
7721
|
method: "GET",
|
|
7659
7722
|
path: "/v1/runs/:id/events",
|
|
7660
|
-
|
|
7661
|
-
|
|
7723
|
+
headers: authHeadersSchema,
|
|
7724
|
+
pathParams: z22.object({
|
|
7725
|
+
id: z22.string().min(1, "Run ID is required")
|
|
7662
7726
|
}),
|
|
7663
|
-
query:
|
|
7664
|
-
last_event_id:
|
|
7727
|
+
query: z22.object({
|
|
7728
|
+
last_event_id: z22.string().optional()
|
|
7665
7729
|
// For reconnection
|
|
7666
7730
|
}),
|
|
7667
7731
|
responses: {
|
|
7668
|
-
200:
|
|
7732
|
+
200: z22.any(),
|
|
7669
7733
|
// SSE stream - actual content is text/event-stream
|
|
7670
7734
|
401: publicApiErrorSchema,
|
|
7671
7735
|
404: publicApiErrorSchema,
|
|
@@ -7677,28 +7741,28 @@ var publicRunEventsContract = c16.router({
|
|
|
7677
7741
|
});
|
|
7678
7742
|
|
|
7679
7743
|
// ../../packages/core/src/contracts/public/artifacts.ts
|
|
7680
|
-
import { z as
|
|
7744
|
+
import { z as z23 } from "zod";
|
|
7681
7745
|
var c17 = initContract();
|
|
7682
|
-
var publicArtifactSchema =
|
|
7683
|
-
id:
|
|
7684
|
-
name:
|
|
7685
|
-
current_version_id:
|
|
7686
|
-
size:
|
|
7746
|
+
var publicArtifactSchema = z23.object({
|
|
7747
|
+
id: z23.string(),
|
|
7748
|
+
name: z23.string(),
|
|
7749
|
+
current_version_id: z23.string().nullable(),
|
|
7750
|
+
size: z23.number(),
|
|
7687
7751
|
// Total size in bytes
|
|
7688
|
-
file_count:
|
|
7752
|
+
file_count: z23.number(),
|
|
7689
7753
|
created_at: timestampSchema,
|
|
7690
7754
|
updated_at: timestampSchema
|
|
7691
7755
|
});
|
|
7692
|
-
var artifactVersionSchema =
|
|
7693
|
-
id:
|
|
7756
|
+
var artifactVersionSchema = z23.object({
|
|
7757
|
+
id: z23.string(),
|
|
7694
7758
|
// SHA-256 content hash
|
|
7695
|
-
artifact_id:
|
|
7696
|
-
size:
|
|
7759
|
+
artifact_id: z23.string(),
|
|
7760
|
+
size: z23.number(),
|
|
7697
7761
|
// Size in bytes
|
|
7698
|
-
file_count:
|
|
7699
|
-
message:
|
|
7762
|
+
file_count: z23.number(),
|
|
7763
|
+
message: z23.string().nullable(),
|
|
7700
7764
|
// Optional commit message
|
|
7701
|
-
created_by:
|
|
7765
|
+
created_by: z23.string(),
|
|
7702
7766
|
created_at: timestampSchema
|
|
7703
7767
|
});
|
|
7704
7768
|
var publicArtifactDetailSchema = publicArtifactSchema.extend({
|
|
@@ -7712,6 +7776,7 @@ var publicArtifactsListContract = c17.router({
|
|
|
7712
7776
|
list: {
|
|
7713
7777
|
method: "GET",
|
|
7714
7778
|
path: "/v1/artifacts",
|
|
7779
|
+
headers: authHeadersSchema,
|
|
7715
7780
|
query: listQuerySchema,
|
|
7716
7781
|
responses: {
|
|
7717
7782
|
200: paginatedArtifactsSchema,
|
|
@@ -7726,8 +7791,9 @@ var publicArtifactByIdContract = c17.router({
|
|
|
7726
7791
|
get: {
|
|
7727
7792
|
method: "GET",
|
|
7728
7793
|
path: "/v1/artifacts/:id",
|
|
7729
|
-
|
|
7730
|
-
|
|
7794
|
+
headers: authHeadersSchema,
|
|
7795
|
+
pathParams: z23.object({
|
|
7796
|
+
id: z23.string().min(1, "Artifact ID is required")
|
|
7731
7797
|
}),
|
|
7732
7798
|
responses: {
|
|
7733
7799
|
200: publicArtifactDetailSchema,
|
|
@@ -7743,8 +7809,9 @@ var publicArtifactVersionsContract = c17.router({
|
|
|
7743
7809
|
list: {
|
|
7744
7810
|
method: "GET",
|
|
7745
7811
|
path: "/v1/artifacts/:id/versions",
|
|
7746
|
-
|
|
7747
|
-
|
|
7812
|
+
headers: authHeadersSchema,
|
|
7813
|
+
pathParams: z23.object({
|
|
7814
|
+
id: z23.string().min(1, "Artifact ID is required")
|
|
7748
7815
|
}),
|
|
7749
7816
|
query: listQuerySchema,
|
|
7750
7817
|
responses: {
|
|
@@ -7761,15 +7828,16 @@ var publicArtifactDownloadContract = c17.router({
|
|
|
7761
7828
|
download: {
|
|
7762
7829
|
method: "GET",
|
|
7763
7830
|
path: "/v1/artifacts/:id/download",
|
|
7764
|
-
|
|
7765
|
-
|
|
7831
|
+
headers: authHeadersSchema,
|
|
7832
|
+
pathParams: z23.object({
|
|
7833
|
+
id: z23.string().min(1, "Artifact ID is required")
|
|
7766
7834
|
}),
|
|
7767
|
-
query:
|
|
7768
|
-
version_id:
|
|
7835
|
+
query: z23.object({
|
|
7836
|
+
version_id: z23.string().optional()
|
|
7769
7837
|
// Defaults to current version
|
|
7770
7838
|
}),
|
|
7771
7839
|
responses: {
|
|
7772
|
-
302:
|
|
7840
|
+
302: z23.undefined(),
|
|
7773
7841
|
// Redirect to presigned URL
|
|
7774
7842
|
401: publicApiErrorSchema,
|
|
7775
7843
|
404: publicApiErrorSchema,
|
|
@@ -7781,28 +7849,28 @@ var publicArtifactDownloadContract = c17.router({
|
|
|
7781
7849
|
});
|
|
7782
7850
|
|
|
7783
7851
|
// ../../packages/core/src/contracts/public/volumes.ts
|
|
7784
|
-
import { z as
|
|
7852
|
+
import { z as z24 } from "zod";
|
|
7785
7853
|
var c18 = initContract();
|
|
7786
|
-
var publicVolumeSchema =
|
|
7787
|
-
id:
|
|
7788
|
-
name:
|
|
7789
|
-
current_version_id:
|
|
7790
|
-
size:
|
|
7854
|
+
var publicVolumeSchema = z24.object({
|
|
7855
|
+
id: z24.string(),
|
|
7856
|
+
name: z24.string(),
|
|
7857
|
+
current_version_id: z24.string().nullable(),
|
|
7858
|
+
size: z24.number(),
|
|
7791
7859
|
// Total size in bytes
|
|
7792
|
-
file_count:
|
|
7860
|
+
file_count: z24.number(),
|
|
7793
7861
|
created_at: timestampSchema,
|
|
7794
7862
|
updated_at: timestampSchema
|
|
7795
7863
|
});
|
|
7796
|
-
var volumeVersionSchema =
|
|
7797
|
-
id:
|
|
7864
|
+
var volumeVersionSchema = z24.object({
|
|
7865
|
+
id: z24.string(),
|
|
7798
7866
|
// SHA-256 content hash
|
|
7799
|
-
volume_id:
|
|
7800
|
-
size:
|
|
7867
|
+
volume_id: z24.string(),
|
|
7868
|
+
size: z24.number(),
|
|
7801
7869
|
// Size in bytes
|
|
7802
|
-
file_count:
|
|
7803
|
-
message:
|
|
7870
|
+
file_count: z24.number(),
|
|
7871
|
+
message: z24.string().nullable(),
|
|
7804
7872
|
// Optional commit message
|
|
7805
|
-
created_by:
|
|
7873
|
+
created_by: z24.string(),
|
|
7806
7874
|
created_at: timestampSchema
|
|
7807
7875
|
});
|
|
7808
7876
|
var publicVolumeDetailSchema = publicVolumeSchema.extend({
|
|
@@ -7814,6 +7882,7 @@ var publicVolumesListContract = c18.router({
|
|
|
7814
7882
|
list: {
|
|
7815
7883
|
method: "GET",
|
|
7816
7884
|
path: "/v1/volumes",
|
|
7885
|
+
headers: authHeadersSchema,
|
|
7817
7886
|
query: listQuerySchema,
|
|
7818
7887
|
responses: {
|
|
7819
7888
|
200: paginatedVolumesSchema,
|
|
@@ -7828,8 +7897,9 @@ var publicVolumeByIdContract = c18.router({
|
|
|
7828
7897
|
get: {
|
|
7829
7898
|
method: "GET",
|
|
7830
7899
|
path: "/v1/volumes/:id",
|
|
7831
|
-
|
|
7832
|
-
|
|
7900
|
+
headers: authHeadersSchema,
|
|
7901
|
+
pathParams: z24.object({
|
|
7902
|
+
id: z24.string().min(1, "Volume ID is required")
|
|
7833
7903
|
}),
|
|
7834
7904
|
responses: {
|
|
7835
7905
|
200: publicVolumeDetailSchema,
|
|
@@ -7845,8 +7915,9 @@ var publicVolumeVersionsContract = c18.router({
|
|
|
7845
7915
|
list: {
|
|
7846
7916
|
method: "GET",
|
|
7847
7917
|
path: "/v1/volumes/:id/versions",
|
|
7848
|
-
|
|
7849
|
-
|
|
7918
|
+
headers: authHeadersSchema,
|
|
7919
|
+
pathParams: z24.object({
|
|
7920
|
+
id: z24.string().min(1, "Volume ID is required")
|
|
7850
7921
|
}),
|
|
7851
7922
|
query: listQuerySchema,
|
|
7852
7923
|
responses: {
|
|
@@ -7863,15 +7934,16 @@ var publicVolumeDownloadContract = c18.router({
|
|
|
7863
7934
|
download: {
|
|
7864
7935
|
method: "GET",
|
|
7865
7936
|
path: "/v1/volumes/:id/download",
|
|
7866
|
-
|
|
7867
|
-
|
|
7937
|
+
headers: authHeadersSchema,
|
|
7938
|
+
pathParams: z24.object({
|
|
7939
|
+
id: z24.string().min(1, "Volume ID is required")
|
|
7868
7940
|
}),
|
|
7869
|
-
query:
|
|
7870
|
-
version_id:
|
|
7941
|
+
query: z24.object({
|
|
7942
|
+
version_id: z24.string().optional()
|
|
7871
7943
|
// Defaults to current version
|
|
7872
7944
|
}),
|
|
7873
7945
|
responses: {
|
|
7874
|
-
302:
|
|
7946
|
+
302: z24.undefined(),
|
|
7875
7947
|
// Redirect to presigned URL
|
|
7876
7948
|
401: publicApiErrorSchema,
|
|
7877
7949
|
404: publicApiErrorSchema,
|
|
@@ -9213,10 +9285,10 @@ async function executeJob(context, config, options = {}) {
|
|
|
9213
9285
|
const vsockPath = vm.getVsockPath();
|
|
9214
9286
|
const guest = new VsockClient(vsockPath);
|
|
9215
9287
|
log(`[Executor] Using vsock for guest communication: ${vsockPath}`);
|
|
9216
|
-
log(`[Executor]
|
|
9288
|
+
log(`[Executor] Waiting for guest connection...`);
|
|
9217
9289
|
await withSandboxTiming(
|
|
9218
9290
|
"guest_wait",
|
|
9219
|
-
() => guest.
|
|
9291
|
+
() => guest.waitForGuestConnection(3e4)
|
|
9220
9292
|
);
|
|
9221
9293
|
log(`[Executor] Guest client ready`);
|
|
9222
9294
|
const firewallConfig = context.experimentalFirewall;
|
|
@@ -10240,7 +10312,7 @@ var benchmarkCommand = new Command4("benchmark").description(
|
|
|
10240
10312
|
});
|
|
10241
10313
|
|
|
10242
10314
|
// src/index.ts
|
|
10243
|
-
var version = true ? "3.0.
|
|
10315
|
+
var version = true ? "3.0.3" : "0.1.0";
|
|
10244
10316
|
program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
|
|
10245
10317
|
program.addCommand(startCommand);
|
|
10246
10318
|
program.addCommand(doctorCommand);
|