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