@dotobokuri/fleet-console 1.68.0 → 1.70.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.
Files changed (67) hide show
  1. package/dist/cli.mjs +92 -2
  2. package/dist/client/assets/{_baseUniq-BPBd-J9P.js → _baseUniq-81Y5kFtp.js} +1 -1
  3. package/dist/client/assets/{arc-spHqy4X3.js → arc-d96Fgk-5.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-Q4EWVU46-7CHqKfxu.js → architectureDiagram-Q4EWVU46-BBgIklLp.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-DXYQGD6D-YasFDgl_.js → blockDiagram-DXYQGD6D-BCjY9dJk.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-AHTNJAMY-CcoPJq56.js → c4Diagram-AHTNJAMY-BVJRdf8q.js} +1 -1
  7. package/dist/client/assets/channel-CiSQi5S5.js +1 -0
  8. package/dist/client/assets/{chunk-4BX2VUAB-MYBJn9BE.js → chunk-4BX2VUAB-CT7BCzBg.js} +1 -1
  9. package/dist/client/assets/{chunk-4TB4RGXK-C1wg6GR_.js → chunk-4TB4RGXK-DUbDaHiY.js} +1 -1
  10. package/dist/client/assets/{chunk-55IACEB6-BoufMT1O.js → chunk-55IACEB6-C7HDwq0R.js} +1 -1
  11. package/dist/client/assets/{chunk-EDXVE4YY-BzAhAIl3.js → chunk-EDXVE4YY-Mh16Bf7t.js} +1 -1
  12. package/dist/client/assets/{chunk-FMBD7UC4-yVrLsKzP.js → chunk-FMBD7UC4-D3BjqAun.js} +1 -1
  13. package/dist/client/assets/{chunk-OYMX7WX6-YiiKaqRQ.js → chunk-OYMX7WX6-DmzxPT1k.js} +1 -1
  14. package/dist/client/assets/{chunk-QZHKN3VN-CqWQlGHT.js → chunk-QZHKN3VN-CaZdQK6Z.js} +1 -1
  15. package/dist/client/assets/{chunk-YZCP3GAM-9yLOmU5k.js → chunk-YZCP3GAM-Q2hrlgLY.js} +1 -1
  16. package/dist/client/assets/classDiagram-6PBFFD2Q-Cy-ZC6xF.js +1 -0
  17. package/dist/client/assets/classDiagram-v2-HSJHXN6E-Cy-ZC6xF.js +1 -0
  18. package/dist/client/assets/clone-BAhE6Fq8.js +1 -0
  19. package/dist/client/assets/{cose-bilkent-S5V4N54A-XkTuSq7v.js → cose-bilkent-S5V4N54A-CPdIsNiQ.js} +1 -1
  20. package/dist/client/assets/{dagre-KV5264BT-DyzXIEAe.js → dagre-KV5264BT-BYWdUXO0.js} +1 -1
  21. package/dist/client/assets/{diagram-5BDNPKRD-DF24YlCa.js → diagram-5BDNPKRD-BC8rqmOK.js} +1 -1
  22. package/dist/client/assets/{diagram-G4DWMVQ6-CVhcj9RK.js → diagram-G4DWMVQ6-CES6iBQQ.js} +1 -1
  23. package/dist/client/assets/{diagram-MMDJMWI5-C-kGKk4K.js → diagram-MMDJMWI5-BfhQrSaN.js} +1 -1
  24. package/dist/client/assets/{diagram-TYMM5635-mr285WbR.js → diagram-TYMM5635-C2FgHNxP.js} +1 -1
  25. package/dist/client/assets/{erDiagram-SMLLAGMA-BtEx-XlU.js → erDiagram-SMLLAGMA-KQgKZTcf.js} +1 -1
  26. package/dist/client/assets/{flowDiagram-DWJPFMVM-DuWy3xzN.js → flowDiagram-DWJPFMVM-7Ytk1sX_.js} +1 -1
  27. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-B2-xEikU.js → ganttDiagram-T4ZO3ILL-C4yl6vGV.js} +1 -1
  28. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-EM17u_t7.js → gitGraphDiagram-UUTBAWPF-DyN7iLk4.js} +1 -1
  29. package/dist/client/assets/{graph-xuE12FIq.js → graph-BsOHL3Ty.js} +1 -1
  30. package/dist/client/assets/index-2049WCXu.css +1 -0
  31. package/dist/client/assets/index-DJcpFTNB.js +466 -0
  32. package/dist/client/assets/{infoDiagram-42DDH7IO-B3MF4XtW.js → infoDiagram-42DDH7IO-BIOEjyDP.js} +1 -1
  33. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-DoQ2mGyh.js → ishikawaDiagram-UXIWVN3A-C18t-DEH.js} +1 -1
  34. package/dist/client/assets/{journeyDiagram-VCZTEJTY-GeR9sFH-.js → journeyDiagram-VCZTEJTY-BysZXCkq.js} +1 -1
  35. package/dist/client/assets/{kanban-definition-6JOO6SKY-DrrYMuvL.js → kanban-definition-6JOO6SKY-Zdulrt1W.js} +1 -1
  36. package/dist/client/assets/{layout-DH63A-3u.js → layout-DhT9CiMw.js} +1 -1
  37. package/dist/client/assets/{linear-BIjE6zB1.js → linear-DQna1rOZ.js} +1 -1
  38. package/dist/client/assets/{mermaid.core-yrrC2Lqo.js → mermaid.core-C0sjt4NJ.js} +4 -4
  39. package/dist/client/assets/{min-CR-H8E6U.js → min-Dyx0ykEh.js} +1 -1
  40. package/dist/client/assets/{mindmap-definition-QFDTVHPH-BzSC43J-.js → mindmap-definition-QFDTVHPH-BzEvAUNd.js} +1 -1
  41. package/dist/client/assets/{pieDiagram-DEJITSTG-BdghNtCc.js → pieDiagram-DEJITSTG-Cd4ORVnw.js} +1 -1
  42. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-s_zN2epw.js → quadrantDiagram-34T5L4WZ-CvNxhBIm.js} +1 -1
  43. package/dist/client/assets/{requirementDiagram-MS252O5E-DuiGG6Tx.js → requirementDiagram-MS252O5E-CuGuie-o.js} +1 -1
  44. package/dist/client/assets/{sankeyDiagram-XADWPNL6-Bp0JBk2g.js → sankeyDiagram-XADWPNL6-zn7buHsU.js} +1 -1
  45. package/dist/client/assets/{sequenceDiagram-FGHM5R23-AzQ3M31V.js → sequenceDiagram-FGHM5R23-BxDReh8o.js} +1 -1
  46. package/dist/client/assets/{stateDiagram-FHFEXIEX-BGgm44ev.js → stateDiagram-FHFEXIEX-DtZ0UE1G.js} +1 -1
  47. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-aYct9Owm.js +1 -0
  48. package/dist/client/assets/{timeline-definition-GMOUNBTQ-UqfsiBJY.js → timeline-definition-GMOUNBTQ-DfKveVha.js} +1 -1
  49. package/dist/client/assets/{vennDiagram-DHZGUBPP-PsCGF9nR.js → vennDiagram-DHZGUBPP-CZe6StT_.js} +1 -1
  50. package/dist/client/assets/{wardley-RL74JXVD-BDQbnh-d.js → wardley-RL74JXVD-B10WfMsc.js} +1 -1
  51. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-CtVA1JMs.js → wardleyDiagram-NUSXRM2D-DzN04fy9.js} +1 -1
  52. package/dist/client/assets/{xychartDiagram-5P7HB3ND-BsLlZWbc.js → xychartDiagram-5P7HB3ND-CIgNRRNp.js} +1 -1
  53. package/dist/client/index.html +2 -2
  54. package/dist/fleet-plugins/ledger/routes.mjs +92 -2
  55. package/dist/fleet-plugins/quota/routes.mjs +92 -2
  56. package/dist/fleet-plugins/repository/routes.mjs +41 -5
  57. package/dist/fleet-plugins/scuttlebutt/routes.mjs +92 -2
  58. package/dist/fleet-plugins/terminal/routes.mjs +672 -412
  59. package/dist/fleet.mjs +582 -260
  60. package/package.json +1 -1
  61. package/dist/client/assets/channel-DfEjadrw.js +0 -1
  62. package/dist/client/assets/classDiagram-6PBFFD2Q-D9vQdv0q.js +0 -1
  63. package/dist/client/assets/classDiagram-v2-HSJHXN6E-D9vQdv0q.js +0 -1
  64. package/dist/client/assets/clone-Ck2x5JX2.js +0 -1
  65. package/dist/client/assets/index-C5EOZGlC.js +0 -466
  66. package/dist/client/assets/index-CHHE3nPw.css +0 -1
  67. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-CZDbnuN-.js +0 -1
package/dist/fleet.mjs CHANGED
@@ -10,7 +10,8 @@ import http from 'node:http';
10
10
  import { spawn, execFileSync, execFile as execFile$1 } from 'node:child_process';
11
11
  import { builtinModules, createRequire } from 'node:module';
12
12
  import { fileURLToPath, pathToFileURL } from 'node:url';
13
- import * as fs32 from 'fs';
13
+ import { randomUUID, createHash } from 'crypto';
14
+ import * as fs42 from 'fs';
14
15
  import { constants, mkdirSync as mkdirSync$1, rmSync, renameSync as renameSync$1, appendFileSync, statSync } from 'fs';
15
16
  import * as path32 from 'path';
16
17
  import path32__default, { dirname } from 'path';
@@ -18,7 +19,6 @@ import { execFile } from 'child_process';
18
19
  import fs22, { appendFile, chmod, mkdir as mkdir$1, stat as stat$1, unlink, rename as rename$1 } from 'fs/promises';
19
20
  import os4 from 'os';
20
21
  import { promisify } from 'util';
21
- import { randomUUID, createHash } from 'crypto';
22
22
  import http2 from 'http2';
23
23
  import { deflateRawSync, inflateRawSync } from 'zlib';
24
24
  import { mkdtemp, rm, mkdir, readdir, readFile, stat, writeFile, appendFile as appendFile$1, realpath, lstat, rename } from 'node:fs/promises';
@@ -1085,7 +1085,7 @@ function joinChunks(chunks, totalBytes) {
1085
1085
  return joined;
1086
1086
  }
