nolo-cli 0.16.0-alpha.8 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/{_executeModel-BXOUO4QK.js → _executeModel-AVCA2NAV.js} +20 -21
  2. package/{agentDeleteCommand-X35VSSVM.js → agentDeleteCommand-QW5PUMDQ.js} +14 -15
  3. package/{agentEmailCommands-SBT6O7PR.js → agentEmailCommands-4ORVLGVQ.js} +25 -26
  4. package/{agentListCommands-LLQHUE4O.js → agentListCommands-YWBYRTYC.js} +16 -17
  5. package/{agentMachineCommands-XZCYBU3R.js → agentMachineCommands-JSQW4FOA.js} +14 -15
  6. package/{agentRecordCommands-RIYJOUA2.js → agentRecordCommands-AASIWOBT.js} +24 -25
  7. package/{agentRunCommand-A5XOHMND.js → agentRunCommand-TB5BHXUH.js} +24 -25
  8. package/{agentRuntimeLocal-N56G2ZJK.js → agentRuntimeLocal-QNPNJRVH.js} +12 -15
  9. package/{agentSlice-3FPEJY4O.js → agentSlice-RUNXC62Y.js} +1 -1
  10. package/{authCommand-P22WCVOP.js → authCommand-YFTR3347.js} +2 -8
  11. package/{chunk-KRGHIVPU.js → chunk-33BJUVK4.js} +2 -2
  12. package/{chunk-BIAWRSVQ.js → chunk-3663CXZN.js} +12 -39
  13. package/{chunk-OIX36K6R.js → chunk-3OIRVWXA.js} +10 -1
  14. package/{chunk-LSFAWXKC.js → chunk-3WGLLTK4.js} +3 -100
  15. package/{chunk-2B3BNWPC.js → chunk-4FX6NVDW.js} +134 -1
  16. package/{chunk-BOPYCNN3.js → chunk-4IJYA27C.js} +1 -1
  17. package/{chunk-4IF3B7WC.js → chunk-4L2OJPCU.js} +2 -2
  18. package/{chunk-CI2G2Z2L.js → chunk-55NSNCFM.js} +1 -1
  19. package/{chunk-5BP2BROQ.js → chunk-66X4VSRC.js} +4 -3
  20. package/{chunk-LJIJWXIT.js → chunk-6EVITP2G.js} +254 -13
  21. package/{chunk-C2BYYSAO.js → chunk-7UKFVQ5W.js} +27 -84
  22. package/{chunk-B2A62NRJ.js → chunk-AUURUT6L.js} +200 -65
  23. package/{chunk-KOW2R4MZ.js → chunk-AVVZUXXC.js} +13 -38
  24. package/{chunk-BS5STUTA.js → chunk-BEBNFWDU.js} +3 -3
  25. package/{chunk-YMMMHRM6.js → chunk-DGEYDWEZ.js} +3 -3
  26. package/{chunk-UVLYZNDL.js → chunk-DPAB4FQ7.js} +124 -629
  27. package/{chunk-J4VLNDI7.js → chunk-EHLHSX7R.js} +2 -9
  28. package/{chunk-LXT3EWFO.js → chunk-FRV6A633.js} +3 -3
  29. package/{chunk-5IMRNKUB.js → chunk-FY233ZFU.js} +18 -17
  30. package/{chunk-ZTRZ2O5B.js → chunk-GSINCD4P.js} +4 -4
  31. package/{chunk-6Z3S3UAU.js → chunk-IGXREZW2.js} +1 -1
  32. package/{chunk-B4KT7RN2.js → chunk-JTMNCCWF.js} +2 -2
  33. package/{chunk-ASZ2C44S.js → chunk-LPEUV5RE.js} +2 -2
  34. package/{chunk-QSWWWYGA.js → chunk-M43KDE25.js} +1 -1
  35. package/{chunk-E4STLOKO.js → chunk-MR6ISAGB.js} +2 -2
  36. package/{chunk-TPHRIFDJ.js → chunk-NSCHQQPU.js} +10 -10
  37. package/{chunk-AKYTMRBP.js → chunk-NVEWUJVX.js} +1 -1
  38. package/{chunk-ZRDWHLMQ.js → chunk-P3RIAYGG.js} +1 -1
  39. package/{chunk-FJHD7FHN.js → chunk-PCTUYVUM.js} +1 -1
  40. package/{chunk-YQMTILRW.js → chunk-RLCXU7A5.js} +1 -1
  41. package/{chunk-DRHXEIMY.js → chunk-S2LXHNHG.js} +3 -3
  42. package/{chunk-UALQTIWY.js → chunk-XBS2WYJ2.js} +1 -1
  43. package/{chunk-ND3KEKR5.js → chunk-Z5JQNBNY.js} +2 -2
  44. package/{chunk-HNLGEZZC.js → chunk-ZQBL7LIC.js} +24 -19
  45. package/{createAgentAutomationAction-P22E427A.js → createAgentAutomationAction-FNHPSKKO.js} +6 -6
  46. package/{createDialogAction-652TOTEI.js → createDialogAction-TZCVQ3NU.js} +7 -7
  47. package/{createPageAction-YOYLCN3U.js → createPageAction-EIGZ3BKT.js} +6 -6
  48. package/{dialogCommands-L4LMXQAI.js → dialogCommands-FO77J5DQ.js} +15 -16
  49. package/{dialogSlice-JDGM4LBU.js → dialogSlice-MM5U4KE2.js} +6 -6
  50. package/{docCreateCommands-C4HJCM47.js → docCreateCommands-I3BS3AZI.js} +17 -20
  51. package/{docDeleteCommands-Y6W6A3W6.js → docDeleteCommands-Q2OPV52P.js} +16 -19
  52. package/{docReadCommands-2WUIDAR6.js → docReadCommands-YOOFACYZ.js} +15 -18
  53. package/{docStore-WR2GOFTC.js → docStore-NGYQ2JTR.js} +7 -7
  54. package/{docUpdateCommands-XVL2CBKE.js → docUpdateCommands-2B32ITHN.js} +16 -19
  55. package/{getPricing-HXWUZAEN.js → getPricing-P4XRJRZB.js} +3 -3
  56. package/{handleSendMessageAction-VWLRU6MN.js → handleSendMessageAction-JRZWWBKP.js} +6 -6
  57. package/index.js +43 -74
  58. package/{machineCommands-2TWAI6PL.js → machineCommands-WRWF2ICZ.js} +23 -24
  59. package/{machineWsRunDispatch-YZV3WPSY.js → machineWsRunDispatch-ZX7Q3TWZ.js} +23 -24
  60. package/{models-DQUMNIGQ.js → models-WQ5N4OJM.js} +2 -2
  61. package/package.json +1 -1
  62. package/{readlineWorkspace-BWJFIKM5.js → readlineWorkspace-ZTGRGW46.js} +81 -78
  63. package/{runAgentClientLoop-S7STEKKR.js → runAgentClientLoop-JZCOP7LG.js} +16 -17
  64. package/{spaceCommands-PYFLKEAW.js → spaceCommands-VV4GTPQK.js} +14 -15
  65. package/{spaceSlice-VRX4URCY.js → spaceSlice-DRWWZJP7.js} +6 -6
  66. package/{streamAgentChatTurn-DVSLQIQE.js → streamAgentChatTurn-Y6WGATQR.js} +26 -27
  67. package/{tools-O2GBX7RP.js → tools-PUNBY3AH.js} +11 -11
  68. package/{tuiSummaryLlmCaller-ENLQTJUV.js → tuiSummaryLlmCaller-F64WLSAF.js} +5 -6
  69. package/{updateDialogTitleAction-SDAHAOAO.js → updateDialogTitleAction-YSR4TCMB.js} +6 -6
  70. package/appDeleteCommands-WHRYDQLZ.js +0 -125
  71. package/appDeployCommands-USRWBT6T.js +0 -164
  72. package/appDeployStatusCommands-R632IBVL.js +0 -145
  73. package/appGetCommands-PKGC2JWH.js +0 -120
  74. package/appListCommands-OMRAEOAL.js +0 -123
  75. package/chunk-EFNMO3YF.js +0 -107
  76. package/chunk-GFUIQ4RY.js +0 -136
  77. package/chunk-KFEVY3ST.js +0 -255
  78. /package/{chunk-LPWS7HMQ.js → chunk-O6W2O2DA.js} +0 -0
