@dotobokuri/fleet-console 1.69.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 (63) hide show
  1. package/dist/client/assets/{_baseUniq-BPBd-J9P.js → _baseUniq-81Y5kFtp.js} +1 -1
  2. package/dist/client/assets/{arc-spHqy4X3.js → arc-d96Fgk-5.js} +1 -1
  3. package/dist/client/assets/{architectureDiagram-Q4EWVU46-7CHqKfxu.js → architectureDiagram-Q4EWVU46-BBgIklLp.js} +1 -1
  4. package/dist/client/assets/{blockDiagram-DXYQGD6D-YasFDgl_.js → blockDiagram-DXYQGD6D-BCjY9dJk.js} +1 -1
  5. package/dist/client/assets/{c4Diagram-AHTNJAMY-CcoPJq56.js → c4Diagram-AHTNJAMY-BVJRdf8q.js} +1 -1
  6. package/dist/client/assets/channel-CiSQi5S5.js +1 -0
  7. package/dist/client/assets/{chunk-4BX2VUAB-MYBJn9BE.js → chunk-4BX2VUAB-CT7BCzBg.js} +1 -1
  8. package/dist/client/assets/{chunk-4TB4RGXK-C1wg6GR_.js → chunk-4TB4RGXK-DUbDaHiY.js} +1 -1
  9. package/dist/client/assets/{chunk-55IACEB6-BoufMT1O.js → chunk-55IACEB6-C7HDwq0R.js} +1 -1
  10. package/dist/client/assets/{chunk-EDXVE4YY-BzAhAIl3.js → chunk-EDXVE4YY-Mh16Bf7t.js} +1 -1
  11. package/dist/client/assets/{chunk-FMBD7UC4-yVrLsKzP.js → chunk-FMBD7UC4-D3BjqAun.js} +1 -1
  12. package/dist/client/assets/{chunk-OYMX7WX6-YiiKaqRQ.js → chunk-OYMX7WX6-DmzxPT1k.js} +1 -1
  13. package/dist/client/assets/{chunk-QZHKN3VN-CqWQlGHT.js → chunk-QZHKN3VN-CaZdQK6Z.js} +1 -1
  14. package/dist/client/assets/{chunk-YZCP3GAM-9yLOmU5k.js → chunk-YZCP3GAM-Q2hrlgLY.js} +1 -1
  15. package/dist/client/assets/classDiagram-6PBFFD2Q-Cy-ZC6xF.js +1 -0
  16. package/dist/client/assets/classDiagram-v2-HSJHXN6E-Cy-ZC6xF.js +1 -0
  17. package/dist/client/assets/clone-BAhE6Fq8.js +1 -0
  18. package/dist/client/assets/{cose-bilkent-S5V4N54A-XkTuSq7v.js → cose-bilkent-S5V4N54A-CPdIsNiQ.js} +1 -1
  19. package/dist/client/assets/{dagre-KV5264BT-DyzXIEAe.js → dagre-KV5264BT-BYWdUXO0.js} +1 -1
  20. package/dist/client/assets/{diagram-5BDNPKRD-DF24YlCa.js → diagram-5BDNPKRD-BC8rqmOK.js} +1 -1
  21. package/dist/client/assets/{diagram-G4DWMVQ6-CVhcj9RK.js → diagram-G4DWMVQ6-CES6iBQQ.js} +1 -1
  22. package/dist/client/assets/{diagram-MMDJMWI5-C-kGKk4K.js → diagram-MMDJMWI5-BfhQrSaN.js} +1 -1
  23. package/dist/client/assets/{diagram-TYMM5635-mr285WbR.js → diagram-TYMM5635-C2FgHNxP.js} +1 -1
  24. package/dist/client/assets/{erDiagram-SMLLAGMA-BtEx-XlU.js → erDiagram-SMLLAGMA-KQgKZTcf.js} +1 -1
  25. package/dist/client/assets/{flowDiagram-DWJPFMVM-DuWy3xzN.js → flowDiagram-DWJPFMVM-7Ytk1sX_.js} +1 -1
  26. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-B2-xEikU.js → ganttDiagram-T4ZO3ILL-C4yl6vGV.js} +1 -1
  27. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-EM17u_t7.js → gitGraphDiagram-UUTBAWPF-DyN7iLk4.js} +1 -1
  28. package/dist/client/assets/{graph-xuE12FIq.js → graph-BsOHL3Ty.js} +1 -1
  29. package/dist/client/assets/index-2049WCXu.css +1 -0
  30. package/dist/client/assets/index-DJcpFTNB.js +466 -0
  31. package/dist/client/assets/{infoDiagram-42DDH7IO-B3MF4XtW.js → infoDiagram-42DDH7IO-BIOEjyDP.js} +1 -1
  32. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-DoQ2mGyh.js → ishikawaDiagram-UXIWVN3A-C18t-DEH.js} +1 -1
  33. package/dist/client/assets/{journeyDiagram-VCZTEJTY-GeR9sFH-.js → journeyDiagram-VCZTEJTY-BysZXCkq.js} +1 -1
  34. package/dist/client/assets/{kanban-definition-6JOO6SKY-DrrYMuvL.js → kanban-definition-6JOO6SKY-Zdulrt1W.js} +1 -1
  35. package/dist/client/assets/{layout-DH63A-3u.js → layout-DhT9CiMw.js} +1 -1
  36. package/dist/client/assets/{linear-BIjE6zB1.js → linear-DQna1rOZ.js} +1 -1
  37. package/dist/client/assets/{mermaid.core-yrrC2Lqo.js → mermaid.core-C0sjt4NJ.js} +4 -4
  38. package/dist/client/assets/{min-CR-H8E6U.js → min-Dyx0ykEh.js} +1 -1
  39. package/dist/client/assets/{mindmap-definition-QFDTVHPH-BzSC43J-.js → mindmap-definition-QFDTVHPH-BzEvAUNd.js} +1 -1
  40. package/dist/client/assets/{pieDiagram-DEJITSTG-BdghNtCc.js → pieDiagram-DEJITSTG-Cd4ORVnw.js} +1 -1
  41. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-s_zN2epw.js → quadrantDiagram-34T5L4WZ-CvNxhBIm.js} +1 -1
  42. package/dist/client/assets/{requirementDiagram-MS252O5E-DuiGG6Tx.js → requirementDiagram-MS252O5E-CuGuie-o.js} +1 -1
  43. package/dist/client/assets/{sankeyDiagram-XADWPNL6-Bp0JBk2g.js → sankeyDiagram-XADWPNL6-zn7buHsU.js} +1 -1
  44. package/dist/client/assets/{sequenceDiagram-FGHM5R23-AzQ3M31V.js → sequenceDiagram-FGHM5R23-BxDReh8o.js} +1 -1
  45. package/dist/client/assets/{stateDiagram-FHFEXIEX-BGgm44ev.js → stateDiagram-FHFEXIEX-DtZ0UE1G.js} +1 -1
  46. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-aYct9Owm.js +1 -0
  47. package/dist/client/assets/{timeline-definition-GMOUNBTQ-UqfsiBJY.js → timeline-definition-GMOUNBTQ-DfKveVha.js} +1 -1
  48. package/dist/client/assets/{vennDiagram-DHZGUBPP-PsCGF9nR.js → vennDiagram-DHZGUBPP-CZe6StT_.js} +1 -1
  49. package/dist/client/assets/{wardley-RL74JXVD-BDQbnh-d.js → wardley-RL74JXVD-B10WfMsc.js} +1 -1
  50. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-CtVA1JMs.js → wardleyDiagram-NUSXRM2D-DzN04fy9.js} +1 -1
  51. package/dist/client/assets/{xychartDiagram-5P7HB3ND-BsLlZWbc.js → xychartDiagram-5P7HB3ND-CIgNRRNp.js} +1 -1
  52. package/dist/client/index.html +2 -2
  53. package/dist/fleet-plugins/repository/routes.mjs +41 -5
  54. package/dist/fleet-plugins/terminal/routes.mjs +580 -410
  55. package/dist/fleet.mjs +490 -258
  56. package/package.json +1 -1
  57. package/dist/client/assets/channel-DfEjadrw.js +0 -1
  58. package/dist/client/assets/classDiagram-6PBFFD2Q-D9vQdv0q.js +0 -1
  59. package/dist/client/assets/classDiagram-v2-HSJHXN6E-D9vQdv0q.js +0 -1
  60. package/dist/client/assets/clone-Ck2x5JX2.js +0 -1
  61. package/dist/client/assets/index-C5EOZGlC.js +0 -466
  62. package/dist/client/assets/index-CHHE3nPw.css +0 -1
  63. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-CZDbnuN-.js +0 -1
@@ -5,7 +5,8 @@ import * as fs9 from 'node:fs';
5
5
  import fs9__default, { existsSync, readFileSync, lstatSync, rmSync, mkdirSync, mkdtempSync, writeFileSync, chmodSync, promises, renameSync as renameSync$1, readdirSync, closeSync, fstatSync, accessSync, constants as constants$1, realpathSync, openSync } from 'node:fs';
6
6
  import * as os3 from 'node:os';
7
7
  import os3__default, { tmpdir, homedir } from 'node:os';
8
- import * as fs32 from 'fs';
8
+ import { randomUUID, createHash } from 'crypto';
9
+ import * as fs42 from 'fs';
9
10
  import { constants, mkdirSync as mkdirSync$1, rmSync as rmSync$1, renameSync, appendFileSync, statSync } from 'fs';
10
11
  import * as path32 from 'path';
11
12
  import path32__default, { dirname } from 'path';
@@ -13,7 +14,6 @@ import { execFile } from 'child_process';
13
14
  import fs22, { appendFile, chmod, mkdir, stat, unlink, rename as rename$1 } from 'fs/promises';
14
15
  import os5 from 'os';
15
16
  import { promisify } from 'util';
16
- import { randomUUID, createHash } from 'crypto';
17
17
  import http2 from 'http2';
18
18
  import { deflateRawSync, inflateRawSync } from 'zlib';
19
19
  import crypto5, { createHash as createHash$1, randomUUID as randomUUID$1 } from 'node:crypto';
@@ -16018,11 +16018,11 @@ function createZeroMessage(desc) {
16018
16018
  }
16019
16019
  }