1087
1087
  function parseVersion(version2) {
1088
- const match = VERSION_PATTERN.exec(version2.trim());
1088
+ const match = VERSION_PATTERN2.exec(version2.trim());
1089
1089
  if (match === null) {
1090
1090
  return void 0;
1091
1091
  }
@@ -1137,13 +1137,13 @@ function parseNumericPart(value) {
1137
1137
  function compareNumbers(left, right) {
1138
1138
  return left === right ? 0 : left > right ? 1 : -1;
1139
1139
  }
1140
- var NPM_REGISTRY_BASE_URL, REGISTRY_TIMEOUT_MS, MAX_REGISTRY_RESPONSE_BYTES, VERSION_PATTERN;
1140
+ var NPM_REGISTRY_BASE_URL, REGISTRY_TIMEOUT_MS, MAX_REGISTRY_RESPONSE_BYTES, VERSION_PATTERN2;
1141
1141
  var init_version_check = __esm({
1142
1142
  "../../packages/core-agent/src/update/version-check.ts"() {
1143
1143
  NPM_REGISTRY_BASE_URL = "https://registry.npmjs.org/";
1144
1144
  REGISTRY_TIMEOUT_MS = 3e3;
1145
1145
  MAX_REGISTRY_RESPONSE_BYTES = 1024 * 1024;
1146
- VERSION_PATTERN = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
1146
+ VERSION_PATTERN2 = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
1147
1147
  }
1148
1148
  });
1149
1149
  function createGlobalPackageUpdater(deps) {
@@ -1517,9 +1517,9 @@ async function checkUpdateStatus(release, options = {}) {
1517
1517
  }
1518
1518
  const channel = resolveUpdateChannel(release.version);
1519
1519
  if (options.forceRefresh !== true) {
1520
- const cached2 = readCachedLatestVersion(channel);
1521
- if (cached2 !== void 0) {
1522
- return isVersionGreater(cached2, release.version) ? { status: "update", latest: cached2 } : { status: "current", latest: cached2 };
1520
+ const cached3 = readCachedLatestVersion(channel);
1521
+ if (cached3 !== void 0) {
1522
+ return isVersionGreater(cached3, release.version) ? { status: "update", latest: cached3 } : { status: "current", latest: cached3 };
1523
1523
  }
1524
1524
  }
1525
1525
  const latest = await fetchLatestFleetCliVersion(channel);
@@ -17642,11 +17642,11 @@ function createZeroMessage(desc) {
17642
17642
  }
17643
17643
  }
17644
17644
  } else {
17645
- const cached2 = messagePrototypes.get(desc);
17645
+ const cached3 = messagePrototypes.get(desc);
17646
17646
  let prototype;
17647
17647
  let members;
17648
- if (cached2) {
17649
- ({ prototype, members } = cached2);
17648
+ if (cached3) {
17649
+ ({ prototype, members } = cached3);
17650
17650
  } else {
17651
17651
  prototype = {};
17652
17652
  members = /* @__PURE__ */ new Set();
@@ -18417,9 +18417,9 @@ function reflect(messageDesc2, message, check2 = true) {
18417
18417
  var messageSortedFields = /* @__PURE__ */ new WeakMap();
18418
18418
  var ReflectMessageImpl = class {
18419
18419
  get sortedFields() {
18420
- const cached2 = messageSortedFields.get(this.desc);
18421
- if (cached2) {
18422
- return cached2;
18420
+ const cached3 = messageSortedFields.get(this.desc);
18421
+ if (cached3) {
18422
+ return cached3;
18423
18423
  }
18424
18424
  const sortedFields = this.desc.fields.concat().sort((a, b) => a.number - b.number);
18425
18425
  messageSortedFields.set(this.desc, sortedFields);
@@ -21538,6 +21538,20 @@ function clampReasoningEffort(effort, supportedEfforts, modelId) {
21538
21538
  if (lower) return lower.supported;
21539
21539
  throw new UnsupportedReasoningEffortError(effort, supportedEfforts, modelId);
21540
21540
  }
21541
+ var REASONING_SIGNATURE_PREFIX = "fleet-reasoning:v1:";
21542
+ function encodeReasoningSignature(id, encrypted) {
21543
+ return `${REASONING_SIGNATURE_PREFIX}${id}:${encrypted}`;
21544
+ }
21545
+ function decodeReasoningSignature(signature) {
21546
+ if (typeof signature !== "string" || !signature.startsWith(REASONING_SIGNATURE_PREFIX)) {
21547
+ return void 0;
21548
+ }
21549
+ const body2 = signature.slice(REASONING_SIGNATURE_PREFIX.length);
21550
+ const separator = body2.indexOf(":");
21551
+ if (separator === -1) return void 0;
21552
+ const encrypted = body2.slice(separator + 1);
21553
+ return encrypted.length > 0 ? { id: body2.slice(0, separator), encrypted } : void 0;
21554
+ }
21541
21555
  var ContextWindowExceededError = class extends Error {
21542
21556
  constructor(requestTokens, contextWindow) {
21543
21557
  super(`Prompt is too long: ${requestTokens} tokens > ${contextWindow} maximum context window`);
@@ -22263,7 +22277,7 @@ var benchmarks_default = {
22263
22277
  };
22264
22278
  var models_default = {
22265
22279
  version: 1,
22266
- updatedAt: "2026-08-19T00:00:00Z",
22280
+ updatedAt: "2026-08-20T00:00:00Z",
22267
22281
  providers: {
22268
22282
  codex: {
22269
22283
  name: "Codex",
@@ -22659,7 +22673,7 @@ var models_default = {
22659
22673
  cursor: {
22660
22674
  name: "Cursor",
22661
22675
  defaultModel: "auto",
22662
- source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; claude-opus-5 and claude-fable-5 standard/Max Mode windows observed 2026-08-10; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05)",
22676
+ source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; claude-opus-5 and claude-fable-5 standard/Max Mode windows observed 2026-08-10; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05); gpt-5.6-sol/terra/luna, gemini-3.7-flash, and kimi-k3 ids, effort rungs, and api quotaScope observed 2026-08-20 from live GetUsableModels (cursor-agent 2026.08.11-e8db854) and GetCurrentPeriodUsage autoBucketModels. Their windows are unmeasured because Cursor answers a first-turn Run with an empty token_details, so each carries the conservative cross-provider figure (272000 from the Codex catalog for the GPT-5.6 lineup, 256000 elsewhere); no Max Mode or -fast sibling is published for them",
22663
22677
  models: [
22664
22678
  {
22665
22679
  modelId: "auto",
@@ -22841,6 +22855,96 @@ var models_default = {
22841
22855
  upstreamModelIdTemplate: "claude-fable-5-{effort}"
22842
22856
  },
22843
22857
  benchmarkKey: "claude-fable-5"
22858
+ },
22859
+ {
22860
+ modelId: "gpt-5.6-sol",
22861
+ name: "GPT-5.6-Sol",
22862
+ capabilityClass: "flagship",
22863
+ quotaScope: "api",
22864
+ contextWindow: 272e3,
22865
+ effort: {
22866
+ supported: true,
22867
+ levels: [
22868
+ "low",
22869
+ "medium",
22870
+ "high",
22871
+ "xhigh",
22872
+ "max"
22873
+ ],
22874
+ upstreamModelIdTemplate: "gpt-5.6-sol-{effort}"
22875
+ },
22876
+ benchmarkKey: "gpt-5.6-sol"
22877
+ },
22878
+ {
22879
+ modelId: "gpt-5.6-terra",
22880
+ name: "GPT-5.6-Terra",
22881
+ capabilityClass: "standard",
22882
+ quotaScope: "api",
22883
+ contextWindow: 272e3,
22884
+ effort: {
22885
+ supported: true,
22886
+ levels: [
22887
+ "low",
22888
+ "medium",
22889
+ "high",
22890
+ "xhigh",
22891
+ "max"
22892
+ ],
22893
+ upstreamModelIdTemplate: "gpt-5.6-terra-{effort}"
22894
+ },
22895
+ benchmarkKey: "gpt-5.6-terra"
22896
+ },
22897
+ {
22898
+ modelId: "gpt-5.6-luna",
22899
+ name: "GPT-5.6-Luna",
22900
+ capabilityClass: "light",
22901
+ quotaScope: "api",
22902
+ contextWindow: 272e3,
22903
+ effort: {
22904
+ supported: true,
22905
+ levels: [
22906
+ "low",
22907
+ "medium",
22908
+ "high",
22909
+ "xhigh",
22910
+ "max"
22911
+ ],
22912
+ upstreamModelIdTemplate: "gpt-5.6-luna-{effort}"
22913
+ },
22914
+ benchmarkKey: "gpt-5.6-luna"
22915
+ },
22916
+ {
22917
+ modelId: "gemini-3.7-flash",
22918
+ name: "Gemini-3.7-Flash",
22919
+ capabilityClass: "light",
22920
+ quotaScope: "api",
22921
+ contextWindow: 256e3,
22922
+ effort: {
22923
+ supported: true,
22924
+ levels: [
22925
+ "low",
22926
+ "medium",
22927
+ "high"
22928
+ ],
22929
+ upstreamModelIdTemplate: "gemini-3.7-flash-{effort}"
22930
+ }
22931
+ },
22932
+ {
22933
+ modelId: "kimi-k3",
22934
+ name: "Kimi-K3",
22935
+ capabilityClass: "flagship",
22936
+ quotaScope: "api",
22937
+ contextWindow: 256e3,
22938
+ effort: {
22939
+ supported: true,
22940
+ levels: [
22941
+ "low",
22942
+ "high",
22943
+ "max"
22944
+ ],
22945
+ upstreamModelIdTemplate: "kimi-k3-{effort}"
22946
+ },
22947
+ benchmarkKey: "kimi-k3"
22844
22948
  }
22845
22949
  ]
22846
22950
  },
@@ -23777,11 +23881,21 @@ function translateMessage(message) {
23777
23881
  const items = [];
23778
23882
  const parts = [];
23779
23883
  let reasoningContent = "";
23884
+ let reasoningBlob;
23780
23885
  const takeReasoningContent = () => {
23781
- if (role !== "assistant" || reasoningContent.length === 0) return {};
23886
+ if (role !== "assistant") return {};
23887
+ const blob = reasoningBlob;
23782
23888
  const reasoning = reasoningContent;
23783
23889
  reasoningContent = "";
23784
- return { reasoning_content: reasoning };
23890
+ reasoningBlob = void 0;
23891
+ if (reasoning.length === 0 && blob === void 0) return {};
23892
+ return {
23893
+ ...reasoning.length === 0 ? {} : { reasoning_content: reasoning },
23894
+ ...blob === void 0 ? {} : {
23895
+ reasoning_encrypted: blob.encrypted,
23896
+ ...blob.id.length === 0 ? {} : { reasoning_id: blob.id }
23897
+ }
23898
+ };
23785
23899
  };
23786
23900
  const flushParts = (includeReasoning = true) => {
23787
23901
  if (parts.length === 0) {
@@ -23830,6 +23944,9 @@ function translateMessage(message) {
23830
23944
  if (role === "assistant" && typeof block.thinking === "string") {
23831
23945
  reasoningContent += block.thinking;
23832
23946
  }
23947
+ if (role === "assistant") {
23948
+ reasoningBlob = decodeReasoningSignature(block.signature) ?? reasoningBlob;
23949
+ }
23833
23950
  break;
23834
23951
  case "redacted_thinking":
23835
23952
  break;
@@ -23985,6 +24102,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
23985
24102
  let model = fallbackModel;
23986
24103
  let text = "";
23987
24104
  const thinking = /* @__PURE__ */ new Map();
24105
+ const reasoningBlobs = /* @__PURE__ */ new Map();
23988
24106
  let stopReason = "end_turn";
23989
24107
  let outputTokens = 0;
23990
24108
  let inputTokens = 0;
@@ -24026,6 +24144,16 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
24026
24144
  break;
24027
24145
  }
24028
24146
  case "response.output_item.done":
24147
+ if (event.item.type === "reasoning") {
24148
+ if (event.item.encrypted_content !== void 0) {
24149
+ reasoningBlobs.set(
24150
+ event.item.id,
24151
+ encodeReasoningSignature(event.item.id, event.item.encrypted_content)
24152
+ );
24153
+ if (!thinking.has(event.item.id)) thinking.set(event.item.id, "");
24154
+ }
24155
+ break;
24156
+ }
24029
24157
  if (event.item.type === "web_search_call") {
24030
24158
  const query = derivedWebSearchQuery(event.item.action);
24031
24159
  content.push({
@@ -24062,7 +24190,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
24062
24190
  content.unshift(...[...thinking].map(([itemId, value]) => ({
24063
24191
  type: "thinking",
24064
24192
  thinking: value,
24065
- signature: `gateway_${reasoningBlockKey(itemId)}`
24193
+ signature: reasoningBlobs.get(itemId) ?? `gateway_${reasoningBlockKey(itemId)}`
24066
24194
  })));
24067
24195
  return {
24068
24196
  id,
@@ -24099,6 +24227,7 @@ async function* encodeAnthropicSse(events, options = {}) {
24099
24227
  let messageStopped = false;
24100
24228
  let sawToolUse = false;
24101
24229
  let activeContentKey;
24230
+ const reasoningBlobs = /* @__PURE__ */ new Map();
24102
24231
  const encode3 = (event, data) => encoder2.encode(`event: ${event}
24103
24232
  data: ${JSON.stringify(data)}
24104
24233
 
@@ -24132,7 +24261,9 @@ data: ${JSON.stringify(data)}
24132
24261
  ...block.kind === "thinking" ? [encode3("content_block_delta", {
24133
24262
  type: "content_block_delta",
24134
24263
  index: block.index,
24135
- delta: { type: "signature_delta", signature: `gateway_${key}` }
24264
+ // The blob is only known once the reasoning item closes, which is why the signature
24265
+ // is emitted here at block close rather than at block start.
24266
+ delta: { type: "signature_delta", signature: reasoningBlobs.get(key) ?? `gateway_${key}` }
24136
24267
  })] : [],
24137
24268
  encode3("content_block_stop", {
24138
24269
  type: "content_block_stop",
@@ -24258,6 +24389,19 @@ data: ${JSON.stringify(data)}
24258
24389
  break;
24259
24390
  }
24260
24391
  case "response.output_item.done":
24392
+ if (event.item.type === "reasoning") {
24393
+ if (event.item.encrypted_content !== void 0) {
24394
+ const key = reasoningBlockKey(event.item.id);
24395
+ reasoningBlobs.set(key, encodeReasoningSignature(event.item.id, event.item.encrypted_content));
24396
+ if (!blocks2.has(key)) {
24397
+ yield* closeActiveContent();
24398
+ const start = startContentBlock(key, "thinking");
24399
+ if (start !== void 0) yield start;
24400
+ }
24401
+ yield* closeBlock(key);
24402
+ }
24403
+ break;
24404
+ }
24261
24405
  if (event.item.type === "function_call") {
24262
24406
  let block = blocks2.get(event.item.id);
24263
24407
  if (block === void 0) {
@@ -24862,6 +25006,13 @@ var OpenAIResponsesAdapter = class {
24862
25006
  "idleTimeoutMs"
24863
25007
  );
24864
25008
  }
25009
+ /**
25010
+ * Headers a subclass derives from the request itself, merged over the constructor's.
25011
+ * The base Platform API surface derives none.
25012
+ */
25013
+ perRequestHeaders(_request) {
25014
+ return {};
25015
+ }
24865
25016
  async stream(request, options) {
24866
25017
  if (options.apiKey.length === 0) {
24867
25018
  throw new TypeError("apiKey must not be empty");
@@ -24878,7 +25029,8 @@ var OpenAIResponsesAdapter = class {
24878
25029
  accept: "text/event-stream",
24879
25030
  authorization: `Bearer ${options.apiKey}`,
24880
25031
  "content-type": "application/json",
24881
- ...this.extraHeaders
25032
+ ...this.extraHeaders,
25033
+ ...this.perRequestHeaders(request)
24882
25034
  },
24883
25035
  body: JSON.stringify(payload),
24884
25036
  signal: controller.signal
@@ -24939,6 +25091,10 @@ var CodexResponsesAdapter = class extends OpenAIResponsesAdapter {
24939
25091
  });
24940
25092
  this.isMarkedFetchFailure = fetchFailureTracker.isMarkedFailure;
24941
25093
  }
25094
+ perRequestHeaders(request) {
25095
+ const sessionId = codexSessionIdentity(request);
25096
+ return sessionId === void 0 ? {} : { session_id: sessionId };
25097
+ }
24942
25098
  async stream(request, options) {
24943
25099
  const callController = new AbortController();
24944
25100
  const unlinkCallAbort = linkAbortSignal(options.signal, callController);
@@ -25218,11 +25374,27 @@ function forOpenAIResponsesBackend(request, dropSamplingParams) {
25218
25374
  }
25219
25375
  return payload;
25220
25376
  }
25377
+ function codexSessionIdentity(request) {
25378
+ const userId = request.metadata?.user_id?.trim();
25379
+ if (!userId) return void 0;
25380
+ const digest = createHash("sha256").update("fleet:codex:claude-session:").update(userId).digest("hex");
25381
+ return [
25382
+ digest.slice(0, 8),
25383
+ digest.slice(8, 12),
25384
+ digest.slice(12, 16),
25385
+ digest.slice(16, 20),
25386
+ digest.slice(20, 32)
25387
+ ].join("-");
25388
+ }
25221
25389
  function forChatGptBackend(request) {
25222
25390
  const copy = { ...request };
25223
25391
  for (const field of CHATGPT_UNSUPPORTED_FIELDS) {
25224
25392
  delete copy[field];
25225
25393
  }
25394
+ const sessionId = codexSessionIdentity(request);
25395
+ if (sessionId !== void 0) {
25396
+ copy.prompt_cache_key = sessionId;
25397
+ }
25226
25398
  if (request.tool_choice === "none" || isClaudeCodeSuggestionMode(request)) {
25227
25399
  delete copy.tools;
25228
25400
  delete copy.tool_choice;
@@ -28101,10 +28273,10 @@ function createQuotaService(deps) {
28101
28273
  if (id === "claude" && !await deps.isClaudeConnected() || id === "cursor" && !await deps.isCursorConnected()) {
28102
28274
  return { status: "not_connected", method: (deps.platform ?? process.platform) === "darwin" ? "keychain" : "file" };
28103
28275
  }
28104
- const cached2 = cache.get(id);
28105
- if (!force && cached2 && cached2.expiresAt > now()) {
28106
- const staleStillValid = cached2.value.status !== "stale" || typeof cached2.value.fetchedAt === "number" && now() - cached2.value.fetchedAt <= STALE_TTL_MS;
28107
- if (staleStillValid) return cached2.value;
28276
+ const cached22 = cache.get(id);
28277
+ if (!force && cached22 && cached22.expiresAt > now()) {
28278
+ const staleStillValid = cached22.value.status !== "stale" || typeof cached22.value.fetchedAt === "number" && now() - cached22.value.fetchedAt <= STALE_TTL_MS;
28279
+ if (staleStillValid) return cached22.value;
28108
28280
  cache.delete(id);
28109
28281
  }
28110
28282
  const pending = inFlight.get(id);
@@ -28156,25 +28328,150 @@ function createQuotaService(deps) {
28156
28328
  }
28157
28329
  };
28158
28330
  }
28331
+ var XAI_CLI_FALLBACK_CLIENT_VERSION = "1.0.5";
28332
+ var VERSION_PATTERN = /\b(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\b/;
28333
+ var VERSION_EXEC_TIMEOUT_MS = 2e3;
28334
+ var MAX_VERSION_FILE_BYTES = 256;
28335
+ function grokHomeDir(deps) {
28336
+ return optionalTrimmedString(deps.env.GROK_HOME) ?? path32__default.join(deps.homedir(), ".grok");
28337
+ }
28338
+ function versionFrom(value) {
28339
+ if (typeof value !== "string") return void 0;
28340
+ return VERSION_PATTERN.exec(value)?.[1];
28341
+ }
28342
+ async function fromInstallerSymlink(home, readLink) {
28343
+ try {
28344
+ return versionFrom(path32__default.basename(await readLink(path32__default.join(home, "bin", "grok"))));
28345
+ } catch {
28346
+ return void 0;
28347
+ }
28348
+ }
28349
+ async function fromMetadataMarker(home, deps) {
28350
+ try {
28351
+ return versionFrom(await deps.readBounded(path32__default.join(home, ".metadata_version"), MAX_VERSION_FILE_BYTES));
28352
+ } catch {
28353
+ return void 0;
28354
+ }
28355
+ }
28356
+ function grokExecutablePath(home, deps) {
28357
+ return path32__default.join(home, "bin", deps.platform === "win32" ? "grok.exe" : "grok");
28358
+ }
28359
+ async function fromCommand(deps, file2) {
28360
+ try {
28361
+ return versionFrom(await deps.execFile(file2, ["--version"], { timeout: VERSION_EXEC_TIMEOUT_MS }));
28362
+ } catch {
28363
+ return void 0;
28364
+ }
28365
+ }
28366
+ async function resolveXaiCliClientVersion(options = {}) {
28367
+ const deps = options.deps ?? defaultCredentialDeps;
28368
+ const readLink = options.readLink ?? ((filePath) => fs22.readlink(filePath));
28369
+ const override = versionFrom(optionalTrimmedString(deps.env.FLEET_XAI_CLI_VERSION));
28370
+ if (override) return override;
28371
+ const home = grokHomeDir(deps);
28372
+ return await fromInstallerSymlink(home, readLink) ?? await fromMetadataMarker(home, deps) ?? await fromCommand(deps, grokExecutablePath(home, deps)) ?? await fromCommand(deps, "grok") ?? XAI_CLI_FALLBACK_CLIENT_VERSION;
28373
+ }
28374
+ var cached2;
28375
+ function xaiCliClientVersion(options = {}) {
28376
+ cached2 ??= resolveXaiCliClientVersion(options).catch(() => XAI_CLI_FALLBACK_CLIENT_VERSION);
28377
+ return cached2;
28378
+ }
28379
+ var XAI_ENDPOINT_PREFERENCES = ["direct", "cli-proxy"];
28380
+ var DEFAULT_XAI_ENDPOINT_PREFERENCE = "cli-proxy";
28381
+ function sanitizeXaiEndpoint(value) {
28382
+ return typeof value === "string" && XAI_ENDPOINT_PREFERENCES.includes(value) ? value : void 0;
28383
+ }
28384
+ function normalizeAiGatewaySettings(value) {
28385
+ if (!isRecord7(value) || value.version !== 1) return { version: 1 };
28386
+ const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord7(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
28387
+ const model = findGatewayModel(entry.id);
28388
+ if (!model) return [];
28389
+ const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
28390
+ const exposed = efforts.length > 0 ? narrowEffortLadder(model, efforts) : void 0;
28391
+ return [{
28392
+ id: entry.id,
28393
+ ...exposed ? { efforts: [...exposed] } : {},
28394
+ ...entry.hostOnly === true ? { hostOnly: true } : {}
28395
+ }];
28396
+ }) : [];
28397
+ const providerPriority = sanitizeProviderPriority(value.providerPriority);
28398
+ const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
28399
+ const xaiEndpoint = sanitizeXaiEndpoint(value.xaiEndpoint);
28400
+ return {
28401
+ version: 1,
28402
+ ...models.length > 0 ? { models } : {},
28403
+ ...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
28404
+ ...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
28405
+ ...providerPriority ? { providerPriority: [...providerPriority] } : {},
28406
+ ...compactCeiling !== void 0 ? { compactCeiling } : {},
28407
+ ...xaiEndpoint !== void 0 ? { xaiEndpoint } : {}
28408
+ };
28409
+ }
28410
+ function sanitizeProviderPriority(value) {
28411
+ if (!Array.isArray(value)) return void 0;
28412
+ const seen = /* @__PURE__ */ new Set();
28413
+ const cleaned = [];
28414
+ for (const entry of value) {
28415
+ if (typeof entry !== "string") continue;
28416
+ if (!GATEWAY_PROVIDERS.includes(entry)) continue;
28417
+ const provider = entry;
28418
+ if (seen.has(provider)) continue;
28419
+ seen.add(provider);
28420
+ cleaned.push(provider);
28421
+ }
28422
+ return cleaned.length > 0 ? cleaned : void 0;
28423
+ }
28424
+ function isRecord7(value) {
28425
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28426
+ }
28427
+ function resolveAiGatewaySelection(settings2) {
28428
+ const enabled = [];
28429
+ const hostOnlyIds = /* @__PURE__ */ new Set();
28430
+ const effortExposure = {};
28431
+ for (const entry of settings2?.models ?? []) {
28432
+ const model = findGatewayModel(entry.id);
28433
+ if (!model) continue;
28434
+ if (entry.hostOnly === true) hostOnlyIds.add(model.id);
28435
+ if (enabled.includes(model)) continue;
28436
+ enabled.push(model);
28437
+ const exposed = narrowEffortLadder(model, entry.efforts);
28438
+ if (exposed) effortExposure[model.id] = exposed;
28439
+ }
28440
+ const models = sortGatewayModelsByProvider(enabled);
28441
+ const delegationModels = models.filter((model) => !hostOnlyIds.has(model.id));
28442
+ return { models, delegationModels, effortExposure, providerPriority: settings2?.providerPriority };
28443
+ }
28444
+ function narrowEffortLadder(model, efforts) {
28445
+ if (!efforts || efforts.length === 0) return void 0;
28446
+ const ladder = buildGatewayModelConstraints(model).effortLadder;
28447
+ const narrowed = ladder.filter((rung) => efforts.includes(rung));
28448
+ if (narrowed.length === 0 || narrowed.length === ladder.length) return void 0;
28449
+ return narrowed;
28450
+ }
28451
+ function sortGatewayModelsByProvider(models) {
28452
+ return [...models].sort((left, right) => {
28453
+ const providerDelta = GATEWAY_PROVIDERS.indexOf(left.provider) - GATEWAY_PROVIDERS.indexOf(right.provider);
28454
+ if (providerDelta !== 0) return providerDelta;
28455
+ return GATEWAY_MODELS.indexOf(left) - GATEWAY_MODELS.indexOf(right);
28456
+ });
28457
+ }
28159
28458
  var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
28160
28459
  var XAI_CLI_RESPONSES_URL = "https://cli-chat-proxy.grok.com/v1/responses";
28161
- var XAI_CLI_CLIENT_VERSION = "1.0.3";
28162
- var XAI_PROXY_FALLBACK_STATUSES = /* @__PURE__ */ new Set([402, 426]);
28163
28460
  var DEFAULT_XAI_RESPONSES_MAX_UPSTREAM_BODY_BYTES = 64 * 1024 * 1024;
28164
28461
  var DEFAULT_XAI_RESPONSES_UPSTREAM_IDLE_TIMEOUT_MS = 3e4;
28165
28462
  var DEFAULT_XAI_RESPONSES_FUNCTION_CALL_TIMEOUT_MS = 3e4;
28166
28463
  var DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS = 6e4;
28167
28464
  var XAI_RETRY_DELAY_MS = 200;
28168
- var xaiProxyOnlyAccount = false;
28465
+ var XAI_REASONING_INCLUDE = "reasoning.encrypted_content";
28169
28466
  function directXaiEndpoint() {
28170
28467
  return { url: XAI_RESPONSES_URL, headers: {} };
28171
28468
  }
28172
- function proxyXaiEndpoint(model) {
28469
+ function proxyXaiEndpoint(model, clientVersion) {
28173
28470
  return {
28174
28471
  url: XAI_CLI_RESPONSES_URL,
28175
28472
  headers: {
28176
28473
  "x-xai-token-auth": "xai-grok-cli",
28177
- "x-grok-client-version": XAI_CLI_CLIENT_VERSION,
28474
+ "x-grok-client-version": clientVersion,
28178
28475
  "x-grok-model-override": model
28179
28476
  }
28180
28477
  };
@@ -28187,6 +28484,8 @@ var XaiResponsesAdapter = class {
28187
28484
  idleTimeoutMs;
28188
28485
  functionCallTimeoutMs;
28189
28486
  semanticStallTimeoutMs;
28487
+ endpointPreference;
28488
+ clientVersion;
28190
28489
  extraHeaders;
28191
28490
  constructor(options = {}) {
28192
28491
  this.extraHeaders = options.headers ?? {};
@@ -28209,6 +28508,8 @@ var XaiResponsesAdapter = class {
28209
28508
  options.semanticStallTimeoutMs ?? DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS,
28210
28509
  "semanticStallTimeoutMs"
28211
28510
  );
28511
+ this.endpointPreference = options.endpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE;
28512
+ this.clientVersion = options.clientVersion ?? (() => xaiCliClientVersion());
28212
28513
  }
28213
28514
  async stream(request, options) {
28214
28515
  if (options.apiKey.length === 0) {
@@ -28216,22 +28517,14 @@ var XaiResponsesAdapter = class {
28216
28517
  }
28217
28518
  const controller = new AbortController();
28218
28519
  const unlinkAbort = linkAbortSignal(options.signal, controller);
28219
- const payload = forXaiResponsesBackend(request, xaiWireTools(request));
28520
+ const tools = xaiWireTools(request);
28521
+ let payload = forXaiResponsesBackend(request, tools);
28522
+ let replayAvailable = replaysXaiReasoning(request);
28220
28523
  let retryAvailable = true;
28221
28524
  let response;
28222
- let endpoint = xaiProxyOnlyAccount ? proxyXaiEndpoint(payload.model) : directXaiEndpoint();
28525
+ const endpoint = this.endpointPreference === "cli-proxy" ? await this.proxyEndpoint(payload.model) : directXaiEndpoint();
28223
28526
  try {
28224
28527
  response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
28225
- if (!response.ok && endpoint.url === XAI_RESPONSES_URL && XAI_PROXY_FALLBACK_STATUSES.has(response.status)) {
28226
- wireLog("xai-responses.endpoint.fallback", {
28227
- status: response.status,
28228
- from: XAI_RESPONSES_URL,
28229
- to: XAI_CLI_RESPONSES_URL
28230
- });
28231
- xaiProxyOnlyAccount = true;
28232
- endpoint = proxyXaiEndpoint(payload.model);
28233
- response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
28234
- }
28235
28528
  } catch (error51) {
28236
28529
  if (!isRetryableXaiFetchSocket(error51, controller.signal, this.isMarkedFetchFailure)) {
28237
28530
  unlinkAbort();
@@ -28254,17 +28547,40 @@ var XaiResponsesAdapter = class {
28254
28547
  unlinkAbort();
28255
28548
  return response;
28256
28549
  }
28257
- return {
28258
- ...response,
28259
- events: retryXaiEvents(response.events, async (signal) => {
28550
+ const reopen = async (signal, reason) => {
28551
+ if (reason === "empty_stream" && replayAvailable) {
28552
+ replayAvailable = false;
28553
+ payload = forXaiResponsesBackend(request, tools, false);
28554
+ wireLog("xai-responses.reasoning.replay_dropped", { reason });
28260
28555
  await abortableXaiDelay(XAI_RETRY_DELAY_MS, signal);
28261
- const retried = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
28262
- if (!retried.ok) {
28263
- throw new UpstreamProtocolError(`xAI retry failed with status ${retried.status}`);
28556
+ const withoutReplay = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
28557
+ if (!withoutReplay.ok) {
28558
+ throw new UpstreamProtocolError(`xAI retry failed with status ${withoutReplay.status}`);
28264
28559
  }
28265
- return retried.events;
28266
- }, controller, unlinkAbort, retryAvailable)
28560
+ return withoutReplay.events;
28561
+ }
28562
+ await abortableXaiDelay(XAI_RETRY_DELAY_MS, signal);
28563
+ const retried = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
28564
+ if (!retried.ok) {
28565
+ throw new UpstreamProtocolError(`xAI retry failed with status ${retried.status}`);
28566
+ }
28567
+ return retried.events;
28267
28568
  };
28569
+ return {
28570
+ ...response,
28571
+ events: retryXaiEvents(
28572
+ response.events,
28573
+ reopen,
28574
+ controller,
28575
+ unlinkAbort,
28576
+ retryAvailable,
28577
+ () => replayAvailable
28578
+ )
28579
+ };
28580
+ }
28581
+ /** The proxy endpoint, with the installed CLI's version resolved for its gate. */
28582
+ async proxyEndpoint(model) {
28583
+ return proxyXaiEndpoint(model, await this.clientVersion());
28268
28584
  }
28269
28585
  async fetchResponse(apiKey, payload, controller, endpoint) {
28270
28586
  wireLog("xai-responses.wire.request", { url: endpoint.url, payload });
@@ -28315,21 +28631,43 @@ var XaiResponsesAdapter = class {
28315
28631
  return xaiWireTools(request) ?? [];
28316
28632
  }
28317
28633
  };
28318
- function forXaiResponsesBackend(request, tools = xaiWireTools(request)) {
28634
+ function forXaiResponsesBackend(request, tools = xaiWireTools(request), replayReasoning = true) {
28319
28635
  const { metadata: _metadata, native_tools: _nativeTools, ...rest } = request;
28636
+ const input = [];
28637
+ for (const item of request.input) {
28638
+ if (item.type === "function_call_output") {
28639
+ const { is_error: _isError, tool_references: _toolReferences, ...wireItem2 } = item;
28640
+ input.push(wireItem2);
28641
+ continue;
28642
+ }
28643
+ const {
28644
+ reasoning_content: _reasoningContent,
28645
+ reasoning_encrypted: encrypted,
28646
+ reasoning_id: reasoningId,
28647
+ ...wireItem
28648
+ } = item;
28649
+ if (replayReasoning && encrypted !== void 0 && encrypted.length > 0) {
28650
+ input.push({
28651
+ type: "reasoning",
28652
+ ...reasoningId === void 0 ? {} : { id: reasoningId },
28653
+ summary: [],
28654
+ encrypted_content: encrypted
28655
+ });
28656
+ }
28657
+ input.push(wireItem);
28658
+ }
28320
28659
  return {
28321
28660
  ...rest,
28322
- input: request.input.map((item) => {
28323
- if (item.type === "function_call_output") {
28324
- const { is_error: _isError, tool_references: _toolReferences, ...wireItem2 } = item;
28325
- return wireItem2;
28326
- }
28327
- const { reasoning_content: _reasoningContent, ...wireItem } = item;
28328
- return wireItem;
28329
- }),
28661
+ input,
28662
+ // Only asked for when a reply could carry one: on a turn that replays nothing the include
28663
+ // is inert, and on a retry that dropped the replay it must not invite a fresh blob back.
28664
+ ...replayReasoning ? { include: [XAI_REASONING_INCLUDE] } : {},
28330
28665
  ...tools === void 0 ? {} : { tools: [...tools] }
28331
28666
  };
28332
28667
  }
28668
+ function replaysXaiReasoning(request) {
28669
+ return request.input.some((item) => item.type !== "function_call_output" && typeof item.reasoning_encrypted === "string" && item.reasoning_encrypted.length > 0);
28670
+ }
28333
28671
  function xaiWireTools(request) {
28334
28672
  if (request.tools === void 0) return void 0;
28335
28673
  const tools = request.tools;
@@ -28350,11 +28688,18 @@ function isToolSearchName(name) {
28350
28688
  function toolNameMatches(declaredName, selectedName) {
28351
28689
  return declaredName === selectedName || toolLeafName(declaredName) === toolLeafName(selectedName);
28352
28690
  }
28353
- function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable) {
28691
+ function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
28354
28692
  return {
28355
28693
  [Symbol.asyncIterator]() {
28356
28694
  const source = events[Symbol.asyncIterator]();
28357
- const iterator = generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable);
28695
+ const iterator = generateXaiRetryEvents(
28696
+ source,
28697
+ retry,
28698
+ controller,
28699
+ unlinkAbort,
28700
+ retryAvailable,
28701
+ replayAvailable
28702
+ );
28358
28703
  return {
28359
28704
  next: () => iterator.next(),
28360
28705
  return: async () => {
@@ -28369,7 +28714,7 @@ function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable)
28369
28714
  }
28370
28715
  };
28371
28716
  }
28372
- async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable) {
28717
+ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
28373
28718
  const lead = [];
28374
28719
  let committed = false;
28375
28720
  let normalCompletion = false;
@@ -28393,14 +28738,26 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
28393
28738
  });
28394
28739
  await source.return?.();
28395
28740
  lead.length = 0;
28396
- yield* await retry(controller.signal);
28741
+ yield* await retry(controller.signal, "retryable_failure");
28397
28742
  return;
28398
28743
  }
28399
28744
  if (result.done) {
28400
- yield* lead;
28401
28745
  if (pendingError !== void 0) {
28402
- yield pendingError;
28746
+ wireLog("xai-responses.retry.discarded", {
28747
+ reason: "error_stream_end",
28748
+ errorTypes: [pendingError.error.type]
28749
+ });
28750
+ lead.length = 0;
28751
+ yield* await retry(controller.signal, "retryable_failure");
28752
+ return;
28403
28753
  }
28754
+ if (!committed && replayAvailable()) {
28755
+ wireLog("xai-responses.retry.discarded", { reason: "empty_stream" });
28756
+ lead.length = 0;
28757
+ yield* await retry(controller.signal, "empty_stream");
28758
+ return;
28759
+ }
28760
+ yield* lead;
28404
28761
  normalCompletion = true;
28405
28762
  return;
28406
28763
  }
@@ -28411,7 +28768,7 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
28411
28768
  wireLog("xai-responses.retry.discarded", pendingError === void 0 ? { reason: "response.failed", errorTypes } : { reason: "error_failed_pair", errorTypes });
28412
28769
  await source.return?.();
28413
28770
  lead.length = 0;
28414
- yield* await retry(controller.signal);
28771
+ yield* await retry(controller.signal, "retryable_failure");
28415
28772
  return;
28416
28773
  }
28417
28774
  pendingError = event;
@@ -28445,7 +28802,7 @@ function isRetryableXaiFailure(event) {
28445
28802
  return event.type === "response.failed" && isRetryableXaiErrorType(event.response.error.type) || event.type === "error" && isRetryableXaiErrorType(event.error.type);
28446
28803
  }
28447
28804
  function isRetryableXaiErrorType(type) {
28448
- return type === "server_error" || type === "server_is_overloaded" || type === "service_unavailable_error";
28805
+ return type === "server_error" || type === "server_is_overloaded" || type === "service_unavailable_error" || type === XAI_OVERLOADED_ERROR_TYPE;
28449
28806
  }
28450
28807
  function commitsXaiOutput(event) {
28451
28808
  if (event.type === "response.created" || event.type === "response.reasoning_summary_text.delta") {
@@ -28750,7 +29107,7 @@ function parseEventFrame3(frame) {
28750
29107
  );
28751
29108
  }
28752
29109
  logRawWireEvent("xai-responses.wire.event", eventName, parsed);
28753
- if (isRecord7(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
29110
+ if (isRecord8(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
28754
29111
  parsed = { ...parsed, type: eventName };
28755
29112
  }
28756
29113
  return canonicalEvent3(parsed);
@@ -28760,7 +29117,7 @@ function withoutXaiSentinel(text) {
28760
29117
  return text.includes(XAI_EOS_SENTINEL) ? text.split(XAI_EOS_SENTINEL).join("") : text;
28761
29118
  }
28762
29119
  function canonicalEvent3(value) {
28763
- if (!isRecord7(value) || typeof value.type !== "string") {
29120
+ if (!isRecord8(value) || typeof value.type !== "string") {
28764
29121
  throw new UpstreamProtocolError("Grok CLI SSE event was not an object with a type");
28765
29122
  }
28766
29123
  switch (value.type) {
@@ -28905,19 +29262,34 @@ function outputItem3(value) {
28905
29262
  arguments: typeof item.arguments === "string" ? item.arguments : ""
28906
29263
  };
28907
29264
  }
29265
+ if (item.type === "reasoning") {
29266
+ const encrypted = typeof item.encrypted_content === "string" && item.encrypted_content.length > 0 ? item.encrypted_content : void 0;
29267
+ if (encrypted === void 0) return void 0;
29268
+ return {
29269
+ id: typeof item.id === "string" ? item.id : "",
29270
+ type: "reasoning",
29271
+ encrypted_content: encrypted
29272
+ };
29273
+ }
28908
29274
  return void 0;
28909
29275
  }
29276
+ var XAI_OVERLOADED_ERROR_TYPE = "overloaded_error";
29277
+ var XAI_CAPACITY_MESSAGE = /\bat capacity\b|\boverloaded\b/i;
28910
29278
  function canonicalError3(value) {
28911
29279
  const error51 = record3(value, "error");
28912
29280
  const message = string32(error51.message, "error.message");
28913
- const type = typeof error51.type === "string" && error51.type !== "error" ? error51.type : typeof error51.code === "string" ? error51.code : "api_error";
28914
- return { type, message };
29281
+ return { type: xaiErrorType(error51, message), message };
28915
29282
  }
28916
- function isRecord7(value) {
29283
+ function xaiErrorType(error51, message) {
29284
+ if (typeof error51.type === "string" && error51.type !== "error") return error51.type;
29285
+ if (typeof error51.code === "string") return error51.code;
29286
+ return XAI_CAPACITY_MESSAGE.test(message) ? XAI_OVERLOADED_ERROR_TYPE : "api_error";
29287
+ }
29288
+ function isRecord8(value) {
28917
29289
  return typeof value === "object" && value !== null && !Array.isArray(value);
28918
29290
  }
28919
29291
  function record3(value, name) {
28920
- if (!isRecord7(value)) {
29292
+ if (!isRecord8(value)) {
28921
29293
  throw new UpstreamProtocolError(`${name} must be an object`);
28922
29294
  }
28923
29295
  return value;
@@ -28989,38 +29361,38 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
28989
29361
  "shell_command",
28990
29362
  "exec_command"
28991
29363
  ]);
28992
- if (isRecord8(exec2.readArgs)) {
29364
+ if (isRecord9(exec2.readArgs)) {
28993
29365
  return [execReply(exec2, "readResult", {
28994
29366
  error: { path: stringValue(exec2.readArgs.path), error: readMessage3 }
28995
29367
  })];
28996
29368
  }
28997
- if (isRecord8(exec2.writeArgs)) {
29369
+ if (isRecord9(exec2.writeArgs)) {
28998
29370
  return [execReply(exec2, "writeResult", {
28999
29371
  rejected: { path: stringValue(exec2.writeArgs.path), reason: mutationMessage }
29000
29372
  })];
29001
29373
  }
29002
- if (isRecord8(exec2.deleteArgs)) {
29374
+ if (isRecord9(exec2.deleteArgs)) {
29003
29375
  return [execReply(exec2, "deleteResult", {
29004
29376
  rejected: { path: stringValue(exec2.deleteArgs.path), reason: mutationMessage }
29005
29377
  })];
29006
29378
  }
29007
- if (isRecord8(exec2.lsArgs)) {
29379
+ if (isRecord9(exec2.lsArgs)) {
29008
29380
  return [execReply(exec2, "lsResult", {
29009
29381
  error: { path: stringValue(exec2.lsArgs.path), error: listMessage }
29010
29382
  })];
29011
29383
  }
29012
- if (isRecord8(exec2.grepArgs)) {
29384
+ if (isRecord9(exec2.grepArgs)) {
29013
29385
  return [execReply(exec2, "grepResult", { error: { error: grepMessage } })];
29014
29386
  }
29015
- if (isRecord8(exec2.shellArgs)) {
29387
+ if (isRecord9(exec2.shellArgs)) {
29016
29388
  return [execReply(exec2, "shellResult", shellFailure(exec2.shellArgs, shellMessage))];
29017
29389
  }
29018
- if (isRecord8(exec2.shellStreamArgs)) {
29390
+ if (isRecord9(exec2.shellStreamArgs)) {
29019
29391
  const args = exec2.shellStreamArgs;
29020
29392
  const cwd = stringValue(args.workingDirectory);
29021
29393
  return [
29022
29394
  execReply(exec2, "shellStream", {
29023
- start: isRecord8(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
29395
+ start: isRecord9(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
29024
29396
  }),
29025
29397
  execReply(exec2, "shellStream", { stderr: { data: shellMessage } }),
29026
29398
  execReply(exec2, "shellStream", { exit: { code: 1, cwd, aborted: true } }),
@@ -29028,7 +29400,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
29028
29400
  { execClientControlMessage: { streamClose: { id: numberValue(exec2.id) } } }
29029
29401
  ];
29030
29402
  }
29031
- if (isRecord8(exec2.backgroundShellSpawnArgs)) {
29403
+ if (isRecord9(exec2.backgroundShellSpawnArgs)) {
29032
29404
  const args = exec2.backgroundShellSpawnArgs;
29033
29405
  return [execReply(exec2, "backgroundShellSpawnResult", {
29034
29406
  error: {
@@ -29038,15 +29410,15 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
29038
29410
  }
29039
29411
  })];
29040
29412
  }
29041
- if (isRecord8(exec2.writeShellStdinArgs)) {
29413
+ if (isRecord9(exec2.writeShellStdinArgs)) {
29042
29414
  return [execReply(exec2, "writeShellStdinResult", { error: { error: shellMessage } })];
29043
29415
  }
29044
- if (isRecord8(exec2.fetchArgs)) {
29416
+ if (isRecord9(exec2.fetchArgs)) {
29045
29417
  return [execReply(exec2, "fetchResult", {
29046
29418
  error: { url: stringValue(exec2.fetchArgs.url), error: networkMessage }
29047
29419
  })];
29048
29420
  }
29049
- if (isRecord8(exec2.diagnosticsArgs)) {
29421
+ if (isRecord9(exec2.diagnosticsArgs)) {
29050
29422
  return [execReply(exec2, "diagnosticsResult", {
29051
29423
  error: {
29052
29424
  path: stringValue(exec2.diagnosticsArgs.path),
@@ -29054,12 +29426,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
29054
29426
  }
29055
29427
  })];
29056
29428
  }
29057
- if (isRecord8(exec2.listMcpResourcesExecArgs)) {
29429
+ if (isRecord9(exec2.listMcpResourcesExecArgs)) {
29058
29430
  return [execReply(exec2, "listMcpResourcesExecResult", {
29059
29431
  error: { error: retryMessage(clientTools, ["ListMcpResources", "list_mcp_resources"]) }
29060
29432
  })];
29061
29433
  }
29062
- if (isRecord8(exec2.readMcpResourceExecArgs)) {
29434
+ if (isRecord9(exec2.readMcpResourceExecArgs)) {
29063
29435
  return [execReply(exec2, "readMcpResourceExecResult", {
29064
29436
  error: {
29065
29437
  uri: stringValue(exec2.readMcpResourceExecArgs.uri),
@@ -29067,12 +29439,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
29067
29439
  }
29068
29440
  })];
29069
29441
  }
29070
- if (isRecord8(exec2.recordScreenArgs)) {
29442
+ if (isRecord9(exec2.recordScreenArgs)) {
29071
29443
  return [execReply(exec2, "recordScreenResult", {
29072
29444
  failure: { error: retryMessage(clientTools, ["record_screen", "computer_use"]) }
29073
29445
  })];
29074
29446
  }
29075
- if (isRecord8(exec2.computerUseArgs)) {
29447
+ if (isRecord9(exec2.computerUseArgs)) {
29076
29448
  return [execReply(exec2, "computerUseResult", {
29077
29449
  error: {
29078
29450
  error: retryMessage(clientTools, ["computer_use"]),
@@ -29082,7 +29454,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
29082
29454
  }
29083
29455
  })];
29084
29456
  }
29085
- if (isRecord8(exec2.mcpArgs)) {
29457
+ if (isRecord9(exec2.mcpArgs)) {
29086
29458
  return [execReply(exec2, "mcpResult", {
29087
29459
  error: { error: retryMessage(clientTools, []) }
29088
29460
  })];
@@ -29154,7 +29526,7 @@ function numberValue(value) {
29154
29526
  function stringValue(value) {
29155
29527
  return typeof value === "string" ? value : "";
29156
29528
  }
29157
- function isRecord8(value) {
29529
+ function isRecord9(value) {
29158
29530
  return typeof value === "object" && value !== null && !Array.isArray(value);
29159
29531
  }
29160
29532
  var EXECUTE_HOOK_FIELD_NUMBER = 27;
@@ -29310,14 +29682,14 @@ function isCursorWithheldToolName(name) {
29310
29682
  function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
29311
29683
  const messageId = numberValue2(exec2.id ?? 0);
29312
29684
  const execId = stringValue2(exec2.execId) || `redirect-${messageId}`;
29313
- if (isRecord9(exec2.readArgs)) {
29314
- const path72 = stringValue2(exec2.readArgs.path);
29315
- if (!path72) return null;
29685
+ if (isRecord10(exec2.readArgs)) {
29686
+ const path82 = stringValue2(exec2.readArgs.path);
29687
+ if (!path82) return null;
29316
29688
  if ([exec2.readArgs.offset, exec2.readArgs.limit].some((value) => typeof value === "number" && value < 0)) return null;
29317
29689
  const offset = positiveNumber(exec2.readArgs.offset);
29318
29690
  const limit = positiveNumber(exec2.readArgs.limit);
29319
29691
  if (offset !== void 0 || limit !== void 0) return null;
29320
- const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path72) })).find((candidate) => candidate.args !== null);
29692
+ const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path82) })).find((candidate) => candidate.args !== null);
29321
29693
  if (!mapped?.args) return null;
29322
29694
  return redirect(
29323
29695
  exec2,
@@ -29329,14 +29701,14 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
29329
29701
  "readResult",
29330
29702
  "read-direct",
29331
29703
  mapped.args,
29332
- { path: path72 }
29704
+ { path: path82 }
29333
29705
  );
29334
29706
  }
29335
- if (isRecord9(exec2.grepArgs)) {
29707
+ if (isRecord10(exec2.grepArgs)) {
29336
29708
  const grepArgs = exec2.grepArgs;
29337
29709
  const pattern = stringValue2(grepArgs.pattern);
29338
29710
  if (!pattern.trim()) return null;
29339
- const path72 = stringValue2(grepArgs.path) || ".";
29711
+ const path82 = stringValue2(grepArgs.path) || ".";
29340
29712
  const glob = stringValue2(grepArgs.glob);
29341
29713
  const outputMode = normalizedGrepOutputMode(stringValue2(grepArgs.outputMode));
29342
29714
  if (!outputMode) return null;
@@ -29352,7 +29724,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
29352
29724
  if (numericOptions.some((value) => typeof value === "number" && value < 0)) return null;
29353
29725
  const mappingInput = {
29354
29726
  pattern,
29355
- path: path72,
29727
+ path: path82,
29356
29728
  glob,
29357
29729
  outputMode,
29358
29730
  caseInsensitive: grepArgs.caseInsensitive === true,
@@ -29369,7 +29741,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
29369
29741
  const mapped = tools.filter((tool) => matchesLeaf(tool, GREP_CANDIDATES)).map((tool) => ({ tool, args: grepArguments(tool, mappingInput) })).find((candidate) => candidate.args !== null);
29370
29742
  const nativeArgs = {
29371
29743
  pattern,
29372
- path: path72,
29744
+ path: path82,
29373
29745
  outputMode,
29374
29746
  ...glob ? { glob } : {},
29375
29747
  ...positiveNumber(grepArgs.offset) === void 0 ? {} : { offset: String(positiveNumber(grepArgs.offset)) }
@@ -29406,15 +29778,15 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
29406
29778
  nativeArgs
29407
29779
  );
29408
29780
  }
29409
- if (isRecord9(exec2.shellArgs) || isRecord9(exec2.shellStreamArgs)) {
29410
- const argsRecord = isRecord9(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
29781
+ if (isRecord10(exec2.shellArgs) || isRecord10(exec2.shellStreamArgs)) {
29782
+ const argsRecord = isRecord10(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
29411
29783
  const command2 = stringValue2(argsRecord.command);
29412
29784
  if (!command2) return null;
29413
29785
  const cwd = stringValue2(argsRecord.workingDirectory);
29414
29786
  const timeout = positiveNumber(argsRecord.timeout) ?? positiveNumber(argsRecord.hardTimeout);
29415
29787
  const mapped = tools.filter((tool) => matchesLeaf(tool, SHELL_CANDIDATES)).map((tool) => ({ tool, args: shellArguments(tool.inputSchemaValue, command2, cwd || void 0, timeout) })).find((candidate) => candidate.args !== null);
29416
29788
  if (!mapped?.args) return null;
29417
- const stream = isRecord9(exec2.shellStreamArgs);
29789
+ const stream = isRecord10(exec2.shellStreamArgs);
29418
29790
  return redirect(
29419
29791
  exec2,
29420
29792
  mapped.tool,
@@ -29504,9 +29876,9 @@ function cursorNativeRedirectErrorReplies(correlation, error51) {
29504
29876
  }
29505
29877
  }
29506
29878
  }
29507
- function readArguments(schema, path72) {
29879
+ function readArguments(schema, path82) {
29508
29880
  const pathKey = firstSchemaProperty(schema, ["file_path", "path"]);
29509
- return pathKey ? { [pathKey]: path72 } : null;
29881
+ return pathKey ? { [pathKey]: path82 } : null;
29510
29882
  }
29511
29883
  function grepArguments(tool, input) {
29512
29884
  const leaf = normalizedLeaf(tool.clientName);
@@ -29673,7 +30045,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
29673
30045
  const decoded = JSON.parse(inflateRawSync(compressed, {
29674
30046
  maxOutputLength: CURSOR_GREP_RECEIPT_MAX_BYTES
29675
30047
  }).toString("utf8"));
29676
- if (!isRecord9(decoded)) throw new Error("receipt is not an object");
30048
+ if (!isRecord10(decoded)) throw new Error("receipt is not an object");
29677
30049
  if (decoded.ok === false && typeof decoded.error === "string") {
29678
30050
  return { ok: false, error: decoded.error };
29679
30051
  }
@@ -29686,7 +30058,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
29686
30058
  if (!Array.isArray(decoded.counts) || !decoded.counts.every((entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "number" && Number.isSafeInteger(entry[1]) && entry[1] >= 0)) {
29687
30059
  throw new Error("receipt counts are invalid");
29688
30060
  }
29689
- if (!Array.isArray(decoded.matches) || !decoded.matches.every((entry) => isRecord9(entry) && typeof entry.file === "string" && typeof entry.lineNumber === "number" && Number.isSafeInteger(entry.lineNumber) && entry.lineNumber > 0 && typeof entry.content === "string" && typeof entry.contentTruncated === "boolean" && typeof entry.isContextLine === "boolean")) {
30061
+ if (!Array.isArray(decoded.matches) || !decoded.matches.every((entry) => isRecord10(entry) && typeof entry.file === "string" && typeof entry.lineNumber === "number" && Number.isSafeInteger(entry.lineNumber) && entry.lineNumber > 0 && typeof entry.content === "string" && typeof entry.contentTruncated === "boolean" && typeof entry.isContextLine === "boolean")) {
29690
30062
  throw new Error("receipt matches are invalid");
29691
30063
  }
29692
30064
  for (const key of ["totalFiles", "totalLines", "totalMatchedLines"]) {
@@ -29704,7 +30076,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
29704
30076
  }
29705
30077
  }
29706
30078
  function buildGrepReceiptSuccess(args, receipt) {
29707
- const path72 = args.path || ".";
30079
+ const path82 = args.path || ".";
29708
30080
  let result;
29709
30081
  if (receipt.outputMode === "files_with_matches") {
29710
30082
  result = {
@@ -29750,15 +30122,15 @@ function buildGrepReceiptSuccess(args, receipt) {
29750
30122
  }
29751
30123
  return {
29752
30124
  pattern: args.pattern ?? "",
29753
- path: path72,
30125
+ path: path82,
29754
30126
  outputMode: receipt.outputMode,
29755
- workspaceResults: { [path72]: result }
30127
+ workspaceResults: { [path82]: result }
29756
30128
  };
29757
30129
  }
29758
30130
  function buildGrepSuccess(args, output) {
29759
30131
  const outputMode = normalizedGrepOutputMode(args.outputMode) ?? "content";
29760
30132
  const lines = output.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0 && !line.startsWith("[") && !/^no matches/i.test(line));
29761
- const path72 = args.path || ".";
30133
+ const path82 = args.path || ".";
29762
30134
  let result;
29763
30135
  if (outputMode === "files_with_matches") {
29764
30136
  result = {
@@ -29821,9 +30193,9 @@ function buildGrepSuccess(args, output) {
29821
30193
  }
29822
30194
  return {
29823
30195
  pattern: args.pattern ?? "",
29824
- path: path72,
30196
+ path: path82,
29825
30197
  outputMode,
29826
- workspaceResults: { [path72]: result }
30198
+ workspaceResults: { [path82]: result }
29827
30199
  };
29828
30200
  }
29829
30201
  function parseCallerShellOutput(output, isError) {
@@ -29885,7 +30257,7 @@ function redirect(exec2, tool, providerIdentifier, messageId, execId, execCase,
29885
30257
  }
29886
30258
  function execArgsToolCallId(exec2) {
29887
30259
  for (const value of Object.values(exec2)) {
29888
- if (!isRecord9(value)) continue;
30260
+ if (!isRecord10(value)) continue;
29889
30261
  const toolCallId = stringValue2(value.toolCallId);
29890
30262
  if (toolCallId) return toolCallId;
29891
30263
  }
@@ -29906,7 +30278,7 @@ function firstSchemaProperty(schema, candidates) {
29906
30278
  return candidates.find((candidate) => schemaHasProperty(schema, candidate));
29907
30279
  }
29908
30280
  function schemaHasProperty(schema, name) {
29909
- return isRecord9(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
30281
+ return isRecord10(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
29910
30282
  }
29911
30283
  function execReply2(exec2, resultName, result) {
29912
30284
  return {
@@ -29933,7 +30305,7 @@ function positiveNumber(value) {
29933
30305
  function stringValue2(value) {
29934
30306
  return typeof value === "string" ? value : "";
29935
30307
  }
29936
- function isRecord9(value) {
30308
+ function isRecord10(value) {
29937
30309
  return typeof value === "object" && value !== null && !Array.isArray(value);
29938
30310
  }
29939
30311
  var cursorAgentDescriptor = [
@@ -30764,18 +31136,18 @@ function decodeCursorServerMessage(payload) {
30764
31136
  const message = fromBinary(AgentServerMessageSchema, payload);
30765
31137
  const unknownExecFields = extractCursorUnknownExecFields(message);
30766
31138
  const json3 = toJson(AgentServerMessageSchema, message);
30767
- if (!isRecord10(json3)) throw new TypeError("Cursor server frame was not a message object");
31139
+ if (!isRecord11(json3)) throw new TypeError("Cursor server frame was not a message object");
30768
31140
  if (unknownExecFields.length > 0) {
30769
31141
  Object.defineProperty(json3, CURSOR_UNKNOWN_EXEC_FIELDS, { value: unknownExecFields });
30770
31142
  }
30771
31143
  return json3;
30772
31144
  }
30773
31145
  function extractCursorUnknownExecFields(message) {
30774
- if (!isRecord10(message) || !isRecord10(message.message)) return [];
30775
- if (message.message.case !== "execServerMessage" || !isRecord10(message.message.value)) return [];
31146
+ if (!isRecord11(message) || !isRecord11(message.message)) return [];
31147
+ if (message.message.case !== "execServerMessage" || !isRecord11(message.message.value)) return [];
30776
31148
  const fields = message.message.value.$unknown;
30777
31149
  if (!Array.isArray(fields)) return [];
30778
- return fields.filter((field) => isRecord10(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
31150
+ return fields.filter((field) => isRecord11(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
30779
31151
  }
30780
31152
  function parseConnectEndStreamError(payload) {
30781
31153
  try {
@@ -31097,7 +31469,7 @@ function cursorToolArgumentBytes(argumentsText) {
31097
31469
  } catch {
31098
31470
  return {};
31099
31471
  }
31100
- if (!isRecord10(parsed)) return {};
31472
+ if (!isRecord11(parsed)) return {};
31101
31473
  return Object.fromEntries(Object.entries(parsed).map(([name, value]) => [
31102
31474
  name,
31103
31475
  Buffer.from(toBinary(ValueSchema, fromJson(ValueSchema, value))).toString("base64")
@@ -32382,7 +32754,7 @@ ${argumentsText}`;
32382
32754
  const handleFrame = (frame, replayed = false) => {
32383
32755
  const unknownExecFields = frame[CURSOR_UNKNOWN_EXEC_FIELDS] ?? [];
32384
32756
  lastFrame = describeCursorServerFrame(frame, unknownExecFields);
32385
- const tokenDetails = isRecord10(frame.conversationCheckpointUpdate) && isRecord10(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
32757
+ const tokenDetails = isRecord11(frame.conversationCheckpointUpdate) && isRecord11(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
32386
32758
  const checkpointContextTokens = positiveTokenCount(tokenDetails?.usedTokens);
32387
32759
  const checkpointContextWindow = positiveTokenCount(tokenDetails?.maxTokens);
32388
32760
  if (!replayed) {
@@ -32395,7 +32767,7 @@ ${argumentsText}`;
32395
32767
  ...checkpointContextWindow === void 0 ? {} : { contextWindow: checkpointContextWindow }
32396
32768
  });
32397
32769
  }
32398
- if (isRecord10(frame.conversationCheckpointUpdate)) {
32770
+ if (isRecord11(frame.conversationCheckpointUpdate)) {
32399
32771
  if (checkpointContextTokens !== void 0) {
32400
32772
  wireLog("cursor.wire.checkpoint", {
32401
32773
  model: diagnosticModel,
@@ -32418,7 +32790,7 @@ ${argumentsText}`;
32418
32790
  }
32419
32791
  return;
32420
32792
  }
32421
- if (isRecord10(frame.kvServerMessage)) {
32793
+ if (isRecord11(frame.kvServerMessage)) {
32422
32794
  const kv = kvReply(frame.kvServerMessage, blobs);
32423
32795
  stream.write(encodeCursorClientMessage(kv.message));
32424
32796
  if (kv.fetch) {
@@ -32439,7 +32811,7 @@ ${argumentsText}`;
32439
32811
  });
32440
32812
  return;
32441
32813
  }
32442
- if (isRecord10(frame.interactionQuery)) {
32814
+ if (isRecord11(frame.interactionQuery)) {
32443
32815
  const reply = cursorInteractionQueryReply(frame.interactionQuery);
32444
32816
  stream.write(encodeCursorClientMessage(reply.message));
32445
32817
  report("client.reply", { model: diagnosticModel, reply: reply.replyKind });
@@ -32455,7 +32827,7 @@ ${argumentsText}`;
32455
32827
  }
32456
32828
  return;
32457
32829
  }
32458
- if (isRecord10(frame.error)) {
32830
+ if (isRecord11(frame.error)) {
32459
32831
  if (state === "attached") {
32460
32832
  emit({ type: "error", error: cursorError(frame.error) });
32461
32833
  completeRun("server_error");
@@ -32484,8 +32856,8 @@ ${argumentsText}`;
32484
32856
  return;
32485
32857
  }
32486
32858
  if (state !== "attached") return;
32487
- if (isRecord10(frame.execServerMessage)) {
32488
- if (isRecord10(frame.execServerMessage.requestContextArgs)) {
32859
+ if (isRecord11(frame.execServerMessage)) {
32860
+ if (isRecord11(frame.execServerMessage.requestContextArgs)) {
32489
32861
  stream.write(encodeCursorClientMessage(cursorRequestContextReply(frame.execServerMessage, tools)));
32490
32862
  report("client.reply", { model: diagnosticModel, reply: "exec.requestContext" });
32491
32863
  return;
@@ -32574,10 +32946,10 @@ ${argumentsText}`;
32574
32946
  }
32575
32947
  return;
32576
32948
  }
32577
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
32949
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
32578
32950
  if (update === void 0) return;
32579
32951
  if (isSettledToolUpdate(update)) return;
32580
- if (isRecord10(update.textDelta) && typeof update.textDelta.text === "string") {
32952
+ if (isRecord11(update.textDelta) && typeof update.textDelta.text === "string") {
32581
32953
  activeSegment.outputText += update.textDelta.text;
32582
32954
  emit({
32583
32955
  type: "response.output_text.delta",
@@ -32588,7 +32960,7 @@ ${argumentsText}`;
32588
32960
  });
32589
32961
  return;
32590
32962
  }
32591
- if (isRecord10(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
32963
+ if (isRecord11(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
32592
32964
  activeSegment.outputText += update.thinkingDelta.text;
32593
32965
  emit({
32594
32966
  type: "response.reasoning_summary_text.delta",
@@ -32598,12 +32970,12 @@ ${argumentsText}`;
32598
32970
  });
32599
32971
  return;
32600
32972
  }
32601
- if (isRecord10(update.tokenDelta)) {
32973
+ if (isRecord11(update.tokenDelta)) {
32602
32974
  const tokens = positiveTokenCount(update.tokenDelta.tokens);
32603
32975
  if (tokens !== void 0) activeSegment.contextOutputTokens += tokens;
32604
32976
  return;
32605
32977
  }
32606
- if (isRecord10(update.toolCallStarted)) {
32978
+ if (isRecord11(update.toolCallStarted)) {
32607
32979
  const wireCall = mcpCallFromToolUpdate(update.toolCallStarted);
32608
32980
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
32609
32981
  if (call) {
@@ -32613,7 +32985,7 @@ ${argumentsText}`;
32613
32985
  }
32614
32986
  return;
32615
32987
  }
32616
- if (isRecord10(update.partialToolCall)) {
32988
+ if (isRecord11(update.partialToolCall)) {
32617
32989
  const wireCall = mcpCallFromToolUpdate(update.partialToolCall);
32618
32990
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
32619
32991
  if (!call) return;
@@ -32624,7 +32996,7 @@ ${argumentsText}`;
32624
32996
  rescheduleToolTurnFinish();
32625
32997
  return;
32626
32998
  }
32627
- if (isRecord10(update.toolCallCompleted)) {
32999
+ if (isRecord11(update.toolCallCompleted)) {
32628
33000
  const wireCall = mcpCallFromToolUpdate(update.toolCallCompleted);
32629
33001
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
32630
33002
  if (!call) return;
@@ -32637,7 +33009,7 @@ ${argumentsText}`;
32637
33009
  rescheduleToolTurnFinish();
32638
33010
  return;
32639
33011
  }
32640
- if (isRecord10(update.turnEnded)) completeRun("turn_ended");
33012
+ if (isRecord11(update.turnEnded)) completeRun("turn_ended");
32641
33013
  };
32642
33014
  const eventsFor = (segment) => (async function* () {
32643
33015
  try {
@@ -32848,34 +33220,34 @@ var CURSOR_INTERACTION_QUERY_CASES = [
32848
33220
  ];
32849
33221
  var CURSOR_KV_CASES = ["getBlobArgs", "setBlobArgs"];
32850
33222
  function describeCursorServerFrame(frame, unknownExecFields = []) {
32851
- if (isRecord10(frame.interactionUpdate)) {
33223
+ if (isRecord11(frame.interactionUpdate)) {
32852
33224
  return `interactionUpdate.${cursorNestedRecordCase(
32853
33225
  frame.interactionUpdate,
32854
33226
  CURSOR_INTERACTION_UPDATE_CASES
32855
33227
  )}`;
32856
33228
  }
32857
- if (isRecord10(frame.execServerMessage)) {
33229
+ if (isRecord11(frame.execServerMessage)) {
32858
33230
  const knownCase = cursorNestedRecordCase(frame.execServerMessage, CURSOR_EXEC_CASES);
32859
33231
  return `execServerMessage.${knownCase === "unknown" ? cursorUnknownExecCaseName(unknownExecFields) : knownCase}`;
32860
33232
  }
32861
- if (isRecord10(frame.interactionQuery)) {
33233
+ if (isRecord11(frame.interactionQuery)) {
32862
33234
  return `interactionQuery.${cursorNestedRecordCase(
32863
33235
  frame.interactionQuery,
32864
33236
  CURSOR_INTERACTION_QUERY_CASES
32865
33237
  )}`;
32866
33238
  }
32867
- if (isRecord10(frame.kvServerMessage)) {
33239
+ if (isRecord11(frame.kvServerMessage)) {
32868
33240
  return `kvServerMessage.${cursorNestedRecordCase(frame.kvServerMessage, CURSOR_KV_CASES)}`;
32869
33241
  }
32870
- if (isRecord10(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
32871
- if (isRecord10(frame.error)) return "error";
33242
+ if (isRecord11(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
33243
+ if (isRecord11(frame.error)) return "error";
32872
33244
  return "unknown";
32873
33245
  }
32874
33246
  function isCursorHeartbeatFrame(frame) {
32875
- return isRecord10(frame.interactionUpdate) && isRecord10(frame.interactionUpdate.heartbeat);
33247
+ return isRecord11(frame.interactionUpdate) && isRecord11(frame.interactionUpdate.heartbeat);
32876
33248
  }
32877
33249
  function cursorNestedRecordCase(value, cases) {
32878
- return cases.find((candidate) => isRecord10(value[candidate])) ?? "unknown";
33250
+ return cases.find((candidate) => isRecord11(value[candidate])) ?? "unknown";
32879
33251
  }
32880
33252
  function positiveTokenCount(value) {
32881
33253
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) return void 0;
@@ -32887,8 +33259,8 @@ function cursorInteractionQueryReply(query) {
32887
33259
  const response = (result = {}) => ({
32888
33260
  interactionResponse: { id, ...result }
32889
33261
  });
32890
- if (isRecord10(query.createPlanRequestQuery)) {
32891
- const args = isRecord10(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
33262
+ if (isRecord11(query.createPlanRequestQuery)) {
33263
+ const args = isRecord11(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
32892
33264
  const name = stringValue3(args?.name)?.trim();
32893
33265
  const overview = stringValue3(args?.overview)?.trim();
32894
33266
  const plan = stringValue3(args?.plan)?.trim();
@@ -32904,7 +33276,7 @@ function cursorInteractionQueryReply(query) {
32904
33276
  ` } : {}
32905
33277
  };
32906
33278
  }
32907
- if (isRecord10(query.askQuestionInteractionQuery)) {
33279
+ if (isRecord11(query.askQuestionInteractionQuery)) {
32908
33280
  return {
32909
33281
  message: response({
32910
33282
  askQuestionInteractionResponse: {
@@ -32914,7 +33286,7 @@ function cursorInteractionQueryReply(query) {
32914
33286
  replyKind: "interaction.askQuestion.rejected"
32915
33287
  };
32916
33288
  }
32917
- if (isRecord10(query.switchModeRequestQuery)) {
33289
+ if (isRecord11(query.switchModeRequestQuery)) {
32918
33290
  return {
32919
33291
  message: response({
32920
33292
  switchModeRequestResponse: {
@@ -32924,19 +33296,19 @@ function cursorInteractionQueryReply(query) {
32924
33296
  replyKind: "interaction.switchMode.rejected"
32925
33297
  };
32926
33298
  }
32927
- if (isRecord10(query.webSearchRequestQuery)) {
33299
+ if (isRecord11(query.webSearchRequestQuery)) {
32928
33300
  return {
32929
33301
  message: response({ webSearchRequestResponse: { approved: {} } }),
32930
33302
  replyKind: "interaction.webSearch.approved"
32931
33303
  };
32932
33304
  }
32933
- if (isRecord10(query.exaSearchRequestQuery)) {
33305
+ if (isRecord11(query.exaSearchRequestQuery)) {
32934
33306
  return {
32935
33307
  message: response({ exaSearchRequestResponse: { approved: {} } }),
32936
33308
  replyKind: "interaction.exaSearch.approved"
32937
33309
  };
32938
33310
  }
32939
- if (isRecord10(query.exaFetchRequestQuery)) {
33311
+ if (isRecord11(query.exaFetchRequestQuery)) {
32940
33312
  return {
32941
33313
  message: response({ exaFetchRequestResponse: { approved: {} } }),
32942
33314
  replyKind: "interaction.exaFetch.approved"
@@ -32946,7 +33318,7 @@ function cursorInteractionQueryReply(query) {
32946
33318
  }
32947
33319
  function kvReply(kv, blobs) {
32948
33320
  const id = kv.id ?? 0;
32949
- if (isRecord10(kv.getBlobArgs)) {
33321
+ if (isRecord11(kv.getBlobArgs)) {
32950
33322
  const blobId = typeof kv.getBlobArgs.blobId === "string" ? kv.getBlobArgs.blobId : "";
32951
33323
  const blobData = blobs.get(blobId);
32952
33324
  return {
@@ -32958,7 +33330,7 @@ function kvReply(kv, blobs) {
32958
33330
  }
32959
33331
  };
32960
33332
  }
32961
- if (isRecord10(kv.setBlobArgs)) {
33333
+ if (isRecord11(kv.setBlobArgs)) {
32962
33334
  const blobId = typeof kv.setBlobArgs.blobId === "string" ? kv.setBlobArgs.blobId : "";
32963
33335
  const blobData = typeof kv.setBlobArgs.blobData === "string" ? kv.setBlobArgs.blobData : "";
32964
33336
  if (blobId) blobs.set(blobId, blobData);
@@ -33009,7 +33381,7 @@ function repairCursorArgumentValue(value, schema) {
33009
33381
  return { value: String(value), count: 1 };
33010
33382
  }
33011
33383
  if (Array.isArray(value)) {
33012
- const itemSchema = isRecord10(schema) ? schema.items : void 0;
33384
+ const itemSchema = isRecord11(schema) ? schema.items : void 0;
33013
33385
  if (itemSchema === void 0) return { value, count: 0 };
33014
33386
  let repairedValues;
33015
33387
  let count2 = 0;
@@ -33022,7 +33394,7 @@ function repairCursorArgumentValue(value, schema) {
33022
33394
  });
33023
33395
  return { value: repairedValues ?? value, count: count2 };
33024
33396
  }
33025
- if (!isRecord10(value) || !isRecord10(schema) || !isRecord10(schema.properties)) {
33397
+ if (!isRecord11(value) || !isRecord11(schema) || !isRecord11(schema.properties)) {
33026
33398
  return { value, count: 0 };
33027
33399
  }
33028
33400
  let repairedValue;
@@ -33038,12 +33410,12 @@ function repairCursorArgumentValue(value, schema) {
33038
33410
  return { value: repairedValue ?? value, count };
33039
33411
  }
33040
33412
  function cursorSchemaRequiresString(schema) {
33041
- if (!isRecord10(schema)) return false;
33413
+ if (!isRecord11(schema)) return false;
33042
33414
  if (schema.type === "string") return true;
33043
33415
  return Array.isArray(schema.type) && schema.type.includes("string") && schema.type.every((type) => type === "string" || type === "null");
33044
33416
  }
33045
33417
  function mcpCallFromToolUpdate(value) {
33046
- const toolCall = isRecord10(value.toolCall) ? value.toolCall : void 0;
33418
+ const toolCall = isRecord11(value.toolCall) ? value.toolCall : void 0;
33047
33419
  const args = toolCall ? mcpArgsFromToolCall(toolCall) : void 0;
33048
33420
  if (!args) return null;
33049
33421
  const publicCallId = stringValue3(value.callId);
@@ -33068,7 +33440,7 @@ var CURSOR_TOOL_UPDATE_CASES = [
33068
33440
  function cursorToolUpdateIdentifiers(update) {
33069
33441
  for (const key of CURSOR_TOOL_UPDATE_CASES) {
33070
33442
  const value = update[key];
33071
- if (!isRecord10(value)) continue;
33443
+ if (!isRecord11(value)) continue;
33072
33444
  const call = mcpCallFromToolUpdate(value);
33073
33445
  if (!call) return [];
33074
33446
  return [...new Set(
@@ -33078,9 +33450,9 @@ function cursorToolUpdateIdentifiers(update) {
33078
33450
  return void 0;
33079
33451
  }
33080
33452
  function isCursorClientToolFrame(frame, tools, redirectTools) {
33081
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
33453
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
33082
33454
  if (update !== void 0) return cursorToolUpdateIdentifiers(update) !== void 0;
33083
- const exec2 = isRecord10(frame.execServerMessage) ? frame.execServerMessage : void 0;
33455
+ const exec2 = isRecord11(frame.execServerMessage) ? frame.execServerMessage : void 0;
33084
33456
  if (exec2 === void 0) return false;
33085
33457
  const wireCall = mcpCallFromExecMessage(exec2);
33086
33458
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
@@ -33096,16 +33468,16 @@ function isCursorClientToolFrame(frame, tools, redirectTools) {
33096
33468
  ) !== null;
33097
33469
  }
33098
33470
  function isCursorParkedResidueFrame(frame, parked) {
33099
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
33471
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
33100
33472
  if (update === void 0) return false;
33101
- if (isRecord10(update.tokenDelta)) return true;
33473
+ if (isRecord11(update.tokenDelta)) return true;
33102
33474
  const identifiers = cursorToolUpdateIdentifiers(update);
33103
33475
  if (identifiers === void 0 || identifiers.length === 0 || parked === void 0) return false;
33104
33476
  const sealed = new Set(parked.flatMap((call) => [call.callId, call.toolCallId]));
33105
33477
  return identifiers.some((identifier) => sealed.has(identifier));
33106
33478
  }
33107
33479
  function mcpCallFromExecMessage(value) {
33108
- const args = isRecord10(value.mcpArgs) ? value.mcpArgs : void 0;
33480
+ const args = isRecord11(value.mcpArgs) ? value.mcpArgs : void 0;
33109
33481
  if (!args) return null;
33110
33482
  const toolCallId = stringValue3(args.toolCallId);
33111
33483
  if (!toolCallId) return null;
@@ -33123,14 +33495,14 @@ function mcpCallFromExecMessage(value) {
33123
33495
  };
33124
33496
  }
33125
33497
  function mcpArgsFromToolCall(toolCall) {
33126
- const direct = isRecord10(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
33127
- if (direct && isRecord10(direct.args)) return direct.args;
33128
- const tool = isRecord10(toolCall.tool) ? toolCall.tool : void 0;
33129
- const nested = tool && isRecord10(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
33130
- return nested && isRecord10(nested.args) ? nested.args : void 0;
33498
+ const direct = isRecord11(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
33499
+ if (direct && isRecord11(direct.args)) return direct.args;
33500
+ const tool = isRecord11(toolCall.tool) ? toolCall.tool : void 0;
33501
+ const nested = tool && isRecord11(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
33502
+ return nested && isRecord11(nested.args) ? nested.args : void 0;
33131
33503
  }
33132
33504
  function cursorMcpArguments(args) {
33133
- if (!isRecord10(args.args) || Object.keys(args.args).length === 0) return {};
33505
+ if (!isRecord11(args.args) || Object.keys(args.args).length === 0) return {};
33134
33506
  const decoded = {};
33135
33507
  for (const [name, value] of Object.entries(args.args)) {
33136
33508
  if (typeof value !== "string") {
@@ -33205,7 +33577,7 @@ function cursorError(value) {
33205
33577
  message: typeof value.message === "string" ? value.message : "Cursor request failed"
33206
33578
  };
33207
33579
  }
33208
- function isRecord10(value) {
33580
+ function isRecord11(value) {
33209
33581
  return typeof value === "object" && value !== null && !Array.isArray(value);
33210
33582
  }
33211
33583
  var DEFAULT_CURSOR_DIAGNOSTIC_MAX_BYTES = 4 * 1024 * 1024;
@@ -33382,78 +33754,6 @@ function kimiAnthropicHeaders(requestHeaders, apiKey) {
33382
33754
  }
33383
33755
  return headers;
33384
33756
  }
33385
- function normalizeAiGatewaySettings(value) {
33386
- if (!isRecord11(value) || value.version !== 1) return { version: 1 };
33387
- const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord11(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
33388
- const model = findGatewayModel(entry.id);
33389
- if (!model) return [];
33390
- const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
33391
- const exposed = efforts.length > 0 ? narrowEffortLadder(model, efforts) : void 0;
33392
- return [{
33393
- id: entry.id,
33394
- ...exposed ? { efforts: [...exposed] } : {},
33395
- ...entry.hostOnly === true ? { hostOnly: true } : {}
33396
- }];
33397
- }) : [];
33398
- const providerPriority = sanitizeProviderPriority(value.providerPriority);
33399
- const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
33400
- return {
33401
- version: 1,
33402
- ...models.length > 0 ? { models } : {},
33403
- ...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
33404
- ...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
33405
- ...providerPriority ? { providerPriority: [...providerPriority] } : {},
33406
- ...compactCeiling !== void 0 ? { compactCeiling } : {}
33407
- };
33408
- }
33409
- function sanitizeProviderPriority(value) {
33410
- if (!Array.isArray(value)) return void 0;
33411
- const seen = /* @__PURE__ */ new Set();
33412
- const cleaned = [];
33413
- for (const entry of value) {
33414
- if (typeof entry !== "string") continue;
33415
- if (!GATEWAY_PROVIDERS.includes(entry)) continue;
33416
- const provider = entry;
33417
- if (seen.has(provider)) continue;
33418
- seen.add(provider);
33419
- cleaned.push(provider);
33420
- }
33421
- return cleaned.length > 0 ? cleaned : void 0;
33422
- }
33423
- function isRecord11(value) {
33424
- return typeof value === "object" && value !== null && !Array.isArray(value);
33425
- }
33426
- function resolveAiGatewaySelection(settings2) {
33427
- const enabled = [];
33428
- const hostOnlyIds = /* @__PURE__ */ new Set();
33429
- const effortExposure = {};
33430
- for (const entry of settings2?.models ?? []) {
33431
- const model = findGatewayModel(entry.id);
33432
- if (!model) continue;
33433
- if (entry.hostOnly === true) hostOnlyIds.add(model.id);
33434
- if (enabled.includes(model)) continue;
33435
- enabled.push(model);
33436
- const exposed = narrowEffortLadder(model, entry.efforts);
33437
- if (exposed) effortExposure[model.id] = exposed;
33438
- }
33439
- const models = sortGatewayModelsByProvider(enabled);
33440
- const delegationModels = models.filter((model) => !hostOnlyIds.has(model.id));
33441
- return { models, delegationModels, effortExposure, providerPriority: settings2?.providerPriority };
33442
- }
33443
- function narrowEffortLadder(model, efforts) {
33444
- if (!efforts || efforts.length === 0) return void 0;
33445
- const ladder = buildGatewayModelConstraints(model).effortLadder;
33446
- const narrowed = ladder.filter((rung) => efforts.includes(rung));
33447
- if (narrowed.length === 0 || narrowed.length === ladder.length) return void 0;
33448
- return narrowed;
33449
- }
33450
- function sortGatewayModelsByProvider(models) {
33451
- return [...models].sort((left, right) => {
33452
- const providerDelta = GATEWAY_PROVIDERS.indexOf(left.provider) - GATEWAY_PROVIDERS.indexOf(right.provider);
33453
- if (providerDelta !== 0) return providerDelta;
33454
- return GATEWAY_MODELS.indexOf(left) - GATEWAY_MODELS.indexOf(right);
33455
- });
33456
- }
33457
33757
  var codexRequestPolicy = {
33458
33758
  provider: "codex",
33459
33759
  shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
@@ -33664,6 +33964,14 @@ function createAiGatewayRouter(deps) {
33664
33964
  return false;
33665
33965
  }
33666
33966
  };
33967
+ const xaiEndpoint = () => {
33968
+ if (!deps.readAiGatewaySettings) return DEFAULT_XAI_ENDPOINT_PREFERENCE;
33969
+ try {
33970
+ return deps.readAiGatewaySettings().xaiEndpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE;
33971
+ } catch {
33972
+ return DEFAULT_XAI_ENDPOINT_PREFERENCE;
33973
+ }
33974
+ };
33667
33975
  const compactCeiling = () => {
33668
33976
  try {
33669
33977
  return gatewaySettings()?.compactCeiling;
@@ -33811,7 +34119,10 @@ function createAiGatewayRouter(deps) {
33811
34119
  );
33812
34120
  return true;
33813
34121
  }
33814
- const gateway = deps.gateway ?? (target2.provider === "cursor" ? ownedCursorGateway : target2.provider === "opencode" ? createOpencodeGateway(opencodeGoWire(target2)) : target2.provider === "xai" ? new AnthropicMessagesGateway(new XaiResponsesAdapter({ fetch: fetchImpl })) : createGatewayFor(target2, chatgptAccountId, deps.originator));
34122
+ const gateway = deps.gateway ?? (target2.provider === "cursor" ? ownedCursorGateway : target2.provider === "opencode" ? createOpencodeGateway(opencodeGoWire(target2)) : target2.provider === "xai" ? new AnthropicMessagesGateway(new XaiResponsesAdapter({
34123
+ fetch: fetchImpl,
34124
+ endpoint: xaiEndpoint()
34125
+ })) : createGatewayFor(target2, chatgptAccountId, deps.originator));
33815
34126
  const diagnosticsEnabled = target2.provider === "cursor" ? cursorDiagnosticsEnabled() : void 0;
33816
34127
  const modelContextWindow = typeof target2.contextWindow === "number" && Number.isFinite(target2.contextWindow) && target2.contextWindow > 0 ? target2.contextWindow : void 0;
33817
34128
  const upstream = await gateway.stream(body2, {
@@ -33973,6 +34284,7 @@ function createAiGatewaySettingsStore(deps = {}) {
33973
34284
  // 무관한 모델 노출 저장 한 번이 사용자의 소진 순서를 지운다.
33974
34285
  ...current.providerPriority ? { providerPriority: current.providerPriority } : {},
33975
34286
  ...current.compactCeiling !== void 0 ? { compactCeiling: current.compactCeiling } : {},
34287
+ ...current.xaiEndpoint !== void 0 ? { xaiEndpoint: current.xaiEndpoint } : {},
33976
34288
  ...value ?? {}
33977
34289
  })),
33978
34290
  writeCursorDiagnosticsEnabled: (enabled) => update((current) => normalizeAiGatewaySettings({
@@ -33998,12 +34310,22 @@ function createAiGatewaySettingsStore(deps = {}) {
33998
34310
  const withoutCeiling = { ...next };
33999
34311
  delete withoutCeiling.compactCeiling;
34000
34312
  return withoutCeiling;
34313
+ }),
34314
+ writeXaiEndpoint: (endpoint) => update((current) => {
34315
+ const next = normalizeAiGatewaySettings({
34316
+ ...current,
34317
+ ...endpoint === void 0 ? {} : { xaiEndpoint: endpoint }
34318
+ });
34319
+ if (endpoint !== void 0) return next;
34320
+ const withoutEndpoint = { ...next };
34321
+ delete withoutEndpoint.xaiEndpoint;
34322
+ return withoutEndpoint;
34001
34323
  })
34002
34324
  };
34003
34325
  }
34004
34326
  function fileExists(filePath) {
34005
34327
  try {
34006
- return fs32.lstatSync(filePath).isFile();
34328
+ return fs42.lstatSync(filePath).isFile();
34007
34329
  } catch {
34008
34330
  return false;
34009
34331
  }
@@ -34012,7 +34334,7 @@ var CONCLUSIVE_LEGACY_READ_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EISDIR",
34012
34334
  function readLegacySettings(legacyPath) {
34013
34335
  let raw;
34014
34336
  try {
34015
- raw = fs32.readFileSync(legacyPath, "utf-8");
34337
+ raw = fs42.readFileSync(legacyPath, "utf-8");
34016
34338
  } catch (error51) {
34017
34339
  return CONCLUSIVE_LEGACY_READ_ERRORS.has(error51.code ?? "") ? { kind: "nothing" } : { kind: "unavailable" };
34018
34340
  }
@@ -34405,7 +34727,7 @@ var GATEWAY_MODELS_DOCTRINE = {
34405
34727
  // usageGuidelines에 적은 문장은 모델에 도달하지 않으므로, 틀리면 조용히 실패하는 두 규칙은
34406
34728
  // 여기에 둔다. 나머지 판정 규칙은 응답 본문을 보면 알 수 있어 싣지 않는다 — 길어질수록
34407
34729
  // 읽히지 않고, 읽히지 않으면 없는 것과 같다.
34408
- description: `Report the gateway models currently available to this session, each model's routing constraints, capability class, and benchmark evidence, and the current provider allowances and the user's provider spend priority. The roster is the models the user exposed in the Console minus the ones reserved for the host session, and it is editable while this session runs, so it is resolved at call time rather than remembered. Two spellings, never interchangeable: agentTypes names an identity for the Agent tool's subagent_type, while modelId is the model as a value for a workflow stage's opts.model \u2014 each is refused where the other belongs. Names are registered once at session start while this roster is re-read live, so a model or reasoning rung exposed mid-session appears here under a name that will not resolve until a new session.`,
34730
+ description: `Report the gateway models currently available to this session, each model's routing constraints, capability class, and benchmark evidence, and the current provider allowances and the user's provider spend priority. The roster is the models the user exposed in the Console minus the ones reserved for the host session, and it is editable while this session runs, so it is resolved at call time rather than remembered. Two spellings, never interchangeable: agentTypes names an identity \u2014 the Agent tool's subagent_type, or a workflow stage's opts.agentType \u2014 while modelId is the model as a value for a workflow stage's opts.model, and each is refused where the other belongs. Names are registered once at session start while this roster is re-read live, so a model or reasoning rung exposed mid-session appears here under a name that will not resolve until a new session.`,
34409
34731
  promptSnippet: `gateway_models \u2014 Live roster of assignable gateway models: constraints, capability class, benchmark evidence, provider allowances, and the user's provider priority.`,
34410
34732
  whenToUse: [],
34411
34733
  whenNotToUse: [],
@@ -34659,7 +34981,7 @@ init_paths();
34659
34981
 
34660
34982
  // ../../packages/fleet-admiral/src/agent-cli/assets.generated.ts
34661
34983
  var EMBEDDED_AGENT_CLI_HOOK_ASSETS = [
34662
- { relativePath: "fleet-gateway-model-guard.mjs", content: '#!/usr/bin/env node\n// Fleet gateway model guard \u2014 \uAC8C\uC774\uD2B8\uC6E8\uC774 \uC138\uC158\uC758 \uC704\uC784 \uC815\uCC45\uC744 \uCF54\uB4DC\uB85C \uAC15\uC81C\uD558\uB294 \uB2E8\uC77C \uD6C5.\n//\n// \uC774 \uC800\uC7A5\uC18C\uB294 Admiral \uC2DC\uC2A4\uD15C \uD504\uB86C\uD504\uD2B8\uB97C \uC2E3\uC9C0 \uC54A\uB294\uB2E4. \uC704\uC784 \uC804\uC5D0 \uB85C\uC2A4\uD130\uB97C \uC77D\uACE0 \uC815\uCCB4\uC131\uC744\n// \uD540\uD558\uB77C\uB294 \uC9C0\uCE68\uC774 \uC0C1\uC8FC \uD14D\uC2A4\uD2B8\uB85C \uC874\uC7AC\uD558\uC9C0 \uC54A\uC73C\uBBC0\uB85C, \uADF8 \uC5ED\uD560 \uC804\uBD80\uAC00 \uC774 \uC2A4\uD06C\uB9BD\uD2B8\uC5D0 \uC788\uB2E4.\n//\n// \uCCAB \uC778\uC790\uAC00 \uC11C\uBE0C\uCEE4\uB9E8\uB4DC\uB2E4. \uD6C5 \uC774\uBCA4\uD2B8\uB9C8\uB2E4 \uBCC4\uB3C4 \uD30C\uC77C\uC744 \uB450\uC9C0 \uC54A\uB294 \uC774\uC720\uB294 \uC138 \uD310\uC815\uC774 \uAC19\uC740\n// \uC5B4\uD718(\uC815\uCCB4\uC131 \uC774\uB984 / modelId / \uC811\uC218\uC99D)\uB97C \uACF5\uC720\uD558\uAE30 \uB54C\uBB38\uC774\uB2E4 \u2014 \uD30C\uC77C\uC744 \uCABC\uAC1C\uBA74 \uADF8 \uC5B4\uD718\uAC00\n// \uC138 \uACF3\uC5D0\uC11C \uB530\uB85C \uB299\uB294\uB2E4.\n//\n// remind UserPromptSubmit \uB9E4 \uD134 \uADDC\uC57D \uC8FC\uC785 (\uBB34\uC870\uAC74)\n// gate-delegation PreToolUse Agent|Workflow \uD540\uB418\uC9C0 \uC54A\uC740 \uC704\uC784\uC744 \uCC28\uB2E8\n// workflow-receipt PostToolUse Workflow \uC811\uC218\uC99D\uC744 \uACB0\uACFC\uB85C \uC77D\uB294 \uC0AC\uACE0\uB97C \uCC28\uB2E8\n//\n// \uC0C1\uD0DC\uB97C \uB0A8\uAE30\uC9C0 \uC54A\uB294\uB2E4. \uD6C5\uC740 \uD638\uCD9C\uB9C8\uB2E4 \uC0C8 \uD504\uB85C\uC138\uC2A4\uB85C \uB728\uBBC0\uB85C \uD504\uB85C\uC138\uC2A4 \uAC04 \uAE30\uC5B5\uC740 \uD30C\uC77C\uB85C\uB9CC\n// \uAC00\uB2A5\uD55C\uB370, \uADF8 \uD30C\uC77C\uC740 \uACE7 \uC2E0\uC120\uB3C4\xB7\uC815\uB9AC\xB7\uACBD\uD569\uC744 \uB5A0\uC548\uB294 \uB450 \uBC88\uC9F8 \uC9C4\uC2E4\uC774 \uB41C\uB2E4. \uC138 \uD310\uC815 \uBAA8\uB450\n// stdin \uD55C \uBC88\uC73C\uB85C \uB05D\uB098\uB3C4\uB85D \uC9F0\uB2E4 \u2014 \uADF8\uB798\uC11C \uD0C0\uC784\uC544\uC6C3\uC73C\uB85C \uAC8C\uC774\uD2B8\uAC00 \uC870\uC6A9\uD788 \uC5F4\uB9B4 \uC5EC\uC9C0\uB3C4 \uC791\uB2E4.\nimport { readFileSync } from "node:fs";\n\n// \uBAA8\uB378\uC5D0\uAC8C \uC8FC\uB294 \uC9C0\uC2DC\uC774\uBBC0\uB85C \uC601\uC5B4\uB85C \uC4F4\uB2E4.\nconst TURN_REMINDER = [\n "Before any Agent or Workflow run leaves the host, call gateway_models and pin an identity from what it",\n "reports \u2014 allowances move while work is in flight.",\n "Agent: subagent_type = the fleet:* name. Workflow: opts.model = the modelId, the claude-gateway-- prefix",\n "included. The two spellings are never interchangeable.",\n].join(" ");\n\nconst IN_FLIGHT_CONTRACT = [\n "This Workflow call returned a receipt, not a result. The run is still in flight and its result arrives later.",\n "End this turn with one status line: which surface, how many stages, and what you are waiting for.",\n "Do not review, conclude, summarize, or predict what the run will find \u2014 a reading written before the result is",\n "indistinguishable from the result to the reader, and it is still there after the real one lands.",\n "Report the finding once, in the turn the result arrives. If asked before then, say it is still running.",\n].join(" ");\n\nconst PIN_INSTRUCTION = [\n "Call gateway_models first, then pin the identity it reports:",\n "Agent \u2014 subagent_type = the fleet:* name;",\n "Workflow \u2014 opts.model = the modelId with the claude-gateway-- prefix, written as a literal.",\n].join(" ");\n\n/**\n * \uC815\uCCB4\uC131\uC774 \uD540\uB418\uC9C0 \uC54A\uC740 \uC704\uC784\uC73C\uB85C \uCDE8\uAE09\uD558\uB294 Agent \uD0C0\uC785.\n *\n * \uB0B4\uC7A5 \uC804\uBB38 \uC5D0\uC774\uC804\uD2B8(Explore/Plan/\u2026)\uC640 fork\uB294 \uD1B5\uACFC\uC2DC\uD0A8\uB2E4. fork\uB294 \uBD80\uBAA8 \uCEE8\uD14D\uC2A4\uD2B8\uB97C \uC787\uB294 \uAC83\uC774\n * \uBAA9\uC801\uC774\uB77C \uB2E4\uB978 \uBAA8\uB378\uB85C \uC62E\uAE30\uB294 \uAC83 \uC790\uCCB4\uAC00 \uADF8 \uD45C\uBA74\uC758 \uC758\uBBF8\uB97C \uC5C6\uC560\uACE0, \uB098\uBA38\uC9C0\uB294 \uADF8 \uB3C4\uAD6C\uB97C \uC4F0\uB824\uACE0\n * \uACE0\uB978 \uC774\uB984\uC774\uC9C0 \uC704\uC784\uC744 \uBBF8\uB8EC \uACB0\uACFC\uAC00 \uC544\uB2C8\uB2E4. \uC544\uB798 \uB458\uB9CC\uC774 "\uC544\uBB34\uAC83\uB3C4 \uACE0\uB974\uC9C0 \uC54A\uC558\uB2E4"\uC758 \uCCA0\uC790\uB2E4.\n */\nconst UNPINNED_AGENT_TYPES = new Set(["general-purpose", "claude"]);\n\nconst GATEWAY_AGENT_PREFIX = "fleet:";\nconst MODEL_ALIASES = /^(fable|opus|sonnet|haiku)$/;\nconst PREFIXED_ALIAS_RE = /^claude-gateway--(fable|opus|sonnet|haiku)$/;\nconst GATEWAY_MODEL_PREFIX = "claude-gateway--";\nconst AGENT_TYPE_RE = /agentType\\s*:/;\nconst MODEL_VALUE_RE = /model:\\s*[\'"]([^\'"]+)[\'"]/g;\nconst AGENT_CALL_RE = /\\bagent\\s*\\(/g;\n\nfunction block(message) {\n process.stderr.write(`[fleet-gateway-model-guard] ${message}\\n`);\n process.exit(2);\n}\n\nfunction emitContext(hookEventName, additionalContext) {\n process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName, additionalContext } }));\n process.exit(0);\n}\n\nfunction readHookInput() {\n try {\n return JSON.parse(readFileSync(0, "utf8"));\n } catch {\n // \uC785\uB825\uC744 \uC77D\uC9C0 \uBABB\uD558\uBA74 \uD310\uC815\uD560 \uADFC\uAC70\uAC00 \uC5C6\uB2E4. \uCC28\uB2E8\uC740 \uADFC\uAC70\uAC00 \uC788\uC744 \uB54C\uB9CC \uD55C\uB2E4.\n process.exit(0);\n }\n}\n\n/**\n * `agent(` \uD638\uCD9C \uD558\uB098\uAC00 \uCC28\uC9C0\uD558\uB294 \uC6D0\uBB38 \uBC94\uC704. \uAD04\uD638 \uADE0\uD615\uC73C\uB85C \uB05D\uC744 \uCC3E\uB418 \uBB38\uC790\uC5F4\xB7\uC8FC\uC11D \uC548\uC758 \uAD04\uD638\uB294\n * \uC138\uC9C0 \uC54A\uB294\uB2E4 \u2014 \uD504\uB86C\uD504\uD2B8 \uD14D\uC2A4\uD2B8\uC5D0 \uAD04\uD638\uAC00 \uD754\uD574\uC11C, \uC138\uB294 \uC21C\uAC04 \uD638\uCD9C \uACBD\uACC4\uAC00 \uC5C9\uB6B1\uD55C \uACF3\uC5D0\uC11C \uB2EB\uD78C\uB2E4.\n *\n * \uB05D\uC744 \uCC3E\uC9C0 \uBABB\uD558\uBA74 undefined\uB97C \uB3CC\uB824\uC8FC\uACE0 \uD638\uCD9C\uC790\uB294 \uADF8 \uD638\uCD9C\uC744 \uAC80\uC0AC\uD558\uC9C0 \uC54A\uB294\uB2E4. \uC774 \uC2A4\uCE90\uB108\uB294\n * \uD30C\uC11C\uAC00 \uC544\uB2C8\uBBC0\uB85C, \uD310\uC815\uD560 \uC218 \uC5C6\uB294 \uD615\uD0DC\uB97C "\uD540 \uC5C6\uC74C"\uC73C\uB85C \uBAB0\uC544 \uBA40\uCA61\uD55C \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uB9C9\uB294 \uCABD\uC774\n * \uAC80\uC0AC \uD55C \uAC74\uC744 \uB193\uCE58\uB294 \uCABD\uBCF4\uB2E4 \uB098\uC058\uB2E4.\n */\nfunction sliceCall(script, openParenIndex) {\n let depth = 0;\n let quote;\n let escaped = false;\n for (let i = openParenIndex; i < script.length; i += 1) {\n const char = script[i];\n if (quote !== undefined) {\n if (escaped) escaped = false;\n else if (char === "\\\\") escaped = true;\n else if (char === quote) quote = undefined;\n continue;\n }\n if (char === "\'" || char === \'"\' || char === "`") {\n quote = char;\n continue;\n }\n if (char === "/" && script[i + 1] === "/") {\n const lineEnd = script.indexOf("\\n", i);\n if (lineEnd === -1) return undefined;\n i = lineEnd;\n continue;\n }\n if (char === "/" && script[i + 1] === "*") {\n const blockEnd = script.indexOf("*/", i + 2);\n if (blockEnd === -1) return undefined;\n i = blockEnd + 1;\n continue;\n }\n if (char === "(") depth += 1;\n else if (char === ")") {\n depth -= 1;\n if (depth === 0) return script.slice(openParenIndex, i + 1);\n }\n }\n return undefined;\n}\n\n/** model \uC635\uC158\uC774 \uC5C6\uB294 `agent(` \uD638\uCD9C\uC758 \uAC1C\uC218. \uACBD\uACC4\uB97C \uBABB \uC77D\uC740 \uD638\uCD9C\uC740 \uC138\uC9C0 \uC54A\uB294\uB2E4. */\nfunction countUnpinnedAgentCalls(script) {\n let unpinned = 0;\n for (const match of script.matchAll(AGENT_CALL_RE)) {\n const call = sliceCall(script, match.index + match[0].length - 1);\n if (call === undefined) continue;\n if (!/\\bmodel\\s*:/.test(call)) unpinned += 1;\n }\n return unpinned;\n}\n\nfunction assertWorkflowModelValues(script) {\n for (const match of script.matchAll(MODEL_VALUE_RE)) {\n const value = match[1];\n if (MODEL_ALIASES.test(value)) continue;\n if (PREFIXED_ALIAS_RE.test(value)) {\n block(\n `lineage alias\uC5D0\uB294 claude-gateway-- prefix\uB97C \uBD99\uC774\uBA74 \uC548 \uB429\uB2C8\uB2E4: "${value}". ` +\n "alias\uB294 \uADF8\uB300\uB85C(fable|opus|sonnet|haiku) \uC0AC\uC6A9\uD558\uC138\uC694."\n );\n }\n if (value.startsWith(GATEWAY_MODEL_PREFIX)) continue;\n block(\n `opts.model \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: "${value}". gateway_models\uC758 modelId(claude-gateway-- prefix \uD3EC\uD568)\uB97C ` +\n "\uADF8\uB300\uB85C \uBCF5\uC0AC\uD558\uAC70\uB098 lineage alias(fable|opus|sonnet|haiku)\uB97C \uC0AC\uC6A9\uD558\uC138\uC694."\n );\n }\n}\n\n/** \uAC80\uC0AC \uB300\uC0C1 \uC2A4\uD06C\uB9BD\uD2B8 \uC6D0\uBB38. \uBCFC \uC218 \uC5C6\uB294 \uD638\uCD9C \uD615\uD0DC\uB294 undefined\uB97C \uB3CC\uB824\uC900\uB2E4. */\nfunction resolveWorkflowScript(toolInput) {\n if (typeof toolInput.script === "string" && toolInput.script.length > 0) return toolInput.script;\n // resumeFromRunId \uC7AC\uC2E4\uD589\uC740 scriptPath\uB85C \uB4E4\uC5B4\uC628\uB2E4. \uD30C\uC77C\uC744 \uC77D\uC5B4 \uB3D9\uC77C\uD558\uAC8C \uAC80\uC99D\uD55C\uB2E4.\n if (typeof toolInput.scriptPath === "string" && toolInput.scriptPath.length > 0) {\n try {\n return readFileSync(toolInput.scriptPath, "utf8");\n } catch {\n // \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC73C\uBA74 \uC2E4\uD589 \uB2E8\uACC4\uC5D0\uC11C \uB4DC\uB7EC\uB098\uB294 \uC624\uB958\uB2E4. \uC5EC\uAE30\uC11C\uB294 \uD310\uC815\uD558\uC9C0 \uC54A\uB294\uB2E4.\n return undefined;\n }\n }\n // name(\uC800\uC7A5 \uC6CC\uD06C\uD50C\uB85C\uC6B0)\uC740 \uB0B4\uC6A9\uC744 \uBCFC \uC218 \uC5C6\uB2E4. \uC0AC\uC804 \uAC80\uC99D\uB41C \uAC83\uC73C\uB85C \uC2E0\uB8B0\uD55C\uB2E4.\n return undefined;\n}\n\nfunction gateAgentDelegation(toolInput) {\n const agentType = typeof toolInput.subagent_type === "string" ? toolInput.subagent_type : undefined;\n if (agentType !== undefined && agentType.startsWith(GATEWAY_AGENT_PREFIX)) process.exit(0);\n if (agentType !== undefined && !UNPINNED_AGENT_TYPES.has(agentType)) process.exit(0);\n block(\n `\uC774 \uC704\uC784\uC740 \uC815\uCCB4\uC131\uC774 \uD540\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4(subagent_type: ${agentType ?? "\uBBF8\uC9C0\uC815"}). ` +\n PIN_INSTRUCTION\n );\n}\n\nfunction gateWorkflowDelegation(toolInput) {\n const script = resolveWorkflowScript(toolInput);\n if (script === undefined) process.exit(0);\n if (AGENT_TYPE_RE.test(script)) {\n block(\n "dynamic workflow \uC2A4\uD06C\uB9BD\uD2B8\uC5D0 agentType\uC774 \uAE08\uC9C0\uB429\uB2C8\uB2E4. agentType\uC740 \uD300\uBA54\uC774\uD2B8/\uC11C\uBE0C\uC5D0\uC774\uC804\uD2B8 \uD45C\uBA74 \uC804\uC6A9\uC774\uACE0, " +\n "\uC6CC\uD06C\uD50C\uB85C\uC6B0\uB294 opts.model\uB85C\uB9CC \uD32C\uC544\uC6C3\uD574\uC57C \uD569\uB2C8\uB2E4."\n );\n }\n const unpinned = countUnpinnedAgentCalls(script);\n if (unpinned > 0) {\n block(\n `model\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 agent() \uD638\uCD9C\uC774 ${unpinned}\uAC74 \uC788\uC2B5\uB2C8\uB2E4. ` +\n PIN_INSTRUCTION +\n " \uC2A4\uD14C\uC774\uC9C0\uB9C8\uB2E4 \uBAA8\uB378\uC744 \uB098\uB204\uB294 \uAC83\uC774 \uC774 \uD45C\uBA74\uC758 \uBAA9\uC801\uC774\uBBC0\uB85C, \uD55C \uAC12\uC73C\uB85C \uCC44\uC6B0\uC9C0 \uB9D0\uACE0 \uC5ED\uD560\uBCC4\uB85C \uBC30\uBD84\uD558\uC138\uC694."\n );\n }\n assertWorkflowModelValues(script);\n process.exit(0);\n}\n\nconst subcommand = process.argv[2];\n\nif (subcommand === "remind") {\n emitContext("UserPromptSubmit", TURN_REMINDER);\n}\n\nconst input = readHookInput();\nconst toolName = input?.tool_name;\nconst toolInput = input?.tool_input ?? {};\n\nif (subcommand === "workflow-receipt") {\n if (toolName !== "Workflow") process.exit(0);\n emitContext("PostToolUse", IN_FLIGHT_CONTRACT);\n}\n\nif (subcommand === "gate-delegation") {\n if (toolName === "Agent") gateAgentDelegation(toolInput);\n if (toolName === "Workflow") gateWorkflowDelegation(toolInput);\n process.exit(0);\n}\n\nprocess.exit(0);\n' }
34984
+ { relativePath: "fleet-gateway-model-guard.mjs", content: '#!/usr/bin/env node\n// Fleet gateway model guard \u2014 \uAC8C\uC774\uD2B8\uC6E8\uC774 \uC138\uC158\uC758 \uC704\uC784 \uC815\uCC45\uC744 \uCF54\uB4DC\uB85C \uAC15\uC81C\uD558\uB294 \uB2E8\uC77C \uD6C5.\n//\n// \uC774 \uC800\uC7A5\uC18C\uB294 Admiral \uC2DC\uC2A4\uD15C \uD504\uB86C\uD504\uD2B8\uB97C \uC2E3\uC9C0 \uC54A\uB294\uB2E4. \uC704\uC784 \uC804\uC5D0 \uB85C\uC2A4\uD130\uB97C \uC77D\uACE0 \uC815\uCCB4\uC131\uC744\n// \uD540\uD558\uB77C\uB294 \uC9C0\uCE68\uC774 \uC0C1\uC8FC \uD14D\uC2A4\uD2B8\uB85C \uC874\uC7AC\uD558\uC9C0 \uC54A\uC73C\uBBC0\uB85C, \uADF8 \uC5ED\uD560 \uC804\uBD80\uAC00 \uC774 \uC2A4\uD06C\uB9BD\uD2B8\uC5D0 \uC788\uB2E4.\n//\n// \uCCAB \uC778\uC790\uAC00 \uC11C\uBE0C\uCEE4\uB9E8\uB4DC\uB2E4. \uD6C5 \uC774\uBCA4\uD2B8\uB9C8\uB2E4 \uBCC4\uB3C4 \uD30C\uC77C\uC744 \uB450\uC9C0 \uC54A\uB294 \uC774\uC720\uB294 \uC138 \uD310\uC815\uC774 \uAC19\uC740\n// \uC5B4\uD718(\uC815\uCCB4\uC131 \uC774\uB984 / modelId / \uC811\uC218\uC99D)\uB97C \uACF5\uC720\uD558\uAE30 \uB54C\uBB38\uC774\uB2E4 \u2014 \uD30C\uC77C\uC744 \uCABC\uAC1C\uBA74 \uADF8 \uC5B4\uD718\uAC00\n// \uC138 \uACF3\uC5D0\uC11C \uB530\uB85C \uB299\uB294\uB2E4.\n//\n// remind UserPromptSubmit \uB9E4 \uD134 \uADDC\uC57D \uC8FC\uC785 (\uBB34\uC870\uAC74)\n// gate-delegation PreToolUse Agent|Workflow Agent\uC758 \uD540 \uB204\uB77D\uACFC workflow\uC758 \uD2C0\uB9B0 \uBAA8\uB378 \uCCA0\uC790\uB97C \uCC28\uB2E8\n// workflow-receipt PostToolUse Workflow \uC811\uC218\uC99D\uC744 \uACB0\uACFC\uB85C \uC77D\uB294 \uC0AC\uACE0\uB97C \uCC28\uB2E8\n//\n// \uC0C1\uD0DC\uB97C \uB0A8\uAE30\uC9C0 \uC54A\uB294\uB2E4. \uD6C5\uC740 \uD638\uCD9C\uB9C8\uB2E4 \uC0C8 \uD504\uB85C\uC138\uC2A4\uB85C \uB728\uBBC0\uB85C \uD504\uB85C\uC138\uC2A4 \uAC04 \uAE30\uC5B5\uC740 \uD30C\uC77C\uB85C\uB9CC\n// \uAC00\uB2A5\uD55C\uB370, \uADF8 \uD30C\uC77C\uC740 \uACE7 \uC2E0\uC120\uB3C4\xB7\uC815\uB9AC\xB7\uACBD\uD569\uC744 \uB5A0\uC548\uB294 \uB450 \uBC88\uC9F8 \uC9C4\uC2E4\uC774 \uB41C\uB2E4. \uC138 \uD310\uC815 \uBAA8\uB450\n// stdin \uD55C \uBC88\uC73C\uB85C \uB05D\uB098\uB3C4\uB85D \uC9F0\uB2E4 \u2014 \uADF8\uB798\uC11C \uD0C0\uC784\uC544\uC6C3\uC73C\uB85C \uAC8C\uC774\uD2B8\uAC00 \uC870\uC6A9\uD788 \uC5F4\uB9B4 \uC5EC\uC9C0\uB3C4 \uC791\uB2E4.\nimport { readFileSync } from "node:fs";\n\n// \uBAA8\uB378\uC5D0\uAC8C \uC8FC\uB294 \uC9C0\uC2DC\uC774\uBBC0\uB85C \uC601\uC5B4\uB85C \uC4F4\uB2E4.\nconst TURN_REMINDER = [\n "Call gateway_models before a run leaves the host and pin from what that call reports \u2014 allowances and the",\n "roster itself move while work is in flight, so a remembered name is not evidence that it still resolves.",\n "Agent: subagent_type = the fleet:* name, always.",\n "A Workflow stage may stay on the host model; when you do move one, pin it from that same lookup \u2014",\n "opts.model takes the modelId with the claude-gateway-- prefix, opts.agentType takes the fleet:* name.",\n "The spellings are never interchangeable.",\n].join(" ");\n\nconst IN_FLIGHT_CONTRACT = [\n "This Workflow call returned a receipt, not a result. The run is still in flight and its result arrives later.",\n "End this turn with one status line: which surface, how many stages, and what you are waiting for.",\n "Do not review, conclude, summarize, or predict what the run will find \u2014 a reading written before the result is",\n "indistinguishable from the result to the reader, and it is still there after the real one lands.",\n "Report the finding once, in the turn the result arrives. If asked before then, say it is still running.",\n].join(" ");\n\nconst PIN_INSTRUCTION =\n "Call gateway_models first, then pin the identity it reports: subagent_type = the fleet:* name.";\n\n/**\n * \uC815\uCCB4\uC131\uC774 \uD540\uB418\uC9C0 \uC54A\uC740 \uC704\uC784\uC73C\uB85C \uCDE8\uAE09\uD558\uB294 Agent \uD0C0\uC785.\n *\n * \uB0B4\uC7A5 \uC804\uBB38 \uC5D0\uC774\uC804\uD2B8(Explore/Plan/\u2026)\uC640 fork\uB294 \uD1B5\uACFC\uC2DC\uD0A8\uB2E4. fork\uB294 \uBD80\uBAA8 \uCEE8\uD14D\uC2A4\uD2B8\uB97C \uC787\uB294 \uAC83\uC774\n * \uBAA9\uC801\uC774\uB77C \uB2E4\uB978 \uBAA8\uB378\uB85C \uC62E\uAE30\uB294 \uAC83 \uC790\uCCB4\uAC00 \uADF8 \uD45C\uBA74\uC758 \uC758\uBBF8\uB97C \uC5C6\uC560\uACE0, \uB098\uBA38\uC9C0\uB294 \uADF8 \uB3C4\uAD6C\uB97C \uC4F0\uB824\uACE0\n * \uACE0\uB978 \uC774\uB984\uC774\uC9C0 \uC704\uC784\uC744 \uBBF8\uB8EC \uACB0\uACFC\uAC00 \uC544\uB2C8\uB2E4. \uC544\uB798 \uB458\uB9CC\uC774 "\uC544\uBB34\uAC83\uB3C4 \uACE0\uB974\uC9C0 \uC54A\uC558\uB2E4"\uC758 \uCCA0\uC790\uB2E4.\n */\nconst UNPINNED_AGENT_TYPES = new Set(["general-purpose", "claude"]);\n\nconst GATEWAY_AGENT_PREFIX = "fleet:";\nconst MODEL_ALIASES = /^(fable|opus|sonnet|haiku)$/;\nconst PREFIXED_ALIAS_RE = /^claude-gateway--(fable|opus|sonnet|haiku)$/;\nconst GATEWAY_MODEL_PREFIX = "claude-gateway--";\n// \uCF5C\uB860 \uC55E \uACF5\uBC31\uC740 \uC720\uD6A8\uD55C \uD504\uB85C\uD37C\uD2F0 \uD45C\uAE30\uB2E4. \uC815\uADDC\uC2DD\uC774 \uC815\uADDC \uD45C\uAE30\uB9CC \uC54C\uBA74 \uADF8 \uD55C \uCE78\uC774 \uAC80\uC0AC\uB97C \uBE44\uCF1C\uAC04\uB2E4.\nconst MODEL_VALUE_RE = /model\\s*:\\s*[\'"]([^\'"]+)[\'"]/g;\nconst AGENT_TYPE_VALUE_RE = /agentType\\s*:\\s*[\'"]([^\'"]+)[\'"]/g;\n\nfunction block(message) {\n process.stderr.write(`[fleet-gateway-model-guard] ${message}\\n`);\n process.exit(2);\n}\n\nfunction emitContext(hookEventName, additionalContext) {\n process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName, additionalContext } }));\n process.exit(0);\n}\n\nfunction readHookInput() {\n try {\n return JSON.parse(readFileSync(0, "utf8"));\n } catch {\n // \uC785\uB825\uC744 \uC77D\uC9C0 \uBABB\uD558\uBA74 \uD310\uC815\uD560 \uADFC\uAC70\uAC00 \uC5C6\uB2E4. \uCC28\uB2E8\uC740 \uADFC\uAC70\uAC00 \uC788\uC744 \uB54C\uB9CC \uD55C\uB2E4.\n process.exit(0);\n }\n}\n\n/**\n * \uC6CC\uD06C\uD50C\uB85C\uC6B0\uAC00 \uC4F4 \uBAA8\uB378 \uAC12\uC758 \uCCA0\uC790 \uAC80\uC0AC.\n *\n * \uC2A4\uD14C\uC774\uC9C0\uB97C \uC62E\uAE38\uC9C0 \uB9D0\uC9C0\uB294 \uD638\uC2A4\uD2B8\uAC00 \uC815\uD55C\uB2E4 \u2014 \uD540\uD558\uC9C0 \uC54A\uC740 \uC2A4\uD14C\uC774\uC9C0\uB294 \uC138\uC158 \uBAA8\uB378\uB85C \uB3CC\uBA74 \uADF8\uB9CC\uC774\uB2E4.\n * \uC5EC\uAE30\uC11C \uB9C9\uB294 \uAC83\uC740 \uC62E\uAE30\uAE30\uB85C \uD574\uB193\uACE0 \uAC12\uC744 \uC798\uBABB \uC4F4 \uACBD\uC6B0\uBFD0\uC774\uB2E4. \uB85C\uC2A4\uD130 \uC774\uB984\uC774\uB098 prefix\uAC00 \uBE60\uC9C4\n * modelId\uAC00 `model` \uC790\uB9AC\uC5D0 \uB4E4\uC5B4\uAC00\uBA74 \uBAA8\uB4E0 \uBD84\uAE30\uAC00 \uC2DC\uC791 \uC989\uC2DC \uC8FD\uC73C\uBBC0\uB85C, \uADF8 \uC2E4\uD328\uB294 \uC2E4\uD589 \uC804\uC5D0 \uC7A1\uB294\n * \uD3B8\uC774 \uD6E8\uC52C \uC2F8\uB2E4.\n */\nfunction assertWorkflowModelValues(script) {\n for (const match of script.matchAll(MODEL_VALUE_RE)) {\n const value = match[1];\n if (MODEL_ALIASES.test(value)) continue;\n if (PREFIXED_ALIAS_RE.test(value)) {\n block(\n `lineage alias\uC5D0\uB294 claude-gateway-- prefix\uB97C \uBD99\uC774\uBA74 \uC548 \uB429\uB2C8\uB2E4: "${value}". ` +\n "alias\uB294 \uADF8\uB300\uB85C(fable|opus|sonnet|haiku) \uC0AC\uC6A9\uD558\uC138\uC694."\n );\n }\n if (value.startsWith(GATEWAY_MODEL_PREFIX)) continue;\n block(\n `opts.model \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: "${value}". gateway_models\uC758 modelId(claude-gateway-- prefix \uD3EC\uD568)\uB97C ` +\n "\uADF8\uB300\uB85C \uBCF5\uC0AC\uD558\uAC70\uB098 lineage alias(fable|opus|sonnet|haiku)\uB97C \uC0AC\uC6A9\uD558\uC138\uC694. " +\n "fleet:* \uC774\uB984\uC740 opts.agentType \uC790\uB9AC\uC785\uB2C8\uB2E4."\n );\n }\n}\n\n/**\n * \uC774\uB984 \uC790\uB9AC\uC5D0 \uB4E4\uC5B4\uAC04 modelId. \uB450 \uCCA0\uC790\uB97C \uB9DE\uBC14\uAFBC \uB098\uBA38\uC9C0 \uC808\uBC18\uC774\uB2E4.\n *\n * `fleet:` \uC811\uB450\uB9CC \uD1B5\uACFC\uC2DC\uD0A4\uC9C0\uB294 \uC54A\uB294\uB2E4 \u2014 `general-purpose`\uCC98\uB7FC \uC774 \uC800\uC7A5\uC18C\uAC00 \uC2E3\uC9C0 \uC54A\uC740 \uB0B4\uC7A5\n * agentType\uB3C4 \uADF8 \uC790\uB9AC\uC758 \uC815\uB2F9\uD55C \uAC12\uC774\uB77C, \uC811\uB450\uB85C \uAC70\uB974\uBA74 \uBA40\uCA61\uD55C \uC2A4\uD06C\uB9BD\uD2B8\uAC00 \uB9C9\uD78C\uB2E4. modelId\uB9CC\n * \uACE8\uB77C \uB9C9\uB294\uB2E4: \uADF8 \uAC12\uC740 \uC5B4\uB5A4 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0\uB3C4 \uC774\uB984\uC73C\uB85C \uB4F1\uB85D\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC544 \uBC18\uB4DC\uC2DC \uC8FD\uB294\uB2E4.\n */\nfunction assertWorkflowAgentTypeValues(script) {\n for (const match of script.matchAll(AGENT_TYPE_VALUE_RE)) {\n const value = match[1];\n if (!value.startsWith(GATEWAY_MODEL_PREFIX)) continue;\n block(\n `opts.agentType \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: "${value}". modelId\uB294 opts.model \uC790\uB9AC\uC774\uACE0, ` +\n "agentType\uC5D0\uB294 gateway_models\uAC00 \uBCF4\uACE0\uD55C fleet:* \uC774\uB984\uC744 \uC501\uB2C8\uB2E4."\n );\n }\n}\n\n/** \uAC80\uC0AC \uB300\uC0C1 \uC2A4\uD06C\uB9BD\uD2B8 \uC6D0\uBB38. \uBCFC \uC218 \uC5C6\uB294 \uD638\uCD9C \uD615\uD0DC\uB294 undefined\uB97C \uB3CC\uB824\uC900\uB2E4. */\nfunction resolveWorkflowScript(toolInput) {\n if (typeof toolInput.script === "string" && toolInput.script.length > 0) return toolInput.script;\n // resumeFromRunId \uC7AC\uC2E4\uD589\uC740 scriptPath\uB85C \uB4E4\uC5B4\uC628\uB2E4. \uD30C\uC77C\uC744 \uC77D\uC5B4 \uB3D9\uC77C\uD558\uAC8C \uAC80\uC99D\uD55C\uB2E4.\n if (typeof toolInput.scriptPath === "string" && toolInput.scriptPath.length > 0) {\n try {\n return readFileSync(toolInput.scriptPath, "utf8");\n } catch {\n // \uD30C\uC77C\uC744 \uC77D\uC744 \uC218 \uC5C6\uC73C\uBA74 \uC2E4\uD589 \uB2E8\uACC4\uC5D0\uC11C \uB4DC\uB7EC\uB098\uB294 \uC624\uB958\uB2E4. \uC5EC\uAE30\uC11C\uB294 \uD310\uC815\uD558\uC9C0 \uC54A\uB294\uB2E4.\n return undefined;\n }\n }\n // name(\uC800\uC7A5 \uC6CC\uD06C\uD50C\uB85C\uC6B0)\uC740 \uB0B4\uC6A9\uC744 \uBCFC \uC218 \uC5C6\uB2E4. \uC0AC\uC804 \uAC80\uC99D\uB41C \uAC83\uC73C\uB85C \uC2E0\uB8B0\uD55C\uB2E4.\n return undefined;\n}\n\nfunction gateAgentDelegation(toolInput) {\n const agentType = typeof toolInput.subagent_type === "string" ? toolInput.subagent_type : undefined;\n if (agentType !== undefined && agentType.startsWith(GATEWAY_AGENT_PREFIX)) process.exit(0);\n if (agentType !== undefined && !UNPINNED_AGENT_TYPES.has(agentType)) process.exit(0);\n block(\n `\uC774 \uC704\uC784\uC740 \uC815\uCCB4\uC131\uC774 \uD540\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4(subagent_type: ${agentType ?? "\uBBF8\uC9C0\uC815"}). ` +\n PIN_INSTRUCTION\n );\n}\n\nfunction gateWorkflowDelegation(toolInput) {\n const script = resolveWorkflowScript(toolInput);\n if (script === undefined) process.exit(0);\n assertWorkflowModelValues(script);\n assertWorkflowAgentTypeValues(script);\n process.exit(0);\n}\n\nconst subcommand = process.argv[2];\n\nif (subcommand === "remind") {\n emitContext("UserPromptSubmit", TURN_REMINDER);\n}\n\nconst input = readHookInput();\nconst toolName = input?.tool_name;\nconst toolInput = input?.tool_input ?? {};\n\nif (subcommand === "workflow-receipt") {\n if (toolName !== "Workflow") process.exit(0);\n emitContext("PostToolUse", IN_FLIGHT_CONTRACT);\n}\n\nif (subcommand === "gate-delegation") {\n if (toolName === "Agent") gateAgentDelegation(toolInput);\n if (toolName === "Workflow") gateWorkflowDelegation(toolInput);\n process.exit(0);\n}\n\nprocess.exit(0);\n' }
34663
34985
  ];
34664
34986
  var DIR_MODE = 448;
34665
34987
  var FILE_MODE = 384;
@@ -48950,17 +49272,17 @@ function createSystemFontsService(deps = {}) {
48950
49272
  const now = deps.now ?? Date.now;
48951
49273
  const successTtlMs = deps.successTtlMs ?? SUCCESS_TTL_MS;
48952
49274
  const failureTtlMs = deps.failureTtlMs ?? FAILURE_TTL_MS;
48953
- let cached2 = null;
49275
+ let cached3 = null;
48954
49276
  let cachedFailure = null;
48955
49277
  let inFlight = null;
48956
49278
  const getFonts = () => {
48957
- if (cached2 && now() - cached2.cachedAt < successTtlMs) return Promise.resolve(cached2.fonts);
49279
+ if (cached3 && now() - cached3.cachedAt < successTtlMs) return Promise.resolve(cached3.fonts);
48958
49280
  if (cachedFailure && now() - cachedFailure.cachedAt < failureTtlMs) return Promise.reject(cachedFailure.error);
48959
49281
  if (inFlight) return inFlight;
48960
49282
  inFlight = loadFonts().then((fonts) => {
48961
49283
  const normalized = normalizeSystemFonts(fonts);
48962
49284
  if (normalized.length === 0) throw EMPTY_SYSTEM_FONTS_ERROR;
48963
- cached2 = { fonts: normalized, cachedAt: now() };
49285
+ cached3 = { fonts: normalized, cachedAt: now() };
48964
49286
  cachedFailure = null;
48965
49287
  return normalized;
48966
49288
  }).catch((error51) => {
@@ -52161,8 +52483,8 @@ function createCodexGateway(deps) {
52161
52483
  return cachedAccessSets(`listener|${listener.origin}`, () => buildListenerAccessSets(listener));
52162
52484
  }
52163
52485
  function cachedAccessSets(key, build) {
52164
- const cached2 = accessSetsByGate.get(key);
52165
- if (cached2) return cached2;
52486
+ const cached3 = accessSetsByGate.get(key);
52487
+ if (cached3) return cached3;
52166
52488
  const sets = build();
52167
52489
  accessSetsByGate.set(key, sets);
52168
52490
  return sets;
@@ -54100,8 +54422,8 @@ function filterDiscoveredPlugins(plugins) {
54100
54422
  }
54101
54423
  var pluginBundleModules = /* @__PURE__ */ new Map();
54102
54424
  function importPluginBundleOnce(digest, bundledPath) {
54103
- const cached2 = pluginBundleModules.get(digest);
54104
- if (cached2) return cached2;
54425
+ const cached3 = pluginBundleModules.get(digest);
54426
+ if (cached3) return cached3;
54105
54427
  const loading = import(pathToFileURL(bundledPath).href);
54106
54428
  pluginBundleModules.set(digest, loading);
54107
54429
  return loading;
@@ -55347,12 +55669,12 @@ function createConsoleUpdateCheckService(deps = {}) {
55347
55669
  const intervalMs = deps.intervalMs ?? UPDATE_CHECK_INTERVAL_MS;
55348
55670
  const startInterval = deps.setInterval ?? ((callback, delayMs) => setInterval(callback, delayMs));
55349
55671
  const stopInterval = deps.clearInterval ?? ((interval2) => clearInterval(interval2));
55350
- let cached2 = null;
55672
+ let cached3 = null;
55351
55673
  let inFlight = null;
55352
55674
  let interval = null;
55353
55675
  const changeListeners = /* @__PURE__ */ new Set();
55354
55676
  const getStatus = () => {
55355
- const current = cached2;
55677
+ const current = cached3;
55356
55678
  if (current && now() - current.checkedAt < current.ttlMs) {
55357
55679
  return current.status;
55358
55680
  }
@@ -55360,7 +55682,7 @@ function createConsoleUpdateCheckService(deps = {}) {
55360
55682
  return current?.status ?? NO_UPDATE_STATUS;
55361
55683
  };
55362
55684
  const refresh = async (options = {}) => {
55363
- const current = cached2;
55685
+ const current = cached3;
55364
55686
  if (options.force !== true && current && now() - current.checkedAt < current.ttlMs) {
55365
55687
  return current.status;
55366
55688
  }
@@ -55368,12 +55690,12 @@ function createConsoleUpdateCheckService(deps = {}) {
55368
55690
  return inFlight;
55369
55691
  }
55370
55692
  inFlight = resolveUpdateStatus().then((status2) => {
55371
- const previousStatus = cached2?.status ?? NO_UPDATE_STATUS;
55372
- cached2 = { status: status2, checkedAt: now(), ttlMs };
55693
+ const previousStatus = cached3?.status ?? NO_UPDATE_STATUS;
55694
+ cached3 = { status: status2, checkedAt: now(), ttlMs };
55373
55695
  notifyIfChanged(previousStatus, status2);
55374
55696
  return status2;
55375
55697
  }).catch(() => {
55376
- cached2 = { status: NO_UPDATE_STATUS, checkedAt: now(), ttlMs: errorTtlMs };
55698
+ cached3 = { status: NO_UPDATE_STATUS, checkedAt: now(), ttlMs: errorTtlMs };
55377
55699
  return NO_UPDATE_STATUS;
55378
55700
  }).finally(() => {
55379
55701
  inFlight = null;