@causyne/agent 1.20.124 → 1.20.128

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 (254) hide show
  1. package/bin/causyne.js +1 -1
  2. package/docs/THIRD_PARTY_NOTICES.md +36 -2
  3. package/package.json +6 -4
  4. package/src/acp/protocol.ts +19 -1
  5. package/src/acp/server.js +282 -8
  6. package/src/acp/server.ts +284 -8
  7. package/src/agent/abortableDelay.js +2 -2
  8. package/src/agent/abortableDelay.ts +2 -2
  9. package/src/agent/errorClassifier.js +9 -1
  10. package/src/agent/errorClassifier.ts +8 -1
  11. package/src/agentLoop.js +142 -53
  12. package/src/agentLoop.ts +151 -50
  13. package/src/approvalPolicy.js +34 -10
  14. package/src/approvalPolicy.ts +42 -11
  15. package/src/browser/causyneBrowser.js +61 -3
  16. package/src/browser/causyneBrowser.ts +65 -3
  17. package/src/browser/urlPolicy.js +14 -1
  18. package/src/browser/urlPolicy.ts +12 -1
  19. package/src/cliMode.js +21 -9
  20. package/src/cliMode.ts +20 -8
  21. package/src/commands.js +365 -45
  22. package/src/commands.ts +403 -45
  23. package/src/config.js +19 -4
  24. package/src/config.ts +18 -4
  25. package/src/core/contextCompactor.js +54 -7
  26. package/src/core/contextCompactor.ts +63 -7
  27. package/src/core/goalLoop.js +257 -0
  28. package/src/core/goalLoop.ts +310 -0
  29. package/src/entrypoint.js +135 -3
  30. package/src/entrypoint.ts +136 -3
  31. package/src/game/causyneCoreBridge.js +686 -0
  32. package/src/game/causyneCoreBridge.ts +702 -0
  33. package/src/game/gameLauncher.js +287 -0
  34. package/src/game/gameLauncher.ts +352 -0
  35. package/src/game/gameProvisioner.js +425 -0
  36. package/src/game/gameProvisioner.ts +488 -0
  37. package/src/headlessCli.js +19 -12
  38. package/src/headlessCli.ts +22 -8
  39. package/src/infra/atomicWriter.js +40 -4
  40. package/src/infra/atomicWriter.ts +36 -4
  41. package/src/launchIntent.js +73 -3
  42. package/src/launchIntent.ts +76 -3
  43. package/src/lsp/lspClient.js +83 -12
  44. package/src/lsp/lspClient.ts +75 -12
  45. package/src/mcp/mcpRegistry.js +75 -8
  46. package/src/mcp/mcpRegistry.ts +70 -7
  47. package/src/memory/contextBudget.js +2 -0
  48. package/src/memory/contextBudget.ts +1 -0
  49. package/src/memory/episodicStore.js +40 -0
  50. package/src/memory/episodicStore.ts +46 -0
  51. package/src/memory.js +67 -0
  52. package/src/memory.ts +65 -0
  53. package/src/modelVariants.js +45 -0
  54. package/src/modelVariants.ts +54 -0
  55. package/src/outputRecovery.js +3 -2
  56. package/src/outputRecovery.ts +4 -2
  57. package/src/permissionPresets.js +327 -0
  58. package/src/permissionPresets.ts +361 -0
  59. package/src/personalization.js +365 -0
  60. package/src/personalization.ts +471 -0
  61. package/src/projectInstructions.js +30 -10
  62. package/src/projectInstructions.ts +31 -12
  63. package/src/providers/acp.js +3 -2
  64. package/src/providers/acp.ts +3 -2
  65. package/src/providers/antigravity.js +64 -9
  66. package/src/providers/antigravity.ts +75 -9
  67. package/src/providers/byokHttp.js +7 -1
  68. package/src/providers/byokHttp.ts +6 -1
  69. package/src/providers/byokStream.js +21 -8
  70. package/src/providers/byokStream.ts +17 -7
  71. package/src/providers/dashscope-byok.js +21 -5
  72. package/src/providers/dashscope-byok.ts +29 -11
  73. package/src/providers/moonshot.js +26 -7
  74. package/src/providers/moonshot.ts +34 -13
  75. package/src/providers/muse.js +6 -0
  76. package/src/providers/muse.ts +8 -0
  77. package/src/providers/ollama.js +39 -7
  78. package/src/providers/ollama.ts +36 -7
  79. package/src/providers/openai-compatible.js +16 -3
  80. package/src/providers/openai-compatible.ts +13 -3
  81. package/src/providers/openai.js +62 -4
  82. package/src/providers/openai.ts +50 -4
  83. package/src/providers/openrouter.js +19 -4
  84. package/src/providers/openrouter.ts +21 -4
  85. package/src/providers/qwen-byok.js +21 -5
  86. package/src/providers/qwen-byok.ts +29 -11
  87. package/src/providers/xai.js +26 -10
  88. package/src/providers/xai.ts +34 -16
  89. package/src/reporting.js +4 -2
  90. package/src/reporting.ts +4 -2
  91. package/src/sandbox.js +34 -0
  92. package/src/sandbox.ts +43 -0
  93. package/src/scheduler/scheduler.js +372 -0
  94. package/src/scheduler/scheduler.ts +433 -0
  95. package/src/sessionSearchIndex.js +267 -0
  96. package/src/sessionSearchIndex.ts +311 -0
  97. package/src/skillsManager.js +2 -3
  98. package/src/skillsManager.ts +2 -3
  99. package/src/toolPacks.js +6 -0
  100. package/src/toolPacks.ts +6 -0
  101. package/src/tools/applyPatch.js +1 -1
  102. package/src/tools/applyPatch.ts +1 -1
  103. package/src/tools/generateMediaViaApi.js +4 -3
  104. package/src/tools/generateMediaViaApi.ts +4 -3
  105. package/src/tools/memoryWrite.js +15 -1
  106. package/src/tools/memoryWrite.ts +16 -1
  107. package/src/tools/nativeEngine.js +2 -2
  108. package/src/tools/nativeEngine.ts +2 -2
  109. package/src/tools/openSourceToolProvisioner.js +2 -2
  110. package/src/tools/openSourceToolProvisioner.ts +2 -2
  111. package/src/tools/osSandbox.js +1 -1
  112. package/src/tools/osSandbox.ts +1 -1
  113. package/src/tools/payloadSanitizer.js +0 -1
  114. package/src/tools/payloadSanitizer.ts +0 -1
  115. package/src/tools/pdfReader.js +122 -20
  116. package/src/tools/pdfReader.ts +111 -20
  117. package/src/tools/presentDeliverable.js +103 -0
  118. package/src/tools/presentDeliverable.ts +127 -0
  119. package/src/tools/ptcRuntime.js +444 -0
  120. package/src/tools/ptcRuntime.ts +490 -0
  121. package/src/tools/ptyTerminal.js +1108 -0
  122. package/src/tools/ptyTerminal.ts +1245 -0
  123. package/src/tools/registry.js +21 -12
  124. package/src/tools/registry.ts +21 -12
  125. package/src/tools/toolOutputStore.js +26 -4
  126. package/src/tools/toolOutputStore.ts +22 -4
  127. package/src/tools/webFetch.js +158 -11
  128. package/src/tools/webFetch.ts +145 -11
  129. package/src/tools/webSearch.js +123 -36
  130. package/src/tools/webSearch.ts +124 -33
  131. package/src/tui/banner.js +5 -1
  132. package/src/tui/banner.ts +6 -1
  133. package/src/tui/chatRenderer.js +1 -2
  134. package/src/tui/chatRenderer.ts +1 -2
  135. package/src/tui/completion.js +1 -0
  136. package/src/tui/completion.ts +1 -0
  137. package/src/tui/composerControls.js +111 -27
  138. package/src/tui/composerControls.ts +124 -28
  139. package/src/tui/dialogs.js +3 -16
  140. package/src/tui/dialogs.ts +3 -16
  141. package/src/tui/home.js +1 -0
  142. package/src/tui/home.ts +1 -0
  143. package/src/tui/invocation.js +1 -2
  144. package/src/tui/invocation.ts +1 -2
  145. package/src/tui/modelPicker.js +22 -12
  146. package/src/tui/modelPicker.ts +22 -12
  147. package/src/tui/overlay.js +2 -5
  148. package/src/tui/overlay.ts +2 -5
  149. package/src/tui/prompt.js +6 -4
  150. package/src/tui/prompt.ts +6 -4
  151. package/src/tui/selectList.js +4 -12
  152. package/src/tui/selectList.ts +4 -12
  153. package/src/tui/setup.js +22 -9
  154. package/src/tui/setup.ts +26 -9
  155. package/src/tui/statusLine.ts +2 -0
  156. package/src/web/client/browserPanel.js +905 -0
  157. package/src/web/client/browserPanel.ts +872 -0
  158. package/src/web/client/chatStream.js +321 -0
  159. package/src/web/client/chatStream.ts +297 -0
  160. package/src/web/client/cliPanel.js +165 -0
  161. package/src/web/client/cliPanel.ts +171 -0
  162. package/src/web/client/composer.js +204 -0
  163. package/src/web/client/composer.ts +209 -0
  164. package/src/web/client/diffPanel.js +176 -0
  165. package/src/web/client/diffPanel.ts +203 -0
  166. package/src/web/client/dom.js +271 -0
  167. package/src/web/client/dom.ts +272 -0
  168. package/src/web/client/filesAndCanvas.js +233 -0
  169. package/src/web/client/filesAndCanvas.ts +240 -0
  170. package/src/web/client/gameLauncherUi.js +78 -0
  171. package/src/web/client/gameLauncherUi.ts +78 -0
  172. package/src/web/client/main.js +316 -0
  173. package/src/web/client/main.ts +391 -0
  174. package/src/web/client/markdown.js +364 -0
  175. package/src/web/client/markdown.ts +373 -0
  176. package/src/web/client/modelPicker.js +455 -0
  177. package/src/web/client/modelPicker.ts +451 -0
  178. package/src/web/client/permissionPresetsUi.js +307 -0
  179. package/src/web/client/permissionPresetsUi.ts +333 -0
  180. package/src/web/client/sessions.js +353 -0
  181. package/src/web/client/sessions.ts +372 -0
  182. package/src/web/client/settingsModal.js +824 -0
  183. package/src/web/client/settingsModal.ts +959 -0
  184. package/src/web/client/state.js +280 -0
  185. package/src/web/client/state.ts +259 -0
  186. package/src/web/client/streamSmoother.js +127 -0
  187. package/src/web/client/streamSmoother.ts +119 -0
  188. package/src/web/client/studioLayout.js +89 -0
  189. package/src/web/client/studioLayout.ts +103 -0
  190. package/src/web/client/studioShell.js +660 -0
  191. package/src/web/client/studioShell.ts +672 -0
  192. package/src/web/client/studioStart.js +77 -0
  193. package/src/web/client/studioStart.ts +89 -0
  194. package/src/web/client/terminalPanel.js +606 -0
  195. package/src/web/client/terminalPanel.ts +632 -0
  196. package/src/web/client/terminalTheme.js +249 -0
  197. package/src/web/client/terminalTheme.ts +258 -0
  198. package/src/web/client/turnView.js +934 -0
  199. package/src/web/client/turnView.ts +981 -0
  200. package/src/web/client/types.js +1 -0
  201. package/src/web/client/types.ts +322 -0
  202. package/src/web/client/validators.js +147 -0
  203. package/src/web/client/validators.ts +140 -0
  204. package/src/web/server/activeRuns.js +152 -0
  205. package/src/web/server/activeRuns.ts +171 -0
  206. package/src/web/server/routesBrowser.js +409 -0
  207. package/src/web/server/routesBrowser.ts +435 -0
  208. package/src/web/server/routesChat.js +304 -0
  209. package/src/web/server/routesChat.ts +347 -0
  210. package/src/web/server/routesCore.js +472 -0
  211. package/src/web/server/routesCore.ts +522 -0
  212. package/src/web/server/routesSettings.js +344 -0
  213. package/src/web/server/routesSettings.ts +397 -0
  214. package/src/web/server/routesTerminal.js +162 -0
  215. package/src/web/server/routesTerminal.ts +182 -0
  216. package/src/web/server/routesWorkspace.js +510 -0
  217. package/src/web/server/routesWorkspace.ts +546 -0
  218. package/src/web/server/security.js +98 -0
  219. package/src/web/server/security.ts +108 -0
  220. package/src/web/server/sessionTranscript.js +586 -0
  221. package/src/web/server/sessionTranscript.ts +566 -0
  222. package/src/web/server/staticAssets.js +104 -0
  223. package/src/web/server/staticAssets.ts +116 -0
  224. package/src/web/server/types.js +1 -0
  225. package/src/web/server/types.ts +135 -0
  226. package/src/web/server/workspaceFiles.js +368 -0
  227. package/src/web/server/workspaceFiles.ts +363 -0
  228. package/src/web/skybridgeServer.js +78 -2448
  229. package/src/web/skybridgeServer.ts +120 -2600
  230. package/src/web/skybridgeUi.js +20 -450
  231. package/src/web/skybridgeUi.ts +24 -455
  232. package/src/web/styles/agent.css +380 -0
  233. package/src/web/styles/composer.css +193 -0
  234. package/src/web/styles/overlays.css +935 -0
  235. package/src/web/styles/shell.css +387 -0
  236. package/src/web/styles/studio.css +951 -0
  237. package/src/web/styles/thread.css +221 -0
  238. package/src/web/styles/tokens.css +94 -0
  239. package/src/web/ui/brandMark.js +73 -0
  240. package/src/web/ui/brandMark.ts +82 -0
  241. package/src/web/ui/modalsTemplate.js +388 -0
  242. package/src/web/ui/modalsTemplate.ts +388 -0
  243. package/src/web/ui/sidebarTemplate.js +63 -0
  244. package/src/web/ui/sidebarTemplate.ts +64 -0
  245. package/src/web/ui/studioTemplate.js +256 -0
  246. package/src/web/ui/studioTemplate.ts +256 -0
  247. package/src/web/ui/workspaceTemplate.js +72 -0
  248. package/src/web/ui/workspaceTemplate.ts +73 -0
  249. package/src/worktreeManager.js +16 -1
  250. package/src/worktreeManager.ts +22 -1
  251. package/src/web/skybridgeClientScript.js +0 -3951
  252. package/src/web/skybridgeClientScript.ts +0 -3952
  253. package/src/web/skybridgeStyles.js +0 -827
  254. package/src/web/skybridgeStyles.ts +0 -828