@@ -3,12 +3,12 @@ import {
3
3
  refreshAntigravityOAuthToken,
4
4
  refreshOpenAiCodexToken,
5
5
  refreshXaiOAuthToken
6
- } from "./chunk-J4VLNDI7.js";
6
+ } from "./chunk-EHLHSX7R.js";
7
7
  import {
8
8
  buildLocalAgentLookupKeys,
9
9
  normalizeAgentHandle,
10
10
  shouldReadAgentKeyRemotely
11
- } from "./chunk-QSWWWYGA.js";
11
+ } from "./chunk-M43KDE25.js";
12
12
  import {
13
13
  LOCAL_CODEX_AGENT_ID,
14
14
  LOCAL_CODEX_AGENT_KEY,
@@ -21,13 +21,13 @@ import {
21
21
  import {
22
22
  inlineImageUrlsForCustomProvider,
23
23
  prepareTools
24
- } from "./chunk-LXT3EWFO.js";
24
+ } from "./chunk-FRV6A633.js";
25
25
  import {
26
26
  getAntigravityUserAgent,
27
27
  isAntigravityOAuthAgent,
28
28
  readAntigravityProjectId,
29
29
  resolveAntigravityCloudCodeBaseUrl
30
- } from "./chunk-CI2G2Z2L.js";
30
+ } from "./chunk-55NSNCFM.js";
31
31
  import {
32
32
  FORCED_TOOLS,
33
33
  addDefaultLightWebToolsForConfiguredAgents,
@@ -48,7 +48,7 @@ import {
48
48
  rememberMemoryFunctionSchema,
49
49
  resolveEffectiveEnabledPacks,
50
50
  resolveRunLabel
51
- } from "./chunk-HNLGEZZC.js";
51
+ } from "./chunk-ZQBL7LIC.js";
52
52
  import {
53
53
  createDrainExhaustedResponse,
54
54
  isCoreDrainingBody,
@@ -60,13 +60,13 @@ import {
60
60
  } from "./chunk-OWOHNGCN.js";
61
61
  import {
62
62
  prepareTokenUsageData
63
- } from "./chunk-TPHRIFDJ.js";
63
+ } from "./chunk-NSCHQQPU.js";
64
64
  import {
65
65
  BUILTIN_TITLE_LLM_CONFIG
66
66
  } from "./chunk-XOIF2TNF.js";
67
67
  import {
68
68
  fetchServerSyncedCredential
69
- } from "./chunk-DRHXEIMY.js";
69
+ } from "./chunk-S2LXHNHG.js";
70
70
  import {
71
71
  buildAgentRuntimeDialogWritePlan,
72
72
  buildLocalWorkspaceOpenAiTools,
@@ -77,33 +77,28 @@ import {
77
77
  executeLocalToolWithPolicy,
78
78
  executeOpenAiCompatibleChatCompletion,
79
79
  parseSseDataLineJson,
80
- parseSseDataLineObject,
81
80
  readOpenAiCompatibleSseCompletion,
82
81
  resolveOpenAiCompatibleProviderConfig
83
- } from "./chunk-C2BYYSAO.js";
82
+ } from "./chunk-7UKFVQ5W.js";
84
83
  import {
85
84
  buildPlatformChatCompletionRequest,
86
85
  canUsePlatformChatProvider,
87
86
  parsePlatformChatCompletionData,
88
87
  parsePlatformChatCompletionResponse,
89
88
  readSseDataValues,
90
- resolveLegacyDeepSeekProxyChatFallback,
91
89
  resolvePlatformChatProviderConfig,
92
90
  shouldUsePlatformChatProvider
93
- } from "./chunk-KOW2R4MZ.js";
91
+ } from "./chunk-AVVZUXXC.js";
94
92
  import {
95
93
  resolveAgentRuntimeConfigFromRecord
96
94
  } from "./chunk-OIQPORYI.js";
97
95
  import {
96
+ parseToolArgumentsJson,
98
97
  summarizeToolArguments
99
- } from "./chunk-ZTRZ2O5B.js";
100
- import {
101
- convertMessagesToResponsesInput,
102
- toResponsesTools
103
- } from "./chunk-KFEVY3ST.js";
98
+ } from "./chunk-GSINCD4P.js";
104
99
  import {
105
100
  resolvePlatformAuthToken
106
- } from "./chunk-LJIJWXIT.js";
101
+ } from "./chunk-6EVITP2G.js";
107
102
  import {
108
103
  buildLoadSkillExecutor,
109
104
  buildNoloWorkspaceCliToolExecutors,
@@ -111,7 +106,7 @@ import {
111
106
  canonicalizeToolNames,
112
107
  parseNoloWorkspaceToolArguments,
113
108
  resolveRuntimeToolSurfaceForAgent
114
- } from "./chunk-B4KT7RN2.js";
109
+ } from "./chunk-JTMNCCWF.js";
115
110
  import {
116
111
  clipCompactText
117
112
  } from "./chunk-5MMAK75Q.js";
