@dotobokuri/fleet-console 1.68.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +92 -2
- package/dist/client/assets/{_baseUniq-BPBd-J9P.js → _baseUniq-81Y5kFtp.js} +1 -1
- package/dist/client/assets/{arc-spHqy4X3.js → arc-d96Fgk-5.js} +1 -1
- package/dist/client/assets/{architectureDiagram-Q4EWVU46-7CHqKfxu.js → architectureDiagram-Q4EWVU46-BBgIklLp.js} +1 -1
- package/dist/client/assets/{blockDiagram-DXYQGD6D-YasFDgl_.js → blockDiagram-DXYQGD6D-BCjY9dJk.js} +1 -1
- package/dist/client/assets/{c4Diagram-AHTNJAMY-CcoPJq56.js → c4Diagram-AHTNJAMY-BVJRdf8q.js} +1 -1
- package/dist/client/assets/channel-CiSQi5S5.js +1 -0
- package/dist/client/assets/{chunk-4BX2VUAB-MYBJn9BE.js → chunk-4BX2VUAB-CT7BCzBg.js} +1 -1
- package/dist/client/assets/{chunk-4TB4RGXK-C1wg6GR_.js → chunk-4TB4RGXK-DUbDaHiY.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-BoufMT1O.js → chunk-55IACEB6-C7HDwq0R.js} +1 -1
- package/dist/client/assets/{chunk-EDXVE4YY-BzAhAIl3.js → chunk-EDXVE4YY-Mh16Bf7t.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-yVrLsKzP.js → chunk-FMBD7UC4-D3BjqAun.js} +1 -1
- package/dist/client/assets/{chunk-OYMX7WX6-YiiKaqRQ.js → chunk-OYMX7WX6-DmzxPT1k.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-CqWQlGHT.js → chunk-QZHKN3VN-CaZdQK6Z.js} +1 -1
- package/dist/client/assets/{chunk-YZCP3GAM-9yLOmU5k.js → chunk-YZCP3GAM-Q2hrlgLY.js} +1 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-Cy-ZC6xF.js +1 -0
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-Cy-ZC6xF.js +1 -0
- package/dist/client/assets/clone-BAhE6Fq8.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-XkTuSq7v.js → cose-bilkent-S5V4N54A-CPdIsNiQ.js} +1 -1
- package/dist/client/assets/{dagre-KV5264BT-DyzXIEAe.js → dagre-KV5264BT-BYWdUXO0.js} +1 -1
- package/dist/client/assets/{diagram-5BDNPKRD-DF24YlCa.js → diagram-5BDNPKRD-BC8rqmOK.js} +1 -1
- package/dist/client/assets/{diagram-G4DWMVQ6-CVhcj9RK.js → diagram-G4DWMVQ6-CES6iBQQ.js} +1 -1
- package/dist/client/assets/{diagram-MMDJMWI5-C-kGKk4K.js → diagram-MMDJMWI5-BfhQrSaN.js} +1 -1
- package/dist/client/assets/{diagram-TYMM5635-mr285WbR.js → diagram-TYMM5635-C2FgHNxP.js} +1 -1
- package/dist/client/assets/{erDiagram-SMLLAGMA-BtEx-XlU.js → erDiagram-SMLLAGMA-KQgKZTcf.js} +1 -1
- package/dist/client/assets/{flowDiagram-DWJPFMVM-DuWy3xzN.js → flowDiagram-DWJPFMVM-7Ytk1sX_.js} +1 -1
- package/dist/client/assets/{ganttDiagram-T4ZO3ILL-B2-xEikU.js → ganttDiagram-T4ZO3ILL-C4yl6vGV.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-EM17u_t7.js → gitGraphDiagram-UUTBAWPF-DyN7iLk4.js} +1 -1
- package/dist/client/assets/{graph-xuE12FIq.js → graph-BsOHL3Ty.js} +1 -1
- package/dist/client/assets/index-2049WCXu.css +1 -0
- package/dist/client/assets/index-DJcpFTNB.js +466 -0
- package/dist/client/assets/{infoDiagram-42DDH7IO-B3MF4XtW.js → infoDiagram-42DDH7IO-BIOEjyDP.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-DoQ2mGyh.js → ishikawaDiagram-UXIWVN3A-C18t-DEH.js} +1 -1
- package/dist/client/assets/{journeyDiagram-VCZTEJTY-GeR9sFH-.js → journeyDiagram-VCZTEJTY-BysZXCkq.js} +1 -1
- package/dist/client/assets/{kanban-definition-6JOO6SKY-DrrYMuvL.js → kanban-definition-6JOO6SKY-Zdulrt1W.js} +1 -1
- package/dist/client/assets/{layout-DH63A-3u.js → layout-DhT9CiMw.js} +1 -1
- package/dist/client/assets/{linear-BIjE6zB1.js → linear-DQna1rOZ.js} +1 -1
- package/dist/client/assets/{mermaid.core-yrrC2Lqo.js → mermaid.core-C0sjt4NJ.js} +4 -4
- package/dist/client/assets/{min-CR-H8E6U.js → min-Dyx0ykEh.js} +1 -1
- package/dist/client/assets/{mindmap-definition-QFDTVHPH-BzSC43J-.js → mindmap-definition-QFDTVHPH-BzEvAUNd.js} +1 -1
- package/dist/client/assets/{pieDiagram-DEJITSTG-BdghNtCc.js → pieDiagram-DEJITSTG-Cd4ORVnw.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-34T5L4WZ-s_zN2epw.js → quadrantDiagram-34T5L4WZ-CvNxhBIm.js} +1 -1
- package/dist/client/assets/{requirementDiagram-MS252O5E-DuiGG6Tx.js → requirementDiagram-MS252O5E-CuGuie-o.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-XADWPNL6-Bp0JBk2g.js → sankeyDiagram-XADWPNL6-zn7buHsU.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-FGHM5R23-AzQ3M31V.js → sequenceDiagram-FGHM5R23-BxDReh8o.js} +1 -1
- package/dist/client/assets/{stateDiagram-FHFEXIEX-BGgm44ev.js → stateDiagram-FHFEXIEX-DtZ0UE1G.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-aYct9Owm.js +1 -0
- package/dist/client/assets/{timeline-definition-GMOUNBTQ-UqfsiBJY.js → timeline-definition-GMOUNBTQ-DfKveVha.js} +1 -1
- package/dist/client/assets/{vennDiagram-DHZGUBPP-PsCGF9nR.js → vennDiagram-DHZGUBPP-CZe6StT_.js} +1 -1
- package/dist/client/assets/{wardley-RL74JXVD-BDQbnh-d.js → wardley-RL74JXVD-B10WfMsc.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-NUSXRM2D-CtVA1JMs.js → wardleyDiagram-NUSXRM2D-DzN04fy9.js} +1 -1
- package/dist/client/assets/{xychartDiagram-5P7HB3ND-BsLlZWbc.js → xychartDiagram-5P7HB3ND-CIgNRRNp.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/fleet-plugins/ledger/routes.mjs +92 -2
- package/dist/fleet-plugins/quota/routes.mjs +92 -2
- package/dist/fleet-plugins/repository/routes.mjs +41 -5
- package/dist/fleet-plugins/scuttlebutt/routes.mjs +92 -2
- package/dist/fleet-plugins/terminal/routes.mjs +672 -412
- package/dist/fleet.mjs +582 -260
- package/package.json +1 -1
- package/dist/client/assets/channel-DfEjadrw.js +0 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-D9vQdv0q.js +0 -1
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-D9vQdv0q.js +0 -1
- package/dist/client/assets/clone-Ck2x5JX2.js +0 -1
- package/dist/client/assets/index-C5EOZGlC.js +0 -466
- package/dist/client/assets/index-CHHE3nPw.css +0 -1
- 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
|
|
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
|
|
16021
|
+
const cached3 = messagePrototypes.get(desc);
|
|
16022
16022
|
let prototype;
|
|
16023
16023
|
let members;
|
|
16024
|
-
if (
|
|
16025
|
-
({ prototype, members } =
|
|
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
|
|
16797
|
-
if (
|
|
16798
|
-
return
|
|
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`);
|
|
@@ -20655,7 +20669,7 @@ var benchmarks_default = {
|
|
|
20655
20669
|
};
|
|
20656
20670
|
var models_default = {
|
|
20657
20671
|
version: 1,
|
|
20658
|
-
updatedAt: "2026-08-
|
|
20672
|
+
updatedAt: "2026-08-20T00:00:00Z",
|
|
20659
20673
|
providers: {
|
|
20660
20674
|
codex: {
|
|
20661
20675
|
name: "Codex",
|
|
@@ -21051,7 +21065,7 @@ var models_default = {
|
|
|
21051
21065
|
cursor: {
|
|
21052
21066
|
name: "Cursor",
|
|
21053
21067
|
defaultModel: "auto",
|
|
21054
|
-
source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; claude-opus-5 and claude-fable-5 standard/Max Mode windows observed 2026-08-10; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05)",
|
|
21068
|
+
source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; claude-opus-5 and claude-fable-5 standard/Max Mode windows observed 2026-08-10; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05); gpt-5.6-sol/terra/luna, gemini-3.7-flash, and kimi-k3 ids, effort rungs, and api quotaScope observed 2026-08-20 from live GetUsableModels (cursor-agent 2026.08.11-e8db854) and GetCurrentPeriodUsage autoBucketModels. Their windows are unmeasured because Cursor answers a first-turn Run with an empty token_details, so each carries the conservative cross-provider figure (272000 from the Codex catalog for the GPT-5.6 lineup, 256000 elsewhere); no Max Mode or -fast sibling is published for them",
|
|
21055
21069
|
models: [
|
|
21056
21070
|
{
|
|
21057
21071
|
modelId: "auto",
|
|
@@ -21233,6 +21247,96 @@ var models_default = {
|
|
|
21233
21247
|
upstreamModelIdTemplate: "claude-fable-5-{effort}"
|
|
21234
21248
|
},
|
|
21235
21249
|
benchmarkKey: "claude-fable-5"
|
|
21250
|
+
},
|
|
21251
|
+
{
|
|
21252
|
+
modelId: "gpt-5.6-sol",
|
|
21253
|
+
name: "GPT-5.6-Sol",
|
|
21254
|
+
capabilityClass: "flagship",
|
|
21255
|
+
quotaScope: "api",
|
|
21256
|
+
contextWindow: 272e3,
|
|
21257
|
+
effort: {
|
|
21258
|
+
supported: true,
|
|
21259
|
+
levels: [
|
|
21260
|
+
"low",
|
|
21261
|
+
"medium",
|
|
21262
|
+
"high",
|
|
21263
|
+
"xhigh",
|
|
21264
|
+
"max"
|
|
21265
|
+
],
|
|
21266
|
+
upstreamModelIdTemplate: "gpt-5.6-sol-{effort}"
|
|
21267
|
+
},
|
|
21268
|
+
benchmarkKey: "gpt-5.6-sol"
|
|
21269
|
+
},
|
|
21270
|
+
{
|
|
21271
|
+
modelId: "gpt-5.6-terra",
|
|
21272
|
+
name: "GPT-5.6-Terra",
|
|
21273
|
+
capabilityClass: "standard",
|
|
21274
|
+
quotaScope: "api",
|
|
21275
|
+
contextWindow: 272e3,
|
|
21276
|
+
effort: {
|
|
21277
|
+
supported: true,
|
|
21278
|
+
levels: [
|
|
21279
|
+
"low",
|
|
21280
|
+
"medium",
|
|
21281
|
+
"high",
|
|
21282
|
+
"xhigh",
|
|
21283
|
+
"max"
|
|
21284
|
+
],
|
|
21285
|
+
upstreamModelIdTemplate: "gpt-5.6-terra-{effort}"
|
|
21286
|
+
},
|
|
21287
|
+
benchmarkKey: "gpt-5.6-terra"
|
|
21288
|
+
},
|
|
21289
|
+
{
|
|
21290
|
+
modelId: "gpt-5.6-luna",
|
|
21291
|
+
name: "GPT-5.6-Luna",
|
|
21292
|
+
capabilityClass: "light",
|
|
21293
|
+
quotaScope: "api",
|
|
21294
|
+
contextWindow: 272e3,
|
|
21295
|
+
effort: {
|
|
21296
|
+
supported: true,
|
|
21297
|
+
levels: [
|
|
21298
|
+
"low",
|
|
21299
|
+
"medium",
|
|
21300
|
+
"high",
|
|
21301
|
+
"xhigh",
|
|
21302
|
+
"max"
|
|
21303
|
+
],
|
|
21304
|
+
upstreamModelIdTemplate: "gpt-5.6-luna-{effort}"
|
|
21305
|
+
},
|
|
21306
|
+
benchmarkKey: "gpt-5.6-luna"
|
|
21307
|
+
},
|
|
21308
|
+
{
|
|
21309
|
+
modelId: "gemini-3.7-flash",
|
|
21310
|
+
name: "Gemini-3.7-Flash",
|
|
21311
|
+
capabilityClass: "light",
|
|
21312
|
+
quotaScope: "api",
|
|
21313
|
+
contextWindow: 256e3,
|
|
21314
|
+
effort: {
|
|
21315
|
+
supported: true,
|
|
21316
|
+
levels: [
|
|
21317
|
+
"low",
|
|
21318
|
+
"medium",
|
|
21319
|
+
"high"
|
|
21320
|
+
],
|
|
21321
|
+
upstreamModelIdTemplate: "gemini-3.7-flash-{effort}"
|
|
21322
|
+
}
|
|
21323
|
+
},
|
|
21324
|
+
{
|
|
21325
|
+
modelId: "kimi-k3",
|
|
21326
|
+
name: "Kimi-K3",
|
|
21327
|
+
capabilityClass: "flagship",
|
|
21328
|
+
quotaScope: "api",
|
|
21329
|
+
contextWindow: 256e3,
|
|
21330
|
+
effort: {
|
|
21331
|
+
supported: true,
|
|
21332
|
+
levels: [
|
|
21333
|
+
"low",
|
|
21334
|
+
"high",
|
|
21335
|
+
"max"
|
|
21336
|
+
],
|
|
21337
|
+
upstreamModelIdTemplate: "kimi-k3-{effort}"
|
|
21338
|
+
},
|
|
21339
|
+
benchmarkKey: "kimi-k3"
|
|
21236
21340
|
}
|
|
21237
21341
|
]
|
|
21238
21342
|
},
|
|
@@ -22169,11 +22273,21 @@ function translateMessage(message) {
|
|
|
22169
22273
|
const items = [];
|
|
22170
22274
|
const parts = [];
|
|
22171
22275
|
let reasoningContent = "";
|
|
22276
|
+
let reasoningBlob;
|
|
22172
22277
|
const takeReasoningContent = () => {
|
|
22173
|
-
if (role !== "assistant"
|
|
22278
|
+
if (role !== "assistant") return {};
|
|
22279
|
+
const blob = reasoningBlob;
|
|
22174
22280
|
const reasoning = reasoningContent;
|
|
22175
22281
|
reasoningContent = "";
|
|
22176
|
-
|
|
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
|
+
};
|
|
22177
22291
|
};
|
|
22178
22292
|
const flushParts = (includeReasoning = true) => {
|
|
22179
22293
|
if (parts.length === 0) {
|
|
@@ -22222,6 +22336,9 @@ function translateMessage(message) {
|
|
|
22222
22336
|
if (role === "assistant" && typeof block.thinking === "string") {
|
|
22223
22337
|
reasoningContent += block.thinking;
|
|
22224
22338
|
}
|
|
22339
|
+
if (role === "assistant") {
|
|
22340
|
+
reasoningBlob = decodeReasoningSignature(block.signature) ?? reasoningBlob;
|
|
22341
|
+
}
|
|
22225
22342
|
break;
|
|
22226
22343
|
case "redacted_thinking":
|
|
22227
22344
|
break;
|
|
@@ -22377,6 +22494,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
|
|
|
22377
22494
|
let model = fallbackModel;
|
|
22378
22495
|
let text2 = "";
|
|
22379
22496
|
const thinking = /* @__PURE__ */ new Map();
|
|
22497
|
+
const reasoningBlobs = /* @__PURE__ */ new Map();
|
|
22380
22498
|
let stopReason = "end_turn";
|
|
22381
22499
|
let outputTokens = 0;
|
|
22382
22500
|
let inputTokens = 0;
|
|
@@ -22418,6 +22536,16 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
|
|
|
22418
22536
|
break;
|
|
22419
22537
|
}
|
|
22420
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
|
+
}
|
|
22421
22549
|
if (event.item.type === "web_search_call") {
|
|
22422
22550
|
const query = derivedWebSearchQuery(event.item.action);
|
|
22423
22551
|
content.push({
|
|
@@ -22454,7 +22582,7 @@ async function collectAnthropicMessage(events, fallbackModel, options = {}) {
|
|
|
22454
22582
|
content.unshift(...[...thinking].map(([itemId, value]) => ({
|
|
22455
22583
|
type: "thinking",
|
|
22456
22584
|
thinking: value,
|
|
22457
|
-
signature: `gateway_${reasoningBlockKey(itemId)}`
|
|
22585
|
+
signature: reasoningBlobs.get(itemId) ?? `gateway_${reasoningBlockKey(itemId)}`
|
|
22458
22586
|
})));
|
|
22459
22587
|
return {
|
|
22460
22588
|
id,
|
|
@@ -22491,6 +22619,7 @@ async function* encodeAnthropicSse(events, options = {}) {
|
|
|
22491
22619
|
let messageStopped = false;
|
|
22492
22620
|
let sawToolUse = false;
|
|
22493
22621
|
let activeContentKey;
|
|
22622
|
+
const reasoningBlobs = /* @__PURE__ */ new Map();
|
|
22494
22623
|
const encode3 = (event, data) => encoder2.encode(`event: ${event}
|
|
22495
22624
|
data: ${JSON.stringify(data)}
|
|
22496
22625
|
|
|
@@ -22524,7 +22653,9 @@ data: ${JSON.stringify(data)}
|
|
|
22524
22653
|
...block.kind === "thinking" ? [encode3("content_block_delta", {
|
|
22525
22654
|
type: "content_block_delta",
|
|
22526
22655
|
index: block.index,
|
|
22527
|
-
|
|
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}` }
|
|
22528
22659
|
})] : [],
|
|
22529
22660
|
encode3("content_block_stop", {
|
|
22530
22661
|
type: "content_block_stop",
|
|
@@ -22650,6 +22781,19 @@ data: ${JSON.stringify(data)}
|
|
|
22650
22781
|
break;
|
|
22651
22782
|
}
|
|
22652
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
|
+
}
|
|
22653
22797
|
if (event.item.type === "function_call") {
|
|
22654
22798
|
let block = blocks2.get(event.item.id);
|
|
22655
22799
|
if (block === void 0) {
|
|
@@ -23254,6 +23398,13 @@ var OpenAIResponsesAdapter = class {
|
|
|
23254
23398
|
"idleTimeoutMs"
|
|
23255
23399
|
);
|
|
23256
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
|
+
}
|
|
23257
23408
|
async stream(request, options) {
|
|
23258
23409
|
if (options.apiKey.length === 0) {
|
|
23259
23410
|
throw new TypeError("apiKey must not be empty");
|
|
@@ -23270,7 +23421,8 @@ var OpenAIResponsesAdapter = class {
|
|
|
23270
23421
|
accept: "text/event-stream",
|
|
23271
23422
|
authorization: `Bearer ${options.apiKey}`,
|
|
23272
23423
|
"content-type": "application/json",
|
|
23273
|
-
...this.extraHeaders
|
|
23424
|
+
...this.extraHeaders,
|
|
23425
|
+
...this.perRequestHeaders(request)
|
|
23274
23426
|
},
|
|
23275
23427
|
body: JSON.stringify(payload),
|
|
23276
23428
|
signal: controller.signal
|
|
@@ -23331,6 +23483,10 @@ var CodexResponsesAdapter = class extends OpenAIResponsesAdapter {
|
|
|
23331
23483
|
});
|
|
23332
23484
|
this.isMarkedFetchFailure = fetchFailureTracker.isMarkedFailure;
|
|
23333
23485
|
}
|
|
23486
|
+
perRequestHeaders(request) {
|
|
23487
|
+
const sessionId = codexSessionIdentity(request);
|
|
23488
|
+
return sessionId === void 0 ? {} : { session_id: sessionId };
|
|
23489
|
+
}
|
|
23334
23490
|
async stream(request, options) {
|
|
23335
23491
|
const callController = new AbortController();
|
|
23336
23492
|
const unlinkCallAbort = linkAbortSignal(options.signal, callController);
|
|
@@ -23610,11 +23766,27 @@ function forOpenAIResponsesBackend(request, dropSamplingParams) {
|
|
|
23610
23766
|
}
|
|
23611
23767
|
return payload;
|
|
23612
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
|
+
}
|
|
23613
23781
|
function forChatGptBackend(request) {
|
|
23614
23782
|
const copy = { ...request };
|
|
23615
23783
|
for (const field of CHATGPT_UNSUPPORTED_FIELDS) {
|
|
23616
23784
|
delete copy[field];
|
|
23617
23785
|
}
|
|
23786
|
+
const sessionId = codexSessionIdentity(request);
|
|
23787
|
+
if (sessionId !== void 0) {
|
|
23788
|
+
copy.prompt_cache_key = sessionId;
|
|
23789
|
+
}
|
|
23618
23790
|
if (request.tool_choice === "none" || isClaudeCodeSuggestionMode(request)) {
|
|
23619
23791
|
delete copy.tools;
|
|
23620
23792
|
delete copy.tool_choice;
|
|
@@ -25715,25 +25887,249 @@ async function resolveXaiCliCredentials(deps, nowOrOptions = Date.now) {
|
|
|
25715
25887
|
const result = await resolveXaiCliAuth(deps, options);
|
|
25716
25888
|
return result.status === "ok" ? result.credentials : null;
|
|
25717
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
|
+
}
|
|
25718
26116
|
var XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
|
|
25719
26117
|
var XAI_CLI_RESPONSES_URL = "https://cli-chat-proxy.grok.com/v1/responses";
|
|
25720
|
-
var XAI_CLI_CLIENT_VERSION = "1.0.3";
|
|
25721
|
-
var XAI_PROXY_FALLBACK_STATUSES = /* @__PURE__ */ new Set([402, 426]);
|
|
25722
26118
|
var DEFAULT_XAI_RESPONSES_MAX_UPSTREAM_BODY_BYTES = 64 * 1024 * 1024;
|
|
25723
26119
|
var DEFAULT_XAI_RESPONSES_UPSTREAM_IDLE_TIMEOUT_MS = 3e4;
|
|
25724
26120
|
var DEFAULT_XAI_RESPONSES_FUNCTION_CALL_TIMEOUT_MS = 3e4;
|
|
25725
26121
|
var DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS = 6e4;
|
|
25726
26122
|
var XAI_RETRY_DELAY_MS = 200;
|
|
25727
|
-
var
|
|
26123
|
+
var XAI_REASONING_INCLUDE = "reasoning.encrypted_content";
|
|
25728
26124
|
function directXaiEndpoint() {
|
|
25729
26125
|
return { url: XAI_RESPONSES_URL, headers: {} };
|
|
25730
26126
|
}
|
|
25731
|
-
function proxyXaiEndpoint(model) {
|
|
26127
|
+
function proxyXaiEndpoint(model, clientVersion) {
|
|
25732
26128
|
return {
|
|
25733
26129
|
url: XAI_CLI_RESPONSES_URL,
|
|
25734
26130
|
headers: {
|
|
25735
26131
|
"x-xai-token-auth": "xai-grok-cli",
|
|
25736
|
-
"x-grok-client-version":
|
|
26132
|
+
"x-grok-client-version": clientVersion,
|
|
25737
26133
|
"x-grok-model-override": model
|
|
25738
26134
|
}
|
|
25739
26135
|
};
|
|
@@ -25746,6 +26142,8 @@ var XaiResponsesAdapter = class {
|
|
|
25746
26142
|
idleTimeoutMs;
|
|
25747
26143
|
functionCallTimeoutMs;
|
|
25748
26144
|
semanticStallTimeoutMs;
|
|
26145
|
+
endpointPreference;
|
|
26146
|
+
clientVersion;
|
|
25749
26147
|
extraHeaders;
|
|
25750
26148
|
constructor(options = {}) {
|
|
25751
26149
|
this.extraHeaders = options.headers ?? {};
|
|
@@ -25768,6 +26166,8 @@ var XaiResponsesAdapter = class {
|
|
|
25768
26166
|
options.semanticStallTimeoutMs ?? DEFAULT_XAI_RESPONSES_SEMANTIC_STALL_TIMEOUT_MS,
|
|
25769
26167
|
"semanticStallTimeoutMs"
|
|
25770
26168
|
);
|
|
26169
|
+
this.endpointPreference = options.endpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE;
|
|
26170
|
+
this.clientVersion = options.clientVersion ?? (() => xaiCliClientVersion());
|
|
25771
26171
|
}
|
|
25772
26172
|
async stream(request, options) {
|
|
25773
26173
|
if (options.apiKey.length === 0) {
|
|
@@ -25775,22 +26175,14 @@ var XaiResponsesAdapter = class {
|
|
|
25775
26175
|
}
|
|
25776
26176
|
const controller = new AbortController();
|
|
25777
26177
|
const unlinkAbort = linkAbortSignal(options.signal, controller);
|
|
25778
|
-
const
|
|
26178
|
+
const tools = xaiWireTools(request);
|
|
26179
|
+
let payload = forXaiResponsesBackend(request, tools);
|
|
26180
|
+
let replayAvailable = replaysXaiReasoning(request);
|
|
25779
26181
|
let retryAvailable = true;
|
|
25780
26182
|
let response;
|
|
25781
|
-
|
|
26183
|
+
const endpoint = this.endpointPreference === "cli-proxy" ? await this.proxyEndpoint(payload.model) : directXaiEndpoint();
|
|
25782
26184
|
try {
|
|
25783
26185
|
response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
|
|
25784
|
-
if (!response.ok && endpoint.url === XAI_RESPONSES_URL && XAI_PROXY_FALLBACK_STATUSES.has(response.status)) {
|
|
25785
|
-
wireLog("xai-responses.endpoint.fallback", {
|
|
25786
|
-
status: response.status,
|
|
25787
|
-
from: XAI_RESPONSES_URL,
|
|
25788
|
-
to: XAI_CLI_RESPONSES_URL
|
|
25789
|
-
});
|
|
25790
|
-
xaiProxyOnlyAccount = true;
|
|
25791
|
-
endpoint = proxyXaiEndpoint(payload.model);
|
|
25792
|
-
response = await this.fetchResponse(options.apiKey, payload, controller, endpoint);
|
|
25793
|
-
}
|
|
25794
26186
|
} catch (error51) {
|
|
25795
26187
|
if (!isRetryableXaiFetchSocket(error51, controller.signal, this.isMarkedFetchFailure)) {
|
|
25796
26188
|
unlinkAbort();
|
|
@@ -25813,18 +26205,41 @@ var XaiResponsesAdapter = class {
|
|
|
25813
26205
|
unlinkAbort();
|
|
25814
26206
|
return response;
|
|
25815
26207
|
}
|
|
25816
|
-
|
|
25817
|
-
|
|
25818
|
-
|
|
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 });
|
|
25819
26213
|
await abortableXaiDelay(XAI_RETRY_DELAY_MS, signal);
|
|
25820
|
-
const
|
|
25821
|
-
if (!
|
|
25822
|
-
throw new UpstreamProtocolError(`xAI retry failed with 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}`);
|
|
25823
26217
|
}
|
|
25824
|
-
return
|
|
25825
|
-
}
|
|
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
|
+
)
|
|
25826
26237
|
};
|
|
25827
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
|
+
}
|
|
25828
26243
|
async fetchResponse(apiKey, payload, controller, endpoint) {
|
|
25829
26244
|
wireLog("xai-responses.wire.request", { url: endpoint.url, payload });
|
|
25830
26245
|
const response = await this.fetchImpl(endpoint.url, {
|
|
@@ -25874,21 +26289,43 @@ var XaiResponsesAdapter = class {
|
|
|
25874
26289
|
return xaiWireTools(request) ?? [];
|
|
25875
26290
|
}
|
|
25876
26291
|
};
|
|
25877
|
-
function forXaiResponsesBackend(request, tools = xaiWireTools(request)) {
|
|
26292
|
+
function forXaiResponsesBackend(request, tools = xaiWireTools(request), replayReasoning = true) {
|
|
25878
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
|
+
}
|
|
25879
26317
|
return {
|
|
25880
26318
|
...rest,
|
|
25881
|
-
input
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
}
|
|
25886
|
-
const { reasoning_content: _reasoningContent, ...wireItem } = item;
|
|
25887
|
-
return wireItem;
|
|
25888
|
-
}),
|
|
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] } : {},
|
|
25889
26323
|
...tools === void 0 ? {} : { tools: [...tools] }
|
|
25890
26324
|
};
|
|
25891
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
|
+
}
|
|
25892
26329
|
function xaiWireTools(request) {
|
|
25893
26330
|
if (request.tools === void 0) return void 0;
|
|
25894
26331
|
const tools = request.tools;
|
|
@@ -25909,11 +26346,18 @@ function isToolSearchName(name) {
|
|
|
25909
26346
|
function toolNameMatches(declaredName, selectedName) {
|
|
25910
26347
|
return declaredName === selectedName || toolLeafName(declaredName) === toolLeafName(selectedName);
|
|
25911
26348
|
}
|
|
25912
|
-
function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable) {
|
|
26349
|
+
function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
|
|
25913
26350
|
return {
|
|
25914
26351
|
[Symbol.asyncIterator]() {
|
|
25915
26352
|
const source = events[Symbol.asyncIterator]();
|
|
25916
|
-
const iterator = generateXaiRetryEvents(
|
|
26353
|
+
const iterator = generateXaiRetryEvents(
|
|
26354
|
+
source,
|
|
26355
|
+
retry,
|
|
26356
|
+
controller,
|
|
26357
|
+
unlinkAbort,
|
|
26358
|
+
retryAvailable,
|
|
26359
|
+
replayAvailable
|
|
26360
|
+
);
|
|
25917
26361
|
return {
|
|
25918
26362
|
next: () => iterator.next(),
|
|
25919
26363
|
return: async () => {
|
|
@@ -25928,7 +26372,7 @@ function retryXaiEvents(events, retry, controller, unlinkAbort, retryAvailable)
|
|
|
25928
26372
|
}
|
|
25929
26373
|
};
|
|
25930
26374
|
}
|
|
25931
|
-
async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable) {
|
|
26375
|
+
async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, retryAvailable, replayAvailable) {
|
|
25932
26376
|
const lead = [];
|
|
25933
26377
|
let committed = false;
|
|
25934
26378
|
let normalCompletion = false;
|
|
@@ -25952,14 +26396,26 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
|
|
|
25952
26396
|
});
|
|
25953
26397
|
await source.return?.();
|
|
25954
26398
|
lead.length = 0;
|
|
25955
|
-
yield* await retry(controller.signal);
|
|
26399
|
+
yield* await retry(controller.signal, "retryable_failure");
|
|
25956
26400
|
return;
|
|
25957
26401
|
}
|
|
25958
26402
|
if (result.done) {
|
|
25959
|
-
yield* lead;
|
|
25960
26403
|
if (pendingError !== void 0) {
|
|
25961
|
-
|
|
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;
|
|
25962
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;
|
|
26417
|
+
}
|
|
26418
|
+
yield* lead;
|
|
25963
26419
|
normalCompletion = true;
|
|
25964
26420
|
return;
|
|
25965
26421
|
}
|
|
@@ -25970,7 +26426,7 @@ async function* generateXaiRetryEvents(source, retry, controller, unlinkAbort, r
|
|
|
25970
26426
|
wireLog("xai-responses.retry.discarded", pendingError === void 0 ? { reason: "response.failed", errorTypes } : { reason: "error_failed_pair", errorTypes });
|
|
25971
26427
|
await source.return?.();
|
|
25972
26428
|
lead.length = 0;
|
|
25973
|
-
yield* await retry(controller.signal);
|
|
26429
|
+
yield* await retry(controller.signal, "retryable_failure");
|
|
25974
26430
|
return;
|
|
25975
26431
|
}
|
|
25976
26432
|
pendingError = event;
|
|
@@ -26004,7 +26460,7 @@ function isRetryableXaiFailure(event) {
|
|
|
26004
26460
|
return event.type === "response.failed" && isRetryableXaiErrorType(event.response.error.type) || event.type === "error" && isRetryableXaiErrorType(event.error.type);
|
|
26005
26461
|
}
|
|
26006
26462
|
function isRetryableXaiErrorType(type) {
|
|
26007
|
-
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;
|
|
26008
26464
|
}
|
|
26009
26465
|
function commitsXaiOutput(event) {
|
|
26010
26466
|
if (event.type === "response.created" || event.type === "response.reasoning_summary_text.delta") {
|
|
@@ -26309,7 +26765,7 @@ function parseEventFrame3(frame) {
|
|
|
26309
26765
|
);
|
|
26310
26766
|
}
|
|
26311
26767
|
logRawWireEvent("xai-responses.wire.event", eventName, parsed);
|
|
26312
|
-
if (
|
|
26768
|
+
if (isRecord8(parsed) && typeof parsed.type !== "string" && eventName !== void 0) {
|
|
26313
26769
|
parsed = { ...parsed, type: eventName };
|
|
26314
26770
|
}
|
|
26315
26771
|
return canonicalEvent3(parsed);
|
|
@@ -26319,7 +26775,7 @@ function withoutXaiSentinel(text2) {
|
|
|
26319
26775
|
return text2.includes(XAI_EOS_SENTINEL) ? text2.split(XAI_EOS_SENTINEL).join("") : text2;
|
|
26320
26776
|
}
|
|
26321
26777
|
function canonicalEvent3(value) {
|
|
26322
|
-
if (!
|
|
26778
|
+
if (!isRecord8(value) || typeof value.type !== "string") {
|
|
26323
26779
|
throw new UpstreamProtocolError("Grok CLI SSE event was not an object with a type");
|
|
26324
26780
|
}
|
|
26325
26781
|
switch (value.type) {
|
|
@@ -26464,19 +26920,34 @@ function outputItem3(value) {
|
|
|
26464
26920
|
arguments: typeof item.arguments === "string" ? item.arguments : ""
|
|
26465
26921
|
};
|
|
26466
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
|
+
}
|
|
26467
26932
|
return void 0;
|
|
26468
26933
|
}
|
|
26934
|
+
var XAI_OVERLOADED_ERROR_TYPE = "overloaded_error";
|
|
26935
|
+
var XAI_CAPACITY_MESSAGE = /\bat capacity\b|\boverloaded\b/i;
|
|
26469
26936
|
function canonicalError3(value) {
|
|
26470
26937
|
const error51 = record3(value, "error");
|
|
26471
26938
|
const message = string32(error51.message, "error.message");
|
|
26472
|
-
|
|
26473
|
-
return { type, message };
|
|
26939
|
+
return { type: xaiErrorType(error51, message), message };
|
|
26474
26940
|
}
|
|
26475
|
-
function
|
|
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) {
|
|
26476
26947
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26477
26948
|
}
|
|
26478
26949
|
function record3(value, name) {
|
|
26479
|
-
if (!
|
|
26950
|
+
if (!isRecord8(value)) {
|
|
26480
26951
|
throw new UpstreamProtocolError(`${name} must be an object`);
|
|
26481
26952
|
}
|
|
26482
26953
|
return value;
|
|
@@ -26548,38 +27019,38 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26548
27019
|
"shell_command",
|
|
26549
27020
|
"exec_command"
|
|
26550
27021
|
]);
|
|
26551
|
-
if (
|
|
27022
|
+
if (isRecord9(exec2.readArgs)) {
|
|
26552
27023
|
return [execReply(exec2, "readResult", {
|
|
26553
27024
|
error: { path: stringValue(exec2.readArgs.path), error: readMessage3 }
|
|
26554
27025
|
})];
|
|
26555
27026
|
}
|
|
26556
|
-
if (
|
|
27027
|
+
if (isRecord9(exec2.writeArgs)) {
|
|
26557
27028
|
return [execReply(exec2, "writeResult", {
|
|
26558
27029
|
rejected: { path: stringValue(exec2.writeArgs.path), reason: mutationMessage }
|
|
26559
27030
|
})];
|
|
26560
27031
|
}
|
|
26561
|
-
if (
|
|
27032
|
+
if (isRecord9(exec2.deleteArgs)) {
|
|
26562
27033
|
return [execReply(exec2, "deleteResult", {
|
|
26563
27034
|
rejected: { path: stringValue(exec2.deleteArgs.path), reason: mutationMessage }
|
|
26564
27035
|
})];
|
|
26565
27036
|
}
|
|
26566
|
-
if (
|
|
27037
|
+
if (isRecord9(exec2.lsArgs)) {
|
|
26567
27038
|
return [execReply(exec2, "lsResult", {
|
|
26568
27039
|
error: { path: stringValue(exec2.lsArgs.path), error: listMessage }
|
|
26569
27040
|
})];
|
|
26570
27041
|
}
|
|
26571
|
-
if (
|
|
27042
|
+
if (isRecord9(exec2.grepArgs)) {
|
|
26572
27043
|
return [execReply(exec2, "grepResult", { error: { error: grepMessage } })];
|
|
26573
27044
|
}
|
|
26574
|
-
if (
|
|
27045
|
+
if (isRecord9(exec2.shellArgs)) {
|
|
26575
27046
|
return [execReply(exec2, "shellResult", shellFailure(exec2.shellArgs, shellMessage))];
|
|
26576
27047
|
}
|
|
26577
|
-
if (
|
|
27048
|
+
if (isRecord9(exec2.shellStreamArgs)) {
|
|
26578
27049
|
const args = exec2.shellStreamArgs;
|
|
26579
27050
|
const cwd = stringValue(args.workingDirectory);
|
|
26580
27051
|
return [
|
|
26581
27052
|
execReply(exec2, "shellStream", {
|
|
26582
|
-
start:
|
|
27053
|
+
start: isRecord9(args.requestedSandboxPolicy) ? { sandboxPolicy: args.requestedSandboxPolicy } : {}
|
|
26583
27054
|
}),
|
|
26584
27055
|
execReply(exec2, "shellStream", { stderr: { data: shellMessage } }),
|
|
26585
27056
|
execReply(exec2, "shellStream", { exit: { code: 1, cwd, aborted: true } }),
|
|
@@ -26587,7 +27058,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26587
27058
|
{ execClientControlMessage: { streamClose: { id: numberValue(exec2.id) } } }
|
|
26588
27059
|
];
|
|
26589
27060
|
}
|
|
26590
|
-
if (
|
|
27061
|
+
if (isRecord9(exec2.backgroundShellSpawnArgs)) {
|
|
26591
27062
|
const args = exec2.backgroundShellSpawnArgs;
|
|
26592
27063
|
return [execReply(exec2, "backgroundShellSpawnResult", {
|
|
26593
27064
|
error: {
|
|
@@ -26597,15 +27068,15 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26597
27068
|
}
|
|
26598
27069
|
})];
|
|
26599
27070
|
}
|
|
26600
|
-
if (
|
|
27071
|
+
if (isRecord9(exec2.writeShellStdinArgs)) {
|
|
26601
27072
|
return [execReply(exec2, "writeShellStdinResult", { error: { error: shellMessage } })];
|
|
26602
27073
|
}
|
|
26603
|
-
if (
|
|
27074
|
+
if (isRecord9(exec2.fetchArgs)) {
|
|
26604
27075
|
return [execReply(exec2, "fetchResult", {
|
|
26605
27076
|
error: { url: stringValue(exec2.fetchArgs.url), error: networkMessage }
|
|
26606
27077
|
})];
|
|
26607
27078
|
}
|
|
26608
|
-
if (
|
|
27079
|
+
if (isRecord9(exec2.diagnosticsArgs)) {
|
|
26609
27080
|
return [execReply(exec2, "diagnosticsResult", {
|
|
26610
27081
|
error: {
|
|
26611
27082
|
path: stringValue(exec2.diagnosticsArgs.path),
|
|
@@ -26613,12 +27084,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26613
27084
|
}
|
|
26614
27085
|
})];
|
|
26615
27086
|
}
|
|
26616
|
-
if (
|
|
27087
|
+
if (isRecord9(exec2.listMcpResourcesExecArgs)) {
|
|
26617
27088
|
return [execReply(exec2, "listMcpResourcesExecResult", {
|
|
26618
27089
|
error: { error: retryMessage(clientTools, ["ListMcpResources", "list_mcp_resources"]) }
|
|
26619
27090
|
})];
|
|
26620
27091
|
}
|
|
26621
|
-
if (
|
|
27092
|
+
if (isRecord9(exec2.readMcpResourceExecArgs)) {
|
|
26622
27093
|
return [execReply(exec2, "readMcpResourceExecResult", {
|
|
26623
27094
|
error: {
|
|
26624
27095
|
uri: stringValue(exec2.readMcpResourceExecArgs.uri),
|
|
@@ -26626,12 +27097,12 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26626
27097
|
}
|
|
26627
27098
|
})];
|
|
26628
27099
|
}
|
|
26629
|
-
if (
|
|
27100
|
+
if (isRecord9(exec2.recordScreenArgs)) {
|
|
26630
27101
|
return [execReply(exec2, "recordScreenResult", {
|
|
26631
27102
|
failure: { error: retryMessage(clientTools, ["record_screen", "computer_use"]) }
|
|
26632
27103
|
})];
|
|
26633
27104
|
}
|
|
26634
|
-
if (
|
|
27105
|
+
if (isRecord9(exec2.computerUseArgs)) {
|
|
26635
27106
|
return [execReply(exec2, "computerUseResult", {
|
|
26636
27107
|
error: {
|
|
26637
27108
|
error: retryMessage(clientTools, ["computer_use"]),
|
|
@@ -26641,7 +27112,7 @@ function cursorNativeExecPolicyReplies(exec2, clientTools) {
|
|
|
26641
27112
|
}
|
|
26642
27113
|
})];
|
|
26643
27114
|
}
|
|
26644
|
-
if (
|
|
27115
|
+
if (isRecord9(exec2.mcpArgs)) {
|
|
26645
27116
|
return [execReply(exec2, "mcpResult", {
|
|
26646
27117
|
error: { error: retryMessage(clientTools, []) }
|
|
26647
27118
|
})];
|
|
@@ -26713,7 +27184,7 @@ function numberValue(value) {
|
|
|
26713
27184
|
function stringValue(value) {
|
|
26714
27185
|
return typeof value === "string" ? value : "";
|
|
26715
27186
|
}
|
|
26716
|
-
function
|
|
27187
|
+
function isRecord9(value) {
|
|
26717
27188
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26718
27189
|
}
|
|
26719
27190
|
var EXECUTE_HOOK_FIELD_NUMBER = 27;
|
|
@@ -26869,14 +27340,14 @@ function isCursorWithheldToolName(name) {
|
|
|
26869
27340
|
function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
|
|
26870
27341
|
const messageId = numberValue2(exec2.id ?? 0);
|
|
26871
27342
|
const execId = stringValue2(exec2.execId) || `redirect-${messageId}`;
|
|
26872
|
-
if (
|
|
26873
|
-
const
|
|
26874
|
-
if (!
|
|
27343
|
+
if (isRecord10(exec2.readArgs)) {
|
|
27344
|
+
const path82 = stringValue2(exec2.readArgs.path);
|
|
27345
|
+
if (!path82) return null;
|
|
26875
27346
|
if ([exec2.readArgs.offset, exec2.readArgs.limit].some((value) => typeof value === "number" && value < 0)) return null;
|
|
26876
27347
|
const offset = positiveNumber(exec2.readArgs.offset);
|
|
26877
27348
|
const limit = positiveNumber(exec2.readArgs.limit);
|
|
26878
27349
|
if (offset !== void 0 || limit !== void 0) return null;
|
|
26879
|
-
const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue,
|
|
27350
|
+
const mapped = tools.filter((tool) => matchesLeaf(tool, READ_CANDIDATES)).map((tool) => ({ tool, args: readArguments(tool.inputSchemaValue, path82) })).find((candidate) => candidate.args !== null);
|
|
26880
27351
|
if (!mapped?.args) return null;
|
|
26881
27352
|
return redirect(
|
|
26882
27353
|
exec2,
|
|
@@ -26888,14 +27359,14 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
|
|
|
26888
27359
|
"readResult",
|
|
26889
27360
|
"read-direct",
|
|
26890
27361
|
mapped.args,
|
|
26891
|
-
{ path:
|
|
27362
|
+
{ path: path82 }
|
|
26892
27363
|
);
|
|
26893
27364
|
}
|
|
26894
|
-
if (
|
|
27365
|
+
if (isRecord10(exec2.grepArgs)) {
|
|
26895
27366
|
const grepArgs = exec2.grepArgs;
|
|
26896
27367
|
const pattern = stringValue2(grepArgs.pattern);
|
|
26897
27368
|
if (!pattern.trim()) return null;
|
|
26898
|
-
const
|
|
27369
|
+
const path82 = stringValue2(grepArgs.path) || ".";
|
|
26899
27370
|
const glob = stringValue2(grepArgs.glob);
|
|
26900
27371
|
const outputMode = normalizedGrepOutputMode(stringValue2(grepArgs.outputMode));
|
|
26901
27372
|
if (!outputMode) return null;
|
|
@@ -26911,7 +27382,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
|
|
|
26911
27382
|
if (numericOptions.some((value) => typeof value === "number" && value < 0)) return null;
|
|
26912
27383
|
const mappingInput = {
|
|
26913
27384
|
pattern,
|
|
26914
|
-
path:
|
|
27385
|
+
path: path82,
|
|
26915
27386
|
glob,
|
|
26916
27387
|
outputMode,
|
|
26917
27388
|
caseInsensitive: grepArgs.caseInsensitive === true,
|
|
@@ -26928,7 +27399,7 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
|
|
|
26928
27399
|
const mapped = tools.filter((tool) => matchesLeaf(tool, GREP_CANDIDATES)).map((tool) => ({ tool, args: grepArguments(tool, mappingInput) })).find((candidate) => candidate.args !== null);
|
|
26929
27400
|
const nativeArgs = {
|
|
26930
27401
|
pattern,
|
|
26931
|
-
path:
|
|
27402
|
+
path: path82,
|
|
26932
27403
|
outputMode,
|
|
26933
27404
|
...glob ? { glob } : {},
|
|
26934
27405
|
...positiveNumber(grepArgs.offset) === void 0 ? {} : { offset: String(positiveNumber(grepArgs.offset)) }
|
|
@@ -26965,15 +27436,15 @@ function cursorNativeExecRedirect(exec2, tools, providerIdentifier) {
|
|
|
26965
27436
|
nativeArgs
|
|
26966
27437
|
);
|
|
26967
27438
|
}
|
|
26968
|
-
if (
|
|
26969
|
-
const argsRecord =
|
|
27439
|
+
if (isRecord10(exec2.shellArgs) || isRecord10(exec2.shellStreamArgs)) {
|
|
27440
|
+
const argsRecord = isRecord10(exec2.shellArgs) ? exec2.shellArgs : exec2.shellStreamArgs;
|
|
26970
27441
|
const command = stringValue2(argsRecord.command);
|
|
26971
27442
|
if (!command) return null;
|
|
26972
27443
|
const cwd = stringValue2(argsRecord.workingDirectory);
|
|
26973
27444
|
const timeout = positiveNumber(argsRecord.timeout) ?? positiveNumber(argsRecord.hardTimeout);
|
|
26974
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);
|
|
26975
27446
|
if (!mapped?.args) return null;
|
|
26976
|
-
const stream =
|
|
27447
|
+
const stream = isRecord10(exec2.shellStreamArgs);
|
|
26977
27448
|
return redirect(
|
|
26978
27449
|
exec2,
|
|
26979
27450
|
mapped.tool,
|
|
@@ -27063,9 +27534,9 @@ function cursorNativeRedirectErrorReplies(correlation, error51) {
|
|
|
27063
27534
|
}
|
|
27064
27535
|
}
|
|
27065
27536
|
}
|
|
27066
|
-
function readArguments(schema,
|
|
27537
|
+
function readArguments(schema, path82) {
|
|
27067
27538
|
const pathKey = firstSchemaProperty(schema, ["file_path", "path"]);
|
|
27068
|
-
return pathKey ? { [pathKey]:
|
|
27539
|
+
return pathKey ? { [pathKey]: path82 } : null;
|
|
27069
27540
|
}
|
|
27070
27541
|
function grepArguments(tool, input) {
|
|
27071
27542
|
const leaf = normalizedLeaf(tool.clientName);
|
|
@@ -27232,7 +27703,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
|
|
|
27232
27703
|
const decoded = JSON.parse(inflateRawSync(compressed, {
|
|
27233
27704
|
maxOutputLength: CURSOR_GREP_RECEIPT_MAX_BYTES
|
|
27234
27705
|
}).toString("utf8"));
|
|
27235
|
-
if (!
|
|
27706
|
+
if (!isRecord10(decoded)) throw new Error("receipt is not an object");
|
|
27236
27707
|
if (decoded.ok === false && typeof decoded.error === "string") {
|
|
27237
27708
|
return { ok: false, error: decoded.error };
|
|
27238
27709
|
}
|
|
@@ -27245,7 +27716,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
|
|
|
27245
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)) {
|
|
27246
27717
|
throw new Error("receipt counts are invalid");
|
|
27247
27718
|
}
|
|
27248
|
-
if (!Array.isArray(decoded.matches) || !decoded.matches.every((entry) =>
|
|
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")) {
|
|
27249
27720
|
throw new Error("receipt matches are invalid");
|
|
27250
27721
|
}
|
|
27251
27722
|
for (const key of ["totalFiles", "totalLines", "totalMatchedLines"]) {
|
|
@@ -27263,7 +27734,7 @@ function parseGrepShellReceipt(output, expectedOutputMode) {
|
|
|
27263
27734
|
}
|
|
27264
27735
|
}
|
|
27265
27736
|
function buildGrepReceiptSuccess(args, receipt) {
|
|
27266
|
-
const
|
|
27737
|
+
const path82 = args.path || ".";
|
|
27267
27738
|
let result;
|
|
27268
27739
|
if (receipt.outputMode === "files_with_matches") {
|
|
27269
27740
|
result = {
|
|
@@ -27309,15 +27780,15 @@ function buildGrepReceiptSuccess(args, receipt) {
|
|
|
27309
27780
|
}
|
|
27310
27781
|
return {
|
|
27311
27782
|
pattern: args.pattern ?? "",
|
|
27312
|
-
path:
|
|
27783
|
+
path: path82,
|
|
27313
27784
|
outputMode: receipt.outputMode,
|
|
27314
|
-
workspaceResults: { [
|
|
27785
|
+
workspaceResults: { [path82]: result }
|
|
27315
27786
|
};
|
|
27316
27787
|
}
|
|
27317
27788
|
function buildGrepSuccess(args, output) {
|
|
27318
27789
|
const outputMode = normalizedGrepOutputMode(args.outputMode) ?? "content";
|
|
27319
27790
|
const lines = output.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0 && !line.startsWith("[") && !/^no matches/i.test(line));
|
|
27320
|
-
const
|
|
27791
|
+
const path82 = args.path || ".";
|
|
27321
27792
|
let result;
|
|
27322
27793
|
if (outputMode === "files_with_matches") {
|
|
27323
27794
|
result = {
|
|
@@ -27380,9 +27851,9 @@ function buildGrepSuccess(args, output) {
|
|
|
27380
27851
|
}
|
|
27381
27852
|
return {
|
|
27382
27853
|
pattern: args.pattern ?? "",
|
|
27383
|
-
path:
|
|
27854
|
+
path: path82,
|
|
27384
27855
|
outputMode,
|
|
27385
|
-
workspaceResults: { [
|
|
27856
|
+
workspaceResults: { [path82]: result }
|
|
27386
27857
|
};
|
|
27387
27858
|
}
|
|
27388
27859
|
function parseCallerShellOutput(output, isError) {
|
|
@@ -27444,7 +27915,7 @@ function redirect(exec2, tool, providerIdentifier, messageId, execId, execCase,
|
|
|
27444
27915
|
}
|
|
27445
27916
|
function execArgsToolCallId(exec2) {
|
|
27446
27917
|
for (const value of Object.values(exec2)) {
|
|
27447
|
-
if (!
|
|
27918
|
+
if (!isRecord10(value)) continue;
|
|
27448
27919
|
const toolCallId = stringValue2(value.toolCallId);
|
|
27449
27920
|
if (toolCallId) return toolCallId;
|
|
27450
27921
|
}
|
|
@@ -27465,7 +27936,7 @@ function firstSchemaProperty(schema, candidates) {
|
|
|
27465
27936
|
return candidates.find((candidate) => schemaHasProperty(schema, candidate));
|
|
27466
27937
|
}
|
|
27467
27938
|
function schemaHasProperty(schema, name) {
|
|
27468
|
-
return
|
|
27939
|
+
return isRecord10(schema.properties) && Object.prototype.hasOwnProperty.call(schema.properties, name);
|
|
27469
27940
|
}
|
|
27470
27941
|
function execReply2(exec2, resultName, result) {
|
|
27471
27942
|
return {
|
|
@@ -27492,7 +27963,7 @@ function positiveNumber(value) {
|
|
|
27492
27963
|
function stringValue2(value) {
|
|
27493
27964
|
return typeof value === "string" ? value : "";
|
|
27494
27965
|
}
|
|
27495
|
-
function
|
|
27966
|
+
function isRecord10(value) {
|
|
27496
27967
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27497
27968
|
}
|
|
27498
27969
|
var cursorAgentDescriptor = [
|
|
@@ -28323,18 +28794,18 @@ function decodeCursorServerMessage(payload) {
|
|
|
28323
28794
|
const message = fromBinary(AgentServerMessageSchema, payload);
|
|
28324
28795
|
const unknownExecFields = extractCursorUnknownExecFields(message);
|
|
28325
28796
|
const json2 = toJson(AgentServerMessageSchema, message);
|
|
28326
|
-
if (!
|
|
28797
|
+
if (!isRecord11(json2)) throw new TypeError("Cursor server frame was not a message object");
|
|
28327
28798
|
if (unknownExecFields.length > 0) {
|
|
28328
28799
|
Object.defineProperty(json2, CURSOR_UNKNOWN_EXEC_FIELDS, { value: unknownExecFields });
|
|
28329
28800
|
}
|
|
28330
28801
|
return json2;
|
|
28331
28802
|
}
|
|
28332
28803
|
function extractCursorUnknownExecFields(message) {
|
|
28333
|
-
if (!
|
|
28334
|
-
if (message.message.case !== "execServerMessage" || !
|
|
28804
|
+
if (!isRecord11(message) || !isRecord11(message.message)) return [];
|
|
28805
|
+
if (message.message.case !== "execServerMessage" || !isRecord11(message.message.value)) return [];
|
|
28335
28806
|
const fields = message.message.value.$unknown;
|
|
28336
28807
|
if (!Array.isArray(fields)) return [];
|
|
28337
|
-
return fields.filter((field) =>
|
|
28808
|
+
return fields.filter((field) => isRecord11(field) && typeof field.no === "number" && typeof field.wireType === "number" && field.data instanceof Uint8Array);
|
|
28338
28809
|
}
|
|
28339
28810
|
function parseConnectEndStreamError(payload) {
|
|
28340
28811
|
try {
|
|
@@ -28656,7 +29127,7 @@ function cursorToolArgumentBytes(argumentsText) {
|
|
|
28656
29127
|
} catch {
|
|
28657
29128
|
return {};
|
|
28658
29129
|
}
|
|
28659
|
-
if (!
|
|
29130
|
+
if (!isRecord11(parsed)) return {};
|
|
28660
29131
|
return Object.fromEntries(Object.entries(parsed).map(([name, value]) => [
|
|
28661
29132
|
name,
|
|
28662
29133
|
Buffer.from(toBinary(ValueSchema, fromJson(ValueSchema, value))).toString("base64")
|
|
@@ -29941,7 +30412,7 @@ ${argumentsText}`;
|
|
|
29941
30412
|
const handleFrame = (frame, replayed = false) => {
|
|
29942
30413
|
const unknownExecFields = frame[CURSOR_UNKNOWN_EXEC_FIELDS] ?? [];
|
|
29943
30414
|
lastFrame = describeCursorServerFrame(frame, unknownExecFields);
|
|
29944
|
-
const tokenDetails =
|
|
30415
|
+
const tokenDetails = isRecord11(frame.conversationCheckpointUpdate) && isRecord11(frame.conversationCheckpointUpdate.tokenDetails) ? frame.conversationCheckpointUpdate.tokenDetails : void 0;
|
|
29945
30416
|
const checkpointContextTokens = positiveTokenCount(tokenDetails?.usedTokens);
|
|
29946
30417
|
const checkpointContextWindow = positiveTokenCount(tokenDetails?.maxTokens);
|
|
29947
30418
|
if (!replayed) {
|
|
@@ -29954,7 +30425,7 @@ ${argumentsText}`;
|
|
|
29954
30425
|
...checkpointContextWindow === void 0 ? {} : { contextWindow: checkpointContextWindow }
|
|
29955
30426
|
});
|
|
29956
30427
|
}
|
|
29957
|
-
if (
|
|
30428
|
+
if (isRecord11(frame.conversationCheckpointUpdate)) {
|
|
29958
30429
|
if (checkpointContextTokens !== void 0) {
|
|
29959
30430
|
wireLog("cursor.wire.checkpoint", {
|
|
29960
30431
|
model: diagnosticModel,
|
|
@@ -29977,7 +30448,7 @@ ${argumentsText}`;
|
|
|
29977
30448
|
}
|
|
29978
30449
|
return;
|
|
29979
30450
|
}
|
|
29980
|
-
if (
|
|
30451
|
+
if (isRecord11(frame.kvServerMessage)) {
|
|
29981
30452
|
const kv = kvReply(frame.kvServerMessage, blobs);
|
|
29982
30453
|
stream.write(encodeCursorClientMessage(kv.message));
|
|
29983
30454
|
if (kv.fetch) {
|
|
@@ -29998,7 +30469,7 @@ ${argumentsText}`;
|
|
|
29998
30469
|
});
|
|
29999
30470
|
return;
|
|
30000
30471
|
}
|
|
30001
|
-
if (
|
|
30472
|
+
if (isRecord11(frame.interactionQuery)) {
|
|
30002
30473
|
const reply = cursorInteractionQueryReply(frame.interactionQuery);
|
|
30003
30474
|
stream.write(encodeCursorClientMessage(reply.message));
|
|
30004
30475
|
report("client.reply", { model: diagnosticModel, reply: reply.replyKind });
|
|
@@ -30014,7 +30485,7 @@ ${argumentsText}`;
|
|
|
30014
30485
|
}
|
|
30015
30486
|
return;
|
|
30016
30487
|
}
|
|
30017
|
-
if (
|
|
30488
|
+
if (isRecord11(frame.error)) {
|
|
30018
30489
|
if (state === "attached") {
|
|
30019
30490
|
emit({ type: "error", error: cursorError(frame.error) });
|
|
30020
30491
|
completeRun("server_error");
|
|
@@ -30043,8 +30514,8 @@ ${argumentsText}`;
|
|
|
30043
30514
|
return;
|
|
30044
30515
|
}
|
|
30045
30516
|
if (state !== "attached") return;
|
|
30046
|
-
if (
|
|
30047
|
-
if (
|
|
30517
|
+
if (isRecord11(frame.execServerMessage)) {
|
|
30518
|
+
if (isRecord11(frame.execServerMessage.requestContextArgs)) {
|
|
30048
30519
|
stream.write(encodeCursorClientMessage(cursorRequestContextReply(frame.execServerMessage, tools)));
|
|
30049
30520
|
report("client.reply", { model: diagnosticModel, reply: "exec.requestContext" });
|
|
30050
30521
|
return;
|
|
@@ -30133,10 +30604,10 @@ ${argumentsText}`;
|
|
|
30133
30604
|
}
|
|
30134
30605
|
return;
|
|
30135
30606
|
}
|
|
30136
|
-
const update =
|
|
30607
|
+
const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
|
|
30137
30608
|
if (update === void 0) return;
|
|
30138
30609
|
if (isSettledToolUpdate(update)) return;
|
|
30139
|
-
if (
|
|
30610
|
+
if (isRecord11(update.textDelta) && typeof update.textDelta.text === "string") {
|
|
30140
30611
|
activeSegment.outputText += update.textDelta.text;
|
|
30141
30612
|
emit({
|
|
30142
30613
|
type: "response.output_text.delta",
|
|
@@ -30147,7 +30618,7 @@ ${argumentsText}`;
|
|
|
30147
30618
|
});
|
|
30148
30619
|
return;
|
|
30149
30620
|
}
|
|
30150
|
-
if (
|
|
30621
|
+
if (isRecord11(update.thinkingDelta) && typeof update.thinkingDelta.text === "string") {
|
|
30151
30622
|
activeSegment.outputText += update.thinkingDelta.text;
|
|
30152
30623
|
emit({
|
|
30153
30624
|
type: "response.reasoning_summary_text.delta",
|
|
@@ -30157,12 +30628,12 @@ ${argumentsText}`;
|
|
|
30157
30628
|
});
|
|
30158
30629
|
return;
|
|
30159
30630
|
}
|
|
30160
|
-
if (
|
|
30631
|
+
if (isRecord11(update.tokenDelta)) {
|
|
30161
30632
|
const tokens = positiveTokenCount(update.tokenDelta.tokens);
|
|
30162
30633
|
if (tokens !== void 0) activeSegment.contextOutputTokens += tokens;
|
|
30163
30634
|
return;
|
|
30164
30635
|
}
|
|
30165
|
-
if (
|
|
30636
|
+
if (isRecord11(update.toolCallStarted)) {
|
|
30166
30637
|
const wireCall = mcpCallFromToolUpdate(update.toolCallStarted);
|
|
30167
30638
|
const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
|
|
30168
30639
|
if (call) {
|
|
@@ -30172,7 +30643,7 @@ ${argumentsText}`;
|
|
|
30172
30643
|
}
|
|
30173
30644
|
return;
|
|
30174
30645
|
}
|
|
30175
|
-
if (
|
|
30646
|
+
if (isRecord11(update.partialToolCall)) {
|
|
30176
30647
|
const wireCall = mcpCallFromToolUpdate(update.partialToolCall);
|
|
30177
30648
|
const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
|
|
30178
30649
|
if (!call) return;
|
|
@@ -30183,7 +30654,7 @@ ${argumentsText}`;
|
|
|
30183
30654
|
rescheduleToolTurnFinish();
|
|
30184
30655
|
return;
|
|
30185
30656
|
}
|
|
30186
|
-
if (
|
|
30657
|
+
if (isRecord11(update.toolCallCompleted)) {
|
|
30187
30658
|
const wireCall = mcpCallFromToolUpdate(update.toolCallCompleted);
|
|
30188
30659
|
const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
|
|
30189
30660
|
if (!call) return;
|
|
@@ -30196,7 +30667,7 @@ ${argumentsText}`;
|
|
|
30196
30667
|
rescheduleToolTurnFinish();
|
|
30197
30668
|
return;
|
|
30198
30669
|
}
|
|
30199
|
-
if (
|
|
30670
|
+
if (isRecord11(update.turnEnded)) completeRun("turn_ended");
|
|
30200
30671
|
};
|
|
30201
30672
|
const eventsFor = (segment) => (async function* () {
|
|
30202
30673
|
try {
|
|
@@ -30407,34 +30878,34 @@ var CURSOR_INTERACTION_QUERY_CASES = [
|
|
|
30407
30878
|
];
|
|
30408
30879
|
var CURSOR_KV_CASES = ["getBlobArgs", "setBlobArgs"];
|
|
30409
30880
|
function describeCursorServerFrame(frame, unknownExecFields = []) {
|
|
30410
|
-
if (
|
|
30881
|
+
if (isRecord11(frame.interactionUpdate)) {
|
|
30411
30882
|
return `interactionUpdate.${cursorNestedRecordCase(
|
|
30412
30883
|
frame.interactionUpdate,
|
|
30413
30884
|
CURSOR_INTERACTION_UPDATE_CASES
|
|
30414
30885
|
)}`;
|
|
30415
30886
|
}
|
|
30416
|
-
if (
|
|
30887
|
+
if (isRecord11(frame.execServerMessage)) {
|
|
30417
30888
|
const knownCase = cursorNestedRecordCase(frame.execServerMessage, CURSOR_EXEC_CASES);
|
|
30418
30889
|
return `execServerMessage.${knownCase === "unknown" ? cursorUnknownExecCaseName(unknownExecFields) : knownCase}`;
|
|
30419
30890
|
}
|
|
30420
|
-
if (
|
|
30891
|
+
if (isRecord11(frame.interactionQuery)) {
|
|
30421
30892
|
return `interactionQuery.${cursorNestedRecordCase(
|
|
30422
30893
|
frame.interactionQuery,
|
|
30423
30894
|
CURSOR_INTERACTION_QUERY_CASES
|
|
30424
30895
|
)}`;
|
|
30425
30896
|
}
|
|
30426
|
-
if (
|
|
30897
|
+
if (isRecord11(frame.kvServerMessage)) {
|
|
30427
30898
|
return `kvServerMessage.${cursorNestedRecordCase(frame.kvServerMessage, CURSOR_KV_CASES)}`;
|
|
30428
30899
|
}
|
|
30429
|
-
if (
|
|
30430
|
-
if (
|
|
30900
|
+
if (isRecord11(frame.conversationCheckpointUpdate)) return "conversationCheckpointUpdate";
|
|
30901
|
+
if (isRecord11(frame.error)) return "error";
|
|
30431
30902
|
return "unknown";
|
|
30432
30903
|
}
|
|
30433
30904
|
function isCursorHeartbeatFrame(frame) {
|
|
30434
|
-
return
|
|
30905
|
+
return isRecord11(frame.interactionUpdate) && isRecord11(frame.interactionUpdate.heartbeat);
|
|
30435
30906
|
}
|
|
30436
30907
|
function cursorNestedRecordCase(value, cases) {
|
|
30437
|
-
return cases.find((candidate) =>
|
|
30908
|
+
return cases.find((candidate) => isRecord11(value[candidate])) ?? "unknown";
|
|
30438
30909
|
}
|
|
30439
30910
|
function positiveTokenCount(value) {
|
|
30440
30911
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) return void 0;
|
|
@@ -30446,8 +30917,8 @@ function cursorInteractionQueryReply(query) {
|
|
|
30446
30917
|
const response = (result = {}) => ({
|
|
30447
30918
|
interactionResponse: { id, ...result }
|
|
30448
30919
|
});
|
|
30449
|
-
if (
|
|
30450
|
-
const args =
|
|
30920
|
+
if (isRecord11(query.createPlanRequestQuery)) {
|
|
30921
|
+
const args = isRecord11(query.createPlanRequestQuery.args) ? query.createPlanRequestQuery.args : void 0;
|
|
30451
30922
|
const name = stringValue3(args?.name)?.trim();
|
|
30452
30923
|
const overview = stringValue3(args?.overview)?.trim();
|
|
30453
30924
|
const plan = stringValue3(args?.plan)?.trim();
|
|
@@ -30463,7 +30934,7 @@ function cursorInteractionQueryReply(query) {
|
|
|
30463
30934
|
` } : {}
|
|
30464
30935
|
};
|
|
30465
30936
|
}
|
|
30466
|
-
if (
|
|
30937
|
+
if (isRecord11(query.askQuestionInteractionQuery)) {
|
|
30467
30938
|
return {
|
|
30468
30939
|
message: response({
|
|
30469
30940
|
askQuestionInteractionResponse: {
|
|
@@ -30473,7 +30944,7 @@ function cursorInteractionQueryReply(query) {
|
|
|
30473
30944
|
replyKind: "interaction.askQuestion.rejected"
|
|
30474
30945
|
};
|
|
30475
30946
|
}
|
|
30476
|
-
if (
|
|
30947
|
+
if (isRecord11(query.switchModeRequestQuery)) {
|
|
30477
30948
|
return {
|
|
30478
30949
|
message: response({
|
|
30479
30950
|
switchModeRequestResponse: {
|
|
@@ -30483,19 +30954,19 @@ function cursorInteractionQueryReply(query) {
|
|
|
30483
30954
|
replyKind: "interaction.switchMode.rejected"
|
|
30484
30955
|
};
|
|
30485
30956
|
}
|
|
30486
|
-
if (
|
|
30957
|
+
if (isRecord11(query.webSearchRequestQuery)) {
|
|
30487
30958
|
return {
|
|
30488
30959
|
message: response({ webSearchRequestResponse: { approved: {} } }),
|
|
30489
30960
|
replyKind: "interaction.webSearch.approved"
|
|
30490
30961
|
};
|
|
30491
30962
|
}
|
|
30492
|
-
if (
|
|
30963
|
+
if (isRecord11(query.exaSearchRequestQuery)) {
|
|
30493
30964
|
return {
|
|
30494
30965
|
message: response({ exaSearchRequestResponse: { approved: {} } }),
|
|
30495
30966
|
replyKind: "interaction.exaSearch.approved"
|
|
30496
30967
|
};
|
|
30497
30968
|
}
|
|
30498
|
-
if (
|
|
30969
|
+
if (isRecord11(query.exaFetchRequestQuery)) {
|
|
30499
30970
|
return {
|
|
30500
30971
|
message: response({ exaFetchRequestResponse: { approved: {} } }),
|
|
30501
30972
|
replyKind: "interaction.exaFetch.approved"
|
|
@@ -30505,7 +30976,7 @@ function cursorInteractionQueryReply(query) {
|
|
|
30505
30976
|
}
|
|
30506
30977
|
function kvReply(kv, blobs) {
|
|
30507
30978
|
const id = kv.id ?? 0;
|
|
30508
|
-
if (
|
|
30979
|
+
if (isRecord11(kv.getBlobArgs)) {
|
|
30509
30980
|
const blobId = typeof kv.getBlobArgs.blobId === "string" ? kv.getBlobArgs.blobId : "";
|
|
30510
30981
|
const blobData = blobs.get(blobId);
|
|
30511
30982
|
return {
|
|
@@ -30517,7 +30988,7 @@ function kvReply(kv, blobs) {
|
|
|
30517
30988
|
}
|
|
30518
30989
|
};
|
|
30519
30990
|
}
|
|
30520
|
-
if (
|
|
30991
|
+
if (isRecord11(kv.setBlobArgs)) {
|
|
30521
30992
|
const blobId = typeof kv.setBlobArgs.blobId === "string" ? kv.setBlobArgs.blobId : "";
|
|
30522
30993
|
const blobData = typeof kv.setBlobArgs.blobData === "string" ? kv.setBlobArgs.blobData : "";
|
|
30523
30994
|
if (blobId) blobs.set(blobId, blobData);
|
|
@@ -30568,7 +31039,7 @@ function repairCursorArgumentValue(value, schema) {
|
|
|
30568
31039
|
return { value: String(value), count: 1 };
|
|
30569
31040
|
}
|
|
30570
31041
|
if (Array.isArray(value)) {
|
|
30571
|
-
const itemSchema =
|
|
31042
|
+
const itemSchema = isRecord11(schema) ? schema.items : void 0;
|
|
30572
31043
|
if (itemSchema === void 0) return { value, count: 0 };
|
|
30573
31044
|
let repairedValues;
|
|
30574
31045
|
let count2 = 0;
|
|
@@ -30581,7 +31052,7 @@ function repairCursorArgumentValue(value, schema) {
|
|
|
30581
31052
|
});
|
|
30582
31053
|
return { value: repairedValues ?? value, count: count2 };
|
|
30583
31054
|
}
|
|
30584
|
-
if (!
|
|
31055
|
+
if (!isRecord11(value) || !isRecord11(schema) || !isRecord11(schema.properties)) {
|
|
30585
31056
|
return { value, count: 0 };
|
|
30586
31057
|
}
|
|
30587
31058
|
let repairedValue;
|
|
@@ -30597,12 +31068,12 @@ function repairCursorArgumentValue(value, schema) {
|
|
|
30597
31068
|
return { value: repairedValue ?? value, count };
|
|
30598
31069
|
}
|
|
30599
31070
|
function cursorSchemaRequiresString(schema) {
|
|
30600
|
-
if (!
|
|
31071
|
+
if (!isRecord11(schema)) return false;
|
|
30601
31072
|
if (schema.type === "string") return true;
|
|
30602
31073
|
return Array.isArray(schema.type) && schema.type.includes("string") && schema.type.every((type) => type === "string" || type === "null");
|
|
30603
31074
|
}
|
|
30604
31075
|
function mcpCallFromToolUpdate(value) {
|
|
30605
|
-
const toolCall =
|
|
31076
|
+
const toolCall = isRecord11(value.toolCall) ? value.toolCall : void 0;
|
|
30606
31077
|
const args = toolCall ? mcpArgsFromToolCall(toolCall) : void 0;
|
|
30607
31078
|
if (!args) return null;
|
|
30608
31079
|
const publicCallId = stringValue3(value.callId);
|
|
@@ -30627,7 +31098,7 @@ var CURSOR_TOOL_UPDATE_CASES = [
|
|
|
30627
31098
|
function cursorToolUpdateIdentifiers(update) {
|
|
30628
31099
|
for (const key of CURSOR_TOOL_UPDATE_CASES) {
|
|
30629
31100
|
const value = update[key];
|
|
30630
|
-
if (!
|
|
31101
|
+
if (!isRecord11(value)) continue;
|
|
30631
31102
|
const call = mcpCallFromToolUpdate(value);
|
|
30632
31103
|
if (!call) return [];
|
|
30633
31104
|
return [...new Set(
|
|
@@ -30637,9 +31108,9 @@ function cursorToolUpdateIdentifiers(update) {
|
|
|
30637
31108
|
return void 0;
|
|
30638
31109
|
}
|
|
30639
31110
|
function isCursorClientToolFrame(frame, tools, redirectTools) {
|
|
30640
|
-
const update =
|
|
31111
|
+
const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
|
|
30641
31112
|
if (update !== void 0) return cursorToolUpdateIdentifiers(update) !== void 0;
|
|
30642
|
-
const exec2 =
|
|
31113
|
+
const exec2 = isRecord11(frame.execServerMessage) ? frame.execServerMessage : void 0;
|
|
30643
31114
|
if (exec2 === void 0) return false;
|
|
30644
31115
|
const wireCall = mcpCallFromExecMessage(exec2);
|
|
30645
31116
|
const call = wireCall ? cursorClientMcpCall(wireCall, tools) : null;
|
|
@@ -30655,16 +31126,16 @@ function isCursorClientToolFrame(frame, tools, redirectTools) {
|
|
|
30655
31126
|
) !== null;
|
|
30656
31127
|
}
|
|
30657
31128
|
function isCursorParkedResidueFrame(frame, parked) {
|
|
30658
|
-
const update =
|
|
31129
|
+
const update = isRecord11(frame.interactionUpdate) ? frame.interactionUpdate : void 0;
|
|
30659
31130
|
if (update === void 0) return false;
|
|
30660
|
-
if (
|
|
31131
|
+
if (isRecord11(update.tokenDelta)) return true;
|
|
30661
31132
|
const identifiers = cursorToolUpdateIdentifiers(update);
|
|
30662
31133
|
if (identifiers === void 0 || identifiers.length === 0 || parked === void 0) return false;
|
|
30663
31134
|
const sealed = new Set(parked.flatMap((call) => [call.callId, call.toolCallId]));
|
|
30664
31135
|
return identifiers.some((identifier) => sealed.has(identifier));
|
|
30665
31136
|
}
|
|
30666
31137
|
function mcpCallFromExecMessage(value) {
|
|
30667
|
-
const args =
|
|
31138
|
+
const args = isRecord11(value.mcpArgs) ? value.mcpArgs : void 0;
|
|
30668
31139
|
if (!args) return null;
|
|
30669
31140
|
const toolCallId = stringValue3(args.toolCallId);
|
|
30670
31141
|
if (!toolCallId) return null;
|
|
@@ -30682,14 +31153,14 @@ function mcpCallFromExecMessage(value) {
|
|
|
30682
31153
|
};
|
|
30683
31154
|
}
|
|
30684
31155
|
function mcpArgsFromToolCall(toolCall) {
|
|
30685
|
-
const direct =
|
|
30686
|
-
if (direct &&
|
|
30687
|
-
const tool =
|
|
30688
|
-
const nested = tool &&
|
|
30689
|
-
return nested &&
|
|
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;
|
|
30690
31161
|
}
|
|
30691
31162
|
function cursorMcpArguments(args) {
|
|
30692
|
-
if (!
|
|
31163
|
+
if (!isRecord11(args.args) || Object.keys(args.args).length === 0) return {};
|
|
30693
31164
|
const decoded = {};
|
|
30694
31165
|
for (const [name, value] of Object.entries(args.args)) {
|
|
30695
31166
|
if (typeof value !== "string") {
|
|
@@ -30764,7 +31235,7 @@ function cursorError(value) {
|
|
|
30764
31235
|
message: typeof value.message === "string" ? value.message : "Cursor request failed"
|
|
30765
31236
|
};
|
|
30766
31237
|
}
|
|
30767
|
-
function
|
|
31238
|
+
function isRecord11(value) {
|
|
30768
31239
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30769
31240
|
}
|
|
30770
31241
|
var DEFAULT_CURSOR_DIAGNOSTIC_MAX_BYTES = 4 * 1024 * 1024;
|
|
@@ -30941,177 +31412,6 @@ function kimiAnthropicHeaders(requestHeaders, apiKey) {
|
|
|
30941
31412
|
}
|
|
30942
31413
|
return headers;
|
|
30943
31414
|
}
|
|
30944
|
-
function normalizeAiGatewaySettings(value) {
|
|
30945
|
-
if (!isRecord11(value) || value.version !== 1) return { version: 1 };
|
|
30946
|
-
const models = Array.isArray(value.models) ? value.models.filter((entry) => isRecord11(entry) && typeof entry.id === "string" && entry.id.length > 0).flatMap((entry) => {
|
|
30947
|
-
const model = findGatewayModel(entry.id);
|
|
30948
|
-
if (!model) return [];
|
|
30949
|
-
const efforts = Array.isArray(entry.efforts) ? entry.efforts.filter((level) => typeof level === "string" && level.length > 0) : [];
|
|
30950
|
-
const exposed = efforts.length > 0 ? narrowEffortLadder(model, efforts) : void 0;
|
|
30951
|
-
return [{
|
|
30952
|
-
id: entry.id,
|
|
30953
|
-
...exposed ? { efforts: [...exposed] } : {},
|
|
30954
|
-
...entry.hostOnly === true ? { hostOnly: true } : {}
|
|
30955
|
-
}];
|
|
30956
|
-
}) : [];
|
|
30957
|
-
const providerPriority = sanitizeProviderPriority(value.providerPriority);
|
|
30958
|
-
const compactCeiling = normalizeCompactCeiling(value.compactCeiling);
|
|
30959
|
-
return {
|
|
30960
|
-
version: 1,
|
|
30961
|
-
...models.length > 0 ? { models } : {},
|
|
30962
|
-
...value.cursorDiagnosticsEnabled === true ? { cursorDiagnosticsEnabled: true } : {},
|
|
30963
|
-
...typeof value.wireLogEnabled === "boolean" ? { wireLogEnabled: value.wireLogEnabled } : {},
|
|
30964
|
-
...providerPriority ? { providerPriority: [...providerPriority] } : {},
|
|
30965
|
-
...compactCeiling !== void 0 ? { compactCeiling } : {}
|
|
30966
|
-
};
|
|
30967
|
-
}
|
|
30968
|
-
function sanitizeProviderPriority(value) {
|
|
30969
|
-
if (!Array.isArray(value)) return void 0;
|
|
30970
|
-
const seen = /* @__PURE__ */ new Set();
|
|
30971
|
-
const cleaned = [];
|
|
30972
|
-
for (const entry of value) {
|
|
30973
|
-
if (typeof entry !== "string") continue;
|
|
30974
|
-
if (!GATEWAY_PROVIDERS.includes(entry)) continue;
|
|
30975
|
-
const provider = entry;
|
|
30976
|
-
if (seen.has(provider)) continue;
|
|
30977
|
-
seen.add(provider);
|
|
30978
|
-
cleaned.push(provider);
|
|
30979
|
-
}
|
|
30980
|
-
return cleaned.length > 0 ? cleaned : void 0;
|
|
30981
|
-
}
|
|
30982
|
-
function isRecord11(value) {
|
|
30983
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30984
|
-
}
|
|
30985
|
-
function resolveAiGatewaySelection(settings2) {
|
|
30986
|
-
const enabled = [];
|
|
30987
|
-
const hostOnlyIds = /* @__PURE__ */ new Set();
|
|
30988
|
-
const effortExposure = {};
|
|
30989
|
-
for (const entry of settings2?.models ?? []) {
|
|
30990
|
-
const model = findGatewayModel(entry.id);
|
|
30991
|
-
if (!model) continue;
|
|
30992
|
-
if (entry.hostOnly === true) hostOnlyIds.add(model.id);
|
|
30993
|
-
if (enabled.includes(model)) continue;
|
|
30994
|
-
enabled.push(model);
|
|
30995
|
-
const exposed = narrowEffortLadder(model, entry.efforts);
|
|
30996
|
-
if (exposed) effortExposure[model.id] = exposed;
|
|
30997
|
-
}
|
|
30998
|
-
const models = sortGatewayModelsByProvider(enabled);
|
|
30999
|
-
const delegationModels = models.filter((model) => !hostOnlyIds.has(model.id));
|
|
31000
|
-
return { models, delegationModels, effortExposure, providerPriority: settings2?.providerPriority };
|
|
31001
|
-
}
|
|
31002
|
-
function narrowEffortLadder(model, efforts) {
|
|
31003
|
-
if (!efforts || efforts.length === 0) return void 0;
|
|
31004
|
-
const ladder = buildGatewayModelConstraints(model).effortLadder;
|
|
31005
|
-
const narrowed = ladder.filter((rung) => efforts.includes(rung));
|
|
31006
|
-
if (narrowed.length === 0 || narrowed.length === ladder.length) return void 0;
|
|
31007
|
-
return narrowed;
|
|
31008
|
-
}
|
|
31009
|
-
function exposableEffortLadder(model) {
|
|
31010
|
-
return buildGatewayModelConstraints(model).effortLadder;
|
|
31011
|
-
}
|
|
31012
|
-
function sortGatewayModelsByProvider(models) {
|
|
31013
|
-
return [...models].sort((left, right) => {
|
|
31014
|
-
const providerDelta = GATEWAY_PROVIDERS.indexOf(left.provider) - GATEWAY_PROVIDERS.indexOf(right.provider);
|
|
31015
|
-
if (providerDelta !== 0) return providerDelta;
|
|
31016
|
-
return GATEWAY_MODELS.indexOf(left) - GATEWAY_MODELS.indexOf(right);
|
|
31017
|
-
});
|
|
31018
|
-
}
|
|
31019
|
-
function parseAiGatewayUpdate(value) {
|
|
31020
|
-
if (value === null) return { ok: true, value: void 0 };
|
|
31021
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return { ok: false };
|
|
31022
|
-
const record42 = value;
|
|
31023
|
-
const extraKeys = Object.keys(record42).filter(
|
|
31024
|
-
(key) => key !== "models" && key !== "defaultModel" && key !== "providerPriority"
|
|
31025
|
-
);
|
|
31026
|
-
if (extraKeys.length > 0) return { ok: false };
|
|
31027
|
-
const models = [];
|
|
31028
|
-
if (record42.models !== void 0) {
|
|
31029
|
-
if (!Array.isArray(record42.models)) return { ok: false };
|
|
31030
|
-
for (const raw of record42.models) {
|
|
31031
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ok: false };
|
|
31032
|
-
const entry = raw;
|
|
31033
|
-
if (Object.keys(entry).some((key) => key !== "id" && key !== "efforts" && key !== "hostOnly")) {
|
|
31034
|
-
return { ok: false };
|
|
31035
|
-
}
|
|
31036
|
-
if (typeof entry.id !== "string") return { ok: false };
|
|
31037
|
-
if (entry.hostOnly !== void 0 && typeof entry.hostOnly !== "boolean") return { ok: false };
|
|
31038
|
-
const model = findGatewayModel(entry.id);
|
|
31039
|
-
if (!model) return { ok: false };
|
|
31040
|
-
if (models.some((existing) => existing.id === model.id)) return { ok: false };
|
|
31041
|
-
const efforts = parseExposedEfforts(model, entry.efforts);
|
|
31042
|
-
if (efforts === null) return { ok: false };
|
|
31043
|
-
models.push({
|
|
31044
|
-
id: model.id,
|
|
31045
|
-
...efforts ? { efforts } : {},
|
|
31046
|
-
...entry.hostOnly === true ? { hostOnly: true } : {}
|
|
31047
|
-
});
|
|
31048
|
-
}
|
|
31049
|
-
}
|
|
31050
|
-
let providerPriority;
|
|
31051
|
-
const hasProviderPriority = Object.prototype.hasOwnProperty.call(record42, "providerPriority");
|
|
31052
|
-
if (hasProviderPriority) {
|
|
31053
|
-
if (!Array.isArray(record42.providerPriority)) return { ok: false };
|
|
31054
|
-
providerPriority = [];
|
|
31055
|
-
for (const raw of record42.providerPriority) {
|
|
31056
|
-
if (typeof raw !== "string") return { ok: false };
|
|
31057
|
-
if (!GATEWAY_PROVIDERS.includes(raw)) return { ok: false };
|
|
31058
|
-
const provider = raw;
|
|
31059
|
-
if (providerPriority.includes(provider)) return { ok: false };
|
|
31060
|
-
providerPriority.push(provider);
|
|
31061
|
-
}
|
|
31062
|
-
}
|
|
31063
|
-
if (models.length === 0 && providerPriority === void 0) {
|
|
31064
|
-
return { ok: true, value: void 0 };
|
|
31065
|
-
}
|
|
31066
|
-
return {
|
|
31067
|
-
ok: true,
|
|
31068
|
-
value: {
|
|
31069
|
-
...models.length > 0 ? { models } : {},
|
|
31070
|
-
...providerPriority !== void 0 ? { providerPriority } : {}
|
|
31071
|
-
}
|
|
31072
|
-
};
|
|
31073
|
-
}
|
|
31074
|
-
function parseExposedEfforts(model, value) {
|
|
31075
|
-
if (value === void 0) return void 0;
|
|
31076
|
-
if (!Array.isArray(value)) return null;
|
|
31077
|
-
const ladder = exposableEffortLadder(model);
|
|
31078
|
-
const seen = [];
|
|
31079
|
-
for (const raw of value) {
|
|
31080
|
-
if (typeof raw !== "string") return null;
|
|
31081
|
-
if (!ladder.includes(raw)) return null;
|
|
31082
|
-
if (seen.includes(raw)) return null;
|
|
31083
|
-
seen.push(raw);
|
|
31084
|
-
}
|
|
31085
|
-
if (seen.length === 0) return null;
|
|
31086
|
-
const ordered = ladder.filter((rung) => seen.includes(rung));
|
|
31087
|
-
return ordered.length === ladder.length ? void 0 : ordered;
|
|
31088
|
-
}
|
|
31089
|
-
function buildAiGatewayCatalog(models = GATEWAY_MODELS) {
|
|
31090
|
-
return {
|
|
31091
|
-
providers: GATEWAY_PROVIDERS.map((provider) => ({
|
|
31092
|
-
id: provider,
|
|
31093
|
-
models: models.filter((model) => model.provider === provider).map((model) => toCatalogModel(model))
|
|
31094
|
-
}))
|
|
31095
|
-
};
|
|
31096
|
-
}
|
|
31097
|
-
function toCatalogModel(model) {
|
|
31098
|
-
const levels = exposableEffortLadder(model);
|
|
31099
|
-
return {
|
|
31100
|
-
id: model.id,
|
|
31101
|
-
name: bareModelName(model),
|
|
31102
|
-
contextWindow: model.contextWindow ?? null,
|
|
31103
|
-
oneMillion: hasClaudeOneMillionMarker(toClaudeGatewayModelId(model)),
|
|
31104
|
-
maxMode: model.cursorMaxMode === true,
|
|
31105
|
-
fast: model.id.endsWith("-fast"),
|
|
31106
|
-
capabilityClass: model.capabilityClass ?? null,
|
|
31107
|
-
description: model.description ?? null,
|
|
31108
|
-
effort: levels.length > 0 ? { levels } : null
|
|
31109
|
-
};
|
|
31110
|
-
}
|
|
31111
|
-
function bareModelName(model) {
|
|
31112
|
-
const prefix = `${GATEWAY_PROVIDER_NAMES[model.provider]}-`;
|
|
31113
|
-
return model.displayName.startsWith(prefix) ? model.displayName.slice(prefix.length) : model.displayName;
|
|
31114
|
-
}
|
|
31115
31415
|
var codexRequestPolicy = {
|
|
31116
31416
|
provider: "codex",
|
|
31117
31417
|
shapeRequest: (request, steps) => steps.withholdWebSearchTools(steps.pruneSkillPayloads(request))
|
|
@@ -31322,6 +31622,14 @@ function createAiGatewayRouter(deps) {
|
|
|
31322
31622
|
return false;
|
|
31323
31623
|
}
|
|
31324
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
|
+
};
|
|
31325
31633
|
const compactCeiling = () => {
|
|
31326
31634
|
try {
|
|
31327
31635
|
return gatewaySettings()?.compactCeiling;
|
|
@@ -31469,7 +31777,10 @@ function createAiGatewayRouter(deps) {
|
|
|
31469
31777
|
);
|
|
31470
31778
|
return true;
|
|
31471
31779
|
}
|
|
31472
|
-
const gateway = deps.gateway ?? (target2.provider === "cursor" ? ownedCursorGateway : target2.provider === "opencode" ? createOpencodeGateway(opencodeGoWire(target2)) : target2.provider === "xai" ? new AnthropicMessagesGateway(new XaiResponsesAdapter({
|
|
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));
|
|
31473
31784
|
const diagnosticsEnabled = target2.provider === "cursor" ? cursorDiagnosticsEnabled() : void 0;
|
|
31474
31785
|
const modelContextWindow = typeof target2.contextWindow === "number" && Number.isFinite(target2.contextWindow) && target2.contextWindow > 0 ? target2.contextWindow : void 0;
|
|
31475
31786
|
const upstream = await gateway.stream(body, {
|
|
@@ -31631,6 +31942,7 @@ function createAiGatewaySettingsStore(deps = {}) {
|
|
|
31631
31942
|
// 무관한 모델 노출 저장 한 번이 사용자의 소진 순서를 지운다.
|
|
31632
31943
|
...current.providerPriority ? { providerPriority: current.providerPriority } : {},
|
|
31633
31944
|
...current.compactCeiling !== void 0 ? { compactCeiling: current.compactCeiling } : {},
|
|
31945
|
+
...current.xaiEndpoint !== void 0 ? { xaiEndpoint: current.xaiEndpoint } : {},
|
|
31634
31946
|
...value ?? {}
|
|
31635
31947
|
})),
|
|
31636
31948
|
writeCursorDiagnosticsEnabled: (enabled) => update((current) => normalizeAiGatewaySettings({
|
|
@@ -31656,12 +31968,22 @@ function createAiGatewaySettingsStore(deps = {}) {
|
|
|
31656
31968
|
const withoutCeiling = { ...next };
|
|
31657
31969
|
delete withoutCeiling.compactCeiling;
|
|
31658
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;
|
|
31659
31981
|
})
|
|
31660
31982
|
};
|
|
31661
31983
|
}
|
|
31662
31984
|
function fileExists(filePath) {
|
|
31663
31985
|
try {
|
|
31664
|
-
return
|
|
31986
|
+
return fs42.lstatSync(filePath).isFile();
|
|
31665
31987
|
} catch {
|
|
31666
31988
|
return false;
|
|
31667
31989
|
}
|
|
@@ -31670,7 +31992,7 @@ var CONCLUSIVE_LEGACY_READ_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EISDIR",
|
|
|
31670
31992
|
function readLegacySettings(legacyPath) {
|
|
31671
31993
|
let raw;
|
|
31672
31994
|
try {
|
|
31673
|
-
raw =
|
|
31995
|
+
raw = fs42.readFileSync(legacyPath, "utf-8");
|
|
31674
31996
|
} catch (error51) {
|
|
31675
31997
|
return CONCLUSIVE_LEGACY_READ_ERRORS.has(error51.code ?? "") ? { kind: "nothing" } : { kind: "unavailable" };
|
|
31676
31998
|
}
|
|
@@ -31916,7 +32238,7 @@ var GATEWAY_MODELS_DOCTRINE = {
|
|
|
31916
32238
|
// usageGuidelines에 적은 문장은 모델에 도달하지 않으므로, 틀리면 조용히 실패하는 두 규칙은
|
|
31917
32239
|
// 여기에 둔다. 나머지 판정 규칙은 응답 본문을 보면 알 수 있어 싣지 않는다 — 길어질수록
|
|
31918
32240
|
// 읽히지 않고, 읽히지 않으면 없는 것과 같다.
|
|
31919
|
-
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
|
|
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.`,
|
|
31920
32242
|
promptSnippet: `gateway_models \u2014 Live roster of assignable gateway models: constraints, capability class, benchmark evidence, provider allowances, and the user's provider priority.`,
|
|
31921
32243
|
whenToUse: [],
|
|
31922
32244
|
whenNotToUse: [],
|
|
@@ -32313,7 +32635,7 @@ function buildDisabledSkillOverrides(skillNames) {
|
|
|
32313
32635
|
|
|
32314
32636
|
// ../../packages/fleet-admiral/src/agent-cli/assets.generated.ts
|
|
32315
32637
|
var EMBEDDED_AGENT_CLI_HOOK_ASSETS = [
|
|
32316
|
-
{ 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' }
|
|
32317
32639
|
];
|
|
32318
32640
|
var DIR_MODE = 448;
|
|
32319
32641
|
var FILE_MODE = 384;
|
|
@@ -45864,6 +46186,15 @@ function registerTerminalSettingsRoutes(ctx, deps) {
|
|
|
45864
46186
|
));
|
|
45865
46187
|
return true;
|
|
45866
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
|
+
}
|
|
45867
46198
|
const updated = deps.globalOptionsService.update((current) => ({ ...current, ...update }));
|
|
45868
46199
|
ctx.host.http.writeJson(res, 200, toTerminalSettingsState(
|
|
45869
46200
|
updated,
|
|
@@ -45891,7 +46222,8 @@ function toTerminalSettingsState(data, aiGateway, wireLogEnabled2) {
|
|
|
45891
46222
|
aiGatewayCatalog: buildAiGatewayCatalog(),
|
|
45892
46223
|
cursorDiagnosticsEnabled: aiGateway.cursorDiagnosticsEnabled === true,
|
|
45893
46224
|
wireLogEnabled: wireLogEnabled2,
|
|
45894
|
-
compactCeiling: aiGateway.compactCeiling ?? null
|
|
46225
|
+
compactCeiling: aiGateway.compactCeiling ?? null,
|
|
46226
|
+
xaiEndpoint: aiGateway.xaiEndpoint ?? DEFAULT_XAI_ENDPOINT_PREFERENCE
|
|
45895
46227
|
};
|
|
45896
46228
|
}
|
|
45897
46229
|
function resolveClaudeCodeSystemPrompt(data) {
|
|
@@ -45926,6 +46258,9 @@ function parseTerminalSettingsBody(value) {
|
|
|
45926
46258
|
const ceiling = normalizeCompactCeiling(body.compactCeiling);
|
|
45927
46259
|
return ceiling === void 0 ? null : { compactCeiling: ceiling };
|
|
45928
46260
|
}
|
|
46261
|
+
if (keys[0] === "xaiEndpoint") {
|
|
46262
|
+
return typeof body.xaiEndpoint === "string" && XAI_ENDPOINT_PREFERENCES.includes(body.xaiEndpoint) ? { xaiEndpoint: body.xaiEndpoint } : null;
|
|
46263
|
+
}
|
|
45929
46264
|
return null;
|
|
45930
46265
|
}
|
|
45931
46266
|
function isAgentIdleDormantMinutes(value) {
|
|
@@ -52767,80 +53102,6 @@ function registerAiGatewayRoutes(ctx, deps = {}) {
|
|
|
52767
53102
|
]);
|
|
52768
53103
|
}
|
|
52769
53104
|
|
|
52770
|
-
// ../fleet-plugins/terminal/server/global.ts
|
|
52771
|
-
var GLOBAL_SHELL_OPERATION_PREFIX = "global-shell:theater:";
|
|
52772
|
-
var GLOBAL_SHELL_OPERATION_TYPE = "shell";
|
|
52773
|
-
function registerGlobalShellRoutes(ctx, runtime) {
|
|
52774
|
-
registerRouter(ctx, "global/ticket", async ({ req, res }) => {
|
|
52775
|
-
if (req.method !== "POST") {
|
|
52776
|
-
ctx.host.http.writeJson(res, 405, { error: "Method not allowed" });
|
|
52777
|
-
return true;
|
|
52778
|
-
}
|
|
52779
|
-
if (!ctx.host.security.isTerminalAuthorized(req)) {
|
|
52780
|
-
ctx.host.http.writeJson(res, 401, { error: "Unauthorized" });
|
|
52781
|
-
return true;
|
|
52782
|
-
}
|
|
52783
|
-
if (req.headers.origin === void 0) {
|
|
52784
|
-
ctx.host.http.writeJson(res, 401, { error: "Unauthorized" });
|
|
52785
|
-
return true;
|
|
52786
|
-
}
|
|
52787
|
-
const body = await ctx.host.http.readJsonBody(req);
|
|
52788
|
-
const operationId = typeof body?.operationId === "string" ? body.operationId : typeof body?.sessionId === "string" ? body.sessionId : null;
|
|
52789
|
-
if (!operationId) {
|
|
52790
|
-
ctx.host.http.writeJson(res, 400, { error: "operation_id_required" });
|
|
52791
|
-
return true;
|
|
52792
|
-
}
|
|
52793
|
-
if (!operationId.startsWith(GLOBAL_SHELL_OPERATION_PREFIX)) {
|
|
52794
|
-
ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
|
|
52795
|
-
return true;
|
|
52796
|
-
}
|
|
52797
|
-
const encodedTheaterId = operationId.slice(GLOBAL_SHELL_OPERATION_PREFIX.length);
|
|
52798
|
-
if (encodedTheaterId.length === 0) {
|
|
52799
|
-
ctx.host.http.writeJson(res, 400, { error: "theater_id_required" });
|
|
52800
|
-
return true;
|
|
52801
|
-
}
|
|
52802
|
-
let theaterId;
|
|
52803
|
-
try {
|
|
52804
|
-
theaterId = decodeURIComponent(encodedTheaterId);
|
|
52805
|
-
} catch {
|
|
52806
|
-
ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
|
|
52807
|
-
return true;
|
|
52808
|
-
}
|
|
52809
|
-
if (theaterId.length === 0 || encodeURIComponent(theaterId) !== encodedTheaterId) {
|
|
52810
|
-
ctx.host.http.writeJson(res, 409, { error: "invalid_global_shell_operation" });
|
|
52811
|
-
return true;
|
|
52812
|
-
}
|
|
52813
|
-
let theaterPath;
|
|
52814
|
-
try {
|
|
52815
|
-
theaterPath = ctx.host.paths.resolveTheaterPath(theaterId);
|
|
52816
|
-
} catch {
|
|
52817
|
-
theaterPath = null;
|
|
52818
|
-
}
|
|
52819
|
-
if (!theaterPath) {
|
|
52820
|
-
ctx.host.http.writeJson(res, 404, { error: "theater_not_found" });
|
|
52821
|
-
return true;
|
|
52822
|
-
}
|
|
52823
|
-
if (!runtime.canAttach(operationId)) {
|
|
52824
|
-
ctx.host.http.writeJson(res, 503, { error: "Terminal session capacity exhausted" });
|
|
52825
|
-
return true;
|
|
52826
|
-
}
|
|
52827
|
-
const colorScheme = body?.colorScheme === "light" || body?.colorScheme === "dark" ? body.colorScheme : void 0;
|
|
52828
|
-
const role = ctx.host.security.resolveTerminalSocketRole(req) === "viewer" ? "viewer" : readSocketRole(body?.role);
|
|
52829
|
-
ctx.host.http.writeJson(res, 200, runtime.issueTicket({
|
|
52830
|
-
cwd: theaterPath,
|
|
52831
|
-
sessionId: operationId,
|
|
52832
|
-
operationId,
|
|
52833
|
-
operationType: GLOBAL_SHELL_OPERATION_TYPE,
|
|
52834
|
-
pluginId: ctx.pluginId,
|
|
52835
|
-
theaterId,
|
|
52836
|
-
kind: "shell",
|
|
52837
|
-
...colorScheme ? { colorScheme } : {},
|
|
52838
|
-
...role ? { role } : {}
|
|
52839
|
-
}));
|
|
52840
|
-
return true;
|
|
52841
|
-
}, { method: "POST", path: "", summary: "Issue a Global Shell WebSocket ticket.", category: "Terminal Plugin", gate: "origin-strict", transport: "http" });
|
|
52842
|
-
}
|
|
52843
|
-
|
|
52844
53105
|
// ../fleet-plugins/terminal/server/model-auth-state.ts
|
|
52845
53106
|
var MODEL_AUTH_STORE_IDS = Object.freeze({
|
|
52846
53107
|
kimi: KIMI_AUTH_PROVIDER_ID,
|
|
@@ -53152,7 +53413,6 @@ var routes_default = definePlugin({
|
|
|
53152
53413
|
});
|
|
53153
53414
|
ctx.host.lifecycle.registerCleanup(unsubscribeControl);
|
|
53154
53415
|
registerShellRoutes(ctx, runtime);
|
|
53155
|
-
registerGlobalShellRoutes(ctx, runtime);
|
|
53156
53416
|
registerTerminalSettingsRoutes(ctx, {
|
|
53157
53417
|
globalOptionsService: infraServices.globalOptionsService,
|
|
53158
53418
|
aiGatewayStore,
|