@kanyun-ai-infra/agenthub 1.5.2 → 1.6.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/dist/index.cjs +1232 -636
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +900 -33
- package/dist/index.d.ts +900 -33
- package/dist/index.js +1218 -635
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -107,10 +107,20 @@ __export(index_exports, {
|
|
|
107
107
|
SessionFileResourceSchema: () => SessionFileResourceSchema,
|
|
108
108
|
SessionMemorySubjectDeclarationSchema: () => SessionMemorySubjectDeclarationSchema,
|
|
109
109
|
SessionResourcesSchema: () => SessionResourcesSchema,
|
|
110
|
+
SessionTurnsResource: () => SessionTurnsResource,
|
|
110
111
|
SessionsResource: () => SessionsResource,
|
|
111
112
|
StageSchema: () => StageSchema,
|
|
112
113
|
StageSlotViewSchema: () => StageSlotViewSchema,
|
|
113
114
|
StoredMemorySubjectPolicySchema: () => StoredMemorySubjectPolicySchema,
|
|
115
|
+
TERMINAL_TURN_STATUSES: () => TERMINAL_TURN_STATUSES,
|
|
116
|
+
TURN_LIST_DEFAULT_LIMIT: () => TURN_LIST_DEFAULT_LIMIT,
|
|
117
|
+
TURN_LIST_MAX_LIMIT: () => TURN_LIST_MAX_LIMIT,
|
|
118
|
+
TurnAssistantPartSchema: () => TurnAssistantPartSchema,
|
|
119
|
+
TurnKindSchema: () => TurnKindSchema,
|
|
120
|
+
TurnListQuerySchema: () => TurnListQuerySchema,
|
|
121
|
+
TurnListResponseDataSchema: () => TurnListResponseDataSchema,
|
|
122
|
+
TurnSchema: () => TurnSchema,
|
|
123
|
+
TurnStatusSchema: () => TurnStatusSchema,
|
|
114
124
|
UpdateEnvironmentInputSchema: () => UpdateEnvironmentInputSchema,
|
|
115
125
|
WorkbenchDTOSchema: () => WorkbenchDTOSchema,
|
|
116
126
|
WorkloadStageCanaryResource: () => WorkloadStageCanaryResource,
|
|
@@ -120,9 +130,12 @@ __export(index_exports, {
|
|
|
120
130
|
WriteMemoriesRequestSchema: () => WriteMemoriesRequestSchema,
|
|
121
131
|
WriteMemoriesResultSchema: () => WriteMemoriesResultSchema,
|
|
122
132
|
WriteMemoryItemSchema: () => WriteMemoryItemSchema,
|
|
133
|
+
isTerminalTurnStatus: () => isTerminalTurnStatus,
|
|
123
134
|
pilotPlatformErrorFromResponse: () => pilotPlatformErrorFromResponse,
|
|
124
135
|
platformRevisionPublishToManifest: () => platformRevisionPublishToManifest,
|
|
125
|
-
platformWorkloadCreateToManifest: () => platformWorkloadCreateToManifest
|
|
136
|
+
platformWorkloadCreateToManifest: () => platformWorkloadCreateToManifest,
|
|
137
|
+
toUIMessages: () => toUIMessages,
|
|
138
|
+
turnMessageIds: () => turnMessageIds
|
|
126
139
|
});
|
|
127
140
|
module.exports = __toCommonJS(index_exports);
|
|
128
141
|
|
|
@@ -219,6 +232,8 @@ var import_zod68 = require("zod");
|
|
|
219
232
|
var import_zod69 = require("zod");
|
|
220
233
|
var import_zod70 = require("zod");
|
|
221
234
|
var import_zod71 = require("zod");
|
|
235
|
+
var import_zod72 = require("zod");
|
|
236
|
+
var import_zod73 = require("zod");
|
|
222
237
|
var MODELGATE_VENDOR_TYPES = [
|
|
223
238
|
"anthropic",
|
|
224
239
|
"openai",
|
|
@@ -5172,7 +5187,45 @@ var WorkerProtocolFailedPayloadSchema = import_zod44.z.object({
|
|
|
5172
5187
|
}).strict().refine((p) => p.reason !== "wp_aborted_by_signal" || p.abortContext !== void 0, {
|
|
5173
5188
|
message: "abortContext required when reason = wp_aborted_by_signal"
|
|
5174
5189
|
});
|
|
5190
|
+
var TurnUsageSchema = import_zod44.z.object({
|
|
5191
|
+
/** Whether the provider reported any token counts for this turn. */
|
|
5192
|
+
usageSource: import_zod44.z.enum(["provider", "missing"]),
|
|
5193
|
+
/** Prompt tokens, cache reads/writes included. */
|
|
5194
|
+
inputTokens: import_zod44.z.number().int().nonnegative().optional(),
|
|
5195
|
+
outputTokens: import_zod44.z.number().int().nonnegative().optional(),
|
|
5196
|
+
/** `inputTokens + outputTokens`. */
|
|
5197
|
+
totalTokens: import_zod44.z.number().int().nonnegative().optional(),
|
|
5198
|
+
/** Breakdown of `inputTokens` — cached prompt tokens read back. */
|
|
5199
|
+
cacheReadInputTokens: import_zod44.z.number().int().nonnegative().optional(),
|
|
5200
|
+
/** Breakdown of `inputTokens` — prompt tokens written into the cache. */
|
|
5201
|
+
cacheWriteInputTokens: import_zod44.z.number().int().nonnegative().optional(),
|
|
5202
|
+
/** Provider-stream duration; see the timing note above. */
|
|
5203
|
+
durationMs: import_zod44.z.number().int().nonnegative().optional(),
|
|
5204
|
+
timeToFirstTokenMs: import_zod44.z.number().int().nonnegative().optional(),
|
|
5205
|
+
/** AI SDK `finishReason` of the last step ("stop" / "tool-calls" / …). */
|
|
5206
|
+
finishReason: import_zod44.z.string().min(1).optional(),
|
|
5207
|
+
/** Absent whenever `usageSource === "missing"`. */
|
|
5208
|
+
costUsd: import_zod44.z.number().nonnegative().optional(),
|
|
5209
|
+
/** Which upstream reported `costUsd`; paired with it, absent without it. */
|
|
5210
|
+
costSource: import_zod44.z.literal("claude_code_cli").optional(),
|
|
5211
|
+
/** Provider steps observed in the turn — 2 after a mid-turn stream resume. */
|
|
5212
|
+
stepCount: import_zod44.z.number().int().nonnegative().optional()
|
|
5213
|
+
});
|
|
5175
5214
|
var WorkerProtocolCompletedPayloadSchema = import_zod44.z.record(import_zod44.z.string(), import_zod44.z.unknown());
|
|
5215
|
+
var SessionUsageSummarySchema = import_zod44.z.object({
|
|
5216
|
+
turnsWithUsage: import_zod44.z.number().int().nonnegative(),
|
|
5217
|
+
turnsMissingUsage: import_zod44.z.number().int().nonnegative(),
|
|
5218
|
+
inputTokens: import_zod44.z.number().int().nonnegative(),
|
|
5219
|
+
outputTokens: import_zod44.z.number().int().nonnegative(),
|
|
5220
|
+
totalTokens: import_zod44.z.number().int().nonnegative(),
|
|
5221
|
+
cacheReadInputTokens: import_zod44.z.number().int().nonnegative(),
|
|
5222
|
+
cacheWriteInputTokens: import_zod44.z.number().int().nonnegative(),
|
|
5223
|
+
/** `null` when no contributing turn reported a cost. */
|
|
5224
|
+
costUsd: import_zod44.z.number().nonnegative().nullable(),
|
|
5225
|
+
costSource: import_zod44.z.literal("claude_code_cli").nullable(),
|
|
5226
|
+
/** ISO timestamp of the latest completed turn that contributed usage. */
|
|
5227
|
+
lastUpdatedAt: import_zod44.z.string().nullable()
|
|
5228
|
+
});
|
|
5176
5229
|
var EVENT_TYPE_REGEX = /^([a-z][a-z0-9_]*)\.([a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)?)$/;
|
|
5177
5230
|
var EventTypeSchema = import_zod43.z.string().min(1).max(100, "event_type must not exceed SESSION_EVENT_TYPE_MAX_LENGTH (100)").regex(EVENT_TYPE_REGEX, "event_type must be {domain}.{action} in lowercase snake_case");
|
|
5178
5231
|
var EVENT_DOMAINS = [
|
|
@@ -7358,17 +7411,273 @@ var SessionTurnRequestSchema = import_zod57.z.object({
|
|
|
7358
7411
|
}).strict();
|
|
7359
7412
|
var SessionTurnDispatchedResponseSchema = import_zod57.z.object({
|
|
7360
7413
|
success: import_zod57.z.literal(true),
|
|
7361
|
-
data: import_zod57.z.object({
|
|
7414
|
+
data: import_zod57.z.object({
|
|
7415
|
+
outcome: DispatchOutcomeSchema,
|
|
7416
|
+
turn: import_zod57.z.object({
|
|
7417
|
+
turnId: import_zod57.z.string().min(1),
|
|
7418
|
+
status: import_zod57.z.literal("dispatched")
|
|
7419
|
+
}).optional()
|
|
7420
|
+
})
|
|
7362
7421
|
});
|
|
7363
7422
|
var SessionTurnRevivalResponseSchema = import_zod57.z.object({
|
|
7364
7423
|
success: import_zod57.z.literal(false),
|
|
7365
7424
|
revivalInProgress: import_zod57.z.literal(true),
|
|
7366
7425
|
sessionId: import_zod57.z.string(),
|
|
7367
7426
|
attemptId: import_zod57.z.string(),
|
|
7368
|
-
alreadyReviving: import_zod57.z.boolean().optional(),
|
|
7369
7427
|
turnId: import_zod57.z.string().optional()
|
|
7370
7428
|
});
|
|
7371
|
-
var
|
|
7429
|
+
var TurnStatusSchema = import_zod58.z.enum([
|
|
7430
|
+
"dispatched",
|
|
7431
|
+
"running",
|
|
7432
|
+
"completed",
|
|
7433
|
+
"failed",
|
|
7434
|
+
"rejected",
|
|
7435
|
+
"aborted",
|
|
7436
|
+
"interrupted"
|
|
7437
|
+
]);
|
|
7438
|
+
var TERMINAL_TURN_STATUSES = [
|
|
7439
|
+
"completed",
|
|
7440
|
+
"failed",
|
|
7441
|
+
"rejected",
|
|
7442
|
+
"aborted",
|
|
7443
|
+
"interrupted"
|
|
7444
|
+
];
|
|
7445
|
+
function isTerminalTurnStatus(status) {
|
|
7446
|
+
return TERMINAL_TURN_STATUSES.includes(status);
|
|
7447
|
+
}
|
|
7448
|
+
var TurnKindSchema = import_zod58.z.enum(["prompt", "followup"]);
|
|
7449
|
+
var TurnPhaseSchema = import_zod58.z.enum(["generating", "delivering"]);
|
|
7450
|
+
var AssistantMessageStateSchema = import_zod58.z.enum(["streaming", "complete", "truncated"]);
|
|
7451
|
+
var DeliveryStateSchema = import_zod58.z.enum([
|
|
7452
|
+
"not_started",
|
|
7453
|
+
"in_progress",
|
|
7454
|
+
"completed",
|
|
7455
|
+
"failed",
|
|
7456
|
+
"interrupted"
|
|
7457
|
+
]);
|
|
7458
|
+
var ArtifactBundleStateSchema = import_zod58.z.enum([
|
|
7459
|
+
"collecting",
|
|
7460
|
+
"available",
|
|
7461
|
+
"superseded_by_retry",
|
|
7462
|
+
"rejected"
|
|
7463
|
+
]);
|
|
7464
|
+
var DELIVERY_PROGRESS_STEPS = ["git_push", "create_mr", "upload_artifact"];
|
|
7465
|
+
var DeliveryProgressStepSchema = import_zod58.z.enum(DELIVERY_PROGRESS_STEPS);
|
|
7466
|
+
var TurnAnomalySchema = import_zod58.z.object({
|
|
7467
|
+
code: import_zod58.z.string().min(1),
|
|
7468
|
+
/** `session_events.id` of the row that triggered it, when there is one. */
|
|
7469
|
+
eventId: import_zod58.z.string().optional(),
|
|
7470
|
+
detail: import_zod58.z.string().optional()
|
|
7471
|
+
});
|
|
7472
|
+
var TurnAssistantPartStateSchema = import_zod58.z.enum(["streaming", "done"]);
|
|
7473
|
+
var TurnToolPartStateSchema = import_zod58.z.enum([
|
|
7474
|
+
"input-streaming",
|
|
7475
|
+
"input-available",
|
|
7476
|
+
"output-available",
|
|
7477
|
+
"output-error"
|
|
7478
|
+
]);
|
|
7479
|
+
var TurnAssistantTextPartSchema = import_zod58.z.object({
|
|
7480
|
+
type: import_zod58.z.literal("text"),
|
|
7481
|
+
text: import_zod58.z.string(),
|
|
7482
|
+
state: TurnAssistantPartStateSchema.optional()
|
|
7483
|
+
});
|
|
7484
|
+
var TurnAssistantReasoningPartSchema = import_zod58.z.object({
|
|
7485
|
+
type: import_zod58.z.literal("reasoning"),
|
|
7486
|
+
text: import_zod58.z.string(),
|
|
7487
|
+
state: TurnAssistantPartStateSchema.optional()
|
|
7488
|
+
});
|
|
7489
|
+
var TurnAssistantToolPartSchema = import_zod58.z.object({
|
|
7490
|
+
type: import_zod58.z.literal("dynamic-tool"),
|
|
7491
|
+
toolName: import_zod58.z.string(),
|
|
7492
|
+
toolCallId: import_zod58.z.string(),
|
|
7493
|
+
state: TurnToolPartStateSchema,
|
|
7494
|
+
input: import_zod58.z.unknown().optional(),
|
|
7495
|
+
output: import_zod58.z.unknown().optional(),
|
|
7496
|
+
errorText: import_zod58.z.string().optional()
|
|
7497
|
+
});
|
|
7498
|
+
var TurnAssistantStepPartSchema = import_zod58.z.object({
|
|
7499
|
+
type: import_zod58.z.literal("step-start")
|
|
7500
|
+
});
|
|
7501
|
+
var TurnAssistantPartSchema = import_zod58.z.discriminatedUnion("type", [
|
|
7502
|
+
TurnAssistantTextPartSchema,
|
|
7503
|
+
TurnAssistantReasoningPartSchema,
|
|
7504
|
+
TurnAssistantToolPartSchema,
|
|
7505
|
+
TurnAssistantStepPartSchema
|
|
7506
|
+
]);
|
|
7507
|
+
var TurnUserMessageSchema = import_zod58.z.object({
|
|
7508
|
+
messageId: import_zod58.z.string(),
|
|
7509
|
+
text: import_zod58.z.string(),
|
|
7510
|
+
attachments: import_zod58.z.array(AttachmentMetaSchema),
|
|
7511
|
+
createdAt: import_zod58.z.string()
|
|
7512
|
+
});
|
|
7513
|
+
var TurnAssistantMessageSchema = import_zod58.z.object({
|
|
7514
|
+
messageId: import_zod58.z.string(),
|
|
7515
|
+
state: AssistantMessageStateSchema,
|
|
7516
|
+
parts: import_zod58.z.array(TurnAssistantPartSchema),
|
|
7517
|
+
/** Chunks the fold could not interpret. Non-zero means data loss. */
|
|
7518
|
+
droppedChunks: import_zod58.z.number().int().nonnegative(),
|
|
7519
|
+
/**
|
|
7520
|
+
* `retained` marks an assistant message whose source chunks were deleted by
|
|
7521
|
+
* the event retention sweep: this row IS the record now, and a projection
|
|
7522
|
+
* re-run may add to it but must never blank it (T-INV-9).
|
|
7523
|
+
*/
|
|
7524
|
+
source: import_zod58.z.literal("retained").optional()
|
|
7525
|
+
});
|
|
7526
|
+
var TurnDeliverySchema = import_zod58.z.object({
|
|
7527
|
+
state: DeliveryStateSchema,
|
|
7528
|
+
/** Last observed wire step; `z.string()` so an unknown value still reads. */
|
|
7529
|
+
step: import_zod58.z.string().optional(),
|
|
7530
|
+
attempts: import_zod58.z.number().int().nonnegative(),
|
|
7531
|
+
pullRequestUrl: import_zod58.z.string().optional(),
|
|
7532
|
+
failedReason: import_zod58.z.string().optional(),
|
|
7533
|
+
failedAt: import_zod58.z.string().optional()
|
|
7534
|
+
});
|
|
7535
|
+
var TurnArtifactBundleSchema = import_zod58.z.object({
|
|
7536
|
+
/** Absent for a `rejected` bundle — nothing was uploaded, so there is no row. */
|
|
7537
|
+
artifactId: import_zod58.z.string().optional(),
|
|
7538
|
+
state: ArtifactBundleStateSchema,
|
|
7539
|
+
entryCount: import_zod58.z.number().int().nonnegative(),
|
|
7540
|
+
createdAt: import_zod58.z.string(),
|
|
7541
|
+
reason: import_zod58.z.string().optional()
|
|
7542
|
+
});
|
|
7543
|
+
var TurnArtifactsSchema = import_zod58.z.object({
|
|
7544
|
+
bundles: import_zod58.z.array(TurnArtifactBundleSchema),
|
|
7545
|
+
incrementalHref: import_zod58.z.string(),
|
|
7546
|
+
cumulativeHref: import_zod58.z.string()
|
|
7547
|
+
});
|
|
7548
|
+
var TurnStatusReasonSchema = import_zod58.z.object({
|
|
7549
|
+
code: import_zod58.z.string(),
|
|
7550
|
+
message: import_zod58.z.string()
|
|
7551
|
+
});
|
|
7552
|
+
var TurnAbortRequestSchema = import_zod58.z.object({
|
|
7553
|
+
requestedAt: import_zod58.z.string(),
|
|
7554
|
+
eventId: import_zod58.z.string()
|
|
7555
|
+
});
|
|
7556
|
+
var TurnSeqRangeSchema = import_zod58.z.object({
|
|
7557
|
+
start: import_zod58.z.number().int().nullable(),
|
|
7558
|
+
end: import_zod58.z.number().int().nullable()
|
|
7559
|
+
});
|
|
7560
|
+
var TurnContextStateSchema = import_zod58.z.enum(["live", "compacted"]);
|
|
7561
|
+
var TurnMemoryRecallStateSchema = import_zod58.z.enum([
|
|
7562
|
+
"selected",
|
|
7563
|
+
"empty",
|
|
7564
|
+
"recall_failed",
|
|
7565
|
+
"unavailable",
|
|
7566
|
+
"legacy"
|
|
7567
|
+
]);
|
|
7568
|
+
var TurnSchema = import_zod58.z.object({
|
|
7569
|
+
turnId: import_zod58.z.string(),
|
|
7570
|
+
kind: TurnKindSchema,
|
|
7571
|
+
parentTurnId: import_zod58.z.string().nullable(),
|
|
7572
|
+
/** Pairs the turn with `${kind}:${idempotencyKey}`-shaped side events. */
|
|
7573
|
+
idempotencyKey: import_zod58.z.string(),
|
|
7574
|
+
status: TurnStatusSchema,
|
|
7575
|
+
revival: import_zod58.z.object({ attemptId: import_zod58.z.string() }).optional(),
|
|
7576
|
+
phase: TurnPhaseSchema.optional(),
|
|
7577
|
+
statusReason: TurnStatusReasonSchema.optional(),
|
|
7578
|
+
user: TurnUserMessageSchema,
|
|
7579
|
+
assistant: TurnAssistantMessageSchema.nullable(),
|
|
7580
|
+
delivery: TurnDeliverySchema.nullable(),
|
|
7581
|
+
/**
|
|
7582
|
+
* Returned from P2 on, once `artifacts.turn_id` exists — attribution before
|
|
7583
|
+
* that column is a path regex, and shipping a guessed answer would teach
|
|
7584
|
+
* consumers to trust it. Absent means "not populated yet", never "no
|
|
7585
|
+
* artifacts".
|
|
7586
|
+
*/
|
|
7587
|
+
artifacts: TurnArtifactsSchema.optional(),
|
|
7588
|
+
/**
|
|
7589
|
+
* Returned from P2 on, with the `POST /workspace-snapshot` envelope's
|
|
7590
|
+
* `turnId` (T-INV-6). Absent means "not populated yet"; `null` means this
|
|
7591
|
+
* turn is not the source of the session's current snapshot.
|
|
7592
|
+
*/
|
|
7593
|
+
workspaceSnapshot: import_zod58.z.object({ capturedAt: import_zod58.z.string() }).nullable().optional(),
|
|
7594
|
+
context: import_zod58.z.object({ state: TurnContextStateSchema }),
|
|
7595
|
+
memoryRecall: import_zod58.z.object({ state: TurnMemoryRecallStateSchema }).optional(),
|
|
7596
|
+
abort: TurnAbortRequestSchema.nullable(),
|
|
7597
|
+
seqRange: TurnSeqRangeSchema,
|
|
7598
|
+
traceId: import_zod58.z.string().nullable(),
|
|
7599
|
+
anomalies: import_zod58.z.array(TurnAnomalySchema),
|
|
7600
|
+
dispatchedAt: import_zod58.z.string(),
|
|
7601
|
+
acceptedAt: import_zod58.z.string().optional(),
|
|
7602
|
+
completedAt: import_zod58.z.string().optional()
|
|
7603
|
+
});
|
|
7604
|
+
var TurnListResponseDataSchema = import_zod58.z.object({
|
|
7605
|
+
turns: import_zod58.z.array(TurnSchema),
|
|
7606
|
+
hasMore: import_zod58.z.boolean(),
|
|
7607
|
+
nextCursor: import_zod58.z.string().nullable(),
|
|
7608
|
+
prevCursor: import_zod58.z.string().nullable(),
|
|
7609
|
+
/** Session-wide `max(__seq)`; usable directly as `Last-Event-ID`. */
|
|
7610
|
+
streamCursor: import_zod58.z.number().int().nullable()
|
|
7611
|
+
});
|
|
7612
|
+
var TURN_LIST_DEFAULT_LIMIT = 20;
|
|
7613
|
+
var TURN_LIST_MAX_LIMIT = 100;
|
|
7614
|
+
var TurnListQuerySchema = import_zod58.z.object({
|
|
7615
|
+
limit: import_zod58.z.coerce.number().int().min(1).max(TURN_LIST_MAX_LIMIT).default(TURN_LIST_DEFAULT_LIMIT),
|
|
7616
|
+
order: import_zod58.z.enum(["desc", "asc"]).default("desc"),
|
|
7617
|
+
before: import_zod58.z.string().min(1).optional(),
|
|
7618
|
+
after: import_zod58.z.string().min(1).optional(),
|
|
7619
|
+
/**
|
|
7620
|
+
* Comma-separated status filter, e.g. `status=completed,failed`. Same wire
|
|
7621
|
+
* form as `SessionEventsQuerySchema.types`: every route mount parses its
|
|
7622
|
+
* query via `Object.fromEntries(new URL(url).searchParams)`, which keeps
|
|
7623
|
+
* only the LAST value of a repeated key, so `status=a&status=b` would
|
|
7624
|
+
* silently filter for `b` alone. Each item must be a `TurnStatus`.
|
|
7625
|
+
*/
|
|
7626
|
+
status: import_zod58.z.string().optional().transform((value, ctx) => {
|
|
7627
|
+
if (value === void 0) return void 0;
|
|
7628
|
+
const items = value.split(",").filter((s) => s.length > 0);
|
|
7629
|
+
const parsed = import_zod58.z.array(TurnStatusSchema).safeParse(items);
|
|
7630
|
+
if (!parsed.success) {
|
|
7631
|
+
ctx.addIssue({ code: "custom", message: `unknown turn status in: ${value}` });
|
|
7632
|
+
return import_zod58.z.NEVER;
|
|
7633
|
+
}
|
|
7634
|
+
return parsed.data;
|
|
7635
|
+
}),
|
|
7636
|
+
revivalAttemptId: import_zod58.z.string().uuid().optional()
|
|
7637
|
+
}).refine((q) => !(q.before !== void 0 && q.after !== void 0), {
|
|
7638
|
+
message: "before and after are mutually exclusive",
|
|
7639
|
+
path: ["before"]
|
|
7640
|
+
});
|
|
7641
|
+
function turnMessageIds(turnId) {
|
|
7642
|
+
return { user: `${turnId}:u`, assistant: `${turnId}:a` };
|
|
7643
|
+
}
|
|
7644
|
+
var SESSION_EVENTS_DEFAULT_LIMIT = 100;
|
|
7645
|
+
var SESSION_EVENTS_MAX_LIMIT = 500;
|
|
7646
|
+
var SessionEventsQuerySchema = import_zod59.z.object({
|
|
7647
|
+
afterEventId: import_zod59.z.string().min(1).optional(),
|
|
7648
|
+
limit: import_zod59.z.coerce.number().int().min(1).max(SESSION_EVENTS_MAX_LIMIT).default(SESSION_EVENTS_DEFAULT_LIMIT),
|
|
7649
|
+
turnId: import_zod59.z.string().uuid().optional(),
|
|
7650
|
+
/**
|
|
7651
|
+
* Comma-separated `event_type` values, e.g.
|
|
7652
|
+
* `types=worker_protocol.prompt.dispatched,pilot_coder.chunk`.
|
|
7653
|
+
*
|
|
7654
|
+
* NOT `types=a&types=b` (repeated keys): every route mount parses its
|
|
7655
|
+
* query string via `Object.fromEntries(new URL(request.url).searchParams)`,
|
|
7656
|
+
* which keeps only the LAST value for a repeated key — a `types=a&types=b`
|
|
7657
|
+
* request would silently filter for `b` alone. Comma-separated is the one
|
|
7658
|
+
* form that survives that parsing unchanged.
|
|
7659
|
+
*/
|
|
7660
|
+
types: import_zod59.z.string().optional().transform(
|
|
7661
|
+
(value) => value === void 0 ? void 0 : value.split(",").filter((t) => t.length > 0)
|
|
7662
|
+
)
|
|
7663
|
+
});
|
|
7664
|
+
var SessionEventsPageDataSchema = import_zod59.z.object({
|
|
7665
|
+
events: import_zod59.z.array(SessionEventSchema),
|
|
7666
|
+
hasMore: import_zod59.z.boolean(),
|
|
7667
|
+
/**
|
|
7668
|
+
* Set `true` only when `afterEventId` was given but matched neither the
|
|
7669
|
+
* `event_id` column nor a row's primary key (e.g. the referenced chunk
|
|
7670
|
+
* was pruned by retention) — the response falls back to the first page
|
|
7671
|
+
* instead of the pre-existing silent fallback. Omitted (not `false`)
|
|
7672
|
+
* otherwise.
|
|
7673
|
+
*/
|
|
7674
|
+
cursorReset: import_zod59.z.boolean().optional()
|
|
7675
|
+
});
|
|
7676
|
+
var SessionEventsPageResponseSchema = import_zod59.z.object({
|
|
7677
|
+
success: import_zod59.z.literal(true),
|
|
7678
|
+
data: SessionEventsPageDataSchema
|
|
7679
|
+
});
|
|
7680
|
+
var GatewayErrorCodeSchema = import_zod60.z.enum([
|
|
7372
7681
|
"gateway_invalid_session_token",
|
|
7373
7682
|
"gateway_session_not_found",
|
|
7374
7683
|
"gateway_missing_mcp_target",
|
|
@@ -7411,7 +7720,7 @@ var GatewayErrorCodeSchema = import_zod58.z.enum([
|
|
|
7411
7720
|
"gateway_request_too_large",
|
|
7412
7721
|
"gateway_response_too_large"
|
|
7413
7722
|
]);
|
|
7414
|
-
var WebhookEventTypeSchema =
|
|
7723
|
+
var WebhookEventTypeSchema = import_zod61.z.enum([
|
|
7415
7724
|
/** v1/v2 Run reached terminal `completed`. */
|
|
7416
7725
|
"run.completed",
|
|
7417
7726
|
/** v1/v2 Run reached terminal `failed`. */
|
|
@@ -7444,43 +7753,43 @@ var WebhookEventTypeSchema = import_zod59.z.enum([
|
|
|
7444
7753
|
]);
|
|
7445
7754
|
var WEBHOOK_EVENT_TYPES = WebhookEventTypeSchema.options;
|
|
7446
7755
|
var MAX_WEBHOOK_EVENT_ID_LENGTH = 255;
|
|
7447
|
-
var WebhookEventPayloadSchema =
|
|
7448
|
-
event_id:
|
|
7756
|
+
var WebhookEventPayloadSchema = import_zod61.z.object({
|
|
7757
|
+
event_id: import_zod61.z.string().min(1).max(MAX_WEBHOOK_EVENT_ID_LENGTH),
|
|
7449
7758
|
event_type: WebhookEventTypeSchema,
|
|
7450
7759
|
/** ISO-8601 instant at which the transition was recorded. */
|
|
7451
|
-
occurred_at:
|
|
7452
|
-
project_id:
|
|
7453
|
-
run_id:
|
|
7454
|
-
agent_id:
|
|
7455
|
-
session_id:
|
|
7760
|
+
occurred_at: import_zod61.z.string(),
|
|
7761
|
+
project_id: import_zod61.z.string().uuid(),
|
|
7762
|
+
run_id: import_zod61.z.string().uuid().optional(),
|
|
7763
|
+
agent_id: import_zod61.z.string().uuid().optional(),
|
|
7764
|
+
session_id: import_zod61.z.string().uuid().optional(),
|
|
7456
7765
|
/**
|
|
7457
7766
|
* Worker turn id of a `turn.*` event, paired with `session_id`.
|
|
7458
7767
|
* NOT a uuid: `deriveWorkerTurnId` yields a uuid-v5, but other
|
|
7459
7768
|
* emitters use composite forms (`${kind}:${idempotencyKey}`), so the
|
|
7460
7769
|
* wire type stays an opaque string.
|
|
7461
7770
|
*/
|
|
7462
|
-
turn_id:
|
|
7463
|
-
lifecycle_phase:
|
|
7464
|
-
lifecycle_transition_id:
|
|
7465
|
-
idle_since:
|
|
7466
|
-
grace_deadline:
|
|
7467
|
-
reason:
|
|
7468
|
-
terminate_deadline:
|
|
7469
|
-
}).strict();
|
|
7470
|
-
var WebhookSubscriptionStatusSchema =
|
|
7471
|
-
var CreateWebhookSubscriptionRequestSchema =
|
|
7472
|
-
projectId:
|
|
7771
|
+
turn_id: import_zod61.z.string().min(1).optional(),
|
|
7772
|
+
lifecycle_phase: import_zod61.z.enum(["idle", "terminating", "terminated"]).optional(),
|
|
7773
|
+
lifecycle_transition_id: import_zod61.z.string().uuid().optional(),
|
|
7774
|
+
idle_since: import_zod61.z.string().optional(),
|
|
7775
|
+
grace_deadline: import_zod61.z.string().optional(),
|
|
7776
|
+
reason: import_zod61.z.string().optional(),
|
|
7777
|
+
terminate_deadline: import_zod61.z.string().optional()
|
|
7778
|
+
}).strict();
|
|
7779
|
+
var WebhookSubscriptionStatusSchema = import_zod61.z.enum(["active", "disabled"]);
|
|
7780
|
+
var CreateWebhookSubscriptionRequestSchema = import_zod61.z.object({
|
|
7781
|
+
projectId: import_zod61.z.string().uuid(),
|
|
7473
7782
|
/** Subscriber endpoint. https required outside dev; SSRF-validated. */
|
|
7474
|
-
url:
|
|
7783
|
+
url: import_zod61.z.string().url().max(1024),
|
|
7475
7784
|
/** Event types to deliver. At least one. */
|
|
7476
|
-
events:
|
|
7785
|
+
events: import_zod61.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length),
|
|
7477
7786
|
/** Optional operator note shown in list responses. */
|
|
7478
|
-
description:
|
|
7787
|
+
description: import_zod61.z.string().max(512).optional()
|
|
7479
7788
|
}).strict();
|
|
7480
|
-
var UpdateWebhookSubscriptionRequestSchema =
|
|
7481
|
-
url:
|
|
7482
|
-
events:
|
|
7483
|
-
description:
|
|
7789
|
+
var UpdateWebhookSubscriptionRequestSchema = import_zod61.z.object({
|
|
7790
|
+
url: import_zod61.z.string().url().max(1024).optional(),
|
|
7791
|
+
events: import_zod61.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length).optional(),
|
|
7792
|
+
description: import_zod61.z.string().max(512).nullable().optional(),
|
|
7484
7793
|
/**
|
|
7485
7794
|
* `active` re-enables a subscription that was auto-disabled after
|
|
7486
7795
|
* consecutive failures (resets the failure counter); `disabled`
|
|
@@ -7491,23 +7800,23 @@ var UpdateWebhookSubscriptionRequestSchema = import_zod59.z.object({
|
|
|
7491
7800
|
(data) => data.url !== void 0 || data.events !== void 0 || data.description !== void 0 || data.status !== void 0,
|
|
7492
7801
|
{ message: "At least one of url / events / description / status MUST be provided" }
|
|
7493
7802
|
);
|
|
7494
|
-
var WebhookSubscriptionSchema =
|
|
7495
|
-
id:
|
|
7496
|
-
projectId:
|
|
7497
|
-
url:
|
|
7498
|
-
events:
|
|
7499
|
-
description:
|
|
7803
|
+
var WebhookSubscriptionSchema = import_zod61.z.object({
|
|
7804
|
+
id: import_zod61.z.string().uuid(),
|
|
7805
|
+
projectId: import_zod61.z.string().uuid(),
|
|
7806
|
+
url: import_zod61.z.string(),
|
|
7807
|
+
events: import_zod61.z.array(WebhookEventTypeSchema),
|
|
7808
|
+
description: import_zod61.z.string().nullable(),
|
|
7500
7809
|
status: WebhookSubscriptionStatusSchema,
|
|
7501
|
-
consecutiveFailures:
|
|
7502
|
-
createdBy:
|
|
7503
|
-
createdAt:
|
|
7504
|
-
updatedAt:
|
|
7810
|
+
consecutiveFailures: import_zod61.z.number().int().nonnegative(),
|
|
7811
|
+
createdBy: import_zod61.z.string(),
|
|
7812
|
+
createdAt: import_zod61.z.string(),
|
|
7813
|
+
updatedAt: import_zod61.z.string()
|
|
7505
7814
|
});
|
|
7506
|
-
var WebhookSubscriptionWithSecretSchema =
|
|
7815
|
+
var WebhookSubscriptionWithSecretSchema = import_zod61.z.object({
|
|
7507
7816
|
subscription: WebhookSubscriptionSchema,
|
|
7508
|
-
secret:
|
|
7817
|
+
secret: import_zod61.z.string()
|
|
7509
7818
|
});
|
|
7510
|
-
var WebhookSubscriptionErrorCodeSchema =
|
|
7819
|
+
var WebhookSubscriptionErrorCodeSchema = import_zod61.z.enum([
|
|
7511
7820
|
// 400
|
|
7512
7821
|
"VALIDATION_ERROR",
|
|
7513
7822
|
/** URL failed SSRF policy (non-https, private/loopback/link-local IP…). */
|
|
@@ -7520,125 +7829,125 @@ var WebhookSubscriptionErrorCodeSchema = import_zod59.z.enum([
|
|
|
7520
7829
|
// 500
|
|
7521
7830
|
"INTERNAL_ERROR"
|
|
7522
7831
|
]);
|
|
7523
|
-
var SessionPrewarmingIdentitySchema =
|
|
7524
|
-
projectIdGenerator:
|
|
7525
|
-
claimNameTemplate:
|
|
7526
|
-
idempotencyScopePrefix:
|
|
7527
|
-
}).strict();
|
|
7528
|
-
var SessionPrewarmingSessionTemplateSchema =
|
|
7529
|
-
configValues:
|
|
7530
|
-
metadata:
|
|
7531
|
-
}).strict();
|
|
7532
|
-
var BusinessReadyProbeSchema =
|
|
7533
|
-
endpointName:
|
|
7534
|
-
path:
|
|
7535
|
-
successCodes:
|
|
7536
|
-
timeoutMs:
|
|
7537
|
-
}).strict();
|
|
7538
|
-
var SessionPrewarmingSpecSchema =
|
|
7539
|
-
targetReadyCount:
|
|
7540
|
-
reVerifyIntervalSeconds:
|
|
7541
|
-
warmingTimeoutSeconds:
|
|
7542
|
-
claimingLeaseTtlSeconds:
|
|
7543
|
-
replenishIntervalSeconds:
|
|
7544
|
-
maxConcurrentWarming:
|
|
7832
|
+
var SessionPrewarmingIdentitySchema = import_zod62.z.object({
|
|
7833
|
+
projectIdGenerator: import_zod62.z.literal("nanoid"),
|
|
7834
|
+
claimNameTemplate: import_zod62.z.string().min(1),
|
|
7835
|
+
idempotencyScopePrefix: import_zod62.z.string().min(1)
|
|
7836
|
+
}).strict();
|
|
7837
|
+
var SessionPrewarmingSessionTemplateSchema = import_zod62.z.object({
|
|
7838
|
+
configValues: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.string()),
|
|
7839
|
+
metadata: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.unknown()).optional()
|
|
7840
|
+
}).strict();
|
|
7841
|
+
var BusinessReadyProbeSchema = import_zod62.z.object({
|
|
7842
|
+
endpointName: import_zod62.z.enum(["api", "preview"]),
|
|
7843
|
+
path: import_zod62.z.string().min(1),
|
|
7844
|
+
successCodes: import_zod62.z.array(import_zod62.z.number().int().min(100).max(599)).min(1),
|
|
7845
|
+
timeoutMs: import_zod62.z.number().int().min(500).max(3e4)
|
|
7846
|
+
}).strict();
|
|
7847
|
+
var SessionPrewarmingSpecSchema = import_zod62.z.object({
|
|
7848
|
+
targetReadyCount: import_zod62.z.number().int().min(1).max(50),
|
|
7849
|
+
reVerifyIntervalSeconds: import_zod62.z.number().int().min(60).max(3600),
|
|
7850
|
+
warmingTimeoutSeconds: import_zod62.z.number().int().min(60).max(600),
|
|
7851
|
+
claimingLeaseTtlSeconds: import_zod62.z.number().int().min(10).max(120),
|
|
7852
|
+
replenishIntervalSeconds: import_zod62.z.number().int().min(5).max(300),
|
|
7853
|
+
maxConcurrentWarming: import_zod62.z.number().int().min(1).max(10),
|
|
7545
7854
|
identity: SessionPrewarmingIdentitySchema,
|
|
7546
7855
|
sessionTemplate: SessionPrewarmingSessionTemplateSchema,
|
|
7547
7856
|
businessReadyProbe: BusinessReadyProbeSchema.optional()
|
|
7548
7857
|
}).strict();
|
|
7549
|
-
var AcquireSessionRequestSchema =
|
|
7550
|
-
workloadId:
|
|
7551
|
-
clientMutationId:
|
|
7552
|
-
}).strict();
|
|
7553
|
-
var AcquireSessionResponseSchema =
|
|
7554
|
-
leaseToken:
|
|
7555
|
-
leaseExpiresAt:
|
|
7556
|
-
sessionId:
|
|
7557
|
-
projectId:
|
|
7558
|
-
runtimeClaimName:
|
|
7559
|
-
configValues:
|
|
7858
|
+
var AcquireSessionRequestSchema = import_zod62.z.object({
|
|
7859
|
+
workloadId: import_zod62.z.string().uuid(),
|
|
7860
|
+
clientMutationId: import_zod62.z.string().min(1).max(255)
|
|
7861
|
+
}).strict();
|
|
7862
|
+
var AcquireSessionResponseSchema = import_zod62.z.object({
|
|
7863
|
+
leaseToken: import_zod62.z.string().min(1),
|
|
7864
|
+
leaseExpiresAt: import_zod62.z.string().datetime(),
|
|
7865
|
+
sessionId: import_zod62.z.string().uuid(),
|
|
7866
|
+
projectId: import_zod62.z.string().min(1),
|
|
7867
|
+
runtimeClaimName: import_zod62.z.string().min(1),
|
|
7868
|
+
configValues: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.string()),
|
|
7560
7869
|
// Optional: outbox-protocol workloads (`managed_agent`) expose no public HTTP
|
|
7561
7870
|
// endpoint, so a ready slot is claimable with no `apiUrl`. self_managed
|
|
7562
7871
|
// (rush-app) slots always carry it. Omitted (not null) when absent — mirrors
|
|
7563
7872
|
// `previewUrl`. See `pilot-v2-managed-agent-prewarming.md` § Readiness and
|
|
7564
7873
|
// `SessionPoolService.buildAcquireResponse`.
|
|
7565
|
-
apiUrl:
|
|
7566
|
-
previewUrl:
|
|
7874
|
+
apiUrl: import_zod62.z.string().url().optional(),
|
|
7875
|
+
previewUrl: import_zod62.z.string().url().optional()
|
|
7567
7876
|
}).strict();
|
|
7568
|
-
var FinalizeAcquireRequestSchema =
|
|
7569
|
-
leaseToken:
|
|
7570
|
-
sessionId:
|
|
7571
|
-
clientMutationId:
|
|
7877
|
+
var FinalizeAcquireRequestSchema = import_zod62.z.object({
|
|
7878
|
+
leaseToken: import_zod62.z.string().min(1),
|
|
7879
|
+
sessionId: import_zod62.z.string().uuid(),
|
|
7880
|
+
clientMutationId: import_zod62.z.string().min(1).max(255).optional()
|
|
7572
7881
|
}).strict();
|
|
7573
|
-
var AbortAcquireRequestSchema =
|
|
7574
|
-
leaseToken:
|
|
7575
|
-
sessionId:
|
|
7882
|
+
var AbortAcquireRequestSchema = import_zod62.z.object({
|
|
7883
|
+
leaseToken: import_zod62.z.string().min(1),
|
|
7884
|
+
sessionId: import_zod62.z.string().uuid()
|
|
7576
7885
|
}).strict();
|
|
7577
|
-
var WorkloadLifecycleKindSchema =
|
|
7578
|
-
var WorkloadLifecycleConfigSchema =
|
|
7579
|
-
idleEnabled:
|
|
7580
|
-
idleAfterSeconds:
|
|
7581
|
-
idleGraceSeconds:
|
|
7582
|
-
maxSessionLifetimeMs:
|
|
7886
|
+
var WorkloadLifecycleKindSchema = import_zod63.z.enum(["managed_agent", "self_managed"]);
|
|
7887
|
+
var WorkloadLifecycleConfigSchema = import_zod63.z.object({
|
|
7888
|
+
idleEnabled: import_zod63.z.boolean().nullable(),
|
|
7889
|
+
idleAfterSeconds: import_zod63.z.number().int().min(300).max(86400).nullable(),
|
|
7890
|
+
idleGraceSeconds: import_zod63.z.number().int().min(60).max(3600).nullable(),
|
|
7891
|
+
maxSessionLifetimeMs: import_zod63.z.number().int().min(36e5).max(6048e5).nullable()
|
|
7583
7892
|
}).strict();
|
|
7584
7893
|
var WorkloadLifecycleConfigUpdateSchema = WorkloadLifecycleConfigSchema.partial().strict();
|
|
7585
|
-
var EffectiveWorkloadLifecycleConfigSchema =
|
|
7586
|
-
idleEnabled:
|
|
7587
|
-
idleAfterSeconds:
|
|
7588
|
-
idleGraceSeconds:
|
|
7589
|
-
maxSessionLifetimeMs:
|
|
7590
|
-
}).strict();
|
|
7591
|
-
var WorkloadLifecycleConfigResponseSchema =
|
|
7592
|
-
workloadId:
|
|
7894
|
+
var EffectiveWorkloadLifecycleConfigSchema = import_zod63.z.object({
|
|
7895
|
+
idleEnabled: import_zod63.z.boolean(),
|
|
7896
|
+
idleAfterSeconds: import_zod63.z.number().int().min(300).max(86400),
|
|
7897
|
+
idleGraceSeconds: import_zod63.z.number().int().min(60).max(3600),
|
|
7898
|
+
maxSessionLifetimeMs: import_zod63.z.number().int().min(36e5).max(6048e5)
|
|
7899
|
+
}).strict();
|
|
7900
|
+
var WorkloadLifecycleConfigResponseSchema = import_zod63.z.object({
|
|
7901
|
+
workloadId: import_zod63.z.string().uuid(),
|
|
7593
7902
|
kind: WorkloadLifecycleKindSchema,
|
|
7594
7903
|
config: WorkloadLifecycleConfigSchema,
|
|
7595
7904
|
effective: EffectiveWorkloadLifecycleConfigSchema
|
|
7596
7905
|
}).strict();
|
|
7597
|
-
var OtelJobContextSchema =
|
|
7906
|
+
var OtelJobContextSchema = import_zod64.z.object({
|
|
7598
7907
|
/** W3C Trace Context `traceparent` header value. */
|
|
7599
|
-
traceparent:
|
|
7908
|
+
traceparent: import_zod64.z.string().optional(),
|
|
7600
7909
|
/** W3C Trace Context `tracestate` header value. */
|
|
7601
|
-
tracestate:
|
|
7910
|
+
tracestate: import_zod64.z.string().optional(),
|
|
7602
7911
|
/** W3C Baggage header value. */
|
|
7603
|
-
baggage:
|
|
7912
|
+
baggage: import_zod64.z.string().optional()
|
|
7604
7913
|
}).passthrough();
|
|
7605
|
-
var LifecycleStageNameSchema =
|
|
7606
|
-
var SlotCanarySummarySchema =
|
|
7914
|
+
var LifecycleStageNameSchema = import_zod65.z.enum(["test", "production"]);
|
|
7915
|
+
var SlotCanarySummarySchema = import_zod65.z.object({
|
|
7607
7916
|
/** canary 臂 revision id。 */
|
|
7608
|
-
revisionId:
|
|
7917
|
+
revisionId: import_zod65.z.string(),
|
|
7609
7918
|
/** canary revision 的人可读版本短名;revision 行缺失时 null(降级显示 id 前缀)。 */
|
|
7610
|
-
revisionLabel:
|
|
7919
|
+
revisionLabel: import_zod65.z.string().nullable(),
|
|
7611
7920
|
/** 0..99;0 = 冻结观察态(仅名单命中仍入 canary)。 */
|
|
7612
|
-
percentage:
|
|
7921
|
+
percentage: import_zod65.z.number().int(),
|
|
7613
7922
|
/** ldap 名单人数(徽章"名单 N 人";0 = 无名单)。 */
|
|
7614
|
-
userAllowlistCount:
|
|
7923
|
+
userAllowlistCount: import_zod65.z.number().int(),
|
|
7615
7924
|
/** 本轮灰度开始时间(ISO);存量行无记录时 null。 */
|
|
7616
|
-
startedAt:
|
|
7925
|
+
startedAt: import_zod65.z.string().nullable()
|
|
7617
7926
|
});
|
|
7618
|
-
var SlotSummarySchema =
|
|
7619
|
-
revisionId:
|
|
7927
|
+
var SlotSummarySchema = import_zod65.z.object({
|
|
7928
|
+
revisionId: import_zod65.z.string().nullable(),
|
|
7620
7929
|
/** 人可读的版本标识(revision name/number);无部署时 null。 */
|
|
7621
|
-
revisionLabel:
|
|
7622
|
-
environmentId:
|
|
7623
|
-
environmentName:
|
|
7624
|
-
environmentVersion:
|
|
7930
|
+
revisionLabel: import_zod65.z.string().nullable(),
|
|
7931
|
+
environmentId: import_zod65.z.string().nullable(),
|
|
7932
|
+
environmentName: import_zod65.z.string().nullable(),
|
|
7933
|
+
environmentVersion: import_zod65.z.number().int().nullable(),
|
|
7625
7934
|
/**
|
|
7626
7935
|
* 槽位所指 revision 自带的运行环境(`revisions.runtime_template_id` 及其名字)。
|
|
7627
7936
|
* 槽位 `environmentId` 为 NULL(存量未绑定行)时会话实际跑的就是它——读侧用
|
|
7628
7937
|
* 它兜底显示,不再渲染「内置于版本」伪状态(ENV-R1a)。发布板读模型必带;
|
|
7629
7938
|
* 工作台等其它 SlotSummary 生产方可省略(省略 = 未报告)。
|
|
7630
7939
|
*/
|
|
7631
|
-
revisionEnvironmentId:
|
|
7632
|
-
revisionEnvironmentName:
|
|
7940
|
+
revisionEnvironmentId: import_zod65.z.string().nullable().optional(),
|
|
7941
|
+
revisionEnvironmentName: import_zod65.z.string().nullable().optional(),
|
|
7633
7942
|
/** 槽位最近一次变更时间(ISO);数据缺口约定:仅当前指针,无历史流水。 */
|
|
7634
|
-
updatedAt:
|
|
7943
|
+
updatedAt: import_zod65.z.string().nullable(),
|
|
7635
7944
|
/**
|
|
7636
7945
|
* 活跃灰度摘要(#1214)。目前仅发布板读模型的槽位显式带出(null = 无灰度);
|
|
7637
7946
|
* 工作台等其它 SlotSummary 生产方不带(optional,省略 = 未报告)。
|
|
7638
7947
|
*/
|
|
7639
7948
|
canary: SlotCanarySummarySchema.nullable().optional()
|
|
7640
7949
|
});
|
|
7641
|
-
var WorkbenchStageDriftKindSchema =
|
|
7950
|
+
var WorkbenchStageDriftKindSchema = import_zod65.z.enum([
|
|
7642
7951
|
/** test 指向新于 production(待晋级)。 */
|
|
7643
7952
|
"test_ahead",
|
|
7644
7953
|
/** 只有 test 有部署(从未上过 production)。 */
|
|
@@ -7661,27 +7970,27 @@ var WorkbenchStageDriftKindSchema = import_zod63.z.enum([
|
|
|
7661
7970
|
*/
|
|
7662
7971
|
"diverged"
|
|
7663
7972
|
]);
|
|
7664
|
-
var WorkbenchStageDriftItemSchema =
|
|
7665
|
-
workloadId:
|
|
7666
|
-
workloadName:
|
|
7667
|
-
workloadSlug:
|
|
7973
|
+
var WorkbenchStageDriftItemSchema = import_zod65.z.object({
|
|
7974
|
+
workloadId: import_zod65.z.string(),
|
|
7975
|
+
workloadName: import_zod65.z.string(),
|
|
7976
|
+
workloadSlug: import_zod65.z.string().nullable(),
|
|
7668
7977
|
kind: WorkbenchStageDriftKindSchema,
|
|
7669
7978
|
test: SlotSummarySchema.nullable(),
|
|
7670
7979
|
production: SlotSummarySchema.nullable(),
|
|
7671
7980
|
/** 差异开始的近似时间 = 领先侧槽位的 updatedAt(ISO)。 */
|
|
7672
|
-
since:
|
|
7981
|
+
since: import_zod65.z.string().nullable()
|
|
7673
7982
|
});
|
|
7674
|
-
var WorkbenchRecentChangeKindSchema =
|
|
7983
|
+
var WorkbenchRecentChangeKindSchema = import_zod65.z.enum([
|
|
7675
7984
|
"stage_updated",
|
|
7676
7985
|
"revision_published",
|
|
7677
7986
|
"environment_version_created"
|
|
7678
7987
|
]);
|
|
7679
|
-
var WorkbenchRecentChangeSchema =
|
|
7988
|
+
var WorkbenchRecentChangeSchema = import_zod65.z.object({
|
|
7680
7989
|
kind: WorkbenchRecentChangeKindSchema,
|
|
7681
7990
|
/** 变更主体的可读标题(如 workload 名 / 环境名)。 */
|
|
7682
|
-
subject:
|
|
7991
|
+
subject: import_zod65.z.string(),
|
|
7683
7992
|
/** 主体 id(workloadId / environmentId),用于前端拼详情链接。 */
|
|
7684
|
-
subjectId:
|
|
7993
|
+
subjectId: import_zod65.z.string(),
|
|
7685
7994
|
/**
|
|
7686
7995
|
* workload 类变更(stage_updated / revision_published)的 slug——详情路由
|
|
7687
7996
|
* UUID / slug 双形态均可达,前端优先用可读的 slug 拼链接,缺失时回退
|
|
@@ -7692,26 +8001,26 @@ var WorkbenchRecentChangeSchema = import_zod63.z.object({
|
|
|
7692
8001
|
* agenthub-sdk 对 WorkbenchDTO 的硬 parse)在滚动发版遇到旧产出时
|
|
7693
8002
|
* 降级为无 slug,而不是整个 DTO 校验失败。
|
|
7694
8003
|
*/
|
|
7695
|
-
subjectSlug:
|
|
8004
|
+
subjectSlug: import_zod65.z.string().nullable().optional(),
|
|
7696
8005
|
/** 一句话变更描述(如 "production → rev-12" / "环境 v3 创建")。 */
|
|
7697
|
-
detail:
|
|
7698
|
-
occurredAt:
|
|
8006
|
+
detail: import_zod65.z.string(),
|
|
8007
|
+
occurredAt: import_zod65.z.string()
|
|
7699
8008
|
});
|
|
7700
|
-
var WorkbenchSessionStatsSchema =
|
|
7701
|
-
running:
|
|
7702
|
-
failed24h:
|
|
7703
|
-
total24h:
|
|
8009
|
+
var WorkbenchSessionStatsSchema = import_zod65.z.object({
|
|
8010
|
+
running: import_zod65.z.number().int(),
|
|
8011
|
+
failed24h: import_zod65.z.number().int(),
|
|
8012
|
+
total24h: import_zod65.z.number().int()
|
|
7704
8013
|
});
|
|
7705
|
-
var WorkbenchDTOSchema =
|
|
7706
|
-
workloadCount:
|
|
8014
|
+
var WorkbenchDTOSchema = import_zod65.z.object({
|
|
8015
|
+
workloadCount: import_zod65.z.number().int(),
|
|
7707
8016
|
sessionStats: WorkbenchSessionStatsSchema,
|
|
7708
|
-
stageDrift:
|
|
7709
|
-
recentChanges:
|
|
8017
|
+
stageDrift: import_zod65.z.array(WorkbenchStageDriftItemSchema),
|
|
8018
|
+
recentChanges: import_zod65.z.array(WorkbenchRecentChangeSchema)
|
|
7710
8019
|
});
|
|
7711
|
-
var ReleaseBoardRowSchema =
|
|
7712
|
-
workloadId:
|
|
7713
|
-
workloadName:
|
|
7714
|
-
workloadSlug:
|
|
8020
|
+
var ReleaseBoardRowSchema = import_zod65.z.object({
|
|
8021
|
+
workloadId: import_zod65.z.string(),
|
|
8022
|
+
workloadName: import_zod65.z.string(),
|
|
8023
|
+
workloadSlug: import_zod65.z.string().nullable(),
|
|
7715
8024
|
/**
|
|
7716
8025
|
* @deprecated Workload 当前默认指针(`default_revision_id`,production 部署
|
|
7717
8026
|
* 从写)。指针收敛(2026-08-02)后发布 UI 不再移动它,本字段随删列窗口结束
|
|
@@ -7720,7 +8029,7 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
|
|
|
7720
8029
|
* 新消费方一律读 `latestRevision`(前端回退链 latestRevision ?? defaultRevision
|
|
7721
8030
|
* 只为兼容旧服务端缺字段,不表示两者同义)。
|
|
7722
8031
|
*/
|
|
7723
|
-
defaultRevision:
|
|
8032
|
+
defaultRevision: import_zod65.z.object({ id: import_zod65.z.string(), version: import_zod65.z.string(), createdAt: import_zod65.z.string() }).nullable(),
|
|
7724
8033
|
/**
|
|
7725
8034
|
* Workload 最近发布的 Revision(createdAt 最新;并列时 id 大者,保证确定性)。
|
|
7726
8035
|
* 发布板用它判断"有新版本尚未部署到 test"(latestRevision.id ≠
|
|
@@ -7733,12 +8042,12 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
|
|
|
7733
8042
|
* pendingRevision)一直想要的一致。**optional**:旧服务端的响应没有此字段,
|
|
7734
8043
|
* 新 client 解析须容忍(双向滚动窗口兼容),缺席时回退读 defaultRevision。
|
|
7735
8044
|
*/
|
|
7736
|
-
latestRevision:
|
|
7737
|
-
id:
|
|
7738
|
-
version:
|
|
7739
|
-
createdAt:
|
|
8045
|
+
latestRevision: import_zod65.z.object({
|
|
8046
|
+
id: import_zod65.z.string(),
|
|
8047
|
+
version: import_zod65.z.string(),
|
|
8048
|
+
createdAt: import_zod65.z.string(),
|
|
7740
8049
|
/** 真实发布时间;optional 仅用于新旧服务端滚动窗口兼容。 */
|
|
7741
|
-
publishedAt:
|
|
8050
|
+
publishedAt: import_zod65.z.string().optional()
|
|
7742
8051
|
}).nullable().optional(),
|
|
7743
8052
|
/**
|
|
7744
8053
|
* 用户当前有理由继续使用的 Revision(latestRevision、test、production)中,
|
|
@@ -7746,7 +8055,7 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
|
|
|
7746
8055
|
* latestRevision;具体复制哪份配置由升级弹窗显式选择。optional 仅用于
|
|
7747
8056
|
* 新旧服务端滚动窗口兼容。
|
|
7748
8057
|
*/
|
|
7749
|
-
runtimeUpgradeAvailable:
|
|
8058
|
+
runtimeUpgradeAvailable: import_zod65.z.boolean().optional(),
|
|
7750
8059
|
test: SlotSummarySchema.nullable(),
|
|
7751
8060
|
production: SlotSummarySchema.nullable(),
|
|
7752
8061
|
/**
|
|
@@ -7755,26 +8064,26 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
|
|
|
7755
8064
|
* 都显式绑定时参与比较——任一侧是兜底态(槽位未绑、跑版本自带环境)时
|
|
7756
8065
|
* 没有可比的版本钉。发布板展开面板的环境行高亮与本字段同口径。
|
|
7757
8066
|
*/
|
|
7758
|
-
drift:
|
|
8067
|
+
drift: import_zod65.z.boolean(),
|
|
7759
8068
|
/** 两槽位 updatedAt 的较新者(ISO);均空则 null。 */
|
|
7760
|
-
lastChangedAt:
|
|
7761
|
-
});
|
|
7762
|
-
var ReleaseBoardDTOSchema =
|
|
7763
|
-
rows:
|
|
7764
|
-
});
|
|
7765
|
-
var SessionDiagnosisSessionSchema =
|
|
7766
|
-
id:
|
|
7767
|
-
workloadId:
|
|
7768
|
-
workloadName:
|
|
7769
|
-
workloadSlug:
|
|
7770
|
-
status:
|
|
7771
|
-
lifecyclePhase:
|
|
7772
|
-
model:
|
|
7773
|
-
createdAt:
|
|
7774
|
-
readyAt:
|
|
7775
|
-
endedAt:
|
|
8069
|
+
lastChangedAt: import_zod65.z.string().nullable()
|
|
8070
|
+
});
|
|
8071
|
+
var ReleaseBoardDTOSchema = import_zod65.z.object({
|
|
8072
|
+
rows: import_zod65.z.array(ReleaseBoardRowSchema)
|
|
8073
|
+
});
|
|
8074
|
+
var SessionDiagnosisSessionSchema = import_zod65.z.object({
|
|
8075
|
+
id: import_zod65.z.string(),
|
|
8076
|
+
workloadId: import_zod65.z.string().nullable(),
|
|
8077
|
+
workloadName: import_zod65.z.string().nullable(),
|
|
8078
|
+
workloadSlug: import_zod65.z.string().nullable(),
|
|
8079
|
+
status: import_zod65.z.string(),
|
|
8080
|
+
lifecyclePhase: import_zod65.z.string().nullable(),
|
|
8081
|
+
model: import_zod65.z.string().nullable(),
|
|
8082
|
+
createdAt: import_zod65.z.string(),
|
|
8083
|
+
readyAt: import_zod65.z.string().nullable(),
|
|
8084
|
+
endedAt: import_zod65.z.string().nullable(),
|
|
7776
8085
|
/** 会话创建链路 trace(Octopus 深链"启动 Trace"数据源)。 */
|
|
7777
|
-
rootTraceId:
|
|
8086
|
+
rootTraceId: import_zod65.z.string().nullable(),
|
|
7778
8087
|
/**
|
|
7779
8088
|
* 该会话能不能点进对话面(`/p/<pid>/s/<sid>`)。**由服务端算好下发,前端不要
|
|
7780
8089
|
* 自己按 `usageKind` 重推** —— `usage_kind` 是会话创建时写死的名字、认领后
|
|
@@ -7782,37 +8091,37 @@ var SessionDiagnosisSessionSchema = import_zod63.z.object({
|
|
|
7782
8091
|
* `packages/control-plane/src/session-lifecycle/session-chat-entry.ts`,
|
|
7783
8092
|
* 排障列表的 `chatHref` 走的是同一个函数。
|
|
7784
8093
|
*/
|
|
7785
|
-
canOpenChat:
|
|
8094
|
+
canOpenChat: import_zod65.z.boolean()
|
|
7786
8095
|
});
|
|
7787
|
-
var SessionDiagnosisFailureSchema =
|
|
7788
|
-
kind:
|
|
7789
|
-
message:
|
|
7790
|
-
occurredAt:
|
|
8096
|
+
var SessionDiagnosisFailureSchema = import_zod65.z.object({
|
|
8097
|
+
kind: import_zod65.z.string().nullable(),
|
|
8098
|
+
message: import_zod65.z.string().nullable(),
|
|
8099
|
+
occurredAt: import_zod65.z.string().nullable()
|
|
7791
8100
|
});
|
|
7792
|
-
var SessionDiagnosisEventSchema =
|
|
7793
|
-
id:
|
|
7794
|
-
type:
|
|
8101
|
+
var SessionDiagnosisEventSchema = import_zod65.z.object({
|
|
8102
|
+
id: import_zod65.z.string(),
|
|
8103
|
+
type: import_zod65.z.string(),
|
|
7795
8104
|
/** 该轮 dispatch trace(每条用户消息的 Octopus 深链数据源);非 dispatch 事件为 null。 */
|
|
7796
|
-
traceId:
|
|
7797
|
-
summary:
|
|
7798
|
-
occurredAt:
|
|
8105
|
+
traceId: import_zod65.z.string().nullable(),
|
|
8106
|
+
summary: import_zod65.z.string().nullable(),
|
|
8107
|
+
occurredAt: import_zod65.z.string()
|
|
7799
8108
|
});
|
|
7800
|
-
var SessionDiagnosisSandboxSchema =
|
|
7801
|
-
id:
|
|
7802
|
-
status:
|
|
7803
|
-
expiresAt:
|
|
7804
|
-
createdAt:
|
|
8109
|
+
var SessionDiagnosisSandboxSchema = import_zod65.z.object({
|
|
8110
|
+
id: import_zod65.z.string(),
|
|
8111
|
+
status: import_zod65.z.string(),
|
|
8112
|
+
expiresAt: import_zod65.z.string().nullable(),
|
|
8113
|
+
createdAt: import_zod65.z.string().nullable()
|
|
7805
8114
|
});
|
|
7806
|
-
var SessionDiagnosisDTOSchema =
|
|
8115
|
+
var SessionDiagnosisDTOSchema = import_zod65.z.object({
|
|
7807
8116
|
session: SessionDiagnosisSessionSchema,
|
|
7808
8117
|
failure: SessionDiagnosisFailureSchema.nullable(),
|
|
7809
|
-
events:
|
|
8118
|
+
events: import_zod65.z.array(SessionDiagnosisEventSchema).nullable(),
|
|
7810
8119
|
sandbox: SessionDiagnosisSandboxSchema.nullable(),
|
|
7811
8120
|
// zod v4 infers `z.record(enum, string)` as a FULL `Record` (all keys
|
|
7812
8121
|
// present) instead of v3's `Partial` — but only failing blocks appear here.
|
|
7813
8122
|
// Explicit partial object keeps the v3 inference; runtime behavior matches
|
|
7814
8123
|
// the record form (any key subset accepted, extras rejected).
|
|
7815
|
-
blockErrors:
|
|
8124
|
+
blockErrors: import_zod65.z.object({ failure: import_zod65.z.string(), events: import_zod65.z.string(), sandbox: import_zod65.z.string() }).partial().optional()
|
|
7816
8125
|
});
|
|
7817
8126
|
var PIPELINE_TRIGGERS = ["push", "merge", "manual", "env_change", "rebake"];
|
|
7818
8127
|
var PIPELINE_RUN_STATUSES = [
|
|
@@ -7854,12 +8163,12 @@ var PIPELINE_FULL_FACE_TRIGGERS = Object.keys(PIPELINE_TRIGGER_STAGES).filter((t
|
|
|
7854
8163
|
return set.length === PIPELINE_STEPS.length && PIPELINE_STEPS.every((s) => set.includes(s));
|
|
7855
8164
|
});
|
|
7856
8165
|
var IMAGE_FINGERPRINT_RE = /^fp_[0-9a-f]{64}$/;
|
|
7857
|
-
var BakeInputsSchema =
|
|
7858
|
-
v:
|
|
7859
|
-
fingerprint:
|
|
7860
|
-
baseImage:
|
|
8166
|
+
var BakeInputsSchema = import_zod66.z.object({
|
|
8167
|
+
v: import_zod66.z.literal(1),
|
|
8168
|
+
fingerprint: import_zod66.z.string().regex(IMAGE_FINGERPRINT_RE),
|
|
8169
|
+
baseImage: import_zod66.z.string().min(1),
|
|
7861
8170
|
packages: EnvironmentPackagesSchema.nullable(),
|
|
7862
|
-
generatorVersion:
|
|
8171
|
+
generatorVersion: import_zod66.z.number().int().positive()
|
|
7863
8172
|
}).strict();
|
|
7864
8173
|
var BAKE_IMAGE_BUILD_TIMEOUT_MS = 45 * 60 * 1e3;
|
|
7865
8174
|
var BAKE_MATERIALIZE_WAIT_MS = 30 * 60 * 1e3;
|
|
@@ -7877,7 +8186,7 @@ var FILE_AGENT_REFERENCE_NAME_MAX_LENGTH = 200;
|
|
|
7877
8186
|
var FILE_AGENT_REFERENCE_LIST_MAX_LENGTH = 100;
|
|
7878
8187
|
var FILE_AGENT_PACKAGE_FILE_CHAR_WHITELIST = /^[A-Za-z0-9._/-]+$/;
|
|
7879
8188
|
function packageFilePathSchema(fieldName) {
|
|
7880
|
-
return
|
|
8189
|
+
return import_zod67.z.string().min(1).max(FILE_AGENT_PACKAGE_FILE_PATH_MAX_LENGTH).refine((value) => FILE_AGENT_PACKAGE_FILE_CHAR_WHITELIST.test(value), {
|
|
7881
8190
|
message: `${fieldName} may only contain [A-Za-z0-9._/-]`
|
|
7882
8191
|
}).refine((value) => !value.startsWith("/"), {
|
|
7883
8192
|
message: `${fieldName} must be a relative path`
|
|
@@ -7893,11 +8202,11 @@ function packageFilePathSchema(fieldName) {
|
|
|
7893
8202
|
var FileAgentSystemPromptFileSchema = packageFilePathSchema("systemPromptFile");
|
|
7894
8203
|
var FileAgentSetupScriptFileSchema = packageFilePathSchema("setupScriptFile");
|
|
7895
8204
|
var FILE_AGENT_RUSH_NAME_WHITELIST = /^(@[A-Za-z0-9][A-Za-z0-9._-]*\/)?[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
7896
|
-
var FileAgentReferenceNameSchema =
|
|
8205
|
+
var FileAgentReferenceNameSchema = import_zod67.z.string().min(1).max(FILE_AGENT_REFERENCE_NAME_MAX_LENGTH).refine((value) => FILE_AGENT_RUSH_NAME_WHITELIST.test(value), {
|
|
7897
8206
|
message: "rush registry name must match (@scope/)?name using only [A-Za-z0-9._-] (no spaces or invisible characters)"
|
|
7898
8207
|
});
|
|
7899
8208
|
function platformEntityNameSchema(fieldName) {
|
|
7900
|
-
return
|
|
8209
|
+
return import_zod67.z.string().min(1).max(FILE_AGENT_REFERENCE_NAME_MAX_LENGTH).refine((value) => value.trim() === value, {
|
|
7901
8210
|
message: `${fieldName} name must not have leading or trailing whitespace`
|
|
7902
8211
|
}).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value), {
|
|
7903
8212
|
message: `${fieldName} name must not contain control or invisible format characters`
|
|
@@ -7905,30 +8214,30 @@ function platformEntityNameSchema(fieldName) {
|
|
|
7905
8214
|
}
|
|
7906
8215
|
var FileAgentEnvironmentNameSchema = platformEntityNameSchema("environment");
|
|
7907
8216
|
var FileAgentModelServiceNameSchema = platformEntityNameSchema("modelService");
|
|
7908
|
-
var FileAgentMcpServerEntrySchema =
|
|
8217
|
+
var FileAgentMcpServerEntrySchema = import_zod67.z.union([
|
|
7909
8218
|
ManagedMcpIdSchema,
|
|
7910
|
-
|
|
8219
|
+
import_zod67.z.object({
|
|
7911
8220
|
id: ManagedMcpIdSchema,
|
|
7912
|
-
disabled:
|
|
8221
|
+
disabled: import_zod67.z.boolean().optional()
|
|
7913
8222
|
}).strict()
|
|
7914
8223
|
]);
|
|
7915
8224
|
function mcpEntryId(entry) {
|
|
7916
8225
|
return typeof entry === "string" ? entry : entry.id;
|
|
7917
8226
|
}
|
|
7918
|
-
var FileAgentMcpServerListSchema =
|
|
8227
|
+
var FileAgentMcpServerListSchema = import_zod67.z.array(FileAgentMcpServerEntrySchema).max(FILE_AGENT_REFERENCE_LIST_MAX_LENGTH).refine(
|
|
7919
8228
|
(list) => {
|
|
7920
8229
|
const ids = list.map(mcpEntryId);
|
|
7921
8230
|
return new Set(ids).size === ids.length;
|
|
7922
8231
|
},
|
|
7923
8232
|
{ message: "must not contain duplicate mcpServers entries (compared by id)" }
|
|
7924
8233
|
);
|
|
7925
|
-
var FileAgentClaudeCodeSectionSchema =
|
|
8234
|
+
var FileAgentClaudeCodeSectionSchema = import_zod67.z.object({
|
|
7926
8235
|
entryCommand: ClaudeCodeAgentPackageEntryCommandSchema.optional()
|
|
7927
8236
|
}).strict();
|
|
7928
8237
|
var FileAgentMemorySchema = WorkloadManifestMemorySchema.pick({ enabled: true }).strict();
|
|
7929
|
-
var FileAgentClaudeCodeDefinitionSchema =
|
|
7930
|
-
apiVersion:
|
|
7931
|
-
format:
|
|
8238
|
+
var FileAgentClaudeCodeDefinitionSchema = import_zod67.z.object({
|
|
8239
|
+
apiVersion: import_zod67.z.literal(FILE_AGENT_API_VERSION),
|
|
8240
|
+
format: import_zod67.z.literal("claude_code"),
|
|
7932
8241
|
model: WorkloadManifestModelSchema.optional(),
|
|
7933
8242
|
/**
|
|
7934
8243
|
* **待退场旧入口**(owner 2026-08-11 拍板,见
|
|
@@ -8009,23 +8318,23 @@ var FileAgentClaudeCodeDefinitionSchema = import_zod65.z.object({
|
|
|
8009
8318
|
memory: FileAgentMemorySchema.optional(),
|
|
8010
8319
|
claudeCode: FileAgentClaudeCodeSectionSchema.optional()
|
|
8011
8320
|
}).strict();
|
|
8012
|
-
var FileAgentDefinitionSchema =
|
|
8321
|
+
var FileAgentDefinitionSchema = import_zod67.z.discriminatedUnion("format", [FileAgentClaudeCodeDefinitionSchema]).superRefine((definition, ctx) => {
|
|
8013
8322
|
if (definition.systemPrompt !== void 0 && definition.systemPromptFile !== void 0) {
|
|
8014
8323
|
ctx.addIssue({
|
|
8015
|
-
code:
|
|
8324
|
+
code: import_zod67.z.ZodIssueCode.custom,
|
|
8016
8325
|
path: ["systemPromptFile"],
|
|
8017
8326
|
message: "systemPrompt and systemPromptFile are mutually exclusive (D18)"
|
|
8018
8327
|
});
|
|
8019
8328
|
}
|
|
8020
8329
|
if (definition.setupScript !== void 0 && definition.setupScriptFile !== void 0) {
|
|
8021
8330
|
ctx.addIssue({
|
|
8022
|
-
code:
|
|
8331
|
+
code: import_zod67.z.ZodIssueCode.custom,
|
|
8023
8332
|
path: ["setupScriptFile"],
|
|
8024
8333
|
message: "setupScript and setupScriptFile are mutually exclusive (D21)"
|
|
8025
8334
|
});
|
|
8026
8335
|
}
|
|
8027
8336
|
});
|
|
8028
|
-
var FileAgentErrorCodeSchema =
|
|
8337
|
+
var FileAgentErrorCodeSchema = import_zod67.z.enum([
|
|
8029
8338
|
/** agent.yaml failed schema validation (unknown/reserved key, apiVersion boundary, field shape). */
|
|
8030
8339
|
"FILE_AGENT_INVALID",
|
|
8031
8340
|
/**
|
|
@@ -8071,7 +8380,7 @@ var FileAgentErrorCodeSchema = import_zod65.z.enum([
|
|
|
8071
8380
|
/** Converted output failed `RevisionManifestSchema` — a pipeline-context input is invalid (e.g. a non-endorsed package URL). */
|
|
8072
8381
|
"FILE_AGENT_REVISION_INVALID"
|
|
8073
8382
|
]);
|
|
8074
|
-
var BindProjectRepoRequestSchema =
|
|
8383
|
+
var BindProjectRepoRequestSchema = import_zod68.z.object({
|
|
8075
8384
|
/**
|
|
8076
8385
|
* Project uuid — the ONLY form accepted (#1635). Slugs used to be
|
|
8077
8386
|
* resolved here (exact `slug` column, then derived-from-`name` fallback
|
|
@@ -8080,8 +8389,8 @@ var BindProjectRepoRequestSchema = import_zod66.z.object({
|
|
|
8080
8389
|
* scan was a full-table fallback with no ordering. Identity is uuid-only;
|
|
8081
8390
|
* slugs are display-only and never resolve.
|
|
8082
8391
|
*/
|
|
8083
|
-
project:
|
|
8084
|
-
repoUrl:
|
|
8392
|
+
project: import_zod68.z.string().uuid(),
|
|
8393
|
+
repoUrl: import_zod68.z.string().min(1).max(1024),
|
|
8085
8394
|
/**
|
|
8086
8395
|
* Repoint a project that already names a DIFFERENT repo.
|
|
8087
8396
|
*
|
|
@@ -8090,53 +8399,53 @@ var BindProjectRepoRequestSchema = import_zod66.z.object({
|
|
|
8090
8399
|
* next release publish agent definitions from another repository, under
|
|
8091
8400
|
* the same project, with no visible signal.
|
|
8092
8401
|
*/
|
|
8093
|
-
allowRebind:
|
|
8402
|
+
allowRebind: import_zod68.z.boolean().optional()
|
|
8094
8403
|
}).strict();
|
|
8095
|
-
var BindProjectRepoResponseSchema =
|
|
8096
|
-
|
|
8404
|
+
var BindProjectRepoResponseSchema = import_zod68.z.discriminatedUnion("outcome", [
|
|
8405
|
+
import_zod68.z.object({ outcome: import_zod68.z.literal("bound"), projectId: import_zod68.z.string().uuid(), repoUrl: import_zod68.z.string() }).strict(),
|
|
8097
8406
|
/** Idempotent re-run: already bound to this repo, nothing written. */
|
|
8098
|
-
|
|
8407
|
+
import_zod68.z.object({ outcome: import_zod68.z.literal("unchanged"), projectId: import_zod68.z.string().uuid(), repoUrl: import_zod68.z.string() }).strict()
|
|
8099
8408
|
]);
|
|
8100
|
-
var FileAgentRefKindSchema =
|
|
8101
|
-
var CheckFileAgentRefsQuerySchema =
|
|
8102
|
-
projectId:
|
|
8103
|
-
environment:
|
|
8104
|
-
modelService:
|
|
8409
|
+
var FileAgentRefKindSchema = import_zod68.z.enum(["environment", "modelService", "managedMcp"]);
|
|
8410
|
+
var CheckFileAgentRefsQuerySchema = import_zod68.z.object({
|
|
8411
|
+
projectId: import_zod68.z.string().uuid(),
|
|
8412
|
+
environment: import_zod68.z.string().min(1).max(200).optional(),
|
|
8413
|
+
modelService: import_zod68.z.string().min(1).max(200).optional(),
|
|
8105
8414
|
/**
|
|
8106
8415
|
* `agent.yaml` `mcpServers:` —— 托管 MCP id(`vcrd_*`),已经是 id 而不是名字,
|
|
8107
8416
|
* 所以这里问的是「它在这个项目里存在吗」。上限对齐 `mcpServers` 的列表上限。
|
|
8108
8417
|
*/
|
|
8109
|
-
managedMcpIds:
|
|
8418
|
+
managedMcpIds: import_zod68.z.array(ManagedMcpIdSchema).max(64).optional()
|
|
8110
8419
|
}).strict();
|
|
8111
|
-
var FileAgentRefProblemSchema =
|
|
8420
|
+
var FileAgentRefProblemSchema = import_zod68.z.object({
|
|
8112
8421
|
kind: FileAgentRefKindSchema,
|
|
8113
|
-
name:
|
|
8422
|
+
name: import_zod68.z.string(),
|
|
8114
8423
|
/** Existing names in the project, for a "did you mean" hint (server-capped). */
|
|
8115
|
-
available:
|
|
8424
|
+
available: import_zod68.z.array(import_zod68.z.string())
|
|
8116
8425
|
}).strict();
|
|
8117
|
-
var CheckFileAgentRefsResponseSchema =
|
|
8118
|
-
environmentId:
|
|
8119
|
-
llmProviderRef:
|
|
8426
|
+
var CheckFileAgentRefsResponseSchema = import_zod68.z.object({
|
|
8427
|
+
environmentId: import_zod68.z.string().optional(),
|
|
8428
|
+
llmProviderRef: import_zod68.z.string().optional(),
|
|
8120
8429
|
/** 解析到的 `managedMcpId → 展示名`(发布侧要把名字冻进快照;check 只看 problems)。 */
|
|
8121
|
-
managedMcpDisplayNames:
|
|
8122
|
-
problems:
|
|
8430
|
+
managedMcpDisplayNames: import_zod68.z.record(import_zod68.z.string(), import_zod68.z.string()).optional(),
|
|
8431
|
+
problems: import_zod68.z.array(FileAgentRefProblemSchema)
|
|
8123
8432
|
}).strict();
|
|
8124
|
-
var IssueMcpDevTicketRequestSchema =
|
|
8125
|
-
projectId:
|
|
8433
|
+
var IssueMcpDevTicketRequestSchema = import_zod69.z.object({
|
|
8434
|
+
projectId: import_zod69.z.string().uuid(),
|
|
8126
8435
|
/**
|
|
8127
8436
|
* 人可读的用途标记(典型值:`<agent slug>@<主机名>`)。只为审计与自助排查
|
|
8128
8437
|
* ("我还有几张票在外面"),不参与鉴权。
|
|
8129
8438
|
*/
|
|
8130
|
-
label:
|
|
8439
|
+
label: import_zod69.z.string().min(1).max(200).optional(),
|
|
8131
8440
|
/** 省略 = 服务端默认(一个开发日)。服务端另有 24h 上限。 */
|
|
8132
|
-
ttlSeconds:
|
|
8441
|
+
ttlSeconds: import_zod69.z.number().int().positive().max(24 * 60 * 60).optional()
|
|
8133
8442
|
}).strict();
|
|
8134
|
-
var McpDevTicketTargetSchema =
|
|
8443
|
+
var McpDevTicketTargetSchema = import_zod69.z.object({
|
|
8135
8444
|
managedMcpId: ManagedMcpIdSchema,
|
|
8136
8445
|
/** 展示名 —— 给人看的(提示、报错)。**不是** `.mcp.json` 的键。 */
|
|
8137
|
-
displayName:
|
|
8446
|
+
displayName: import_zod69.z.string(),
|
|
8138
8447
|
/** 真实上游 URL。作为 `X-Pilot-MCP-Target` 头传给 gateway(**不是**凭据)。 */
|
|
8139
|
-
mcpServerUrl:
|
|
8448
|
+
mcpServerUrl: import_zod69.z.string(),
|
|
8140
8449
|
/**
|
|
8141
8450
|
* `.mcp.json` 的**键名**,平台侧创建期定死(`pilot_v2_vault_credentials.
|
|
8142
8451
|
* server_key`)。CLI 必须用它,不许从 `displayName` 现造:LLM 看到的工具名是
|
|
@@ -8151,37 +8460,37 @@ var McpDevTicketTargetSchema = import_zod67.z.object({
|
|
|
8151
8460
|
* 版本 skew 面(老服务端可能回 null → 新 SDK parse 抛错),而收益只是类型更
|
|
8152
8461
|
* 诚实。CLI 侧不该再有 null 分支——那个分支正是这条修复要消灭的东西。
|
|
8153
8462
|
*/
|
|
8154
|
-
serverKey:
|
|
8463
|
+
serverKey: import_zod69.z.string().nullable()
|
|
8155
8464
|
}).strict();
|
|
8156
|
-
var McpDevTicketStdioTargetSchema =
|
|
8465
|
+
var McpDevTicketStdioTargetSchema = import_zod69.z.object({
|
|
8157
8466
|
managedMcpId: ManagedMcpIdSchema,
|
|
8158
8467
|
/**
|
|
8159
8468
|
* `.mcp.json` 的键名。与 remote 的 `serverKey` 在**同一个命名空间**里分配:
|
|
8160
8469
|
* `.mcp.json` 是一张表,stdio 与 remote 的键撞了就是互相覆盖(沙箱冻结侧同
|
|
8161
8470
|
* 此约束,见 `vault-snapshot-freezer`)。
|
|
8162
8471
|
*/
|
|
8163
|
-
serverKey:
|
|
8472
|
+
serverKey: import_zod69.z.string().min(1).max(200),
|
|
8164
8473
|
/** 展示名 —— 给人看的。**不是**键。 */
|
|
8165
|
-
displayName:
|
|
8166
|
-
command:
|
|
8167
|
-
args:
|
|
8474
|
+
displayName: import_zod69.z.string(),
|
|
8475
|
+
command: import_zod69.z.string().min(1).max(500),
|
|
8476
|
+
args: import_zod69.z.array(import_zod69.z.string().max(500)).max(64).optional(),
|
|
8168
8477
|
/** 变量名 → 已渲染的值(`${MCP_...}` 占位符或字面量)。**绝不含明文凭据。** */
|
|
8169
|
-
env:
|
|
8478
|
+
env: import_zod69.z.record(import_zod69.z.string(), import_zod69.z.string()).optional()
|
|
8170
8479
|
}).strict();
|
|
8171
|
-
var IssueMcpDevTicketResponseSchema =
|
|
8480
|
+
var IssueMcpDevTicketResponseSchema = import_zod69.z.object({
|
|
8172
8481
|
/**
|
|
8173
8482
|
* 写进 `.mcp.json` 的 `Authorization: Bearer <token>`。
|
|
8174
8483
|
* **只在这一次响应里出现**,服务端不留明文。
|
|
8175
8484
|
*/
|
|
8176
|
-
token:
|
|
8485
|
+
token: import_zod69.z.string(),
|
|
8177
8486
|
/** 票据的 public id —— 撤销时用它。 */
|
|
8178
|
-
ticketId:
|
|
8487
|
+
ticketId: import_zod69.z.string(),
|
|
8179
8488
|
/** ISO 时间串。 */
|
|
8180
|
-
expiresAt:
|
|
8489
|
+
expiresAt: import_zod69.z.string(),
|
|
8181
8490
|
/** gateway URL(CLI 不该自己猜环境)。 */
|
|
8182
|
-
gatewayUrl:
|
|
8491
|
+
gatewayUrl: import_zod69.z.string(),
|
|
8183
8492
|
/** `remote` 形态 —— 经 gateway 代理,白名单即 `allowedMcpTargets`。 */
|
|
8184
|
-
targets:
|
|
8493
|
+
targets: import_zod69.z.array(McpDevTicketTargetSchema),
|
|
8185
8494
|
/**
|
|
8186
8495
|
* `stdio` 形态 —— 本机子进程,不经 gateway、不进白名单。上限与
|
|
8187
8496
|
* `FrozenStdioMcpListSchema` 对齐(64),两侧同一个上限才不会出现
|
|
@@ -8196,20 +8505,20 @@ var IssueMcpDevTicketResponseSchema = import_zod67.z.object({
|
|
|
8196
8505
|
* 注意输出类型仍是**非可选数组**(`z.infer` 取的是 default 之后的形态),所以
|
|
8197
8506
|
* 消费方不需要写 `?? []` 分支。
|
|
8198
8507
|
*/
|
|
8199
|
-
stdioTargets:
|
|
8508
|
+
stdioTargets: import_zod69.z.array(McpDevTicketStdioTargetSchema).max(64).default([])
|
|
8200
8509
|
}).strict();
|
|
8201
|
-
var RevokeMcpDevTicketResponseSchema =
|
|
8510
|
+
var RevokeMcpDevTicketResponseSchema = import_zod69.z.object({
|
|
8202
8511
|
/** `false` = 本来就不活跃(已撤销/不存在)。撤销是幂等的,两种都算成功。 */
|
|
8203
|
-
revoked:
|
|
8512
|
+
revoked: import_zod69.z.boolean()
|
|
8204
8513
|
}).strict();
|
|
8205
|
-
var DevSecretEnvKeySchema =
|
|
8206
|
-
var ResolveMcpDevSecretsRequestSchema =
|
|
8207
|
-
projectId:
|
|
8514
|
+
var DevSecretEnvKeySchema = import_zod70.z.string().min(1).max(100).regex(/^[A-Z_][A-Z0-9_]*$/, "env key must match ^[A-Z_][A-Z0-9_]*$");
|
|
8515
|
+
var ResolveMcpDevSecretsRequestSchema = import_zod70.z.object({
|
|
8516
|
+
projectId: import_zod70.z.string().uuid(),
|
|
8208
8517
|
/**
|
|
8209
8518
|
* 这个 agent 声明的托管 MCP id。服务端据此推导要解哪些 `sec_*` ——
|
|
8210
8519
|
* 只有 `stdio` 形态有凭据要下发(`remote` 走 gateway,明文不出平台)。
|
|
8211
8520
|
*/
|
|
8212
|
-
managedMcpIds:
|
|
8521
|
+
managedMcpIds: import_zod70.z.array(ManagedMcpIdSchema).max(64).optional(),
|
|
8213
8522
|
/**
|
|
8214
8523
|
* `agent.yaml` 的 `env:` 里指向 secret 的条目:`envKey → sec_*`。
|
|
8215
8524
|
*
|
|
@@ -8218,16 +8527,16 @@ var ResolveMcpDevSecretsRequestSchema = import_zod68.z.object({
|
|
|
8218
8527
|
* `secrets:resolve` 的调用方本来就被授权读本项目任意 secret,所以这不扩大权限;
|
|
8219
8528
|
* 上限在这里是为了让一次请求不能变成"把整个项目扫一遍"的批量导出工具。
|
|
8220
8529
|
*/
|
|
8221
|
-
envSecretRefs:
|
|
8530
|
+
envSecretRefs: import_zod70.z.record(DevSecretEnvKeySchema, SecretPublicIdSchema).refine((refs) => Object.keys(refs).length <= 64, {
|
|
8222
8531
|
message: "envSecretRefs must have at most 64 entries"
|
|
8223
8532
|
}).optional()
|
|
8224
8533
|
}).strict();
|
|
8225
|
-
var ResolveMcpDevSecretsResponseSchema =
|
|
8534
|
+
var ResolveMcpDevSecretsResponseSchema = import_zod70.z.object({
|
|
8226
8535
|
/**
|
|
8227
8536
|
* env 变量名 → **明文**。CLI 只把它放进子进程 env(`.mcp.json` 与 env 文件里
|
|
8228
8537
|
* 都只写 `${VAR}` 占位符),不落盘。
|
|
8229
8538
|
*/
|
|
8230
|
-
values:
|
|
8539
|
+
values: import_zod70.z.record(DevSecretEnvKeySchema, import_zod70.z.string()),
|
|
8231
8540
|
/**
|
|
8232
8541
|
* 声明了但解不出来的 env key(不存在 / 已归档 / 不属于本项目)。
|
|
8233
8542
|
*
|
|
@@ -8235,7 +8544,7 @@ var ResolveMcpDevSecretsResponseSchema = import_zod68.z.object({
|
|
|
8235
8544
|
* `${VAR}` 字面量原样传给 MCP server,于是上游报"token 无效",排查方向被带到
|
|
8236
8545
|
* 上游去,而真实原因是这里少了一个值。
|
|
8237
8546
|
*/
|
|
8238
|
-
missing:
|
|
8547
|
+
missing: import_zod70.z.array(import_zod70.z.string())
|
|
8239
8548
|
}).strict();
|
|
8240
8549
|
var EVAL_SUITE_API_VERSION = "agenthub/v1alpha1";
|
|
8241
8550
|
var EVAL_SUITE_KIND = "EvalSuite";
|
|
@@ -8245,7 +8554,7 @@ var EVAL_MAX_RETRIES = 2;
|
|
|
8245
8554
|
var EVAL_MAX_TURN_BYTES = 32 * 1024;
|
|
8246
8555
|
var EVAL_MAX_FIXTURE_FILE_BYTES = 64 * 1024;
|
|
8247
8556
|
var EVAL_MAX_FIXTURE_TOTAL_BYTES = 512 * 1024;
|
|
8248
|
-
var EvalRunStatusSchema =
|
|
8557
|
+
var EvalRunStatusSchema = import_zod71.z.enum([
|
|
8249
8558
|
"pending",
|
|
8250
8559
|
"running",
|
|
8251
8560
|
"passed",
|
|
@@ -8253,20 +8562,20 @@ var EvalRunStatusSchema = import_zod69.z.enum([
|
|
|
8253
8562
|
"errored",
|
|
8254
8563
|
"cancelled"
|
|
8255
8564
|
]);
|
|
8256
|
-
var EvalCaseVerdictSchema =
|
|
8257
|
-
var EvalGraderStatusSchema =
|
|
8258
|
-
var EvalErrorClassSchema =
|
|
8565
|
+
var EvalCaseVerdictSchema = import_zod71.z.enum(["passed", "failed", "errored"]);
|
|
8566
|
+
var EvalGraderStatusSchema = import_zod71.z.enum(["passed", "failed", "errored", "skipped"]);
|
|
8567
|
+
var EvalErrorClassSchema = import_zod71.z.enum([
|
|
8259
8568
|
"capability_unavailable",
|
|
8260
8569
|
"infrastructure_error",
|
|
8261
8570
|
"indeterminate",
|
|
8262
8571
|
"invalid_definition"
|
|
8263
8572
|
]);
|
|
8264
|
-
var EvalErrorCodeSchema =
|
|
8573
|
+
var EvalErrorCodeSchema = import_zod71.z.enum([
|
|
8265
8574
|
"EVAL_GRADER_CAPABILITY_UNAVAILABLE",
|
|
8266
8575
|
"EVAL_SELF_EVAL_FORBIDDEN"
|
|
8267
8576
|
]);
|
|
8268
8577
|
var EVAL_SCRIPT_STDOUT_TAIL_MAX_BYTES = 64 * 1024;
|
|
8269
|
-
var EvalTriggerSchema =
|
|
8578
|
+
var EvalTriggerSchema = import_zod71.z.enum([
|
|
8270
8579
|
"manual",
|
|
8271
8580
|
"promote_gate",
|
|
8272
8581
|
"cli",
|
|
@@ -8276,51 +8585,51 @@ var EvalTriggerSchema = import_zod69.z.enum([
|
|
|
8276
8585
|
"replay",
|
|
8277
8586
|
"pipeline"
|
|
8278
8587
|
]);
|
|
8279
|
-
var EvalSeveritySchema =
|
|
8280
|
-
var EvalGraderTypeSchema =
|
|
8281
|
-
var EvalPassPolicySchema =
|
|
8282
|
-
var EvalSuitePurposeSchema =
|
|
8588
|
+
var EvalSeveritySchema = import_zod71.z.enum(["gate", "soft"]);
|
|
8589
|
+
var EvalGraderTypeSchema = import_zod71.z.enum(["transcript", "file", "llm", "script"]);
|
|
8590
|
+
var EvalPassPolicySchema = import_zod71.z.enum(["all", "any"]);
|
|
8591
|
+
var EvalSuitePurposeSchema = import_zod71.z.enum(["regression", "capability"]);
|
|
8283
8592
|
var EVAL_SKIP_REASON_MAX = 2048;
|
|
8284
|
-
var EvalSuiteSkipSchema =
|
|
8285
|
-
var EvalSkippedSuiteSchema =
|
|
8286
|
-
var EvalConclusionStatusSchema =
|
|
8593
|
+
var EvalSuiteSkipSchema = import_zod71.z.object({ reason: import_zod71.z.string().min(1).max(EVAL_SKIP_REASON_MAX) }).strict();
|
|
8594
|
+
var EvalSkippedSuiteSchema = import_zod71.z.object({ path: import_zod71.z.string().min(1), reason: import_zod71.z.string().min(1) }).strict();
|
|
8595
|
+
var EvalConclusionStatusSchema = import_zod71.z.enum(["passed", "failed", "errored", "unassessed"]);
|
|
8287
8596
|
var isSafeRelativePath = (p) => !p.startsWith("/") && !p.split("/").includes("..") && !p.split("/").includes(".");
|
|
8288
|
-
var EvalRelativePathSchema =
|
|
8597
|
+
var EvalRelativePathSchema = import_zod71.z.string().min(1).max(255).refine(isSafeRelativePath, {
|
|
8289
8598
|
message: "path must be a relative path without '.' or '..' segments"
|
|
8290
8599
|
});
|
|
8291
|
-
var EvalSlugSchema =
|
|
8600
|
+
var EvalSlugSchema = import_zod71.z.string().regex(/^[a-z0-9-]{1,64}$/, {
|
|
8292
8601
|
message: "must be a slug matching [a-z0-9-]{1,64}"
|
|
8293
8602
|
});
|
|
8294
|
-
var EvalTimesExprSchema =
|
|
8603
|
+
var EvalTimesExprSchema = import_zod71.z.string().regex(/^(>=|<=|=|>|<)?\d+$/, {
|
|
8295
8604
|
message: 'times must match an operator + integer, e.g. ">=1", "=3", "2"'
|
|
8296
8605
|
});
|
|
8297
|
-
var EvalMarkerSchema =
|
|
8298
|
-
evalRunId:
|
|
8606
|
+
var EvalMarkerSchema = import_zod71.z.object({
|
|
8607
|
+
evalRunId: import_zod71.z.string().min(1),
|
|
8299
8608
|
caseId: EvalSlugSchema,
|
|
8300
|
-
trial:
|
|
8301
|
-
}).strict();
|
|
8302
|
-
var EvalPatternRulesSchema =
|
|
8303
|
-
required:
|
|
8304
|
-
forbidden:
|
|
8305
|
-
}).strict();
|
|
8306
|
-
var EvalTranscriptExpectSchema =
|
|
8307
|
-
completed:
|
|
8308
|
-
calledTool:
|
|
8309
|
-
toolOrder:
|
|
8310
|
-
forbiddenTools:
|
|
8311
|
-
calledSubagent:
|
|
8312
|
-
usedNoTools:
|
|
8313
|
-
loadedSkill:
|
|
8314
|
-
maxToolCalls:
|
|
8609
|
+
trial: import_zod71.z.number().int().nonnegative()
|
|
8610
|
+
}).strict();
|
|
8611
|
+
var EvalPatternRulesSchema = import_zod71.z.object({
|
|
8612
|
+
required: import_zod71.z.array(import_zod71.z.string()).optional(),
|
|
8613
|
+
forbidden: import_zod71.z.array(import_zod71.z.string()).optional()
|
|
8614
|
+
}).strict();
|
|
8615
|
+
var EvalTranscriptExpectSchema = import_zod71.z.object({
|
|
8616
|
+
completed: import_zod71.z.boolean().optional(),
|
|
8617
|
+
calledTool: import_zod71.z.object({ name: import_zod71.z.string().min(1), times: EvalTimesExprSchema.optional() }).strict().optional(),
|
|
8618
|
+
toolOrder: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
|
|
8619
|
+
forbiddenTools: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
|
|
8620
|
+
calledSubagent: import_zod71.z.object({ name: import_zod71.z.string().min(1).optional(), times: EvalTimesExprSchema.optional() }).strict().optional(),
|
|
8621
|
+
usedNoTools: import_zod71.z.boolean().optional(),
|
|
8622
|
+
loadedSkill: import_zod71.z.string().min(1).optional(),
|
|
8623
|
+
maxToolCalls: import_zod71.z.number().int().positive().optional(),
|
|
8315
8624
|
commandPatterns: EvalPatternRulesSchema.optional(),
|
|
8316
8625
|
toolInputPatterns: EvalPatternRulesSchema.optional()
|
|
8317
8626
|
}).strict();
|
|
8318
|
-
var EvalTranscriptGraderSchema =
|
|
8319
|
-
type:
|
|
8627
|
+
var EvalTranscriptGraderSchema = import_zod71.z.object({
|
|
8628
|
+
type: import_zod71.z.literal("transcript"),
|
|
8320
8629
|
label: EvalSlugSchema.optional(),
|
|
8321
8630
|
severity: EvalSeveritySchema.optional(),
|
|
8322
8631
|
// 缺省 gate
|
|
8323
|
-
online:
|
|
8632
|
+
online: import_zod71.z.boolean().optional(),
|
|
8324
8633
|
/**
|
|
8325
8634
|
* T2 真·多轮:只对第 `turn` 轮(0-based,指向 `case.turns` 的下标)的轨迹
|
|
8326
8635
|
* 断言——可以表达"第二轮才调用 run_sql"。缺省 = 整个 trial 的合并轨迹
|
|
@@ -8332,79 +8641,79 @@ var EvalTranscriptGraderSchema = import_zod69.z.object({
|
|
|
8332
8641
|
* turns 上下文;单 parse 一个 grader 不带上界,越界到 gradeTranscript
|
|
8333
8642
|
* 才 errored——已知取舍)。
|
|
8334
8643
|
*/
|
|
8335
|
-
turn:
|
|
8644
|
+
turn: import_zod71.z.number().int().min(0).optional(),
|
|
8336
8645
|
expect: EvalTranscriptExpectSchema
|
|
8337
8646
|
}).strict();
|
|
8338
|
-
var EvalFileEntrySchema =
|
|
8647
|
+
var EvalFileEntrySchema = import_zod71.z.object({
|
|
8339
8648
|
path: EvalRelativePathSchema,
|
|
8340
|
-
mustMatch:
|
|
8341
|
-
mustNotMatch:
|
|
8649
|
+
mustMatch: import_zod71.z.array(import_zod71.z.string()).optional(),
|
|
8650
|
+
mustNotMatch: import_zod71.z.array(import_zod71.z.string()).optional()
|
|
8342
8651
|
}).strict();
|
|
8343
|
-
var EvalFileShorthandExpectSchema =
|
|
8344
|
-
includes:
|
|
8345
|
-
equals:
|
|
8346
|
-
matches:
|
|
8652
|
+
var EvalFileShorthandExpectSchema = import_zod71.z.object({
|
|
8653
|
+
includes: import_zod71.z.string().optional(),
|
|
8654
|
+
equals: import_zod71.z.string().optional(),
|
|
8655
|
+
matches: import_zod71.z.string().optional()
|
|
8347
8656
|
// 正则字符串
|
|
8348
8657
|
}).strict();
|
|
8349
|
-
var EvalFileGraderSchema =
|
|
8350
|
-
type:
|
|
8658
|
+
var EvalFileGraderSchema = import_zod71.z.object({
|
|
8659
|
+
type: import_zod71.z.literal("file"),
|
|
8351
8660
|
label: EvalSlugSchema.optional(),
|
|
8352
8661
|
severity: EvalSeveritySchema.optional(),
|
|
8353
8662
|
// 缺省 gate
|
|
8354
|
-
online:
|
|
8663
|
+
online: import_zod71.z.boolean().optional(),
|
|
8355
8664
|
// 多文件形式
|
|
8356
|
-
files:
|
|
8665
|
+
files: import_zod71.z.array(EvalFileEntrySchema).min(1).optional(),
|
|
8357
8666
|
// 简写形式
|
|
8358
8667
|
path: EvalRelativePathSchema.optional(),
|
|
8359
8668
|
expect: EvalFileShorthandExpectSchema.optional()
|
|
8360
8669
|
}).strict();
|
|
8361
|
-
var EvalLlmGraderSchema =
|
|
8362
|
-
type:
|
|
8670
|
+
var EvalLlmGraderSchema = import_zod71.z.object({
|
|
8671
|
+
type: import_zod71.z.literal("llm"),
|
|
8363
8672
|
label: EvalSlugSchema.optional(),
|
|
8364
8673
|
severity: EvalSeveritySchema.optional(),
|
|
8365
8674
|
// 缺省 soft
|
|
8366
|
-
online:
|
|
8675
|
+
online: import_zod71.z.boolean().optional(),
|
|
8367
8676
|
rubric: EvalRelativePathSchema.refine((p) => p.endsWith(".md"), {
|
|
8368
8677
|
message: "rubric must be a relative .md path within the suite"
|
|
8369
8678
|
}),
|
|
8370
|
-
dimensions:
|
|
8371
|
-
threshold:
|
|
8372
|
-
graderVersion:
|
|
8679
|
+
dimensions: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
|
|
8680
|
+
threshold: import_zod71.z.number().min(0).max(1),
|
|
8681
|
+
graderVersion: import_zod71.z.number().int().positive()
|
|
8373
8682
|
}).strict();
|
|
8374
|
-
var EvalScriptExpectSchema =
|
|
8375
|
-
exitCode:
|
|
8683
|
+
var EvalScriptExpectSchema = import_zod71.z.object({
|
|
8684
|
+
exitCode: import_zod71.z.number().int().optional(),
|
|
8376
8685
|
// 缺省 0
|
|
8377
|
-
stdoutIncludes:
|
|
8686
|
+
stdoutIncludes: import_zod71.z.array(import_zod71.z.string()).optional()
|
|
8378
8687
|
}).strict();
|
|
8379
|
-
var EvalScriptGraderSchema =
|
|
8380
|
-
type:
|
|
8688
|
+
var EvalScriptGraderSchema = import_zod71.z.object({
|
|
8689
|
+
type: import_zod71.z.literal("script"),
|
|
8381
8690
|
label: EvalSlugSchema.optional(),
|
|
8382
8691
|
severity: EvalSeveritySchema.optional(),
|
|
8383
8692
|
// 缺省 gate
|
|
8384
|
-
online:
|
|
8385
|
-
run:
|
|
8386
|
-
timeout:
|
|
8693
|
+
online: import_zod71.z.boolean().optional(),
|
|
8694
|
+
run: import_zod71.z.string().min(1),
|
|
8695
|
+
timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
|
|
8387
8696
|
expect: EvalScriptExpectSchema.optional()
|
|
8388
8697
|
}).strict();
|
|
8389
|
-
var EvalGraderSpecSchema =
|
|
8698
|
+
var EvalGraderSpecSchema = import_zod71.z.discriminatedUnion("type", [
|
|
8390
8699
|
EvalTranscriptGraderSchema,
|
|
8391
8700
|
EvalFileGraderSchema,
|
|
8392
8701
|
EvalLlmGraderSchema,
|
|
8393
8702
|
EvalScriptGraderSchema
|
|
8394
8703
|
]);
|
|
8395
|
-
var EvalFixtureWorkspaceSchema =
|
|
8396
|
-
repo:
|
|
8397
|
-
ref:
|
|
8704
|
+
var EvalFixtureWorkspaceSchema = import_zod71.z.object({
|
|
8705
|
+
repo: import_zod71.z.string().url(),
|
|
8706
|
+
ref: import_zod71.z.string().min(1)
|
|
8398
8707
|
}).strict();
|
|
8399
|
-
var EvalFixtureFileSchema =
|
|
8708
|
+
var EvalFixtureFileSchema = import_zod71.z.object({
|
|
8400
8709
|
path: EvalRelativePathSchema,
|
|
8401
|
-
content:
|
|
8710
|
+
content: import_zod71.z.string()
|
|
8402
8711
|
}).strict();
|
|
8403
|
-
var EvalFixturesSchema =
|
|
8712
|
+
var EvalFixturesSchema = import_zod71.z.object({
|
|
8404
8713
|
workspace: EvalFixtureWorkspaceSchema.optional(),
|
|
8405
|
-
files:
|
|
8714
|
+
files: import_zod71.z.array(EvalFixtureFileSchema).optional()
|
|
8406
8715
|
}).strict();
|
|
8407
|
-
var EvalAgentOverridesSchema =
|
|
8716
|
+
var EvalAgentOverridesSchema = import_zod71.z.object({
|
|
8408
8717
|
/**
|
|
8409
8718
|
* 覆盖被测 agent 的模型。**被测 model 是 case 级可变的**:最终生效值 =
|
|
8410
8719
|
* `agentOverrides.model ?? agent 默认 model`,故同一份卷不同 case 的被测
|
|
@@ -8417,7 +8726,7 @@ var EvalAgentOverridesSchema = import_zod69.z.object({
|
|
|
8417
8726
|
* 先经 ModelGate 归一为 canonical id 再比较——**需运行时上下文,故不在本零依赖
|
|
8418
8727
|
* 契约层做,留给 T3/T4 resolve 层的 400**。
|
|
8419
8728
|
*/
|
|
8420
|
-
model:
|
|
8729
|
+
model: import_zod71.z.string().min(1).optional(),
|
|
8421
8730
|
/**
|
|
8422
8731
|
* T1 语义(减法白名单):把 revision 解析出的 skills **收窄**为名单内的
|
|
8423
8732
|
* 子集(按 `EnabledSkill.rushSkillName` 匹配——即 agent skills.json 里写的
|
|
@@ -8426,42 +8735,42 @@ var EvalAgentOverridesSchema = import_zod69.z.object({
|
|
|
8426
8735
|
* agent,是假红灯)。**不能加塞** revision 未声明的 skill——eval 测的是
|
|
8427
8736
|
* 「已发布的 agent」,不是「一个不存在的配置」。
|
|
8428
8737
|
*/
|
|
8429
|
-
skills:
|
|
8738
|
+
skills: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
|
|
8430
8739
|
/**
|
|
8431
8740
|
* T1 语义(减法白名单):把 revision 解析出的 mcpServers **收窄**为名单内
|
|
8432
8741
|
* 的子集(按 runtime `.mcp.json` 的 server 键名匹配,即 agent 实际运行的
|
|
8433
8742
|
* server 名)。匹配规则与 fail-loud 姿态同 `skills`。stdio transport 的
|
|
8434
8743
|
* server 仍受 `allowStdioMcp` 总闸约束(默认不注入)。
|
|
8435
8744
|
*/
|
|
8436
|
-
mcpServers:
|
|
8745
|
+
mcpServers: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
|
|
8437
8746
|
/**
|
|
8438
8747
|
* T1 语义:追加在被测 agent 冻结 systemPrompt 之后的指令块(`\n\n` 拼接),
|
|
8439
8748
|
* 例如注入 case 特有的输出格式要求。不能替换(替换 = 测别的 agent)。
|
|
8440
8749
|
*/
|
|
8441
|
-
systemPromptAppend:
|
|
8750
|
+
systemPromptAppend: import_zod71.z.string().optional()
|
|
8442
8751
|
}).strict();
|
|
8443
|
-
var EvalCaseOriginSchema =
|
|
8444
|
-
sessionId:
|
|
8445
|
-
capturedAt:
|
|
8752
|
+
var EvalCaseOriginSchema = import_zod71.z.object({
|
|
8753
|
+
sessionId: import_zod71.z.string().min(1),
|
|
8754
|
+
capturedAt: import_zod71.z.string().min(1)
|
|
8446
8755
|
}).strict();
|
|
8447
|
-
var EvalCaseSchema =
|
|
8756
|
+
var EvalCaseSchema = import_zod71.z.object({
|
|
8448
8757
|
id: EvalSlugSchema,
|
|
8449
|
-
description:
|
|
8450
|
-
turns:
|
|
8758
|
+
description: import_zod71.z.string().optional(),
|
|
8759
|
+
turns: import_zod71.z.array(import_zod71.z.object({ user: import_zod71.z.string().min(1) }).strict()).min(1),
|
|
8451
8760
|
fixtures: EvalFixturesSchema.optional(),
|
|
8452
8761
|
agentOverrides: EvalAgentOverridesSchema.optional(),
|
|
8453
|
-
timeout:
|
|
8454
|
-
maxRetries:
|
|
8455
|
-
trials:
|
|
8762
|
+
timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
|
|
8763
|
+
maxRetries: import_zod71.z.number().int().min(0).max(EVAL_MAX_RETRIES).optional(),
|
|
8764
|
+
trials: import_zod71.z.number().int().min(1).max(EVAL_MAX_TRIALS).optional(),
|
|
8456
8765
|
// U1,默认 1
|
|
8457
8766
|
passPolicy: EvalPassPolicySchema.optional(),
|
|
8458
8767
|
// U1,缺省按 purpose
|
|
8459
8768
|
origin: EvalCaseOriginSchema.optional(),
|
|
8460
|
-
allowStdioMcp:
|
|
8769
|
+
allowStdioMcp: import_zod71.z.boolean().optional(),
|
|
8461
8770
|
// 默认 false(§2.1.1 副作用面)
|
|
8462
|
-
graders:
|
|
8771
|
+
graders: import_zod71.z.array(EvalGraderSpecSchema).min(1)
|
|
8463
8772
|
}).strict();
|
|
8464
|
-
var EvalSuiteDefaultsSchema =
|
|
8773
|
+
var EvalSuiteDefaultsSchema = import_zod71.z.object({
|
|
8465
8774
|
/**
|
|
8466
8775
|
* llm grader 的裁判模型。**仅 suite 级、不可 case/grader 级覆盖**(也不在
|
|
8467
8776
|
* `EvalAgentOverridesSchema` 白名单里)。
|
|
@@ -8483,27 +8792,27 @@ var EvalSuiteDefaultsSchema = import_zod69.z.object({
|
|
|
8483
8792
|
* 兑现留给 T7(llm grader 实现),届时大概率取当时最合适的 judge 且做成运行面
|
|
8484
8793
|
* 可配置,而非硬编码进契约。
|
|
8485
8794
|
*/
|
|
8486
|
-
judgeModel:
|
|
8487
|
-
timeout:
|
|
8488
|
-
maxConcurrency:
|
|
8795
|
+
judgeModel: import_zod71.z.string().min(1).optional(),
|
|
8796
|
+
timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
|
|
8797
|
+
maxConcurrency: import_zod71.z.number().int().positive().optional()
|
|
8489
8798
|
}).strict();
|
|
8490
8799
|
var byteLen = (s) => new TextEncoder().encode(s).length;
|
|
8491
|
-
var EvalSuiteSchema =
|
|
8492
|
-
apiVersion:
|
|
8493
|
-
kind:
|
|
8800
|
+
var EvalSuiteSchema = import_zod71.z.object({
|
|
8801
|
+
apiVersion: import_zod71.z.literal(EVAL_SUITE_API_VERSION),
|
|
8802
|
+
kind: import_zod71.z.literal(EVAL_SUITE_KIND),
|
|
8494
8803
|
purpose: EvalSuitePurposeSchema.optional(),
|
|
8495
8804
|
// U2,默认 regression
|
|
8496
8805
|
skip: EvalSuiteSkipSchema.optional(),
|
|
8497
8806
|
// §4 声明跳过(带必填理由)
|
|
8498
8807
|
defaults: EvalSuiteDefaultsSchema.optional(),
|
|
8499
|
-
cases:
|
|
8808
|
+
cases: import_zod71.z.array(EvalCaseSchema).min(1)
|
|
8500
8809
|
}).strict().superRefine((suite, ctx) => {
|
|
8501
8810
|
const seen = /* @__PURE__ */ new Set();
|
|
8502
8811
|
suite.cases.forEach((c, ci) => {
|
|
8503
8812
|
var _a, _b;
|
|
8504
8813
|
if (seen.has(c.id)) {
|
|
8505
8814
|
ctx.addIssue({
|
|
8506
|
-
code:
|
|
8815
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8507
8816
|
path: ["cases", ci, "id"],
|
|
8508
8817
|
message: `duplicate case id "${c.id}" (must be unique within suite)`
|
|
8509
8818
|
});
|
|
@@ -8512,7 +8821,7 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8512
8821
|
c.turns.forEach((t, ti) => {
|
|
8513
8822
|
if (byteLen(t.user) > EVAL_MAX_TURN_BYTES) {
|
|
8514
8823
|
ctx.addIssue({
|
|
8515
|
-
code:
|
|
8824
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8516
8825
|
path: ["cases", ci, "turns", ti, "user"],
|
|
8517
8826
|
message: `turn exceeds ${EVAL_MAX_TURN_BYTES} bytes`
|
|
8518
8827
|
});
|
|
@@ -8524,7 +8833,7 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8524
8833
|
fixtureTotal += size;
|
|
8525
8834
|
if (size > EVAL_MAX_FIXTURE_FILE_BYTES) {
|
|
8526
8835
|
ctx.addIssue({
|
|
8527
|
-
code:
|
|
8836
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8528
8837
|
path: ["cases", ci, "fixtures", "files", fi, "content"],
|
|
8529
8838
|
message: `fixture file exceeds ${EVAL_MAX_FIXTURE_FILE_BYTES} bytes`
|
|
8530
8839
|
});
|
|
@@ -8532,7 +8841,7 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8532
8841
|
});
|
|
8533
8842
|
if (fixtureTotal > EVAL_MAX_FIXTURE_TOTAL_BYTES) {
|
|
8534
8843
|
ctx.addIssue({
|
|
8535
|
-
code:
|
|
8844
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8536
8845
|
path: ["cases", ci, "fixtures", "files"],
|
|
8537
8846
|
message: `fixture files total exceeds ${EVAL_MAX_FIXTURE_TOTAL_BYTES} bytes`
|
|
8538
8847
|
});
|
|
@@ -8543,7 +8852,7 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8543
8852
|
const hasShorthand = g.path != null && g.expect != null;
|
|
8544
8853
|
if (hasFiles === hasShorthand) {
|
|
8545
8854
|
ctx.addIssue({
|
|
8546
|
-
code:
|
|
8855
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8547
8856
|
path: ["cases", ci, "graders", gi],
|
|
8548
8857
|
message: "file grader must use either `files[]` or `{path, expect}`, not both/neither"
|
|
8549
8858
|
});
|
|
@@ -8551,7 +8860,7 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8551
8860
|
}
|
|
8552
8861
|
if (g.type === "transcript" && g.turn != null && g.turn >= c.turns.length) {
|
|
8553
8862
|
ctx.addIssue({
|
|
8554
|
-
code:
|
|
8863
|
+
code: import_zod71.z.ZodIssueCode.custom,
|
|
8555
8864
|
path: ["cases", ci, "graders", gi, "turn"],
|
|
8556
8865
|
message: `transcript grader turn=${g.turn} is out of range (case has ${c.turns.length} turn(s); 0-based)`
|
|
8557
8866
|
});
|
|
@@ -8559,90 +8868,90 @@ var EvalSuiteSchema = import_zod69.z.object({
|
|
|
8559
8868
|
});
|
|
8560
8869
|
});
|
|
8561
8870
|
});
|
|
8562
|
-
var ScriptEvidenceSchema =
|
|
8563
|
-
|
|
8564
|
-
kind:
|
|
8871
|
+
var ScriptEvidenceSchema = import_zod71.z.discriminatedUnion("kind", [
|
|
8872
|
+
import_zod71.z.object({
|
|
8873
|
+
kind: import_zod71.z.literal("executed"),
|
|
8565
8874
|
// A1
|
|
8566
|
-
exitCode:
|
|
8567
|
-
stdoutTailRef:
|
|
8875
|
+
exitCode: import_zod71.z.number().int(),
|
|
8876
|
+
stdoutTailRef: import_zod71.z.string().optional(),
|
|
8568
8877
|
// 超限内容走 OSS ref
|
|
8569
|
-
durationMs:
|
|
8878
|
+
durationMs: import_zod71.z.number().int().nonnegative()
|
|
8570
8879
|
}).strict(),
|
|
8571
|
-
|
|
8572
|
-
kind:
|
|
8880
|
+
import_zod71.z.object({
|
|
8881
|
+
kind: import_zod71.z.literal("capability_unavailable"),
|
|
8573
8882
|
// A0
|
|
8574
|
-
capability:
|
|
8575
|
-
phase:
|
|
8883
|
+
capability: import_zod71.z.literal("script_grader"),
|
|
8884
|
+
phase: import_zod71.z.literal("A0")
|
|
8576
8885
|
}).strict()
|
|
8577
8886
|
]);
|
|
8578
|
-
var EvalGraderEvidenceSchema =
|
|
8579
|
-
|
|
8580
|
-
type:
|
|
8581
|
-
matchedEventIds:
|
|
8582
|
-
violatedCheck:
|
|
8887
|
+
var EvalGraderEvidenceSchema = import_zod71.z.discriminatedUnion("type", [
|
|
8888
|
+
import_zod71.z.object({
|
|
8889
|
+
type: import_zod71.z.literal("transcript"),
|
|
8890
|
+
matchedEventIds: import_zod71.z.array(import_zod71.z.string()).optional(),
|
|
8891
|
+
violatedCheck: import_zod71.z.string().optional()
|
|
8583
8892
|
}).strict(),
|
|
8584
|
-
|
|
8585
|
-
type:
|
|
8586
|
-
path:
|
|
8587
|
-
excerpt:
|
|
8893
|
+
import_zod71.z.object({
|
|
8894
|
+
type: import_zod71.z.literal("file"),
|
|
8895
|
+
path: import_zod71.z.string(),
|
|
8896
|
+
excerpt: import_zod71.z.string().max(2048).optional()
|
|
8588
8897
|
// ≤2KB
|
|
8589
8898
|
}).strict(),
|
|
8590
|
-
|
|
8591
|
-
type:
|
|
8592
|
-
judgeModel:
|
|
8593
|
-
rubricSha:
|
|
8899
|
+
import_zod71.z.object({
|
|
8900
|
+
type: import_zod71.z.literal("llm"),
|
|
8901
|
+
judgeModel: import_zod71.z.string(),
|
|
8902
|
+
rubricSha: import_zod71.z.string(),
|
|
8594
8903
|
// U5:离散档位 + 锚点文本(不是换算后小数)
|
|
8595
|
-
dimensionScores:
|
|
8596
|
-
judgeOutputRef:
|
|
8904
|
+
dimensionScores: import_zod71.z.record(import_zod71.z.string(), import_zod71.z.unknown()).optional(),
|
|
8905
|
+
judgeOutputRef: import_zod71.z.string().optional()
|
|
8597
8906
|
// judge 原始输出 OSS ref
|
|
8598
8907
|
}).strict(),
|
|
8599
|
-
|
|
8908
|
+
import_zod71.z.object({ type: import_zod71.z.literal("script"), evidence: ScriptEvidenceSchema }).strict()
|
|
8600
8909
|
]);
|
|
8601
|
-
var GraderVerdictSchema =
|
|
8602
|
-
graderIndex:
|
|
8603
|
-
graderKey:
|
|
8910
|
+
var GraderVerdictSchema = import_zod71.z.object({
|
|
8911
|
+
graderIndex: import_zod71.z.number().int().nonnegative(),
|
|
8912
|
+
graderKey: import_zod71.z.string(),
|
|
8604
8913
|
type: EvalGraderTypeSchema,
|
|
8605
8914
|
severity: EvalSeveritySchema,
|
|
8606
8915
|
// resolve 后终值
|
|
8607
|
-
label:
|
|
8916
|
+
label: import_zod71.z.string().optional(),
|
|
8608
8917
|
status: EvalGraderStatusSchema,
|
|
8609
8918
|
errorClass: EvalErrorClassSchema.optional(),
|
|
8610
8919
|
// status=errored 时
|
|
8611
8920
|
errorCode: EvalErrorCodeSchema.optional(),
|
|
8612
8921
|
// status=errored 时
|
|
8613
|
-
score:
|
|
8922
|
+
score: import_zod71.z.number().nullable(),
|
|
8614
8923
|
// llm=0~1;二值 grader=null
|
|
8615
|
-
threshold:
|
|
8616
|
-
reason:
|
|
8924
|
+
threshold: import_zod71.z.number().optional(),
|
|
8925
|
+
reason: import_zod71.z.string(),
|
|
8617
8926
|
evidence: EvalGraderEvidenceSchema.optional(),
|
|
8618
|
-
graderVersion:
|
|
8619
|
-
engineVersion:
|
|
8927
|
+
graderVersion: import_zod71.z.number().int().optional(),
|
|
8928
|
+
engineVersion: import_zod71.z.string(),
|
|
8620
8929
|
// 平台 grader 实现版本,基线口径用
|
|
8621
|
-
durationMs:
|
|
8930
|
+
durationMs: import_zod71.z.number().int().nonnegative().optional()
|
|
8622
8931
|
}).strict();
|
|
8623
|
-
var EvalCaseResultSchema =
|
|
8624
|
-
caseId:
|
|
8625
|
-
trial:
|
|
8932
|
+
var EvalCaseResultSchema = import_zod71.z.object({
|
|
8933
|
+
caseId: import_zod71.z.string(),
|
|
8934
|
+
trial: import_zod71.z.number().int().nonnegative(),
|
|
8626
8935
|
// U1,online_sample 恒 0
|
|
8627
|
-
attempt:
|
|
8936
|
+
attempt: import_zod71.z.number().int().nonnegative(),
|
|
8628
8937
|
// 基础设施重试序
|
|
8629
|
-
sessionId:
|
|
8938
|
+
sessionId: import_zod71.z.string().optional(),
|
|
8630
8939
|
verdict: EvalCaseVerdictSchema,
|
|
8631
|
-
caseDefinitionDigest:
|
|
8940
|
+
caseDefinitionDigest: import_zod71.z.string(),
|
|
8632
8941
|
errorClass: EvalErrorClassSchema.optional(),
|
|
8633
8942
|
errorCode: EvalErrorCodeSchema.optional(),
|
|
8634
|
-
softMisses:
|
|
8635
|
-
softIncomplete:
|
|
8636
|
-
graders:
|
|
8637
|
-
resolvedRef:
|
|
8943
|
+
softMisses: import_zod71.z.array(import_zod71.z.string()),
|
|
8944
|
+
softIncomplete: import_zod71.z.array(import_zod71.z.string()),
|
|
8945
|
+
graders: import_zod71.z.array(GraderVerdictSchema),
|
|
8946
|
+
resolvedRef: import_zod71.z.string().optional()
|
|
8638
8947
|
// fixtures.workspace.ref → commit SHA
|
|
8639
8948
|
}).strict();
|
|
8640
|
-
var EvalRunSummarySchema =
|
|
8641
|
-
total:
|
|
8642
|
-
passed:
|
|
8643
|
-
failed:
|
|
8644
|
-
errored:
|
|
8645
|
-
gatePass:
|
|
8949
|
+
var EvalRunSummarySchema = import_zod71.z.object({
|
|
8950
|
+
total: import_zod71.z.number().int().nonnegative(),
|
|
8951
|
+
passed: import_zod71.z.number().int().nonnegative(),
|
|
8952
|
+
failed: import_zod71.z.number().int().nonnegative(),
|
|
8953
|
+
errored: import_zod71.z.number().int().nonnegative(),
|
|
8954
|
+
gatePass: import_zod71.z.boolean(),
|
|
8646
8955
|
// 正向断言:全部 case 的全部 gate grader 显式 passed
|
|
8647
8956
|
/**
|
|
8648
8957
|
* v1.2:本 run 参与门禁的 grader 总数。零 gate grader 时 `gatePass` 按「真空为真」
|
|
@@ -8650,116 +8959,116 @@ var EvalRunSummarySchema = import_zod69.z.object({
|
|
|
8650
8959
|
* 本字段让使用者一眼分辨「真的全部通过」与「压根没有门禁断言」。
|
|
8651
8960
|
* optional:老数据无此字段。
|
|
8652
8961
|
*/
|
|
8653
|
-
gateGraderCount:
|
|
8962
|
+
gateGraderCount: import_zod71.z.number().int().nonnegative().optional(),
|
|
8654
8963
|
/**
|
|
8655
8964
|
* v1.2:有多少 case 一个 gate grader 都没有(各自「真空为真」)。`gateGraderCount`
|
|
8656
8965
|
* 是 sum,只能答「全 run 有没有任何门禁断言」;本字段答「是否每个 case 都有」——
|
|
8657
8966
|
* `gatePass=true` 但本值 > 0 = 有 case 无门禁却被算作通过(case 级假绿)。optional:老数据无。
|
|
8658
8967
|
*/
|
|
8659
|
-
casesWithoutGateGrader:
|
|
8660
|
-
errorSummary:
|
|
8661
|
-
capabilityUnavailable:
|
|
8662
|
-
infrastructureError:
|
|
8968
|
+
casesWithoutGateGrader: import_zod71.z.number().int().nonnegative().optional(),
|
|
8969
|
+
errorSummary: import_zod71.z.object({
|
|
8970
|
+
capabilityUnavailable: import_zod71.z.number().int().nonnegative(),
|
|
8971
|
+
infrastructureError: import_zod71.z.number().int().nonnegative(),
|
|
8663
8972
|
/** v1.2:judge 未能给出结论(gate llm UNKNOWN)。optional:老数据无此字段。 */
|
|
8664
|
-
indeterminate:
|
|
8973
|
+
indeterminate: import_zod71.z.number().int().nonnegative().optional(),
|
|
8665
8974
|
/** v1.2:定义写错(自评防护 EVAL_SELF_EVAL_FORBIDDEN)。optional:老数据无此字段。 */
|
|
8666
|
-
invalidDefinition:
|
|
8975
|
+
invalidDefinition: import_zod71.z.number().int().nonnegative().optional()
|
|
8667
8976
|
}).loose().optional()
|
|
8668
8977
|
}).loose();
|
|
8669
8978
|
var EvalRunSummaryWriteSchema = EvalRunSummarySchema.extend({
|
|
8670
8979
|
errorSummary: EvalRunSummarySchema.shape.errorSummary.unwrap().strict().optional()
|
|
8671
8980
|
}).strict();
|
|
8672
|
-
var EvalSuiteRefSchema =
|
|
8673
|
-
source:
|
|
8674
|
-
digest:
|
|
8675
|
-
path:
|
|
8981
|
+
var EvalSuiteRefSchema = import_zod71.z.object({
|
|
8982
|
+
source: import_zod71.z.enum(["package", "repo"]),
|
|
8983
|
+
digest: import_zod71.z.string().min(1),
|
|
8984
|
+
path: import_zod71.z.string().min(1)
|
|
8676
8985
|
}).strict();
|
|
8677
|
-
var CreateEvalRunRequestSchema =
|
|
8678
|
-
agent:
|
|
8986
|
+
var CreateEvalRunRequestSchema = import_zod71.z.object({
|
|
8987
|
+
agent: import_zod71.z.string().min(1),
|
|
8679
8988
|
// A0 只打 test stage(§9 非目标:不做 prod 直评)。用 enum 而非 literal——
|
|
8680
8989
|
// 将来放开 staging/prod 时「enum 加值」是非破坏性变更,literal 变 enum 才是
|
|
8681
8990
|
// 破坏性变更(T1 评审建议,见设计文档 §2.1.6)。
|
|
8682
|
-
stage:
|
|
8991
|
+
stage: import_zod71.z.enum(["test"]),
|
|
8683
8992
|
suiteRef: EvalSuiteRefSchema.optional(),
|
|
8684
8993
|
// 缺省=目标 Revision 绑定的 suite
|
|
8685
|
-
caseIds:
|
|
8686
|
-
strict:
|
|
8994
|
+
caseIds: import_zod71.z.array(EvalSlugSchema).optional(),
|
|
8995
|
+
strict: import_zod71.z.boolean().optional()
|
|
8687
8996
|
}).strict();
|
|
8688
|
-
var CreateEvalRunResponseSchema =
|
|
8689
|
-
var CancelEvalRunResponseSchema =
|
|
8690
|
-
var EvalRunViewSchema =
|
|
8691
|
-
runId:
|
|
8997
|
+
var CreateEvalRunResponseSchema = import_zod71.z.object({ runId: import_zod71.z.string().min(1) }).strict();
|
|
8998
|
+
var CancelEvalRunResponseSchema = import_zod71.z.object({ runId: import_zod71.z.string().min(1), cancelled: import_zod71.z.boolean() }).strict();
|
|
8999
|
+
var EvalRunViewSchema = import_zod71.z.object({
|
|
9000
|
+
runId: import_zod71.z.string(),
|
|
8692
9001
|
status: EvalRunStatusSchema,
|
|
8693
|
-
agent:
|
|
8694
|
-
revisionId:
|
|
8695
|
-
stage:
|
|
9002
|
+
agent: import_zod71.z.string(),
|
|
9003
|
+
revisionId: import_zod71.z.string(),
|
|
9004
|
+
stage: import_zod71.z.string(),
|
|
8696
9005
|
suiteRef: EvalSuiteRefSchema,
|
|
8697
|
-
strict:
|
|
9006
|
+
strict: import_zod71.z.boolean(),
|
|
8698
9007
|
trigger: EvalTriggerSchema,
|
|
8699
|
-
startedAt:
|
|
8700
|
-
completedAt:
|
|
8701
|
-
cases:
|
|
9008
|
+
startedAt: import_zod71.z.string().optional(),
|
|
9009
|
+
completedAt: import_zod71.z.string().optional(),
|
|
9010
|
+
cases: import_zod71.z.array(EvalCaseResultSchema),
|
|
8702
9011
|
summary: EvalRunSummarySchema
|
|
8703
9012
|
}).strict();
|
|
8704
|
-
var EvalRunListItemSchema =
|
|
8705
|
-
runId:
|
|
9013
|
+
var EvalRunListItemSchema = import_zod71.z.object({
|
|
9014
|
+
runId: import_zod71.z.string(),
|
|
8706
9015
|
status: EvalRunStatusSchema,
|
|
8707
|
-
agent:
|
|
8708
|
-
revisionId:
|
|
8709
|
-
stage:
|
|
9016
|
+
agent: import_zod71.z.string(),
|
|
9017
|
+
revisionId: import_zod71.z.string(),
|
|
9018
|
+
stage: import_zod71.z.string(),
|
|
8710
9019
|
trigger: EvalTriggerSchema,
|
|
8711
|
-
startedAt:
|
|
8712
|
-
completedAt:
|
|
9020
|
+
startedAt: import_zod71.z.string().optional(),
|
|
9021
|
+
completedAt: import_zod71.z.string().optional(),
|
|
8713
9022
|
summary: EvalRunSummarySchema
|
|
8714
9023
|
}).strict();
|
|
8715
|
-
var EvalRunListResponseSchema =
|
|
8716
|
-
items:
|
|
8717
|
-
nextCursor:
|
|
9024
|
+
var EvalRunListResponseSchema = import_zod71.z.object({
|
|
9025
|
+
items: import_zod71.z.array(EvalRunListItemSchema),
|
|
9026
|
+
nextCursor: import_zod71.z.string().optional()
|
|
8718
9027
|
}).strict();
|
|
8719
9028
|
var PIPELINE_COMMIT_SHA_RE = /^[0-9a-f]{7,64}$/i;
|
|
8720
|
-
var CommitShaSchema =
|
|
9029
|
+
var CommitShaSchema = import_zod72.z.string().regex(PIPELINE_COMMIT_SHA_RE, {
|
|
8721
9030
|
message: "commitSha must be 7-64 hexadecimal characters"
|
|
8722
9031
|
});
|
|
8723
9032
|
var PIPELINE_FULL_COMMIT_SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
8724
|
-
var FullCommitShaSchema =
|
|
9033
|
+
var FullCommitShaSchema = import_zod72.z.string().regex(PIPELINE_FULL_COMMIT_SHA_RE, {
|
|
8725
9034
|
message: "commitSha must be a full 40- or 64-character hexadecimal SHA (short prefixes cannot anchor a release)"
|
|
8726
9035
|
});
|
|
8727
9036
|
var PIPELINE_TRIGGERED_REF_MAX_LENGTH = 512;
|
|
8728
|
-
var TriggeredRefSchema =
|
|
8729
|
-
var IsoTimestampSchema =
|
|
9037
|
+
var TriggeredRefSchema = import_zod72.z.string().min(1).max(PIPELINE_TRIGGERED_REF_MAX_LENGTH);
|
|
9038
|
+
var IsoTimestampSchema = import_zod72.z.string().datetime({ offset: true });
|
|
8730
9039
|
var NullableIsoTimestampSchema = IsoTimestampSchema.nullable();
|
|
8731
|
-
var PipelineTriggerSchema =
|
|
8732
|
-
var PipelineRunStatusSchema =
|
|
8733
|
-
var PipelineStepSchema =
|
|
8734
|
-
var PipelineStepStatusSchema =
|
|
8735
|
-
var PipelineErrorCodeSchema =
|
|
8736
|
-
var ListPipelineRunsQuerySchema =
|
|
8737
|
-
projectId:
|
|
8738
|
-
limit:
|
|
8739
|
-
}).strict();
|
|
8740
|
-
var NullableTriggeredRefSchema =
|
|
8741
|
-
var PipelineRunListItemSchema =
|
|
8742
|
-
id:
|
|
8743
|
-
commitSha:
|
|
8744
|
-
commitMessage:
|
|
9040
|
+
var PipelineTriggerSchema = import_zod72.z.enum(PIPELINE_TRIGGERS);
|
|
9041
|
+
var PipelineRunStatusSchema = import_zod72.z.enum(PIPELINE_RUN_STATUSES);
|
|
9042
|
+
var PipelineStepSchema = import_zod72.z.enum(PIPELINE_STEPS);
|
|
9043
|
+
var PipelineStepStatusSchema = import_zod72.z.enum(PIPELINE_STEP_STATUSES);
|
|
9044
|
+
var PipelineErrorCodeSchema = import_zod72.z.string().min(1).nullable();
|
|
9045
|
+
var ListPipelineRunsQuerySchema = import_zod72.z.object({
|
|
9046
|
+
projectId: import_zod72.z.string().uuid(),
|
|
9047
|
+
limit: import_zod72.z.coerce.number().int().min(1).max(200).default(50)
|
|
9048
|
+
}).strict();
|
|
9049
|
+
var NullableTriggeredRefSchema = import_zod72.z.string().nullable().optional();
|
|
9050
|
+
var PipelineRunListItemSchema = import_zod72.z.object({
|
|
9051
|
+
id: import_zod72.z.string().uuid(),
|
|
9052
|
+
commitSha: import_zod72.z.string(),
|
|
9053
|
+
commitMessage: import_zod72.z.string().nullable(),
|
|
8745
9054
|
trigger: PipelineTriggerSchema,
|
|
8746
9055
|
status: PipelineRunStatusSchema,
|
|
8747
|
-
stagesKey:
|
|
8748
|
-
attempt:
|
|
8749
|
-
agentSlugs:
|
|
8750
|
-
createdBy:
|
|
9056
|
+
stagesKey: import_zod72.z.string(),
|
|
9057
|
+
attempt: import_zod72.z.number().int().nonnegative(),
|
|
9058
|
+
agentSlugs: import_zod72.z.array(import_zod72.z.string()),
|
|
9059
|
+
createdBy: import_zod72.z.string().nullable(),
|
|
8751
9060
|
createdAt: IsoTimestampSchema,
|
|
8752
9061
|
startedAt: NullableIsoTimestampSchema,
|
|
8753
9062
|
completedAt: NullableIsoTimestampSchema,
|
|
8754
9063
|
errorCode: PipelineErrorCodeSchema,
|
|
8755
9064
|
triggeredRef: NullableTriggeredRefSchema
|
|
8756
9065
|
}).strict();
|
|
8757
|
-
var ListPipelineRunsResponseSchema =
|
|
8758
|
-
enabled:
|
|
8759
|
-
items:
|
|
9066
|
+
var ListPipelineRunsResponseSchema = import_zod72.z.object({
|
|
9067
|
+
enabled: import_zod72.z.boolean(),
|
|
9068
|
+
items: import_zod72.z.array(PipelineRunListItemSchema)
|
|
8760
9069
|
}).strict();
|
|
8761
|
-
var CreatePipelineRunRequestSchema =
|
|
8762
|
-
projectId:
|
|
9070
|
+
var CreatePipelineRunRequestSchema = import_zod72.z.object({
|
|
9071
|
+
projectId: import_zod72.z.string().uuid(),
|
|
8763
9072
|
commitSha: FullCommitShaSchema,
|
|
8764
9073
|
/**
|
|
8765
9074
|
* Explicit re-run: mint `attempt+1` even when the latest run for this
|
|
@@ -8768,7 +9077,7 @@ var CreatePipelineRunRequestSchema = import_zod70.z.object({
|
|
|
8768
9077
|
* against servers that predate it (`.strict()` on their side). Non-passed
|
|
8769
9078
|
* terminal runs re-run automatically without this flag (§4).
|
|
8770
9079
|
*/
|
|
8771
|
-
rerun:
|
|
9080
|
+
rerun: import_zod72.z.boolean().optional(),
|
|
8772
9081
|
/**
|
|
8773
9082
|
* The ref the caller resolved `commitSha` from, recorded for display only
|
|
8774
9083
|
* (see `TriggeredRefSchema`). Optional: a caller that has just a SHA and no
|
|
@@ -8781,54 +9090,54 @@ var CreatePipelineRunRequestSchema = import_zod70.z.object({
|
|
|
8781
9090
|
*/
|
|
8782
9091
|
triggeredRef: TriggeredRefSchema.optional()
|
|
8783
9092
|
}).strict();
|
|
8784
|
-
var CreatePipelineRunResponseSchema =
|
|
8785
|
-
runId:
|
|
8786
|
-
deduplicated:
|
|
8787
|
-
attempt:
|
|
9093
|
+
var CreatePipelineRunResponseSchema = import_zod72.z.object({
|
|
9094
|
+
runId: import_zod72.z.string().uuid(),
|
|
9095
|
+
deduplicated: import_zod72.z.boolean(),
|
|
9096
|
+
attempt: import_zod72.z.number().int().nonnegative().optional(),
|
|
8788
9097
|
status: PipelineRunStatusSchema.optional()
|
|
8789
9098
|
});
|
|
8790
|
-
var PipelineRunDetailRunSchema =
|
|
8791
|
-
id:
|
|
8792
|
-
projectId:
|
|
8793
|
-
repoUrl:
|
|
8794
|
-
commitSha:
|
|
8795
|
-
commitMessage:
|
|
9099
|
+
var PipelineRunDetailRunSchema = import_zod72.z.object({
|
|
9100
|
+
id: import_zod72.z.string().uuid(),
|
|
9101
|
+
projectId: import_zod72.z.string().uuid(),
|
|
9102
|
+
repoUrl: import_zod72.z.string(),
|
|
9103
|
+
commitSha: import_zod72.z.string(),
|
|
9104
|
+
commitMessage: import_zod72.z.string().nullable(),
|
|
8796
9105
|
trigger: PipelineTriggerSchema,
|
|
8797
9106
|
status: PipelineRunStatusSchema,
|
|
8798
|
-
stagesRequested:
|
|
8799
|
-
stagesKey:
|
|
8800
|
-
attempt:
|
|
8801
|
-
planJson:
|
|
9107
|
+
stagesRequested: import_zod72.z.array(PipelineStepSchema).nullable(),
|
|
9108
|
+
stagesKey: import_zod72.z.string(),
|
|
9109
|
+
attempt: import_zod72.z.number().int().nonnegative(),
|
|
9110
|
+
planJson: import_zod72.z.unknown().nullable(),
|
|
8802
9111
|
errorCode: PipelineErrorCodeSchema,
|
|
8803
|
-
errorMessage:
|
|
8804
|
-
createdBy:
|
|
9112
|
+
errorMessage: import_zod72.z.string().nullable(),
|
|
9113
|
+
createdBy: import_zod72.z.string().nullable(),
|
|
8805
9114
|
createdAt: IsoTimestampSchema,
|
|
8806
9115
|
startedAt: NullableIsoTimestampSchema,
|
|
8807
9116
|
completedAt: NullableIsoTimestampSchema,
|
|
8808
9117
|
triggeredRef: NullableTriggeredRefSchema
|
|
8809
9118
|
}).strict();
|
|
8810
|
-
var PipelineRunStepSchema =
|
|
9119
|
+
var PipelineRunStepSchema = import_zod72.z.object({
|
|
8811
9120
|
step: PipelineStepSchema,
|
|
8812
9121
|
status: PipelineStepStatusSchema,
|
|
8813
|
-
attempt:
|
|
8814
|
-
resultJson:
|
|
9122
|
+
attempt: import_zod72.z.number().int().nonnegative(),
|
|
9123
|
+
resultJson: import_zod72.z.unknown().nullable(),
|
|
8815
9124
|
errorCode: PipelineErrorCodeSchema,
|
|
8816
|
-
errorMessage:
|
|
9125
|
+
errorMessage: import_zod72.z.string().nullable(),
|
|
8817
9126
|
startedAt: NullableIsoTimestampSchema,
|
|
8818
9127
|
completedAt: NullableIsoTimestampSchema
|
|
8819
9128
|
}).strict();
|
|
8820
|
-
var PipelineRunWorkloadSchema =
|
|
8821
|
-
agentSlug:
|
|
8822
|
-
affectedReason:
|
|
8823
|
-
workloadId:
|
|
8824
|
-
revisionId:
|
|
8825
|
-
repointStatus:
|
|
8826
|
-
freezeStatus:
|
|
8827
|
-
frozenPackageOssUrl:
|
|
8828
|
-
frozenPackageSha256:
|
|
8829
|
-
frozenPackageWarnings:
|
|
8830
|
-
evalRunId:
|
|
8831
|
-
evalVerdict:
|
|
9129
|
+
var PipelineRunWorkloadSchema = import_zod72.z.object({
|
|
9130
|
+
agentSlug: import_zod72.z.string(),
|
|
9131
|
+
affectedReason: import_zod72.z.string().nullable(),
|
|
9132
|
+
workloadId: import_zod72.z.string().nullable(),
|
|
9133
|
+
revisionId: import_zod72.z.string().nullable(),
|
|
9134
|
+
repointStatus: import_zod72.z.string().nullable(),
|
|
9135
|
+
freezeStatus: import_zod72.z.string().nullable(),
|
|
9136
|
+
frozenPackageOssUrl: import_zod72.z.string().nullable(),
|
|
9137
|
+
frozenPackageSha256: import_zod72.z.string().nullable(),
|
|
9138
|
+
frozenPackageWarnings: import_zod72.z.array(import_zod72.z.string()).nullable(),
|
|
9139
|
+
evalRunId: import_zod72.z.string().nullable(),
|
|
9140
|
+
evalVerdict: import_zod72.z.string().nullable(),
|
|
8832
9141
|
/**
|
|
8833
9142
|
* joined | skipped_no_base_revision | skipped_no_image_change | failed.
|
|
8834
9143
|
*
|
|
@@ -8837,7 +9146,7 @@ var PipelineRunWorkloadSchema = import_zod70.z.object({
|
|
|
8837
9146
|
* so a client parsing a response from a control-plane that predates these
|
|
8838
9147
|
* fields must not throw. Absent and null both read as "not reported".
|
|
8839
9148
|
*/
|
|
8840
|
-
joinStatus:
|
|
9149
|
+
joinStatus: import_zod72.z.string().nullable().optional(),
|
|
8841
9150
|
/**
|
|
8842
9151
|
* Per-workload failure, so a client can say WHICH agent failed and why —
|
|
8843
9152
|
* the run/step level only ever counts failures. Deliberately NOT
|
|
@@ -8849,16 +9158,16 @@ var PipelineRunWorkloadSchema = import_zod70.z.object({
|
|
|
8849
9158
|
* `.max()`-ed here — a schema cap would upgrade "the error text is long"
|
|
8850
9159
|
* into "the whole response fails to parse".
|
|
8851
9160
|
*/
|
|
8852
|
-
errorCode:
|
|
8853
|
-
errorMessage:
|
|
9161
|
+
errorCode: import_zod72.z.string().nullable().optional(),
|
|
9162
|
+
errorMessage: import_zod72.z.string().nullable().optional()
|
|
8854
9163
|
}).strict();
|
|
8855
|
-
var PipelineRunDetailResponseSchema =
|
|
9164
|
+
var PipelineRunDetailResponseSchema = import_zod72.z.object({
|
|
8856
9165
|
run: PipelineRunDetailRunSchema,
|
|
8857
|
-
steps:
|
|
8858
|
-
workloads:
|
|
9166
|
+
steps: import_zod72.z.array(PipelineRunStepSchema),
|
|
9167
|
+
workloads: import_zod72.z.array(PipelineRunWorkloadSchema)
|
|
8859
9168
|
}).strict();
|
|
8860
|
-
var GetPipelinePlanQuerySchema =
|
|
8861
|
-
projectId:
|
|
9169
|
+
var GetPipelinePlanQuerySchema = import_zod72.z.object({
|
|
9170
|
+
projectId: import_zod72.z.string().uuid(),
|
|
8862
9171
|
commitSha: CommitShaSchema,
|
|
8863
9172
|
fromSha: CommitShaSchema.optional(),
|
|
8864
9173
|
/**
|
|
@@ -8866,20 +9175,20 @@ var GetPipelinePlanQuerySchema = import_zod70.z.object({
|
|
|
8866
9175
|
* Accepted as the STRING "false" because it arrives as a query param; any
|
|
8867
9176
|
* other value (including absent) means "compute if missing".
|
|
8868
9177
|
*/
|
|
8869
|
-
enqueue:
|
|
9178
|
+
enqueue: import_zod72.z.enum(["true", "false"]).optional().transform((value) => value !== "false")
|
|
8870
9179
|
}).strict();
|
|
8871
|
-
var PipelinePlanResponseSchema =
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
source:
|
|
8875
|
-
enqueued:
|
|
9180
|
+
var PipelinePlanResponseSchema = import_zod72.z.discriminatedUnion("source", [
|
|
9181
|
+
import_zod72.z.object({ source: import_zod72.z.literal("cache"), plan: import_zod72.z.unknown() }).strict(),
|
|
9182
|
+
import_zod72.z.object({
|
|
9183
|
+
source: import_zod72.z.literal("computing"),
|
|
9184
|
+
enqueued: import_zod72.z.boolean(),
|
|
8876
9185
|
// 上一次计算的失败摘要(若有)。默认 enqueue=true 会不断重算,plan 一直
|
|
8877
9186
|
// "computing" 时失败原本被吞——带上它让轮询者看到「在重试,但上次失败:…」
|
|
8878
9187
|
// 而不是无限"计算中"(#1346 D4)。
|
|
8879
9188
|
// 长度上游已有界(plan-cache fail() 落库前截断 2000),这里刻意不设
|
|
8880
9189
|
// .max():schema 硬上限会把"错误信息超长"升级成"整个响应 parse 失败",
|
|
8881
9190
|
// 让错误路径反过来炸掉主功能。
|
|
8882
|
-
lastError:
|
|
9191
|
+
lastError: import_zod72.z.string().nullable().optional()
|
|
8883
9192
|
}).strict()
|
|
8884
9193
|
]);
|
|
8885
9194
|
var PIPELINE_API_ERROR_CODES = [
|
|
@@ -8890,23 +9199,23 @@ var PIPELINE_API_ERROR_CODES = [
|
|
|
8890
9199
|
"PIPELINE_RUN_NOT_FOUND",
|
|
8891
9200
|
"PLAN_NOT_CACHED"
|
|
8892
9201
|
];
|
|
8893
|
-
var PipelineApiErrorCodeSchema =
|
|
9202
|
+
var PipelineApiErrorCodeSchema = import_zod72.z.enum(PIPELINE_API_ERROR_CODES);
|
|
8894
9203
|
var SKILL_NAME_MAX_LENGTH = 200;
|
|
8895
9204
|
var SKILL_SOURCE_REF_MAX_LENGTH = 512;
|
|
8896
9205
|
var SKILL_NAME_WHITELIST = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8897
|
-
var SkillNameSchema =
|
|
9206
|
+
var SkillNameSchema = import_zod73.z.string().min(1).max(SKILL_NAME_MAX_LENGTH).refine((value) => SKILL_NAME_WHITELIST.test(value), {
|
|
8898
9207
|
message: "skill name must start with [A-Za-z0-9] and contain only [A-Za-z0-9._-] (no path separators, spaces or invisible characters)"
|
|
8899
9208
|
}).refine((value) => value !== "." && value !== "..", {
|
|
8900
9209
|
message: "skill name must not be '.' or '..'"
|
|
8901
9210
|
});
|
|
8902
|
-
var SkillSourceRefSchema =
|
|
8903
|
-
var SkillManifestSourceTypeSchema =
|
|
8904
|
-
var SkillsManifestDefaultsSchema =
|
|
8905
|
-
installDir:
|
|
8906
|
-
targetAgents:
|
|
8907
|
-
installMode:
|
|
9211
|
+
var SkillSourceRefSchema = import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH);
|
|
9212
|
+
var SkillManifestSourceTypeSchema = import_zod73.z.enum(["rush", "github", "gitlab"]);
|
|
9213
|
+
var SkillsManifestDefaultsSchema = import_zod73.z.object({
|
|
9214
|
+
installDir: import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH).optional(),
|
|
9215
|
+
targetAgents: import_zod73.z.array(import_zod73.z.string().min(1)).optional(),
|
|
9216
|
+
installMode: import_zod73.z.string().min(1).optional()
|
|
8908
9217
|
}).passthrough();
|
|
8909
|
-
var SkillsManifestSchema =
|
|
9218
|
+
var SkillsManifestSchema = import_zod73.z.object({
|
|
8910
9219
|
/**
|
|
8911
9220
|
* **必填,刻意不做 `.optional().default({})`**(评审提过,权衡后维持):
|
|
8912
9221
|
* 本 schema 是 passthrough 的,若 `skills` 可省略,一个拼错的顶层 key
|
|
@@ -8915,27 +9224,27 @@ var SkillsManifestSchema = import_zod71.z.object({
|
|
|
8915
9224
|
* 看到一条报错、补上 `"skills": {}`:响的、可恢复的。空清单请显式写
|
|
8916
9225
|
* `{"skills": {}}`(脚手架生成的就是这个形态)。
|
|
8917
9226
|
*/
|
|
8918
|
-
skills:
|
|
8919
|
-
registries:
|
|
9227
|
+
skills: import_zod73.z.record(SkillNameSchema, SkillSourceRefSchema),
|
|
9228
|
+
registries: import_zod73.z.record(import_zod73.z.string().min(1), import_zod73.z.string().min(1)).optional(),
|
|
8920
9229
|
defaults: SkillsManifestDefaultsSchema.optional()
|
|
8921
9230
|
}).passthrough();
|
|
8922
|
-
var SkillsLockEntrySchema =
|
|
8923
|
-
source:
|
|
9231
|
+
var SkillsLockEntrySchema = import_zod73.z.object({
|
|
9232
|
+
source: import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH),
|
|
8924
9233
|
/** 注册表源的精确版本;git 源这里是可读注记(实测常为 `main`)。 */
|
|
8925
|
-
version:
|
|
9234
|
+
version: import_zod73.z.string().optional(),
|
|
8926
9235
|
/** 浮动 ref 的人类可读注记——**绝不参与安装**(D23)。 */
|
|
8927
|
-
ref:
|
|
8928
|
-
resolved:
|
|
9236
|
+
ref: import_zod73.z.string().optional(),
|
|
9237
|
+
resolved: import_zod73.z.string().optional(),
|
|
8929
9238
|
/** git 源的钉死点。实测可能为 `""`(缺 commit),由校验层硬拒。 */
|
|
8930
|
-
commit:
|
|
8931
|
-
integrity:
|
|
8932
|
-
installedAt:
|
|
9239
|
+
commit: import_zod73.z.string().optional(),
|
|
9240
|
+
integrity: import_zod73.z.string().optional(),
|
|
9241
|
+
installedAt: import_zod73.z.string().optional()
|
|
8933
9242
|
}).passthrough();
|
|
8934
|
-
var SkillsLockSchema =
|
|
8935
|
-
lockfileVersion:
|
|
8936
|
-
skills:
|
|
9243
|
+
var SkillsLockSchema = import_zod73.z.object({
|
|
9244
|
+
lockfileVersion: import_zod73.z.number().int().nonnegative().optional(),
|
|
9245
|
+
skills: import_zod73.z.record(SkillNameSchema, SkillsLockEntrySchema)
|
|
8937
9246
|
}).passthrough();
|
|
8938
|
-
var SkillsManifestErrorCodeSchema =
|
|
9247
|
+
var SkillsManifestErrorCodeSchema = import_zod73.z.enum([
|
|
8939
9248
|
/** `skills.json` 语法/结构非法。 */
|
|
8940
9249
|
"SKILLS_MANIFEST_INVALID",
|
|
8941
9250
|
/** `skills.lock` 语法/结构非法。 */
|
|
@@ -9071,7 +9380,7 @@ var BindingsResource = class {
|
|
|
9071
9380
|
};
|
|
9072
9381
|
|
|
9073
9382
|
// src/resources/environments.ts
|
|
9074
|
-
var
|
|
9383
|
+
var import_zod74 = require("zod");
|
|
9075
9384
|
|
|
9076
9385
|
// src/agent-vocab.ts
|
|
9077
9386
|
function resolveExclusiveAlias(canonicalKey, canonicalValue, aliasKey, aliasValue) {
|
|
@@ -9095,24 +9404,24 @@ function attachAgentAliases(data) {
|
|
|
9095
9404
|
}
|
|
9096
9405
|
|
|
9097
9406
|
// src/resources/environments.ts
|
|
9098
|
-
var EnvironmentVersionHistorySchema =
|
|
9099
|
-
versions:
|
|
9100
|
-
repoints:
|
|
9407
|
+
var EnvironmentVersionHistorySchema = import_zod74.z.object({
|
|
9408
|
+
versions: import_zod74.z.array(EnvironmentVersionSchema),
|
|
9409
|
+
repoints: import_zod74.z.array(EnvironmentRepointRecordSchema)
|
|
9101
9410
|
}).strict();
|
|
9102
|
-
var RepointedSlotResultSchema =
|
|
9103
|
-
workloadId:
|
|
9411
|
+
var RepointedSlotResultSchema = import_zod74.z.object({
|
|
9412
|
+
workloadId: import_zod74.z.string().uuid(),
|
|
9104
9413
|
stage: StageSchema,
|
|
9105
|
-
fromVersion:
|
|
9414
|
+
fromVersion: import_zod74.z.number().int().positive().nullable()
|
|
9106
9415
|
}).strict();
|
|
9107
|
-
var RepointEnvironmentResultSchema =
|
|
9108
|
-
toVersion:
|
|
9109
|
-
repointedSlotCount:
|
|
9110
|
-
repointedSlots:
|
|
9416
|
+
var RepointEnvironmentResultSchema = import_zod74.z.object({
|
|
9417
|
+
toVersion: import_zod74.z.number().int().positive(),
|
|
9418
|
+
repointedSlotCount: import_zod74.z.number().int().nonnegative(),
|
|
9419
|
+
repointedSlots: import_zod74.z.array(RepointedSlotResultSchema)
|
|
9111
9420
|
}).strict();
|
|
9112
|
-
var UpdateEnvironmentResultSchema =
|
|
9421
|
+
var UpdateEnvironmentResultSchema = import_zod74.z.object({
|
|
9113
9422
|
environment: EnvironmentSchema,
|
|
9114
|
-
createdVersion:
|
|
9115
|
-
repointedSlotCount:
|
|
9423
|
+
createdVersion: import_zod74.z.number().int().positive().nullable(),
|
|
9424
|
+
repointedSlotCount: import_zod74.z.number().int().nonnegative()
|
|
9116
9425
|
}).strict();
|
|
9117
9426
|
function attachAgentAliasesToEach(items) {
|
|
9118
9427
|
return items.map((item) => attachAgentAliases(item));
|
|
@@ -9433,14 +9742,14 @@ var McpDevTicketsResource = class {
|
|
|
9433
9742
|
};
|
|
9434
9743
|
|
|
9435
9744
|
// src/resources/memories.ts
|
|
9436
|
-
var
|
|
9745
|
+
var import_zod75 = require("zod");
|
|
9437
9746
|
var ListedMemorySchema = AgentMemorySchema.extend({
|
|
9438
|
-
createdAt:
|
|
9439
|
-
updatedAt:
|
|
9747
|
+
createdAt: import_zod75.z.string(),
|
|
9748
|
+
updatedAt: import_zod75.z.string()
|
|
9440
9749
|
});
|
|
9441
|
-
var ListMemoriesResponseSchema =
|
|
9442
|
-
items:
|
|
9443
|
-
nextCursor:
|
|
9750
|
+
var ListMemoriesResponseSchema = import_zod75.z.object({
|
|
9751
|
+
items: import_zod75.z.array(ListedMemorySchema),
|
|
9752
|
+
nextCursor: import_zod75.z.string().nullish()
|
|
9444
9753
|
});
|
|
9445
9754
|
function parseEnvelopeData2(envelope, routeLabel, schema) {
|
|
9446
9755
|
if (envelope?.data === void 0) {
|
|
@@ -9911,7 +10220,7 @@ var ProjectsResource = class {
|
|
|
9911
10220
|
};
|
|
9912
10221
|
|
|
9913
10222
|
// src/resources/sessions.ts
|
|
9914
|
-
var
|
|
10223
|
+
var import_zod76 = require("zod");
|
|
9915
10224
|
function normalizeSessionRequest(request) {
|
|
9916
10225
|
const { agentId, versionId, ...rest } = request;
|
|
9917
10226
|
const workloadId = resolveExclusiveAlias("workloadId", rest.workloadId, "agentId", agentId);
|
|
@@ -9936,33 +10245,181 @@ function normalizeSessionRequest(request) {
|
|
|
9936
10245
|
...revisionId !== void 0 ? { revisionId } : {}
|
|
9937
10246
|
};
|
|
9938
10247
|
}
|
|
9939
|
-
var ListSessionEventsEnvelopeSchema =
|
|
9940
|
-
data:
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
10248
|
+
var ListSessionEventsEnvelopeSchema = import_zod76.z.object({
|
|
10249
|
+
data: import_zod76.z.object({
|
|
10250
|
+
events: import_zod76.z.array(SessionEventSchema),
|
|
10251
|
+
// Optional so a pre-P1 server's `{ events }` body still parses.
|
|
10252
|
+
hasMore: import_zod76.z.boolean().optional(),
|
|
10253
|
+
cursorReset: import_zod76.z.boolean().optional()
|
|
10254
|
+
})
|
|
10255
|
+
});
|
|
10256
|
+
var TurnListEnvelopeSchema = import_zod76.z.object({ data: TurnListResponseDataSchema });
|
|
10257
|
+
var TurnEnvelopeSchema = import_zod76.z.object({ data: TurnSchema });
|
|
10258
|
+
var DispatchOutcomeEnvelopeSchema = import_zod76.z.object({
|
|
10259
|
+
data: import_zod76.z.object({ outcome: DispatchOutcomeSchema })
|
|
10260
|
+
});
|
|
10261
|
+
var SendTurnTurnRefEnvelopeSchema = import_zod76.z.object({
|
|
10262
|
+
data: import_zod76.z.object({
|
|
10263
|
+
turn: import_zod76.z.object({ turnId: import_zod76.z.string(), status: TurnStatusSchema }).optional()
|
|
10264
|
+
})
|
|
10265
|
+
});
|
|
10266
|
+
var SessionRuntimeBindingEnvelopeSchema = import_zod76.z.object({
|
|
10267
|
+
runtimeBinding: import_zod76.z.object({ id: import_zod76.z.string().min(1) }).nullish()
|
|
10268
|
+
});
|
|
10269
|
+
var DeliveryResultEnvelopeSchema = import_zod76.z.object({
|
|
10270
|
+
data: import_zod76.z.object({ delivery: SessionDeliveryEnvelopeSchema.nullable() })
|
|
10271
|
+
});
|
|
10272
|
+
var SessionArtifactsListEnvelopeSchema = import_zod76.z.object({
|
|
10273
|
+
data: import_zod76.z.object({
|
|
10274
|
+
items: import_zod76.z.array(
|
|
10275
|
+
import_zod76.z.object({
|
|
10276
|
+
id: import_zod76.z.string(),
|
|
10277
|
+
artifactId: import_zod76.z.string().optional(),
|
|
10278
|
+
filename: import_zod76.z.string(),
|
|
10279
|
+
path: import_zod76.z.string(),
|
|
10280
|
+
contentType: import_zod76.z.string(),
|
|
10281
|
+
size: import_zod76.z.number(),
|
|
10282
|
+
turnId: import_zod76.z.string().optional(),
|
|
10283
|
+
messageId: import_zod76.z.string().optional()
|
|
9957
10284
|
})
|
|
9958
10285
|
),
|
|
9959
|
-
partial:
|
|
9960
|
-
skippedBundles:
|
|
10286
|
+
partial: import_zod76.z.boolean().optional(),
|
|
10287
|
+
skippedBundles: import_zod76.z.array(import_zod76.z.object({ artifactId: import_zod76.z.string(), reason: import_zod76.z.string() })).optional()
|
|
9961
10288
|
})
|
|
9962
10289
|
});
|
|
10290
|
+
var SessionTurnsResource = class {
|
|
10291
|
+
constructor(client, sessions) {
|
|
10292
|
+
this.client = client;
|
|
10293
|
+
this.sessions = sessions;
|
|
10294
|
+
}
|
|
10295
|
+
/**
|
|
10296
|
+
* `GET /api/sessions/:id/turns` — one keyset page of turns, newest first by
|
|
10297
|
+
* default. Requires scope `runs:stream`.
|
|
10298
|
+
*
|
|
10299
|
+
* Page forward with `after: nextCursor` / back with `before: prevCursor`;
|
|
10300
|
+
* there is no `page`/`offset`.
|
|
10301
|
+
*
|
|
10302
|
+
* "Forward" is relative to the ORDER YOU ASKED FOR, not to time: under the
|
|
10303
|
+
* default `order: "desc"` it means toward OLDER turns. `hasMore` describes
|
|
10304
|
+
* that same forward direction, so the loop that walks a whole history is
|
|
10305
|
+
* `after: nextCursor` until `hasMore` is false. Pairing `hasMore` with
|
|
10306
|
+
* `before`/`prevCursor` reads a flag about the direction you are NOT
|
|
10307
|
+
* walking and will not terminate correctly — `before` is for picking up
|
|
10308
|
+
* turns that arrived on the other side of your page, not for draining.
|
|
10309
|
+
*
|
|
10310
|
+
* `streamCursor` is the session's highest `__seq` and can be handed
|
|
10311
|
+
* straight to {@link SessionsResource.streamEvents} as `lastEventId` to
|
|
10312
|
+
* resume live streaming without replaying what this page already covers.
|
|
10313
|
+
*/
|
|
10314
|
+
async list(sessionId, options = {}) {
|
|
10315
|
+
const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns`;
|
|
10316
|
+
const envelope = await this.client.request(path, {
|
|
10317
|
+
method: "GET",
|
|
10318
|
+
query: {
|
|
10319
|
+
limit: options.limit,
|
|
10320
|
+
order: options.order,
|
|
10321
|
+
before: options.before,
|
|
10322
|
+
after: options.after,
|
|
10323
|
+
status: options.status && options.status.length > 0 ? options.status.join(",") : void 0,
|
|
10324
|
+
revivalAttemptId: options.revivalAttemptId
|
|
10325
|
+
},
|
|
10326
|
+
signal: options.signal,
|
|
10327
|
+
cache: "no-store"
|
|
10328
|
+
});
|
|
10329
|
+
const parsed = TurnListEnvelopeSchema.safeParse(envelope);
|
|
10330
|
+
if (!parsed.success) {
|
|
10331
|
+
throw new PilotPlatformApiError({
|
|
10332
|
+
status: 0,
|
|
10333
|
+
code: "MALFORMED_PLATFORM_RESPONSE",
|
|
10334
|
+
message: `GET ${path} did not return a {data: {turns: [...]}} envelope.`,
|
|
10335
|
+
cause: parsed.error
|
|
10336
|
+
});
|
|
10337
|
+
}
|
|
10338
|
+
return parsed.data.data;
|
|
10339
|
+
}
|
|
10340
|
+
/**
|
|
10341
|
+
* `GET /api/sessions/:id/turns/:turnId` — one turn. Requires scope
|
|
10342
|
+
* `runs:stream`.
|
|
10343
|
+
*
|
|
10344
|
+
* Throws `PilotPlatformNotFoundError` with `code` `TURN_NOT_FOUND` (404)
|
|
10345
|
+
* for an id this session has no turn for. A prompt that is waiting on
|
|
10346
|
+
* Agent Recovery has NOT become a turn yet and reads as that same 404 —
|
|
10347
|
+
* check `sessions.get(id)`'s `pendingRevival` before treating it as a bad
|
|
10348
|
+
* id.
|
|
10349
|
+
*/
|
|
10350
|
+
async get(sessionId, turnId, options = {}) {
|
|
10351
|
+
const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns/${encodeURIComponent(turnId)}`;
|
|
10352
|
+
const envelope = await this.client.request(path, {
|
|
10353
|
+
method: "GET",
|
|
10354
|
+
signal: options.signal,
|
|
10355
|
+
cache: "no-store"
|
|
10356
|
+
});
|
|
10357
|
+
const parsed = TurnEnvelopeSchema.safeParse(envelope);
|
|
10358
|
+
if (!parsed.success) {
|
|
10359
|
+
throw new PilotPlatformApiError({
|
|
10360
|
+
status: 0,
|
|
10361
|
+
code: "MALFORMED_PLATFORM_RESPONSE",
|
|
10362
|
+
message: `GET ${path} did not return a {data: <Turn>} envelope.`,
|
|
10363
|
+
cause: parsed.error
|
|
10364
|
+
});
|
|
10365
|
+
}
|
|
10366
|
+
return parsed.data.data;
|
|
10367
|
+
}
|
|
10368
|
+
/**
|
|
10369
|
+
* `POST /api/sessions/:id/abort` — ask the worker to stop `turnId`.
|
|
10370
|
+
* Requires scope **`runs:abort`** (not `runs:stream`, unlike every other
|
|
10371
|
+
* method here).
|
|
10372
|
+
*
|
|
10373
|
+
* Requires a control-plane that declares `tokenAudience: "agenthub"` on the
|
|
10374
|
+
* abort dispatch binding. Against an older one, an AgentHub token
|
|
10375
|
+
* (`aud=agenthub` — the only kind this SDK sends) is rejected with 403
|
|
10376
|
+
* `TOKEN_AUDIENCE_MISMATCH` before the scope check.
|
|
10377
|
+
*
|
|
10378
|
+
* Idempotent: the request key is derived from the session and turn, so
|
|
10379
|
+
* re-issuing it — including from the portal's Stop button — collapses onto
|
|
10380
|
+
* the one abort rather than stacking.
|
|
10381
|
+
*
|
|
10382
|
+
* The returned `DispatchOutcome` is the dispatch result, NOT proof the turn
|
|
10383
|
+
* stopped: a `rejected` / `transport_failed` outcome comes back as a VALUE
|
|
10384
|
+
* with 200 (branch on `outcome.kind`, and on `priorOutcome` for
|
|
10385
|
+
* `idempotent_replay`), and even an `accepted` abort only means the worker
|
|
10386
|
+
* received the signal. Whether it landed is read off the turn:
|
|
10387
|
+
* `(await turns.get(sessionId, turnId)).status === "aborted"`.
|
|
10388
|
+
*/
|
|
10389
|
+
async abort(sessionId, turnId, options = {}) {
|
|
10390
|
+
const runtimeBindingId = options.runtimeBindingId ?? await resolveRuntimeBindingId(this.sessions, sessionId, options.signal);
|
|
10391
|
+
const path = `/api/sessions/${encodeURIComponent(sessionId)}/abort`;
|
|
10392
|
+
const envelope = await this.client.request(path, {
|
|
10393
|
+
method: "POST",
|
|
10394
|
+
body: {
|
|
10395
|
+
// Byte-identical to the portal Stop button's key
|
|
10396
|
+
// (`use-session-revival.ts`), so a user click and an SDK abort for the
|
|
10397
|
+
// same turn dedupe against each other instead of racing.
|
|
10398
|
+
idempotencyKey: `abort:session:${sessionId}:turn:${turnId}`,
|
|
10399
|
+
session: { sessionId, runtimeBindingId },
|
|
10400
|
+
protocolVersion: "v1",
|
|
10401
|
+
turnId,
|
|
10402
|
+
reason: options.reason ?? { kind: "user" },
|
|
10403
|
+
trace: { traceId: newTraceId(), spanId: newTraceId() }
|
|
10404
|
+
},
|
|
10405
|
+
signal: options.signal
|
|
10406
|
+
});
|
|
10407
|
+
const parsed = DispatchOutcomeEnvelopeSchema.safeParse(envelope);
|
|
10408
|
+
if (!parsed.success) {
|
|
10409
|
+
throw new PilotPlatformApiError({
|
|
10410
|
+
status: 0,
|
|
10411
|
+
code: "MALFORMED_PLATFORM_RESPONSE",
|
|
10412
|
+
message: `POST ${path} did not return a {data: {outcome: ...}} envelope.`,
|
|
10413
|
+
cause: parsed.error
|
|
10414
|
+
});
|
|
10415
|
+
}
|
|
10416
|
+
return parsed.data.data.outcome;
|
|
10417
|
+
}
|
|
10418
|
+
};
|
|
9963
10419
|
var SessionsResource = class {
|
|
9964
10420
|
constructor(client) {
|
|
9965
10421
|
this.client = client;
|
|
10422
|
+
this.turns = new SessionTurnsResource(client, this);
|
|
9966
10423
|
}
|
|
9967
10424
|
async create(request, options = {}) {
|
|
9968
10425
|
const body = CreatePlatformSessionRequestSchema.parse(normalizeSessionRequest(request));
|
|
@@ -10080,7 +10537,10 @@ var SessionsResource = class {
|
|
|
10080
10537
|
*
|
|
10081
10538
|
* Requires scope `runs:create`. The session must be `ready`
|
|
10082
10539
|
* (`sessions.wait`) and have no turn in flight — a prior running turn
|
|
10083
|
-
* throws `SESSION_TURN_IN_PROGRESS` (409), it is never queued.
|
|
10540
|
+
* throws `SESSION_TURN_IN_PROGRESS` (409), it is never queued. A turn sent
|
|
10541
|
+
* while an Agent Recovery started by someone else is running throws
|
|
10542
|
+
* `SESSION_REVIVING` (409): nothing was dispatched, so re-send it once
|
|
10543
|
+
* `lifecyclePhase` is back to `"active"` (see {@link SendTurnResult}).
|
|
10084
10544
|
*/
|
|
10085
10545
|
async sendTurn(sessionId, input, options = {}) {
|
|
10086
10546
|
const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns`;
|
|
@@ -10106,16 +10566,15 @@ var SessionsResource = class {
|
|
|
10106
10566
|
return {
|
|
10107
10567
|
kind: "revival_in_progress",
|
|
10108
10568
|
attemptId: revival.attemptId,
|
|
10109
|
-
...revival.turnId !== void 0 && { turnId: revival.turnId }
|
|
10110
|
-
...revival.alreadyReviving !== void 0 && {
|
|
10111
|
-
alreadyReviving: revival.alreadyReviving
|
|
10112
|
-
}
|
|
10569
|
+
...revival.turnId !== void 0 && { turnId: revival.turnId }
|
|
10113
10570
|
};
|
|
10114
10571
|
}
|
|
10115
10572
|
const dispatched = SessionTurnDispatchedResponseSchema.parse(json);
|
|
10116
10573
|
const outcome = dispatched.data.outcome;
|
|
10117
10574
|
if (outcome.kind === "accepted" || outcome.kind === "idempotent_replay") {
|
|
10118
|
-
|
|
10575
|
+
const turnRef = SendTurnTurnRefEnvelopeSchema.safeParse(json);
|
|
10576
|
+
const turn = turnRef.success ? turnRef.data.data.turn : void 0;
|
|
10577
|
+
return { kind: outcome.kind, turnId: outcome.turnId, outcome, ...turn && { turn } };
|
|
10119
10578
|
}
|
|
10120
10579
|
throw new PilotPlatformApiError({
|
|
10121
10580
|
status: res.status,
|
|
@@ -10136,7 +10595,9 @@ var SessionsResource = class {
|
|
|
10136
10595
|
method: "GET",
|
|
10137
10596
|
query: {
|
|
10138
10597
|
afterEventId: options.afterEventId,
|
|
10139
|
-
limit: options.limit
|
|
10598
|
+
limit: options.limit,
|
|
10599
|
+
turnId: options.turnId,
|
|
10600
|
+
types: options.types && options.types.length > 0 ? options.types.join(",") : void 0
|
|
10140
10601
|
},
|
|
10141
10602
|
signal: options.signal,
|
|
10142
10603
|
cache: "no-store"
|
|
@@ -10150,7 +10611,8 @@ var SessionsResource = class {
|
|
|
10150
10611
|
cause: parsed.error
|
|
10151
10612
|
});
|
|
10152
10613
|
}
|
|
10153
|
-
|
|
10614
|
+
const { events, hasMore, cursorReset } = parsed.data.data;
|
|
10615
|
+
return attachPageFields(events, { hasMore, cursorReset });
|
|
10154
10616
|
}
|
|
10155
10617
|
/**
|
|
10156
10618
|
* `GET /api/sessions/:id/delivery-result` — the session-plane delivery
|
|
@@ -10456,21 +10918,39 @@ var SessionsResource = class {
|
|
|
10456
10918
|
}
|
|
10457
10919
|
}
|
|
10458
10920
|
/**
|
|
10459
|
-
* Convenience poller: after `sendTurn`, poll `
|
|
10460
|
-
*
|
|
10461
|
-
*
|
|
10462
|
-
*
|
|
10463
|
-
*
|
|
10464
|
-
*
|
|
10465
|
-
*
|
|
10466
|
-
*
|
|
10467
|
-
*
|
|
10468
|
-
*
|
|
10469
|
-
*
|
|
10470
|
-
*
|
|
10471
|
-
*
|
|
10472
|
-
*
|
|
10473
|
-
*
|
|
10921
|
+
* Convenience poller: after `sendTurn`, poll the TURN (`turns.get`) until
|
|
10922
|
+
* its `status` is terminal, then resolve with the turn and — when one
|
|
10923
|
+
* exists — its terminal worker-protocol event.
|
|
10924
|
+
*
|
|
10925
|
+
* It polls the turn rather than draining `listEvents` because the cost of
|
|
10926
|
+
* the old form scaled with the CONVERSATION, not with the wait: a session
|
|
10927
|
+
* with thousands of streamed chunk rows spent its first polls paging
|
|
10928
|
+
* through history it did not care about, and an `interrupted` turn (worker
|
|
10929
|
+
* died, so no terminal event was ever written) could only ever time out.
|
|
10930
|
+
* A turn's status answers both in one request.
|
|
10931
|
+
*
|
|
10932
|
+
* `terminalEvent` is fetched with a SINGLE `listEvents` call after the
|
|
10933
|
+
* status settles, windowed to this turn and to the terminal event types —
|
|
10934
|
+
* it stays on the result because callers read its payload (e.g.
|
|
10935
|
+
* `completedAt`, which {@link exportWorkspace} needs). It is `undefined`
|
|
10936
|
+
* for an `interrupted` turn, which by construction has no terminal event.
|
|
10937
|
+
*
|
|
10938
|
+
* A 404 `TURN_NOT_FOUND` in the first {@link TURN_VISIBILITY_GRACE_MS} is
|
|
10939
|
+
* treated as "the turn row has not materialized yet" and retried — the
|
|
10940
|
+
* canonical call is `waitForTurn(id, sendTurn(...).turnId)`, and the turn
|
|
10941
|
+
* projection is not guaranteed to have run by the time that returns. After
|
|
10942
|
+
* the grace window the 404 is rethrown UNCHANGED, so a wrong turn id
|
|
10943
|
+
* surfaces as `TURN_NOT_FOUND` within seconds instead of costing the full
|
|
10944
|
+
* (10-minute) deadline.
|
|
10945
|
+
*
|
|
10946
|
+
* **Agent Recovery does not count against that grace.** After a 202
|
|
10947
|
+
* `revival_in_progress`, the prompt is replayed server-side and its turn row
|
|
10948
|
+
* only exists once the replay lands — minutes, not seconds. So on a 404 the
|
|
10949
|
+
* wait asks `sessions.get`: while `pendingRevival` is non-null (or
|
|
10950
|
+
* `lifecyclePhase` is `"reviving"`) the grace window is restarted rather
|
|
10951
|
+
* than consumed, and polling continues until the replay materializes. Only
|
|
10952
|
+
* the overall `timeoutMs` bounds that; a session NOT reviving keeps the
|
|
10953
|
+
* plain 30s behavior.
|
|
10474
10954
|
*
|
|
10475
10955
|
* Throws `SESSION_TURN_WAIT_TIMEOUT` on deadline (default 10 min; managed
|
|
10476
10956
|
* agent turns are long tasks, raise `timeoutMs` for longer runs).
|
|
@@ -10478,31 +10958,37 @@ var SessionsResource = class {
|
|
|
10478
10958
|
async waitForTurn(sessionId, turnId, options = {}) {
|
|
10479
10959
|
const intervalMs = options.intervalMs ?? 1e3;
|
|
10480
10960
|
const timeoutMs = options.timeoutMs ?? 6e5;
|
|
10481
|
-
const pageLimit = 200;
|
|
10482
10961
|
const startedAt = Date.now();
|
|
10483
|
-
|
|
10484
|
-
let
|
|
10962
|
+
const graceMs = Math.min(TURN_VISIBILITY_GRACE_MS, timeoutMs);
|
|
10963
|
+
let graceDeadline = startedAt + graceMs;
|
|
10485
10964
|
while (true) {
|
|
10486
10965
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
if (
|
|
10495
|
-
|
|
10496
|
-
continue;
|
|
10497
|
-
if (payloadTurnId === turnId) {
|
|
10498
|
-
return { terminalEvent: event };
|
|
10966
|
+
let turn;
|
|
10967
|
+
try {
|
|
10968
|
+
turn = await this.turns.get(sessionId, turnId, { signal: options.signal });
|
|
10969
|
+
} catch (error) {
|
|
10970
|
+
if (!isTurnNotFound(error)) throw error;
|
|
10971
|
+
if (await isRevivalPending(this, sessionId, options.signal)) {
|
|
10972
|
+
graceDeadline = Date.now() + graceMs;
|
|
10973
|
+
} else if (Date.now() >= graceDeadline) {
|
|
10974
|
+
throw error;
|
|
10499
10975
|
}
|
|
10500
|
-
if ((
|
|
10501
|
-
|
|
10976
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
10977
|
+
throw new PilotPlatformApiError({
|
|
10978
|
+
status: 0,
|
|
10979
|
+
code: "SESSION_TURN_WAIT_TIMEOUT",
|
|
10980
|
+
message: `Timed out waiting for turn ${turnId} of session ${sessionId} to appear; the session was still recovering.`
|
|
10981
|
+
});
|
|
10502
10982
|
}
|
|
10983
|
+
await sleep(intervalMs, options.signal);
|
|
10984
|
+
continue;
|
|
10985
|
+
}
|
|
10986
|
+
if (isTerminalTurnStatus(turn.status)) {
|
|
10987
|
+
return {
|
|
10988
|
+
terminalEvent: await fetchTerminalEvent(this, sessionId, turnId, options.signal),
|
|
10989
|
+
turn
|
|
10990
|
+
};
|
|
10503
10991
|
}
|
|
10504
|
-
const last = events[events.length - 1];
|
|
10505
|
-
if (last) cursor = last.eventId;
|
|
10506
10992
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
10507
10993
|
throw new PilotPlatformApiError({
|
|
10508
10994
|
status: 0,
|
|
@@ -10510,7 +10996,6 @@ var SessionsResource = class {
|
|
|
10510
10996
|
message: `Timed out waiting for turn ${turnId} of session ${sessionId} to terminate.`
|
|
10511
10997
|
});
|
|
10512
10998
|
}
|
|
10513
|
-
if (events.length === pageLimit) continue;
|
|
10514
10999
|
await sleep(intervalMs, options.signal);
|
|
10515
11000
|
}
|
|
10516
11001
|
}
|
|
@@ -10552,7 +11037,71 @@ async function* parseSseFrames(body, signal) {
|
|
|
10552
11037
|
});
|
|
10553
11038
|
}
|
|
10554
11039
|
}
|
|
11040
|
+
var TURN_VISIBILITY_GRACE_MS = 3e4;
|
|
11041
|
+
function isTurnNotFound(error) {
|
|
11042
|
+
return error instanceof PilotPlatformApiError && error.code === "TURN_NOT_FOUND";
|
|
11043
|
+
}
|
|
11044
|
+
var SessionRevivalStateSchema = import_zod76.z.object({
|
|
11045
|
+
pendingRevival: import_zod76.z.object({ attemptId: import_zod76.z.string() }).nullish(),
|
|
11046
|
+
session: import_zod76.z.object({ lifecyclePhase: import_zod76.z.string().nullish() }).loose().optional()
|
|
11047
|
+
});
|
|
11048
|
+
async function isRevivalPending(sessions, sessionId, signal) {
|
|
11049
|
+
let snapshot;
|
|
11050
|
+
try {
|
|
11051
|
+
snapshot = await sessions.get(sessionId, { signal });
|
|
11052
|
+
} catch (error) {
|
|
11053
|
+
if (signal?.aborted) throw error;
|
|
11054
|
+
return false;
|
|
11055
|
+
}
|
|
11056
|
+
const parsed = SessionRevivalStateSchema.safeParse(snapshot);
|
|
11057
|
+
if (!parsed.success) return false;
|
|
11058
|
+
return (parsed.data.pendingRevival ?? null) !== null || parsed.data.session?.lifecyclePhase === "reviving";
|
|
11059
|
+
}
|
|
11060
|
+
async function fetchTerminalEvent(sessions, sessionId, turnId, signal) {
|
|
11061
|
+
let events;
|
|
11062
|
+
try {
|
|
11063
|
+
events = await sessions.listEvents(sessionId, {
|
|
11064
|
+
turnId,
|
|
11065
|
+
types: [...WORKER_PROTOCOL_TERMINAL_EVENT_TYPES],
|
|
11066
|
+
limit: 10,
|
|
11067
|
+
signal
|
|
11068
|
+
});
|
|
11069
|
+
} catch (error) {
|
|
11070
|
+
if (!isTurnNotFound(error)) throw error;
|
|
11071
|
+
return void 0;
|
|
11072
|
+
}
|
|
11073
|
+
const terminals = events.filter(
|
|
11074
|
+
(event) => WORKER_PROTOCOL_TERMINAL_EVENT_TYPES.includes(event.eventType)
|
|
11075
|
+
);
|
|
11076
|
+
return terminals[terminals.length - 1];
|
|
11077
|
+
}
|
|
11078
|
+
function attachPageFields(events, fields) {
|
|
11079
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
11080
|
+
if (value === void 0) continue;
|
|
11081
|
+
Object.defineProperty(events, key, { value, enumerable: false, configurable: true });
|
|
11082
|
+
}
|
|
11083
|
+
return events;
|
|
11084
|
+
}
|
|
11085
|
+
async function resolveRuntimeBindingId(sessions, sessionId, signal) {
|
|
11086
|
+
const snapshot = await sessions.get(sessionId, { signal });
|
|
11087
|
+
const parsed = SessionRuntimeBindingEnvelopeSchema.safeParse(snapshot);
|
|
11088
|
+
const runtimeBindingId = parsed.success ? parsed.data.runtimeBinding?.id ?? void 0 : void 0;
|
|
11089
|
+
if (!runtimeBindingId) {
|
|
11090
|
+
throw new PilotPlatformApiError({
|
|
11091
|
+
status: 0,
|
|
11092
|
+
code: "RUNTIME_BINDING_NOT_READY",
|
|
11093
|
+
message: `Session ${sessionId} has no active runtime binding; there is no worker to abort.`
|
|
11094
|
+
});
|
|
11095
|
+
}
|
|
11096
|
+
return runtimeBindingId;
|
|
11097
|
+
}
|
|
11098
|
+
function newTraceId() {
|
|
11099
|
+
const cryptoImpl = globalThis.crypto;
|
|
11100
|
+
if (typeof cryptoImpl?.randomUUID === "function") return cryptoImpl.randomUUID();
|
|
11101
|
+
return `sdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
11102
|
+
}
|
|
10555
11103
|
function sleep(ms, signal) {
|
|
11104
|
+
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
10556
11105
|
if (ms <= 0) return Promise.resolve();
|
|
10557
11106
|
return new Promise((resolve, reject) => {
|
|
10558
11107
|
const timer = setTimeout(resolve, ms);
|
|
@@ -10568,11 +11117,11 @@ function sleep(ms, signal) {
|
|
|
10568
11117
|
}
|
|
10569
11118
|
|
|
10570
11119
|
// src/resources/workloads.ts
|
|
10571
|
-
var
|
|
10572
|
-
var CanaryPromoteResponseSchema =
|
|
11120
|
+
var import_zod77 = require("zod");
|
|
11121
|
+
var CanaryPromoteResponseSchema = import_zod77.z.object({
|
|
10573
11122
|
slot: StageSlotViewSchema,
|
|
10574
|
-
fromRevisionId:
|
|
10575
|
-
toRevisionId:
|
|
11123
|
+
fromRevisionId: import_zod77.z.string().uuid(),
|
|
11124
|
+
toRevisionId: import_zod77.z.string().uuid()
|
|
10576
11125
|
}).strict();
|
|
10577
11126
|
var WorkloadStageCanaryResource = class {
|
|
10578
11127
|
constructor(client) {
|
|
@@ -11226,6 +11775,40 @@ function mergeSignals(...signals) {
|
|
|
11226
11775
|
}
|
|
11227
11776
|
return controller.signal;
|
|
11228
11777
|
}
|
|
11778
|
+
|
|
11779
|
+
// src/ui-messages.ts
|
|
11780
|
+
function toUIMessages(turns) {
|
|
11781
|
+
const messages = [];
|
|
11782
|
+
for (const turn of [...turns].sort(compareByDispatch)) {
|
|
11783
|
+
const userMessage = {
|
|
11784
|
+
id: turn.user.messageId,
|
|
11785
|
+
role: "user",
|
|
11786
|
+
parts: [{ type: "text", text: turn.user.text }]
|
|
11787
|
+
};
|
|
11788
|
+
if (turn.user.attachments.length > 0) {
|
|
11789
|
+
userMessage.metadata = { attachments: turn.user.attachments };
|
|
11790
|
+
}
|
|
11791
|
+
messages.push(userMessage);
|
|
11792
|
+
if (turn.assistant === null) continue;
|
|
11793
|
+
const assistantMessage = {
|
|
11794
|
+
id: turn.assistant.messageId,
|
|
11795
|
+
role: "assistant",
|
|
11796
|
+
parts: turn.assistant.parts
|
|
11797
|
+
};
|
|
11798
|
+
if (turn.assistant.state === "truncated") {
|
|
11799
|
+
assistantMessage.metadata = { truncated: true };
|
|
11800
|
+
}
|
|
11801
|
+
messages.push(assistantMessage);
|
|
11802
|
+
}
|
|
11803
|
+
return messages;
|
|
11804
|
+
}
|
|
11805
|
+
function compareByDispatch(a, b) {
|
|
11806
|
+
const aTime = Date.parse(a.dispatchedAt);
|
|
11807
|
+
const bTime = Date.parse(b.dispatchedAt);
|
|
11808
|
+
const byTime = Number.isNaN(aTime) || Number.isNaN(bTime) ? a.dispatchedAt.localeCompare(b.dispatchedAt) : aTime - bTime;
|
|
11809
|
+
if (byTime !== 0) return byTime;
|
|
11810
|
+
return a.turnId.localeCompare(b.turnId);
|
|
11811
|
+
}
|
|
11229
11812
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11230
11813
|
0 && (module.exports = {
|
|
11231
11814
|
AGENTHUB_SDK_USER_AGENT,
|
|
@@ -11308,10 +11891,20 @@ function mergeSignals(...signals) {
|
|
|
11308
11891
|
SessionFileResourceSchema,
|
|
11309
11892
|
SessionMemorySubjectDeclarationSchema,
|
|
11310
11893
|
SessionResourcesSchema,
|
|
11894
|
+
SessionTurnsResource,
|
|
11311
11895
|
SessionsResource,
|
|
11312
11896
|
StageSchema,
|
|
11313
11897
|
StageSlotViewSchema,
|
|
11314
11898
|
StoredMemorySubjectPolicySchema,
|
|
11899
|
+
TERMINAL_TURN_STATUSES,
|
|
11900
|
+
TURN_LIST_DEFAULT_LIMIT,
|
|
11901
|
+
TURN_LIST_MAX_LIMIT,
|
|
11902
|
+
TurnAssistantPartSchema,
|
|
11903
|
+
TurnKindSchema,
|
|
11904
|
+
TurnListQuerySchema,
|
|
11905
|
+
TurnListResponseDataSchema,
|
|
11906
|
+
TurnSchema,
|
|
11907
|
+
TurnStatusSchema,
|
|
11315
11908
|
UpdateEnvironmentInputSchema,
|
|
11316
11909
|
WorkbenchDTOSchema,
|
|
11317
11910
|
WorkloadStageCanaryResource,
|
|
@@ -11321,8 +11914,11 @@ function mergeSignals(...signals) {
|
|
|
11321
11914
|
WriteMemoriesRequestSchema,
|
|
11322
11915
|
WriteMemoriesResultSchema,
|
|
11323
11916
|
WriteMemoryItemSchema,
|
|
11917
|
+
isTerminalTurnStatus,
|
|
11324
11918
|
pilotPlatformErrorFromResponse,
|
|
11325
11919
|
platformRevisionPublishToManifest,
|
|
11326
|
-
platformWorkloadCreateToManifest
|
|
11920
|
+
platformWorkloadCreateToManifest,
|
|
11921
|
+
toUIMessages,
|
|
11922
|
+
turnMessageIds
|
|
11327
11923
|
});
|
|
11328
11924
|
//# sourceMappingURL=index.cjs.map
|