16020
16020
  } else {
16021
- const cached2 = messagePrototypes.get(desc);
16021
+ const cached3 = messagePrototypes.get(desc);
16022
16022
  let prototype;
16023
16023
  let members;
16024
- if (cached2) {
16025
- ({ prototype, members } = cached2);
16024
+ if (cached3) {
16025
+ ({ prototype, members } = cached3);
16026
16026
  } else {
16027
16027
  prototype = {};
16028
16028
  members = /* @__PURE__ */ new Set();
@@ -16793,9 +16793,9 @@ function reflect(messageDesc2, message, check2 = true) {
16793
16793
  var messageSortedFields = /* @__PURE__ */ new WeakMap();
16794
16794
  var ReflectMessageImpl = class {
16795
16795
  get sortedFields() {
16796
- const cached2 = messageSortedFields.get(this.desc);
16797
- if (cached2) {
16798
- return cached2;
16796
+ const cached3 = messageSortedFields.get(this.desc);
16797
+ if (cached3) {
16798
+ return cached3;
16799
16799
  }
16800
16800
  const sortedFields = this.desc.fields.concat().sort((a, b) => a.number - b.number);
16801
16801
  messageSortedFields.set(this.desc, sortedFields);
@@ -19914,6 +19914,20 @@ function clampReasoningEffort(effort, supportedEfforts, modelId) {
19914
19914
  if (lower) return lower.supported;
19915
19915
  throw new UnsupportedReasoningEffortError(effort, supportedEfforts, modelId);
19916
19916
  }
19917
+ var REASONING_SIGNATURE_PREFIX = "fleet-reasoning:v1:";
19918
+ function encodeReasoningSignature(id, encrypted) {
19919
+ return `${REASONING_SIGNATURE_PREFIX}${id}:${encrypted}`;
19920
+ }
19921
+ function decodeReasoningSignature(signature) {
19922
+ if (typeof signature !== "string" || !signature.startsWith(REASONING_SIGNATURE_PREFIX)) {
19923
+ return void 0;
19924
+ }
19925
+ const body = signature.slice(REASONING_SIGNATURE_PREFIX.length);
19926
+ const separator = body.indexOf(":");
19927
+ if (separator === -1) return void 0;
19928
+ const encrypted = body.slice(separator + 1);
19929
+ return encrypted.length > 0 ? { id: body.slice(0, separator), encrypted } : void 0;
19930
+ }
19917
19931
  var ContextWindowExceededError = class extends Error {
19918
19932
  constructor(requestTokens, contextWindow) {
19919
19933
  super(`Prompt is too long: ${requestTokens} tokens > ${contextWindow} maximum context window`);
@@ -22259,11 +22273,21 @@ function translateMessage(message) {
22259
22273
  const items = [];
22260
22274
  const parts = [];
22261
22275
  let reasoningContent = "";
22276
+ let reasoningBlob;
22262
22277
  const takeReasoningContent = () => {
22263
- if (role !== "assistant" || reasoningContent.length === 0) return {};
22278
+ if (role !== "assistant") return {};
22279
+ const blob = reasoningBlob;
22264
22280
  const reasoning = reasoningContent;
22265
22281
  reasoningContent = "";
22266
- return { reasoning_content: reasoning };
22282
+ reasoningBlob = void 0;
22283
+ if (reasoning.length === 0 && blob === void 0) return {};
22284
+ return {
22285
+ ...reasoning.length === 0 ? {} : { reasoning_content: reasoning },
22286
+ ...blob === void 0 ? {} : {
22287
+ reasoning_encrypted: blob.encrypted,
22288
+ ...blob.id.length === 0 ? {} : { reasoning_id: blob.id }
22289
+ }
22290
+ };
22267
22291
  };
22268
22292
  const flushParts = (includeReasoning = true) => {
22269
22293
  if (parts.length === 0) {
@@ -22312,6 +22336,9 @@ function translateMessage(message) {
22312
22336
  if (role === "assistant" && typeof block.thinking === "string") {
22313
22337
  reasoningContent += block.thinking;
22314
22338
  }
22339
+ if (role === "assistant") {
22340
+ reasoningBlob = decodeReasoningSignature(block.signature) ?? reasoningBlob;
22341
+ }
22315
22342
  break;
22316
22343
  case "redacted_thinking":
22317
22344
  break;
@@ -22467,6 +22494,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
22467
22494
  let model = fallbackModel;
22468
22495
  let text2 = "";
22469
22496
  const thinking = /* @__PURE__ */ new Map();
22497
+ const reasoningBlobs = /* @__PURE__ */ new Map();
22470
22498
  let stopReason = "end_turn";
22471
22499
  let outputTokens = 0;
22472
22500
  let inputTokens = 0;
@@ -22508,6 +22536,16 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
22508
22536
  break;
22509
22537
  }
22510
22538
  case "response.output_item.done":
22539
+ if (event.item.type === "reasoning") {
22540
+ if (event.item.encrypted_content !== void 0) {
22541
+ reasoningBlobs.set(
22542
+ event.item.id,
22543
+ encodeReasoningSignature(event.item.id, event.item.encrypted_content)
22544
+ );
22545
+ if (!thinking.has(event.item.id)) thinking.set(event.item.id, "");
22546
+ }
22547
+ break;
22548
+ }
22511
22549
  if (event.item.type === "web_search_call") {
22512
22550
  const query = derivedWebSearchQuery(event.item.action);
22513
22551
  content.push({
@@ -22544,7 +22582,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
22544
22582
  content.unshift(...[...thinking].map(([itemId, value]) => ({
22545
22583
  type: "thinking",
22546
22584
  thinking: value,
22547
- signature: `gateway_${reasoningBlockKey(itemId)}`
22585
+ signature: reasoningBlobs.get(itemId) ?? `gateway_${reasoningBlockKey(itemId)}`
22548
22586
  })));
22549
22587
  return {
22550
22588
  id,
@@ -22581,6 +22619,7 @@ async function* encodeAnthropicSse(events, options = {}) {
22581
22619
  let messageStopped = false;
22582
22620
  let sawToolUse = false;
22583
22621
  let activeContentKey;
22622
+ const reasoningBlobs = /* @__PURE__ */ new Map();
22584
22623
  const encode3 = (event, data) => encoder2.encode(`event: ${event}
22585
22624
  data: ${JSON.stringify(data)}
22586
22625
 
@@ -22614,7 +22653,9 @@ data: ${JSON.stringify(data)}
22614
22653
  ...block.kind === "thinking" ? [encode3("content_block_delta", {
22615
22654
  type: "content_block_delta",
22616
22655
  index: block.index,
22617
- delta: { type: "signature_delta", signature: `gateway_${key}` }
22656
+ // The blob is only known once the reasoning item closes, which is why the signature
22657
+ // is emitted here at block close rather than at block start.
22658
+ delta: { type: "signature_delta", signature: reasoningBlobs.get(key) ?? `gateway_${key}` }
22618
22659
  })] : [],
22619
22660
  encode3("content_block_stop", {
22620
22661
  type: "content_block_stop",
@@ -22740,6 +22781,19 @@ data: ${JSON.stringify(data)}
22740
22781
  break;
22741
22782
  }
22742
22783
  case "response.output_item.done":
22784
+ if (event.item.type === "reasoning") {
22785
+ if (event.item.encrypted_content !== void 0) {
22786
+ const key = reasoningBlockKey(event.item.id);
22787
+ reasoningBlobs.set(key, encodeReasoningSignature(event.item.id, event.item.encrypted_content));
22788
+ if (!blocks2.has(key)) {
22789
+ yield* closeActiveContent();
22790
+ const start = startContentBlock(key, "thinking");
22791
+ if (start !== void 0) yield start;
22792
+ }
22793
+ yield* closeBlock(key);
22794
+ }
22795
+ break;
22796
+ }
22743
22797
  if (event.item.type === "function_call") {
22744
22798
  let block = blocks2.get(event.item.id);
22745
22799
  if (block === void 0) {
@@ -23344,6 +23398,13 @@ var OpenAIResponsesAdapter = class {
23344
23398
  "idleTimeoutMs"
23345
23399
  );
23346
23400
  }
23401
+ /**
23402
+ * Headers a subclass derives from the request itself, merged over the constructor's.
23403
+ * The base Platform API surface derives none.
23404
+ */
23405
+ perRequestHeaders(_request) {
23406
+ return {};
23407
+ }
23347
23408
  async stream(request, options) {
23348
23409
  if (options.apiKey.length === 0) {
23349
23410
  throw new TypeError("apiKey must not be empty");
@@ -23360,7 +23421,8 @@ var OpenAIResponsesAdapter = class {
23360
23421
  accept: "text/event-stream",
23361
23422
  authorization: `Bearer ${options.apiKey}`,
23362
23423
  "content-type": "application/json",
23363
- ...this.extraHeaders
23424
+ ...this.extraHeaders,
23425
+ ...this.perRequestHeaders(request)
23364
23426
  },
23365
23427
  body: JSON.stringify(payload),
23366
23428
  signal: controller.signal
@@ -23421,6 +23483,10 @@ var CodexResponsesAdapter = class extends OpenAIResponsesAdapter {
23421
23483
  });
23422
23484
  this.isMarkedFetchFailure = fetchFailureTracker.isMarkedFailure;
23423
23485
  }
23486
+ perRequestHeaders(request) {
23487
+ const sessionId = codexSessionIdentity(request);
23488
+ return sessionId === void 0 ? {} : { session_id: sessionId };
23489
+ }
23424
23490
  async stream(request, options) {
23425
23491
  const callController = new AbortController();
23426
23492
  const unlinkCallAbort = linkAbortSignal(options.signal, callController);
@@ -23700,11 +23766,27 @@ function forOpenAIResponsesBackend(request, dropSamplingParams) {
23700
23766
  }
23701
23767
  return payload;
23702
23768
  }
23769
+ function codexSessionIdentity(request) {
23770
+ const userId = request.metadata?.user_id?.trim();
23771
+ if (!userId) return void 0;
23772
+ const digest = createHash("sha256").update("fleet:codex:claude-session:").update(userId).digest("hex");
23773
+ return [
23774
+ digest.slice(0, 8),
23775
+ digest.slice(8, 12),
23776
+ digest.slice(12, 16),
23777
+ digest.slice(16, 20),
23778
+ digest.slice(20, 32)
23779
+ ].join("-");
23780
+ }
23703
23781
  function forChatGptBackend(request) {
23704
23782
  const copy = { ...request };
23705
23783
  for (const field of CHATGPT_UNSUPPORTED_FIELDS) {
23706
23784
  delete copy[field];
23707
23785
  }
23786
+ const sessionId = codexSessionIdentity(request);
23787
+ if (sessionId !== void 0) {
23788
+ copy.prompt_cache_key = sessionId;
23789
+ }
23708
23790
  if (request.tool_choice === "none" || isClaudeCodeSuggestionMode(request)) {
23709
23791
  delete copy.tools;
23710
23792
  delete copy.tool_choice;
@@ -25805,25 +25887,249 @@ async function resolveXaiCliCredentials(deps, nowOrOptions = Date.now) {
25805
25887
  const result = await resolveXaiCliAuth(deps, options);
25806
25888
  return result.status === "ok" ? result.credentials : null;
25807
25889
  }
25890
+ var XAI_CLI_FALLBACK_CLIENT_VERSION = "1.0.5";
25891
+ var VERSION_PATTERN = /\b(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\b/;
25892
+ var VERSION_EXEC_TIMEOUT_MS = 2e3;
25893
+ var MAX_VERSION_FILE_BYTES = 256;
25894
+ function grokHomeDir(deps) {
25895
+ return optionalTrimmedString(deps.env.GROK_HOME) ?? path32__default.join(deps.homedir(), ".grok");
25896
+ }
25897
+ function versionFrom(value) {
25898
+ if (typeof value !== "string") return void 0;
25899
+ return VERSION_PATTERN.exec(value)?.[1];
25900
+ }
25901
+ async function fromInstallerSymlink(home, readLink) {
25902
+ try {
25903
+ return versionFrom(path32__default.basename(await readLink(path32__default.join(home, "bin", "grok"))));
25904
+ } catch {
25905
+ return void 0;
25906
+ }
25907
+ }
25908
+ async function fromMetadataMarker(home, deps) {
25909
+ try {
25910
+ return versionFrom(await deps.readBounded(path32__default.join(home, ".metadata_version"), MAX_VERSION_FILE_BYTES));
25911
+ } catch {
25912
+ return void 0;
25913
+ }
25914
+ }
25915
+ function grokExecutablePath(home, deps) {
25916
+ return path32__default.join(home, "bin", deps.platform === "win32" ? "grok.exe" : "grok");
25917
+ }
25918
+ async function fromCommand(deps, file2) {
25919
+ try {
25920
+ return versionFrom(await deps.execFile(file2, ["--version"], { timeout: VERSION_EXEC_TIMEOUT_MS }));
25921
+ } catch {
25922
+ return void 0;
25923
+ }
25924
+ }
25925
+ async function resolveXaiCliClientVersion(options = {}) {
25926
+ const deps = options.deps ?? defaultCredentialDeps;
25927
+ const readLink = options.readLink ?? ((filePath) => fs22.readlink(filePath));
25928
+ const override = versionFrom(optionalTrimmedString(deps.env.FLEET_XAI_CLI_VERSION));
25929
+ if (override) return override;
25930
+ const home = grokHomeDir(deps);
25931
+ return await fromInstallerSymlink(home, readLink) ?? await fromMetadataMarker(home, deps) ?? await fromCommand(deps, grokExecutablePath(home, deps)) ?? await fromCommand(deps, "grok") ?? XAI_CLI_FALLBACK_CLIENT_VERSION;
25932
+ }
25933
+ var cached2;
25934
+ function xaiCliClientVersion(options = {}) {
25935
+ cached2 ??= resolveXaiCliClientVersion(options).catch(() => XAI_CLI_FALLBACK_CLIENT_VERSION);
25936
+ return cached2;
25937
+ }
25938
+ var XAI_ENDPOINT_PREFERENCES = ["direct", "cli-proxy"];
25939
+ var DEFAULT_XAI_ENDPOINT_PREFERENCE = "cli-proxy";
25940
+ function sanitizeXaiEndpoint(value) {
25941
+ return typeof value === "string" && XAI_ENDPOINT_PREFERENCES.includes(value) ? value : void 0;
25942
+ }
25943
+ function normalizeAiGatewaySettings(value) {
25944
+ if (!isRecord7(value) || value.version !== 1) return { version: 1 };
25945
+ const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord7(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
25946
+ const model = findGatewayModel(entry.id);
25947
+ if (!model) return [];
25948
+ const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
25949
+ const exposed = efforts.length > 0 ? narrowEffortLadder(model, efforts) : void 0;
25950
+ return [{
25951
+ id: entry.id,
25952
+ ...exposed ? { efforts: [...exposed] } : {},
25953
+ ...entry.hostOnly === true ? { hostOnly: true } : {}
25954
+ }];
25955
+ }) : [];
25956
+ const providerPriority = sanitizeProviderPriority(value.providerPriority);
25957
+ const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
25958
+ const xaiEndpoint = sanitizeXaiEndpoint(value.xaiEndpoint);
25959
+ return {
25960
+ version: 1,
25961
+ ...models.length > 0 ? { models } : {},
25962
+ ...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
25963
+ ...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
25964
+ ...providerPriority ? { providerPriority: [...providerPriority] } : {},
25965
+ ...compactCeiling !== void 0 ? { compactCeiling } : {},
25966
+ ...xaiEndpoint !== void 0 ? { xaiEndpoint } : {}
25967
+ };
25968
+ }
25969
+ function sanitizeProviderPriority(value) {
25970
+ if (!Array.isArray(value)) return void 0;
25971
+ const seen = /* @__PURE__ */ new Set();
25972
+ const cleaned = [];
25973
+ for (const entry of value) {
25974
+ if (typeof entry !== "string") continue;
25975
+ if (!GATEWAY_PROVIDERS.includes(entry)) continue;
25976
+ const provider = entry;
25977
+ if (seen.has(provider)) continue;
25978
+ seen.add(provider);
25979
+ cleaned.push(provider);
25980
+ }
25981
+ return cleaned.length > 0 ? cleaned : void 0;
25982
+ }
25983
+ function isRecord7(value) {
25984
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25985
+ }
25986
+ function resolveAiGatewaySelection(settings2) {
25987
+ const enabled = [];
25988
+ const hostOnlyIds = /* @__PURE__ */ new Set();
25989
+ const effortExposure = {};
25990
+ for (const entry of settings2?.models ?? []) {
25991
+ const model = findGatewayModel(entry.id);
25992
+ if (!model) continue;
25993
+ if (entry.hostOnly === true) hostOnlyIds.add(model.id);
25994
+ if (enabled.includes(model)) continue;
25995
+ enabled.push(model);
25996
+ const exposed = narrowEffortLadder(model, entry.efforts);
25997
+ if (exposed) effortExposure[model.id] = exposed;
25998
+ }
25999
+ const models = sortGatewayModelsByProvider(enabled);
26000
+ const delegationModels = models.filter((model) => !hostOnlyIds.has(model.id));
26001
+ return { models, delegationModels, effortExposure, providerPriority: settings2?.providerPriority };
26002
+ }
26003
+ function narrowEffortLadder(model, efforts) {
26004
+ if (!efforts || efforts.length === 0) return void 0;
26005
+ const ladder = buildGatewayModelConstraints(model).effortLadder;
26006
+ const narrowed = ladder.filter((rung) => efforts.includes(rung));
26007
+ if (narrowed.length === 0 || narrowed.length === ladder.length) return void 0;
26008
+ return narrowed;
26009
+ }
26010
+ function exposableEffortLadder(model) {
26011
+ return buildGatewayModelConstraints(model).effortLadder;
26012
+ }
26013
+ function sortGatewayModelsByProvider(models) {
26014
+ return [...models].sort((left, right) => {
26015
+ const providerDelta = GATEWAY_PROVIDERS.indexOf(left.provider) - GATEWAY_PROVIDERS.indexOf(right.provider);
26016
+ if (providerDelta !== 0) return providerDelta;
26017
+ return GATEWAY_MODELS.indexOf(left) - GATEWAY_MODELS.indexOf(right);
26018
+ });
26019
+ }
26020
+ function parseAiGatewayUpdate(value) {
26021
+ if (value === null) return { ok: true, value: void 0 };
26022
+ if (!value || typeof value !== "object" || Array.isArray(value)) return { ok: false };
26023
+ const record42 = value;
26024
+ const extraKeys = Object.keys(record42).filter(
26025
+ (key) => key !== "models" && key !== "defaultModel" && key !== "providerPriority"
26026
+ );
26027
+ if (extraKeys.length > 0) return { ok: false };
26028
+ const models = [];
26029
+ if (record42.models !== void 0) {
26030
+ if (!Array.isArray(record42.models)) return { ok: false };
26031
+ for (const raw of record42.models) {
26032
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ok: false };
26033
+ const entry = raw;
26034
+ if (Object.keys(entry).some((key) => key !== "id" && key !== "efforts" && key !== "hostOnly")) {
26035
+ return { ok: false };
26036
+ }
26037
+ if (typeof entry.id !== "string") return { ok: false };
26038
+ if (entry.hostOnly !== void 0 && typeof entry.hostOnly !== "boolean") return { ok: false };
26039
+ const model = findGatewayModel(entry.id);
26040
+ if (!model) return { ok: false };
26041
+ if (models.some((existing) => existing.id === model.id)) return { ok: false };
26042
+ const efforts = parseExposedEfforts(model, entry.efforts);
26043
+ if (efforts === null) return { ok: false };
26044
+ models.push({
26045
+ id: model.id,
26046
+ ...efforts ? { efforts } : {},
26047
+ ...entry.hostOnly === true ? { hostOnly: true } : {}
26048
+ });
26049
+ }
26050
+ }
26051
+ let providerPriority;
26052
+ const hasProviderPriority = Object.prototype.hasOwnProperty.call(record42, "providerPriority");
26053
+ if (hasProviderPriority) {
26054
+ if (!Array.isArray(record42.providerPriority)) return { ok: false };
26055
+ providerPriority = [];
26056
+ for (const raw of record42.providerPriority) {
26057
+ if (typeof raw !== "string") return { ok: false };
26058
+ if (!GATEWAY_PROVIDERS.includes(raw)) return { ok: false };
26059
+ const provider = raw;
26060
+ if (providerPriority.includes(provider)) return { ok: false };
26061
+ providerPriority.push(provider);
26062
+ }
26063
+ }
26064
+ if (models.length === 0 && providerPriority === void 0) {
26065
+ return { ok: true, value: void 0 };
26066
+ }
26067
+ return {
26068
+ ok: true,
26069
+ value: {
26070
+ ...models.length > 0 ? { models } : {},
26071
+ ...providerPriority !== void 0 ? { providerPriority } : {}
26072
+ }
26073
+ };
26074
+ }
26075
+ function parseExposedEfforts(model, value) {
26076
+ if (value === void 0) return void 0;
26077
+ if (!Array.isArray(value)) return null;
26078
+ const ladder = exposableEffortLadder(model);
26079
+ const seen = [];
26080
+ for (const raw of value) {
26081
+ if (typeof raw !== "string") return null;
26082
+ if (!ladder.includes(raw)) return null;
26083
+ if (seen.includes(raw)) return null;
26084
+ seen.push(raw);
26085
+ }
26086
+ if (seen.length === 0) return null;
26087
+ const ordered = ladder.filter((rung) => seen.includes(rung));
26088
+ return ordered.length === ladder.length ? void 0 : ordered;
26089
+ }
26090
+ function buildAiGatewayCatalog(models = GATEWAY_MODELS) {
26091
+ return {
26092
+ providers: GATEWAY_PROVIDERS.map((provider) => ({
26093
+ id: provider,
26094
+ models: models.filter((model) => model.provider === provider).map((model) => toCatalogModel(model))
26095
+ }))
26096
+ };
26097
+ }
26098
+ function toCatalogModel(model) {
26099
+ const levels = exposableEffortLadder(model);
26100
+ return {
26101
+ id: model.id,
26102
+ name: bareModelName(model),
26103
+ contextWindow: model.contextWindow ?? null,
26104
+ oneMillion: hasClaudeOneMillionMarker(toClaudeGatewayModelId(model)),
26105
+ maxMode: model.cursorMaxMode === true,
26106
+ fast: model.id.endsWith("-fast"),
26107
+ capabilityClass: model.capabilityClass ?? null,
26108
+ description: model.description ?? null,
26109
+ effort: levels.length > 0 ? { levels } : null
26110
+ };
26111
+ }
26112
+ function bareModelName(model) {
26113
+ const prefix = `${GATEWAY_PROVIDER_NAMES[model.provider]}-`;
26114
+ return model.displayName.startsWith(prefix) ? model.displayName.slice(prefix.length) : model.displayName;
26115
+ }
25808
26116
  var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
25809
26117
  var XAI_CLI_RESPONSES_URL = "https://cli-chat-proxy.grok.com/v1/responses";
25810
- var XAI_CLI_CLIENT_VERSION = "1.0.3";
25811
- var XAI_PROXY_FALLBACK_STATUSES = /* @__PURE__ */ new Set([402, 426]);
25812
26118
  var DEFAULT_XAI_RESPONSES_MAX_UPSTREAM_BODY_BYTES = 64 * 1024 * 1024;
25813
26119
  var DEFAULT_XAI_RESPONSES_UPSTREAM_IDLE_TIMEOUT_MS = 3e4;
25814
26120
  var DEFAULT_XAI_RESPONSES_FUNCTION_CALL_TIMEOUT_MS = 3e4;
25815
26121
  var DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS = 6e4;
25816
26122
  var XAI_RETRY_DELAY_MS = 200;
25817
- var xaiProxyOnlyAccount = false;
26123
+ var XAI_REASONING_INCLUDE = "reasoning.encrypted_content";
25818
26124
  function directXaiEndpoint() {
25819
26125
  return { url: XAI_RESPONSES_URL, headers: {} };
25820
26126
  }
25821
- function proxyXaiEndpoint(model) {
26127
+ function proxyXaiEndpoint(model, clientVersion) {
25822
26128
  return {
25823
26129
  url: XAI_CLI_RESPONSES_URL,
25824
26130
  headers: {
25825
26131
  "x-xai-token-auth": "xai-grok-cli",
25826
- "x-grok-client-version": XAI_CLI_CLIENT_VERSION,
26132
+ "x-grok-client-version": clientVersion,
25827
26133
  "x-grok-model-override": model
25828
26134
  }
25829
26135
  };
@@ -25836,6 +26142,8 @@ var XaiResponsesAdapter = class {
25836
26142
  idleTimeoutMs;
25837
26143
  functionCallTimeoutMs;
25838
26144
  semanticStallTimeoutMs;
26145
+ endpointPreference;
26146
+ clientVersion;
25839
26147
  extraHeaders;
25840
26148
  constructor(options = {}) {
25841
26149
  this.extraHeaders = options.headers ?? {};
@@ -25858,6 +26166,8 @@ var XaiResponsesAdapter = class {
25858
26166
  options.semanticStallTimeoutMs ?? DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS,
25859
26167
  "semanticStallTimeoutMs"
25860
26168
  );
26169
+ this.endpointPreference = options.endpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE;
26170
+ this.clientVersion = options.clientVersion ?? (() => xaiCliClientVersion());
25861
26171
  }
25862
26172
  async stream(request, options) {
25863
26173
  if (options.apiKey.length === 0) {
@@ -25865,22 +26175,14 @@ var XaiResponsesAdapter = class {
25865
26175
  }
25866
26176
  const controller = new AbortController();
25867
26177
  const unlinkAbort = linkAbortSignal(options.signal, controller);
25868
- const payload = forXaiResponsesBackend(request, xaiWireTools(request));
26178
+ const tools = xaiWireTools(request);
26179
+ let payload = forXaiResponsesBackend(request, tools);
26180
+ let replayAvailable = replaysXaiReasoning(request);
25869
26181
  let retryAvailable = true;
25870
26182
  let response;
25871
- let endpoint = xaiProxyOnlyAccount ? proxyXaiEndpoint(payload.model) : directXaiEndpoint();
26183
+ const endpoint = this.endpointPreference === "cli-proxy" ? await this.proxyEndpoint(payload.model) : directXaiEndpoint();
25872
26184
  try {
25873
26185
  response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
25874
- if (!response.ok && endpoint.url === XAI_RESPONSES_URL && XAI_PROXY_FALLBACK_STATUSES.has(response.status)) {
25875
- wireLog("xai-responses.endpoint.fallback", {
25876
- status: response.status,
25877
- from: XAI_RESPONSES_URL,
25878
- to: XAI_CLI_RESPONSES_URL
25879
- });
25880
- xaiProxyOnlyAccount = true;
25881
- endpoint = proxyXaiEndpoint(payload.model);
25882
- response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
25883
- }
25884
26186
  } catch (error51) {
25885
26187
  if (!isRetryableXaiFetchSocket(error51, controller.signal, this.isMarkedFetchFailure)) {
25886
26188
  unlinkAbort();
@@ -25903,18 +26205,41 @@ var XaiResponsesAdapter = class {
25903
26205
  unlinkAbort();
25904
26206
  return response;
25905
26207
  }
25906
- return {
25907
- ...response,
25908
- events: retryXaiEvents(response.events, async (signal) => {
26208
+ const reopen = async (signal, reason) => {
26209
+ if (reason === "empty_stream" && replayAvailable) {
26210
+ replayAvailable = false;
26211
+ payload = forXaiResponsesBackend(request, tools, false);
26212
+ wireLog("xai-responses.reasoning.replay_dropped", { reason });
25909
26213
  await abortableXaiDelay(XAI_RETRY_DELAY_MS, signal);
25910
- const retried = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
25911
- if (!retried.ok) {
25912
- throw new UpstreamProtocolError(`xAI retry failed with status ${retried.status}`);
26214
+ const withoutReplay = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
26215
+ if (!withoutReplay.ok) {
26216
+ throw new UpstreamProtocolError(`xAI retry failed with status ${withoutReplay.status}`);
25913
26217
  }
25914
- return retried.events;
25915
- }, controller, unlinkAbort, retryAvailable)
26218
+ return withoutReplay.events;
26219
+ }
26220
+ await abortableXaiDelay(XAI_RETRY_DELAY_MS, signal);
26221
+ const retried = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
26222
+ if (!retried.ok) {
26223
+ throw new UpstreamProtocolError(`xAI retry failed with status ${retried.status}`);
26224
+ }
26225
+ return retried.events;
26226
+ };
26227
+ return {
26228
+ ...response,
26229
+ events: retryXaiEvents(
26230
+ response.events,
26231
+ reopen,
26232
+ controller,
26233
+ unlinkAbort,
26234
+ retryAvailable,
26235
+ () => replayAvailable
26236
+ )
25916
26237
  };
25917
26238
  }
26239
+ /** The proxy endpoint, with the installed CLI's version resolved for its gate. */
26240
+ async proxyEndpoint(model) {
26241
+ return proxyXaiEndpoint(model, await this.clientVersion());
26242
+ }
25918
26243
  async fetchResponse(apiKey, payload, controller, endpoint) {
25919
26244
  wireLog("xai-responses.wire.request", { url: endpoint.url, payload });
25920
26245
  const response = await this.fetchImpl(endpoint.url, {
@@ -25964,21 +26289,43 @@ var XaiResponsesAdapter = class {
25964
26289
  return xaiWireTools(request) ?? [];
25965
26290
  }
25966
26291
  };
25967
- function forXaiResponsesBackend(request, tools = xaiWireTools(request)) {
26292
+ function forXaiResponsesBackend(request, tools = xaiWireTools(request), replayReasoning = true) {
25968
26293
  const { metadata: _metadata, native_tools: _nativeTools, ...rest } = request;
26294
+ const input = [];
26295
+ for (const item of request.input) {
26296
+ if (item.type === "function_call_output") {
26297
+ const { is_error: _isError, tool_references: _toolReferences, ...wireItem2 } = item;
26298
+ input.push(wireItem2);
26299
+ continue;
26300
+ }
26301
+ const {
26302
+ reasoning_content: _reasoningContent,
26303
+ reasoning_encrypted: encrypted,
26304
+ reasoning_id: reasoningId,
26305
+ ...wireItem
26306
+ } = item;
26307
+ if (replayReasoning && encrypted !== void 0 && encrypted.length > 0) {
26308
+ input.push({
26309
+ type: "reasoning",
26310
+ ...reasoningId === void 0 ? {} : { id: reasoningId },
26311
+ summary: [],
26312
+ encrypted_content: encrypted
26313
+ });
26314
+ }
26315
+ input.push(wireItem);
26316
+ }
25969
26317
  return {
25970
26318
  ...rest,
25971
- input: request.input.map((item) => {
25972
- if (item.type === "function_call_output") {
25973
- const { is_error: _isError, tool_references: _toolReferences, ...wireItem2 } = item;
25974
- return wireItem2;
25975
- }
25976
- const { reasoning_content: _reasoningContent, ...wireItem } = item;
25977
- return wireItem;
25978
- }),
26319
+ input,
26320
+ // Only asked for when a reply could carry one: on a turn that replays nothing the include
26321
+ // is inert, and on a retry that dropped the replay it must not invite a fresh blob back.
26322
+ ...replayReasoning ? { include: [XAI_REASONING_INCLUDE] } : {},
25979
26323
  ...tools === void 0 ? {} : { tools: [...tools] }
25980
26324
  };
25981
26325
  }
26326
+ function replaysXaiReasoning(request) {
26327
+ return request.input.some((item) => item.type !== "function_call_output" && typeof item.reasoning_encrypted === "string" && item.reasoning_encrypted.length > 0);
26328
+ }
25982
26329
  function xaiWireTools(request) {
25983
26330
  if (request.tools === void 0) return void 0;
25984
26331
  const tools = request.tools;
@@ -25999,11 +26346,18 @@ function isToolSearchName(name) {
25999
26346
  function toolNameMatches(declaredName, selectedName) {
26000
26347
  return declaredName === selectedName || toolLeafName(declaredName) === toolLeafName(selectedName);
26001
26348
  }
26002
- function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable) {
26349
+ function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
26003
26350
  return {
26004
26351
  [Symbol.asyncIterator]() {
26005
26352
  const source = events[Symbol.asyncIterator]();
26006
- const iterator = generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable);
26353
+ const iterator = generateXaiRetryEvents(
26354
+ source,
26355
+ retry,
26356
+ controller,
26357
+ unlinkAbort,
26358
+ retryAvailable,
26359
+ replayAvailable
26360
+ );
26007
26361
  return {
26008
26362
  next: () => iterator.next(),
26009
26363
  return: async () => {
@@ -26018,7 +26372,7 @@ function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable)
26018
26372
  }
26019
26373
  };
26020
26374
  }
26021
- async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable) {
26375
+ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
26022
26376
  const lead = [];
26023
26377
  let committed = false;
26024
26378
  let normalCompletion = false;
@@ -26042,14 +26396,26 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
26042
26396
  });
26043
26397
  await source.return?.();
26044
26398
  lead.length = 0;
26045
- yield* await retry(controller.signal);
26399
+ yield* await retry(controller.signal, "retryable_failure");
26046
26400
  return;
26047
26401
  }
26048
26402
  if (result.done) {
26049
- yield* lead;
26050
26403
  if (pendingError !== void 0) {
26051
- yield pendingError;
26404
+ wireLog("xai-responses.retry.discarded", {
26405
+ reason: "error_stream_end",
26406
+ errorTypes: [pendingError.error.type]
26407
+ });
26408
+ lead.length = 0;
26409
+ yield* await retry(controller.signal, "retryable_failure");
26410
+ return;
26411
+ }
26412
+ if (!committed && replayAvailable()) {
26413
+ wireLog("xai-responses.retry.discarded", { reason: "empty_stream" });
26414
+ lead.length = 0;
26415
+ yield* await retry(controller.signal, "empty_stream");
26416
+ return;
26052
26417
  }
26418
+ yield* lead;
26053
26419
  normalCompletion = true;
26054
26420
  return;
26055
26421
  }
@@ -26060,7 +26426,7 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
26060
26426
  wireLog("xai-responses.retry.discarded", pendingError === void 0 ? { reason: "response.failed", errorTypes } : { reason: "error_failed_pair", errorTypes });
26061
26427
  await source.return?.();
26062
26428
  lead.length = 0;
26063
- yield* await retry(controller.signal);
26429
+ yield* await retry(controller.signal, "retryable_failure");
26064
26430
  return;
26065
26431
  }
26066
26432
  pendingError = event;
@@ -26094,7 +26460,7 @@ function isRetryableXaiFailure(event) {
26094
26460
  return event.type === "response.failed" && isRetryableXaiErrorType(event.response.error.type) || event.type === "error" && isRetryableXaiErrorType(event.error.type);
26095
26461
  }
26096
26462
  function isRetryableXaiErrorType(type) {
26097
- return type === "server_error" || type === "server_is_overloaded" || type === "service_unavailable_error";
26463
+ return type === "server_error" || type === "server_is_overloaded" || type === "service_unavailable_error" || type === XAI_OVERLOADED_ERROR_TYPE;
26098
26464
  }
26099
26465
  function commitsXaiOutput(event) {
26100
26466
  if (event.type === "response.created" || event.type === "response.reasoning_summary_text.delta") {
@@ -26399,7 +26765,7 @@ function parseEventFrame3(frame) {
26399
26765
  );
26400
26766
  }
26401
26767
  logRawWireEvent("xai-responses.wire.event", eventName, parsed);
26402
- if (isRecord7(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
26768
+ if (isRecord8(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
26403
26769
  parsed = { ...parsed, type: eventName };
26404
26770
  }
26405
26771
  return canonicalEvent3(parsed);
@@ -26409,7 +26775,7 @@ function withoutXaiSentinel(text2) {
26409
26775
  return text2.includes(XAI_EOS_SENTINEL) ? text2.split(XAI_EOS_SENTINEL).join("") : text2;
26410
26776
  }
26411
26777
  function canonicalEvent3(value) {
26412
- if (!isRecord7(value) || typeof value.type !== "string") {
26778
+ if (!isRecord8(value) || typeof value.type !== "string") {
26413
26779
  throw new UpstreamProtocolError("Grok CLI SSE event was not an object with a type");
26414
26780
  }
26415
26781
  switch (value.type) {
@@ -26554,19 +26920,34 @@ function outputItem3(value) {
26554
26920
  arguments: typeof item.arguments === "string" ? item.arguments : ""
26555
26921
  };
26556
26922
  }
26923
+ if (item.type === "reasoning") {
26924
+ const encrypted = typeof item.encrypted_content === "string" && item.encrypted_content.length > 0 ? item.encrypted_content : void 0;
26925
+ if (encrypted === void 0) return void 0;
26926
+ return {
26927
+ id: typeof item.id === "string" ? item.id : "",
26928
+ type: "reasoning",
26929
+ encrypted_content: encrypted
26930
+ };
26931
+ }
26557
26932
  return void 0;
26558
26933
  }
26934
+ var XAI_OVERLOADED_ERROR_TYPE = "overloaded_error";
26935
+ var XAI_CAPACITY_MESSAGE = /\bat capacity\b|\boverloaded\b/i;
26559
26936
  function canonicalError3(value) {
26560
26937
  const error51 = record3(value, "error");
26561
26938
  const message = string32(error51.message, "error.message");
26562
- const type = typeof error51.type === "string" && error51.type !== "error" ? error51.type : typeof error51.code === "string" ? error51.code : "api_error";
26563
- return { type, message };
26939
+ return { type: xaiErrorType(error51, message), message };
26564
26940
  }
26565
- function isRecord7(value) {
26941
+ function xaiErrorType(error51, message) {
26942
+ if (typeof error51.type === "string" && error51.type !== "error") return error51.type;
26943
+ if (typeof error51.code === "string") return error51.code;
26944
+ return XAI_CAPACITY_MESSAGE.test(message) ? XAI_OVERLOADED_ERROR_TYPE : "api_error";
26945
+ }
26946
+ function isRecord8(value) {
26566
26947
  return typeof value === "object" && value !== null && !Array.isArray(value);
26567
26948
  }
26568
26949
  function record3(value, name) {
26569
- if (!isRecord7(value)) {
26950
+ if (!isRecord8(value)) {
26570
26951
  throw new UpstreamProtocolError(`${name} must be an object`);
26571
26952
  }
26572
26953
  return value;
@@ -26638,38 +27019,38 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26638
27019
  "shell_command",
26639
27020
  "exec_command"
26640
27021
  ]);
26641
- if (isRecord8(exec2.readArgs)) {
27022
+ if (isRecord9(exec2.readArgs)) {
26642
27023
  return [execReply(exec2, "readResult", {
26643
27024
  error: { path: stringValue(exec2.readArgs.path), error: readMessage3 }
26644
27025
  })];
26645
27026
  }
26646
- if (isRecord8(exec2.writeArgs)) {
27027
+ if (isRecord9(exec2.writeArgs)) {
26647
27028
  return [execReply(exec2, "writeResult", {
26648
27029
  rejected: { path: stringValue(exec2.writeArgs.path), reason: mutationMessage }
26649
27030
  })];
26650
27031
  }
26651
- if (isRecord8(exec2.deleteArgs)) {
27032
+ if (isRecord9(exec2.deleteArgs)) {
26652
27033
  return [execReply(exec2, "deleteResult", {
26653
27034
  rejected: { path: stringValue(exec2.deleteArgs.path), reason: mutationMessage }
26654
27035
  })];
26655
27036
  }
26656
- if (isRecord8(exec2.lsArgs)) {
27037
+ if (isRecord9(exec2.lsArgs)) {
26657
27038
  return [execReply(exec2, "lsResult", {
26658
27039
  error: { path: stringValue(exec2.lsArgs.path), error: listMessage }
26659
27040
  })];
26660
27041
  }
26661
- if (isRecord8(exec2.grepArgs)) {
27042
+ if (isRecord9(exec2.grepArgs)) {
26662
27043
  return [execReply(exec2, "grepResult", { error: { error: grepMessage } })];
26663
27044
  }
26664
- if (isRecord8(exec2.shellArgs)) {
27045
+ if (isRecord9(exec2.shellArgs)) {
26665
27046
  return [execReply(exec2, "shellResult", shellFailure(exec2.shellArgs, shellMessage))];
26666
27047
  }
26667
- if (isRecord8(exec2.shellStreamArgs)) {
27048
+ if (isRecord9(exec2.shellStreamArgs)) {
26668
27049
  const args = exec2.shellStreamArgs;
26669
27050
  const cwd = stringValue(args.workingDirectory);
26670
27051
  return [
26671
27052
  execReply(exec2, "shellStream", {
26672
- start: isRecord8(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
27053
+ start: isRecord9(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
26673
27054
  }),
26674
27055
  execReply(exec2, "shellStream", { stderr: { data: shellMessage } }),
26675
27056
  execReply(exec2, "shellStream", { exit: { code: 1, cwd, aborted: true } }),
@@ -26677,7 +27058,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26677
27058
  { execClientControlMessage: { streamClose: { id: numberValue(exec2.id) } } }
26678
27059
  ];
26679
27060
  }
26680
- if (isRecord8(exec2.backgroundShellSpawnArgs)) {
27061
+ if (isRecord9(exec2.backgroundShellSpawnArgs)) {
26681
27062
  const args = exec2.backgroundShellSpawnArgs;
26682
27063
  return [execReply(exec2, "backgroundShellSpawnResult", {
26683
27064
  error: {
@@ -26687,15 +27068,15 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26687
27068
  }
26688
27069
  })];
26689
27070
  }
26690
- if (isRecord8(exec2.writeShellStdinArgs)) {
27071
+ if (isRecord9(exec2.writeShellStdinArgs)) {
26691
27072
  return [execReply(exec2, "writeShellStdinResult", { error: { error: shellMessage } })];
26692
27073
  }
26693
- if (isRecord8(exec2.fetchArgs)) {
27074
+ if (isRecord9(exec2.fetchArgs)) {
26694
27075
  return [execReply(exec2, "fetchResult", {
26695
27076
  error: { url: stringValue(exec2.fetchArgs.url), error: networkMessage }
26696
27077
  })];
26697
27078
  }
26698
- if (isRecord8(exec2.diagnosticsArgs)) {
27079
+ if (isRecord9(exec2.diagnosticsArgs)) {
26699
27080
  return [execReply(exec2, "diagnosticsResult", {
26700
27081
  error: {
26701
27082
  path: stringValue(exec2.diagnosticsArgs.path),
@@ -26703,12 +27084,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26703
27084
  }
26704
27085
  })];
26705
27086
  }
26706
- if (isRecord8(exec2.listMcpResourcesExecArgs)) {
27087
+ if (isRecord9(exec2.listMcpResourcesExecArgs)) {
26707
27088
  return [execReply(exec2, "listMcpResourcesExecResult", {
26708
27089
  error: { error: retryMessage(clientTools, ["ListMcpResources", "list_mcp_resources"]) }
26709
27090
  })];
26710
27091
  }
26711
- if (isRecord8(exec2.readMcpResourceExecArgs)) {
27092
+ if (isRecord9(exec2.readMcpResourceExecArgs)) {
26712
27093
  return [execReply(exec2, "readMcpResourceExecResult", {
26713
27094
  error: {
26714
27095
  uri: stringValue(exec2.readMcpResourceExecArgs.uri),
@@ -26716,12 +27097,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26716
27097
  }
26717
27098
  })];
26718
27099
  }
26719
- if (isRecord8(exec2.recordScreenArgs)) {
27100
+ if (isRecord9(exec2.recordScreenArgs)) {
26720
27101
  return [execReply(exec2, "recordScreenResult", {
26721
27102
  failure: { error: retryMessage(clientTools, ["record_screen", "computer_use"]) }
26722
27103
  })];
26723
27104
  }
26724
- if (isRecord8(exec2.computerUseArgs)) {
27105
+ if (isRecord9(exec2.computerUseArgs)) {
26725
27106
  return [execReply(exec2, "computerUseResult", {
26726
27107
  error: {
26727
27108
  error: retryMessage(clientTools, ["computer_use"]),
@@ -26731,7 +27112,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
26731
27112
  }
26732
27113
  })];
26733
27114
  }
26734
- if (isRecord8(exec2.mcpArgs)) {
27115
+ if (isRecord9(exec2.mcpArgs)) {
26735
27116
  return [execReply(exec2, "mcpResult", {
26736
27117
  error: { error: retryMessage(clientTools, []) }
26737
27118
  })];
@@ -26803,7 +27184,7 @@ function numberValue(value) {
26803
27184
  function stringValue(value) {
26804
27185
  return typeof value === "string" ? value : "";
26805
27186
  }
26806
- function isRecord8(value) {
27187
+ function isRecord9(value) {
26807
27188
  return typeof value === "object" && value !== null && !Array.isArray(value);
26808
27189
  }
26809
27190
  var EXECUTE_HOOK_FIELD_NUMBER = 27;
@@ -26959,14 +27340,14 @@ function isCursorWithheldToolName(name) {
26959
27340
  function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
26960
27341
  const messageId = numberValue2(exec2.id ?? 0);
26961
27342
  const execId = stringValue2(exec2.execId) || `redirect-${messageId}`;
26962
- if (isRecord9(exec2.readArgs)) {
26963
- const path72 = stringValue2(exec2.readArgs.path);
26964
- if (!path72) return null;
27343
+ if (isRecord10(exec2.readArgs)) {
27344
+ const path82 = stringValue2(exec2.readArgs.path);
27345
+ if (!path82) return null;
26965
27346
  if ([exec2.readArgs.offset, exec2.readArgs.limit].some((value) => typeof value === "number" && value < 0)) return null;
26966
27347
  const offset = positiveNumber(exec2.readArgs.offset);
26967
27348
  const limit = positiveNumber(exec2.readArgs.limit);
26968
27349
  if (offset !== void 0 || limit !== void 0) return null;
26969
- const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path72) })).find((candidate) => candidate.args !== null);
27350
+ const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path82) })).find((candidate) => candidate.args !== null);
26970
27351
  if (!mapped?.args) return null;
26971
27352
  return redirect(
26972
27353
  exec2,
@@ -26978,14 +27359,14 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
26978
27359
  "readResult",
26979
27360
  "read-direct",
26980
27361
  mapped.args,
26981
- { path: path72 }
27362
+ { path: path82 }
26982
27363
  );
26983
27364
  }
26984
- if (isRecord9(exec2.grepArgs)) {
27365
+ if (isRecord10(exec2.grepArgs)) {
26985
27366
  const grepArgs = exec2.grepArgs;
26986
27367
  const pattern = stringValue2(grepArgs.pattern);
26987
27368
  if (!pattern.trim()) return null;
26988
- const path72 = stringValue2(grepArgs.path) || ".";
27369
+ const path82 = stringValue2(grepArgs.path) || ".";
26989
27370
  const glob = stringValue2(grepArgs.glob);
26990
27371
  const outputMode = normalizedGrepOutputMode(stringValue2(grepArgs.outputMode));
26991
27372
  if (!outputMode) return null;
@@ -27001,7 +27382,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27001
27382
  if (numericOptions.some((value) => typeof value === "number" && value < 0)) return null;
27002
27383
  const mappingInput = {
27003
27384
  pattern,
27004
- path: path72,
27385
+ path: path82,
27005
27386
  glob,
27006
27387
  outputMode,
27007
27388
  caseInsensitive: grepArgs.caseInsensitive === true,
@@ -27018,7 +27399,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27018
27399
  const mapped = tools.filter((tool) => matchesLeaf(tool, GREP_CANDIDATES)).map((tool) => ({ tool, args: grepArguments(tool, mappingInput) })).find((candidate) => candidate.args !== null);
27019
27400
  const nativeArgs = {
27020
27401
  pattern,
27021
- path: path72,
27402
+ path: path82,
27022
27403
  outputMode,
27023
27404
  ...glob ? { glob } : {},
27024
27405
  ...positiveNumber(grepArgs.offset) === void 0 ? {} : { offset: String(positiveNumber(grepArgs.offset)) }
@@ -27055,15 +27436,15 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
27055
27436
  nativeArgs
27056
27437
  );
27057
27438
  }
27058
- if (isRecord9(exec2.shellArgs) || isRecord9(exec2.shellStreamArgs)) {
27059
- const argsRecord = isRecord9(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
27439
+ if (isRecord10(exec2.shellArgs) || isRecord10(exec2.shellStreamArgs)) {
27440
+ const argsRecord = isRecord10(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
27060
27441
  const command = stringValue2(argsRecord.command);
27061
27442
  if (!command) return null;
27062
27443
  const cwd = stringValue2(argsRecord.workingDirectory);
27063
27444
  const timeout = positiveNumber(argsRecord.timeout) ?? positiveNumber(argsRecord.hardTimeout);
27064
27445
  const mapped = tools.filter((tool) => matchesLeaf(tool, SHELL_CANDIDATES)).map((tool) => ({ tool, args: shellArguments(tool.inputSchemaValue, command, cwd || void 0, timeout) })).find((candidate) => candidate.args !== null);
27065
27446
  if (!mapped?.args) return null;
27066
- const stream = isRecord9(exec2.shellStreamArgs);
27447
+ const stream = isRecord10(exec2.shellStreamArgs);
27067
27448
  return redirect(
27068
27449
  exec2,
27069
27450
  mapped.tool,
@@ -27153,9 +27534,9 @@ function cursorNativeRedirectErrorReplies(correlation, error51) {
27153
27534
  }
27154
27535
  }
27155
27536
  }
27156
- function readArguments(schema, path72) {
27537
+ function readArguments(schema, path82) {
27157
27538
  const pathKey = firstSchemaProperty(schema, ["file_path", "path"]);
27158
- return pathKey ? { [pathKey]: path72 } : null;
27539
+ return pathKey ? { [pathKey]: path82 } : null;
27159
27540
  }
27160
27541
  function grepArguments(tool, input) {
27161
27542
  const leaf = normalizedLeaf(tool.clientName);
@@ -27322,7 +27703,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27322
27703
  const decoded = JSON.parse(inflateRawSync(compressed, {
27323
27704
  maxOutputLength: CURSOR_GREP_RECEIPT_MAX_BYTES
27324
27705
  }).toString("utf8"));
27325
- if (!isRecord9(decoded)) throw new Error("receipt is not an object");
27706
+ if (!isRecord10(decoded)) throw new Error("receipt is not an object");
27326
27707
  if (decoded.ok === false && typeof decoded.error === "string") {
27327
27708
  return { ok: false, error: decoded.error };
27328
27709
  }
@@ -27335,7 +27716,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27335
27716
  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)) {
27336
27717
  throw new Error("receipt counts are invalid");
27337
27718
  }
27338
- 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")) {
27719
+ 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")) {
27339
27720
  throw new Error("receipt matches are invalid");
27340
27721
  }
27341
27722
  for (const key of ["totalFiles", "totalLines", "totalMatchedLines"]) {
@@ -27353,7 +27734,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
27353
27734
  }
27354
27735
  }
27355
27736
  function buildGrepReceiptSuccess(args, receipt) {
27356
- const path72 = args.path || ".";
27737
+ const path82 = args.path || ".";
27357
27738
  let result;
27358
27739
  if (receipt.outputMode === "files_with_matches") {
27359
27740
  result = {
@@ -27399,15 +27780,15 @@ function buildGrepReceiptSuccess(args, receipt) {
27399
27780
  }
27400
27781
  return {
27401
27782
  pattern: args.pattern ?? "",
27402
- path: path72,
27783
+ path: path82,
27403
27784
  outputMode: receipt.outputMode,
27404
- workspaceResults: { [path72]: result }
27785
+ workspaceResults: { [path82]: result }
27405
27786
  };
27406
27787
  }
27407
27788
  function buildGrepSuccess(args, output) {
27408
27789
  const outputMode = normalizedGrepOutputMode(args.outputMode) ?? "content";
27409
27790
  const lines = output.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0 && !line.startsWith("[") && !/^no matches/i.test(line));
27410
- const path72 = args.path || ".";
27791
+ const path82 = args.path || ".";
27411
27792
  let result;
27412
27793
  if (outputMode === "files_with_matches") {
27413
27794
  result = {
@@ -27470,9 +27851,9 @@ function buildGrepSuccess(args, output) {
27470
27851
  }
27471
27852
  return {
27472
27853
  pattern: args.pattern ?? "",
27473
- path: path72,
27854
+ path: path82,
27474
27855
  outputMode,
27475
- workspaceResults: { [path72]: result }
27856
+ workspaceResults: { [path82]: result }
27476
27857
  };
27477
27858
  }
27478
27859
  function parseCallerShellOutput(output, isError) {
@@ -27534,7 +27915,7 @@ function redirect(exec2, tool, providerIdentifier, messageId, execId, execCase,
27534
27915
  }
27535
27916
  function execArgsToolCallId(exec2) {
27536
27917
  for (const value of Object.values(exec2)) {
27537
- if (!isRecord9(value)) continue;
27918
+ if (!isRecord10(value)) continue;
27538
27919
  const toolCallId = stringValue2(value.toolCallId);
27539
27920
  if (toolCallId) return toolCallId;
27540
27921
  }
@@ -27555,7 +27936,7 @@ function firstSchemaProperty(schema, candidates) {
27555
27936
  return candidates.find((candidate) => schemaHasProperty(schema, candidate));
27556
27937
  }
27557
27938
  function schemaHasProperty(schema, name) {
27558
- return isRecord9(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
27939
+ return isRecord10(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
27559
27940
  }
27560
27941
  function execReply2(exec2, resultName, result) {
27561
27942
  return {
@@ -27582,7 +27963,7 @@ function positiveNumber(value) {
27582
27963
  function stringValue2(value) {
27583
27964
  return typeof value === "string" ? value : "";
27584
27965
  }
27585
- function isRecord9(value) {
27966
+ function isRecord10(value) {
27586
27967
  return typeof value === "object" && value !== null && !Array.isArray(value);
27587
27968
  }
27588
27969
  var cursorAgentDescriptor = [
@@ -28413,18 +28794,18 @@ function decodeCursorServerMessage(payload) {
28413
28794
  const message = fromBinary(AgentServerMessageSchema, payload);
28414
28795
  const unknownExecFields = extractCursorUnknownExecFields(message);
28415
28796
  const json2 = toJson(AgentServerMessageSchema, message);
28416
- if (!isRecord10(json2)) throw new TypeError("Cursor server frame was not a message object");
28797
+ if (!isRecord11(json2)) throw new TypeError("Cursor server frame was not a message object");
28417
28798
  if (unknownExecFields.length > 0) {
28418
28799
  Object.defineProperty(json2, CURSOR_UNKNOWN_EXEC_FIELDS, { value: unknownExecFields });
28419
28800
  }
28420
28801
  return json2;
28421
28802
  }
28422
28803
  function extractCursorUnknownExecFields(message) {
28423
- if (!isRecord10(message) || !isRecord10(message.message)) return [];
28424
- if (message.message.case !== "execServerMessage" || !isRecord10(message.message.value)) return [];
28804
+ if (!isRecord11(message) || !isRecord11(message.message)) return [];
28805
+ if (message.message.case !== "execServerMessage" || !isRecord11(message.message.value)) return [];
28425
28806
  const fields = message.message.value.$unknown;
28426
28807
  if (!Array.isArray(fields)) return [];
28427
- return fields.filter((field) => isRecord10(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
28808
+ return fields.filter((field) => isRecord11(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
28428
28809
  }
28429
28810
  function parseConnectEndStreamError(payload) {
28430
28811
  try {
@@ -28746,7 +29127,7 @@ function cursorToolArgumentBytes(argumentsText) {
28746
29127
  } catch {
28747
29128
  return {};
28748
29129
  }
28749
- if (!isRecord10(parsed)) return {};
29130
+ if (!isRecord11(parsed)) return {};
28750
29131
  return Object.fromEntries(Object.entries(parsed).map(([name, value]) => [
28751
29132
  name,
28752
29133
  Buffer.from(toBinary(ValueSchema, fromJson(ValueSchema, value))).toString("base64")
@@ -30031,7 +30412,7 @@ ${argumentsText}`;
30031
30412
  const handleFrame = (frame, replayed = false) => {
30032
30413
  const unknownExecFields = frame[CURSOR_UNKNOWN_EXEC_FIELDS] ?? [];
30033
30414
  lastFrame = describeCursorServerFrame(frame, unknownExecFields);
30034
- const tokenDetails = isRecord10(frame.conversationCheckpointUpdate) && isRecord10(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
30415
+ const tokenDetails = isRecord11(frame.conversationCheckpointUpdate) && isRecord11(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
30035
30416
  const checkpointContextTokens = positiveTokenCount(tokenDetails?.usedTokens);
30036
30417
  const checkpointContextWindow = positiveTokenCount(tokenDetails?.maxTokens);
30037
30418
  if (!replayed) {
@@ -30044,7 +30425,7 @@ ${argumentsText}`;
30044
30425
  ...checkpointContextWindow === void 0 ? {} : { contextWindow: checkpointContextWindow }
30045
30426
  });
30046
30427
  }
30047
- if (isRecord10(frame.conversationCheckpointUpdate)) {
30428
+ if (isRecord11(frame.conversationCheckpointUpdate)) {
30048
30429
  if (checkpointContextTokens !== void 0) {
30049
30430
  wireLog("cursor.wire.checkpoint", {
30050
30431
  model: diagnosticModel,
@@ -30067,7 +30448,7 @@ ${argumentsText}`;
30067
30448
  }
30068
30449
  return;
30069
30450
  }
30070
- if (isRecord10(frame.kvServerMessage)) {
30451
+ if (isRecord11(frame.kvServerMessage)) {
30071
30452
  const kv = kvReply(frame.kvServerMessage, blobs);
30072
30453
  stream.write(encodeCursorClientMessage(kv.message));
30073
30454
  if (kv.fetch) {
@@ -30088,7 +30469,7 @@ ${argumentsText}`;
30088
30469
  });
30089
30470
  return;
30090
30471
  }
30091
- if (isRecord10(frame.interactionQuery)) {
30472
+ if (isRecord11(frame.interactionQuery)) {
30092
30473
  const reply = cursorInteractionQueryReply(frame.interactionQuery);
30093
30474
  stream.write(encodeCursorClientMessage(reply.message));
30094
30475
  report("client.reply", { model: diagnosticModel, reply: reply.replyKind });
@@ -30104,7 +30485,7 @@ ${argumentsText}`;
30104
30485
  }
30105
30486
  return;
30106
30487
  }
30107
- if (isRecord10(frame.error)) {
30488
+ if (isRecord11(frame.error)) {
30108
30489
  if (state === "attached") {
30109
30490
  emit({ type: "error", error: cursorError(frame.error) });
30110
30491
  completeRun("server_error");
@@ -30133,8 +30514,8 @@ ${argumentsText}`;
30133
30514
  return;
30134
30515
  }
30135
30516
  if (state !== "attached") return;
30136
- if (isRecord10(frame.execServerMessage)) {
30137
- if (isRecord10(frame.execServerMessage.requestContextArgs)) {
30517
+ if (isRecord11(frame.execServerMessage)) {
30518
+ if (isRecord11(frame.execServerMessage.requestContextArgs)) {
30138
30519
  stream.write(encodeCursorClientMessage(cursorRequestContextReply(frame.execServerMessage, tools)));
30139
30520
  report("client.reply", { model: diagnosticModel, reply: "exec.requestContext" });
30140
30521
  return;
@@ -30223,10 +30604,10 @@ ${argumentsText}`;
30223
30604
  }
30224
30605
  return;
30225
30606
  }
30226
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
30607
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
30227
30608
  if (update === void 0) return;
30228
30609
  if (isSettledToolUpdate(update)) return;
30229
- if (isRecord10(update.textDelta) && typeof update.textDelta.text === "string") {
30610
+ if (isRecord11(update.textDelta) && typeof update.textDelta.text === "string") {
30230
30611
  activeSegment.outputText += update.textDelta.text;
30231
30612
  emit({
30232
30613
  type: "response.output_text.delta",
@@ -30237,7 +30618,7 @@ ${argumentsText}`;
30237
30618
  });
30238
30619
  return;
30239
30620
  }
30240
- if (isRecord10(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
30621
+ if (isRecord11(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
30241
30622
  activeSegment.outputText += update.thinkingDelta.text;
30242
30623
  emit({
30243
30624
  type: "response.reasoning_summary_text.delta",
@@ -30247,12 +30628,12 @@ ${argumentsText}`;
30247
30628
  });
30248
30629
  return;
30249
30630
  }
30250
- if (isRecord10(update.tokenDelta)) {
30631
+ if (isRecord11(update.tokenDelta)) {
30251
30632
  const tokens = positiveTokenCount(update.tokenDelta.tokens);
30252
30633
  if (tokens !== void 0) activeSegment.contextOutputTokens += tokens;
30253
30634
  return;
30254
30635
  }
30255
- if (isRecord10(update.toolCallStarted)) {
30636
+ if (isRecord11(update.toolCallStarted)) {
30256
30637
  const wireCall = mcpCallFromToolUpdate(update.toolCallStarted);
30257
30638
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30258
30639
  if (call) {
@@ -30262,7 +30643,7 @@ ${argumentsText}`;
30262
30643
  }
30263
30644
  return;
30264
30645
  }
30265
- if (isRecord10(update.partialToolCall)) {
30646
+ if (isRecord11(update.partialToolCall)) {
30266
30647
  const wireCall = mcpCallFromToolUpdate(update.partialToolCall);
30267
30648
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30268
30649
  if (!call) return;
@@ -30273,7 +30654,7 @@ ${argumentsText}`;
30273
30654
  rescheduleToolTurnFinish();
30274
30655
  return;
30275
30656
  }
30276
- if (isRecord10(update.toolCallCompleted)) {
30657
+ if (isRecord11(update.toolCallCompleted)) {
30277
30658
  const wireCall = mcpCallFromToolUpdate(update.toolCallCompleted);
30278
30659
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
30279
30660
  if (!call) return;
@@ -30286,7 +30667,7 @@ ${argumentsText}`;
30286
30667
  rescheduleToolTurnFinish();
30287
30668
  return;
30288
30669
  }
30289
- if (isRecord10(update.turnEnded)) completeRun("turn_ended");
30670
+ if (isRecord11(update.turnEnded)) completeRun("turn_ended");
30290
30671
  };
30291
30672
  const eventsFor = (segment) => (async function* () {
30292
30673
  try {
@@ -30497,34 +30878,34 @@ var CURSOR_INTERACTION_QUERY_CASES = [
30497
30878
  ];
30498
30879
  var CURSOR_KV_CASES = ["getBlobArgs", "setBlobArgs"];
30499
30880
  function describeCursorServerFrame(frame, unknownExecFields = []) {
30500
- if (isRecord10(frame.interactionUpdate)) {
30881
+ if (isRecord11(frame.interactionUpdate)) {
30501
30882
  return `interactionUpdate.${cursorNestedRecordCase(
30502
30883
  frame.interactionUpdate,
30503
30884
  CURSOR_INTERACTION_UPDATE_CASES
30504
30885
  )}`;
30505
30886
  }
30506
- if (isRecord10(frame.execServerMessage)) {
30887
+ if (isRecord11(frame.execServerMessage)) {
30507
30888
  const knownCase = cursorNestedRecordCase(frame.execServerMessage, CURSOR_EXEC_CASES);
30508
30889
  return `execServerMessage.${knownCase === "unknown" ? cursorUnknownExecCaseName(unknownExecFields) : knownCase}`;
30509
30890
  }
30510
- if (isRecord10(frame.interactionQuery)) {
30891
+ if (isRecord11(frame.interactionQuery)) {
30511
30892
  return `interactionQuery.${cursorNestedRecordCase(
30512
30893
  frame.interactionQuery,
30513
30894
  CURSOR_INTERACTION_QUERY_CASES
30514
30895
  )}`;
30515
30896
  }
30516
- if (isRecord10(frame.kvServerMessage)) {
30897
+ if (isRecord11(frame.kvServerMessage)) {
30517
30898
  return `kvServerMessage.${cursorNestedRecordCase(frame.kvServerMessage, CURSOR_KV_CASES)}`;
30518
30899
  }
30519
- if (isRecord10(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
30520
- if (isRecord10(frame.error)) return "error";
30900
+ if (isRecord11(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
30901
+ if (isRecord11(frame.error)) return "error";
30521
30902
  return "unknown";
30522
30903
  }
30523
30904
  function isCursorHeartbeatFrame(frame) {
30524
- return isRecord10(frame.interactionUpdate) && isRecord10(frame.interactionUpdate.heartbeat);
30905
+ return isRecord11(frame.interactionUpdate) && isRecord11(frame.interactionUpdate.heartbeat);
30525
30906
  }
30526
30907
  function cursorNestedRecordCase(value, cases) {
30527
- return cases.find((candidate) => isRecord10(value[candidate])) ?? "unknown";
30908
+ return cases.find((candidate) => isRecord11(value[candidate])) ?? "unknown";
30528
30909
  }
30529
30910
  function positiveTokenCount(value) {
30530
30911
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) return void 0;
@@ -30536,8 +30917,8 @@ function cursorInteractionQueryReply(query) {
30536
30917
  const response = (result = {}) => ({
30537
30918
  interactionResponse: { id, ...result }
30538
30919
  });
30539
- if (isRecord10(query.createPlanRequestQuery)) {
30540
- const args = isRecord10(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
30920
+ if (isRecord11(query.createPlanRequestQuery)) {
30921
+ const args = isRecord11(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
30541
30922
  const name = stringValue3(args?.name)?.trim();
30542
30923
  const overview = stringValue3(args?.overview)?.trim();
30543
30924
  const plan = stringValue3(args?.plan)?.trim();
@@ -30553,7 +30934,7 @@ function cursorInteractionQueryReply(query) {
30553
30934
  ` } : {}
30554
30935
  };
30555
30936
  }
30556
- if (isRecord10(query.askQuestionInteractionQuery)) {
30937
+ if (isRecord11(query.askQuestionInteractionQuery)) {
30557
30938
  return {
30558
30939
  message: response({
30559
30940
  askQuestionInteractionResponse: {
@@ -30563,7 +30944,7 @@ function cursorInteractionQueryReply(query) {
30563
30944
  replyKind: "interaction.askQuestion.rejected"
30564
30945
  };
30565
30946
  }
30566
- if (isRecord10(query.switchModeRequestQuery)) {
30947
+ if (isRecord11(query.switchModeRequestQuery)) {
30567
30948
  return {
30568
30949
  message: response({
30569
30950
  switchModeRequestResponse: {
@@ -30573,19 +30954,19 @@ function cursorInteractionQueryReply(query) {
30573
30954
  replyKind: "interaction.switchMode.rejected"
30574
30955
  };
30575
30956
  }
30576
- if (isRecord10(query.webSearchRequestQuery)) {
30957
+ if (isRecord11(query.webSearchRequestQuery)) {
30577
30958
  return {
30578
30959
  message: response({ webSearchRequestResponse: { approved: {} } }),
30579
30960
  replyKind: "interaction.webSearch.approved"
30580
30961
  };
30581
30962
  }
30582
- if (isRecord10(query.exaSearchRequestQuery)) {
30963
+ if (isRecord11(query.exaSearchRequestQuery)) {
30583
30964
  return {
30584
30965
  message: response({ exaSearchRequestResponse: { approved: {} } }),
30585
30966
  replyKind: "interaction.exaSearch.approved"
30586
30967
  };
30587
30968
  }
30588
- if (isRecord10(query.exaFetchRequestQuery)) {
30969
+ if (isRecord11(query.exaFetchRequestQuery)) {
30589
30970
  return {
30590
30971
  message: response({ exaFetchRequestResponse: { approved: {} } }),
30591
30972
  replyKind: "interaction.exaFetch.approved"
@@ -30595,7 +30976,7 @@ function cursorInteractionQueryReply(query) {
30595
30976
  }
30596
30977
  function kvReply(kv, blobs) {
30597
30978
  const id = kv.id ?? 0;
30598
- if (isRecord10(kv.getBlobArgs)) {
30979
+ if (isRecord11(kv.getBlobArgs)) {
30599
30980
  const blobId = typeof kv.getBlobArgs.blobId === "string" ? kv.getBlobArgs.blobId : "";
30600
30981
  const blobData = blobs.get(blobId);
30601
30982
  return {
@@ -30607,7 +30988,7 @@ function kvReply(kv, blobs) {
30607
30988
  }
30608
30989
  };
30609
30990
  }
30610
- if (isRecord10(kv.setBlobArgs)) {
30991
+ if (isRecord11(kv.setBlobArgs)) {
30611
30992
  const blobId = typeof kv.setBlobArgs.blobId === "string" ? kv.setBlobArgs.blobId : "";
30612
30993
  const blobData = typeof kv.setBlobArgs.blobData === "string" ? kv.setBlobArgs.blobData : "";
30613
30994
  if (blobId) blobs.set(blobId, blobData);
@@ -30658,7 +31039,7 @@ function repairCursorArgumentValue(value, schema) {
30658
31039
  return { value: String(value), count: 1 };
30659
31040
  }
30660
31041
  if (Array.isArray(value)) {
30661
- const itemSchema = isRecord10(schema) ? schema.items : void 0;
31042
+ const itemSchema = isRecord11(schema) ? schema.items : void 0;
30662
31043
  if (itemSchema === void 0) return { value, count: 0 };
30663
31044
  let repairedValues;
30664
31045
  let count2 = 0;
@@ -30671,7 +31052,7 @@ function repairCursorArgumentValue(value, schema) {
30671
31052
  });
30672
31053
  return { value: repairedValues ?? value, count: count2 };
30673
31054
  }
30674
- if (!isRecord10(value) || !isRecord10(schema) || !isRecord10(schema.properties)) {
31055
+ if (!isRecord11(value) || !isRecord11(schema) || !isRecord11(schema.properties)) {
30675
31056
  return { value, count: 0 };
30676
31057
  }
30677
31058
  let repairedValue;
@@ -30687,12 +31068,12 @@ function repairCursorArgumentValue(value, schema) {
30687
31068
  return { value: repairedValue ?? value, count };
30688
31069
  }
30689
31070
  function cursorSchemaRequiresString(schema) {
30690
- if (!isRecord10(schema)) return false;
31071
+ if (!isRecord11(schema)) return false;
30691
31072
  if (schema.type === "string") return true;
30692
31073
  return Array.isArray(schema.type) && schema.type.includes("string") && schema.type.every((type) => type === "string" || type === "null");
30693
31074
  }
30694
31075
  function mcpCallFromToolUpdate(value) {
30695
- const toolCall = isRecord10(value.toolCall) ? value.toolCall : void 0;
31076
+ const toolCall = isRecord11(value.toolCall) ? value.toolCall : void 0;
30696
31077
  const args = toolCall ? mcpArgsFromToolCall(toolCall) : void 0;
30697
31078
  if (!args) return null;
30698
31079
  const publicCallId = stringValue3(value.callId);
@@ -30717,7 +31098,7 @@ var CURSOR_TOOL_UPDATE_CASES = [
30717
31098
  function cursorToolUpdateIdentifiers(update) {
30718
31099
  for (const key of CURSOR_TOOL_UPDATE_CASES) {
30719
31100
  const value = update[key];
30720
- if (!isRecord10(value)) continue;
31101
+ if (!isRecord11(value)) continue;
30721
31102
  const call = mcpCallFromToolUpdate(value);
30722
31103
  if (!call) return [];
30723
31104
  return [...new Set(
@@ -30727,9 +31108,9 @@ function cursorToolUpdateIdentifiers(update) {
30727
31108
  return void 0;
30728
31109
  }
30729
31110
  function isCursorClientToolFrame(frame, tools, redirectTools) {
30730
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
31111
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
30731
31112
  if (update !== void 0) return cursorToolUpdateIdentifiers(update) !== void 0;
30732
- const exec2 = isRecord10(frame.execServerMessage) ? frame.execServerMessage : void 0;
31113
+ const exec2 = isRecord11(frame.execServerMessage) ? frame.execServerMessage : void 0;
30733
31114
  if (exec2 === void 0) return false;
30734
31115
  const wireCall = mcpCallFromExecMessage(exec2);
30735
31116
  const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
@@ -30745,16 +31126,16 @@ function isCursorClientToolFrame(frame, tools, redirectTools) {
30745
31126
  ) !== null;
30746
31127
  }
30747
31128
  function isCursorParkedResidueFrame(frame, parked) {
30748
- const update = isRecord10(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
31129
+ const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
30749
31130
  if (update === void 0) return false;
30750
- if (isRecord10(update.tokenDelta)) return true;
31131
+ if (isRecord11(update.tokenDelta)) return true;
30751
31132
  const identifiers = cursorToolUpdateIdentifiers(update);
30752
31133
  if (identifiers === void 0 || identifiers.length === 0 || parked === void 0) return false;
30753
31134
  const sealed = new Set(parked.flatMap((call) => [call.callId, call.toolCallId]));
30754
31135
  return identifiers.some((identifier) => sealed.has(identifier));
30755
31136
  }
30756
31137
  function mcpCallFromExecMessage(value) {
30757
- const args = isRecord10(value.mcpArgs) ? value.mcpArgs : void 0;
31138
+ const args = isRecord11(value.mcpArgs) ? value.mcpArgs : void 0;
30758
31139
  if (!args) return null;
30759
31140
  const toolCallId = stringValue3(args.toolCallId);
30760
31141
  if (!toolCallId) return null;
@@ -30772,14 +31153,14 @@ function mcpCallFromExecMessage(value) {
30772
31153
  };
30773
31154
  }
30774
31155
  function mcpArgsFromToolCall(toolCall) {
30775
- const direct = isRecord10(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
30776
- if (direct && isRecord10(direct.args)) return direct.args;
30777
- const tool = isRecord10(toolCall.tool) ? toolCall.tool : void 0;
30778
- const nested = tool && isRecord10(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
30779
- return nested && isRecord10(nested.args) ? nested.args : void 0;
31156
+ const direct = isRecord11(toolCall.mcpToolCall) ? toolCall.mcpToolCall : void 0;
31157
+ if (direct && isRecord11(direct.args)) return direct.args;
31158
+ const tool = isRecord11(toolCall.tool) ? toolCall.tool : void 0;
31159
+ const nested = tool && isRecord11(tool.mcpToolCall) ? tool.mcpToolCall : void 0;
31160
+ return nested && isRecord11(nested.args) ? nested.args : void 0;
30780
31161
  }
30781
31162
  function cursorMcpArguments(args) {
30782
- if (!isRecord10(args.args) || Object.keys(args.args).length === 0) return {};
31163
+ if (!isRecord11(args.args) || Object.keys(args.args).length === 0) return {};
30783
31164
  const decoded = {};
30784
31165
  for (const [name, value] of Object.entries(args.args)) {
30785
31166
  if (typeof value !== "string") {
@@ -30854,7 +31235,7 @@ function cursorError(value) {
30854
31235
  message: typeof value.message === "string" ? value.message : "Cursor request failed"
30855
31236
  };
30856
31237
  }
30857
- function isRecord10(value) {
31238
+ function isRecord11(value) {
30858
31239
  return typeof value === "object" && value !== null && !Array.isArray(value);
30859
31240
  }
30860
31241
  var DEFAULT_CURSOR_DIAGNOSTIC_MAX_BYTES = 4 * 1024 * 1024;
@@ -31031,177 +31412,6 @@ function kimiAnthropicHeaders(requestHeaders, apiKey) {
31031
31412
  }
31032
31413
  return headers;
31033
31414
  }
31034
- function normalizeAiGatewaySettings(value) {
31035
- if (!isRecord11(value) || value.version !== 1) return { version: 1 };
31036
- const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord11(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
31037
- const model = findGatewayModel(entry.id);
31038
- if (!model) return [];
31039
- const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
31040
- const exposed = efforts.length > 0 ? narrowEffortLadder(model, efforts) : void 0;
31041
- return [{
31042
- id: entry.id,
31043
- ...exposed ? { efforts: [...exposed] } : {},
31044
- ...entry.hostOnly === true ? { hostOnly: true } : {}
31045
- }];
31046
- }) : [];
31047
- const providerPriority = sanitizeProviderPriority(value.providerPriority);
31048
- const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
31049
- return {
31050
- version: 1,
31051
- ...models.length > 0 ? { models } : {},
31052
- ...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
31053
- ...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
31054
- ...providerPriority ? { providerPriority: [...providerPriority] } : {},
31055
- ...compactCeiling !== void 0 ? { compactCeiling } : {}
31056
- };
31057
- }
31058
- function sanitizeProviderPriority(value) {
31059
- if (!Array.isArray(value)) return void 0;
31060
- const seen = /* @__PURE__ */ new Set();
31061
- const cleaned = [];
31062
- for (const entry of value) {
31063
- if (typeof entry !== "string") continue;
31064
- if (!GATEWAY_PROVIDERS.includes(entry)) continue;
31065
- const provider = entry;
31066
- if (seen.has(provider)) continue;
31067
- seen.add(provider);
31068
- cleaned.push(provider);
31069
- }
31070
- return cleaned.length > 0 ? cleaned : void 0;
31071
- }
31072
- function isRecord11(value) {
31073
- return typeof value === "object" && value !== null && !Array.isArray(value);
31074
- }
31075
- function resolveAiGatewaySelection(settings2) {
31076
- const enabled = [];
31077
- const hostOnlyIds = /* @__PURE__ */ new Set();
31078
- const effortExposure = {};
31079
- for (const entry of settings2?.models ?? []) {
31080
- const model = findGatewayModel(entry.id);
31081
- if (!model) continue;
31082
- if (entry.hostOnly === true) hostOnlyIds.add(model.id);
31083
- if (enabled.includes(model)) continue;
31084
- enabled.push(model);
31085
- const exposed = narrowEffortLadder(model, entry.efforts);
31086
- if (exposed) effortExposure[model.id] = exposed;
31087
- }
31088
- const models = sortGatewayModelsByProvider(enabled);
31089
- const delegationModels = models.filter((model) => !hostOnlyIds.has(model.id));
31090
- return { models, delegationModels, effortExposure, providerPriority: settings2?.providerPriority };
31091
- }
31092
- function narrowEffortLadder(model, efforts) {
31093
- if (!efforts || efforts.length === 0) return void 0;
31094
- const ladder = buildGatewayModelConstraints(model).effortLadder;
31095
- const narrowed = ladder.filter((rung) => efforts.includes(rung));
31096
- if (narrowed.length === 0 || narrowed.length === ladder.length) return void 0;
31097
- return narrowed;
31098
- }
31099
- function exposableEffortLadder(model) {
31100
- return buildGatewayModelConstraints(model).effortLadder;
31101
- }
31102
- function sortGatewayModelsByProvider(models) {
31103
- return [...models].sort((left, right) => {
31104
- const providerDelta = GATEWAY_PROVIDERS.indexOf(left.provider) - GATEWAY_PROVIDERS.indexOf(right.provider);
31105
- if (providerDelta !== 0) return providerDelta;
31106
- return GATEWAY_MODELS.indexOf(left) - GATEWAY_MODELS.indexOf(right);
31107
- });
31108
- }
31109
- function parseAiGatewayUpdate(value) {
31110
- if (value === null) return { ok: true, value: void 0 };
31111
- if (!value || typeof value !== "object" || Array.isArray(value)) return { ok: false };
31112
- const record42 = value;
31113
- const extraKeys = Object.keys(record42).filter(
31114
- (key) => key !== "models" && key !== "defaultModel" && key !== "providerPriority"
31115
- );
31116
- if (extraKeys.length > 0) return { ok: false };
31117
- const models = [];
31118
- if (record42.models !== void 0) {
31119
- if (!Array.isArray(record42.models)) return { ok: false };
31120
- for (const raw of record42.models) {
31121
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ok: false };
31122
- const entry = raw;
31123
- if (Object.keys(entry).some((key) => key !== "id" && key !== "efforts" && key !== "hostOnly")) {
31124
- return { ok: false };
31125
- }
31126
- if (typeof entry.id !== "string") return { ok: false };
31127
- if (entry.hostOnly !== void 0 && typeof entry.hostOnly !== "boolean") return { ok: false };
31128
- const model = findGatewayModel(entry.id);
31129
- if (!model) return { ok: false };
31130
- if (models.some((existing) => existing.id === model.id)) return { ok: false };
31131
- const efforts = parseExposedEfforts(model, entry.efforts);
31132
- if (efforts === null) return { ok: false };
31133
- models.push({
31134
- id: model.id,
31135
- ...efforts ? { efforts } : {},
31136
- ...entry.hostOnly === true ? { hostOnly: true } : {}
31137
- });
31138
- }
31139
- }
31140
- let providerPriority;
31141
- const hasProviderPriority = Object.prototype.hasOwnProperty.call(record42, "providerPriority");
31142
- if (hasProviderPriority) {
31143
- if (!Array.isArray(record42.providerPriority)) return { ok: false };
31144
- providerPriority = [];
31145
- for (const raw of record42.providerPriority) {
31146
- if (typeof raw !== "string") return { ok: false };
31147
- if (!GATEWAY_PROVIDERS.includes(raw)) return { ok: false };
31148
- const provider = raw;
31149
- if (providerPriority.includes(provider)) return { ok: false };
31150
- providerPriority.push(provider);
31151
- }
31152
- }
31153
- if (models.length === 0 && providerPriority === void 0) {
31154
- return { ok: true, value: void 0 };
31155
- }
31156
- return {
31157
- ok: true,
31158
- value: {
31159
- ...models.length > 0 ? { models } : {},
31160
- ...providerPriority !== void 0 ? { providerPriority } : {}
31161
- }
31162
- };
31163
- }
31164
- function parseExposedEfforts(model, value) {
31165
- if (value === void 0) return void 0;
31166
- if (!Array.isArray(value)) return null;
31167
- const ladder = exposableEffortLadder(model);
31168
- const seen = [];
31169
- for (const raw of value) {
31170
- if (typeof raw !== "string") return null;
31171
- if (!ladder.includes(raw)) return null;
31172
- if (seen.includes(raw)) return null;
31173
- seen.push(raw);
31174
- }
31175
- if (seen.length === 0) return null;
31176
- const ordered = ladder.filter((rung) => seen.includes(rung));
31177
- return ordered.length === ladder.length ? void 0 : ordered;
31178
- }
31179
- function buildAiGatewayCatalog(models = GATEWAY_MODELS) {
31180
- return {
31181
- providers: GATEWAY_PROVIDERS.map((provider) => ({
31182
- id: provider,
31183
- models: models.filter((model) => model.provider === provider).map((model) => toCatalogModel(model))
31184
- }))
31185
- };
31186
- }
31187
- function toCatalogModel(model) {
31188
- const levels = exposableEffortLadder(model);
31189
- return {
31190
- id: model.id,
31191
- name: bareModelName(model),
31192
- contextWindow: model.contextWindow ?? null,
31193
- oneMillion: hasClaudeOneMillionMarker(toClaudeGatewayModelId(model)),
31194
- maxMode: model.cursorMaxMode === true,
31195
- fast: model.id.endsWith("-fast"),
31196
- capabilityClass: model.capabilityClass ?? null,
31197
- description: model.description ?? null,
31198
- effort: levels.length > 0 ? { levels } : null
31199
- };
31200
- }
31201
- function bareModelName(model) {
31202
- const prefix = `${GATEWAY_PROVIDER_NAMES[model.provider]}-`;
31203
- return model.displayName.startsWith(prefix) ? model.displayName.slice(prefix.length) : model.displayName;
31204
- }
31205
31415
  var codexRequestPolicy = {
31206
31416
  provider: "codex",
31207
31417
  shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
@@ -31412,6 +31622,14 @@ function createAiGatewayRouter(deps) {
31412
31622
  return false;
31413
31623
  }
31414
31624
  };
31625
+ const xaiEndpoint = () => {
31626
+ if (!deps.readAiGatewaySettings) return DEFAULT_XAI_ENDPOINT_PREFERENCE;
31627
+ try {
31628
+ return deps.readAiGatewaySettings().xaiEndpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE;
31629
+ } catch {
31630
+ return DEFAULT_XAI_ENDPOINT_PREFERENCE;
31631
+ }
31632
+ };
31415
31633
  const compactCeiling = () => {
31416
31634
  try {
31417
31635
  return gatewaySettings()?.compactCeiling;
@@ -31559,7 +31777,10 @@ function createAiGatewayRouter(deps) {
31559
31777
  );
31560
31778
  return true;
31561
31779
  }
31562
- 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));
31780
+ const gateway = deps.gateway ?? (target2.provider === "cursor" ? ownedCursorGateway : target2.provider === "opencode" ? createOpencodeGateway(opencodeGoWire(target2)) : target2.provider === "xai" ? new AnthropicMessagesGateway(new XaiResponsesAdapter({
31781
+ fetch: fetchImpl,
31782
+ endpoint: xaiEndpoint()
31783
+ })) : createGatewayFor(target2, chatgptAccountId, deps.originator));
31563
31784
  const diagnosticsEnabled = target2.provider === "cursor" ? cursorDiagnosticsEnabled() : void 0;
31564
31785
  const modelContextWindow = typeof target2.contextWindow === "number" && Number.isFinite(target2.contextWindow) && target2.contextWindow > 0 ? target2.contextWindow : void 0;
31565
31786
  const upstream = await gateway.stream(body, {
@@ -31721,6 +31942,7 @@ function createAiGatewaySettingsStore(deps = {}) {
31721
31942
  // 무관한 모델 노출 저장 한 번이 사용자의 소진 순서를 지운다.
31722
31943
  ...current.providerPriority ? { providerPriority: current.providerPriority } : {},
31723
31944
  ...current.compactCeiling !== void 0 ? { compactCeiling: current.compactCeiling } : {},
31945
+ ...current.xaiEndpoint !== void 0 ? { xaiEndpoint: current.xaiEndpoint } : {},
31724
31946
  ...value ?? {}
31725
31947
  })),
31726
31948
  writeCursorDiagnosticsEnabled: (enabled) => update((current) => normalizeAiGatewaySettings({
@@ -31746,12 +31968,22 @@ function createAiGatewaySettingsStore(deps = {}) {
31746
31968
  const withoutCeiling = { ...next };
31747
31969
  delete withoutCeiling.compactCeiling;
31748
31970
  return withoutCeiling;
31971
+ }),
31972
+ writeXaiEndpoint: (endpoint) => update((current) => {
31973
+ const next = normalizeAiGatewaySettings({
31974
+ ...current,
31975
+ ...endpoint === void 0 ? {} : { xaiEndpoint: endpoint }
31976
+ });
31977
+ if (endpoint !== void 0) return next;
31978
+ const withoutEndpoint = { ...next };
31979
+ delete withoutEndpoint.xaiEndpoint;
31980
+ return withoutEndpoint;
31749
31981
  })
31750
31982
  };
31751
31983
  }
31752
31984
  function fileExists(filePath) {
31753
31985
  try {
31754
- return fs32.lstatSync(filePath).isFile();
31986
+ return fs42.lstatSync(filePath).isFile();
31755
31987
  } catch {
31756
31988
  return false;
31757
31989
  }
@@ -31760,7 +31992,7 @@ var CONCLUSIVE_LEGACY_READ_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EISDIR",
31760
31992
  function readLegacySettings(legacyPath) {
31761
31993
  let raw;
31762
31994
  try {
31763
- raw = fs32.readFileSync(legacyPath, "utf-8");
31995
+ raw = fs42.readFileSync(legacyPath, "utf-8");
31764
31996
  } catch (error51) {
31765
31997
  return CONCLUSIVE_LEGACY_READ_ERRORS.has(error51.code ?? "") ? { kind: "nothing" } : { kind: "unavailable" };
31766
31998
  }
@@ -32006,7 +32238,7 @@ var GATEWAY_MODELS_DOCTRINE = {
32006
32238
  // usageGuidelines에 적은 문장은 모델에 도달하지 않으므로, 틀리면 조용히 실패하는 두 규칙은
32007
32239
  // 여기에 둔다. 나머지 판정 규칙은 응답 본문을 보면 알 수 있어 싣지 않는다 — 길어질수록
32008
32240
  // 읽히지 않고, 읽히지 않으면 없는 것과 같다.
32009
- 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.`,
32241
+ 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.`,
32010
32242
  promptSnippet: `gateway_models \u2014 Live roster of assignable gateway models: constraints, capability class, benchmark evidence, provider allowances, and the user's provider priority.`,
32011
32243
  whenToUse: [],
32012
32244
  whenNotToUse: [],
@@ -32403,7 +32635,7 @@ function buildDisabledSkillOverrides(skillNames) {
32403
32635
 
32404
32636
  // ../../packages/fleet-admiral/src/agent-cli/assets.generated.ts
32405
32637
  var EMBEDDED_AGENT_CLI_HOOK_ASSETS = [
32406
- { 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' }
32638
+ { 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' }
32407
32639
  ];
32408
32640
  var DIR_MODE = 448;
32409
32641
  var FILE_MODE = 384;
@@ -45954,6 +46186,15 @@ function registerTerminalSettingsRoutes(ctx, deps) {
45954
46186
  ));
45955
46187
  return true;
45956
46188
  }
46189
+ if ("xaiEndpoint" in update) {
46190
+ const stored = deps.aiGatewayStore.writeXaiEndpoint(update.xaiEndpoint);
46191
+ ctx.host.http.writeJson(res, 200, toTerminalSettingsState(
46192
+ deps.globalOptionsService.load(),
46193
+ stored,
46194
+ deps.wireLogRuntime.enabled()
46195
+ ));
46196
+ return true;
46197
+ }
45957
46198
  const updated = deps.globalOptionsService.update((current) => ({ ...current, ...update }));
45958
46199
  ctx.host.http.writeJson(res, 200, toTerminalSettingsState(
45959
46200
  updated,
@@ -45981,7 +46222,8 @@ function toTerminalSettingsState(data, aiGateway, wireLogEnabled2) {
45981
46222
  aiGatewayCatalog: buildAiGatewayCatalog(),
45982
46223
  cursorDiagnosticsEnabled: aiGateway.cursorDiagnosticsEnabled === true,
45983
46224
  wireLogEnabled: wireLogEnabled2,
45984
- compactCeiling: aiGateway.compactCeiling ?? null
46225
+ compactCeiling: aiGateway.compactCeiling ?? null,
46226
+ xaiEndpoint: aiGateway.xaiEndpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE
45985
46227
  };
45986
46228
  }
45987
46229
  function resolveClaudeCodeSystemPrompt(data) {
@@ -46016,6 +46258,9 @@ function parseTerminalSettingsBody(value) {
46016
46258
  const ceiling = normalizeCompactCeiling(body.compactCeiling);
46017
46259
  return ceiling === void 0 ? null : { compactCeiling: ceiling };
46018
46260
  }
46261
+ if (keys[0] === "xaiEndpoint") {
46262
+ return typeof body.xaiEndpoint === "string" && XAI_ENDPOINT_PREFERENCES.includes(body.xaiEndpoint) ? { xaiEndpoint: body.xaiEndpoint } : null;
46263
+ }
46019
46264
  return null;
46020
46265
  }
46021
46266
  function isAgentIdleDormantMinutes(value) {
@@ -52857,80 +53102,6 @@ function registerAiGatewayRoutes(ctx, deps = {}) {
52857
53102
  ]);
52858
53103
  }
52859
53104
 
52860
- // ../fleet-plugins/terminal/server/global.ts
52861
- var GLOBAL_SHELL_OPERATION_PREFIX = "global-shell:theater:";
52862
- var GLOBAL_SHELL_OPERATION_TYPE = "shell";
52863
- function registerGlobalShellRoutes(ctx, runtime) {
52864
- registerRouter(ctx, "global/ticket", async ({ req, res }) => {
52865
- if (req.method !== "POST") {
52866
- ctx.host.http.writeJson(res, 405, { error: "Method not allowed" });
52867
- return true;
52868
- }
52869
- if (!ctx.host.security.isTerminalAuthorized(req)) {
52870
- ctx.host.http.writeJson(res, 401, { error: "Unauthorized" });
52871
- return true;
52872
- }
52873
- if (req.headers.origin === void 0) {
52874
- ctx.host.http.writeJson(res, 401, { error: "Unauthorized" });
52875
- return true;
52876
- }
52877
- const body = await ctx.host.http.readJsonBody(req);
52878
- const operationId = typeof body?.operationId === "string" ? body.operationId : typeof body?.sessionId === "string" ? body.sessionId : null;
52879
- if (!operationId) {
52880
- ctx.host.http.writeJson(res, 400, { error: "operation_id_required" });
52881
- return true;
52882
- }
52883
- if (!operationId.startsWith(GLOBAL_SHELL_OPERATION_PREFIX)) {
52884
- ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
52885
- return true;
52886
- }
52887
- const encodedTheaterId = operationId.slice(GLOBAL_SHELL_OPERATION_PREFIX.length);
52888
- if (encodedTheaterId.length === 0) {
52889
- ctx.host.http.writeJson(res, 400, { error: "theater_id_required" });
52890
- return true;
52891
- }
52892
- let theaterId;
52893
- try {
52894
- theaterId = decodeURIComponent(encodedTheaterId);
52895
- } catch {
52896
- ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
52897
- return true;
52898
- }
52899
- if (theaterId.length === 0 || encodeURIComponent(theaterId) !== encodedTheaterId) {
52900
- ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
52901
- return true;
52902
- }
52903
- let theaterPath;
52904
- try {
52905
- theaterPath = ctx.host.paths.resolveTheaterPath(theaterId);
52906
- } catch {
52907
- theaterPath = null;
52908
- }
52909
- if (!theaterPath) {
52910
- ctx.host.http.writeJson(res, 404, { error: "theater_not_found" });
52911
- return true;
52912
- }
52913
- if (!runtime.canAttach(operationId)) {
52914
- ctx.host.http.writeJson(res, 503, { error: "Terminal session capacity exhausted" });
52915
- return true;
52916
- }
52917
- const colorScheme = body?.colorScheme === "light" || body?.colorScheme === "dark" ? body.colorScheme : void 0;
52918
- const role = ctx.host.security.resolveTerminalSocketRole(req) === "viewer" ? "viewer" : readSocketRole(body?.role);
52919
- ctx.host.http.writeJson(res, 200, runtime.issueTicket({
52920
- cwd: theaterPath,
52921
- sessionId: operationId,
52922
- operationId,
52923
- operationType: GLOBAL_SHELL_OPERATION_TYPE,
52924
- pluginId: ctx.pluginId,
52925
- theaterId,
52926
- kind: "shell",
52927
- ...colorScheme ? { colorScheme } : {},
52928
- ...role ? { role } : {}
52929
- }));
52930
- return true;
52931
- }, { method: "POST", path: "", summary: "Issue a Global Shell WebSocket ticket.", category: "Terminal Plugin", gate: "origin-strict", transport: "http" });
52932
- }
52933
-
52934
53105
  // ../fleet-plugins/terminal/server/model-auth-state.ts
52935
53106
  var MODEL_AUTH_STORE_IDS = Object.freeze({
52936
53107
  kimi: KIMI_AUTH_PROVIDER_ID,
@@ -53242,7 +53413,6 @@ var routes_default = definePlugin({
53242
53413
  });
53243
53414
  ctx.host.lifecycle.registerCleanup(unsubscribeControl);
53244
53415
  registerShellRoutes(ctx, runtime);
53245
- registerGlobalShellRoutes(ctx, runtime);
53246
53416
  registerTerminalSettingsRoutes(ctx, {
53247
53417
  globalOptionsService: infraServices.globalOptionsService,
53248
53418
  aiGatewayStore,