@kanyun-ai-infra/agenthub 1.5.2 → 1.7.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 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",
@@ -4920,9 +4935,18 @@ var DeliveryResultArtifactItemSchema = import_zod42.z.object({
4920
4935
  /** Artifact category. Workers MAY add new kinds; storage is opaque. */
4921
4936
  kind: import_zod42.z.enum(["diff", "log", "general"]),
4922
4937
  /**
4923
- * Logical path inside the sandbox workspace (used as the idempotency
4924
- * key together with `runId`). Two writes with the same `(runId, path)`
4925
- * pair collapse to a single row via `ON CONFLICT DO NOTHING`.
4938
+ * Logical path inside the sandbox workspace, and the idempotency key of
4939
+ * the artifact row: `(runId, path)` on the run plane, `(sessionId, path)`
4940
+ * on the session plane. Two writes with the same pair collapse to a single
4941
+ * row — the run plane keeps the first (`ON CONFLICT DO NOTHING`), the
4942
+ * session plane keeps the newest bytes and moves `turn_id` to the newest
4943
+ * ATTRIBUTED writer (`ON CONFLICT DO UPDATE`, T-INV-5).
4944
+ *
4945
+ * Two items with the SAME path inside one request body are legal wire but
4946
+ * a single artifact: the session plane de-duplicates them before the
4947
+ * insert, last one wins, and `artifactsInserted` counts the de-duplicated
4948
+ * items. Not a 400 — see `turnId` below on why an artifact-shaped problem
4949
+ * must not be the reason a delivery result is lost.
4926
4950
  */
4927
4951
  path: import_zod42.z.string().min(1).max(1024),
4928
4952
  /** Object key inside the OSS bucket where the artifact was uploaded. */
@@ -4940,6 +4964,26 @@ var DeliveryResultArtifactItemSchema = import_zod42.z.object({
4940
4964
  contentType: import_zod42.z.string().min(1).max(255)
4941
4965
  }).strict();
4942
4966
  var DeliveryResultUpdateSchema = import_zod42.z.object({
4967
+ /**
4968
+ * The turn this delivery result belongs to — `ctx.turnId` on the worker
4969
+ * side (`deriveWorkerTurnId`, uuid v5). Drives `artifacts.turn_id`; see
4970
+ * `specs/features/pilot-v2-session-turns.md` §Projection 6.
4971
+ *
4972
+ * Optional through the migration window: a sandbox image predating P2
4973
+ * omits it, and the control plane then INFERS the turn and records an
4974
+ * anomaly rather than rejecting the write. Delivery attribution must not
4975
+ * become a reason a delivery fails — which is also why an id that names no
4976
+ * turn of THIS session degrades to the same inference (plus a warn log and
4977
+ * the anomaly naming the rejected id) instead of failing the request. The
4978
+ * id is still never honoured across sessions: `artifacts.turn_id` has no
4979
+ * foreign key, so a foreign id would attach these artifacts to a turn
4980
+ * another session's `GET /turns` serves.
4981
+ *
4982
+ * Deliberately NOT part of the `.refine()` below: it qualifies the other
4983
+ * fields rather than mutating anything, so a body carrying only `turnId`
4984
+ * is still the empty request it looks like, and still a 400.
4985
+ */
4986
+ turnId: import_zod42.z.string().uuid().optional(),
4943
4987
  /**
4944
4988
  * The PR / MR URL the agent created. First-write-wins per spec
4945
4989
  * (`UPDATE ... WHERE pull_request_url IS NULL`); subsequent writes
@@ -4948,10 +4992,11 @@ var DeliveryResultUpdateSchema = import_zod42.z.object({
4948
4992
  */
4949
4993
  pullRequestUrl: import_zod42.z.string().url().max(1024).optional(),
4950
4994
  /**
4951
- * Append-set of artifacts uploaded for this run. Each item is
4952
- * upserted independently via the `unique(run_id, path)` constraint;
4953
- * the response indicates how many of the submitted items resulted
4954
- * in a new row.
4995
+ * Append-set of artifacts uploaded for this run. Each item is upserted
4996
+ * independently via the `unique(run_id, path)` / `unique(session_id, path)`
4997
+ * constraint; the response indicates how many of the submitted items
4998
+ * resulted in a new row. Items are keyed by `path` — see the field's own
4999
+ * doc for what a repeated path inside one body means.
4955
5000
  */
4956
5001
  artifacts: import_zod42.z.array(DeliveryResultArtifactItemSchema).max(64).optional(),
4957
5002
  /**
@@ -5172,7 +5217,45 @@ var WorkerProtocolFailedPayloadSchema = import_zod44.z.object({
5172
5217
  }).strict().refine((p) => p.reason !== "wp_aborted_by_signal" || p.abortContext !== void 0, {
5173
5218
  message: "abortContext required when reason = wp_aborted_by_signal"
5174
5219
  });
5220
+ var TurnUsageSchema = import_zod44.z.object({
5221
+ /** Whether the provider reported any token counts for this turn. */
5222
+ usageSource: import_zod44.z.enum(["provider", "missing"]),
5223
+ /** Prompt tokens, cache reads/writes included. */
5224
+ inputTokens: import_zod44.z.number().int().nonnegative().optional(),
5225
+ outputTokens: import_zod44.z.number().int().nonnegative().optional(),
5226
+ /** `inputTokens + outputTokens`. */
5227
+ totalTokens: import_zod44.z.number().int().nonnegative().optional(),
5228
+ /** Breakdown of `inputTokens` — cached prompt tokens read back. */
5229
+ cacheReadInputTokens: import_zod44.z.number().int().nonnegative().optional(),
5230
+ /** Breakdown of `inputTokens` — prompt tokens written into the cache. */
5231
+ cacheWriteInputTokens: import_zod44.z.number().int().nonnegative().optional(),
5232
+ /** Provider-stream duration; see the timing note above. */
5233
+ durationMs: import_zod44.z.number().int().nonnegative().optional(),
5234
+ timeToFirstTokenMs: import_zod44.z.number().int().nonnegative().optional(),
5235
+ /** AI SDK `finishReason` of the last step ("stop" / "tool-calls" / …). */
5236
+ finishReason: import_zod44.z.string().min(1).optional(),
5237
+ /** Absent whenever `usageSource === "missing"`. */
5238
+ costUsd: import_zod44.z.number().nonnegative().optional(),
5239
+ /** Which upstream reported `costUsd`; paired with it, absent without it. */
5240
+ costSource: import_zod44.z.literal("claude_code_cli").optional(),
5241
+ /** Provider steps observed in the turn — 2 after a mid-turn stream resume. */
5242
+ stepCount: import_zod44.z.number().int().nonnegative().optional()
5243
+ });
5175
5244
  var WorkerProtocolCompletedPayloadSchema = import_zod44.z.record(import_zod44.z.string(), import_zod44.z.unknown());
5245
+ var SessionUsageSummarySchema = import_zod44.z.object({
5246
+ turnsWithUsage: import_zod44.z.number().int().nonnegative(),
5247
+ turnsMissingUsage: import_zod44.z.number().int().nonnegative(),
5248
+ inputTokens: import_zod44.z.number().int().nonnegative(),
5249
+ outputTokens: import_zod44.z.number().int().nonnegative(),
5250
+ totalTokens: import_zod44.z.number().int().nonnegative(),
5251
+ cacheReadInputTokens: import_zod44.z.number().int().nonnegative(),
5252
+ cacheWriteInputTokens: import_zod44.z.number().int().nonnegative(),
5253
+ /** `null` when no contributing turn reported a cost. */
5254
+ costUsd: import_zod44.z.number().nonnegative().nullable(),
5255
+ costSource: import_zod44.z.literal("claude_code_cli").nullable(),
5256
+ /** ISO timestamp of the latest completed turn that contributed usage. */
5257
+ lastUpdatedAt: import_zod44.z.string().nullable()
5258
+ });
5176
5259
  var EVENT_TYPE_REGEX = /^([a-z][a-z0-9_]*)\.([a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)?)$/;
5177
5260
  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
5261
  var EVENT_DOMAINS = [
@@ -5599,7 +5682,28 @@ var RecordWorkspaceSnapshotRequestSchema = import_zod50.z.object({
5599
5682
  * parts may be null ("nothing to restore" — a valid no-op snapshot, NOT
5600
5683
  * a failure, per 已定方案 决策②).
5601
5684
  */
5602
- snapshot: WorkspaceSnapshotSchema
5685
+ snapshot: WorkspaceSnapshotSchema,
5686
+ /**
5687
+ * The turn whose end produced this snapshot (`ctx.turnId`, uuid v5 from
5688
+ * `deriveWorkerTurnId`). The control plane stamps
5689
+ * `session_turns.workspace_snapshot_captured_at` on that row; the stored
5690
+ * snapshot JSON and its session-level latest-wins semantics are unchanged.
5691
+ *
5692
+ * **It lives on the ENVELOPE, not inside `snapshot`** (T-INV-6).
5693
+ * `WorkspaceSnapshotSchema` is `.strict()` and is re-used verbatim as
5694
+ * `PodAgentStartWorkerRequestSchema.workspaceSnapshot`, which travels
5695
+ * control-plane → pod-agent: a key added there makes every pod-agent
5696
+ * older than the change reject `POST /pilot/worker/start`. The contract
5697
+ * test in `__tests__/pilot-v2-workspace-snapshot.test.ts` pins this.
5698
+ *
5699
+ * Optional for one migration window. This envelope is `.strict()`, so a
5700
+ * worker that sends `turnId` to a control plane predating this field gets
5701
+ * a 400 and loses the snapshot entirely — **control-plane and agent-hub
5702
+ * MUST ship before the sandbox image**. Until the window closes the
5703
+ * control plane infers the turn (most recent completed one) when it is
5704
+ * absent; after it, this becomes required.
5705
+ */
5706
+ turnId: import_zod50.z.string().uuid().optional()
5603
5707
  }).strict();
5604
5708
  var RecordWorkspaceSnapshotResponseSchema = import_zod50.z.object({
5605
5709
  success: import_zod50.z.literal(true),
@@ -5632,44 +5736,54 @@ var WorkspaceExportPartSchema = WorkspaceSnapshotPartSchema.extend({
5632
5736
  var WorkspaceExportDataSchema = import_zod50.z.object({
5633
5737
  version: import_zod50.z.literal("v1"),
5634
5738
  /**
5635
- * Opaque monotonic cursor identifying this capture. **Not a turn ordinal**
5739
+ * **Internal ordering cursor. Prefer {@link WorkspaceExportDataSchema.shape.turnId}.**
5740
+ *
5741
+ * Opaque monotonic value identifying this capture. **Not a turn ordinal**
5636
5742
  * despite the name: the capture side sets it to `capturedAt.getTime()`
5637
5743
  * (epoch milliseconds, sandbox clock). The name is fixed by the stored
5638
5744
  * `WorkspaceSnapshot` envelope. Never render it as "turn N".
5639
5745
  *
5640
- * Its one job for a caller is deciding **whether the snapshot is this turn's
5641
- * or the previous turn's**. The worker emits the turn's terminal event
5642
- * BEFORE it captures and uploads, so an export issued the moment a turn
5643
- * completes races the capture: it returns either 404 or the PRIOR turn's
5644
- * snapshot. Compare against `completedAt` from the terminal event payload —
5645
- * both come from the same in-sandbox clock, and the capture is ordered after
5646
- * the terminal append — and poll until
5647
- * `capturedAtTurn >= Date.parse(completedAt)`, with a bounded timeout.
5648
- *
5649
- * **`>=`, not `>`.** The two readings are `ctx.now()` calls in one process
5650
- * separated by a single `await`, at millisecond resolution, so they can land
5651
- * on the SAME millisecond. Under a strict `>` that turn's own snapshot never
5652
- * satisfies the test, and the caller polls out the timeout and concludes "no
5653
- * files" for a turn that did produce them — a wrong answer that looks like a
5654
- * normal one.
5655
- *
5656
- * `>=` cannot admit the previous turn's snapshot: that capture happens in the
5657
- * tail of turn N-1, before turn N is dispatched at all, so it precedes turn
5658
- * N's `completedAt` by a whole turn (turns are serial per session — a second
5659
- * concurrent turn is refused with `SESSION_TURN_IN_PROGRESS`). Equality is
5660
- * only reachable within one turn, between its own terminal and its own
5661
- * capture.
5662
- *
5663
- * Residual limit, deliberately not papered over: if the sandbox clock steps
5664
- * BACKWARDS between the terminal append and the capture (NTP correction),
5665
- * `capturedAtTurn` lands before `completedAt` and neither `>` nor `>=`
5666
- * accepts it. The poll then times out, and the caller cannot distinguish that
5667
- * from "nothing was produced". Anchoring the snapshot to a turn identity
5668
- * rather than a timestamp is the real fix — see the spec's follow-ups.
5746
+ * Its remaining job is the platform's own latest-wins comparison on the
5747
+ * recording path. The freshness question it used to answer for callers —
5748
+ * "is this snapshot my turn's or the previous turn's?" — is now answered
5749
+ * directly by `turnId`: compare it against the turn you dispatched instead
5750
+ * of comparing timestamps. The old recipe (poll until
5751
+ * `capturedAtTurn >= Date.parse(completedAt)`, `>=` and not `>` because the
5752
+ * two `ctx.now()` readings can land on the same millisecond) still works and
5753
+ * is the only option against a sandbox image predating P2, but it carries a
5754
+ * failure mode `turnId` does not: a BACKWARD sandbox clock step (NTP
5755
+ * correction) between the terminal append and the capture puts
5756
+ * `capturedAtTurn` before `completedAt`, and neither `>` nor `>=` accepts
5757
+ * it — the poll then times out and looks exactly like "nothing was
5758
+ * produced".
5759
+ *
5760
+ * The race itself is unchanged either way: the worker emits the turn's
5761
+ * terminal event BEFORE it captures and uploads, so an export issued the
5762
+ * moment a turn completes returns either 404 or the PRIOR turn's snapshot.
5763
+ * Poll with a bounded timeout; with `turnId` the predicate is equality
5764
+ * against your own turn, so there is nothing to reason about clocks.
5669
5765
  */
5670
5766
  capturedAtTurn: import_zod50.z.number().int().nonnegative(),
5671
5767
  /** ISO-8601 capture time — the field to show a human. */
5672
5768
  capturedAt: import_zod50.z.string().min(1),
5769
+ /**
5770
+ * The turn whose end produced this snapshot, when the platform knows it.
5771
+ * This is the field a caller polls on: the export is this turn's iff
5772
+ * `turnId` equals the turn id it dispatched — no clock comparison, and
5773
+ * immune to the backward-clock-step hole in `capturedAtTurn`.
5774
+ *
5775
+ * Absent (or attributed to an earlier turn than you expect) in three cases,
5776
+ * all of which mean "not yours yet", not "broken":
5777
+ * 1. the snapshot was recorded by a sandbox image predating the envelope
5778
+ * `turnId` — the platform then attributes it to the most recent
5779
+ * completed turn and flags the inference;
5780
+ * 2. the turn's projection had not materialized its `session_turns` row
5781
+ * when the snapshot landed, so there was no row to stamp;
5782
+ * 3. the session predates this field entirely.
5783
+ * Keep the `capturedAtTurn` fallback for those; do not treat a missing
5784
+ * `turnId` as an error.
5785
+ */
5786
+ turnId: import_zod50.z.string().uuid().nullable().optional(),
5673
5787
  parts: import_zod50.z.object({
5674
5788
  repoBundle: WorkspaceExportPartSchema.nullable(),
5675
5789
  externalArchive: WorkspaceExportPartSchema.nullable()
@@ -7358,17 +7472,301 @@ var SessionTurnRequestSchema = import_zod57.z.object({
7358
7472
  }).strict();
7359
7473
  var SessionTurnDispatchedResponseSchema = import_zod57.z.object({
7360
7474
  success: import_zod57.z.literal(true),
7361
- data: import_zod57.z.object({ outcome: DispatchOutcomeSchema })
7475
+ data: import_zod57.z.object({
7476
+ outcome: DispatchOutcomeSchema,
7477
+ turn: import_zod57.z.object({
7478
+ turnId: import_zod57.z.string().min(1),
7479
+ status: import_zod57.z.literal("dispatched")
7480
+ }).optional()
7481
+ })
7362
7482
  });
7363
7483
  var SessionTurnRevivalResponseSchema = import_zod57.z.object({
7364
7484
  success: import_zod57.z.literal(false),
7365
7485
  revivalInProgress: import_zod57.z.literal(true),
7366
7486
  sessionId: import_zod57.z.string(),
7367
7487
  attemptId: import_zod57.z.string(),
7368
- alreadyReviving: import_zod57.z.boolean().optional(),
7369
7488
  turnId: import_zod57.z.string().optional()
7370
7489
  });
7371
- var GatewayErrorCodeSchema = import_zod58.z.enum([
7490
+ var TurnStatusSchema = import_zod58.z.enum([
7491
+ "dispatched",
7492
+ "running",
7493
+ "completed",
7494
+ "failed",
7495
+ "rejected",
7496
+ "aborted",
7497
+ "interrupted"
7498
+ ]);
7499
+ var TERMINAL_TURN_STATUSES = [
7500
+ "completed",
7501
+ "failed",
7502
+ "rejected",
7503
+ "aborted",
7504
+ "interrupted"
7505
+ ];
7506
+ function isTerminalTurnStatus(status) {
7507
+ return TERMINAL_TURN_STATUSES.includes(status);
7508
+ }
7509
+ var TurnKindSchema = import_zod58.z.enum(["prompt", "followup"]);
7510
+ var TurnPhaseSchema = import_zod58.z.enum(["generating", "delivering"]);
7511
+ var AssistantMessageStateSchema = import_zod58.z.enum(["streaming", "complete", "truncated"]);
7512
+ var DeliveryStateSchema = import_zod58.z.enum([
7513
+ "not_started",
7514
+ "in_progress",
7515
+ "completed",
7516
+ "failed",
7517
+ "interrupted"
7518
+ ]);
7519
+ var ArtifactBundleStateSchema = import_zod58.z.enum([
7520
+ "collecting",
7521
+ "available",
7522
+ "superseded_by_retry",
7523
+ "rejected"
7524
+ ]);
7525
+ var DELIVERY_PROGRESS_STEPS = ["git_push", "create_mr", "upload_artifact"];
7526
+ var DeliveryProgressStepSchema = import_zod58.z.enum(DELIVERY_PROGRESS_STEPS);
7527
+ var TurnAnomalySchema = import_zod58.z.object({
7528
+ code: import_zod58.z.string().min(1),
7529
+ /** `session_events.id` of the row that triggered it, when there is one. */
7530
+ eventId: import_zod58.z.string().optional(),
7531
+ detail: import_zod58.z.string().optional()
7532
+ });
7533
+ var TurnAssistantPartStateSchema = import_zod58.z.enum(["streaming", "done"]);
7534
+ var TurnToolPartStateSchema = import_zod58.z.enum([
7535
+ "input-streaming",
7536
+ "input-available",
7537
+ "output-available",
7538
+ "output-error"
7539
+ ]);
7540
+ var TurnAssistantTextPartSchema = import_zod58.z.object({
7541
+ type: import_zod58.z.literal("text"),
7542
+ text: import_zod58.z.string(),
7543
+ state: TurnAssistantPartStateSchema.optional()
7544
+ });
7545
+ var TurnAssistantReasoningPartSchema = import_zod58.z.object({
7546
+ type: import_zod58.z.literal("reasoning"),
7547
+ text: import_zod58.z.string(),
7548
+ state: TurnAssistantPartStateSchema.optional()
7549
+ });
7550
+ var TurnAssistantToolPartSchema = import_zod58.z.object({
7551
+ type: import_zod58.z.literal("dynamic-tool"),
7552
+ toolName: import_zod58.z.string(),
7553
+ toolCallId: import_zod58.z.string(),
7554
+ state: TurnToolPartStateSchema,
7555
+ input: import_zod58.z.unknown().optional(),
7556
+ output: import_zod58.z.unknown().optional(),
7557
+ errorText: import_zod58.z.string().optional()
7558
+ });
7559
+ var TurnAssistantStepPartSchema = import_zod58.z.object({
7560
+ type: import_zod58.z.literal("step-start")
7561
+ });
7562
+ var TurnAssistantPartSchema = import_zod58.z.discriminatedUnion("type", [
7563
+ TurnAssistantTextPartSchema,
7564
+ TurnAssistantReasoningPartSchema,
7565
+ TurnAssistantToolPartSchema,
7566
+ TurnAssistantStepPartSchema
7567
+ ]);
7568
+ var TurnUserMessageSchema = import_zod58.z.object({
7569
+ messageId: import_zod58.z.string(),
7570
+ text: import_zod58.z.string(),
7571
+ attachments: import_zod58.z.array(AttachmentMetaSchema),
7572
+ createdAt: import_zod58.z.string()
7573
+ });
7574
+ var TurnAssistantMessageSchema = import_zod58.z.object({
7575
+ messageId: import_zod58.z.string(),
7576
+ state: AssistantMessageStateSchema,
7577
+ parts: import_zod58.z.array(TurnAssistantPartSchema),
7578
+ /** Chunks the fold could not interpret. Non-zero means data loss. */
7579
+ droppedChunks: import_zod58.z.number().int().nonnegative(),
7580
+ /**
7581
+ * `retained` marks an assistant message whose source chunks were deleted by
7582
+ * the event retention sweep: this row IS the record now, and a projection
7583
+ * re-run may add to it but must never blank it (T-INV-9).
7584
+ */
7585
+ source: import_zod58.z.literal("retained").optional()
7586
+ });
7587
+ var TurnDeliverySchema = import_zod58.z.object({
7588
+ state: DeliveryStateSchema,
7589
+ /** Last observed wire step; `z.string()` so an unknown value still reads. */
7590
+ step: import_zod58.z.string().optional(),
7591
+ attempts: import_zod58.z.number().int().nonnegative(),
7592
+ pullRequestUrl: import_zod58.z.string().optional(),
7593
+ failedReason: import_zod58.z.string().optional(),
7594
+ failedAt: import_zod58.z.string().optional()
7595
+ });
7596
+ var TurnArtifactBundleSchema = import_zod58.z.object({
7597
+ /** Absent for a `rejected` bundle — nothing was uploaded, so there is no row. */
7598
+ artifactId: import_zod58.z.string().optional(),
7599
+ state: ArtifactBundleStateSchema,
7600
+ /**
7601
+ * MUST STAY A PLAIN `number` — widening it to `.nullable()` is a wire break,
7602
+ * not an additive change. `@kanyun-ai-infra/agenthub` bundles contracts into
7603
+ * its published artifact (`noExternal: ["@pilot/contracts"]`), so SDK 1.6.0
7604
+ * carries a FROZEN copy of this schema with `entryCount` a required number.
7605
+ * Old readers tolerate keys they have never heard of (every envelope on the
7606
+ * turn read path is a non-strict `z.object`, which strips them) but not a
7607
+ * value outside the type they froze: a `null` here makes 1.6.0's
7608
+ * `sessions.turns.get` / `.list` throw `MALFORMED_PLATFORM_RESPONSE` for
7609
+ * every turn that has any artifact row at all.
7610
+ *
7611
+ * So "not counted" travels as `0` plus {@link entryCountKnown} `false`
7612
+ * rather than as `null`. The real count lives in the manifest inside the zip
7613
+ * in object storage, and the read path that produces a `Turn` does not fan
7614
+ * out to object storage to get it; to see the actual entries, follow
7615
+ * `TurnArtifacts.incrementalHref` / `cumulativeHref` on the parent object.
7616
+ */
7617
+ entryCount: import_zod58.z.number().int().nonnegative(),
7618
+ /**
7619
+ * Is {@link entryCount} a measurement? Absent or `false` means it is not —
7620
+ * the `0` above is a placeholder, NOT an empty bundle. Optional so the key
7621
+ * itself is additive: a reader frozen before it existed drops it and still
7622
+ * parses, and one that has it must treat "absent" as "unknown" too, because
7623
+ * that is exactly what a pre-P2 control plane sends.
7624
+ *
7625
+ * `true` is reserved for a build that really counts the manifest entries.
7626
+ * Nothing sets it today.
7627
+ */
7628
+ entryCountKnown: import_zod58.z.boolean().optional(),
7629
+ createdAt: import_zod58.z.string(),
7630
+ reason: import_zod58.z.string().optional()
7631
+ });
7632
+ var TurnArtifactsSchema = import_zod58.z.object({
7633
+ bundles: import_zod58.z.array(TurnArtifactBundleSchema),
7634
+ incrementalHref: import_zod58.z.string(),
7635
+ cumulativeHref: import_zod58.z.string()
7636
+ });
7637
+ var TurnStatusReasonSchema = import_zod58.z.object({
7638
+ code: import_zod58.z.string(),
7639
+ message: import_zod58.z.string()
7640
+ });
7641
+ var TurnAbortRequestSchema = import_zod58.z.object({
7642
+ requestedAt: import_zod58.z.string(),
7643
+ eventId: import_zod58.z.string()
7644
+ });
7645
+ var TurnSeqRangeSchema = import_zod58.z.object({
7646
+ start: import_zod58.z.number().int().nullable(),
7647
+ end: import_zod58.z.number().int().nullable()
7648
+ });
7649
+ var TurnContextStateSchema = import_zod58.z.enum(["live", "compacted"]);
7650
+ var TurnMemoryRecallStateSchema = import_zod58.z.enum([
7651
+ "selected",
7652
+ "empty",
7653
+ "recall_failed",
7654
+ "unavailable",
7655
+ "legacy"
7656
+ ]);
7657
+ var TurnSchema = import_zod58.z.object({
7658
+ turnId: import_zod58.z.string(),
7659
+ kind: TurnKindSchema,
7660
+ parentTurnId: import_zod58.z.string().nullable(),
7661
+ /** Pairs the turn with `${kind}:${idempotencyKey}`-shaped side events. */
7662
+ idempotencyKey: import_zod58.z.string(),
7663
+ status: TurnStatusSchema,
7664
+ revival: import_zod58.z.object({ attemptId: import_zod58.z.string() }).optional(),
7665
+ phase: TurnPhaseSchema.optional(),
7666
+ statusReason: TurnStatusReasonSchema.optional(),
7667
+ user: TurnUserMessageSchema,
7668
+ assistant: TurnAssistantMessageSchema.nullable(),
7669
+ delivery: TurnDeliverySchema.nullable(),
7670
+ /**
7671
+ * Returned from P2 on, once `artifacts.turn_id` exists — attribution before
7672
+ * that column is a path regex, and shipping a guessed answer would teach
7673
+ * consumers to trust it. Absent means "not populated yet", never "no
7674
+ * artifacts".
7675
+ */
7676
+ artifacts: TurnArtifactsSchema.optional(),
7677
+ /**
7678
+ * Returned from P2 on, with the `POST /workspace-snapshot` envelope's
7679
+ * `turnId` (T-INV-6). Absent means "not populated yet"; `null` means this
7680
+ * turn is not the source of the session's current snapshot.
7681
+ */
7682
+ workspaceSnapshot: import_zod58.z.object({ capturedAt: import_zod58.z.string() }).nullable().optional(),
7683
+ context: import_zod58.z.object({ state: TurnContextStateSchema }),
7684
+ memoryRecall: import_zod58.z.object({ state: TurnMemoryRecallStateSchema }).optional(),
7685
+ abort: TurnAbortRequestSchema.nullable(),
7686
+ seqRange: TurnSeqRangeSchema,
7687
+ traceId: import_zod58.z.string().nullable(),
7688
+ anomalies: import_zod58.z.array(TurnAnomalySchema),
7689
+ dispatchedAt: import_zod58.z.string(),
7690
+ acceptedAt: import_zod58.z.string().optional(),
7691
+ completedAt: import_zod58.z.string().optional()
7692
+ });
7693
+ var TurnListResponseDataSchema = import_zod58.z.object({
7694
+ turns: import_zod58.z.array(TurnSchema),
7695
+ hasMore: import_zod58.z.boolean(),
7696
+ nextCursor: import_zod58.z.string().nullable(),
7697
+ prevCursor: import_zod58.z.string().nullable(),
7698
+ /** Session-wide `max(__seq)`; usable directly as `Last-Event-ID`. */
7699
+ streamCursor: import_zod58.z.number().int().nullable()
7700
+ });
7701
+ var TURN_LIST_DEFAULT_LIMIT = 20;
7702
+ var TURN_LIST_MAX_LIMIT = 100;
7703
+ var TurnListQuerySchema = import_zod58.z.object({
7704
+ limit: import_zod58.z.coerce.number().int().min(1).max(TURN_LIST_MAX_LIMIT).default(TURN_LIST_DEFAULT_LIMIT),
7705
+ order: import_zod58.z.enum(["desc", "asc"]).default("desc"),
7706
+ before: import_zod58.z.string().min(1).optional(),
7707
+ after: import_zod58.z.string().min(1).optional(),
7708
+ /**
7709
+ * Comma-separated status filter, e.g. `status=completed,failed`. Same wire
7710
+ * form as `SessionEventsQuerySchema.types`: every route mount parses its
7711
+ * query via `Object.fromEntries(new URL(url).searchParams)`, which keeps
7712
+ * only the LAST value of a repeated key, so `status=a&status=b` would
7713
+ * silently filter for `b` alone. Each item must be a `TurnStatus`.
7714
+ */
7715
+ status: import_zod58.z.string().optional().transform((value, ctx) => {
7716
+ if (value === void 0) return void 0;
7717
+ const items = value.split(",").filter((s) => s.length > 0);
7718
+ const parsed = import_zod58.z.array(TurnStatusSchema).safeParse(items);
7719
+ if (!parsed.success) {
7720
+ ctx.addIssue({ code: "custom", message: `unknown turn status in: ${value}` });
7721
+ return import_zod58.z.NEVER;
7722
+ }
7723
+ return parsed.data;
7724
+ }),
7725
+ revivalAttemptId: import_zod58.z.string().uuid().optional()
7726
+ }).refine((q) => !(q.before !== void 0 && q.after !== void 0), {
7727
+ message: "before and after are mutually exclusive",
7728
+ path: ["before"]
7729
+ });
7730
+ function turnMessageIds(turnId) {
7731
+ return { user: `${turnId}:u`, assistant: `${turnId}:a` };
7732
+ }
7733
+ var SESSION_EVENTS_DEFAULT_LIMIT = 100;
7734
+ var SESSION_EVENTS_MAX_LIMIT = 500;
7735
+ var SessionEventsQuerySchema = import_zod59.z.object({
7736
+ afterEventId: import_zod59.z.string().min(1).optional(),
7737
+ limit: import_zod59.z.coerce.number().int().min(1).max(SESSION_EVENTS_MAX_LIMIT).default(SESSION_EVENTS_DEFAULT_LIMIT),
7738
+ turnId: import_zod59.z.string().uuid().optional(),
7739
+ /**
7740
+ * Comma-separated `event_type` values, e.g.
7741
+ * `types=worker_protocol.prompt.dispatched,pilot_coder.chunk`.
7742
+ *
7743
+ * NOT `types=a&types=b` (repeated keys): every route mount parses its
7744
+ * query string via `Object.fromEntries(new URL(request.url).searchParams)`,
7745
+ * which keeps only the LAST value for a repeated key — a `types=a&types=b`
7746
+ * request would silently filter for `b` alone. Comma-separated is the one
7747
+ * form that survives that parsing unchanged.
7748
+ */
7749
+ types: import_zod59.z.string().optional().transform(
7750
+ (value) => value === void 0 ? void 0 : value.split(",").filter((t) => t.length > 0)
7751
+ )
7752
+ });
7753
+ var SessionEventsPageDataSchema = import_zod59.z.object({
7754
+ events: import_zod59.z.array(SessionEventSchema),
7755
+ hasMore: import_zod59.z.boolean(),
7756
+ /**
7757
+ * Set `true` only when `afterEventId` was given but matched neither the
7758
+ * `event_id` column nor a row's primary key (e.g. the referenced chunk
7759
+ * was pruned by retention) — the response falls back to the first page
7760
+ * instead of the pre-existing silent fallback. Omitted (not `false`)
7761
+ * otherwise.
7762
+ */
7763
+ cursorReset: import_zod59.z.boolean().optional()
7764
+ });
7765
+ var SessionEventsPageResponseSchema = import_zod59.z.object({
7766
+ success: import_zod59.z.literal(true),
7767
+ data: SessionEventsPageDataSchema
7768
+ });
7769
+ var GatewayErrorCodeSchema = import_zod60.z.enum([
7372
7770
  "gateway_invalid_session_token",
7373
7771
  "gateway_session_not_found",
7374
7772
  "gateway_missing_mcp_target",
@@ -7411,7 +7809,7 @@ var GatewayErrorCodeSchema = import_zod58.z.enum([
7411
7809
  "gateway_request_too_large",
7412
7810
  "gateway_response_too_large"
7413
7811
  ]);
7414
- var WebhookEventTypeSchema = import_zod59.z.enum([
7812
+ var WebhookEventTypeSchema = import_zod61.z.enum([
7415
7813
  /** v1/v2 Run reached terminal `completed`. */
7416
7814
  "run.completed",
7417
7815
  /** v1/v2 Run reached terminal `failed`. */
@@ -7444,43 +7842,43 @@ var WebhookEventTypeSchema = import_zod59.z.enum([
7444
7842
  ]);
7445
7843
  var WEBHOOK_EVENT_TYPES = WebhookEventTypeSchema.options;
7446
7844
  var MAX_WEBHOOK_EVENT_ID_LENGTH = 255;
7447
- var WebhookEventPayloadSchema = import_zod59.z.object({
7448
- event_id: import_zod59.z.string().min(1).max(MAX_WEBHOOK_EVENT_ID_LENGTH),
7845
+ var WebhookEventPayloadSchema = import_zod61.z.object({
7846
+ event_id: import_zod61.z.string().min(1).max(MAX_WEBHOOK_EVENT_ID_LENGTH),
7449
7847
  event_type: WebhookEventTypeSchema,
7450
7848
  /** ISO-8601 instant at which the transition was recorded. */
7451
- occurred_at: import_zod59.z.string(),
7452
- project_id: import_zod59.z.string().uuid(),
7453
- run_id: import_zod59.z.string().uuid().optional(),
7454
- agent_id: import_zod59.z.string().uuid().optional(),
7455
- session_id: import_zod59.z.string().uuid().optional(),
7849
+ occurred_at: import_zod61.z.string(),
7850
+ project_id: import_zod61.z.string().uuid(),
7851
+ run_id: import_zod61.z.string().uuid().optional(),
7852
+ agent_id: import_zod61.z.string().uuid().optional(),
7853
+ session_id: import_zod61.z.string().uuid().optional(),
7456
7854
  /**
7457
7855
  * Worker turn id of a `turn.*` event, paired with `session_id`.
7458
7856
  * NOT a uuid: `deriveWorkerTurnId` yields a uuid-v5, but other
7459
7857
  * emitters use composite forms (`${kind}:${idempotencyKey}`), so the
7460
7858
  * wire type stays an opaque string.
7461
7859
  */
7462
- turn_id: import_zod59.z.string().min(1).optional(),
7463
- lifecycle_phase: import_zod59.z.enum(["idle", "terminating", "terminated"]).optional(),
7464
- lifecycle_transition_id: import_zod59.z.string().uuid().optional(),
7465
- idle_since: import_zod59.z.string().optional(),
7466
- grace_deadline: import_zod59.z.string().optional(),
7467
- reason: import_zod59.z.string().optional(),
7468
- terminate_deadline: import_zod59.z.string().optional()
7469
- }).strict();
7470
- var WebhookSubscriptionStatusSchema = import_zod59.z.enum(["active", "disabled"]);
7471
- var CreateWebhookSubscriptionRequestSchema = import_zod59.z.object({
7472
- projectId: import_zod59.z.string().uuid(),
7860
+ turn_id: import_zod61.z.string().min(1).optional(),
7861
+ lifecycle_phase: import_zod61.z.enum(["idle", "terminating", "terminated"]).optional(),
7862
+ lifecycle_transition_id: import_zod61.z.string().uuid().optional(),
7863
+ idle_since: import_zod61.z.string().optional(),
7864
+ grace_deadline: import_zod61.z.string().optional(),
7865
+ reason: import_zod61.z.string().optional(),
7866
+ terminate_deadline: import_zod61.z.string().optional()
7867
+ }).strict();
7868
+ var WebhookSubscriptionStatusSchema = import_zod61.z.enum(["active", "disabled"]);
7869
+ var CreateWebhookSubscriptionRequestSchema = import_zod61.z.object({
7870
+ projectId: import_zod61.z.string().uuid(),
7473
7871
  /** Subscriber endpoint. https required outside dev; SSRF-validated. */
7474
- url: import_zod59.z.string().url().max(1024),
7872
+ url: import_zod61.z.string().url().max(1024),
7475
7873
  /** Event types to deliver. At least one. */
7476
- events: import_zod59.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length),
7874
+ events: import_zod61.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length),
7477
7875
  /** Optional operator note shown in list responses. */
7478
- description: import_zod59.z.string().max(512).optional()
7876
+ description: import_zod61.z.string().max(512).optional()
7479
7877
  }).strict();
7480
- var UpdateWebhookSubscriptionRequestSchema = import_zod59.z.object({
7481
- url: import_zod59.z.string().url().max(1024).optional(),
7482
- events: import_zod59.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length).optional(),
7483
- description: import_zod59.z.string().max(512).nullable().optional(),
7878
+ var UpdateWebhookSubscriptionRequestSchema = import_zod61.z.object({
7879
+ url: import_zod61.z.string().url().max(1024).optional(),
7880
+ events: import_zod61.z.array(WebhookEventTypeSchema).min(1).max(WEBHOOK_EVENT_TYPES.length).optional(),
7881
+ description: import_zod61.z.string().max(512).nullable().optional(),
7484
7882
  /**
7485
7883
  * `active` re-enables a subscription that was auto-disabled after
7486
7884
  * consecutive failures (resets the failure counter); `disabled`
@@ -7491,23 +7889,23 @@ var UpdateWebhookSubscriptionRequestSchema = import_zod59.z.object({
7491
7889
  (data) => data.url !== void 0 || data.events !== void 0 || data.description !== void 0 || data.status !== void 0,
7492
7890
  { message: "At least one of url / events / description / status MUST be provided" }
7493
7891
  );
7494
- var WebhookSubscriptionSchema = import_zod59.z.object({
7495
- id: import_zod59.z.string().uuid(),
7496
- projectId: import_zod59.z.string().uuid(),
7497
- url: import_zod59.z.string(),
7498
- events: import_zod59.z.array(WebhookEventTypeSchema),
7499
- description: import_zod59.z.string().nullable(),
7892
+ var WebhookSubscriptionSchema = import_zod61.z.object({
7893
+ id: import_zod61.z.string().uuid(),
7894
+ projectId: import_zod61.z.string().uuid(),
7895
+ url: import_zod61.z.string(),
7896
+ events: import_zod61.z.array(WebhookEventTypeSchema),
7897
+ description: import_zod61.z.string().nullable(),
7500
7898
  status: WebhookSubscriptionStatusSchema,
7501
- consecutiveFailures: import_zod59.z.number().int().nonnegative(),
7502
- createdBy: import_zod59.z.string(),
7503
- createdAt: import_zod59.z.string(),
7504
- updatedAt: import_zod59.z.string()
7899
+ consecutiveFailures: import_zod61.z.number().int().nonnegative(),
7900
+ createdBy: import_zod61.z.string(),
7901
+ createdAt: import_zod61.z.string(),
7902
+ updatedAt: import_zod61.z.string()
7505
7903
  });
7506
- var WebhookSubscriptionWithSecretSchema = import_zod59.z.object({
7904
+ var WebhookSubscriptionWithSecretSchema = import_zod61.z.object({
7507
7905
  subscription: WebhookSubscriptionSchema,
7508
- secret: import_zod59.z.string()
7906
+ secret: import_zod61.z.string()
7509
7907
  });
7510
- var WebhookSubscriptionErrorCodeSchema = import_zod59.z.enum([
7908
+ var WebhookSubscriptionErrorCodeSchema = import_zod61.z.enum([
7511
7909
  // 400
7512
7910
  "VALIDATION_ERROR",
7513
7911
  /** URL failed SSRF policy (non-https, private/loopback/link-local IP…). */
@@ -7520,125 +7918,125 @@ var WebhookSubscriptionErrorCodeSchema = import_zod59.z.enum([
7520
7918
  // 500
7521
7919
  "INTERNAL_ERROR"
7522
7920
  ]);
7523
- var SessionPrewarmingIdentitySchema = import_zod60.z.object({
7524
- projectIdGenerator: import_zod60.z.literal("nanoid"),
7525
- claimNameTemplate: import_zod60.z.string().min(1),
7526
- idempotencyScopePrefix: import_zod60.z.string().min(1)
7527
- }).strict();
7528
- var SessionPrewarmingSessionTemplateSchema = import_zod60.z.object({
7529
- configValues: import_zod60.z.record(import_zod60.z.string(), import_zod60.z.string()),
7530
- metadata: import_zod60.z.record(import_zod60.z.string(), import_zod60.z.unknown()).optional()
7531
- }).strict();
7532
- var BusinessReadyProbeSchema = import_zod60.z.object({
7533
- endpointName: import_zod60.z.enum(["api", "preview"]),
7534
- path: import_zod60.z.string().min(1),
7535
- successCodes: import_zod60.z.array(import_zod60.z.number().int().min(100).max(599)).min(1),
7536
- timeoutMs: import_zod60.z.number().int().min(500).max(3e4)
7537
- }).strict();
7538
- var SessionPrewarmingSpecSchema = import_zod60.z.object({
7539
- targetReadyCount: import_zod60.z.number().int().min(1).max(50),
7540
- reVerifyIntervalSeconds: import_zod60.z.number().int().min(60).max(3600),
7541
- warmingTimeoutSeconds: import_zod60.z.number().int().min(60).max(600),
7542
- claimingLeaseTtlSeconds: import_zod60.z.number().int().min(10).max(120),
7543
- replenishIntervalSeconds: import_zod60.z.number().int().min(5).max(300),
7544
- maxConcurrentWarming: import_zod60.z.number().int().min(1).max(10),
7921
+ var SessionPrewarmingIdentitySchema = import_zod62.z.object({
7922
+ projectIdGenerator: import_zod62.z.literal("nanoid"),
7923
+ claimNameTemplate: import_zod62.z.string().min(1),
7924
+ idempotencyScopePrefix: import_zod62.z.string().min(1)
7925
+ }).strict();
7926
+ var SessionPrewarmingSessionTemplateSchema = import_zod62.z.object({
7927
+ configValues: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.string()),
7928
+ metadata: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.unknown()).optional()
7929
+ }).strict();
7930
+ var BusinessReadyProbeSchema = import_zod62.z.object({
7931
+ endpointName: import_zod62.z.enum(["api", "preview"]),
7932
+ path: import_zod62.z.string().min(1),
7933
+ successCodes: import_zod62.z.array(import_zod62.z.number().int().min(100).max(599)).min(1),
7934
+ timeoutMs: import_zod62.z.number().int().min(500).max(3e4)
7935
+ }).strict();
7936
+ var SessionPrewarmingSpecSchema = import_zod62.z.object({
7937
+ targetReadyCount: import_zod62.z.number().int().min(1).max(50),
7938
+ reVerifyIntervalSeconds: import_zod62.z.number().int().min(60).max(3600),
7939
+ warmingTimeoutSeconds: import_zod62.z.number().int().min(60).max(600),
7940
+ claimingLeaseTtlSeconds: import_zod62.z.number().int().min(10).max(120),
7941
+ replenishIntervalSeconds: import_zod62.z.number().int().min(5).max(300),
7942
+ maxConcurrentWarming: import_zod62.z.number().int().min(1).max(10),
7545
7943
  identity: SessionPrewarmingIdentitySchema,
7546
7944
  sessionTemplate: SessionPrewarmingSessionTemplateSchema,
7547
7945
  businessReadyProbe: BusinessReadyProbeSchema.optional()
7548
7946
  }).strict();
7549
- var AcquireSessionRequestSchema = import_zod60.z.object({
7550
- workloadId: import_zod60.z.string().uuid(),
7551
- clientMutationId: import_zod60.z.string().min(1).max(255)
7552
- }).strict();
7553
- var AcquireSessionResponseSchema = import_zod60.z.object({
7554
- leaseToken: import_zod60.z.string().min(1),
7555
- leaseExpiresAt: import_zod60.z.string().datetime(),
7556
- sessionId: import_zod60.z.string().uuid(),
7557
- projectId: import_zod60.z.string().min(1),
7558
- runtimeClaimName: import_zod60.z.string().min(1),
7559
- configValues: import_zod60.z.record(import_zod60.z.string(), import_zod60.z.string()),
7947
+ var AcquireSessionRequestSchema = import_zod62.z.object({
7948
+ workloadId: import_zod62.z.string().uuid(),
7949
+ clientMutationId: import_zod62.z.string().min(1).max(255)
7950
+ }).strict();
7951
+ var AcquireSessionResponseSchema = import_zod62.z.object({
7952
+ leaseToken: import_zod62.z.string().min(1),
7953
+ leaseExpiresAt: import_zod62.z.string().datetime(),
7954
+ sessionId: import_zod62.z.string().uuid(),
7955
+ projectId: import_zod62.z.string().min(1),
7956
+ runtimeClaimName: import_zod62.z.string().min(1),
7957
+ configValues: import_zod62.z.record(import_zod62.z.string(), import_zod62.z.string()),
7560
7958
  // Optional: outbox-protocol workloads (`managed_agent`) expose no public HTTP
7561
7959
  // endpoint, so a ready slot is claimable with no `apiUrl`. self_managed
7562
7960
  // (rush-app) slots always carry it. Omitted (not null) when absent — mirrors
7563
7961
  // `previewUrl`. See `pilot-v2-managed-agent-prewarming.md` § Readiness and
7564
7962
  // `SessionPoolService.buildAcquireResponse`.
7565
- apiUrl: import_zod60.z.string().url().optional(),
7566
- previewUrl: import_zod60.z.string().url().optional()
7963
+ apiUrl: import_zod62.z.string().url().optional(),
7964
+ previewUrl: import_zod62.z.string().url().optional()
7567
7965
  }).strict();
7568
- var FinalizeAcquireRequestSchema = import_zod60.z.object({
7569
- leaseToken: import_zod60.z.string().min(1),
7570
- sessionId: import_zod60.z.string().uuid(),
7571
- clientMutationId: import_zod60.z.string().min(1).max(255).optional()
7966
+ var FinalizeAcquireRequestSchema = import_zod62.z.object({
7967
+ leaseToken: import_zod62.z.string().min(1),
7968
+ sessionId: import_zod62.z.string().uuid(),
7969
+ clientMutationId: import_zod62.z.string().min(1).max(255).optional()
7572
7970
  }).strict();
7573
- var AbortAcquireRequestSchema = import_zod60.z.object({
7574
- leaseToken: import_zod60.z.string().min(1),
7575
- sessionId: import_zod60.z.string().uuid()
7971
+ var AbortAcquireRequestSchema = import_zod62.z.object({
7972
+ leaseToken: import_zod62.z.string().min(1),
7973
+ sessionId: import_zod62.z.string().uuid()
7576
7974
  }).strict();
7577
- var WorkloadLifecycleKindSchema = import_zod61.z.enum(["managed_agent", "self_managed"]);
7578
- var WorkloadLifecycleConfigSchema = import_zod61.z.object({
7579
- idleEnabled: import_zod61.z.boolean().nullable(),
7580
- idleAfterSeconds: import_zod61.z.number().int().min(300).max(86400).nullable(),
7581
- idleGraceSeconds: import_zod61.z.number().int().min(60).max(3600).nullable(),
7582
- maxSessionLifetimeMs: import_zod61.z.number().int().min(36e5).max(6048e5).nullable()
7975
+ var WorkloadLifecycleKindSchema = import_zod63.z.enum(["managed_agent", "self_managed"]);
7976
+ var WorkloadLifecycleConfigSchema = import_zod63.z.object({
7977
+ idleEnabled: import_zod63.z.boolean().nullable(),
7978
+ idleAfterSeconds: import_zod63.z.number().int().min(300).max(86400).nullable(),
7979
+ idleGraceSeconds: import_zod63.z.number().int().min(60).max(3600).nullable(),
7980
+ maxSessionLifetimeMs: import_zod63.z.number().int().min(36e5).max(6048e5).nullable()
7583
7981
  }).strict();
7584
7982
  var WorkloadLifecycleConfigUpdateSchema = WorkloadLifecycleConfigSchema.partial().strict();
7585
- var EffectiveWorkloadLifecycleConfigSchema = import_zod61.z.object({
7586
- idleEnabled: import_zod61.z.boolean(),
7587
- idleAfterSeconds: import_zod61.z.number().int().min(300).max(86400),
7588
- idleGraceSeconds: import_zod61.z.number().int().min(60).max(3600),
7589
- maxSessionLifetimeMs: import_zod61.z.number().int().min(36e5).max(6048e5)
7590
- }).strict();
7591
- var WorkloadLifecycleConfigResponseSchema = import_zod61.z.object({
7592
- workloadId: import_zod61.z.string().uuid(),
7983
+ var EffectiveWorkloadLifecycleConfigSchema = import_zod63.z.object({
7984
+ idleEnabled: import_zod63.z.boolean(),
7985
+ idleAfterSeconds: import_zod63.z.number().int().min(300).max(86400),
7986
+ idleGraceSeconds: import_zod63.z.number().int().min(60).max(3600),
7987
+ maxSessionLifetimeMs: import_zod63.z.number().int().min(36e5).max(6048e5)
7988
+ }).strict();
7989
+ var WorkloadLifecycleConfigResponseSchema = import_zod63.z.object({
7990
+ workloadId: import_zod63.z.string().uuid(),
7593
7991
  kind: WorkloadLifecycleKindSchema,
7594
7992
  config: WorkloadLifecycleConfigSchema,
7595
7993
  effective: EffectiveWorkloadLifecycleConfigSchema
7596
7994
  }).strict();
7597
- var OtelJobContextSchema = import_zod62.z.object({
7995
+ var OtelJobContextSchema = import_zod64.z.object({
7598
7996
  /** W3C Trace Context `traceparent` header value. */
7599
- traceparent: import_zod62.z.string().optional(),
7997
+ traceparent: import_zod64.z.string().optional(),
7600
7998
  /** W3C Trace Context `tracestate` header value. */
7601
- tracestate: import_zod62.z.string().optional(),
7999
+ tracestate: import_zod64.z.string().optional(),
7602
8000
  /** W3C Baggage header value. */
7603
- baggage: import_zod62.z.string().optional()
8001
+ baggage: import_zod64.z.string().optional()
7604
8002
  }).passthrough();
7605
- var LifecycleStageNameSchema = import_zod63.z.enum(["test", "production"]);
7606
- var SlotCanarySummarySchema = import_zod63.z.object({
8003
+ var LifecycleStageNameSchema = import_zod65.z.enum(["test", "production"]);
8004
+ var SlotCanarySummarySchema = import_zod65.z.object({
7607
8005
  /** canary 臂 revision id。 */
7608
- revisionId: import_zod63.z.string(),
8006
+ revisionId: import_zod65.z.string(),
7609
8007
  /** canary revision 的人可读版本短名;revision 行缺失时 null(降级显示 id 前缀)。 */
7610
- revisionLabel: import_zod63.z.string().nullable(),
8008
+ revisionLabel: import_zod65.z.string().nullable(),
7611
8009
  /** 0..99;0 = 冻结观察态(仅名单命中仍入 canary)。 */
7612
- percentage: import_zod63.z.number().int(),
8010
+ percentage: import_zod65.z.number().int(),
7613
8011
  /** ldap 名单人数(徽章"名单 N 人";0 = 无名单)。 */
7614
- userAllowlistCount: import_zod63.z.number().int(),
8012
+ userAllowlistCount: import_zod65.z.number().int(),
7615
8013
  /** 本轮灰度开始时间(ISO);存量行无记录时 null。 */
7616
- startedAt: import_zod63.z.string().nullable()
8014
+ startedAt: import_zod65.z.string().nullable()
7617
8015
  });
7618
- var SlotSummarySchema = import_zod63.z.object({
7619
- revisionId: import_zod63.z.string().nullable(),
8016
+ var SlotSummarySchema = import_zod65.z.object({
8017
+ revisionId: import_zod65.z.string().nullable(),
7620
8018
  /** 人可读的版本标识(revision name/number);无部署时 null。 */
7621
- revisionLabel: import_zod63.z.string().nullable(),
7622
- environmentId: import_zod63.z.string().nullable(),
7623
- environmentName: import_zod63.z.string().nullable(),
7624
- environmentVersion: import_zod63.z.number().int().nullable(),
8019
+ revisionLabel: import_zod65.z.string().nullable(),
8020
+ environmentId: import_zod65.z.string().nullable(),
8021
+ environmentName: import_zod65.z.string().nullable(),
8022
+ environmentVersion: import_zod65.z.number().int().nullable(),
7625
8023
  /**
7626
8024
  * 槽位所指 revision 自带的运行环境(`revisions.runtime_template_id` 及其名字)。
7627
8025
  * 槽位 `environmentId` 为 NULL(存量未绑定行)时会话实际跑的就是它——读侧用
7628
8026
  * 它兜底显示,不再渲染「内置于版本」伪状态(ENV-R1a)。发布板读模型必带;
7629
8027
  * 工作台等其它 SlotSummary 生产方可省略(省略 = 未报告)。
7630
8028
  */
7631
- revisionEnvironmentId: import_zod63.z.string().nullable().optional(),
7632
- revisionEnvironmentName: import_zod63.z.string().nullable().optional(),
8029
+ revisionEnvironmentId: import_zod65.z.string().nullable().optional(),
8030
+ revisionEnvironmentName: import_zod65.z.string().nullable().optional(),
7633
8031
  /** 槽位最近一次变更时间(ISO);数据缺口约定:仅当前指针,无历史流水。 */
7634
- updatedAt: import_zod63.z.string().nullable(),
8032
+ updatedAt: import_zod65.z.string().nullable(),
7635
8033
  /**
7636
8034
  * 活跃灰度摘要(#1214)。目前仅发布板读模型的槽位显式带出(null = 无灰度);
7637
8035
  * 工作台等其它 SlotSummary 生产方不带(optional,省略 = 未报告)。
7638
8036
  */
7639
8037
  canary: SlotCanarySummarySchema.nullable().optional()
7640
8038
  });
7641
- var WorkbenchStageDriftKindSchema = import_zod63.z.enum([
8039
+ var WorkbenchStageDriftKindSchema = import_zod65.z.enum([
7642
8040
  /** test 指向新于 production(待晋级)。 */
7643
8041
  "test_ahead",
7644
8042
  /** 只有 test 有部署(从未上过 production)。 */
@@ -7661,27 +8059,27 @@ var WorkbenchStageDriftKindSchema = import_zod63.z.enum([
7661
8059
  */
7662
8060
  "diverged"
7663
8061
  ]);
7664
- var WorkbenchStageDriftItemSchema = import_zod63.z.object({
7665
- workloadId: import_zod63.z.string(),
7666
- workloadName: import_zod63.z.string(),
7667
- workloadSlug: import_zod63.z.string().nullable(),
8062
+ var WorkbenchStageDriftItemSchema = import_zod65.z.object({
8063
+ workloadId: import_zod65.z.string(),
8064
+ workloadName: import_zod65.z.string(),
8065
+ workloadSlug: import_zod65.z.string().nullable(),
7668
8066
  kind: WorkbenchStageDriftKindSchema,
7669
8067
  test: SlotSummarySchema.nullable(),
7670
8068
  production: SlotSummarySchema.nullable(),
7671
8069
  /** 差异开始的近似时间 = 领先侧槽位的 updatedAt(ISO)。 */
7672
- since: import_zod63.z.string().nullable()
8070
+ since: import_zod65.z.string().nullable()
7673
8071
  });
7674
- var WorkbenchRecentChangeKindSchema = import_zod63.z.enum([
8072
+ var WorkbenchRecentChangeKindSchema = import_zod65.z.enum([
7675
8073
  "stage_updated",
7676
8074
  "revision_published",
7677
8075
  "environment_version_created"
7678
8076
  ]);
7679
- var WorkbenchRecentChangeSchema = import_zod63.z.object({
8077
+ var WorkbenchRecentChangeSchema = import_zod65.z.object({
7680
8078
  kind: WorkbenchRecentChangeKindSchema,
7681
8079
  /** 变更主体的可读标题(如 workload 名 / 环境名)。 */
7682
- subject: import_zod63.z.string(),
8080
+ subject: import_zod65.z.string(),
7683
8081
  /** 主体 id(workloadId / environmentId),用于前端拼详情链接。 */
7684
- subjectId: import_zod63.z.string(),
8082
+ subjectId: import_zod65.z.string(),
7685
8083
  /**
7686
8084
  * workload 类变更(stage_updated / revision_published)的 slug——详情路由
7687
8085
  * UUID / slug 双形态均可达,前端优先用可读的 slug 拼链接,缺失时回退
@@ -7692,26 +8090,26 @@ var WorkbenchRecentChangeSchema = import_zod63.z.object({
7692
8090
  * agenthub-sdk 对 WorkbenchDTO 的硬 parse)在滚动发版遇到旧产出时
7693
8091
  * 降级为无 slug,而不是整个 DTO 校验失败。
7694
8092
  */
7695
- subjectSlug: import_zod63.z.string().nullable().optional(),
8093
+ subjectSlug: import_zod65.z.string().nullable().optional(),
7696
8094
  /** 一句话变更描述(如 "production → rev-12" / "环境 v3 创建")。 */
7697
- detail: import_zod63.z.string(),
7698
- occurredAt: import_zod63.z.string()
8095
+ detail: import_zod65.z.string(),
8096
+ occurredAt: import_zod65.z.string()
7699
8097
  });
7700
- var WorkbenchSessionStatsSchema = import_zod63.z.object({
7701
- running: import_zod63.z.number().int(),
7702
- failed24h: import_zod63.z.number().int(),
7703
- total24h: import_zod63.z.number().int()
8098
+ var WorkbenchSessionStatsSchema = import_zod65.z.object({
8099
+ running: import_zod65.z.number().int(),
8100
+ failed24h: import_zod65.z.number().int(),
8101
+ total24h: import_zod65.z.number().int()
7704
8102
  });
7705
- var WorkbenchDTOSchema = import_zod63.z.object({
7706
- workloadCount: import_zod63.z.number().int(),
8103
+ var WorkbenchDTOSchema = import_zod65.z.object({
8104
+ workloadCount: import_zod65.z.number().int(),
7707
8105
  sessionStats: WorkbenchSessionStatsSchema,
7708
- stageDrift: import_zod63.z.array(WorkbenchStageDriftItemSchema),
7709
- recentChanges: import_zod63.z.array(WorkbenchRecentChangeSchema)
8106
+ stageDrift: import_zod65.z.array(WorkbenchStageDriftItemSchema),
8107
+ recentChanges: import_zod65.z.array(WorkbenchRecentChangeSchema)
7710
8108
  });
7711
- var ReleaseBoardRowSchema = import_zod63.z.object({
7712
- workloadId: import_zod63.z.string(),
7713
- workloadName: import_zod63.z.string(),
7714
- workloadSlug: import_zod63.z.string().nullable(),
8109
+ var ReleaseBoardRowSchema = import_zod65.z.object({
8110
+ workloadId: import_zod65.z.string(),
8111
+ workloadName: import_zod65.z.string(),
8112
+ workloadSlug: import_zod65.z.string().nullable(),
7715
8113
  /**
7716
8114
  * @deprecated Workload 当前默认指针(`default_revision_id`,production 部署
7717
8115
  * 从写)。指针收敛(2026-08-02)后发布 UI 不再移动它,本字段随删列窗口结束
@@ -7720,7 +8118,7 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
7720
8118
  * 新消费方一律读 `latestRevision`(前端回退链 latestRevision ?? defaultRevision
7721
8119
  * 只为兼容旧服务端缺字段,不表示两者同义)。
7722
8120
  */
7723
- defaultRevision: import_zod63.z.object({ id: import_zod63.z.string(), version: import_zod63.z.string(), createdAt: import_zod63.z.string() }).nullable(),
8121
+ defaultRevision: import_zod65.z.object({ id: import_zod65.z.string(), version: import_zod65.z.string(), createdAt: import_zod65.z.string() }).nullable(),
7724
8122
  /**
7725
8123
  * Workload 最近发布的 Revision(createdAt 最新;并列时 id 大者,保证确定性)。
7726
8124
  * 发布板用它判断"有新版本尚未部署到 test"(latestRevision.id ≠
@@ -7733,12 +8131,12 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
7733
8131
  * pendingRevision)一直想要的一致。**optional**:旧服务端的响应没有此字段,
7734
8132
  * 新 client 解析须容忍(双向滚动窗口兼容),缺席时回退读 defaultRevision。
7735
8133
  */
7736
- latestRevision: import_zod63.z.object({
7737
- id: import_zod63.z.string(),
7738
- version: import_zod63.z.string(),
7739
- createdAt: import_zod63.z.string(),
8134
+ latestRevision: import_zod65.z.object({
8135
+ id: import_zod65.z.string(),
8136
+ version: import_zod65.z.string(),
8137
+ createdAt: import_zod65.z.string(),
7740
8138
  /** 真实发布时间;optional 仅用于新旧服务端滚动窗口兼容。 */
7741
- publishedAt: import_zod63.z.string().optional()
8139
+ publishedAt: import_zod65.z.string().optional()
7742
8140
  }).nullable().optional(),
7743
8141
  /**
7744
8142
  * 用户当前有理由继续使用的 Revision(latestRevision、test、production)中,
@@ -7746,7 +8144,7 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
7746
8144
  * latestRevision;具体复制哪份配置由升级弹窗显式选择。optional 仅用于
7747
8145
  * 新旧服务端滚动窗口兼容。
7748
8146
  */
7749
- runtimeUpgradeAvailable: import_zod63.z.boolean().optional(),
8147
+ runtimeUpgradeAvailable: import_zod65.z.boolean().optional(),
7750
8148
  test: SlotSummarySchema.nullable(),
7751
8149
  production: SlotSummarySchema.nullable(),
7752
8150
  /**
@@ -7755,26 +8153,26 @@ var ReleaseBoardRowSchema = import_zod63.z.object({
7755
8153
  * 都显式绑定时参与比较——任一侧是兜底态(槽位未绑、跑版本自带环境)时
7756
8154
  * 没有可比的版本钉。发布板展开面板的环境行高亮与本字段同口径。
7757
8155
  */
7758
- drift: import_zod63.z.boolean(),
8156
+ drift: import_zod65.z.boolean(),
7759
8157
  /** 两槽位 updatedAt 的较新者(ISO);均空则 null。 */
7760
- lastChangedAt: import_zod63.z.string().nullable()
7761
- });
7762
- var ReleaseBoardDTOSchema = import_zod63.z.object({
7763
- rows: import_zod63.z.array(ReleaseBoardRowSchema)
7764
- });
7765
- var SessionDiagnosisSessionSchema = import_zod63.z.object({
7766
- id: import_zod63.z.string(),
7767
- workloadId: import_zod63.z.string().nullable(),
7768
- workloadName: import_zod63.z.string().nullable(),
7769
- workloadSlug: import_zod63.z.string().nullable(),
7770
- status: import_zod63.z.string(),
7771
- lifecyclePhase: import_zod63.z.string().nullable(),
7772
- model: import_zod63.z.string().nullable(),
7773
- createdAt: import_zod63.z.string(),
7774
- readyAt: import_zod63.z.string().nullable(),
7775
- endedAt: import_zod63.z.string().nullable(),
8158
+ lastChangedAt: import_zod65.z.string().nullable()
8159
+ });
8160
+ var ReleaseBoardDTOSchema = import_zod65.z.object({
8161
+ rows: import_zod65.z.array(ReleaseBoardRowSchema)
8162
+ });
8163
+ var SessionDiagnosisSessionSchema = import_zod65.z.object({
8164
+ id: import_zod65.z.string(),
8165
+ workloadId: import_zod65.z.string().nullable(),
8166
+ workloadName: import_zod65.z.string().nullable(),
8167
+ workloadSlug: import_zod65.z.string().nullable(),
8168
+ status: import_zod65.z.string(),
8169
+ lifecyclePhase: import_zod65.z.string().nullable(),
8170
+ model: import_zod65.z.string().nullable(),
8171
+ createdAt: import_zod65.z.string(),
8172
+ readyAt: import_zod65.z.string().nullable(),
8173
+ endedAt: import_zod65.z.string().nullable(),
7776
8174
  /** 会话创建链路 trace(Octopus 深链"启动 Trace"数据源)。 */
7777
- rootTraceId: import_zod63.z.string().nullable(),
8175
+ rootTraceId: import_zod65.z.string().nullable(),
7778
8176
  /**
7779
8177
  * 该会话能不能点进对话面(`/p/<pid>/s/<sid>`)。**由服务端算好下发,前端不要
7780
8178
  * 自己按 `usageKind` 重推** —— `usage_kind` 是会话创建时写死的名字、认领后
@@ -7782,37 +8180,37 @@ var SessionDiagnosisSessionSchema = import_zod63.z.object({
7782
8180
  * `packages/control-plane/src/session-lifecycle/session-chat-entry.ts`,
7783
8181
  * 排障列表的 `chatHref` 走的是同一个函数。
7784
8182
  */
7785
- canOpenChat: import_zod63.z.boolean()
8183
+ canOpenChat: import_zod65.z.boolean()
7786
8184
  });
7787
- var SessionDiagnosisFailureSchema = import_zod63.z.object({
7788
- kind: import_zod63.z.string().nullable(),
7789
- message: import_zod63.z.string().nullable(),
7790
- occurredAt: import_zod63.z.string().nullable()
8185
+ var SessionDiagnosisFailureSchema = import_zod65.z.object({
8186
+ kind: import_zod65.z.string().nullable(),
8187
+ message: import_zod65.z.string().nullable(),
8188
+ occurredAt: import_zod65.z.string().nullable()
7791
8189
  });
7792
- var SessionDiagnosisEventSchema = import_zod63.z.object({
7793
- id: import_zod63.z.string(),
7794
- type: import_zod63.z.string(),
8190
+ var SessionDiagnosisEventSchema = import_zod65.z.object({
8191
+ id: import_zod65.z.string(),
8192
+ type: import_zod65.z.string(),
7795
8193
  /** 该轮 dispatch trace(每条用户消息的 Octopus 深链数据源);非 dispatch 事件为 null。 */
7796
- traceId: import_zod63.z.string().nullable(),
7797
- summary: import_zod63.z.string().nullable(),
7798
- occurredAt: import_zod63.z.string()
8194
+ traceId: import_zod65.z.string().nullable(),
8195
+ summary: import_zod65.z.string().nullable(),
8196
+ occurredAt: import_zod65.z.string()
7799
8197
  });
7800
- var SessionDiagnosisSandboxSchema = import_zod63.z.object({
7801
- id: import_zod63.z.string(),
7802
- status: import_zod63.z.string(),
7803
- expiresAt: import_zod63.z.string().nullable(),
7804
- createdAt: import_zod63.z.string().nullable()
8198
+ var SessionDiagnosisSandboxSchema = import_zod65.z.object({
8199
+ id: import_zod65.z.string(),
8200
+ status: import_zod65.z.string(),
8201
+ expiresAt: import_zod65.z.string().nullable(),
8202
+ createdAt: import_zod65.z.string().nullable()
7805
8203
  });
7806
- var SessionDiagnosisDTOSchema = import_zod63.z.object({
8204
+ var SessionDiagnosisDTOSchema = import_zod65.z.object({
7807
8205
  session: SessionDiagnosisSessionSchema,
7808
8206
  failure: SessionDiagnosisFailureSchema.nullable(),
7809
- events: import_zod63.z.array(SessionDiagnosisEventSchema).nullable(),
8207
+ events: import_zod65.z.array(SessionDiagnosisEventSchema).nullable(),
7810
8208
  sandbox: SessionDiagnosisSandboxSchema.nullable(),
7811
8209
  // zod v4 infers `z.record(enum, string)` as a FULL `Record` (all keys
7812
8210
  // present) instead of v3's `Partial` — but only failing blocks appear here.
7813
8211
  // Explicit partial object keeps the v3 inference; runtime behavior matches
7814
8212
  // the record form (any key subset accepted, extras rejected).
7815
- blockErrors: import_zod63.z.object({ failure: import_zod63.z.string(), events: import_zod63.z.string(), sandbox: import_zod63.z.string() }).partial().optional()
8213
+ blockErrors: import_zod65.z.object({ failure: import_zod65.z.string(), events: import_zod65.z.string(), sandbox: import_zod65.z.string() }).partial().optional()
7816
8214
  });
7817
8215
  var PIPELINE_TRIGGERS = ["push", "merge", "manual", "env_change", "rebake"];
7818
8216
  var PIPELINE_RUN_STATUSES = [
@@ -7854,12 +8252,12 @@ var PIPELINE_FULL_FACE_TRIGGERS = Object.keys(PIPELINE_TRIGGER_STAGES).filter((t
7854
8252
  return set.length === PIPELINE_STEPS.length && PIPELINE_STEPS.every((s) => set.includes(s));
7855
8253
  });
7856
8254
  var IMAGE_FINGERPRINT_RE = /^fp_[0-9a-f]{64}$/;
7857
- var BakeInputsSchema = import_zod64.z.object({
7858
- v: import_zod64.z.literal(1),
7859
- fingerprint: import_zod64.z.string().regex(IMAGE_FINGERPRINT_RE),
7860
- baseImage: import_zod64.z.string().min(1),
8255
+ var BakeInputsSchema = import_zod66.z.object({
8256
+ v: import_zod66.z.literal(1),
8257
+ fingerprint: import_zod66.z.string().regex(IMAGE_FINGERPRINT_RE),
8258
+ baseImage: import_zod66.z.string().min(1),
7861
8259
  packages: EnvironmentPackagesSchema.nullable(),
7862
- generatorVersion: import_zod64.z.number().int().positive()
8260
+ generatorVersion: import_zod66.z.number().int().positive()
7863
8261
  }).strict();
7864
8262
  var BAKE_IMAGE_BUILD_TIMEOUT_MS = 45 * 60 * 1e3;
7865
8263
  var BAKE_MATERIALIZE_WAIT_MS = 30 * 60 * 1e3;
@@ -7877,7 +8275,7 @@ var FILE_AGENT_REFERENCE_NAME_MAX_LENGTH = 200;
7877
8275
  var FILE_AGENT_REFERENCE_LIST_MAX_LENGTH = 100;
7878
8276
  var FILE_AGENT_PACKAGE_FILE_CHAR_WHITELIST = /^[A-Za-z0-9._/-]+$/;
7879
8277
  function packageFilePathSchema(fieldName) {
7880
- return import_zod65.z.string().min(1).max(FILE_AGENT_PACKAGE_FILE_PATH_MAX_LENGTH).refine((value) => FILE_AGENT_PACKAGE_FILE_CHAR_WHITELIST.test(value), {
8278
+ 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
8279
  message: `${fieldName} may only contain [A-Za-z0-9._/-]`
7882
8280
  }).refine((value) => !value.startsWith("/"), {
7883
8281
  message: `${fieldName} must be a relative path`
@@ -7893,11 +8291,11 @@ function packageFilePathSchema(fieldName) {
7893
8291
  var FileAgentSystemPromptFileSchema = packageFilePathSchema("systemPromptFile");
7894
8292
  var FileAgentSetupScriptFileSchema = packageFilePathSchema("setupScriptFile");
7895
8293
  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 = import_zod65.z.string().min(1).max(FILE_AGENT_REFERENCE_NAME_MAX_LENGTH).refine((value) => FILE_AGENT_RUSH_NAME_WHITELIST.test(value), {
8294
+ 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
8295
  message: "rush registry name must match (@scope/)?name using only [A-Za-z0-9._-] (no spaces or invisible characters)"
7898
8296
  });
7899
8297
  function platformEntityNameSchema(fieldName) {
7900
- return import_zod65.z.string().min(1).max(FILE_AGENT_REFERENCE_NAME_MAX_LENGTH).refine((value) => value.trim() === value, {
8298
+ return import_zod67.z.string().min(1).max(FILE_AGENT_REFERENCE_NAME_MAX_LENGTH).refine((value) => value.trim() === value, {
7901
8299
  message: `${fieldName} name must not have leading or trailing whitespace`
7902
8300
  }).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value), {
7903
8301
  message: `${fieldName} name must not contain control or invisible format characters`
@@ -7905,30 +8303,30 @@ function platformEntityNameSchema(fieldName) {
7905
8303
  }
7906
8304
  var FileAgentEnvironmentNameSchema = platformEntityNameSchema("environment");
7907
8305
  var FileAgentModelServiceNameSchema = platformEntityNameSchema("modelService");
7908
- var FileAgentMcpServerEntrySchema = import_zod65.z.union([
8306
+ var FileAgentMcpServerEntrySchema = import_zod67.z.union([
7909
8307
  ManagedMcpIdSchema,
7910
- import_zod65.z.object({
8308
+ import_zod67.z.object({
7911
8309
  id: ManagedMcpIdSchema,
7912
- disabled: import_zod65.z.boolean().optional()
8310
+ disabled: import_zod67.z.boolean().optional()
7913
8311
  }).strict()
7914
8312
  ]);
7915
8313
  function mcpEntryId(entry) {
7916
8314
  return typeof entry === "string" ? entry : entry.id;
7917
8315
  }
7918
- var FileAgentMcpServerListSchema = import_zod65.z.array(FileAgentMcpServerEntrySchema).max(FILE_AGENT_REFERENCE_LIST_MAX_LENGTH).refine(
8316
+ var FileAgentMcpServerListSchema = import_zod67.z.array(FileAgentMcpServerEntrySchema).max(FILE_AGENT_REFERENCE_LIST_MAX_LENGTH).refine(
7919
8317
  (list) => {
7920
8318
  const ids = list.map(mcpEntryId);
7921
8319
  return new Set(ids).size === ids.length;
7922
8320
  },
7923
8321
  { message: "must not contain duplicate mcpServers entries (compared by id)" }
7924
8322
  );
7925
- var FileAgentClaudeCodeSectionSchema = import_zod65.z.object({
8323
+ var FileAgentClaudeCodeSectionSchema = import_zod67.z.object({
7926
8324
  entryCommand: ClaudeCodeAgentPackageEntryCommandSchema.optional()
7927
8325
  }).strict();
7928
8326
  var FileAgentMemorySchema = WorkloadManifestMemorySchema.pick({ enabled: true }).strict();
7929
- var FileAgentClaudeCodeDefinitionSchema = import_zod65.z.object({
7930
- apiVersion: import_zod65.z.literal(FILE_AGENT_API_VERSION),
7931
- format: import_zod65.z.literal("claude_code"),
8327
+ var FileAgentClaudeCodeDefinitionSchema = import_zod67.z.object({
8328
+ apiVersion: import_zod67.z.literal(FILE_AGENT_API_VERSION),
8329
+ format: import_zod67.z.literal("claude_code"),
7932
8330
  model: WorkloadManifestModelSchema.optional(),
7933
8331
  /**
7934
8332
  * **待退场旧入口**(owner 2026-08-11 拍板,见
@@ -8009,23 +8407,23 @@ var FileAgentClaudeCodeDefinitionSchema = import_zod65.z.object({
8009
8407
  memory: FileAgentMemorySchema.optional(),
8010
8408
  claudeCode: FileAgentClaudeCodeSectionSchema.optional()
8011
8409
  }).strict();
8012
- var FileAgentDefinitionSchema = import_zod65.z.discriminatedUnion("format", [FileAgentClaudeCodeDefinitionSchema]).superRefine((definition, ctx) => {
8410
+ var FileAgentDefinitionSchema = import_zod67.z.discriminatedUnion("format", [FileAgentClaudeCodeDefinitionSchema]).superRefine((definition, ctx) => {
8013
8411
  if (definition.systemPrompt !== void 0 && definition.systemPromptFile !== void 0) {
8014
8412
  ctx.addIssue({
8015
- code: import_zod65.z.ZodIssueCode.custom,
8413
+ code: import_zod67.z.ZodIssueCode.custom,
8016
8414
  path: ["systemPromptFile"],
8017
8415
  message: "systemPrompt and systemPromptFile are mutually exclusive (D18)"
8018
8416
  });
8019
8417
  }
8020
8418
  if (definition.setupScript !== void 0 && definition.setupScriptFile !== void 0) {
8021
8419
  ctx.addIssue({
8022
- code: import_zod65.z.ZodIssueCode.custom,
8420
+ code: import_zod67.z.ZodIssueCode.custom,
8023
8421
  path: ["setupScriptFile"],
8024
8422
  message: "setupScript and setupScriptFile are mutually exclusive (D21)"
8025
8423
  });
8026
8424
  }
8027
8425
  });
8028
- var FileAgentErrorCodeSchema = import_zod65.z.enum([
8426
+ var FileAgentErrorCodeSchema = import_zod67.z.enum([
8029
8427
  /** agent.yaml failed schema validation (unknown/reserved key, apiVersion boundary, field shape). */
8030
8428
  "FILE_AGENT_INVALID",
8031
8429
  /**
@@ -8071,7 +8469,7 @@ var FileAgentErrorCodeSchema = import_zod65.z.enum([
8071
8469
  /** Converted output failed `RevisionManifestSchema` — a pipeline-context input is invalid (e.g. a non-endorsed package URL). */
8072
8470
  "FILE_AGENT_REVISION_INVALID"
8073
8471
  ]);
8074
- var BindProjectRepoRequestSchema = import_zod66.z.object({
8472
+ var BindProjectRepoRequestSchema = import_zod68.z.object({
8075
8473
  /**
8076
8474
  * Project uuid — the ONLY form accepted (#1635). Slugs used to be
8077
8475
  * resolved here (exact `slug` column, then derived-from-`name` fallback
@@ -8080,8 +8478,8 @@ var BindProjectRepoRequestSchema = import_zod66.z.object({
8080
8478
  * scan was a full-table fallback with no ordering. Identity is uuid-only;
8081
8479
  * slugs are display-only and never resolve.
8082
8480
  */
8083
- project: import_zod66.z.string().uuid(),
8084
- repoUrl: import_zod66.z.string().min(1).max(1024),
8481
+ project: import_zod68.z.string().uuid(),
8482
+ repoUrl: import_zod68.z.string().min(1).max(1024),
8085
8483
  /**
8086
8484
  * Repoint a project that already names a DIFFERENT repo.
8087
8485
  *
@@ -8090,53 +8488,53 @@ var BindProjectRepoRequestSchema = import_zod66.z.object({
8090
8488
  * next release publish agent definitions from another repository, under
8091
8489
  * the same project, with no visible signal.
8092
8490
  */
8093
- allowRebind: import_zod66.z.boolean().optional()
8491
+ allowRebind: import_zod68.z.boolean().optional()
8094
8492
  }).strict();
8095
- var BindProjectRepoResponseSchema = import_zod66.z.discriminatedUnion("outcome", [
8096
- import_zod66.z.object({ outcome: import_zod66.z.literal("bound"), projectId: import_zod66.z.string().uuid(), repoUrl: import_zod66.z.string() }).strict(),
8493
+ var BindProjectRepoResponseSchema = import_zod68.z.discriminatedUnion("outcome", [
8494
+ import_zod68.z.object({ outcome: import_zod68.z.literal("bound"), projectId: import_zod68.z.string().uuid(), repoUrl: import_zod68.z.string() }).strict(),
8097
8495
  /** Idempotent re-run: already bound to this repo, nothing written. */
8098
- import_zod66.z.object({ outcome: import_zod66.z.literal("unchanged"), projectId: import_zod66.z.string().uuid(), repoUrl: import_zod66.z.string() }).strict()
8496
+ import_zod68.z.object({ outcome: import_zod68.z.literal("unchanged"), projectId: import_zod68.z.string().uuid(), repoUrl: import_zod68.z.string() }).strict()
8099
8497
  ]);
8100
- var FileAgentRefKindSchema = import_zod66.z.enum(["environment", "modelService", "managedMcp"]);
8101
- var CheckFileAgentRefsQuerySchema = import_zod66.z.object({
8102
- projectId: import_zod66.z.string().uuid(),
8103
- environment: import_zod66.z.string().min(1).max(200).optional(),
8104
- modelService: import_zod66.z.string().min(1).max(200).optional(),
8498
+ var FileAgentRefKindSchema = import_zod68.z.enum(["environment", "modelService", "managedMcp"]);
8499
+ var CheckFileAgentRefsQuerySchema = import_zod68.z.object({
8500
+ projectId: import_zod68.z.string().uuid(),
8501
+ environment: import_zod68.z.string().min(1).max(200).optional(),
8502
+ modelService: import_zod68.z.string().min(1).max(200).optional(),
8105
8503
  /**
8106
8504
  * `agent.yaml` `mcpServers:` —— 托管 MCP id(`vcrd_*`),已经是 id 而不是名字,
8107
8505
  * 所以这里问的是「它在这个项目里存在吗」。上限对齐 `mcpServers` 的列表上限。
8108
8506
  */
8109
- managedMcpIds: import_zod66.z.array(ManagedMcpIdSchema).max(64).optional()
8507
+ managedMcpIds: import_zod68.z.array(ManagedMcpIdSchema).max(64).optional()
8110
8508
  }).strict();
8111
- var FileAgentRefProblemSchema = import_zod66.z.object({
8509
+ var FileAgentRefProblemSchema = import_zod68.z.object({
8112
8510
  kind: FileAgentRefKindSchema,
8113
- name: import_zod66.z.string(),
8511
+ name: import_zod68.z.string(),
8114
8512
  /** Existing names in the project, for a "did you mean" hint (server-capped). */
8115
- available: import_zod66.z.array(import_zod66.z.string())
8513
+ available: import_zod68.z.array(import_zod68.z.string())
8116
8514
  }).strict();
8117
- var CheckFileAgentRefsResponseSchema = import_zod66.z.object({
8118
- environmentId: import_zod66.z.string().optional(),
8119
- llmProviderRef: import_zod66.z.string().optional(),
8515
+ var CheckFileAgentRefsResponseSchema = import_zod68.z.object({
8516
+ environmentId: import_zod68.z.string().optional(),
8517
+ llmProviderRef: import_zod68.z.string().optional(),
8120
8518
  /** 解析到的 `managedMcpId → 展示名`(发布侧要把名字冻进快照;check 只看 problems)。 */
8121
- managedMcpDisplayNames: import_zod66.z.record(import_zod66.z.string(), import_zod66.z.string()).optional(),
8122
- problems: import_zod66.z.array(FileAgentRefProblemSchema)
8519
+ managedMcpDisplayNames: import_zod68.z.record(import_zod68.z.string(), import_zod68.z.string()).optional(),
8520
+ problems: import_zod68.z.array(FileAgentRefProblemSchema)
8123
8521
  }).strict();
8124
- var IssueMcpDevTicketRequestSchema = import_zod67.z.object({
8125
- projectId: import_zod67.z.string().uuid(),
8522
+ var IssueMcpDevTicketRequestSchema = import_zod69.z.object({
8523
+ projectId: import_zod69.z.string().uuid(),
8126
8524
  /**
8127
8525
  * 人可读的用途标记(典型值:`<agent slug>@<主机名>`)。只为审计与自助排查
8128
8526
  * ("我还有几张票在外面"),不参与鉴权。
8129
8527
  */
8130
- label: import_zod67.z.string().min(1).max(200).optional(),
8528
+ label: import_zod69.z.string().min(1).max(200).optional(),
8131
8529
  /** 省略 = 服务端默认(一个开发日)。服务端另有 24h 上限。 */
8132
- ttlSeconds: import_zod67.z.number().int().positive().max(24 * 60 * 60).optional()
8530
+ ttlSeconds: import_zod69.z.number().int().positive().max(24 * 60 * 60).optional()
8133
8531
  }).strict();
8134
- var McpDevTicketTargetSchema = import_zod67.z.object({
8532
+ var McpDevTicketTargetSchema = import_zod69.z.object({
8135
8533
  managedMcpId: ManagedMcpIdSchema,
8136
8534
  /** 展示名 —— 给人看的(提示、报错)。**不是** `.mcp.json` 的键。 */
8137
- displayName: import_zod67.z.string(),
8535
+ displayName: import_zod69.z.string(),
8138
8536
  /** 真实上游 URL。作为 `X-Pilot-MCP-Target` 头传给 gateway(**不是**凭据)。 */
8139
- mcpServerUrl: import_zod67.z.string(),
8537
+ mcpServerUrl: import_zod69.z.string(),
8140
8538
  /**
8141
8539
  * `.mcp.json` 的**键名**,平台侧创建期定死(`pilot_v2_vault_credentials.
8142
8540
  * server_key`)。CLI 必须用它,不许从 `displayName` 现造:LLM 看到的工具名是
@@ -8151,37 +8549,37 @@ var McpDevTicketTargetSchema = import_zod67.z.object({
8151
8549
  * 版本 skew 面(老服务端可能回 null → 新 SDK parse 抛错),而收益只是类型更
8152
8550
  * 诚实。CLI 侧不该再有 null 分支——那个分支正是这条修复要消灭的东西。
8153
8551
  */
8154
- serverKey: import_zod67.z.string().nullable()
8552
+ serverKey: import_zod69.z.string().nullable()
8155
8553
  }).strict();
8156
- var McpDevTicketStdioTargetSchema = import_zod67.z.object({
8554
+ var McpDevTicketStdioTargetSchema = import_zod69.z.object({
8157
8555
  managedMcpId: ManagedMcpIdSchema,
8158
8556
  /**
8159
8557
  * `.mcp.json` 的键名。与 remote 的 `serverKey` 在**同一个命名空间**里分配:
8160
8558
  * `.mcp.json` 是一张表,stdio 与 remote 的键撞了就是互相覆盖(沙箱冻结侧同
8161
8559
  * 此约束,见 `vault-snapshot-freezer`)。
8162
8560
  */
8163
- serverKey: import_zod67.z.string().min(1).max(200),
8561
+ serverKey: import_zod69.z.string().min(1).max(200),
8164
8562
  /** 展示名 —— 给人看的。**不是**键。 */
8165
- displayName: import_zod67.z.string(),
8166
- command: import_zod67.z.string().min(1).max(500),
8167
- args: import_zod67.z.array(import_zod67.z.string().max(500)).max(64).optional(),
8563
+ displayName: import_zod69.z.string(),
8564
+ command: import_zod69.z.string().min(1).max(500),
8565
+ args: import_zod69.z.array(import_zod69.z.string().max(500)).max(64).optional(),
8168
8566
  /** 变量名 → 已渲染的值(`${MCP_...}` 占位符或字面量)。**绝不含明文凭据。** */
8169
- env: import_zod67.z.record(import_zod67.z.string(), import_zod67.z.string()).optional()
8567
+ env: import_zod69.z.record(import_zod69.z.string(), import_zod69.z.string()).optional()
8170
8568
  }).strict();
8171
- var IssueMcpDevTicketResponseSchema = import_zod67.z.object({
8569
+ var IssueMcpDevTicketResponseSchema = import_zod69.z.object({
8172
8570
  /**
8173
8571
  * 写进 `.mcp.json` 的 `Authorization: Bearer <token>`。
8174
8572
  * **只在这一次响应里出现**,服务端不留明文。
8175
8573
  */
8176
- token: import_zod67.z.string(),
8574
+ token: import_zod69.z.string(),
8177
8575
  /** 票据的 public id —— 撤销时用它。 */
8178
- ticketId: import_zod67.z.string(),
8576
+ ticketId: import_zod69.z.string(),
8179
8577
  /** ISO 时间串。 */
8180
- expiresAt: import_zod67.z.string(),
8578
+ expiresAt: import_zod69.z.string(),
8181
8579
  /** gateway URL(CLI 不该自己猜环境)。 */
8182
- gatewayUrl: import_zod67.z.string(),
8580
+ gatewayUrl: import_zod69.z.string(),
8183
8581
  /** `remote` 形态 —— 经 gateway 代理,白名单即 `allowedMcpTargets`。 */
8184
- targets: import_zod67.z.array(McpDevTicketTargetSchema),
8582
+ targets: import_zod69.z.array(McpDevTicketTargetSchema),
8185
8583
  /**
8186
8584
  * `stdio` 形态 —— 本机子进程,不经 gateway、不进白名单。上限与
8187
8585
  * `FrozenStdioMcpListSchema` 对齐(64),两侧同一个上限才不会出现
@@ -8196,20 +8594,20 @@ var IssueMcpDevTicketResponseSchema = import_zod67.z.object({
8196
8594
  * 注意输出类型仍是**非可选数组**(`z.infer` 取的是 default 之后的形态),所以
8197
8595
  * 消费方不需要写 `?? []` 分支。
8198
8596
  */
8199
- stdioTargets: import_zod67.z.array(McpDevTicketStdioTargetSchema).max(64).default([])
8597
+ stdioTargets: import_zod69.z.array(McpDevTicketStdioTargetSchema).max(64).default([])
8200
8598
  }).strict();
8201
- var RevokeMcpDevTicketResponseSchema = import_zod67.z.object({
8599
+ var RevokeMcpDevTicketResponseSchema = import_zod69.z.object({
8202
8600
  /** `false` = 本来就不活跃(已撤销/不存在)。撤销是幂等的,两种都算成功。 */
8203
- revoked: import_zod67.z.boolean()
8601
+ revoked: import_zod69.z.boolean()
8204
8602
  }).strict();
8205
- var DevSecretEnvKeySchema = import_zod68.z.string().min(1).max(100).regex(/^[A-Z_][A-Z0-9_]*$/, "env key must match ^[A-Z_][A-Z0-9_]*$");
8206
- var ResolveMcpDevSecretsRequestSchema = import_zod68.z.object({
8207
- projectId: import_zod68.z.string().uuid(),
8603
+ 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_]*$");
8604
+ var ResolveMcpDevSecretsRequestSchema = import_zod70.z.object({
8605
+ projectId: import_zod70.z.string().uuid(),
8208
8606
  /**
8209
8607
  * 这个 agent 声明的托管 MCP id。服务端据此推导要解哪些 `sec_*` ——
8210
8608
  * 只有 `stdio` 形态有凭据要下发(`remote` 走 gateway,明文不出平台)。
8211
8609
  */
8212
- managedMcpIds: import_zod68.z.array(ManagedMcpIdSchema).max(64).optional(),
8610
+ managedMcpIds: import_zod70.z.array(ManagedMcpIdSchema).max(64).optional(),
8213
8611
  /**
8214
8612
  * `agent.yaml` 的 `env:` 里指向 secret 的条目:`envKey → sec_*`。
8215
8613
  *
@@ -8218,16 +8616,16 @@ var ResolveMcpDevSecretsRequestSchema = import_zod68.z.object({
8218
8616
  * `secrets:resolve` 的调用方本来就被授权读本项目任意 secret,所以这不扩大权限;
8219
8617
  * 上限在这里是为了让一次请求不能变成"把整个项目扫一遍"的批量导出工具。
8220
8618
  */
8221
- envSecretRefs: import_zod68.z.record(DevSecretEnvKeySchema, SecretPublicIdSchema).refine((refs) => Object.keys(refs).length <= 64, {
8619
+ envSecretRefs: import_zod70.z.record(DevSecretEnvKeySchema, SecretPublicIdSchema).refine((refs) => Object.keys(refs).length <= 64, {
8222
8620
  message: "envSecretRefs must have at most 64 entries"
8223
8621
  }).optional()
8224
8622
  }).strict();
8225
- var ResolveMcpDevSecretsResponseSchema = import_zod68.z.object({
8623
+ var ResolveMcpDevSecretsResponseSchema = import_zod70.z.object({
8226
8624
  /**
8227
8625
  * env 变量名 → **明文**。CLI 只把它放进子进程 env(`.mcp.json` 与 env 文件里
8228
8626
  * 都只写 `${VAR}` 占位符),不落盘。
8229
8627
  */
8230
- values: import_zod68.z.record(DevSecretEnvKeySchema, import_zod68.z.string()),
8628
+ values: import_zod70.z.record(DevSecretEnvKeySchema, import_zod70.z.string()),
8231
8629
  /**
8232
8630
  * 声明了但解不出来的 env key(不存在 / 已归档 / 不属于本项目)。
8233
8631
  *
@@ -8235,7 +8633,7 @@ var ResolveMcpDevSecretsResponseSchema = import_zod68.z.object({
8235
8633
  * `${VAR}` 字面量原样传给 MCP server,于是上游报"token 无效",排查方向被带到
8236
8634
  * 上游去,而真实原因是这里少了一个值。
8237
8635
  */
8238
- missing: import_zod68.z.array(import_zod68.z.string())
8636
+ missing: import_zod70.z.array(import_zod70.z.string())
8239
8637
  }).strict();
8240
8638
  var EVAL_SUITE_API_VERSION = "agenthub/v1alpha1";
8241
8639
  var EVAL_SUITE_KIND = "EvalSuite";
@@ -8245,7 +8643,7 @@ var EVAL_MAX_RETRIES = 2;
8245
8643
  var EVAL_MAX_TURN_BYTES = 32 * 1024;
8246
8644
  var EVAL_MAX_FIXTURE_FILE_BYTES = 64 * 1024;
8247
8645
  var EVAL_MAX_FIXTURE_TOTAL_BYTES = 512 * 1024;
8248
- var EvalRunStatusSchema = import_zod69.z.enum([
8646
+ var EvalRunStatusSchema = import_zod71.z.enum([
8249
8647
  "pending",
8250
8648
  "running",
8251
8649
  "passed",
@@ -8253,20 +8651,20 @@ var EvalRunStatusSchema = import_zod69.z.enum([
8253
8651
  "errored",
8254
8652
  "cancelled"
8255
8653
  ]);
8256
- var EvalCaseVerdictSchema = import_zod69.z.enum(["passed", "failed", "errored"]);
8257
- var EvalGraderStatusSchema = import_zod69.z.enum(["passed", "failed", "errored", "skipped"]);
8258
- var EvalErrorClassSchema = import_zod69.z.enum([
8654
+ var EvalCaseVerdictSchema = import_zod71.z.enum(["passed", "failed", "errored"]);
8655
+ var EvalGraderStatusSchema = import_zod71.z.enum(["passed", "failed", "errored", "skipped"]);
8656
+ var EvalErrorClassSchema = import_zod71.z.enum([
8259
8657
  "capability_unavailable",
8260
8658
  "infrastructure_error",
8261
8659
  "indeterminate",
8262
8660
  "invalid_definition"
8263
8661
  ]);
8264
- var EvalErrorCodeSchema = import_zod69.z.enum([
8662
+ var EvalErrorCodeSchema = import_zod71.z.enum([
8265
8663
  "EVAL_GRADER_CAPABILITY_UNAVAILABLE",
8266
8664
  "EVAL_SELF_EVAL_FORBIDDEN"
8267
8665
  ]);
8268
8666
  var EVAL_SCRIPT_STDOUT_TAIL_MAX_BYTES = 64 * 1024;
8269
- var EvalTriggerSchema = import_zod69.z.enum([
8667
+ var EvalTriggerSchema = import_zod71.z.enum([
8270
8668
  "manual",
8271
8669
  "promote_gate",
8272
8670
  "cli",
@@ -8276,51 +8674,51 @@ var EvalTriggerSchema = import_zod69.z.enum([
8276
8674
  "replay",
8277
8675
  "pipeline"
8278
8676
  ]);
8279
- var EvalSeveritySchema = import_zod69.z.enum(["gate", "soft"]);
8280
- var EvalGraderTypeSchema = import_zod69.z.enum(["transcript", "file", "llm", "script"]);
8281
- var EvalPassPolicySchema = import_zod69.z.enum(["all", "any"]);
8282
- var EvalSuitePurposeSchema = import_zod69.z.enum(["regression", "capability"]);
8677
+ var EvalSeveritySchema = import_zod71.z.enum(["gate", "soft"]);
8678
+ var EvalGraderTypeSchema = import_zod71.z.enum(["transcript", "file", "llm", "script"]);
8679
+ var EvalPassPolicySchema = import_zod71.z.enum(["all", "any"]);
8680
+ var EvalSuitePurposeSchema = import_zod71.z.enum(["regression", "capability"]);
8283
8681
  var EVAL_SKIP_REASON_MAX = 2048;
8284
- var EvalSuiteSkipSchema = import_zod69.z.object({ reason: import_zod69.z.string().min(1).max(EVAL_SKIP_REASON_MAX) }).strict();
8285
- var EvalSkippedSuiteSchema = import_zod69.z.object({ path: import_zod69.z.string().min(1), reason: import_zod69.z.string().min(1) }).strict();
8286
- var EvalConclusionStatusSchema = import_zod69.z.enum(["passed", "failed", "errored", "unassessed"]);
8682
+ var EvalSuiteSkipSchema = import_zod71.z.object({ reason: import_zod71.z.string().min(1).max(EVAL_SKIP_REASON_MAX) }).strict();
8683
+ var EvalSkippedSuiteSchema = import_zod71.z.object({ path: import_zod71.z.string().min(1), reason: import_zod71.z.string().min(1) }).strict();
8684
+ var EvalConclusionStatusSchema = import_zod71.z.enum(["passed", "failed", "errored", "unassessed"]);
8287
8685
  var isSafeRelativePath = (p) => !p.startsWith("/") && !p.split("/").includes("..") && !p.split("/").includes(".");
8288
- var EvalRelativePathSchema = import_zod69.z.string().min(1).max(255).refine(isSafeRelativePath, {
8686
+ var EvalRelativePathSchema = import_zod71.z.string().min(1).max(255).refine(isSafeRelativePath, {
8289
8687
  message: "path must be a relative path without '.' or '..' segments"
8290
8688
  });
8291
- var EvalSlugSchema = import_zod69.z.string().regex(/^[a-z0-9-]{1,64}$/, {
8689
+ var EvalSlugSchema = import_zod71.z.string().regex(/^[a-z0-9-]{1,64}$/, {
8292
8690
  message: "must be a slug matching [a-z0-9-]{1,64}"
8293
8691
  });
8294
- var EvalTimesExprSchema = import_zod69.z.string().regex(/^(>=|<=|=|>|<)?\d+$/, {
8692
+ var EvalTimesExprSchema = import_zod71.z.string().regex(/^(>=|<=|=|>|<)?\d+$/, {
8295
8693
  message: 'times must match an operator + integer, e.g. ">=1", "=3", "2"'
8296
8694
  });
8297
- var EvalMarkerSchema = import_zod69.z.object({
8298
- evalRunId: import_zod69.z.string().min(1),
8695
+ var EvalMarkerSchema = import_zod71.z.object({
8696
+ evalRunId: import_zod71.z.string().min(1),
8299
8697
  caseId: EvalSlugSchema,
8300
- trial: import_zod69.z.number().int().nonnegative()
8301
- }).strict();
8302
- var EvalPatternRulesSchema = import_zod69.z.object({
8303
- required: import_zod69.z.array(import_zod69.z.string()).optional(),
8304
- forbidden: import_zod69.z.array(import_zod69.z.string()).optional()
8305
- }).strict();
8306
- var EvalTranscriptExpectSchema = import_zod69.z.object({
8307
- completed: import_zod69.z.boolean().optional(),
8308
- calledTool: import_zod69.z.object({ name: import_zod69.z.string().min(1), times: EvalTimesExprSchema.optional() }).strict().optional(),
8309
- toolOrder: import_zod69.z.array(import_zod69.z.string().min(1)).optional(),
8310
- forbiddenTools: import_zod69.z.array(import_zod69.z.string().min(1)).optional(),
8311
- calledSubagent: import_zod69.z.object({ name: import_zod69.z.string().min(1).optional(), times: EvalTimesExprSchema.optional() }).strict().optional(),
8312
- usedNoTools: import_zod69.z.boolean().optional(),
8313
- loadedSkill: import_zod69.z.string().min(1).optional(),
8314
- maxToolCalls: import_zod69.z.number().int().positive().optional(),
8698
+ trial: import_zod71.z.number().int().nonnegative()
8699
+ }).strict();
8700
+ var EvalPatternRulesSchema = import_zod71.z.object({
8701
+ required: import_zod71.z.array(import_zod71.z.string()).optional(),
8702
+ forbidden: import_zod71.z.array(import_zod71.z.string()).optional()
8703
+ }).strict();
8704
+ var EvalTranscriptExpectSchema = import_zod71.z.object({
8705
+ completed: import_zod71.z.boolean().optional(),
8706
+ calledTool: import_zod71.z.object({ name: import_zod71.z.string().min(1), times: EvalTimesExprSchema.optional() }).strict().optional(),
8707
+ toolOrder: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8708
+ forbiddenTools: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8709
+ calledSubagent: import_zod71.z.object({ name: import_zod71.z.string().min(1).optional(), times: EvalTimesExprSchema.optional() }).strict().optional(),
8710
+ usedNoTools: import_zod71.z.boolean().optional(),
8711
+ loadedSkill: import_zod71.z.string().min(1).optional(),
8712
+ maxToolCalls: import_zod71.z.number().int().positive().optional(),
8315
8713
  commandPatterns: EvalPatternRulesSchema.optional(),
8316
8714
  toolInputPatterns: EvalPatternRulesSchema.optional()
8317
8715
  }).strict();
8318
- var EvalTranscriptGraderSchema = import_zod69.z.object({
8319
- type: import_zod69.z.literal("transcript"),
8716
+ var EvalTranscriptGraderSchema = import_zod71.z.object({
8717
+ type: import_zod71.z.literal("transcript"),
8320
8718
  label: EvalSlugSchema.optional(),
8321
8719
  severity: EvalSeveritySchema.optional(),
8322
8720
  // 缺省 gate
8323
- online: import_zod69.z.boolean().optional(),
8721
+ online: import_zod71.z.boolean().optional(),
8324
8722
  /**
8325
8723
  * T2 真·多轮:只对第 `turn` 轮(0-based,指向 `case.turns` 的下标)的轨迹
8326
8724
  * 断言——可以表达"第二轮才调用 run_sql"。缺省 = 整个 trial 的合并轨迹
@@ -8332,79 +8730,79 @@ var EvalTranscriptGraderSchema = import_zod69.z.object({
8332
8730
  * turns 上下文;单 parse 一个 grader 不带上界,越界到 gradeTranscript
8333
8731
  * 才 errored——已知取舍)。
8334
8732
  */
8335
- turn: import_zod69.z.number().int().min(0).optional(),
8733
+ turn: import_zod71.z.number().int().min(0).optional(),
8336
8734
  expect: EvalTranscriptExpectSchema
8337
8735
  }).strict();
8338
- var EvalFileEntrySchema = import_zod69.z.object({
8736
+ var EvalFileEntrySchema = import_zod71.z.object({
8339
8737
  path: EvalRelativePathSchema,
8340
- mustMatch: import_zod69.z.array(import_zod69.z.string()).optional(),
8341
- mustNotMatch: import_zod69.z.array(import_zod69.z.string()).optional()
8738
+ mustMatch: import_zod71.z.array(import_zod71.z.string()).optional(),
8739
+ mustNotMatch: import_zod71.z.array(import_zod71.z.string()).optional()
8342
8740
  }).strict();
8343
- var EvalFileShorthandExpectSchema = import_zod69.z.object({
8344
- includes: import_zod69.z.string().optional(),
8345
- equals: import_zod69.z.string().optional(),
8346
- matches: import_zod69.z.string().optional()
8741
+ var EvalFileShorthandExpectSchema = import_zod71.z.object({
8742
+ includes: import_zod71.z.string().optional(),
8743
+ equals: import_zod71.z.string().optional(),
8744
+ matches: import_zod71.z.string().optional()
8347
8745
  // 正则字符串
8348
8746
  }).strict();
8349
- var EvalFileGraderSchema = import_zod69.z.object({
8350
- type: import_zod69.z.literal("file"),
8747
+ var EvalFileGraderSchema = import_zod71.z.object({
8748
+ type: import_zod71.z.literal("file"),
8351
8749
  label: EvalSlugSchema.optional(),
8352
8750
  severity: EvalSeveritySchema.optional(),
8353
8751
  // 缺省 gate
8354
- online: import_zod69.z.boolean().optional(),
8752
+ online: import_zod71.z.boolean().optional(),
8355
8753
  // 多文件形式
8356
- files: import_zod69.z.array(EvalFileEntrySchema).min(1).optional(),
8754
+ files: import_zod71.z.array(EvalFileEntrySchema).min(1).optional(),
8357
8755
  // 简写形式
8358
8756
  path: EvalRelativePathSchema.optional(),
8359
8757
  expect: EvalFileShorthandExpectSchema.optional()
8360
8758
  }).strict();
8361
- var EvalLlmGraderSchema = import_zod69.z.object({
8362
- type: import_zod69.z.literal("llm"),
8759
+ var EvalLlmGraderSchema = import_zod71.z.object({
8760
+ type: import_zod71.z.literal("llm"),
8363
8761
  label: EvalSlugSchema.optional(),
8364
8762
  severity: EvalSeveritySchema.optional(),
8365
8763
  // 缺省 soft
8366
- online: import_zod69.z.boolean().optional(),
8764
+ online: import_zod71.z.boolean().optional(),
8367
8765
  rubric: EvalRelativePathSchema.refine((p) => p.endsWith(".md"), {
8368
8766
  message: "rubric must be a relative .md path within the suite"
8369
8767
  }),
8370
- dimensions: import_zod69.z.array(import_zod69.z.string().min(1)).optional(),
8371
- threshold: import_zod69.z.number().min(0).max(1),
8372
- graderVersion: import_zod69.z.number().int().positive()
8768
+ dimensions: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8769
+ threshold: import_zod71.z.number().min(0).max(1),
8770
+ graderVersion: import_zod71.z.number().int().positive()
8373
8771
  }).strict();
8374
- var EvalScriptExpectSchema = import_zod69.z.object({
8375
- exitCode: import_zod69.z.number().int().optional(),
8772
+ var EvalScriptExpectSchema = import_zod71.z.object({
8773
+ exitCode: import_zod71.z.number().int().optional(),
8376
8774
  // 缺省 0
8377
- stdoutIncludes: import_zod69.z.array(import_zod69.z.string()).optional()
8775
+ stdoutIncludes: import_zod71.z.array(import_zod71.z.string()).optional()
8378
8776
  }).strict();
8379
- var EvalScriptGraderSchema = import_zod69.z.object({
8380
- type: import_zod69.z.literal("script"),
8777
+ var EvalScriptGraderSchema = import_zod71.z.object({
8778
+ type: import_zod71.z.literal("script"),
8381
8779
  label: EvalSlugSchema.optional(),
8382
8780
  severity: EvalSeveritySchema.optional(),
8383
8781
  // 缺省 gate
8384
- online: import_zod69.z.boolean().optional(),
8385
- run: import_zod69.z.string().min(1),
8386
- timeout: import_zod69.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8782
+ online: import_zod71.z.boolean().optional(),
8783
+ run: import_zod71.z.string().min(1),
8784
+ timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8387
8785
  expect: EvalScriptExpectSchema.optional()
8388
8786
  }).strict();
8389
- var EvalGraderSpecSchema = import_zod69.z.discriminatedUnion("type", [
8787
+ var EvalGraderSpecSchema = import_zod71.z.discriminatedUnion("type", [
8390
8788
  EvalTranscriptGraderSchema,
8391
8789
  EvalFileGraderSchema,
8392
8790
  EvalLlmGraderSchema,
8393
8791
  EvalScriptGraderSchema
8394
8792
  ]);
8395
- var EvalFixtureWorkspaceSchema = import_zod69.z.object({
8396
- repo: import_zod69.z.string().url(),
8397
- ref: import_zod69.z.string().min(1)
8793
+ var EvalFixtureWorkspaceSchema = import_zod71.z.object({
8794
+ repo: import_zod71.z.string().url(),
8795
+ ref: import_zod71.z.string().min(1)
8398
8796
  }).strict();
8399
- var EvalFixtureFileSchema = import_zod69.z.object({
8797
+ var EvalFixtureFileSchema = import_zod71.z.object({
8400
8798
  path: EvalRelativePathSchema,
8401
- content: import_zod69.z.string()
8799
+ content: import_zod71.z.string()
8402
8800
  }).strict();
8403
- var EvalFixturesSchema = import_zod69.z.object({
8801
+ var EvalFixturesSchema = import_zod71.z.object({
8404
8802
  workspace: EvalFixtureWorkspaceSchema.optional(),
8405
- files: import_zod69.z.array(EvalFixtureFileSchema).optional()
8803
+ files: import_zod71.z.array(EvalFixtureFileSchema).optional()
8406
8804
  }).strict();
8407
- var EvalAgentOverridesSchema = import_zod69.z.object({
8805
+ var EvalAgentOverridesSchema = import_zod71.z.object({
8408
8806
  /**
8409
8807
  * 覆盖被测 agent 的模型。**被测 model 是 case 级可变的**:最终生效值 =
8410
8808
  * `agentOverrides.model ?? agent 默认 model`,故同一份卷不同 case 的被测
@@ -8417,7 +8815,7 @@ var EvalAgentOverridesSchema = import_zod69.z.object({
8417
8815
  * 先经 ModelGate 归一为 canonical id 再比较——**需运行时上下文,故不在本零依赖
8418
8816
  * 契约层做,留给 T3/T4 resolve 层的 400**。
8419
8817
  */
8420
- model: import_zod69.z.string().min(1).optional(),
8818
+ model: import_zod71.z.string().min(1).optional(),
8421
8819
  /**
8422
8820
  * T1 语义(减法白名单):把 revision 解析出的 skills **收窄**为名单内的
8423
8821
  * 子集(按 `EnabledSkill.rushSkillName` 匹配——即 agent skills.json 里写的
@@ -8426,42 +8824,42 @@ var EvalAgentOverridesSchema = import_zod69.z.object({
8426
8824
  * agent,是假红灯)。**不能加塞** revision 未声明的 skill——eval 测的是
8427
8825
  * 「已发布的 agent」,不是「一个不存在的配置」。
8428
8826
  */
8429
- skills: import_zod69.z.array(import_zod69.z.string().min(1)).optional(),
8827
+ skills: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8430
8828
  /**
8431
8829
  * T1 语义(减法白名单):把 revision 解析出的 mcpServers **收窄**为名单内
8432
8830
  * 的子集(按 runtime `.mcp.json` 的 server 键名匹配,即 agent 实际运行的
8433
8831
  * server 名)。匹配规则与 fail-loud 姿态同 `skills`。stdio transport 的
8434
8832
  * server 仍受 `allowStdioMcp` 总闸约束(默认不注入)。
8435
8833
  */
8436
- mcpServers: import_zod69.z.array(import_zod69.z.string().min(1)).optional(),
8834
+ mcpServers: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8437
8835
  /**
8438
8836
  * T1 语义:追加在被测 agent 冻结 systemPrompt 之后的指令块(`\n\n` 拼接),
8439
8837
  * 例如注入 case 特有的输出格式要求。不能替换(替换 = 测别的 agent)。
8440
8838
  */
8441
- systemPromptAppend: import_zod69.z.string().optional()
8839
+ systemPromptAppend: import_zod71.z.string().optional()
8442
8840
  }).strict();
8443
- var EvalCaseOriginSchema = import_zod69.z.object({
8444
- sessionId: import_zod69.z.string().min(1),
8445
- capturedAt: import_zod69.z.string().min(1)
8841
+ var EvalCaseOriginSchema = import_zod71.z.object({
8842
+ sessionId: import_zod71.z.string().min(1),
8843
+ capturedAt: import_zod71.z.string().min(1)
8446
8844
  }).strict();
8447
- var EvalCaseSchema = import_zod69.z.object({
8845
+ var EvalCaseSchema = import_zod71.z.object({
8448
8846
  id: EvalSlugSchema,
8449
- description: import_zod69.z.string().optional(),
8450
- turns: import_zod69.z.array(import_zod69.z.object({ user: import_zod69.z.string().min(1) }).strict()).min(1),
8847
+ description: import_zod71.z.string().optional(),
8848
+ turns: import_zod71.z.array(import_zod71.z.object({ user: import_zod71.z.string().min(1) }).strict()).min(1),
8451
8849
  fixtures: EvalFixturesSchema.optional(),
8452
8850
  agentOverrides: EvalAgentOverridesSchema.optional(),
8453
- timeout: import_zod69.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8454
- maxRetries: import_zod69.z.number().int().min(0).max(EVAL_MAX_RETRIES).optional(),
8455
- trials: import_zod69.z.number().int().min(1).max(EVAL_MAX_TRIALS).optional(),
8851
+ timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8852
+ maxRetries: import_zod71.z.number().int().min(0).max(EVAL_MAX_RETRIES).optional(),
8853
+ trials: import_zod71.z.number().int().min(1).max(EVAL_MAX_TRIALS).optional(),
8456
8854
  // U1,默认 1
8457
8855
  passPolicy: EvalPassPolicySchema.optional(),
8458
8856
  // U1,缺省按 purpose
8459
8857
  origin: EvalCaseOriginSchema.optional(),
8460
- allowStdioMcp: import_zod69.z.boolean().optional(),
8858
+ allowStdioMcp: import_zod71.z.boolean().optional(),
8461
8859
  // 默认 false(§2.1.1 副作用面)
8462
- graders: import_zod69.z.array(EvalGraderSpecSchema).min(1)
8860
+ graders: import_zod71.z.array(EvalGraderSpecSchema).min(1)
8463
8861
  }).strict();
8464
- var EvalSuiteDefaultsSchema = import_zod69.z.object({
8862
+ var EvalSuiteDefaultsSchema = import_zod71.z.object({
8465
8863
  /**
8466
8864
  * llm grader 的裁判模型。**仅 suite 级、不可 case/grader 级覆盖**(也不在
8467
8865
  * `EvalAgentOverridesSchema` 白名单里)。
@@ -8483,27 +8881,27 @@ var EvalSuiteDefaultsSchema = import_zod69.z.object({
8483
8881
  * 兑现留给 T7(llm grader 实现),届时大概率取当时最合适的 judge 且做成运行面
8484
8882
  * 可配置,而非硬编码进契约。
8485
8883
  */
8486
- judgeModel: import_zod69.z.string().min(1).optional(),
8487
- timeout: import_zod69.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8488
- maxConcurrency: import_zod69.z.number().int().positive().optional()
8884
+ judgeModel: import_zod71.z.string().min(1).optional(),
8885
+ timeout: import_zod71.z.number().int().positive().max(EVAL_MAX_TIMEOUT_SECONDS).optional(),
8886
+ maxConcurrency: import_zod71.z.number().int().positive().optional()
8489
8887
  }).strict();
8490
8888
  var byteLen = (s) => new TextEncoder().encode(s).length;
8491
- var EvalSuiteSchema = import_zod69.z.object({
8492
- apiVersion: import_zod69.z.literal(EVAL_SUITE_API_VERSION),
8493
- kind: import_zod69.z.literal(EVAL_SUITE_KIND),
8889
+ var EvalSuiteSchema = import_zod71.z.object({
8890
+ apiVersion: import_zod71.z.literal(EVAL_SUITE_API_VERSION),
8891
+ kind: import_zod71.z.literal(EVAL_SUITE_KIND),
8494
8892
  purpose: EvalSuitePurposeSchema.optional(),
8495
8893
  // U2,默认 regression
8496
8894
  skip: EvalSuiteSkipSchema.optional(),
8497
8895
  // §4 声明跳过(带必填理由)
8498
8896
  defaults: EvalSuiteDefaultsSchema.optional(),
8499
- cases: import_zod69.z.array(EvalCaseSchema).min(1)
8897
+ cases: import_zod71.z.array(EvalCaseSchema).min(1)
8500
8898
  }).strict().superRefine((suite, ctx) => {
8501
8899
  const seen = /* @__PURE__ */ new Set();
8502
8900
  suite.cases.forEach((c, ci) => {
8503
8901
  var _a, _b;
8504
8902
  if (seen.has(c.id)) {
8505
8903
  ctx.addIssue({
8506
- code: import_zod69.z.ZodIssueCode.custom,
8904
+ code: import_zod71.z.ZodIssueCode.custom,
8507
8905
  path: ["cases", ci, "id"],
8508
8906
  message: `duplicate case id "${c.id}" (must be unique within suite)`
8509
8907
  });
@@ -8512,7 +8910,7 @@ var EvalSuiteSchema = import_zod69.z.object({
8512
8910
  c.turns.forEach((t, ti) => {
8513
8911
  if (byteLen(t.user) > EVAL_MAX_TURN_BYTES) {
8514
8912
  ctx.addIssue({
8515
- code: import_zod69.z.ZodIssueCode.custom,
8913
+ code: import_zod71.z.ZodIssueCode.custom,
8516
8914
  path: ["cases", ci, "turns", ti, "user"],
8517
8915
  message: `turn exceeds ${EVAL_MAX_TURN_BYTES} bytes`
8518
8916
  });
@@ -8524,7 +8922,7 @@ var EvalSuiteSchema = import_zod69.z.object({
8524
8922
  fixtureTotal += size;
8525
8923
  if (size > EVAL_MAX_FIXTURE_FILE_BYTES) {
8526
8924
  ctx.addIssue({
8527
- code: import_zod69.z.ZodIssueCode.custom,
8925
+ code: import_zod71.z.ZodIssueCode.custom,
8528
8926
  path: ["cases", ci, "fixtures", "files", fi, "content"],
8529
8927
  message: `fixture file exceeds ${EVAL_MAX_FIXTURE_FILE_BYTES} bytes`
8530
8928
  });
@@ -8532,7 +8930,7 @@ var EvalSuiteSchema = import_zod69.z.object({
8532
8930
  });
8533
8931
  if (fixtureTotal > EVAL_MAX_FIXTURE_TOTAL_BYTES) {
8534
8932
  ctx.addIssue({
8535
- code: import_zod69.z.ZodIssueCode.custom,
8933
+ code: import_zod71.z.ZodIssueCode.custom,
8536
8934
  path: ["cases", ci, "fixtures", "files"],
8537
8935
  message: `fixture files total exceeds ${EVAL_MAX_FIXTURE_TOTAL_BYTES} bytes`
8538
8936
  });
@@ -8543,7 +8941,7 @@ var EvalSuiteSchema = import_zod69.z.object({
8543
8941
  const hasShorthand = g.path != null && g.expect != null;
8544
8942
  if (hasFiles === hasShorthand) {
8545
8943
  ctx.addIssue({
8546
- code: import_zod69.z.ZodIssueCode.custom,
8944
+ code: import_zod71.z.ZodIssueCode.custom,
8547
8945
  path: ["cases", ci, "graders", gi],
8548
8946
  message: "file grader must use either `files[]` or `{path, expect}`, not both/neither"
8549
8947
  });
@@ -8551,7 +8949,7 @@ var EvalSuiteSchema = import_zod69.z.object({
8551
8949
  }
8552
8950
  if (g.type === "transcript" && g.turn != null && g.turn >= c.turns.length) {
8553
8951
  ctx.addIssue({
8554
- code: import_zod69.z.ZodIssueCode.custom,
8952
+ code: import_zod71.z.ZodIssueCode.custom,
8555
8953
  path: ["cases", ci, "graders", gi, "turn"],
8556
8954
  message: `transcript grader turn=${g.turn} is out of range (case has ${c.turns.length} turn(s); 0-based)`
8557
8955
  });
@@ -8559,90 +8957,90 @@ var EvalSuiteSchema = import_zod69.z.object({
8559
8957
  });
8560
8958
  });
8561
8959
  });
8562
- var ScriptEvidenceSchema = import_zod69.z.discriminatedUnion("kind", [
8563
- import_zod69.z.object({
8564
- kind: import_zod69.z.literal("executed"),
8960
+ var ScriptEvidenceSchema = import_zod71.z.discriminatedUnion("kind", [
8961
+ import_zod71.z.object({
8962
+ kind: import_zod71.z.literal("executed"),
8565
8963
  // A1
8566
- exitCode: import_zod69.z.number().int(),
8567
- stdoutTailRef: import_zod69.z.string().optional(),
8964
+ exitCode: import_zod71.z.number().int(),
8965
+ stdoutTailRef: import_zod71.z.string().optional(),
8568
8966
  // 超限内容走 OSS ref
8569
- durationMs: import_zod69.z.number().int().nonnegative()
8967
+ durationMs: import_zod71.z.number().int().nonnegative()
8570
8968
  }).strict(),
8571
- import_zod69.z.object({
8572
- kind: import_zod69.z.literal("capability_unavailable"),
8969
+ import_zod71.z.object({
8970
+ kind: import_zod71.z.literal("capability_unavailable"),
8573
8971
  // A0
8574
- capability: import_zod69.z.literal("script_grader"),
8575
- phase: import_zod69.z.literal("A0")
8972
+ capability: import_zod71.z.literal("script_grader"),
8973
+ phase: import_zod71.z.literal("A0")
8576
8974
  }).strict()
8577
8975
  ]);
8578
- var EvalGraderEvidenceSchema = import_zod69.z.discriminatedUnion("type", [
8579
- import_zod69.z.object({
8580
- type: import_zod69.z.literal("transcript"),
8581
- matchedEventIds: import_zod69.z.array(import_zod69.z.string()).optional(),
8582
- violatedCheck: import_zod69.z.string().optional()
8976
+ var EvalGraderEvidenceSchema = import_zod71.z.discriminatedUnion("type", [
8977
+ import_zod71.z.object({
8978
+ type: import_zod71.z.literal("transcript"),
8979
+ matchedEventIds: import_zod71.z.array(import_zod71.z.string()).optional(),
8980
+ violatedCheck: import_zod71.z.string().optional()
8583
8981
  }).strict(),
8584
- import_zod69.z.object({
8585
- type: import_zod69.z.literal("file"),
8586
- path: import_zod69.z.string(),
8587
- excerpt: import_zod69.z.string().max(2048).optional()
8982
+ import_zod71.z.object({
8983
+ type: import_zod71.z.literal("file"),
8984
+ path: import_zod71.z.string(),
8985
+ excerpt: import_zod71.z.string().max(2048).optional()
8588
8986
  // ≤2KB
8589
8987
  }).strict(),
8590
- import_zod69.z.object({
8591
- type: import_zod69.z.literal("llm"),
8592
- judgeModel: import_zod69.z.string(),
8593
- rubricSha: import_zod69.z.string(),
8988
+ import_zod71.z.object({
8989
+ type: import_zod71.z.literal("llm"),
8990
+ judgeModel: import_zod71.z.string(),
8991
+ rubricSha: import_zod71.z.string(),
8594
8992
  // U5:离散档位 + 锚点文本(不是换算后小数)
8595
- dimensionScores: import_zod69.z.record(import_zod69.z.string(), import_zod69.z.unknown()).optional(),
8596
- judgeOutputRef: import_zod69.z.string().optional()
8993
+ dimensionScores: import_zod71.z.record(import_zod71.z.string(), import_zod71.z.unknown()).optional(),
8994
+ judgeOutputRef: import_zod71.z.string().optional()
8597
8995
  // judge 原始输出 OSS ref
8598
8996
  }).strict(),
8599
- import_zod69.z.object({ type: import_zod69.z.literal("script"), evidence: ScriptEvidenceSchema }).strict()
8997
+ import_zod71.z.object({ type: import_zod71.z.literal("script"), evidence: ScriptEvidenceSchema }).strict()
8600
8998
  ]);
8601
- var GraderVerdictSchema = import_zod69.z.object({
8602
- graderIndex: import_zod69.z.number().int().nonnegative(),
8603
- graderKey: import_zod69.z.string(),
8999
+ var GraderVerdictSchema = import_zod71.z.object({
9000
+ graderIndex: import_zod71.z.number().int().nonnegative(),
9001
+ graderKey: import_zod71.z.string(),
8604
9002
  type: EvalGraderTypeSchema,
8605
9003
  severity: EvalSeveritySchema,
8606
9004
  // resolve 后终值
8607
- label: import_zod69.z.string().optional(),
9005
+ label: import_zod71.z.string().optional(),
8608
9006
  status: EvalGraderStatusSchema,
8609
9007
  errorClass: EvalErrorClassSchema.optional(),
8610
9008
  // status=errored 时
8611
9009
  errorCode: EvalErrorCodeSchema.optional(),
8612
9010
  // status=errored 时
8613
- score: import_zod69.z.number().nullable(),
9011
+ score: import_zod71.z.number().nullable(),
8614
9012
  // llm=0~1;二值 grader=null
8615
- threshold: import_zod69.z.number().optional(),
8616
- reason: import_zod69.z.string(),
9013
+ threshold: import_zod71.z.number().optional(),
9014
+ reason: import_zod71.z.string(),
8617
9015
  evidence: EvalGraderEvidenceSchema.optional(),
8618
- graderVersion: import_zod69.z.number().int().optional(),
8619
- engineVersion: import_zod69.z.string(),
9016
+ graderVersion: import_zod71.z.number().int().optional(),
9017
+ engineVersion: import_zod71.z.string(),
8620
9018
  // 平台 grader 实现版本,基线口径用
8621
- durationMs: import_zod69.z.number().int().nonnegative().optional()
9019
+ durationMs: import_zod71.z.number().int().nonnegative().optional()
8622
9020
  }).strict();
8623
- var EvalCaseResultSchema = import_zod69.z.object({
8624
- caseId: import_zod69.z.string(),
8625
- trial: import_zod69.z.number().int().nonnegative(),
9021
+ var EvalCaseResultSchema = import_zod71.z.object({
9022
+ caseId: import_zod71.z.string(),
9023
+ trial: import_zod71.z.number().int().nonnegative(),
8626
9024
  // U1,online_sample 恒 0
8627
- attempt: import_zod69.z.number().int().nonnegative(),
9025
+ attempt: import_zod71.z.number().int().nonnegative(),
8628
9026
  // 基础设施重试序
8629
- sessionId: import_zod69.z.string().optional(),
9027
+ sessionId: import_zod71.z.string().optional(),
8630
9028
  verdict: EvalCaseVerdictSchema,
8631
- caseDefinitionDigest: import_zod69.z.string(),
9029
+ caseDefinitionDigest: import_zod71.z.string(),
8632
9030
  errorClass: EvalErrorClassSchema.optional(),
8633
9031
  errorCode: EvalErrorCodeSchema.optional(),
8634
- softMisses: import_zod69.z.array(import_zod69.z.string()),
8635
- softIncomplete: import_zod69.z.array(import_zod69.z.string()),
8636
- graders: import_zod69.z.array(GraderVerdictSchema),
8637
- resolvedRef: import_zod69.z.string().optional()
9032
+ softMisses: import_zod71.z.array(import_zod71.z.string()),
9033
+ softIncomplete: import_zod71.z.array(import_zod71.z.string()),
9034
+ graders: import_zod71.z.array(GraderVerdictSchema),
9035
+ resolvedRef: import_zod71.z.string().optional()
8638
9036
  // fixtures.workspace.ref → commit SHA
8639
9037
  }).strict();
8640
- var EvalRunSummarySchema = import_zod69.z.object({
8641
- total: import_zod69.z.number().int().nonnegative(),
8642
- passed: import_zod69.z.number().int().nonnegative(),
8643
- failed: import_zod69.z.number().int().nonnegative(),
8644
- errored: import_zod69.z.number().int().nonnegative(),
8645
- gatePass: import_zod69.z.boolean(),
9038
+ var EvalRunSummarySchema = import_zod71.z.object({
9039
+ total: import_zod71.z.number().int().nonnegative(),
9040
+ passed: import_zod71.z.number().int().nonnegative(),
9041
+ failed: import_zod71.z.number().int().nonnegative(),
9042
+ errored: import_zod71.z.number().int().nonnegative(),
9043
+ gatePass: import_zod71.z.boolean(),
8646
9044
  // 正向断言:全部 case 的全部 gate grader 显式 passed
8647
9045
  /**
8648
9046
  * v1.2:本 run 参与门禁的 grader 总数。零 gate grader 时 `gatePass` 按「真空为真」
@@ -8650,116 +9048,116 @@ var EvalRunSummarySchema = import_zod69.z.object({
8650
9048
  * 本字段让使用者一眼分辨「真的全部通过」与「压根没有门禁断言」。
8651
9049
  * optional:老数据无此字段。
8652
9050
  */
8653
- gateGraderCount: import_zod69.z.number().int().nonnegative().optional(),
9051
+ gateGraderCount: import_zod71.z.number().int().nonnegative().optional(),
8654
9052
  /**
8655
9053
  * v1.2:有多少 case 一个 gate grader 都没有(各自「真空为真」)。`gateGraderCount`
8656
9054
  * 是 sum,只能答「全 run 有没有任何门禁断言」;本字段答「是否每个 case 都有」——
8657
9055
  * `gatePass=true` 但本值 > 0 = 有 case 无门禁却被算作通过(case 级假绿)。optional:老数据无。
8658
9056
  */
8659
- casesWithoutGateGrader: import_zod69.z.number().int().nonnegative().optional(),
8660
- errorSummary: import_zod69.z.object({
8661
- capabilityUnavailable: import_zod69.z.number().int().nonnegative(),
8662
- infrastructureError: import_zod69.z.number().int().nonnegative(),
9057
+ casesWithoutGateGrader: import_zod71.z.number().int().nonnegative().optional(),
9058
+ errorSummary: import_zod71.z.object({
9059
+ capabilityUnavailable: import_zod71.z.number().int().nonnegative(),
9060
+ infrastructureError: import_zod71.z.number().int().nonnegative(),
8663
9061
  /** v1.2:judge 未能给出结论(gate llm UNKNOWN)。optional:老数据无此字段。 */
8664
- indeterminate: import_zod69.z.number().int().nonnegative().optional(),
9062
+ indeterminate: import_zod71.z.number().int().nonnegative().optional(),
8665
9063
  /** v1.2:定义写错(自评防护 EVAL_SELF_EVAL_FORBIDDEN)。optional:老数据无此字段。 */
8666
- invalidDefinition: import_zod69.z.number().int().nonnegative().optional()
9064
+ invalidDefinition: import_zod71.z.number().int().nonnegative().optional()
8667
9065
  }).loose().optional()
8668
9066
  }).loose();
8669
9067
  var EvalRunSummaryWriteSchema = EvalRunSummarySchema.extend({
8670
9068
  errorSummary: EvalRunSummarySchema.shape.errorSummary.unwrap().strict().optional()
8671
9069
  }).strict();
8672
- var EvalSuiteRefSchema = import_zod69.z.object({
8673
- source: import_zod69.z.enum(["package", "repo"]),
8674
- digest: import_zod69.z.string().min(1),
8675
- path: import_zod69.z.string().min(1)
9070
+ var EvalSuiteRefSchema = import_zod71.z.object({
9071
+ source: import_zod71.z.enum(["package", "repo"]),
9072
+ digest: import_zod71.z.string().min(1),
9073
+ path: import_zod71.z.string().min(1)
8676
9074
  }).strict();
8677
- var CreateEvalRunRequestSchema = import_zod69.z.object({
8678
- agent: import_zod69.z.string().min(1),
9075
+ var CreateEvalRunRequestSchema = import_zod71.z.object({
9076
+ agent: import_zod71.z.string().min(1),
8679
9077
  // A0 只打 test stage(§9 非目标:不做 prod 直评)。用 enum 而非 literal——
8680
9078
  // 将来放开 staging/prod 时「enum 加值」是非破坏性变更,literal 变 enum 才是
8681
9079
  // 破坏性变更(T1 评审建议,见设计文档 §2.1.6)。
8682
- stage: import_zod69.z.enum(["test"]),
9080
+ stage: import_zod71.z.enum(["test"]),
8683
9081
  suiteRef: EvalSuiteRefSchema.optional(),
8684
9082
  // 缺省=目标 Revision 绑定的 suite
8685
- caseIds: import_zod69.z.array(EvalSlugSchema).optional(),
8686
- strict: import_zod69.z.boolean().optional()
9083
+ caseIds: import_zod71.z.array(EvalSlugSchema).optional(),
9084
+ strict: import_zod71.z.boolean().optional()
8687
9085
  }).strict();
8688
- var CreateEvalRunResponseSchema = import_zod69.z.object({ runId: import_zod69.z.string().min(1) }).strict();
8689
- var CancelEvalRunResponseSchema = import_zod69.z.object({ runId: import_zod69.z.string().min(1), cancelled: import_zod69.z.boolean() }).strict();
8690
- var EvalRunViewSchema = import_zod69.z.object({
8691
- runId: import_zod69.z.string(),
9086
+ var CreateEvalRunResponseSchema = import_zod71.z.object({ runId: import_zod71.z.string().min(1) }).strict();
9087
+ var CancelEvalRunResponseSchema = import_zod71.z.object({ runId: import_zod71.z.string().min(1), cancelled: import_zod71.z.boolean() }).strict();
9088
+ var EvalRunViewSchema = import_zod71.z.object({
9089
+ runId: import_zod71.z.string(),
8692
9090
  status: EvalRunStatusSchema,
8693
- agent: import_zod69.z.string(),
8694
- revisionId: import_zod69.z.string(),
8695
- stage: import_zod69.z.string(),
9091
+ agent: import_zod71.z.string(),
9092
+ revisionId: import_zod71.z.string(),
9093
+ stage: import_zod71.z.string(),
8696
9094
  suiteRef: EvalSuiteRefSchema,
8697
- strict: import_zod69.z.boolean(),
9095
+ strict: import_zod71.z.boolean(),
8698
9096
  trigger: EvalTriggerSchema,
8699
- startedAt: import_zod69.z.string().optional(),
8700
- completedAt: import_zod69.z.string().optional(),
8701
- cases: import_zod69.z.array(EvalCaseResultSchema),
9097
+ startedAt: import_zod71.z.string().optional(),
9098
+ completedAt: import_zod71.z.string().optional(),
9099
+ cases: import_zod71.z.array(EvalCaseResultSchema),
8702
9100
  summary: EvalRunSummarySchema
8703
9101
  }).strict();
8704
- var EvalRunListItemSchema = import_zod69.z.object({
8705
- runId: import_zod69.z.string(),
9102
+ var EvalRunListItemSchema = import_zod71.z.object({
9103
+ runId: import_zod71.z.string(),
8706
9104
  status: EvalRunStatusSchema,
8707
- agent: import_zod69.z.string(),
8708
- revisionId: import_zod69.z.string(),
8709
- stage: import_zod69.z.string(),
9105
+ agent: import_zod71.z.string(),
9106
+ revisionId: import_zod71.z.string(),
9107
+ stage: import_zod71.z.string(),
8710
9108
  trigger: EvalTriggerSchema,
8711
- startedAt: import_zod69.z.string().optional(),
8712
- completedAt: import_zod69.z.string().optional(),
9109
+ startedAt: import_zod71.z.string().optional(),
9110
+ completedAt: import_zod71.z.string().optional(),
8713
9111
  summary: EvalRunSummarySchema
8714
9112
  }).strict();
8715
- var EvalRunListResponseSchema = import_zod69.z.object({
8716
- items: import_zod69.z.array(EvalRunListItemSchema),
8717
- nextCursor: import_zod69.z.string().optional()
9113
+ var EvalRunListResponseSchema = import_zod71.z.object({
9114
+ items: import_zod71.z.array(EvalRunListItemSchema),
9115
+ nextCursor: import_zod71.z.string().optional()
8718
9116
  }).strict();
8719
9117
  var PIPELINE_COMMIT_SHA_RE = /^[0-9a-f]{7,64}$/i;
8720
- var CommitShaSchema = import_zod70.z.string().regex(PIPELINE_COMMIT_SHA_RE, {
9118
+ var CommitShaSchema = import_zod72.z.string().regex(PIPELINE_COMMIT_SHA_RE, {
8721
9119
  message: "commitSha must be 7-64 hexadecimal characters"
8722
9120
  });
8723
9121
  var PIPELINE_FULL_COMMIT_SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
8724
- var FullCommitShaSchema = import_zod70.z.string().regex(PIPELINE_FULL_COMMIT_SHA_RE, {
9122
+ var FullCommitShaSchema = import_zod72.z.string().regex(PIPELINE_FULL_COMMIT_SHA_RE, {
8725
9123
  message: "commitSha must be a full 40- or 64-character hexadecimal SHA (short prefixes cannot anchor a release)"
8726
9124
  });
8727
9125
  var PIPELINE_TRIGGERED_REF_MAX_LENGTH = 512;
8728
- var TriggeredRefSchema = import_zod70.z.string().min(1).max(PIPELINE_TRIGGERED_REF_MAX_LENGTH);
8729
- var IsoTimestampSchema = import_zod70.z.string().datetime({ offset: true });
9126
+ var TriggeredRefSchema = import_zod72.z.string().min(1).max(PIPELINE_TRIGGERED_REF_MAX_LENGTH);
9127
+ var IsoTimestampSchema = import_zod72.z.string().datetime({ offset: true });
8730
9128
  var NullableIsoTimestampSchema = IsoTimestampSchema.nullable();
8731
- var PipelineTriggerSchema = import_zod70.z.enum(PIPELINE_TRIGGERS);
8732
- var PipelineRunStatusSchema = import_zod70.z.enum(PIPELINE_RUN_STATUSES);
8733
- var PipelineStepSchema = import_zod70.z.enum(PIPELINE_STEPS);
8734
- var PipelineStepStatusSchema = import_zod70.z.enum(PIPELINE_STEP_STATUSES);
8735
- var PipelineErrorCodeSchema = import_zod70.z.string().min(1).nullable();
8736
- var ListPipelineRunsQuerySchema = import_zod70.z.object({
8737
- projectId: import_zod70.z.string().uuid(),
8738
- limit: import_zod70.z.coerce.number().int().min(1).max(200).default(50)
8739
- }).strict();
8740
- var NullableTriggeredRefSchema = import_zod70.z.string().nullable().optional();
8741
- var PipelineRunListItemSchema = import_zod70.z.object({
8742
- id: import_zod70.z.string().uuid(),
8743
- commitSha: import_zod70.z.string(),
8744
- commitMessage: import_zod70.z.string().nullable(),
9129
+ var PipelineTriggerSchema = import_zod72.z.enum(PIPELINE_TRIGGERS);
9130
+ var PipelineRunStatusSchema = import_zod72.z.enum(PIPELINE_RUN_STATUSES);
9131
+ var PipelineStepSchema = import_zod72.z.enum(PIPELINE_STEPS);
9132
+ var PipelineStepStatusSchema = import_zod72.z.enum(PIPELINE_STEP_STATUSES);
9133
+ var PipelineErrorCodeSchema = import_zod72.z.string().min(1).nullable();
9134
+ var ListPipelineRunsQuerySchema = import_zod72.z.object({
9135
+ projectId: import_zod72.z.string().uuid(),
9136
+ limit: import_zod72.z.coerce.number().int().min(1).max(200).default(50)
9137
+ }).strict();
9138
+ var NullableTriggeredRefSchema = import_zod72.z.string().nullable().optional();
9139
+ var PipelineRunListItemSchema = import_zod72.z.object({
9140
+ id: import_zod72.z.string().uuid(),
9141
+ commitSha: import_zod72.z.string(),
9142
+ commitMessage: import_zod72.z.string().nullable(),
8745
9143
  trigger: PipelineTriggerSchema,
8746
9144
  status: PipelineRunStatusSchema,
8747
- stagesKey: import_zod70.z.string(),
8748
- attempt: import_zod70.z.number().int().nonnegative(),
8749
- agentSlugs: import_zod70.z.array(import_zod70.z.string()),
8750
- createdBy: import_zod70.z.string().nullable(),
9145
+ stagesKey: import_zod72.z.string(),
9146
+ attempt: import_zod72.z.number().int().nonnegative(),
9147
+ agentSlugs: import_zod72.z.array(import_zod72.z.string()),
9148
+ createdBy: import_zod72.z.string().nullable(),
8751
9149
  createdAt: IsoTimestampSchema,
8752
9150
  startedAt: NullableIsoTimestampSchema,
8753
9151
  completedAt: NullableIsoTimestampSchema,
8754
9152
  errorCode: PipelineErrorCodeSchema,
8755
9153
  triggeredRef: NullableTriggeredRefSchema
8756
9154
  }).strict();
8757
- var ListPipelineRunsResponseSchema = import_zod70.z.object({
8758
- enabled: import_zod70.z.boolean(),
8759
- items: import_zod70.z.array(PipelineRunListItemSchema)
9155
+ var ListPipelineRunsResponseSchema = import_zod72.z.object({
9156
+ enabled: import_zod72.z.boolean(),
9157
+ items: import_zod72.z.array(PipelineRunListItemSchema)
8760
9158
  }).strict();
8761
- var CreatePipelineRunRequestSchema = import_zod70.z.object({
8762
- projectId: import_zod70.z.string().uuid(),
9159
+ var CreatePipelineRunRequestSchema = import_zod72.z.object({
9160
+ projectId: import_zod72.z.string().uuid(),
8763
9161
  commitSha: FullCommitShaSchema,
8764
9162
  /**
8765
9163
  * Explicit re-run: mint `attempt+1` even when the latest run for this
@@ -8768,7 +9166,7 @@ var CreatePipelineRunRequestSchema = import_zod70.z.object({
8768
9166
  * against servers that predate it (`.strict()` on their side). Non-passed
8769
9167
  * terminal runs re-run automatically without this flag (§4).
8770
9168
  */
8771
- rerun: import_zod70.z.boolean().optional(),
9169
+ rerun: import_zod72.z.boolean().optional(),
8772
9170
  /**
8773
9171
  * The ref the caller resolved `commitSha` from, recorded for display only
8774
9172
  * (see `TriggeredRefSchema`). Optional: a caller that has just a SHA and no
@@ -8781,54 +9179,54 @@ var CreatePipelineRunRequestSchema = import_zod70.z.object({
8781
9179
  */
8782
9180
  triggeredRef: TriggeredRefSchema.optional()
8783
9181
  }).strict();
8784
- var CreatePipelineRunResponseSchema = import_zod70.z.object({
8785
- runId: import_zod70.z.string().uuid(),
8786
- deduplicated: import_zod70.z.boolean(),
8787
- attempt: import_zod70.z.number().int().nonnegative().optional(),
9182
+ var CreatePipelineRunResponseSchema = import_zod72.z.object({
9183
+ runId: import_zod72.z.string().uuid(),
9184
+ deduplicated: import_zod72.z.boolean(),
9185
+ attempt: import_zod72.z.number().int().nonnegative().optional(),
8788
9186
  status: PipelineRunStatusSchema.optional()
8789
9187
  });
8790
- var PipelineRunDetailRunSchema = import_zod70.z.object({
8791
- id: import_zod70.z.string().uuid(),
8792
- projectId: import_zod70.z.string().uuid(),
8793
- repoUrl: import_zod70.z.string(),
8794
- commitSha: import_zod70.z.string(),
8795
- commitMessage: import_zod70.z.string().nullable(),
9188
+ var PipelineRunDetailRunSchema = import_zod72.z.object({
9189
+ id: import_zod72.z.string().uuid(),
9190
+ projectId: import_zod72.z.string().uuid(),
9191
+ repoUrl: import_zod72.z.string(),
9192
+ commitSha: import_zod72.z.string(),
9193
+ commitMessage: import_zod72.z.string().nullable(),
8796
9194
  trigger: PipelineTriggerSchema,
8797
9195
  status: PipelineRunStatusSchema,
8798
- stagesRequested: import_zod70.z.array(PipelineStepSchema).nullable(),
8799
- stagesKey: import_zod70.z.string(),
8800
- attempt: import_zod70.z.number().int().nonnegative(),
8801
- planJson: import_zod70.z.unknown().nullable(),
9196
+ stagesRequested: import_zod72.z.array(PipelineStepSchema).nullable(),
9197
+ stagesKey: import_zod72.z.string(),
9198
+ attempt: import_zod72.z.number().int().nonnegative(),
9199
+ planJson: import_zod72.z.unknown().nullable(),
8802
9200
  errorCode: PipelineErrorCodeSchema,
8803
- errorMessage: import_zod70.z.string().nullable(),
8804
- createdBy: import_zod70.z.string().nullable(),
9201
+ errorMessage: import_zod72.z.string().nullable(),
9202
+ createdBy: import_zod72.z.string().nullable(),
8805
9203
  createdAt: IsoTimestampSchema,
8806
9204
  startedAt: NullableIsoTimestampSchema,
8807
9205
  completedAt: NullableIsoTimestampSchema,
8808
9206
  triggeredRef: NullableTriggeredRefSchema
8809
9207
  }).strict();
8810
- var PipelineRunStepSchema = import_zod70.z.object({
9208
+ var PipelineRunStepSchema = import_zod72.z.object({
8811
9209
  step: PipelineStepSchema,
8812
9210
  status: PipelineStepStatusSchema,
8813
- attempt: import_zod70.z.number().int().nonnegative(),
8814
- resultJson: import_zod70.z.unknown().nullable(),
9211
+ attempt: import_zod72.z.number().int().nonnegative(),
9212
+ resultJson: import_zod72.z.unknown().nullable(),
8815
9213
  errorCode: PipelineErrorCodeSchema,
8816
- errorMessage: import_zod70.z.string().nullable(),
9214
+ errorMessage: import_zod72.z.string().nullable(),
8817
9215
  startedAt: NullableIsoTimestampSchema,
8818
9216
  completedAt: NullableIsoTimestampSchema
8819
9217
  }).strict();
8820
- var PipelineRunWorkloadSchema = import_zod70.z.object({
8821
- agentSlug: import_zod70.z.string(),
8822
- affectedReason: import_zod70.z.string().nullable(),
8823
- workloadId: import_zod70.z.string().nullable(),
8824
- revisionId: import_zod70.z.string().nullable(),
8825
- repointStatus: import_zod70.z.string().nullable(),
8826
- freezeStatus: import_zod70.z.string().nullable(),
8827
- frozenPackageOssUrl: import_zod70.z.string().nullable(),
8828
- frozenPackageSha256: import_zod70.z.string().nullable(),
8829
- frozenPackageWarnings: import_zod70.z.array(import_zod70.z.string()).nullable(),
8830
- evalRunId: import_zod70.z.string().nullable(),
8831
- evalVerdict: import_zod70.z.string().nullable(),
9218
+ var PipelineRunWorkloadSchema = import_zod72.z.object({
9219
+ agentSlug: import_zod72.z.string(),
9220
+ affectedReason: import_zod72.z.string().nullable(),
9221
+ workloadId: import_zod72.z.string().nullable(),
9222
+ revisionId: import_zod72.z.string().nullable(),
9223
+ repointStatus: import_zod72.z.string().nullable(),
9224
+ freezeStatus: import_zod72.z.string().nullable(),
9225
+ frozenPackageOssUrl: import_zod72.z.string().nullable(),
9226
+ frozenPackageSha256: import_zod72.z.string().nullable(),
9227
+ frozenPackageWarnings: import_zod72.z.array(import_zod72.z.string()).nullable(),
9228
+ evalRunId: import_zod72.z.string().nullable(),
9229
+ evalVerdict: import_zod72.z.string().nullable(),
8832
9230
  /**
8833
9231
  * joined | skipped_no_base_revision | skipped_no_image_change | failed.
8834
9232
  *
@@ -8837,7 +9235,7 @@ var PipelineRunWorkloadSchema = import_zod70.z.object({
8837
9235
  * so a client parsing a response from a control-plane that predates these
8838
9236
  * fields must not throw. Absent and null both read as "not reported".
8839
9237
  */
8840
- joinStatus: import_zod70.z.string().nullable().optional(),
9238
+ joinStatus: import_zod72.z.string().nullable().optional(),
8841
9239
  /**
8842
9240
  * Per-workload failure, so a client can say WHICH agent failed and why —
8843
9241
  * the run/step level only ever counts failures. Deliberately NOT
@@ -8849,16 +9247,16 @@ var PipelineRunWorkloadSchema = import_zod70.z.object({
8849
9247
  * `.max()`-ed here — a schema cap would upgrade "the error text is long"
8850
9248
  * into "the whole response fails to parse".
8851
9249
  */
8852
- errorCode: import_zod70.z.string().nullable().optional(),
8853
- errorMessage: import_zod70.z.string().nullable().optional()
9250
+ errorCode: import_zod72.z.string().nullable().optional(),
9251
+ errorMessage: import_zod72.z.string().nullable().optional()
8854
9252
  }).strict();
8855
- var PipelineRunDetailResponseSchema = import_zod70.z.object({
9253
+ var PipelineRunDetailResponseSchema = import_zod72.z.object({
8856
9254
  run: PipelineRunDetailRunSchema,
8857
- steps: import_zod70.z.array(PipelineRunStepSchema),
8858
- workloads: import_zod70.z.array(PipelineRunWorkloadSchema)
9255
+ steps: import_zod72.z.array(PipelineRunStepSchema),
9256
+ workloads: import_zod72.z.array(PipelineRunWorkloadSchema)
8859
9257
  }).strict();
8860
- var GetPipelinePlanQuerySchema = import_zod70.z.object({
8861
- projectId: import_zod70.z.string().uuid(),
9258
+ var GetPipelinePlanQuerySchema = import_zod72.z.object({
9259
+ projectId: import_zod72.z.string().uuid(),
8862
9260
  commitSha: CommitShaSchema,
8863
9261
  fromSha: CommitShaSchema.optional(),
8864
9262
  /**
@@ -8866,20 +9264,20 @@ var GetPipelinePlanQuerySchema = import_zod70.z.object({
8866
9264
  * Accepted as the STRING "false" because it arrives as a query param; any
8867
9265
  * other value (including absent) means "compute if missing".
8868
9266
  */
8869
- enqueue: import_zod70.z.enum(["true", "false"]).optional().transform((value) => value !== "false")
9267
+ enqueue: import_zod72.z.enum(["true", "false"]).optional().transform((value) => value !== "false")
8870
9268
  }).strict();
8871
- var PipelinePlanResponseSchema = import_zod70.z.discriminatedUnion("source", [
8872
- import_zod70.z.object({ source: import_zod70.z.literal("cache"), plan: import_zod70.z.unknown() }).strict(),
8873
- import_zod70.z.object({
8874
- source: import_zod70.z.literal("computing"),
8875
- enqueued: import_zod70.z.boolean(),
9269
+ var PipelinePlanResponseSchema = import_zod72.z.discriminatedUnion("source", [
9270
+ import_zod72.z.object({ source: import_zod72.z.literal("cache"), plan: import_zod72.z.unknown() }).strict(),
9271
+ import_zod72.z.object({
9272
+ source: import_zod72.z.literal("computing"),
9273
+ enqueued: import_zod72.z.boolean(),
8876
9274
  // 上一次计算的失败摘要(若有)。默认 enqueue=true 会不断重算,plan 一直
8877
9275
  // "computing" 时失败原本被吞——带上它让轮询者看到「在重试,但上次失败:…」
8878
9276
  // 而不是无限"计算中"(#1346 D4)。
8879
9277
  // 长度上游已有界(plan-cache fail() 落库前截断 2000),这里刻意不设
8880
9278
  // .max():schema 硬上限会把"错误信息超长"升级成"整个响应 parse 失败",
8881
9279
  // 让错误路径反过来炸掉主功能。
8882
- lastError: import_zod70.z.string().nullable().optional()
9280
+ lastError: import_zod72.z.string().nullable().optional()
8883
9281
  }).strict()
8884
9282
  ]);
8885
9283
  var PIPELINE_API_ERROR_CODES = [
@@ -8890,23 +9288,23 @@ var PIPELINE_API_ERROR_CODES = [
8890
9288
  "PIPELINE_RUN_NOT_FOUND",
8891
9289
  "PLAN_NOT_CACHED"
8892
9290
  ];
8893
- var PipelineApiErrorCodeSchema = import_zod70.z.enum(PIPELINE_API_ERROR_CODES);
9291
+ var PipelineApiErrorCodeSchema = import_zod72.z.enum(PIPELINE_API_ERROR_CODES);
8894
9292
  var SKILL_NAME_MAX_LENGTH = 200;
8895
9293
  var SKILL_SOURCE_REF_MAX_LENGTH = 512;
8896
9294
  var SKILL_NAME_WHITELIST = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8897
- var SkillNameSchema = import_zod71.z.string().min(1).max(SKILL_NAME_MAX_LENGTH).refine((value) => SKILL_NAME_WHITELIST.test(value), {
9295
+ var SkillNameSchema = import_zod73.z.string().min(1).max(SKILL_NAME_MAX_LENGTH).refine((value) => SKILL_NAME_WHITELIST.test(value), {
8898
9296
  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
9297
  }).refine((value) => value !== "." && value !== "..", {
8900
9298
  message: "skill name must not be '.' or '..'"
8901
9299
  });
8902
- var SkillSourceRefSchema = import_zod71.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH);
8903
- var SkillManifestSourceTypeSchema = import_zod71.z.enum(["rush", "github", "gitlab"]);
8904
- var SkillsManifestDefaultsSchema = import_zod71.z.object({
8905
- installDir: import_zod71.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH).optional(),
8906
- targetAgents: import_zod71.z.array(import_zod71.z.string().min(1)).optional(),
8907
- installMode: import_zod71.z.string().min(1).optional()
9300
+ var SkillSourceRefSchema = import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH);
9301
+ var SkillManifestSourceTypeSchema = import_zod73.z.enum(["rush", "github", "gitlab"]);
9302
+ var SkillsManifestDefaultsSchema = import_zod73.z.object({
9303
+ installDir: import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH).optional(),
9304
+ targetAgents: import_zod73.z.array(import_zod73.z.string().min(1)).optional(),
9305
+ installMode: import_zod73.z.string().min(1).optional()
8908
9306
  }).passthrough();
8909
- var SkillsManifestSchema = import_zod71.z.object({
9307
+ var SkillsManifestSchema = import_zod73.z.object({
8910
9308
  /**
8911
9309
  * **必填,刻意不做 `.optional().default({})`**(评审提过,权衡后维持):
8912
9310
  * 本 schema 是 passthrough 的,若 `skills` 可省略,一个拼错的顶层 key
@@ -8915,27 +9313,27 @@ var SkillsManifestSchema = import_zod71.z.object({
8915
9313
  * 看到一条报错、补上 `"skills": {}`:响的、可恢复的。空清单请显式写
8916
9314
  * `{"skills": {}}`(脚手架生成的就是这个形态)。
8917
9315
  */
8918
- skills: import_zod71.z.record(SkillNameSchema, SkillSourceRefSchema),
8919
- registries: import_zod71.z.record(import_zod71.z.string().min(1), import_zod71.z.string().min(1)).optional(),
9316
+ skills: import_zod73.z.record(SkillNameSchema, SkillSourceRefSchema),
9317
+ registries: import_zod73.z.record(import_zod73.z.string().min(1), import_zod73.z.string().min(1)).optional(),
8920
9318
  defaults: SkillsManifestDefaultsSchema.optional()
8921
9319
  }).passthrough();
8922
- var SkillsLockEntrySchema = import_zod71.z.object({
8923
- source: import_zod71.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH),
9320
+ var SkillsLockEntrySchema = import_zod73.z.object({
9321
+ source: import_zod73.z.string().min(1).max(SKILL_SOURCE_REF_MAX_LENGTH),
8924
9322
  /** 注册表源的精确版本;git 源这里是可读注记(实测常为 `main`)。 */
8925
- version: import_zod71.z.string().optional(),
9323
+ version: import_zod73.z.string().optional(),
8926
9324
  /** 浮动 ref 的人类可读注记——**绝不参与安装**(D23)。 */
8927
- ref: import_zod71.z.string().optional(),
8928
- resolved: import_zod71.z.string().optional(),
9325
+ ref: import_zod73.z.string().optional(),
9326
+ resolved: import_zod73.z.string().optional(),
8929
9327
  /** git 源的钉死点。实测可能为 `""`(缺 commit),由校验层硬拒。 */
8930
- commit: import_zod71.z.string().optional(),
8931
- integrity: import_zod71.z.string().optional(),
8932
- installedAt: import_zod71.z.string().optional()
9328
+ commit: import_zod73.z.string().optional(),
9329
+ integrity: import_zod73.z.string().optional(),
9330
+ installedAt: import_zod73.z.string().optional()
8933
9331
  }).passthrough();
8934
- var SkillsLockSchema = import_zod71.z.object({
8935
- lockfileVersion: import_zod71.z.number().int().nonnegative().optional(),
8936
- skills: import_zod71.z.record(SkillNameSchema, SkillsLockEntrySchema)
9332
+ var SkillsLockSchema = import_zod73.z.object({
9333
+ lockfileVersion: import_zod73.z.number().int().nonnegative().optional(),
9334
+ skills: import_zod73.z.record(SkillNameSchema, SkillsLockEntrySchema)
8937
9335
  }).passthrough();
8938
- var SkillsManifestErrorCodeSchema = import_zod71.z.enum([
9336
+ var SkillsManifestErrorCodeSchema = import_zod73.z.enum([
8939
9337
  /** `skills.json` 语法/结构非法。 */
8940
9338
  "SKILLS_MANIFEST_INVALID",
8941
9339
  /** `skills.lock` 语法/结构非法。 */
@@ -9071,7 +9469,7 @@ var BindingsResource = class {
9071
9469
  };
9072
9470
 
9073
9471
  // src/resources/environments.ts
9074
- var import_zod72 = require("zod");
9472
+ var import_zod74 = require("zod");
9075
9473
 
9076
9474
  // src/agent-vocab.ts
9077
9475
  function resolveExclusiveAlias(canonicalKey, canonicalValue, aliasKey, aliasValue) {
@@ -9095,24 +9493,24 @@ function attachAgentAliases(data) {
9095
9493
  }
9096
9494
 
9097
9495
  // src/resources/environments.ts
9098
- var EnvironmentVersionHistorySchema = import_zod72.z.object({
9099
- versions: import_zod72.z.array(EnvironmentVersionSchema),
9100
- repoints: import_zod72.z.array(EnvironmentRepointRecordSchema)
9496
+ var EnvironmentVersionHistorySchema = import_zod74.z.object({
9497
+ versions: import_zod74.z.array(EnvironmentVersionSchema),
9498
+ repoints: import_zod74.z.array(EnvironmentRepointRecordSchema)
9101
9499
  }).strict();
9102
- var RepointedSlotResultSchema = import_zod72.z.object({
9103
- workloadId: import_zod72.z.string().uuid(),
9500
+ var RepointedSlotResultSchema = import_zod74.z.object({
9501
+ workloadId: import_zod74.z.string().uuid(),
9104
9502
  stage: StageSchema,
9105
- fromVersion: import_zod72.z.number().int().positive().nullable()
9503
+ fromVersion: import_zod74.z.number().int().positive().nullable()
9106
9504
  }).strict();
9107
- var RepointEnvironmentResultSchema = import_zod72.z.object({
9108
- toVersion: import_zod72.z.number().int().positive(),
9109
- repointedSlotCount: import_zod72.z.number().int().nonnegative(),
9110
- repointedSlots: import_zod72.z.array(RepointedSlotResultSchema)
9505
+ var RepointEnvironmentResultSchema = import_zod74.z.object({
9506
+ toVersion: import_zod74.z.number().int().positive(),
9507
+ repointedSlotCount: import_zod74.z.number().int().nonnegative(),
9508
+ repointedSlots: import_zod74.z.array(RepointedSlotResultSchema)
9111
9509
  }).strict();
9112
- var UpdateEnvironmentResultSchema = import_zod72.z.object({
9510
+ var UpdateEnvironmentResultSchema = import_zod74.z.object({
9113
9511
  environment: EnvironmentSchema,
9114
- createdVersion: import_zod72.z.number().int().positive().nullable(),
9115
- repointedSlotCount: import_zod72.z.number().int().nonnegative()
9512
+ createdVersion: import_zod74.z.number().int().positive().nullable(),
9513
+ repointedSlotCount: import_zod74.z.number().int().nonnegative()
9116
9514
  }).strict();
9117
9515
  function attachAgentAliasesToEach(items) {
9118
9516
  return items.map((item) => attachAgentAliases(item));
@@ -9433,14 +9831,14 @@ var McpDevTicketsResource = class {
9433
9831
  };
9434
9832
 
9435
9833
  // src/resources/memories.ts
9436
- var import_zod73 = require("zod");
9834
+ var import_zod75 = require("zod");
9437
9835
  var ListedMemorySchema = AgentMemorySchema.extend({
9438
- createdAt: import_zod73.z.string(),
9439
- updatedAt: import_zod73.z.string()
9836
+ createdAt: import_zod75.z.string(),
9837
+ updatedAt: import_zod75.z.string()
9440
9838
  });
9441
- var ListMemoriesResponseSchema = import_zod73.z.object({
9442
- items: import_zod73.z.array(ListedMemorySchema),
9443
- nextCursor: import_zod73.z.string().nullish()
9839
+ var ListMemoriesResponseSchema = import_zod75.z.object({
9840
+ items: import_zod75.z.array(ListedMemorySchema),
9841
+ nextCursor: import_zod75.z.string().nullish()
9444
9842
  });
9445
9843
  function parseEnvelopeData2(envelope, routeLabel, schema) {
9446
9844
  if (envelope?.data === void 0) {
@@ -9911,7 +10309,7 @@ var ProjectsResource = class {
9911
10309
  };
9912
10310
 
9913
10311
  // src/resources/sessions.ts
9914
- var import_zod74 = require("zod");
10312
+ var import_zod76 = require("zod");
9915
10313
  function normalizeSessionRequest(request) {
9916
10314
  const { agentId, versionId, ...rest } = request;
9917
10315
  const workloadId = resolveExclusiveAlias("workloadId", rest.workloadId, "agentId", agentId);
@@ -9936,33 +10334,181 @@ function normalizeSessionRequest(request) {
9936
10334
  ...revisionId !== void 0 ? { revisionId } : {}
9937
10335
  };
9938
10336
  }
9939
- var ListSessionEventsEnvelopeSchema = import_zod74.z.object({
9940
- data: import_zod74.z.object({ events: import_zod74.z.array(SessionEventSchema) })
9941
- });
9942
- var DeliveryResultEnvelopeSchema = import_zod74.z.object({
9943
- data: import_zod74.z.object({ delivery: SessionDeliveryEnvelopeSchema.nullable() })
9944
- });
9945
- var SessionArtifactsListEnvelopeSchema = import_zod74.z.object({
9946
- data: import_zod74.z.object({
9947
- items: import_zod74.z.array(
9948
- import_zod74.z.object({
9949
- id: import_zod74.z.string(),
9950
- artifactId: import_zod74.z.string().optional(),
9951
- filename: import_zod74.z.string(),
9952
- path: import_zod74.z.string(),
9953
- contentType: import_zod74.z.string(),
9954
- size: import_zod74.z.number(),
9955
- turnId: import_zod74.z.string().optional(),
9956
- messageId: import_zod74.z.string().optional()
10337
+ var ListSessionEventsEnvelopeSchema = import_zod76.z.object({
10338
+ data: import_zod76.z.object({
10339
+ events: import_zod76.z.array(SessionEventSchema),
10340
+ // Optional so a pre-P1 server's `{ events }` body still parses.
10341
+ hasMore: import_zod76.z.boolean().optional(),
10342
+ cursorReset: import_zod76.z.boolean().optional()
10343
+ })
10344
+ });
10345
+ var TurnListEnvelopeSchema = import_zod76.z.object({ data: TurnListResponseDataSchema });
10346
+ var TurnEnvelopeSchema = import_zod76.z.object({ data: TurnSchema });
10347
+ var DispatchOutcomeEnvelopeSchema = import_zod76.z.object({
10348
+ data: import_zod76.z.object({ outcome: DispatchOutcomeSchema })
10349
+ });
10350
+ var SendTurnTurnRefEnvelopeSchema = import_zod76.z.object({
10351
+ data: import_zod76.z.object({
10352
+ turn: import_zod76.z.object({ turnId: import_zod76.z.string(), status: TurnStatusSchema }).optional()
10353
+ })
10354
+ });
10355
+ var SessionRuntimeBindingEnvelopeSchema = import_zod76.z.object({
10356
+ runtimeBinding: import_zod76.z.object({ id: import_zod76.z.string().min(1) }).nullish()
10357
+ });
10358
+ var DeliveryResultEnvelopeSchema = import_zod76.z.object({
10359
+ data: import_zod76.z.object({ delivery: SessionDeliveryEnvelopeSchema.nullable() })
10360
+ });
10361
+ var SessionArtifactsListEnvelopeSchema = import_zod76.z.object({
10362
+ data: import_zod76.z.object({
10363
+ items: import_zod76.z.array(
10364
+ import_zod76.z.object({
10365
+ id: import_zod76.z.string(),
10366
+ artifactId: import_zod76.z.string().optional(),
10367
+ filename: import_zod76.z.string(),
10368
+ path: import_zod76.z.string(),
10369
+ contentType: import_zod76.z.string(),
10370
+ size: import_zod76.z.number(),
10371
+ turnId: import_zod76.z.string().optional(),
10372
+ messageId: import_zod76.z.string().optional()
9957
10373
  })
9958
10374
  ),
9959
- partial: import_zod74.z.boolean().optional(),
9960
- skippedBundles: import_zod74.z.array(import_zod74.z.object({ artifactId: import_zod74.z.string(), reason: import_zod74.z.string() })).optional()
10375
+ partial: import_zod76.z.boolean().optional(),
10376
+ skippedBundles: import_zod76.z.array(import_zod76.z.object({ artifactId: import_zod76.z.string(), reason: import_zod76.z.string() })).optional()
9961
10377
  })
9962
10378
  });
10379
+ var SessionTurnsResource = class {
10380
+ constructor(client, sessions) {
10381
+ this.client = client;
10382
+ this.sessions = sessions;
10383
+ }
10384
+ /**
10385
+ * `GET /api/sessions/:id/turns` — one keyset page of turns, newest first by
10386
+ * default. Requires scope `runs:stream`.
10387
+ *
10388
+ * Page forward with `after: nextCursor` / back with `before: prevCursor`;
10389
+ * there is no `page`/`offset`.
10390
+ *
10391
+ * "Forward" is relative to the ORDER YOU ASKED FOR, not to time: under the
10392
+ * default `order: "desc"` it means toward OLDER turns. `hasMore` describes
10393
+ * that same forward direction, so the loop that walks a whole history is
10394
+ * `after: nextCursor` until `hasMore` is false. Pairing `hasMore` with
10395
+ * `before`/`prevCursor` reads a flag about the direction you are NOT
10396
+ * walking and will not terminate correctly — `before` is for picking up
10397
+ * turns that arrived on the other side of your page, not for draining.
10398
+ *
10399
+ * `streamCursor` is the session's highest `__seq` and can be handed
10400
+ * straight to {@link SessionsResource.streamEvents} as `lastEventId` to
10401
+ * resume live streaming without replaying what this page already covers.
10402
+ */
10403
+ async list(sessionId, options = {}) {
10404
+ const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns`;
10405
+ const envelope = await this.client.request(path, {
10406
+ method: "GET",
10407
+ query: {
10408
+ limit: options.limit,
10409
+ order: options.order,
10410
+ before: options.before,
10411
+ after: options.after,
10412
+ status: options.status && options.status.length > 0 ? options.status.join(",") : void 0,
10413
+ revivalAttemptId: options.revivalAttemptId
10414
+ },
10415
+ signal: options.signal,
10416
+ cache: "no-store"
10417
+ });
10418
+ const parsed = TurnListEnvelopeSchema.safeParse(envelope);
10419
+ if (!parsed.success) {
10420
+ throw new PilotPlatformApiError({
10421
+ status: 0,
10422
+ code: "MALFORMED_PLATFORM_RESPONSE",
10423
+ message: `GET ${path} did not return a {data: {turns: [...]}} envelope.`,
10424
+ cause: parsed.error
10425
+ });
10426
+ }
10427
+ return parsed.data.data;
10428
+ }
10429
+ /**
10430
+ * `GET /api/sessions/:id/turns/:turnId` — one turn. Requires scope
10431
+ * `runs:stream`.
10432
+ *
10433
+ * Throws `PilotPlatformNotFoundError` with `code` `TURN_NOT_FOUND` (404)
10434
+ * for an id this session has no turn for. A prompt that is waiting on
10435
+ * Agent Recovery has NOT become a turn yet and reads as that same 404 —
10436
+ * check `sessions.get(id)`'s `pendingRevival` before treating it as a bad
10437
+ * id.
10438
+ */
10439
+ async get(sessionId, turnId, options = {}) {
10440
+ const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns/${encodeURIComponent(turnId)}`;
10441
+ const envelope = await this.client.request(path, {
10442
+ method: "GET",
10443
+ signal: options.signal,
10444
+ cache: "no-store"
10445
+ });
10446
+ const parsed = TurnEnvelopeSchema.safeParse(envelope);
10447
+ if (!parsed.success) {
10448
+ throw new PilotPlatformApiError({
10449
+ status: 0,
10450
+ code: "MALFORMED_PLATFORM_RESPONSE",
10451
+ message: `GET ${path} did not return a {data: <Turn>} envelope.`,
10452
+ cause: parsed.error
10453
+ });
10454
+ }
10455
+ return parsed.data.data;
10456
+ }
10457
+ /**
10458
+ * `POST /api/sessions/:id/abort` — ask the worker to stop `turnId`.
10459
+ * Requires scope **`runs:abort`** (not `runs:stream`, unlike every other
10460
+ * method here).
10461
+ *
10462
+ * Requires a control-plane that declares `tokenAudience: "agenthub"` on the
10463
+ * abort dispatch binding. Against an older one, an AgentHub token
10464
+ * (`aud=agenthub` — the only kind this SDK sends) is rejected with 403
10465
+ * `TOKEN_AUDIENCE_MISMATCH` before the scope check.
10466
+ *
10467
+ * Idempotent: the request key is derived from the session and turn, so
10468
+ * re-issuing it — including from the portal's Stop button — collapses onto
10469
+ * the one abort rather than stacking.
10470
+ *
10471
+ * The returned `DispatchOutcome` is the dispatch result, NOT proof the turn
10472
+ * stopped: a `rejected` / `transport_failed` outcome comes back as a VALUE
10473
+ * with 200 (branch on `outcome.kind`, and on `priorOutcome` for
10474
+ * `idempotent_replay`), and even an `accepted` abort only means the worker
10475
+ * received the signal. Whether it landed is read off the turn:
10476
+ * `(await turns.get(sessionId, turnId)).status === "aborted"`.
10477
+ */
10478
+ async abort(sessionId, turnId, options = {}) {
10479
+ const runtimeBindingId = options.runtimeBindingId ?? await resolveRuntimeBindingId(this.sessions, sessionId, options.signal);
10480
+ const path = `/api/sessions/${encodeURIComponent(sessionId)}/abort`;
10481
+ const envelope = await this.client.request(path, {
10482
+ method: "POST",
10483
+ body: {
10484
+ // Byte-identical to the portal Stop button's key
10485
+ // (`use-session-revival.ts`), so a user click and an SDK abort for the
10486
+ // same turn dedupe against each other instead of racing.
10487
+ idempotencyKey: `abort:session:${sessionId}:turn:${turnId}`,
10488
+ session: { sessionId, runtimeBindingId },
10489
+ protocolVersion: "v1",
10490
+ turnId,
10491
+ reason: options.reason ?? { kind: "user" },
10492
+ trace: { traceId: newTraceId(), spanId: newTraceId() }
10493
+ },
10494
+ signal: options.signal
10495
+ });
10496
+ const parsed = DispatchOutcomeEnvelopeSchema.safeParse(envelope);
10497
+ if (!parsed.success) {
10498
+ throw new PilotPlatformApiError({
10499
+ status: 0,
10500
+ code: "MALFORMED_PLATFORM_RESPONSE",
10501
+ message: `POST ${path} did not return a {data: {outcome: ...}} envelope.`,
10502
+ cause: parsed.error
10503
+ });
10504
+ }
10505
+ return parsed.data.data.outcome;
10506
+ }
10507
+ };
9963
10508
  var SessionsResource = class {
9964
10509
  constructor(client) {
9965
10510
  this.client = client;
10511
+ this.turns = new SessionTurnsResource(client, this);
9966
10512
  }
9967
10513
  async create(request, options = {}) {
9968
10514
  const body = CreatePlatformSessionRequestSchema.parse(normalizeSessionRequest(request));
@@ -10080,7 +10626,10 @@ var SessionsResource = class {
10080
10626
  *
10081
10627
  * Requires scope `runs:create`. The session must be `ready`
10082
10628
  * (`sessions.wait`) and have no turn in flight — a prior running turn
10083
- * throws `SESSION_TURN_IN_PROGRESS` (409), it is never queued.
10629
+ * throws `SESSION_TURN_IN_PROGRESS` (409), it is never queued. A turn sent
10630
+ * while an Agent Recovery started by someone else is running throws
10631
+ * `SESSION_REVIVING` (409): nothing was dispatched, so re-send it once
10632
+ * `lifecyclePhase` is back to `"active"` (see {@link SendTurnResult}).
10084
10633
  */
10085
10634
  async sendTurn(sessionId, input, options = {}) {
10086
10635
  const path = `/api/sessions/${encodeURIComponent(sessionId)}/turns`;
@@ -10106,16 +10655,15 @@ var SessionsResource = class {
10106
10655
  return {
10107
10656
  kind: "revival_in_progress",
10108
10657
  attemptId: revival.attemptId,
10109
- ...revival.turnId !== void 0 && { turnId: revival.turnId },
10110
- ...revival.alreadyReviving !== void 0 && {
10111
- alreadyReviving: revival.alreadyReviving
10112
- }
10658
+ ...revival.turnId !== void 0 && { turnId: revival.turnId }
10113
10659
  };
10114
10660
  }
10115
10661
  const dispatched = SessionTurnDispatchedResponseSchema.parse(json);
10116
10662
  const outcome = dispatched.data.outcome;
10117
10663
  if (outcome.kind === "accepted" || outcome.kind === "idempotent_replay") {
10118
- return { kind: outcome.kind, turnId: outcome.turnId, outcome };
10664
+ const turnRef = SendTurnTurnRefEnvelopeSchema.safeParse(json);
10665
+ const turn = turnRef.success ? turnRef.data.data.turn : void 0;
10666
+ return { kind: outcome.kind, turnId: outcome.turnId, outcome, ...turn && { turn } };
10119
10667
  }
10120
10668
  throw new PilotPlatformApiError({
10121
10669
  status: res.status,
@@ -10136,7 +10684,9 @@ var SessionsResource = class {
10136
10684
  method: "GET",
10137
10685
  query: {
10138
10686
  afterEventId: options.afterEventId,
10139
- limit: options.limit
10687
+ limit: options.limit,
10688
+ turnId: options.turnId,
10689
+ types: options.types && options.types.length > 0 ? options.types.join(",") : void 0
10140
10690
  },
10141
10691
  signal: options.signal,
10142
10692
  cache: "no-store"
@@ -10150,7 +10700,8 @@ var SessionsResource = class {
10150
10700
  cause: parsed.error
10151
10701
  });
10152
10702
  }
10153
- return parsed.data.data.events;
10703
+ const { events, hasMore, cursorReset } = parsed.data.data;
10704
+ return attachPageFields(events, { hasMore, cursorReset });
10154
10705
  }
10155
10706
  /**
10156
10707
  * `GET /api/sessions/:id/delivery-result` — the session-plane delivery
@@ -10192,14 +10743,14 @@ var SessionsResource = class {
10192
10743
  * **`waitForTurn` resolving does NOT mean the snapshot is ready.** The worker
10193
10744
  * emits the turn's terminal event and only then bundles, uploads and reports.
10194
10745
  * Exporting the instant a turn completes therefore returns either a 404 or —
10195
- * worse, because it is silent — the PREVIOUS turn's snapshot. Poll for
10196
- * freshness instead of calling once:
10746
+ * worse, because it is silent — the PREVIOUS turn's snapshot. Poll until the
10747
+ * export names your turn instead of calling once:
10197
10748
  *
10198
10749
  * ```ts
10199
10750
  * const { terminalEvent } = await agenthub.sessions.waitForTurn(sessionId, turnId);
10200
- * // `completedAt` exists ONLY on a success terminal, and is the same
10201
- * // in-sandbox clock as capturedAtTurn (capture is strictly ordered after the
10202
- * // terminal append). `payload` is typed `unknown`, hence the cast.
10751
+ * // `completedAt` exists ONLY on a success terminal. Its value is the
10752
+ * // fallback cursor below; its PRESENCE is what tells you the turn succeeded.
10753
+ * // `payload` is typed `unknown`, hence the cast.
10203
10754
  * const completedAtRaw = (terminalEvent.payload as { completedAt?: string })?.completedAt;
10204
10755
  * if (!completedAtRaw) {
10205
10756
  * // Failed / aborted turn: nothing was captured, and polling would just
@@ -10212,11 +10763,24 @@ var SessionsResource = class {
10212
10763
  * while (Date.now() < deadline) {
10213
10764
  * try {
10214
10765
  * const candidate = await agenthub.sessions.exportWorkspace(sessionId);
10215
- * // `>=`, not `>`: both timestamps are `ctx.now()` in the same sandbox
10216
- * // process, one `await` apart, at millisecond resolution — so they can
10217
- * // be EQUAL, and a strict `>` would then never accept this turn's own
10218
- * // snapshot and report "no files" after the full timeout.
10219
- * if (candidate.capturedAtTurn >= completedAt) { exported = candidate; break; }
10766
+ * // The snapshot names its own turn — compare ids, no clock reasoning.
10767
+ * if (candidate.turnId === turnId) { exported = candidate; break; }
10768
+ * // Fallback: `turnId` didn't match — either it's absent (session
10769
+ * // predates the field, or the turn's `session_turns` row hadn't
10770
+ * // materialized yet when the snapshot landed) or it's present but
10771
+ * // WRONG: a sandbox image older than this field makes the platform
10772
+ * // infer "most recent completed turn", which can land on a turn you
10773
+ * // didn't dispatch. Either way `turnId` cannot tell you "not mine" —
10774
+ * // only the timestamp can, so any non-match falls through to it, not
10775
+ * // just a null one. `>=`, not `>`: both timestamps are `ctx.now()` in
10776
+ * // the same sandbox process, one `await` apart, at millisecond
10777
+ * // resolution — so they can be EQUAL, and a strict `>` would never
10778
+ * // accept this turn's own snapshot, reporting "no files" after the
10779
+ * // full timeout.
10780
+ * if (candidate.capturedAtTurn >= completedAt) {
10781
+ * exported = candidate;
10782
+ * break;
10783
+ * }
10220
10784
  * } catch (err) {
10221
10785
  * // Discriminate on `code`, NOT on status: SESSION_NOT_FOUND is a 404 too,
10222
10786
  * // and a bad id / deleted session / lost access must surface immediately
@@ -10233,6 +10797,20 @@ var SessionsResource = class {
10233
10797
  * // exported === null → this turn produced no files. Normal, not a failure.
10234
10798
  * ```
10235
10799
  *
10800
+ * **`turnId` is the primary check; the timestamp branch is only a fallback.**
10801
+ * They are not equivalent. `turnId` is an equality test against an id you
10802
+ * already hold — but a non-matching `turnId` does not mean "not my turn": it
10803
+ * can be null, or it can be a DIFFERENT turn the platform inferred during the
10804
+ * migration window, and nothing in the response distinguishes the two. Treat
10805
+ * every non-match the same way and fall back to the timestamp rather than
10806
+ * special-casing "absent." `capturedAtTurn` is an internal epoch-ms cursor
10807
+ * with a failure mode `turnId` does not have: a BACKWARD sandbox clock step
10808
+ * (NTP correction) between the terminal append and the capture puts it before
10809
+ * `completedAt`, no comparison accepts it, and the poll times out —
10810
+ * reporting "no files" for a turn that produced them, which reads like a
10811
+ * normal result. Never display either value; `capturedAt` is the
10812
+ * human-facing field.
10813
+ *
10236
10814
  * **404 `WORKSPACE_SNAPSHOT_NOT_FOUND` is not by itself an error.** It throws
10237
10815
  * (a `PilotPlatformApiError`, so "this session never ran" is never silently
10238
10816
  * flattened to an empty result), and you MUST catch it inside the polling
@@ -10456,21 +11034,39 @@ var SessionsResource = class {
10456
11034
  }
10457
11035
  }
10458
11036
  /**
10459
- * Convenience poller: after `sendTurn`, poll `listEvents` until the
10460
- * worker-protocol TERMINAL event for `turnId` arrives, then resolve with
10461
- * it. Purely client-side — no extra server capability.
10462
- *
10463
- * Matching: a terminal event whose `payload.turnId` equals `turnId` always
10464
- * matches. Terminal events that omit `payload.turnId` (workers stamp the
10465
- * derived turn id on `worker_protocol.*.accepted` but may omit it on the
10466
- * terminal — observed in the baseline e2e worker) match ONLY after this
10467
- * turn's marker — any event whose `payload.turnId` equals `turnId`,
10468
- * normally the `.accepted` row — has been observed in the stream: turns
10469
- * dispatch serially per session, so the first turnId-less terminal after
10470
- * OUR accepted is this turn's, while stale pre-dispatch legacy terminals
10471
- * can never resolve the wait early. Callers resuming with an
10472
- * `afterEventId` cursor past the accepted marker get exact-turnId
10473
- * matching only.
11037
+ * Convenience poller: after `sendTurn`, poll the TURN (`turns.get`) until
11038
+ * its `status` is terminal, then resolve with the turn and — when one
11039
+ * exists — its terminal worker-protocol event.
11040
+ *
11041
+ * It polls the turn rather than draining `listEvents` because the cost of
11042
+ * the old form scaled with the CONVERSATION, not with the wait: a session
11043
+ * with thousands of streamed chunk rows spent its first polls paging
11044
+ * through history it did not care about, and an `interrupted` turn (worker
11045
+ * died, so no terminal event was ever written) could only ever time out.
11046
+ * A turn's status answers both in one request.
11047
+ *
11048
+ * `terminalEvent` is fetched with a SINGLE `listEvents` call after the
11049
+ * status settles, windowed to this turn and to the terminal event types —
11050
+ * it stays on the result because callers read its payload (e.g.
11051
+ * `completedAt`, which {@link exportWorkspace} needs). It is `undefined`
11052
+ * for an `interrupted` turn, which by construction has no terminal event.
11053
+ *
11054
+ * A 404 `TURN_NOT_FOUND` in the first {@link TURN_VISIBILITY_GRACE_MS} is
11055
+ * treated as "the turn row has not materialized yet" and retried — the
11056
+ * canonical call is `waitForTurn(id, sendTurn(...).turnId)`, and the turn
11057
+ * projection is not guaranteed to have run by the time that returns. After
11058
+ * the grace window the 404 is rethrown UNCHANGED, so a wrong turn id
11059
+ * surfaces as `TURN_NOT_FOUND` within seconds instead of costing the full
11060
+ * (10-minute) deadline.
11061
+ *
11062
+ * **Agent Recovery does not count against that grace.** After a 202
11063
+ * `revival_in_progress`, the prompt is replayed server-side and its turn row
11064
+ * only exists once the replay lands — minutes, not seconds. So on a 404 the
11065
+ * wait asks `sessions.get`: while `pendingRevival` is non-null (or
11066
+ * `lifecyclePhase` is `"reviving"`) the grace window is restarted rather
11067
+ * than consumed, and polling continues until the replay materializes. Only
11068
+ * the overall `timeoutMs` bounds that; a session NOT reviving keeps the
11069
+ * plain 30s behavior.
10474
11070
  *
10475
11071
  * Throws `SESSION_TURN_WAIT_TIMEOUT` on deadline (default 10 min; managed
10476
11072
  * agent turns are long tasks, raise `timeoutMs` for longer runs).
@@ -10478,31 +11074,37 @@ var SessionsResource = class {
10478
11074
  async waitForTurn(sessionId, turnId, options = {}) {
10479
11075
  const intervalMs = options.intervalMs ?? 1e3;
10480
11076
  const timeoutMs = options.timeoutMs ?? 6e5;
10481
- const pageLimit = 200;
10482
11077
  const startedAt = Date.now();
10483
- let cursor = options.afterEventId;
10484
- let dispatchSeen = false;
11078
+ const graceMs = Math.min(TURN_VISIBILITY_GRACE_MS, timeoutMs);
11079
+ let graceDeadline = startedAt + graceMs;
10485
11080
  while (true) {
10486
11081
  if (options.signal?.aborted) throw options.signal.reason;
10487
- const events = await this.listEvents(sessionId, {
10488
- afterEventId: cursor,
10489
- limit: pageLimit,
10490
- signal: options.signal
10491
- });
10492
- for (const event of events) {
10493
- const payloadTurnId = typeof event.payload === "object" && event.payload !== null ? event.payload.turnId : void 0;
10494
- if (payloadTurnId === turnId) dispatchSeen = true;
10495
- if (!WORKER_PROTOCOL_TERMINAL_EVENT_TYPES.includes(event.eventType))
10496
- continue;
10497
- if (payloadTurnId === turnId) {
10498
- return { terminalEvent: event };
11082
+ let turn;
11083
+ try {
11084
+ turn = await this.turns.get(sessionId, turnId, { signal: options.signal });
11085
+ } catch (error) {
11086
+ if (!isTurnNotFound(error)) throw error;
11087
+ if (await isRevivalPending(this, sessionId, options.signal)) {
11088
+ graceDeadline = Date.now() + graceMs;
11089
+ } else if (Date.now() >= graceDeadline) {
11090
+ throw error;
10499
11091
  }
10500
- if ((payloadTurnId === void 0 || payloadTurnId === null) && dispatchSeen) {
10501
- return { terminalEvent: event };
11092
+ if (Date.now() - startedAt >= timeoutMs) {
11093
+ throw new PilotPlatformApiError({
11094
+ status: 0,
11095
+ code: "SESSION_TURN_WAIT_TIMEOUT",
11096
+ message: `Timed out waiting for turn ${turnId} of session ${sessionId} to appear; the session was still recovering.`
11097
+ });
10502
11098
  }
11099
+ await sleep(intervalMs, options.signal);
11100
+ continue;
11101
+ }
11102
+ if (isTerminalTurnStatus(turn.status)) {
11103
+ return {
11104
+ terminalEvent: await fetchTerminalEvent(this, sessionId, turnId, options.signal),
11105
+ turn
11106
+ };
10503
11107
  }
10504
- const last = events[events.length - 1];
10505
- if (last) cursor = last.eventId;
10506
11108
  if (Date.now() - startedAt >= timeoutMs) {
10507
11109
  throw new PilotPlatformApiError({
10508
11110
  status: 0,
@@ -10510,7 +11112,6 @@ var SessionsResource = class {
10510
11112
  message: `Timed out waiting for turn ${turnId} of session ${sessionId} to terminate.`
10511
11113
  });
10512
11114
  }
10513
- if (events.length === pageLimit) continue;
10514
11115
  await sleep(intervalMs, options.signal);
10515
11116
  }
10516
11117
  }
@@ -10552,7 +11153,71 @@ async function* parseSseFrames(body, signal) {
10552
11153
  });
10553
11154
  }
10554
11155
  }
11156
+ var TURN_VISIBILITY_GRACE_MS = 3e4;
11157
+ function isTurnNotFound(error) {
11158
+ return error instanceof PilotPlatformApiError && error.code === "TURN_NOT_FOUND";
11159
+ }
11160
+ var SessionRevivalStateSchema = import_zod76.z.object({
11161
+ pendingRevival: import_zod76.z.object({ attemptId: import_zod76.z.string() }).nullish(),
11162
+ session: import_zod76.z.object({ lifecyclePhase: import_zod76.z.string().nullish() }).loose().optional()
11163
+ });
11164
+ async function isRevivalPending(sessions, sessionId, signal) {
11165
+ let snapshot;
11166
+ try {
11167
+ snapshot = await sessions.get(sessionId, { signal });
11168
+ } catch (error) {
11169
+ if (signal?.aborted) throw error;
11170
+ return false;
11171
+ }
11172
+ const parsed = SessionRevivalStateSchema.safeParse(snapshot);
11173
+ if (!parsed.success) return false;
11174
+ return (parsed.data.pendingRevival ?? null) !== null || parsed.data.session?.lifecyclePhase === "reviving";
11175
+ }
11176
+ async function fetchTerminalEvent(sessions, sessionId, turnId, signal) {
11177
+ let events;
11178
+ try {
11179
+ events = await sessions.listEvents(sessionId, {
11180
+ turnId,
11181
+ types: [...WORKER_PROTOCOL_TERMINAL_EVENT_TYPES],
11182
+ limit: 10,
11183
+ signal
11184
+ });
11185
+ } catch (error) {
11186
+ if (!isTurnNotFound(error)) throw error;
11187
+ return void 0;
11188
+ }
11189
+ const terminals = events.filter(
11190
+ (event) => WORKER_PROTOCOL_TERMINAL_EVENT_TYPES.includes(event.eventType)
11191
+ );
11192
+ return terminals[terminals.length - 1];
11193
+ }
11194
+ function attachPageFields(events, fields) {
11195
+ for (const [key, value] of Object.entries(fields)) {
11196
+ if (value === void 0) continue;
11197
+ Object.defineProperty(events, key, { value, enumerable: false, configurable: true });
11198
+ }
11199
+ return events;
11200
+ }
11201
+ async function resolveRuntimeBindingId(sessions, sessionId, signal) {
11202
+ const snapshot = await sessions.get(sessionId, { signal });
11203
+ const parsed = SessionRuntimeBindingEnvelopeSchema.safeParse(snapshot);
11204
+ const runtimeBindingId = parsed.success ? parsed.data.runtimeBinding?.id ?? void 0 : void 0;
11205
+ if (!runtimeBindingId) {
11206
+ throw new PilotPlatformApiError({
11207
+ status: 0,
11208
+ code: "RUNTIME_BINDING_NOT_READY",
11209
+ message: `Session ${sessionId} has no active runtime binding; there is no worker to abort.`
11210
+ });
11211
+ }
11212
+ return runtimeBindingId;
11213
+ }
11214
+ function newTraceId() {
11215
+ const cryptoImpl = globalThis.crypto;
11216
+ if (typeof cryptoImpl?.randomUUID === "function") return cryptoImpl.randomUUID();
11217
+ return `sdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
11218
+ }
10555
11219
  function sleep(ms, signal) {
11220
+ if (signal?.aborted) return Promise.reject(signal.reason);
10556
11221
  if (ms <= 0) return Promise.resolve();
10557
11222
  return new Promise((resolve, reject) => {
10558
11223
  const timer = setTimeout(resolve, ms);
@@ -10568,11 +11233,11 @@ function sleep(ms, signal) {
10568
11233
  }
10569
11234
 
10570
11235
  // src/resources/workloads.ts
10571
- var import_zod75 = require("zod");
10572
- var CanaryPromoteResponseSchema = import_zod75.z.object({
11236
+ var import_zod77 = require("zod");
11237
+ var CanaryPromoteResponseSchema = import_zod77.z.object({
10573
11238
  slot: StageSlotViewSchema,
10574
- fromRevisionId: import_zod75.z.string().uuid(),
10575
- toRevisionId: import_zod75.z.string().uuid()
11239
+ fromRevisionId: import_zod77.z.string().uuid(),
11240
+ toRevisionId: import_zod77.z.string().uuid()
10576
11241
  }).strict();
10577
11242
  var WorkloadStageCanaryResource = class {
10578
11243
  constructor(client) {
@@ -11226,6 +11891,40 @@ function mergeSignals(...signals) {
11226
11891
  }
11227
11892
  return controller.signal;
11228
11893
  }
11894
+
11895
+ // src/ui-messages.ts
11896
+ function toUIMessages(turns) {
11897
+ const messages = [];
11898
+ for (const turn of [...turns].sort(compareByDispatch)) {
11899
+ const userMessage = {
11900
+ id: turn.user.messageId,
11901
+ role: "user",
11902
+ parts: [{ type: "text", text: turn.user.text }]
11903
+ };
11904
+ if (turn.user.attachments.length > 0) {
11905
+ userMessage.metadata = { attachments: turn.user.attachments };
11906
+ }
11907
+ messages.push(userMessage);
11908
+ if (turn.assistant === null) continue;
11909
+ const assistantMessage = {
11910
+ id: turn.assistant.messageId,
11911
+ role: "assistant",
11912
+ parts: turn.assistant.parts
11913
+ };
11914
+ if (turn.assistant.state === "truncated") {
11915
+ assistantMessage.metadata = { truncated: true };
11916
+ }
11917
+ messages.push(assistantMessage);
11918
+ }
11919
+ return messages;
11920
+ }
11921
+ function compareByDispatch(a, b) {
11922
+ const aTime = Date.parse(a.dispatchedAt);
11923
+ const bTime = Date.parse(b.dispatchedAt);
11924
+ const byTime = Number.isNaN(aTime) || Number.isNaN(bTime) ? a.dispatchedAt.localeCompare(b.dispatchedAt) : aTime - bTime;
11925
+ if (byTime !== 0) return byTime;
11926
+ return a.turnId.localeCompare(b.turnId);
11927
+ }
11229
11928
  // Annotate the CommonJS export names for ESM import in node:
11230
11929
  0 && (module.exports = {
11231
11930
  AGENTHUB_SDK_USER_AGENT,
@@ -11308,10 +12007,20 @@ function mergeSignals(...signals) {
11308
12007
  SessionFileResourceSchema,
11309
12008
  SessionMemorySubjectDeclarationSchema,
11310
12009
  SessionResourcesSchema,
12010
+ SessionTurnsResource,
11311
12011
  SessionsResource,
11312
12012
  StageSchema,
11313
12013
  StageSlotViewSchema,
11314
12014
  StoredMemorySubjectPolicySchema,
12015
+ TERMINAL_TURN_STATUSES,
12016
+ TURN_LIST_DEFAULT_LIMIT,
12017
+ TURN_LIST_MAX_LIMIT,
12018
+ TurnAssistantPartSchema,
12019
+ TurnKindSchema,
12020
+ TurnListQuerySchema,
12021
+ TurnListResponseDataSchema,
12022
+ TurnSchema,
12023
+ TurnStatusSchema,
11315
12024
  UpdateEnvironmentInputSchema,
11316
12025
  WorkbenchDTOSchema,
11317
12026
  WorkloadStageCanaryResource,
@@ -11321,8 +12030,11 @@ function mergeSignals(...signals) {
11321
12030
  WriteMemoriesRequestSchema,
11322
12031
  WriteMemoriesResultSchema,
11323
12032
  WriteMemoryItemSchema,
12033
+ isTerminalTurnStatus,
11324
12034
  pilotPlatformErrorFromResponse,
11325
12035
  platformRevisionPublishToManifest,
11326
- platformWorkloadCreateToManifest
12036
+ platformWorkloadCreateToManifest,
12037
+ toUIMessages,
12038
+ turnMessageIds
11327
12039
  });
11328
12040
  //# sourceMappingURL=index.cjs.map