@@ -168,7 +168,7 @@ export class AcpProvider extends LLMProvider {
168
168
  ' - Bundled Causyne skills must be read via the host tool `fs_read_skill`. Do NOT call peer-native `skill` or functions for Causyne skills. To read a skill, write `<tool_call>{"name": "fs_read_skill", "arguments": {"skill_id": "domain/name"}}</tool_call>` directly in your assistant text response.\n' +
169
169
  ' - To invoke a Causyne host tool, write `<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>` directly in your assistant text response with NO native function call in that step; Causyne will execute the host tool and return the result on the next turn.\n' +
170
170
  '2. WORKSPACE PATH BOUNDARY (NO /tmp):\n' +
171
- ' - Keep ALL temporary files, server logs, and headless browser screenshots inside the active workspace directory (for example, `./.shots/preview.png` or `./server.log`). NEVER write to, read from, or `cp`/`mv` paths in `/tmp` or outside the workspace root, as the host sandbox rejects `/tmp` access.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. Respond naturally in that same language.'
171
+ ' - Keep ALL temporary files, server logs, and headless browser screenshots inside the active workspace directory (for example, `./.shots/preview.png` or `./server.log`). NEVER write to, read from, or `cp`/`mv` paths in `/tmp` or outside the workspace root, as the host sandbox rejects `/tmp` access.\n\n[Personalization Directive]\nStrictly honor any Project Personalization (`.causyne/personalization.md`) and workspace instructions included in system context as a high-priority binding contract for this project (subordinate only to safety and sandbox boundaries).\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. Respond naturally in that same language.'
172
172
  );