@@ -157,6 +152,9 @@ import {
157
152
  import {
158
153
  DEFAULT_NOLO_SERVER_URL
159
154
  } from "./chunk-OLZBQWZU.js";
155
+ import {
156
+ asRecordOrEmpty
157
+ } from "./chunk-KX6YBIHG.js";
160
158
  import {
161
159
  createTokenKey,
162
160
  createUserKey,
@@ -168,9 +166,6 @@ import {
168
166
  import {
169
167
  asOptionalFiniteNumber
170
168
  } from "./chunk-WWC7I6TA.js";
171
- import {
172
- asTrimmedLowercaseString
173
- } from "./chunk-QSJ3HFEF.js";
174
169
  import {
175
170
  BUILTIN_NOLO_AGENT_KEY,
176
171
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY,
@@ -299,10 +294,6 @@ var STRINGS = {
299
294
  en: "Agent switch cancelled.",
300
295
  zh: "\u5DF2\u53D6\u6D88\u5207\u6362 agent\u3002"
301
296
  },
302
- agentPickerLoading: {
303
- en: "Loading agents\u2026",
304
- zh: "\u6B63\u5728\u52A0\u8F7D agent \u5217\u8868\u2026"
305
- },
306
297
  historyPickerTitle: {
307
298
  en: "Resume dialog (\u2191\u2193 Enter Esc)",
308
299
  zh: "\u6062\u590D\u5BF9\u8BDD\uFF08\u2191\u2193 \u79FB\u52A8 \xB7 Enter \u9009\u62E9 \xB7 Esc \u53D6\u6D88\uFF09"
@@ -622,6 +613,10 @@ var STRINGS = {
622
613
  en: "tools",
623
614
  zh: "\u5DE5\u5177"
624
615
  },
616
+ contextFieldThinking: {
617
+ en: "thinking",
618
+ zh: "\u601D\u8003"
619
+ },
625
620
  contextFieldServer: {
626
621
  en: "server",
627
622
  zh: "\u670D\u52A1\u7AEF"
@@ -659,6 +654,7 @@ var STRINGS = {
659
654
  " /context Show workspace context and next actions",
660
655
  " /runtime <mode> Use auto, local, or server runtime",
661
656
  " /tools <mode> Control tool trace: hide, compact, verbose",
657
+ " /thinking <mode> Control thinking output: hide, marker, show",
662
658
  " /switch Pick an agent interactively (\u2191\u2193, Enter)",
663
659
  " /switch list List agents as text",
664
660
  " /switch <name> Switch directly by name, alias, or key (alias: /agent)",
@@ -695,6 +691,7 @@ var STRINGS = {
695
691
  " /context \u67E5\u770B\u5DE5\u4F5C\u533A\u4E0A\u4E0B\u6587\u4E0E\u540E\u7EED\u64CD\u4F5C",
696
692
  " /runtime <mode> \u5207\u6362 runtime\uFF1Aauto\u3001local\u3001server",
697
693
  " /tools <mode> \u5DE5\u5177\u8F68\u8FF9\u663E\u793A\uFF1Ahide\u3001compact\u3001verbose",
694
+ " /thinking <mode> \u601D\u8003\u8FC7\u7A0B\u663E\u793A\uFF1Ahide\u3001marker\u3001show",
698
695
  " /switch \u4EA4\u4E92\u5F0F\u9009\u62E9 agent\uFF08\u2191\u2193 \u79FB\u52A8\uFF0CEnter \u786E\u8BA4\uFF09",
699
696
  " /switch list \u4EE5\u6587\u672C\u5217\u51FA\u5168\u90E8 agent",
700
697
  " /switch <name> \u6309\u540D\u79F0\u3001\u522B\u540D\u6216 key \u76F4\u63A5\u5207\u6362\uFF08\u522B\u540D\uFF1A/agent\uFF09",
@@ -739,6 +736,12 @@ var STRINGS = {
739
736
  },
740
737
  toolsUsage: { en: "Usage: /tools <hide|compact|verbose>", zh: "\u7528\u6CD5\uFF1A/tools <hide|compact|verbose>" },
741
738
  toolsSet: { en: "Tool display: {0}", zh: "\u5DE5\u5177\u663E\u793A\uFF1A{0}" },
739
+ thinkingCurrent: {
740
+ en: "Thinking display: {0} (hide | marker | show)",
741
+ zh: "\u601D\u8003\u663E\u793A\uFF1A{0}\uFF08hide | marker | show\uFF09"
742
+ },
743
+ thinkingUsage: { en: "Usage: /thinking <hide|marker|show>", zh: "\u7528\u6CD5\uFF1A/thinking <hide|marker|show>" },
744
+ thinkingSet: { en: "Thinking display: {0}", zh: "\u601D\u8003\u663E\u793A\uFF1A{0}" },
742
745
  tasksRunning: { en: "Running processes ({0}):", zh: "\u8FD0\u884C\u4E2D\u7684\u8FDB\u7A0B\uFF08{0}\uFF09\uFF1A" },
743
746
  tasksStopped: { en: "Stopped/exited ({0}):", zh: "\u5DF2\u505C\u6B62/\u5DF2\u9000\u51FA\uFF08{0}\uFF09\uFF1A" },
744
747
  tasksNone: { en: "No processes.", zh: "\u6CA1\u6709\u8FD0\u884C\u4E2D\u7684\u8FDB\u7A0B\u3002" },
@@ -2057,7 +2060,16 @@ function createCliStartAgentRunExecutor(deps = {}) {
2057
2060
 
2058
2061
  --- \u9644\u52A0\u8F93\u5165 ---
2059
2062
  ${JSON.stringify(args.input)}`;
2060
- const rawArgs = ["--agent", agentKey, "--msg-file", "PLACEHOLDER", "--bg"];
2063
+ const rawArgs = [
2064
+ "--agent",
2065
+ agentKey,
2066
+ "--msg-file",
2067
+ "PLACEHOLDER",
2068
+ "--bg",
2069
+ // 非持久化派发(review 等一次性任务):透传 --ephemeral,run 完成后不留
2070
+ // dialog 记录。与 web 端 runAgentBackground 的 ephemeral: true 对齐。
2071
+ ...args.ephemeral === true ? ["--ephemeral"] : []
2072
+ ];
2061
2073
  const agentName = typeof args.agentName === "string" && args.agentName.trim() ? args.agentName.trim() : typeof args.name === "string" && args.name.trim() ? args.name.trim() : void 0;
2062
2074
  const { runId } = await spawnLocalBackgroundRun(
2063
2075
  {
@@ -2436,22 +2448,19 @@ function resolveAntigravityWireModel(logicalModelId) {
2436
2448
  return { wireModelId: id };
2437
2449
  }
2438
2450
 
2439
- // packages/agent-runtime/geminiNativeShared.ts
2451
+ // packages/agent-runtime/antigravityCloudCodeProvider.ts
2452
+ var STREAM_PATH = "/v1internal:streamGenerateContent?alt=sse";
2440
2453
  var SKIP_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
2441
- function isGemini3Model(modelId) {
2454
+ function isGemini3WireModel(modelId) {
2442
2455
  return modelId.includes("gemini-3");
2443
2456
  }
2444
2457
  function messageText(content) {
2445
2458
  if (typeof content === "string") return content;
2446
2459
  if (!Array.isArray(content)) return "";
2447
- return content.filter(
2448
- (part) => part?.type === "text"
2449
- ).map((part) => part.text).join("\n").trim();
2460
+ return content.filter((part) => part?.type === "text").map((part) => part.text).join("\n").trim();
2450
2461
  }
2451
2462
  function parseDataUrlToInlineData(url) {
2452
- const match = /^data:([A-Za-z0-9.+-]+\/[A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=]*)$/.exec(
2453
- url
2454
- );
2463
+ const match = /^data:([A-Za-z0-9.+-]+\/[A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=]*)$/.exec(url);
2455
2464
  if (!match) return null;
2456
2465
  return { mimeType: match[1], data: match[2] };
2457
2466
  }
@@ -2468,7 +2477,7 @@ function extractInlineDataParts(content) {
2468
2477
  }
2469
2478
  return parts;
2470
2479
  }
2471
- function convertOpenAiMessagesToGemini(messages, options) {
2480
+ function convertOpenAiMessagesToCca(messages, options) {
2472
2481
  const contents = [];
2473
2482
  const systemTexts = [];
2474
2483
  const toolNamesById = /* @__PURE__ */ new Map();
@@ -2484,11 +2493,9 @@ function convertOpenAiMessagesToGemini(messages, options) {
2484
2493
  };
2485
2494
  const flushPendingFunctionCalls = () => {
2486
2495
  if (pendingFunctionCalls.length === 0) return;
2487
- const dummyResponses = pendingFunctionCalls.map(
2488
- ({ name }) => ({
2489
- functionResponse: { name, response: { output: "{}" } }
2490
- })
2491
- );
2496
+ const dummyResponses = pendingFunctionCalls.map(({ name }) => ({
2497
+ functionResponse: { name, response: { output: "{}" } }
2498
+ }));
2492
2499
  pendingFunctionCalls = [];
2493
2500
  pushOrMergeContent("user", dummyResponses);
2494
2501
  };
@@ -2497,17 +2504,13 @@ function convertOpenAiMessagesToGemini(messages, options) {
2497
2504
  const role = String(raw.role);
2498
2505
  const content = "content" in raw ? raw.content : null;
2499
2506
  if (role === "system") {
2500
- const text = messageText(
2501
- content
2502
- );
2507
+ const text = messageText(content);
2503
2508
  if (text) systemTexts.push(text);
2504
2509
  continue;
2505
2510
  }
2506
2511
  if (role === "user") {
2507
2512
  flushPendingFunctionCalls();
2508
- const text = messageText(
2509
- content
2510
- );
2513
+ const text = messageText(content);
2511
2514
  const imageParts = extractInlineDataParts(
2512
2515
  content
2513
2516
  );
@@ -2521,9 +2524,7 @@ function convertOpenAiMessagesToGemini(messages, options) {
2521
2524
  if (role === "assistant") {
2522
2525
  flushPendingFunctionCalls();
2523
2526
  const parts = [];
2524
- const text = messageText(
2525
- content
2526
- );
2527
+ const text = messageText(content);
2527
2528
  if (text) parts.push({ text });
2528
2529
  const toolCalls = "tool_calls" in raw && Array.isArray(raw.tool_calls) ? raw.tool_calls ?? [] : [];
2529
2530
  for (const call of toolCalls) {
@@ -2533,20 +2534,17 @@ function convertOpenAiMessagesToGemini(messages, options) {
2533
2534
  toolNamesById.set(id, name);
2534
2535
  pendingFunctionCalls.push({ name, id });
2535
2536
  const realSignature = typeof call.thought_signature === "string" && call.thought_signature ? call.thought_signature : void 0;
2536
- const isFirstFunctionCallPart = !parts.some(
2537
- (p) => "functionCall" in p
2538
- );
2539
- const signature = realSignature ?? (options.attachSkipThoughtSignature && isFirstFunctionCallPart ? SKIP_THOUGHT_SIGNATURE : void 0);
2540
- const part = {
2537
+ const isFirstFunctionCallPart = !parts.some((p) => "functionCall" in p);
2538
+ parts.push({
2541
2539
  functionCall: {
2542
2540
  name,
2543
- args: parseToolArgs(call.function?.arguments),
2544
- ...id ? { id } : {}
2541
+ args: parseToolArgumentsJson(call.function?.arguments),
2542
+ id
2545
2543
  },
2546
- ...signature ? { thoughtSignature: signature } : {}
2547
- };
2548
- parts.push(part);
2544
+ ...realSignature ? { thoughtSignature: realSignature } : options.attachSkipThoughtSignature && isFirstFunctionCallPart ? { thoughtSignature: SKIP_THOUGHT_SIGNATURE } : {}
2545
+ });
2549
2546
  }
2547
+ if (parts.length === 0) continue;
2550
2548
  pushOrMergeContent("model", parts);
2551
2549
  continue;
2552
2550
  }
@@ -2571,22 +2569,7 @@ function convertOpenAiMessagesToGemini(messages, options) {
2571
2569
  flushPendingFunctionCalls();
2572
2570
  return { contents, systemTexts };
2573
2571
  }
2574
- function parseToolArgs(raw) {
2575
- if (typeof raw === "string") {
2576
- try {
2577
- const parsed = JSON.parse(raw);
2578
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
2579
- return parsed;
2580
- }
2581
- } catch {
2582
- }
2583
- }
2584
- if (raw && typeof raw === "object" && !Array.isArray(raw)) {
2585
- return raw;
2586
- }
2587
- return {};
2588
- }
2589
- function convertOpenAiToolsToGemini(tools) {
2572
+ function convertOpenAiTools(tools) {
2590
2573
  if (!Array.isArray(tools) || tools.length === 0) return void 0;
2591
2574
  const declarations = [];
2592
2575
  for (const tool of tools) {
@@ -2603,97 +2586,6 @@ function convertOpenAiToolsToGemini(tools) {
2603
2586
  if (declarations.length === 0) return void 0;
2604
2587
  return [{ functionDeclarations: declarations }];
2605
2588
  }
2606
- function accumulateGeminiChunks(chunks) {
2607
- let text = "";
2608
- const toolCalls = [];
2609
- let usage;
2610
- let pendingThoughtSignature;
2611
- for (const chunk of chunks) {
2612
- if (!chunk || typeof chunk !== "object") continue;
2613
- const response = "response" in chunk && chunk.response && typeof chunk.response === "object" ? chunk.response : chunk;
2614
- if ("usageMetadata" in response && response.usageMetadata && typeof response.usageMetadata === "object") {
2615
- const meta = response.usageMetadata;
2616
- const prompt = typeof meta.promptTokenCount === "number" ? meta.promptTokenCount : 0;
2617
- const candidates2 = typeof meta.candidatesTokenCount === "number" ? meta.candidatesTokenCount : 0;
2618
- const total = typeof meta.totalTokenCount === "number" ? meta.totalTokenCount : prompt + candidates2;
2619
- usage = {
2620
- prompt_tokens: prompt,
2621
- completion_tokens: candidates2,
2622
- total_tokens: total
2623
- };
2624
- }
2625
- const candidates = Array.isArray(response.candidates) ? response.candidates : [];
2626
- for (const candidate of candidates) {
2627
- if (!candidate || typeof candidate !== "object") continue;
2628
- const parts = Array.isArray(
2629
- candidate.content?.parts
2630
- ) ? candidate.content.parts : [];
2631
- for (const part of parts) {
2632
- if (!part || typeof part !== "object") continue;
2633
- const partSignature = part.thoughtSignature;
2634
- if ("text" in part && typeof part.text === "string") {
2635
- const piece = part.text;
2636
- if (!part.thought) {
2637
- text += piece;
2638
- }
2639
- }
2640
- if (part.thought && typeof partSignature === "string" && partSignature) {
2641
- pendingThoughtSignature = partSignature;
2642
- }
2643
- if ("functionCall" in part && part.functionCall) {
2644
- const call = part.functionCall;
2645
- const name = typeof call.name === "string" ? call.name : "tool";
2646
- const id = typeof call.id === "string" ? call.id : `${name}_${toolCalls.length}`;
2647
- const argsObj = call.args && typeof call.args === "object" ? call.args : {};
2648
- const resolvedSignature = typeof partSignature === "string" && partSignature ? partSignature : pendingThoughtSignature;
2649
- pendingThoughtSignature = void 0;
2650
- toolCalls.push({
2651
- id,
2652
- type: "function",
2653
- function: { name, arguments: JSON.stringify(argsObj) },
2654
- ...typeof resolvedSignature === "string" && resolvedSignature ? { thought_signature: resolvedSignature } : {}
2655
- });
2656
- }
2657
- }
2658
- }
2659
- }
2660
- return { text, toolCalls, usage };
2661
- }
2662
- function shouldUseGeminiNativeToolRoute(provider, model, tools, isImageModel) {
2663
- return provider === "google" && !isImageModel(model) && isGemini3Model(model) && Array.isArray(tools) && tools.length > 0;
2664
- }
2665
- function buildGeminiGenerateContentRequest(args) {
2666
- const { contents, systemTexts } = convertOpenAiMessagesToGemini(
2667
- args.messages,
2668
- { attachSkipThoughtSignature: args.attachSkipThoughtSignature }
2669
- );
2670
- const request = { contents };
2671
- if (systemTexts.length > 0) {
2672
- request.systemInstruction = {
2673
- role: "user",
2674
- parts: systemTexts.map((text) => ({ text }))
2675
- };
2676
- }
2677
- const toolsResult = convertOpenAiToolsToGemini(args.tools);
2678
- if (toolsResult) {
2679
- request.tools = toolsResult;
2680
- request.toolConfig = { functionCallingConfig: { mode: "VALIDATED" } };
2681
- }
2682
- const generationConfig = {};
2683
- if (typeof args.maxTokens === "number" && args.maxTokens > 0) {
2684
- generationConfig.maxOutputTokens = args.maxTokens;
2685
- }
2686
- if (typeof args.temperature === "number") {
2687
- generationConfig.temperature = args.temperature;
2688
- }
2689
- if (Object.keys(generationConfig).length > 0) {
2690
- request.generationConfig = generationConfig;
2691
- }
2692
- return request;
2693
- }
2694
-
2695
- // packages/agent-runtime/antigravityCloudCodeProvider.ts
2696
- var STREAM_PATH = "/v1internal:streamGenerateContent?alt=sse";
2697
2589
  function buildCloudCodeAssistPayload(args) {
2698
2590
  const projectId = readAntigravityProjectId(args.metadata);
2699
2591
  if (!projectId) {
@@ -2704,8 +2596,8 @@ function buildCloudCodeAssistPayload(args) {
2704
2596
  const logicalModel = asOptionalTrimmedString(args.openAiBody.model) ?? asOptionalTrimmedString(args.agentConfig.model) ?? "gemini-3.1-pro";
2705
2597
  const { wireModelId: model, profile } = resolveAntigravityWireModel(logicalModel);
2706
2598
  const rawMessages = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
2707
- const { contents, systemTexts } = convertOpenAiMessagesToGemini(rawMessages, {
2708
- attachSkipThoughtSignature: isGemini3Model(model)
2599
+ const { contents, systemTexts } = convertOpenAiMessagesToCca(rawMessages, {
2600
+ attachSkipThoughtSignature: isGemini3WireModel(model)
2709
2601
  });
2710
2602
  if (contents.length === 0) {
2711
2603
  throw new Error("Antigravity Cloud Code Assist request has no user/model contents.");
@@ -2719,7 +2611,7 @@ function buildCloudCodeAssistPayload(args) {
2719
2611
  parts: systemTexts.map((text) => ({ text }))
2720
2612
  };
2721
2613
  }
2722
- const tools = convertOpenAiToolsToGemini(
2614
+ const tools = convertOpenAiTools(
2723
2615
  Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools : void 0
2724
2616
  );
2725
2617
  if (tools) {
@@ -2766,6 +2658,63 @@ function buildCloudCodeAssistPayload(args) {
2766
2658
  }
2767
2659
  };
2768
2660
  }
2661
+ function accumulateCcaChunks(chunks) {
2662
+ let text = "";
2663
+ const toolCalls = [];
2664
+ let usage;
2665
+ let pendingThoughtSignature;
2666
+ for (const chunk of chunks) {
2667
+ if (!chunk || typeof chunk !== "object") continue;
2668
+ const response = "response" in chunk && chunk.response && typeof chunk.response === "object" ? chunk.response : chunk;
2669
+ if ("usageMetadata" in response && response.usageMetadata && typeof response.usageMetadata === "object") {
2670
+ const meta = response.usageMetadata;
2671
+ const prompt = typeof meta.promptTokenCount === "number" ? meta.promptTokenCount : 0;
2672
+ const candidates2 = typeof meta.candidatesTokenCount === "number" ? meta.candidatesTokenCount : 0;
2673
+ const total = typeof meta.totalTokenCount === "number" ? meta.totalTokenCount : prompt + candidates2;
2674
+ usage = {
2675
+ prompt_tokens: prompt,
2676
+ completion_tokens: candidates2,
2677
+ total_tokens: total
2678
+ };
2679
+ }
2680
+ const candidates = Array.isArray(response.candidates) ? response.candidates : [];
2681
+ for (const candidate of candidates) {
2682
+ if (!candidate || typeof candidate !== "object" || !("content" in candidate)) continue;
2683
+ const content = candidate.content;
2684
+ if (!content || typeof content !== "object" || !("parts" in content)) continue;
2685
+ const parts = content.parts;
2686
+ if (!Array.isArray(parts)) continue;
2687
+ for (const part of parts) {
2688
+ if (!part || typeof part !== "object") continue;
2689
+ const partSignature = part.thoughtSignature;
2690
+ if ("text" in part && typeof part.text === "string") {
2691
+ const piece = part.text;
2692
+ if (!part.thought) {
2693
+ text += piece;
2694
+ }
2695
+ }
2696
+ if (part.thought && typeof partSignature === "string" && partSignature) {
2697
+ pendingThoughtSignature = partSignature;
2698
+ }
2699
+ if ("functionCall" in part && part.functionCall) {
2700
+ const call = part.functionCall;
2701
+ const name = typeof call.name === "string" ? call.name : "tool";
2702
+ const id = typeof call.id === "string" ? call.id : `${name}_${toolCalls.length}`;
2703
+ const argsObj = asRecordOrEmpty(call.args);
2704
+ const resolvedSignature = typeof partSignature === "string" && partSignature ? partSignature : pendingThoughtSignature;
2705
+ pendingThoughtSignature = void 0;
2706
+ toolCalls.push({
2707
+ id,
2708
+ type: "function",
2709
+ function: { name, arguments: JSON.stringify(argsObj) },
2710
+ ...typeof resolvedSignature === "string" && resolvedSignature ? { thought_signature: resolvedSignature } : {}
2711
+ });
2712
+ }
2713
+ }
2714
+ }
2715
+ }
2716
+ return { text, toolCalls, usage };
2717
+ }
2769
2718
  async function readSseJsonChunks(response) {
2770
2719
  return readSseDataValues(response, parseSseDataLineJson);
2771
2720
  }
@@ -2790,7 +2739,7 @@ async function fetchAntigravityCloudCodeCompletion(args) {
2790
2739
  };
2791
2740
  }
2792
2741
  const chunks = await readSseJsonChunks(response);
2793
- const { text, toolCalls, usage } = accumulateGeminiChunks(chunks);
2742
+ const { text, toolCalls, usage } = accumulateCcaChunks(chunks);
2794
2743
  const message = {
2795
2744
  role: "assistant",
2796
2745
  content: text || null
@@ -2829,11 +2778,6 @@ var CLAUDE_CODE_IDENTITY_PATTERNS = [
2829
2778
  function stringValue(value) {
2830
2779
  return typeof value === "string" && value.length > 0 ? value : void 0;
2831
2780
  }
2832
- function isCacheControl(value) {
2833
- return Boolean(
2834
- value && typeof value === "object" && !Array.isArray(value) && typeof value.type === "string"
2835
- );
2836
- }
2837
2781
  function toAnthropicContent(content) {
2838
2782
  if (typeof content === "string") {
2839
2783
  return content.length > 0 ? [{ type: "text", text: content }] : [];
@@ -2844,23 +2788,17 @@ function toAnthropicContent(content) {
2844
2788
  if (!raw || typeof raw !== "object") continue;
2845
2789
  const part = raw;
2846
2790
  if ((part.type === "text" || part.type === "input_text") && typeof part.text === "string") {
2847
- if (part.text.length > 0) {
2848
- const block2 = { type: "text", text: part.text };
2849
- if (isCacheControl(part.cache_control)) block2.cache_control = part.cache_control;
2850
- blocks.push(block2);
2851
- }
2791
+ if (part.text.length > 0) blocks.push({ type: "text", text: part.text });
2852
2792
  continue;
2853
2793
  }
2854
2794
  if (part.type !== "image_url") continue;
2855
2795
  const imageUrl = typeof part.image_url === "string" ? part.image_url : stringValue(part.image_url?.url);
2856
2796
  if (!imageUrl) continue;
2857
2797
  const dataMatch = imageUrl.match(/^data:([^;,]+);base64,(.+)$/s);
2858
- const block = {
2798
+ blocks.push({
2859
2799
  type: "image",
2860
2800
  source: dataMatch ? { type: "base64", media_type: dataMatch[1], data: dataMatch[2] } : { type: "url", url: imageUrl }
2861
- };
2862
- if (isCacheControl(part.cache_control)) block.cache_control = part.cache_control;
2863
- blocks.push(block);
2801
+ });
2864
2802
  }
2865
2803
  return blocks;
2866
2804
  }
@@ -2936,12 +2874,6 @@ function buildAnthropicMessagesBody(args) {
2936
2874
  if (!hasClaudeCodeIdentity(system)) {
2937
2875
  system.unshift({ type: "text", text: CLAUDE_CODE_SYSTEM_INSTRUCTION });
2938
2876
  }
2939
- if (system.length > 0) {
2940
- const last = system[system.length - 1];
2941
- if (!isCacheControl(last.cache_control)) {
2942
- last.cache_control = { type: "ephemeral" };
2943
- }
2944
- }
2945
2877
  const tools = Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools.flatMap((raw) => {
2946
2878
  if (!raw || typeof raw !== "object") return [];
2947
2879
  const fn = raw.function;
@@ -2956,16 +2888,6 @@ function buildAnthropicMessagesBody(args) {
2956
2888
  const model = stringValue(args.openAiBody.model) ?? args.agentConfig.model ?? "claude-sonnet-5";
2957
2889
  const maxTokensRaw = args.openAiBody.max_completion_tokens ?? args.openAiBody.max_tokens ?? args.agentConfig.max_tokens;
2958
2890
  const maxTokens = typeof maxTokensRaw === "number" && Number.isFinite(maxTokensRaw) ? Math.max(1, Math.floor(maxTokensRaw)) : 8192;
2959
- if (messages.length > 0) {
2960
- const lastMessage = messages[messages.length - 1];
2961
- const content = Array.isArray(lastMessage.content) ? lastMessage.content : [];
2962
- if (content.length > 0) {
2963
- const lastBlock = content[content.length - 1];
2964
- if (!isCacheControl(lastBlock.cache_control)) {
2965
- lastBlock.cache_control = { type: "ephemeral" };
2966
- }
2967
- }
2968
- }
2969
2891
  return {
2970
2892
  model,
2971
2893
  messages,
@@ -9089,234 +9011,6 @@ function isCursorOAuthAgent(agent) {
9089
9011
  return agent.apiKeyRef?.trim().toLowerCase() === "cursor";
9090
9012
  }
9091
9013
 
9092
- // packages/agent-runtime/codexResponsesProvider.ts
9093
- import { randomUUID as randomUUID4 } from "node:crypto";
9094
- var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
9095
- var CODEX_CLIENT_VERSION = "0.144.1";
9096
- var CODEX_ORIGINATOR = "codex_cli_rs";
9097
- var CODEX_OPENAI_BETA = "responses=experimental";
9098
- var OPENAI_AUTH_CLAIM = "https://api.openai.com/auth";
9099
- var CODEX_INSTALLATION_ID = randomUUID4();
9100
- function decodeCodexAccountId(accessToken) {
9101
- const parts = accessToken.split(".");
9102
- if (parts.length < 2) return void 0;
9103
- try {
9104
- const payload = JSON.parse(
9105
- Buffer.from(parts[1], "base64").toString("utf8")
9106
- );
9107
- const claim = payload[OPENAI_AUTH_CLAIM];
9108
- const value = claim && typeof claim === "object" ? claim.chatgpt_account_id : void 0;
9109
- return typeof value === "string" && value ? value : void 0;
9110
- } catch {
9111
- return void 0;
9112
- }
9113
- }
9114
- function createCodexRequestIdentity(installationId = CODEX_INSTALLATION_ID) {
9115
- const sessionId = randomUUID4();
9116
- const threadId = randomUUID4();
9117
- const windowId = randomUUID4();
9118
- const turnId = randomUUID4();
9119
- const turnMetadata = {
9120
- installation_id: installationId,
9121
- session_id: sessionId,
9122
- thread_id: threadId,
9123
- turn_id: turnId,
9124
- window_id: windowId,
9125
- request_kind: "turn",
9126
- turn_started_at_unix_ms: Date.now()
9127
- };
9128
- const turnMetadataJson = JSON.stringify(turnMetadata);
9129
- return {
9130
- sessionId,
9131
- threadId,
9132
- windowId,
9133
- turnId,
9134
- turnMetadataJson,
9135
- clientMetadata: {
9136
- "x-codex-installation-id": installationId,
9137
- session_id: sessionId,
9138
- thread_id: threadId,
9139
- "x-codex-window-id": windowId,
9140
- turn_id: turnId,
9141
- "x-codex-turn-metadata": turnMetadataJson
9142
- }
9143
- };
9144
- }
9145
- function buildCodexCompatibilityHeaders(identity, accountId) {
9146
- return {
9147
- Authorization: "",
9148
- // filled by caller with bearer token
9149
- "Content-Type": "application/json",
9150
- Accept: "text/event-stream",
9151
- "chatgpt-account-id": accountId,
9152
- "OpenAI-Beta": CODEX_OPENAI_BETA,
9153
- originator: CODEX_ORIGINATOR,
9154
- version: CODEX_CLIENT_VERSION,
9155
- session_id: identity.sessionId,
9156
- conversation_id: identity.sessionId,
9157
- "x-client-request-id": identity.sessionId,
9158
- "session-id": identity.sessionId,
9159
- "thread-id": identity.threadId,
9160
- "x-codex-window-id": identity.windowId,
9161
- "x-codex-turn-metadata": identity.turnMetadataJson
9162
- };
9163
- }
9164
- function collectInstructions(messages, agentPrompt) {
9165
- const systemTexts = [];
9166
- const prompt = agentPrompt?.trim();
9167
- if (prompt) systemTexts.push(prompt);
9168
- for (const raw of messages) {
9169
- if (!raw || typeof raw !== "object") continue;
9170
- const role = String(raw.role ?? "");
9171
- if (role !== "system" && role !== "developer") continue;
9172
- const content = raw.content;
9173
- const stringContent = asOptionalTrimmedString(content);
9174
- if (stringContent) {
9175
- systemTexts.push(stringContent);
9176
- } else if (Array.isArray(content)) {
9177
- const text = content.filter(
9178
- (p) => !!p && p.type === "text"
9179
- ).map((p) => p.text).join("\n").trim();
9180
- if (text) systemTexts.push(text);
9181
- }
9182
- }
9183
- return systemTexts.join("\n\n");
9184
- }
9185
- function buildCodexRequestBody(args, identity = createCodexRequestIdentity()) {
9186
- const rawMessages = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
9187
- const nonSystem = rawMessages.filter((m) => {
9188
- const role = m && typeof m === "object" ? String(m.role) : "";
9189
- return role !== "system" && role !== "developer";
9190
- });
9191
- const input = convertMessagesToResponsesInput(nonSystem);
9192
- const instructions = collectInstructions(rawMessages, args.agentConfig.prompt);
9193
- const model = asOptionalTrimmedString(args.openAiBody.model) ?? asOptionalTrimmedString(args.agentConfig.model) ?? "gpt-5.5";
9194
- const tools = toResponsesTools(
9195
- Array.isArray(args.openAiBody.tools) ? args.openAiBody.tools : void 0
9196
- );
9197
- const body = {
9198
- model,
9199
- input,
9200
- stream: true,
9201
- store: false,
9202
- prompt_cache_key: identity.sessionId,
9203
- client_metadata: identity.clientMetadata
9204
- };
9205
- if (instructions) body.instructions = instructions;
9206
- if (tools && tools.length > 0) {
9207
- body.tools = tools;
9208
- body.tool_choice = "auto";
9209
- body.parallel_tool_calls = true;
9210
- }
9211
- return body;
9212
- }
9213
- function aggregateResponsesStream(events) {
9214
- let text = "";
9215
- const toolCalls = [];
9216
- let usage;
9217
- for (const ev of events) {
9218
- const type = String(ev.type ?? "");
9219
- if (type === "response.output_text.delta" && typeof ev.delta === "string") {
9220
- text += ev.delta;
9221
- continue;
9222
- }
9223
- if (type === "response.output_item.done") {
9224
- const item = ev.item;
9225
- if (item && item.type === "function_call") {
9226
- const name = typeof item.name === "string" ? item.name : "";
9227
- if (name) {
9228
- toolCalls.push({
9229
- id: typeof item.call_id === "string" && item.call_id ? item.call_id : `${name}_${toolCalls.length}`,
9230
- type: "function",
9231
- function: {
9232
- name,
9233
- arguments: typeof item.arguments === "string" ? item.arguments : "{}"
9234
- }
9235
- });
9236
- }
9237
- }
9238
- continue;
9239
- }
9240
- if (type === "response.completed") {
9241
- const response = ev.response;
9242
- const u = response?.usage;
9243
- if (u) {
9244
- const prompt = typeof u.input_tokens === "number" ? u.input_tokens : 0;
9245
- const completion = typeof u.output_tokens === "number" ? u.output_tokens : 0;
9246
- const total = typeof u.total_tokens === "number" ? u.total_tokens : prompt + completion;
9247
- usage = {
9248
- prompt_tokens: prompt,
9249
- completion_tokens: completion,
9250
- total_tokens: total
9251
- };
9252
- }
9253
- }
9254
- }
9255
- return { text, toolCalls, usage };
9256
- }
9257
- async function readSseEvents(response) {
9258
- return readSseDataValues(response, (line) => {
9259
- const ev = parseSseDataLineObject(line);
9260
- return ev && !Array.isArray(ev) ? ev : null;
9261
- });
9262
- }
9263
- async function fetchCodexResponsesCompletion(args) {
9264
- const fetchImpl = args.fetchImpl ?? fetch;
9265
- const accountId = args.accountId?.trim() || decodeCodexAccountId(args.accessToken);
9266
- if (!accountId) {
9267
- return {
9268
- status: 401,
9269
- body: {
9270
- error: {
9271
- message: "ChatGPT Codex credential is missing chatgpt_account_id. Re-run `nolo auth chatgpt`."
9272
- }
9273
- }
9274
- };
9275
- }
9276
- const identity = createCodexRequestIdentity();
9277
- const body = buildCodexRequestBody(args, identity);
9278
- const headers = buildCodexCompatibilityHeaders(identity, accountId);
9279
- headers.Authorization = `Bearer ${args.accessToken}`;
9280
- const response = await fetchImpl(CODEX_RESPONSES_URL, {
9281
- method: "POST",
9282
- headers,
9283
- body: JSON.stringify(body),
9284
- signal: args.signal
9285
- });
9286
- if (!response.ok) {
9287
- const errorText = await response.text();
9288
- return {
9289
- status: response.status,
9290
- body: { error: { message: errorText || response.statusText } }
9291
- };
9292
- }
9293
- const events = await readSseEvents(response);
9294
- const { text, toolCalls, usage } = aggregateResponsesStream(events);
9295
- const message = {
9296
- role: "assistant",
9297
- content: text || null
9298
- };
9299
- if (toolCalls.length > 0) message.tool_calls = toolCalls;
9300
- return {
9301
- status: 200,
9302
- body: {
9303
- choices: [
9304
- {
9305
- index: 0,
9306
- message,
9307
- finish_reason: toolCalls.length > 0 ? "tool_calls" : "stop"
9308
- }
9309
- ],
9310
- ...usage ? { usage } : {}
9311
- }
9312
- };
9313
- }
9314
- function isCodexOAuthAgent(agentConfig) {
9315
- if (!agentConfig) return false;
9316
- const apiKeyRef = asTrimmedLowercaseString(agentConfig.apiKeyRef);
9317
- return apiKeyRef === "chatgpt";
9318
- }
9319
-
9320
9014
  // packages/agent-runtime/oauthProviders.ts
9321
9015
  var XAI_ACCESS_TOKEN_CLIENT_SKEW_MS = 5 * 60 * 1e3;
9322
9016
  var decodeBase64 = (s) => Buffer.from(s, "base64").toString("utf8");
@@ -10514,74 +10208,6 @@ function createCliLocalRuntimeAdapter(deps) {
10514
10208
  }
10515
10209
  };
10516
10210
  }
10517
- if (isCodexOAuthAgent(agentConfig)) {
10518
- const accessToken = await apiKeyRefResolver("chatgpt");
10519
- if (!accessToken) {
10520
- throw new Error(
10521
- 'OAuth credential for "chatgpt" not found locally. Run `nolo auth chatgpt`.'
10522
- );
10523
- }
10524
- const credential = readOAuthCredential("chatgpt");
10525
- const accountId = credential?.accountId;
10526
- const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
10527
- agentConfig,
10528
- deps.env,
10529
- buildProviderOpenAiTools,
10530
- additionalToolNames,
10531
- { hasUserChoice: Boolean(deps.requestUserChoice) }
10532
- );
10533
- logLocalRuntimeDiagnostic("provider.selected", {
10534
- agentKey: agentConfig.key,
10535
- transport: "codex-responses",
10536
- provider: "openai",
10537
- model: agentConfig.model ?? "gpt-5.6-sol",
10538
- hasApiKey: true
10539
- });
10540
- return {
10541
- model: agentConfig.model || "gpt-5.6-sol",
10542
- complete: async (messages, options) => {
10543
- const result = await fetchCodexResponsesCompletion({
10544
- agentConfig,
10545
- accessToken,
10546
- ...accountId ? { accountId } : {},
10547
- openAiBody: {
10548
- model: agentConfig.model || "gpt-5.6-sol",
10549
- messages,
10550
- stream: false,
10551
- ...tools2.length > 0 ? { tools: tools2 } : {}
10552
- },
10553
- fetchImpl: (url, init) => fetchWithTransientRetry(fetchImpl, url, init, {
10554
- sleep: deps.sleep,
10555
- loopbackRequest
10556
- })
10557
- });
10558
- if (result.status < 200 || result.status >= 300) {
10559
- const errMsg = result.body?.error && typeof result.body.error === "object" && typeof result.body.error.message === "string" ? result.body.error.message : JSON.stringify(result.body);
10560
- throw new Error(
10561
- `local Codex OAuth provider failed: HTTP ${result.status} ${errMsg}`
10562
- );
10563
- }
10564
- const choice = Array.isArray(result.body.choices) ? result.body.choices[0] : void 0;
10565
- const message = choice?.message ?? {};
10566
- const content = typeof message.content === "string" ? message.content : "";
10567
- const tool_calls = Array.isArray(message.tool_calls) ? message.tool_calls : void 0;
10568
- if (content && options?.onTextDelta) options.onTextDelta(content);
10569
- logLocalRuntimeDiagnostic("provider.request.result", {
10570
- agentKey: agentConfig.key,
10571
- transport: "codex-responses",
10572
- ok: true,
10573
- contentChars: content.length,
10574
- toolCallCount: tool_calls?.length ?? 0,
10575
- requestedToolNames: requestedToolNames2
10576
- });
10577
- return {
10578
- content,
10579
- ...tool_calls ? { tool_calls } : {},
10580
- trace: messages
10581
- };
10582
- }
10583
- };
10584
- }
10585
10211
  if (isCursorOAuthAgent(agentConfig)) {
10586
10212
  const accessToken = await apiKeyRefResolver("cursor");
10587
10213
  if (!accessToken) {
@@ -10651,101 +10277,6 @@ function createCliLocalRuntimeAdapter(deps) {
10651
10277
  }
10652
10278
  };
10653
10279
  }
10654
- if (shouldUsePlatformChatProvider(deps.env, agentConfig) && isGemini3Model(agentConfig.model ?? "") && agentConfig.provider === "google") {
10655
- const providerConfig2 = await resolvePlatformChatProviderConfig({
10656
- agentConfig,
10657
- env: deps.env,
10658
- apiKeyRefResolver,
10659
- credentialBroker,
10660
- syncFetcher
10661
- });
10662
- const { requestedToolNames: requestedToolNames2, tools: tools2 } = resolveProviderOpenAiToolBundle(
10663
- agentConfig,
10664
- deps.env,
10665
- buildProviderOpenAiTools,
10666
- additionalToolNames,
10667
- { hasUserChoice: Boolean(deps.requestUserChoice) }
10668
- );
10669
- if (tools2.length > 0 && providerConfig2.apiKey && shouldUseGeminiNativeToolRoute(
10670
- agentConfig.provider ?? "",
10671
- agentConfig.model ?? "",
10672
- tools2,
10673
- () => false
10674
- // CLI 端不区分 image 模型
10675
- )) {
10676
- logLocalRuntimeDiagnostic("provider.selected", {
10677
- agentKey: agentConfig.key,
10678
- transport: "gemini-native-tool",
10679
- apiSource: agentConfig.apiSource ?? null,
10680
- provider: providerConfig2.provider,
10681
- model: providerConfig2.model,
10682
- hasApiKey: Boolean(providerConfig2.apiKey)
10683
- });
10684
- return {
10685
- model: providerConfig2.model,
10686
- complete: async (messages, options) => {
10687
- const requestBody = buildGeminiGenerateContentRequest({
10688
- messages,
10689
- tools: tools2,
10690
- maxTokens: typeof agentConfig.max_tokens === "number" ? agentConfig.max_tokens : void 0,
10691
- temperature: typeof agentConfig.temperature === "number" ? agentConfig.temperature : void 0,
10692
- attachSkipThoughtSignature: true
10693
- });
10694
- const model = providerConfig2.model;
10695
- const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:streamGenerateContent?alt=sse`;
10696
- logLocalRuntimeDiagnostic("provider.request.start", {
10697
- agentKey: agentConfig.key,
10698
- transport: "gemini-native-tool",
10699
- model,
10700
- messageCount: messages.length,
10701
- toolCount: tools2.length,
10702
- requestedToolNames: requestedToolNames2
10703
- });
10704
- const res = await fetchImpl(url, {
10705
- method: "POST",
10706
- headers: {
10707
- "Content-Type": "application/json",
10708
- "x-goog-api-key": providerConfig2.apiKey ?? ""
10709
- },
10710
- body: JSON.stringify(requestBody),
10711
- signal: AbortSignal.timeout(12e4)
10712
- });
10713
- if (!res.ok) {
10714
- const errText = await res.text();
10715
- logLocalRuntimeDiagnostic("provider.request.failed", {
10716
- agentKey: agentConfig.key,
10717
- transport: "gemini-native-tool",
10718
- status: res.status,
10719
- error: errText.slice(0, 200)
10720
- });
10721
- throw new Error(
10722
- `gemini native tool provider failed: HTTP ${res.status} ${errText.slice(0, 500)}`
10723
- );
10724
- }
10725
- const chunks = await readSseDataValues(res, parseSseDataLineJson);
10726
- const { text, toolCalls, usage } = accumulateGeminiChunks(chunks);
10727
- if (text && options?.onTextDelta) {
10728
- options.onTextDelta(text);
10729
- }
10730
- const result = {
10731
- content: text,
10732
- model,
10733
- tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
10734
- ...usage ? { usage } : {},
10735
- trace: messages
10736
- };
10737
- logLocalRuntimeDiagnostic("provider.request.result", {
10738
- agentKey: agentConfig.key,
10739
- transport: "gemini-native-tool",
10740
- ok: true,
10741
- contentChars: text.length,
10742
- toolCallCount: toolCalls.length
10743
- });
10744
- return result;
10745
- }
10746
- };
10747
- }
10748
- }
10749
10280
  if (shouldUsePlatformChatProvider(deps.env, agentConfig)) {
10750
10281
  const providerConfig2 = await resolvePlatformChatProviderConfig({
10751
10282
  agentConfig,
@@ -10809,44 +10340,8 @@ function createCliLocalRuntimeAdapter(deps) {
10809
10340
  loopbackRequest
10810
10341
  }
10811
10342
  );
10812
- let responseProviderConfig = providerConfig2;
10813
- let firstErrorRaw;
10814
- if (!res.ok) {
10815
- firstErrorRaw = await res.text().catch(() => "");
10816
- const fallbackProviderConfig = resolveLegacyDeepSeekProxyChatFallback({
10817
- providerConfig: providerConfig2,
10818
- status: res.status,
10819
- raw: firstErrorRaw
10820
- });
10821
- if (fallbackProviderConfig) {
10822
- responseProviderConfig = fallbackProviderConfig;
10823
- const fallbackRequest = buildPlatformChatCompletionRequest({
10824
- providerConfig: fallbackProviderConfig,
10825
- messages,
10826
- tools: tools2,
10827
- stream: false
10828
- });
10829
- logLocalRuntimeDiagnostic("provider.request.compatibility-fallback", {
10830
- agentKey: agentConfig.key,
10831
- provider: providerConfig2.provider,
10832
- fromEndpoint: summarizeEndpoint(providerConfig2.endpoint) ?? null,
10833
- toEndpoint: summarizeEndpoint(fallbackProviderConfig.endpoint) ?? null,
10834
- reason: "legacy-proxy-responses-schema"
10835
- });
10836
- res = await fetchWithTransientRetry(
10837
- fetchImpl,
10838
- fallbackRequest.url,
10839
- { ...fallbackRequest.init },
10840
- {
10841
- sleep: deps.sleep,
10842
- loopbackRequest
10843
- }
10844
- );
10845
- firstErrorRaw = void 0;
10846
- }
10847
- }
10848
10343
  if (!res.ok) {
10849
- const raw2 = firstErrorRaw ?? await res.text().catch(() => "");
10344
+ const raw2 = await res.text().catch(() => "");
10850
10345
  const data2 = parsePlatformChatCompletionData(raw2);
10851
10346
  const rawPreview = raw2.length > 200 ? `${raw2.slice(0, 200)}\u2026(${raw2.length}b)` : raw2;
10852
10347
  const gatewayHeaders = [
@@ -10897,7 +10392,7 @@ function createCliLocalRuntimeAdapter(deps) {
10897
10392
  });
10898
10393
  const data = parsePlatformChatCompletionData(raw);
10899
10394
  return parsePlatformChatCompletionResponse({
10900
- providerConfig: responseProviderConfig,
10395
+ providerConfig: providerConfig2,
10901
10396
  data,
10902
10397
  trace: messages
10903
10398
  });