173
173
 
174
174
  if (tools && tools.length > 0) {
@@ -243,7 +243,8 @@ export class AcpProvider extends LLMProvider {
243
243
  ' - Bundled Causyne skills must be read via the host tool `fs_read_skill`. Do NOT call peer-native `skill` or functions for Causyne skills. To read a skill, write `<tool_call>{"name": "fs_read_skill", "arguments": {"skill_id": "domain/name"}}</tool_call>` directly in your assistant text response.\n' +
244
244
  ' - To invoke a Causyne host tool, write `<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>` directly in your assistant text response with NO native function call in that step; Causyne will execute the host tool and return the result on the next turn.\n' +
245
245
  '2. WORKSPACE PATH BOUNDARY (NO /tmp):\n' +
246
- ' - Keep ALL temporary files, server logs, and headless browser screenshots inside the active workspace directory (for example, `./.shots/preview.png` or `./server.log`). NEVER write to, read from, or `cp`/`mv` paths in `/tmp` or outside the workspace root, as the host sandbox rejects `/tmp` access.'
246
+ ' - Keep ALL temporary files, server logs, and headless browser screenshots inside the active workspace directory (for example, `./.shots/preview.png` or `./server.log`). NEVER write to, read from, or `cp`/`mv` paths in `/tmp` or outside the workspace root, as the host sandbox rejects `/tmp` access.\n\n' +
247
+ '[Personalization Directive]\nStrictly honor any Project Personalization (`.causyne/personalization.md`) and workspace instructions included in system context as a high-priority binding contract for this project (subordinate only to safety and sandbox boundaries).'
247
248
  );
248
249
  }
249
250
 
@@ -247,6 +247,50 @@ export function resolveAgyEffort(model) {
247
247
  return 'max';
248
248
  return 'low';
249
249
  }
250
+ const VALID_AGY_EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
251
+ function findRegisteredAgySlug(candidateLower) {
252
+ for (const slug of Object.values(ANTIGRAVITY_MODEL_IDS)) {
253
+ if (slug.toLowerCase() === candidateLower)
254
+ return slug;
255
+ }
256
+ return null;
257
+ }
258
+ /**
259
+ * Resolve the exact `--model` slug and optional `--effort` flag for `agy` CLI
260
+ * without ever emitting a conflicting pair (e.g. `--model gemini-4-neon-xhigh --effort max`)
261
+ * or passing `--effort` to unsuffixed orchestrator models that reject it.
262
+ */
263
+ export function resolveAgyCliModelAndEffort(model, rawReasoningEffort) {
264
+ const baseSlug = resolveAgyModelId(model);
265
+ if (!baseSlug)
266
+ return { modelSlug: '', effort: null };
267
+ const cleanedEffort = typeof rawReasoningEffort === 'string'
268
+ ? rawReasoningEffort.trim().toLowerCase()
269
+ : '';
270
+ const requestedEffort = VALID_AGY_EFFORTS.has(cleanedEffort) ? cleanedEffort : null;
271
+ const suffixMatch = /^(.+?)-(minimal|low|medium|high|xhigh|max)$/i.exec(baseSlug);
272
+ if (suffixMatch && suffixMatch[1] && suffixMatch[2]) {
273
+ const baseFamily = suffixMatch[1];
274
+ const slugEffort = suffixMatch[2].toLowerCase();
275
+ if (requestedEffort && requestedEffort !== slugEffort) {
276
+ const sibling = findRegisteredAgySlug(`${baseFamily.toLowerCase()}-${requestedEffort}`);
277
+ if (sibling) {
278
+ return { modelSlug: sibling, effort: null };
279
+ }
280
+ }
281
+ // Suffixed slugs already carry the exact effort tier; omitting `--effort`
282
+ // avoids redundant/conflicting flag rejection on every `agy` version.
283
+ return { modelSlug: baseSlug, effort: null };
284
+ }
285
+ if (requestedEffort) {
286
+ const sibling = findRegisteredAgySlug(`${baseSlug.toLowerCase()}-${requestedEffort}`);
287
+ if (sibling) {
288
+ return { modelSlug: sibling, effort: null };
289
+ }
290
+ }
291
+ // Unsuffixed models (such as orchestrators) reject `--effort`.
292
+ return { modelSlug: baseSlug, effort: null };
293
+ }
250
294
  export function isAntigravityProvider(provider) {
251
295
  if (!provider)
252
296
  return false;
@@ -869,6 +913,8 @@ export class AntigravityProvider extends LLMProvider {
869
913
  'Follow the task scope and execute directly with your native tools (or Causyne host tools when needed). ' +
870
914
  'When target files and verification commands are specified, read those files, apply minimal accurate edits, and verify with the project test/build command — avoid redundant git log, find, or throwaway scratch probes. ' +
871
915
  'Put file contents directly in edit/write arguments, NEVER reply with conversational pleasantries, and report verified outcomes or blockers concisely.\n\n' +
916
+ '[Personalization Directive]\n' +
917
+ 'Strictly obey any Project Personalization (`.causyne/personalization.md`) and workspace instructions provided in the system messages—treat them as a high-priority binding operational contract for this project (vision, conventions, language, and style), subordinate only to safety and permission boundaries.\n\n' +
872
918
  '[Language & Communication Directive]\n' +
873
919
  'Communicate concisely and strictly in English with zero canned greetings.');
874
920
  if (tools && tools.length > 0) {
@@ -1048,11 +1094,8 @@ export class AntigravityProvider extends LLMProvider {
1048
1094
  'Use <tool_call>{"name": "browser_act", "arguments": {"actions": [{"type": "preview", "filePath": "index.html"}, {"type": "snapshot"}]}}</tool_call> to verify rendered output directly. ' +
1049
1095
  'If you start a persistent local HTTP server, use `sysRunBg` or redirect stdio (`nohup ... </dev/null >/dev/null 2>&1 &`) so the server does not break with EIO when the turn pseudo-terminal closes.\n\n' + promptText;
1050
1096
  }
1051
- const modelSlug = resolveAgyModelId(this.model);
1052
- const explicitEffort = this.reasoningEffort && ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(this.reasoningEffort)
1053
- ? this.reasoningEffort
1054
- : null;
1055
- const effort = explicitEffort || resolveAgyEffort(this.model);
1097
+ const { modelSlug, effort } = resolveAgyCliModelAndEffort(this.model, this.reasoningEffort);
1098
+ const workerEffortKey = effort || resolveAgyEffort(modelSlug);
1056
1099
  // Run the user's normal peer in the selected project. Do not substitute a
1057
1100
  // managed inference profile or hide project MCPs, skills, and instructions.
1058
1101
  const workspaceRoot = path.resolve(options.workspaceRoot || process.cwd());
@@ -1067,7 +1110,7 @@ export class AntigravityProvider extends LLMProvider {
1067
1110
  '--model',
1068
1111
  modelSlug
1069
1112
  ];
1070
- if (effort && (Boolean(explicitEffort) || modelSlug.endsWith(`-${effort}`) || /-(low|medium|high|xhigh|max|ultra)$/i.test(modelSlug))) {
1113
+ if (effort) {
1071
1114
  args.push('--effort', effort);
1072
1115
  }
1073
1116
  if (useConversation && this.currentConversationId) {
@@ -1080,7 +1123,7 @@ export class AntigravityProvider extends LLMProvider {
1080
1123
  const reuseExistingWorker = Boolean(existingWorker
1081
1124
  && existingWorker.workspaceRoot === workspaceRoot
1082
1125
  && existingWorker.modelSlug === modelSlug
1083
- && existingWorker.effort === effort
1126
+ && existingWorker.effort === workerEffortKey
1084
1127
  && existingWorker.child.exitCode === null
1085
1128
  && existingWorker.child.signalCode === null
1086
1129
  && !existingWorker.child.killed
@@ -1105,7 +1148,7 @@ export class AntigravityProvider extends LLMProvider {
1105
1148
  windowsHide: true
1106
1149
  });
1107
1150
  if (canUsePersistent) {
1108
- this.persistentWorker = { child, workspaceRoot, modelSlug, effort };
1151
+ this.persistentWorker = { child, workspaceRoot, modelSlug, effort: workerEffortKey };
1109
1152
  }
1110
1153
  }
1111
1154
  this.activeChild = child;
@@ -1663,7 +1706,9 @@ export class AntigravityProvider extends LLMProvider {
1663
1706
  this.currentConversationId = null;
1664
1707
  const errDetail = finalResultObj?.error || stderrBuffer.trim() ||
1665
1708
  `terminal status ${finalResultObj?.status || 'unknown'}, exit code ${code}`;
1666
- safeReject(new Error(`Antigravity Agent (agy) failed: ${errDetail}`));
1709
+ const isInvalidSelection = /invalid model selection|conflicts with --effort|--effort is not supported/i.test(errDetail);
1710
+ const failure = Object.assign(new Error(`Antigravity Agent (agy) failed: ${errDetail}`), isInvalidSelection ? { code: 'AGY_INVALID_MODEL_SELECTION', status: 400 } : {});
1711
+ safeReject(failure);
1667
1712
  return;
1668
1713
  }
1669
1714
  let rawContent = (finalResultObj?.response || streamedResponse || '').trim();
@@ -1877,12 +1922,22 @@ export class AntigravityProvider extends LLMProvider {
1877
1922
  async chat(messages, options = {}) {
1878
1923
  const maxRetries = options.maxRetries ?? (options.taskIntent === 'launch' ? 1 : 2);
1879
1924
  let attempt = 0;
1925
+ let clearedEffortFallback = false;
1880
1926
  while (attempt <= maxRetries) {
1881
1927
  const hadConversation = Boolean(this.currentConversationId);
1882
1928
  try {
1883
1929
  return await this._executeOnce(messages, options);
1884
1930
  }
1885
1931
  catch (err) {
1932
+ if (err?.code === 'AGY_INVALID_MODEL_SELECTION') {
1933
+ if (!clearedEffortFallback && this.reasoningEffort) {
1934
+ clearedEffortFallback = true;
1935
+ this.reasoningEffort = null;
1936
+ this.currentConversationId = null;
1937
+ continue;
1938
+ }
1939
+ throw err;
1940
+ }
1886
1941
  if (!shouldRetryPeerError(err, options.signal?.aborted === true || err?.name === 'AbortError')
1887
1942
  || err?.code === 'AGY_NATIVE_ACTION_DENIED' || err?.code === 'PROVIDER_NO_PROGRESS') {
1888
1943
  throw err;
@@ -248,6 +248,58 @@ export function resolveAgyEffort(model?: string | null): string {
248
248
  return 'low';
249
249
  }
250
250
 
251
+ const VALID_AGY_EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
252
+
253
+ function findRegisteredAgySlug(candidateLower: string): string | null {
254
+ for (const slug of Object.values(ANTIGRAVITY_MODEL_IDS)) {
255
+ if (slug.toLowerCase() === candidateLower) return slug;
256
+ }
257
+ return null;
258
+ }
259
+
260
+ /**
261
+ * Resolve the exact `--model` slug and optional `--effort` flag for `agy` CLI
262
+ * without ever emitting a conflicting pair (e.g. `--model gemini-4-neon-xhigh --effort max`)
263
+ * or passing `--effort` to unsuffixed orchestrator models that reject it.
264
+ */
265
+ export function resolveAgyCliModelAndEffort(
266
+ model?: string | null,
267
+ rawReasoningEffort?: string | null
268
+ ): { modelSlug: string; effort: string | null } {
269
+ const baseSlug = resolveAgyModelId(model);
270
+ if (!baseSlug) return { modelSlug: '', effort: null };
271
+
272
+ const cleanedEffort = typeof rawReasoningEffort === 'string'
273
+ ? rawReasoningEffort.trim().toLowerCase()
274
+ : '';
275
+ const requestedEffort = VALID_AGY_EFFORTS.has(cleanedEffort) ? cleanedEffort : null;
276
+
277
+ const suffixMatch = /^(.+?)-(minimal|low|medium|high|xhigh|max)$/i.exec(baseSlug);
278
+ if (suffixMatch && suffixMatch[1] && suffixMatch[2]) {
279
+ const baseFamily = suffixMatch[1];
280
+ const slugEffort = suffixMatch[2].toLowerCase();
281
+ if (requestedEffort && requestedEffort !== slugEffort) {
282
+ const sibling = findRegisteredAgySlug(`${baseFamily.toLowerCase()}-${requestedEffort}`);
283
+ if (sibling) {
284
+ return { modelSlug: sibling, effort: null };
285
+ }
286
+ }
287
+ // Suffixed slugs already carry the exact effort tier; omitting `--effort`
288
+ // avoids redundant/conflicting flag rejection on every `agy` version.
289
+ return { modelSlug: baseSlug, effort: null };
290
+ }
291
+
292
+ if (requestedEffort) {
293
+ const sibling = findRegisteredAgySlug(`${baseSlug.toLowerCase()}-${requestedEffort}`);
294
+ if (sibling) {
295
+ return { modelSlug: sibling, effort: null };
296
+ }
297
+ }
298
+
299
+ // Unsuffixed models (such as orchestrators) reject `--effort`.
300
+ return { modelSlug: baseSlug, effort: null };
301
+ }
302
+
251
303
  export function isAntigravityProvider(provider?: string | null): boolean {
252
304
  if (!provider) return false;
253
305
  const p = String(provider).toLowerCase();
@@ -881,6 +933,8 @@ export class AntigravityProvider extends LLMProvider {
881
933
  'Follow the task scope and execute directly with your native tools (or Causyne host tools when needed). ' +
882
934
  'When target files and verification commands are specified, read those files, apply minimal accurate edits, and verify with the project test/build command — avoid redundant git log, find, or throwaway scratch probes. ' +
883
935
  'Put file contents directly in edit/write arguments, NEVER reply with conversational pleasantries, and report verified outcomes or blockers concisely.\n\n' +
936
+ '[Personalization Directive]\n' +
937
+ 'Strictly obey any Project Personalization (`.causyne/personalization.md`) and workspace instructions provided in the system messages—treat them as a high-priority binding operational contract for this project (vision, conventions, language, and style), subordinate only to safety and permission boundaries.\n\n' +
884
938
  '[Language & Communication Directive]\n' +
885
939
  'Communicate concisely and strictly in English with zero canned greetings.'
886
940
  );
@@ -1070,11 +1124,8 @@ export class AntigravityProvider extends LLMProvider {
1070
1124
  'If you start a persistent local HTTP server, use `sysRunBg` or redirect stdio (`nohup ... </dev/null >/dev/null 2>&1 &`) so the server does not break with EIO when the turn pseudo-terminal closes.\n\n' + promptText;
1071
1125
  }
1072
1126
 
1073
- const modelSlug = resolveAgyModelId(this.model);
1074
- const explicitEffort = this.reasoningEffort && ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(this.reasoningEffort)
1075
- ? this.reasoningEffort
1076
- : null;
1077
- const effort = explicitEffort || resolveAgyEffort(this.model);
1127
+ const { modelSlug, effort } = resolveAgyCliModelAndEffort(this.model, this.reasoningEffort);
1128
+ const workerEffortKey = effort || resolveAgyEffort(modelSlug);
1078
1129
 
1079
1130
  // Run the user's normal peer in the selected project. Do not substitute a
1080
1131
  // managed inference profile or hide project MCPs, skills, and instructions.
@@ -1091,7 +1142,7 @@ export class AntigravityProvider extends LLMProvider {
1091
1142
  modelSlug
1092
1143
  ];
1093
1144
 
1094
- if (effort && (Boolean(explicitEffort) || modelSlug.endsWith(`-${effort}`) || /-(low|medium|high|xhigh|max|ultra)$/i.test(modelSlug))) {
1145
+ if (effort) {
1095
1146
  args.push('--effort', effort);
1096
1147
  }
1097
1148
 
@@ -1107,7 +1158,7 @@ export class AntigravityProvider extends LLMProvider {
1107
1158
  existingWorker
1108
1159
  && existingWorker.workspaceRoot === workspaceRoot
1109
1160
  && existingWorker.modelSlug === modelSlug
1110
- && existingWorker.effort === effort
1161
+ && existingWorker.effort === workerEffortKey
1111
1162
  && existingWorker.child.exitCode === null
1112
1163
  && existingWorker.child.signalCode === null
1113
1164
  && !existingWorker.child.killed
@@ -1133,7 +1184,7 @@ export class AntigravityProvider extends LLMProvider {
1133
1184
  windowsHide: true
1134
1185
  });
1135
1186
  if (canUsePersistent) {
1136
- this.persistentWorker = { child, workspaceRoot, modelSlug, effort };
1187
+ this.persistentWorker = { child, workspaceRoot, modelSlug, effort: workerEffortKey };
1137
1188
  }
1138
1189
  }
1139
1190
  this.activeChild = child;
@@ -1686,7 +1737,12 @@ export class AntigravityProvider extends LLMProvider {
1686
1737
  if (useConversation) this.currentConversationId = null;
1687
1738
  const errDetail = finalResultObj?.error || stderrBuffer.trim() ||
1688
1739
  `terminal status ${finalResultObj?.status || 'unknown'}, exit code ${code}`;
1689
- safeReject(new Error(`Antigravity Agent (agy) failed: ${errDetail}`));
1740
+ const isInvalidSelection = /invalid model selection|conflicts with --effort|--effort is not supported/i.test(errDetail);
1741
+ const failure = Object.assign(
1742
+ new Error(`Antigravity Agent (agy) failed: ${errDetail}`),
1743
+ isInvalidSelection ? { code: 'AGY_INVALID_MODEL_SELECTION', status: 400 } : {}
1744
+ );
1745
+ safeReject(failure);
1690
1746
  return;
1691
1747
  }
1692
1748
 
@@ -1924,11 +1980,21 @@ export class AntigravityProvider extends LLMProvider {
1924
1980
  override async chat(messages: any[], options: ChatOptions = {}): Promise<ChatResponse> {
1925
1981
  const maxRetries = options.maxRetries ?? ((options as any).taskIntent === 'launch' ? 1 : 2);
1926
1982
  let attempt = 0;
1983
+ let clearedEffortFallback = false;
1927
1984
  while (attempt <= maxRetries) {
1928
1985
  const hadConversation = Boolean(this.currentConversationId);
1929
1986
  try {
1930
1987
  return await this._executeOnce(messages, options);
1931
1988
  } catch (err: any) {
1989
+ if (err?.code === 'AGY_INVALID_MODEL_SELECTION') {
1990
+ if (!clearedEffortFallback && this.reasoningEffort) {
1991
+ clearedEffortFallback = true;
1992
+ this.reasoningEffort = null;
1993
+ this.currentConversationId = null;
1994
+ continue;
1995
+ }
1996
+ throw err;
1997
+ }
1932
1998
  if (!shouldRetryPeerError(err, options.signal?.aborted === true || err?.name === 'AbortError')
1933
1999
  || err?.code === 'AGY_NATIVE_ACTION_DENIED' || err?.code === 'PROVIDER_NO_PROGRESS') {
1934
2000
  throw err;
@@ -220,7 +220,13 @@ export function redactTextSecrets(rawText, secrets = [], options = {}) {
220
220
  const trimmed = secret.trim();
221
221
  if (trimmed.length >= 6) {
222
222
  text = text.split(trimmed).join('[REDACTED]');
223
- const encoded = encodeURIComponent(trimmed);
223
+ let encoded = trimmed;
224
+ try {
225
+ encoded = encodeURIComponent(trimmed);
226
+ }
227
+ catch {
228
+ // The raw secret was already redacted; malformed UTF-16 has no URI encoding.
229
+ }
224
230
  if (encoded !== trimmed && encoded.length >= 6) {
225
231
  text = text.split(encoded).join('[REDACTED]');
226
232
  }
@@ -309,7 +309,12 @@ export function redactTextSecrets(
309
309
  const trimmed = secret.trim();
310
310
  if (trimmed.length >= 6) {
311
311
  text = text.split(trimmed).join('[REDACTED]');
312
- const encoded = encodeURIComponent(trimmed);
312
+ let encoded = trimmed;
313
+ try {
314
+ encoded = encodeURIComponent(trimmed);
315
+ } catch {
316
+ // The raw secret was already redacted; malformed UTF-16 has no URI encoding.
317
+ }
313
318
  if (encoded !== trimmed && encoded.length >= 6) {
314
319
  text = text.split(encoded).join('[REDACTED]');
315
320
  }
@@ -210,22 +210,30 @@ async function consumeSseStream(response, providerLabel, maxBytes, onEvent, sign
210
210
  await reader.cancel().catch(() => { });
211
211
  throw new Error(`${providerLabel} SSE event buffer exceeded safety limit (${MAX_SSE_BUFFER_BYTES} bytes).`);
212
212
  }
213
- let newlineIdx = buffer.indexOf('\n');
213
+ let newlineIdx = buffer.search(/[\r\n]/);
214
214
  while (newlineIdx !== -1) {
215
+ // Retain a trailing CR until the next chunk to distinguish CRLF.
216
+ if (buffer[newlineIdx] === '\r' && newlineIdx === buffer.length - 1)
217
+ break;
218
+ const delimiterLength = buffer.slice(newlineIdx, newlineIdx + 2) === '\r\n' ? 2 : 1;
215
219
  const line = buffer.slice(0, newlineIdx);
216
- buffer = buffer.slice(newlineIdx + 1);
220
+ buffer = buffer.slice(newlineIdx + delimiterLength);
217
221
  processLine(line);
218
- newlineIdx = buffer.indexOf('\n');
222
+ newlineIdx = buffer.search(/[\r\n]/);
219
223
  }
220
224
  }
221
225
  buffer += decoder.decode();
222
226
  if (buffer.length > 0) {
223
- for (const tailLine of buffer.split('\n')) {
227
+ for (const tailLine of buffer.split(/\r\n|\r|\n/)) {
224
228
  processLine(tailLine);
225
229
  }
226
230
  }
227
231
  flushEvent();
228
232
  }
233
+ catch (error) {
234
+ await reader.cancel().catch(() => { });
235
+ throw error;
236
+ }
229
237
  finally {
230
238
  reader.releaseLock();
231
239
  }
@@ -243,14 +251,15 @@ async function consumeNdjsonStream(response, providerLabel, maxBytes, onObject,
243
251
  const trimmed = stripped.trim();
244
252
  if (!trimmed)
245
253
  return;
254
+ let parsed;
246
255
  try {
247
- const parsed = JSON.parse(trimmed);
248
- if (isRecord(parsed))
249
- onObject(parsed);
256
+ parsed = JSON.parse(trimmed);
250
257
  }
251
258
  catch {
252
- // Ignore malformed trailing fragments
259
+ return;
253
260
  }
261
+ if (isRecord(parsed))
262
+ onObject(parsed);
254
263
  };
255
264
  try {
256
265
  while (true) {
@@ -287,6 +296,10 @@ async function consumeNdjsonStream(response, providerLabel, maxBytes, onObject,
287
296
  processLine(buffer);
288
297
  }
289
298
  }
299
+ catch (error) {
300
+ await reader.cancel().catch(() => { });
301
+ throw error;
302
+ }
290
303
  finally {
291
304
  reader.releaseLock();
292
305
  }
@@ -275,22 +275,28 @@ async function consumeSseStream(
275
275
  throw new Error(`${providerLabel} SSE event buffer exceeded safety limit (${MAX_SSE_BUFFER_BYTES} bytes).`);
276
276
  }
277
277
 
278
- let newlineIdx = buffer.indexOf('\n');
278
+ let newlineIdx = buffer.search(/[\r\n]/);
279
279
  while (newlineIdx !== -1) {
280
+ // Retain a trailing CR until the next chunk to distinguish CRLF.
281
+ if (buffer[newlineIdx] === '\r' && newlineIdx === buffer.length - 1) break;
282
+ const delimiterLength = buffer.slice(newlineIdx, newlineIdx + 2) === '\r\n' ? 2 : 1;
280
283
  const line = buffer.slice(0, newlineIdx);
281
- buffer = buffer.slice(newlineIdx + 1);
284
+ buffer = buffer.slice(newlineIdx + delimiterLength);
282
285
  processLine(line);
283
- newlineIdx = buffer.indexOf('\n');
286
+ newlineIdx = buffer.search(/[\r\n]/);
284
287
  }
285
288
  }
286
289
 
287
290
  buffer += decoder.decode();
288
291
  if (buffer.length > 0) {
289
- for (const tailLine of buffer.split('\n')) {
292
+ for (const tailLine of buffer.split(/\r\n|\r|\n/)) {
290
293
  processLine(tailLine);
291
294
  }
292
295
  }
293
296
  flushEvent();
297
+ } catch (error) {
298
+ await reader.cancel().catch(() => {});
299
+ throw error;
294
300
  } finally {
295
301
  reader.releaseLock();
296
302
  }
@@ -316,12 +322,13 @@ async function consumeNdjsonStream(
316
322
  const stripped = rawLine.charCodeAt(0) === 0xfeff ? rawLine.slice(1) : rawLine;
317
323
  const trimmed = stripped.trim();
318
324
  if (!trimmed) return;
325
+ let parsed: unknown;
319
326
  try {
320
- const parsed: unknown = JSON.parse(trimmed);
321
- if (isRecord(parsed)) onObject(parsed);
327
+ parsed = JSON.parse(trimmed);
322
328
  } catch {
323
- // Ignore malformed trailing fragments
329
+ return;
324
330
  }
331
+ if (isRecord(parsed)) onObject(parsed);
325
332
  };
326
333
 
327
334
  try {
@@ -360,6 +367,9 @@ async function consumeNdjsonStream(
360
367
  if (buffer.trim()) {
361
368
  processLine(buffer);
362
369
  }
370
+ } catch (error) {
371
+ await reader.cancel().catch(() => {});
372
+ throw error;
363
373
  } finally {
364
374
  reader.releaseLock();
365
375
  }
@@ -3,7 +3,7 @@ import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
3
3
  import { LLMProvider } from './base.js';
4
4
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
5
5
  import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
6
- import { requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
6
+ import { ProviderHttpError, requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
7
7
  import { streamOpenAICompatibleChat, wantsStreaming } from './byokStream.js';
8
8
  import { resolveBudgetTokensForVariant } from '../modelVariants.js';
9
9
  export class DashscopeByokProvider extends LLMProvider {
@@ -109,17 +109,33 @@ export class DashscopeByokProvider extends LLMProvider {
109
109
  }
110
110
  }
111
111
  };
112
- const data = wantsStreaming(options)
112
+ const runDashscopeRequest = async (reqPayload) => (wantsStreaming(options)
113
113
  ? await streamOpenAICompatibleChat({
114
114
  ...requestOpts,
115
- payload,
115
+ payload: reqPayload,
116
116
  onChunk: options.onChunk,
117
117
  onReasoningChunk: options.onReasoningChunk
118
118
  })
119
119
  : await safeProviderFetchJson({
120
120
  ...requestOpts,
121
- body: JSON.stringify(payload)
122
- });
121
+ body: JSON.stringify(reqPayload)
122
+ }));
123
+ let data;
124
+ try {
125
+ data = await runDashscopeRequest(payload);
126
+ }
127
+ catch (err) {
128
+ const rejectedThinking = ('enable_thinking' in payload || 'thinking_budget' in payload)
129
+ && err instanceof ProviderHttpError
130
+ && err.status === 400
131
+ && /(?:enable_thinking|thinking_budget|thinking|unsupported|not supported|invalid|unknown)/i.test(err.message);
132
+ if (!rejectedThinking)
133
+ throw err;
134
+ const fallbackPayload = { ...payload };
135
+ delete fallbackPayload['enable_thinking'];
136
+ delete fallbackPayload['thinking_budget'];
137
+ data = await runDashscopeRequest(fallbackPayload);
138
+ }
123
139
  const normalized = normalizeOpenAIChatChoiceResponse(data, {
124
140
  prefix: 'call_dashscope',
125
141
  freeFormPaths
@@ -4,6 +4,7 @@ import { LLMProvider, type ChatOptions, type ChatResponse, type ProviderConfig }
4
4
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
5
5
  import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
6
6
  import {
7
+ ProviderHttpError,
7
8
  requireApiKey,
8
9
  resolveTemperature,
9
10
  safeProviderFetchJson
@@ -116,17 +117,34 @@ export class DashscopeByokProvider extends LLMProvider {
116
117
  }
117
118
  };
118
119
 
119
- const data = wantsStreaming(options)
120
- ? await streamOpenAICompatibleChat({
121
- ...requestOpts,
122
- payload,
123
- onChunk: options.onChunk,
124
- onReasoningChunk: options.onReasoningChunk
125
- })
126
- : await safeProviderFetchJson({
127
- ...requestOpts,
128
- body: JSON.stringify(payload)
129
- });
120
+ const runDashscopeRequest = async (reqPayload: Record<string, any>) => (
121
+ wantsStreaming(options)
122
+ ? await streamOpenAICompatibleChat({
123
+ ...requestOpts,
124
+ payload: reqPayload,
125
+ onChunk: options.onChunk,
126
+ onReasoningChunk: options.onReasoningChunk
127
+ })
128
+ : await safeProviderFetchJson({
129
+ ...requestOpts,
130
+ body: JSON.stringify(reqPayload)
131
+ })
132
+ );
133
+
134
+ let data: Record<string, any>;
135
+ try {
136
+ data = await runDashscopeRequest(payload);
137
+ } catch (err: unknown) {
138
+ const rejectedThinking = ('enable_thinking' in payload || 'thinking_budget' in payload)
139
+ && err instanceof ProviderHttpError
140
+ && err.status === 400
141
+ && /(?:enable_thinking|thinking_budget|thinking|unsupported|not supported|invalid|unknown)/i.test(err.message);
142
+ if (!rejectedThinking) throw err;
143
+ const fallbackPayload = { ...payload };
144
+ delete fallbackPayload['enable_thinking'];
145
+ delete fallbackPayload['thinking_budget'];
146
+ data = await runDashscopeRequest(fallbackPayload);
147
+ }
130
148
  const normalized = normalizeOpenAIChatChoiceResponse(data, {
131
149
  prefix: 'call_dashscope',
132
150
  freeFormPaths
@@ -3,7 +3,7 @@ import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
3
3
  import { LLMProvider } from './base.js';
4
4
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
5
5
  import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
6
- import { requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
6
+ import { ProviderHttpError, requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
7
7
  import { streamOpenAICompatibleChat, wantsStreaming } from './byokStream.js';
8
8
  export class MoonshotProvider extends LLMProvider {
9
9
  allowInsecureHttp;
@@ -38,8 +38,11 @@ export class MoonshotProvider extends LLMProvider {
38
38
  }
39
39
  else {
40
40
  payload['thinking'] = { type: 'enabled' };
41
- if (['low', 'medium', 'high'].includes(this.reasoningEffort)) {
42
- payload['reasoning_effort'] = this.reasoningEffort;
41
+ const mappedEffort = this.reasoningEffort === 'minimal'
42
+ ? 'low'
43
+ : (['xhigh', 'max', 'ultra'].includes(this.reasoningEffort) ? 'high' : this.reasoningEffort);
44
+ if (['low', 'medium', 'high'].includes(mappedEffort)) {
45
+ payload['reasoning_effort'] = mappedEffort;
43
46
  }
44
47
  }
45
48
  }
@@ -88,17 +91,33 @@ export class MoonshotProvider extends LLMProvider {
88
91
  }
89
92
  }
90
93
  };
91
- const data = wantsStreaming(options)
94
+ const runMoonshotRequest = async (reqPayload) => (wantsStreaming(options)
92
95
  ? await streamOpenAICompatibleChat({
93
96
  ...requestOpts,
94
- payload,
97
+ payload: reqPayload,
95
98
  onChunk: options.onChunk,
96
99
  onReasoningChunk: options.onReasoningChunk
97
100
  })
98
101
  : await safeProviderFetchJson({
99
102
  ...requestOpts,
100
- body: JSON.stringify(payload)
101
- });
103
+ body: JSON.stringify(reqPayload)
104
+ }));
105
+ let data;
106
+ try {
107
+ data = await runMoonshotRequest(payload);
108
+ }
109
+ catch (err) {
110
+ const rejectedReasoning = ('thinking' in payload || 'reasoning_effort' in payload)
111
+ && err instanceof ProviderHttpError
112
+ && err.status === 400
113
+ && /(?:thinking|reasoning_effort|effort|unsupported|not supported|invalid|unknown)/i.test(err.message);
114
+ if (!rejectedReasoning)
115
+ throw err;
116
+ const fallbackPayload = { ...payload };
117
+ delete fallbackPayload['thinking'];
118
+ delete fallbackPayload['reasoning_effort'];
119
+ data = await runMoonshotRequest(fallbackPayload);
120
+ }
102
121
  const normalized = normalizeOpenAIChatChoiceResponse(data, {
103
122
  prefix: 'call_moonshot',
104
123
  freeFormPaths