@andorra-labs/code 0.1.12 → 0.1.13

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 (592) hide show
  1. package/dist/src/account-presentation.d.ts +1 -37
  2. package/dist/src/account-presentation.js +2 -42
  3. package/dist/src/activity.d.ts +0 -25
  4. package/dist/src/activity.js +1 -23
  5. package/dist/src/agent-definitions.d.ts +0 -26
  6. package/dist/src/agent-definitions.js +0 -43
  7. package/dist/src/agent-execution.d.ts +0 -2
  8. package/dist/src/agent-execution.js +49 -416
  9. package/dist/src/agent-mcp-catalog.d.ts +0 -8
  10. package/dist/src/agent-mcp-catalog.js +0 -2
  11. package/dist/src/agent-mcp.d.ts +0 -56
  12. package/dist/src/agent-mcp.js +9 -153
  13. package/dist/src/agent-modifiers.d.ts +0 -1
  14. package/dist/src/agent-modifiers.js +25 -68
  15. package/dist/src/analytics.d.ts +0 -66
  16. package/dist/src/analytics.js +0 -45
  17. package/dist/src/anthropic-console-auth.d.ts +0 -24
  18. package/dist/src/anthropic-console-auth.js +0 -37
  19. package/dist/src/anthropic-credentials.d.ts +0 -25
  20. package/dist/src/anthropic-credentials.js +0 -28
  21. package/dist/src/app-server/protocol.d.ts +13 -245
  22. package/dist/src/app-server/protocol.js +1 -132
  23. package/dist/src/app-server/reasoning.d.ts +0 -31
  24. package/dist/src/app-server/reasoning.js +0 -54
  25. package/dist/src/app-server/terminal.d.ts +0 -36
  26. package/dist/src/app-server/terminal.js +3 -39
  27. package/dist/src/app-server/workspace.d.ts +0 -167
  28. package/dist/src/app-server/workspace.js +4 -406
  29. package/dist/src/app-server.d.ts +27 -927
  30. package/dist/src/app-server.js +537 -2992
  31. package/dist/src/artifacts.d.ts +0 -10
  32. package/dist/src/artifacts.js +1 -11
  33. package/dist/src/attachments.d.ts +4 -98
  34. package/dist/src/attachments.js +10 -130
  35. package/dist/src/auth/AuthManager.d.ts +0 -93
  36. package/dist/src/auth/AuthManager.js +3 -165
  37. package/dist/src/auth/callback-page.d.ts +0 -1
  38. package/dist/src/auth/callback-page.js +0 -4
  39. package/dist/src/auth/callback.d.ts +0 -25
  40. package/dist/src/auth/callback.js +1 -29
  41. package/dist/src/auth/deployment.d.ts +0 -16
  42. package/dist/src/auth/deployment.js +0 -16
  43. package/dist/src/auth/index.d.ts +0 -11
  44. package/dist/src/auth/index.js +0 -11
  45. package/dist/src/auth/lock.d.ts +0 -1
  46. package/dist/src/auth/lock.js +0 -1
  47. package/dist/src/auth/store.d.ts +7 -108
  48. package/dist/src/auth/store.js +21 -129
  49. package/dist/src/auth/types.d.ts +0 -8
  50. package/dist/src/auth-commands.d.ts +0 -5
  51. package/dist/src/auth-commands.js +0 -1
  52. package/dist/src/automation-runner.d.ts +0 -9
  53. package/dist/src/automation-runner.js +0 -11
  54. package/dist/src/automation-service.d.ts +0 -10
  55. package/dist/src/automation-service.js +3 -17
  56. package/dist/src/automation-tool.js +0 -5
  57. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  58. package/dist/src/automation-worker-shutdown.js +0 -3
  59. package/dist/src/automations.d.ts +23 -2
  60. package/dist/src/automations.js +91 -12
  61. package/dist/src/background-tasks.d.ts +0 -23
  62. package/dist/src/background-tasks.js +0 -11
  63. package/dist/src/boot-trace.d.ts +0 -13
  64. package/dist/src/boot-trace.js +1 -14
  65. package/dist/src/browser-activity.js +0 -2
  66. package/dist/src/browser-bridge.d.ts +0 -2
  67. package/dist/src/browser-bridge.js +0 -27
  68. package/dist/src/browser-captcha-tool.d.ts +0 -13
  69. package/dist/src/browser-captcha-tool.js +3 -35
  70. package/dist/src/browser-extensions-tool.d.ts +24 -0
  71. package/dist/src/browser-extensions-tool.js +137 -0
  72. package/dist/src/browser-extensions.d.ts +127 -0
  73. package/dist/src/browser-extensions.js +729 -0
  74. package/dist/src/browser-observation.d.ts +0 -15
  75. package/dist/src/browser-observation.js +1 -22
  76. package/dist/src/browser-panel-tool.d.ts +1 -37
  77. package/dist/src/browser-panel-tool.js +3 -73
  78. package/dist/src/browser-runner.d.ts +0 -1
  79. package/dist/src/browser-runner.js +4 -45
  80. package/dist/src/browser-server.d.ts +0 -6
  81. package/dist/src/browser-server.js +6 -229
  82. package/dist/src/browser-session.d.ts +0 -25
  83. package/dist/src/browser-session.js +1 -71
  84. package/dist/src/browser-stealth.d.ts +0 -12
  85. package/dist/src/browser-stealth.js +0 -36
  86. package/dist/src/browser-ui/app.js +7 -174
  87. package/dist/src/browser-ui/style.css +0 -68
  88. package/dist/src/browser-ui/tokens.css +11 -93
  89. package/dist/src/browser-view.d.ts +47 -301
  90. package/dist/src/browser-view.js +333 -582
  91. package/dist/src/capabilities.d.ts +0 -8
  92. package/dist/src/capabilities.js +0 -29
  93. package/dist/src/capsolver.d.ts +0 -13
  94. package/dist/src/capsolver.js +0 -15
  95. package/dist/src/clarification-ui.d.ts +0 -7
  96. package/dist/src/clarification-ui.js +0 -8
  97. package/dist/src/claude-executable.d.ts +0 -1
  98. package/dist/src/claude-executable.js +1 -2
  99. package/dist/src/claude-provider.d.ts +6 -19
  100. package/dist/src/claude-provider.js +155 -63
  101. package/dist/src/cli-executable.d.ts +0 -16
  102. package/dist/src/cli-executable.js +0 -7
  103. package/dist/src/cli-process.d.ts +0 -26
  104. package/dist/src/cli-process.js +0 -18
  105. package/dist/src/cli-sign-in.d.ts +0 -20
  106. package/dist/src/cli-sign-in.js +1 -17
  107. package/dist/src/cli.d.ts +1 -55
  108. package/dist/src/cli.js +80 -721
  109. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  110. package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
  111. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  112. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  113. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  114. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  115. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  116. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  117. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  118. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  119. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  120. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  121. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  122. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  123. package/dist/src/code-intelligence/repository.d.ts +0 -9
  124. package/dist/src/code-intelligence/repository.js +1 -11
  125. package/dist/src/code-intelligence/types.d.ts +0 -8
  126. package/dist/src/codex-auth.d.ts +0 -44
  127. package/dist/src/codex-auth.js +0 -45
  128. package/dist/src/codex-browser-auth.d.ts +0 -13
  129. package/dist/src/codex-browser-auth.js +3 -20
  130. package/dist/src/codex-errors.js +0 -2
  131. package/dist/src/codex-executable.d.ts +0 -2
  132. package/dist/src/codex-executable.js +1 -7
  133. package/dist/src/codex-provider.d.ts +0 -13
  134. package/dist/src/codex-provider.js +0 -28
  135. package/dist/src/codex-rpc.d.ts +0 -10
  136. package/dist/src/codex-rpc.js +0 -12
  137. package/dist/src/coding-tools.d.ts +4 -26
  138. package/dist/src/coding-tools.js +161 -181
  139. package/dist/src/command-metrics.d.ts +0 -4
  140. package/dist/src/command-output-tap.d.ts +0 -11
  141. package/dist/src/command-output-tap.js +0 -3
  142. package/dist/src/command-screens.d.ts +24 -0
  143. package/dist/src/command-screens.js +132 -100
  144. package/dist/src/commands.d.ts +6 -63
  145. package/dist/src/commands.js +20 -100
  146. package/dist/src/completion-gates.d.ts +0 -47
  147. package/dist/src/completion-gates.js +0 -14
  148. package/dist/src/completion.d.ts +0 -98
  149. package/dist/src/completion.js +2 -239
  150. package/dist/src/config.d.ts +11 -116
  151. package/dist/src/config.js +39 -171
  152. package/dist/src/context-budget.d.ts +0 -22
  153. package/dist/src/context-budget.js +0 -44
  154. package/dist/src/context-compaction.d.ts +29 -6
  155. package/dist/src/context-compaction.js +94 -25
  156. package/dist/src/context-selection.d.ts +0 -24
  157. package/dist/src/context-selection.js +0 -34
  158. package/dist/src/dashboard-view.d.ts +0 -2
  159. package/dist/src/dashboard-view.js +0 -35
  160. package/dist/src/dashboard.d.ts +0 -2
  161. package/dist/src/dashboard.js +0 -9
  162. package/dist/src/deadline.d.ts +0 -45
  163. package/dist/src/deadline.js +0 -54
  164. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  165. package/dist/src/decision/ContinuationAdapter.js +0 -5
  166. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  167. package/dist/src/decision/DecisionManager.d.ts +0 -1
  168. package/dist/src/decision/DecisionManager.js +2 -7
  169. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  170. package/dist/src/decision/DecisionPolicy.js +0 -1
  171. package/dist/src/decision/FactContinuations.d.ts +11 -43
  172. package/dist/src/decision/FactContinuations.js +126 -95
  173. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  174. package/dist/src/decision/FactServiceGate.js +0 -4
  175. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  176. package/dist/src/decision/PreparedSteps.js +0 -10
  177. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  178. package/dist/src/decision/applyToolMenu.js +1 -5
  179. package/dist/src/decision/checks.d.ts +15 -28
  180. package/dist/src/decision/checks.js +118 -49
  181. package/dist/src/decision/facts.d.ts +0 -16
  182. package/dist/src/decision/facts.js +0 -30
  183. package/dist/src/decision/guidancePolicy.js +0 -1
  184. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  185. package/dist/src/decision/hostedPolicy.js +0 -7
  186. package/dist/src/decision/hostedSkills.d.ts +0 -19
  187. package/dist/src/decision/hostedSkills.js +0 -19
  188. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  189. package/dist/src/decision/optimizationPolicy.js +1 -4
  190. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  191. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  192. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  193. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  194. package/dist/src/decision/routeTools.d.ts +0 -8
  195. package/dist/src/decision/routeTools.js +1 -8
  196. package/dist/src/decision/toolFamilies.d.ts +0 -1
  197. package/dist/src/decision/toolFamilies.js +0 -1
  198. package/dist/src/decision/toolMenu.d.ts +0 -3
  199. package/dist/src/decision/toolMenu.js +0 -4
  200. package/dist/src/decision/types.d.ts +0 -6
  201. package/dist/src/default-graph.d.ts +0 -9
  202. package/dist/src/default-graph.js +0 -9
  203. package/dist/src/delegation-changes.d.ts +0 -56
  204. package/dist/src/delegation-changes.js +4 -130
  205. package/dist/src/diff-preview.d.ts +0 -1
  206. package/dist/src/diff-preview.js +0 -17
  207. package/dist/src/duration.d.ts +0 -50
  208. package/dist/src/duration.js +0 -50
  209. package/dist/src/efficiency.d.ts +0 -39
  210. package/dist/src/efficiency.js +0 -16
  211. package/dist/src/engine/protocol.d.ts +0 -2
  212. package/dist/src/engine/protocol.js +0 -2
  213. package/dist/src/engine-streams.d.ts +0 -9
  214. package/dist/src/extensions.d.ts +3 -2
  215. package/dist/src/extensions.js +63 -35
  216. package/dist/src/favicons.d.ts +0 -26
  217. package/dist/src/favicons.js +0 -34
  218. package/dist/src/file-diff.d.ts +2 -58
  219. package/dist/src/file-diff.js +0 -32
  220. package/dist/src/file-read-key.d.ts +0 -7
  221. package/dist/src/file-read-key.js +0 -7
  222. package/dist/src/file-read-state.d.ts +0 -1
  223. package/dist/src/file-read-state.js +0 -4
  224. package/dist/src/firefox-cookies.d.ts +0 -34
  225. package/dist/src/firefox-cookies.js +1 -55
  226. package/dist/src/git-identity-audit.d.ts +27 -0
  227. package/dist/src/git-identity-audit.js +286 -0
  228. package/dist/src/git-identity-guard.d.ts +4 -0
  229. package/dist/src/git-identity-guard.js +998 -0
  230. package/dist/src/git-identity-hold.d.ts +12 -0
  231. package/dist/src/git-identity-hold.js +81 -0
  232. package/dist/src/git-summary.d.ts +0 -58
  233. package/dist/src/git-summary.js +2 -212
  234. package/dist/src/goal-completion-verification.d.ts +2 -2
  235. package/dist/src/goal-completion-verification.js +3 -6
  236. package/dist/src/graph-account.d.ts +0 -21
  237. package/dist/src/graph-account.js +0 -17
  238. package/dist/src/graph-editor-session.d.ts +0 -1
  239. package/dist/src/graph-editor-session.js +0 -3
  240. package/dist/src/graph-health.d.ts +0 -63
  241. package/dist/src/graph-health.js +0 -57
  242. package/dist/src/graph-manager-chat.d.ts +5 -155
  243. package/dist/src/graph-manager-chat.js +2 -177
  244. package/dist/src/graph-provider-portability.d.ts +1 -21
  245. package/dist/src/graph-provider-portability.js +6 -45
  246. package/dist/src/graph-quota.d.ts +0 -33
  247. package/dist/src/graph-quota.js +1 -44
  248. package/dist/src/graph-runner.d.ts +0 -1
  249. package/dist/src/graph-runner.js +31 -391
  250. package/dist/src/graph-selection.d.ts +0 -14
  251. package/dist/src/graph-selection.js +0 -14
  252. package/dist/src/graph-server.d.ts +2 -10
  253. package/dist/src/graph-server.js +39 -101
  254. package/dist/src/graph-studio-features.d.ts +0 -5
  255. package/dist/src/graph-studio-features.js +2 -42
  256. package/dist/src/graph-sync.d.ts +0 -78
  257. package/dist/src/graph-sync.js +5 -201
  258. package/dist/src/graph-tool.d.ts +0 -18
  259. package/dist/src/graph-tool.js +0 -27
  260. package/dist/src/graph-ui/app.js +152 -491
  261. package/dist/src/graph-ui/compat.js +0 -7
  262. package/dist/src/graph-ui/controls.css +0 -48
  263. package/dist/src/graph-ui/controls.js +0 -88
  264. package/dist/src/graph-ui/drafts.js +0 -12
  265. package/dist/src/graph-ui/edge-router.js +0 -62
  266. package/dist/src/graph-ui/embed.js +0 -59
  267. package/dist/src/graph-ui/icons.js +0 -8
  268. package/dist/src/graph-ui/library.css +0 -5
  269. package/dist/src/graph-ui/manager-markdown.js +0 -11
  270. package/dist/src/graph-ui/manager-state.js +1 -78
  271. package/dist/src/graph-ui/manager.css +0 -18
  272. package/dist/src/graph-ui/manager.js +3 -180
  273. package/dist/src/graph-ui/model-picker.js +0 -29
  274. package/dist/src/graph-ui/sidebar.js +2 -3
  275. package/dist/src/graph-ui/skill-picker.js +373 -39
  276. package/dist/src/graph-ui/studio-canvas.js +3 -38
  277. package/dist/src/graph-ui/studio.css +0 -18
  278. package/dist/src/graph-ui/studio.js +3 -71
  279. package/dist/src/graph-ui/style.css +11 -134
  280. package/dist/src/graph-ui/theme.js +1 -26
  281. package/dist/src/graph-ui/tokens.css +15 -114
  282. package/dist/src/graphs.d.ts +6 -157
  283. package/dist/src/graphs.js +65 -266
  284. package/dist/src/grep-regex-worker.js +0 -2
  285. package/dist/src/grep-regex.d.ts +1 -5
  286. package/dist/src/grep-regex.js +6 -8
  287. package/dist/src/grok-provider.d.ts +0 -17
  288. package/dist/src/grok-provider.js +1 -26
  289. package/dist/src/handoffs.d.ts +0 -11
  290. package/dist/src/handoffs.js +0 -13
  291. package/dist/src/hardened-runtime.d.ts +0 -10
  292. package/dist/src/hardened-runtime.js +8 -46
  293. package/dist/src/harness-home.d.ts +21 -0
  294. package/dist/src/harness-home.js +87 -0
  295. package/dist/src/host-process-guard.d.ts +0 -50
  296. package/dist/src/host-process-guard.js +0 -641
  297. package/dist/src/limits.d.ts +0 -64
  298. package/dist/src/limits.js +0 -62
  299. package/dist/src/managed-sign-in.d.ts +0 -12
  300. package/dist/src/managed-sign-in.js +0 -16
  301. package/dist/src/markdown.d.ts +0 -28
  302. package/dist/src/markdown.js +1 -175
  303. package/dist/src/mcp.d.ts +0 -99
  304. package/dist/src/mcp.js +4 -170
  305. package/dist/src/membership-errors.d.ts +0 -14
  306. package/dist/src/membership-errors.js +0 -13
  307. package/dist/src/membership.d.ts +2 -60
  308. package/dist/src/membership.js +0 -85
  309. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  310. package/dist/src/memory/LocalToolMemory.js +2 -7
  311. package/dist/src/memory/MemoryDistiller.js +0 -15
  312. package/dist/src/memory/MemoryManager.d.ts +0 -3
  313. package/dist/src/memory/MemoryManager.js +6 -18
  314. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  315. package/dist/src/memory/MemoryPolicy.js +0 -2
  316. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  317. package/dist/src/memory/MemoryRetriever.js +0 -7
  318. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  319. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  320. package/dist/src/memory/ProjectMemory.d.ts +5 -40
  321. package/dist/src/memory/ProjectMemory.js +22 -47
  322. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  323. package/dist/src/memory/ToolFailureLessons.js +0 -6
  324. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  325. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  326. package/dist/src/memory/redaction.d.ts +0 -5
  327. package/dist/src/memory/redaction.js +0 -11
  328. package/dist/src/memory/repository.d.ts +0 -6
  329. package/dist/src/memory/repository.js +2 -12
  330. package/dist/src/memory/types.d.ts +0 -1
  331. package/dist/src/model-health-cache.d.ts +0 -38
  332. package/dist/src/model-health-cache.js +1 -49
  333. package/dist/src/model-metadata.d.ts +0 -18
  334. package/dist/src/model-metadata.js +2 -42
  335. package/dist/src/model-override.d.ts +0 -36
  336. package/dist/src/model-override.js +0 -43
  337. package/dist/src/model-tiers.d.ts +0 -13
  338. package/dist/src/model-tiers.js +0 -23
  339. package/dist/src/opencode-catalog.d.ts +0 -2
  340. package/dist/src/opencode-catalog.js +0 -11
  341. package/dist/src/opencode-cli-provider.d.ts +0 -35
  342. package/dist/src/opencode-cli-provider.js +1 -44
  343. package/dist/src/opencode-provider.d.ts +0 -2
  344. package/dist/src/opencode-provider.js +1 -16
  345. package/dist/src/package-name.d.ts +0 -2
  346. package/dist/src/package-name.js +0 -2
  347. package/dist/src/paged-transcript.d.ts +0 -11
  348. package/dist/src/paged-transcript.js +2 -20
  349. package/dist/src/palette.d.ts +0 -63
  350. package/dist/src/palette.js +0 -63
  351. package/dist/src/permissions.d.ts +0 -15
  352. package/dist/src/permissions.js +0 -17
  353. package/dist/src/powershell-pool.d.ts +0 -9
  354. package/dist/src/powershell-pool.js +3 -26
  355. package/dist/src/process-warnings.d.ts +4 -0
  356. package/dist/src/process-warnings.js +103 -0
  357. package/dist/src/profile.d.ts +0 -43
  358. package/dist/src/profile.js +0 -43
  359. package/dist/src/project-reservation.d.ts +11 -0
  360. package/dist/src/project-reservation.js +143 -0
  361. package/dist/src/provider-connection.d.ts +0 -18
  362. package/dist/src/provider-connection.js +0 -39
  363. package/dist/src/provider-engine.d.ts +0 -21
  364. package/dist/src/provider-engine.js +1 -96
  365. package/dist/src/provider-import.d.ts +0 -49
  366. package/dist/src/provider-import.js +0 -60
  367. package/dist/src/provider-keys.d.ts +1 -36
  368. package/dist/src/provider-keys.js +5 -48
  369. package/dist/src/provider-settings.d.ts +0 -2
  370. package/dist/src/provider-settings.js +0 -32
  371. package/dist/src/providers.d.ts +0 -217
  372. package/dist/src/providers.js +0 -315
  373. package/dist/src/pull-requests.d.ts +0 -173
  374. package/dist/src/pull-requests.js +5 -195
  375. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  376. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  377. package/dist/src/qa/command-policy.d.ts +0 -23
  378. package/dist/src/qa/command-policy.js +0 -30
  379. package/dist/src/qa/guidance.d.ts +0 -21
  380. package/dist/src/qa/guidance.js +0 -20
  381. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  382. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  383. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  384. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  385. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  386. package/dist/src/qa/profile/QaProfile.js +0 -7
  387. package/dist/src/qa/profile/yaml.d.ts +0 -9
  388. package/dist/src/qa/profile/yaml.js +0 -13
  389. package/dist/src/qa/qa-authorize.d.ts +0 -19
  390. package/dist/src/qa/qa-authorize.js +4 -11
  391. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  392. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  393. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  394. package/dist/src/qa/runtime/PtyManager.js +1 -7
  395. package/dist/src/qa/runtime/changes.d.ts +0 -11
  396. package/dist/src/qa/runtime/changes.js +1 -3
  397. package/dist/src/qa/tools.d.ts +0 -10
  398. package/dist/src/qa/tools.js +0 -12
  399. package/dist/src/qa/types.d.ts +0 -13
  400. package/dist/src/react-runtime.d.ts +2 -21
  401. package/dist/src/react-runtime.js +95 -415
  402. package/dist/src/read-document-doc.d.ts +0 -6
  403. package/dist/src/read-document-doc.js +0 -55
  404. package/dist/src/read-document-docx.d.ts +0 -16
  405. package/dist/src/read-document-docx.js +2 -69
  406. package/dist/src/read-document-text.d.ts +0 -17
  407. package/dist/src/read-document-text.js +0 -22
  408. package/dist/src/read-document-tool.d.ts +0 -31
  409. package/dist/src/read-document-tool.js +0 -30
  410. package/dist/src/read-document.d.ts +0 -49
  411. package/dist/src/read-document.js +1 -67
  412. package/dist/src/read-image.d.ts +0 -32
  413. package/dist/src/read-image.js +0 -33
  414. package/dist/src/remote/cert.d.ts +0 -18
  415. package/dist/src/remote/cert.js +0 -44
  416. package/dist/src/remote/client.d.ts +0 -70
  417. package/dist/src/remote/client.js +1 -116
  418. package/dist/src/remote/command.js +0 -17
  419. package/dist/src/remote/engine-pool.d.ts +0 -152
  420. package/dist/src/remote/engine-pool.js +17 -335
  421. package/dist/src/remote/errors.d.ts +0 -15
  422. package/dist/src/remote/errors.js +0 -7
  423. package/dist/src/remote/network.d.ts +0 -26
  424. package/dist/src/remote/network.js +1 -34
  425. package/dist/src/remote/pairing.d.ts +16 -51
  426. package/dist/src/remote/pairing.js +50 -57
  427. package/dist/src/remote/pem.d.ts +0 -4
  428. package/dist/src/remote/pem.js +0 -4
  429. package/dist/src/remote/roots.d.ts +0 -20
  430. package/dist/src/remote/roots.js +0 -8
  431. package/dist/src/remote/serve.d.ts +0 -47
  432. package/dist/src/remote/serve.js +0 -30
  433. package/dist/src/remote/server.d.ts +0 -14
  434. package/dist/src/remote/server.js +1 -79
  435. package/dist/src/remote/types.d.ts +1 -32
  436. package/dist/src/remote/types.js +0 -10
  437. package/dist/src/run-control.d.ts +0 -7
  438. package/dist/src/run-control.js +0 -7
  439. package/dist/src/run-progress.d.ts +0 -170
  440. package/dist/src/run-progress.js +0 -285
  441. package/dist/src/run-records.d.ts +0 -443
  442. package/dist/src/run-records.js +14 -687
  443. package/dist/src/run-temp.d.ts +12 -0
  444. package/dist/src/run-temp.js +50 -0
  445. package/dist/src/runtime.d.ts +10 -228
  446. package/dist/src/runtime.js +0 -127
  447. package/dist/src/sandbox-child.js +0 -1
  448. package/dist/src/save-lock.d.ts +0 -12
  449. package/dist/src/save-lock.js +0 -28
  450. package/dist/src/screen-selection.d.ts +0 -23
  451. package/dist/src/screen-selection.js +0 -22
  452. package/dist/src/secret-redaction.d.ts +0 -12
  453. package/dist/src/secret-redaction.js +0 -45
  454. package/dist/src/session-changes.d.ts +4 -80
  455. package/dist/src/session-changes.js +25 -130
  456. package/dist/src/session-goal.d.ts +129 -0
  457. package/dist/src/session-goal.js +230 -0
  458. package/dist/src/session-monitor.d.ts +1 -10
  459. package/dist/src/session-monitor.js +2 -39
  460. package/dist/src/session-reaper.d.ts +0 -15
  461. package/dist/src/session-reaper.js +0 -14
  462. package/dist/src/session-skills.d.ts +15 -44
  463. package/dist/src/session-skills.js +75 -60
  464. package/dist/src/session-summary.d.ts +0 -26
  465. package/dist/src/session-summary.js +0 -32
  466. package/dist/src/session-title.d.ts +0 -1
  467. package/dist/src/session-title.js +0 -2
  468. package/dist/src/sessions.d.ts +2 -122
  469. package/dist/src/sessions.js +7 -178
  470. package/dist/src/shell.d.ts +3 -20
  471. package/dist/src/shell.js +8 -72
  472. package/dist/src/side-panel.d.ts +5 -99
  473. package/dist/src/side-panel.js +76 -133
  474. package/dist/src/sign-in-detection.d.ts +0 -39
  475. package/dist/src/sign-in-detection.js +0 -43
  476. package/dist/src/sign-in-offer.d.ts +1 -19
  477. package/dist/src/sign-in-offer.js +0 -13
  478. package/dist/src/skill-commands.d.ts +0 -1
  479. package/dist/src/skill-commands.js +1 -4
  480. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  481. package/dist/src/skills/bundled/provenance.json +1 -1
  482. package/dist/src/skills/invocable-skills.d.ts +0 -18
  483. package/dist/src/skills/invocable-skills.js +0 -17
  484. package/dist/src/skills/project-skills.d.ts +0 -1
  485. package/dist/src/skills/project-skills.js +0 -3
  486. package/dist/src/skills/prompt-skills.js +0 -14
  487. package/dist/src/skills/runtime-skills.d.ts +0 -13
  488. package/dist/src/skills/runtime-skills.js +0 -37
  489. package/dist/src/stall-recovery.d.ts +0 -25
  490. package/dist/src/stall-recovery.js +0 -38
  491. package/dist/src/stray-files.d.ts +0 -9
  492. package/dist/src/stray-files.js +0 -16
  493. package/dist/src/structured-step.d.ts +0 -22
  494. package/dist/src/structured-step.js +0 -22
  495. package/dist/src/subagent-run.d.ts +0 -163
  496. package/dist/src/subagent-run.js +4 -373
  497. package/dist/src/subagent-tree.d.ts +32 -0
  498. package/dist/src/subagent-tree.js +128 -0
  499. package/dist/src/telemetry/aggregate.d.ts +0 -37
  500. package/dist/src/telemetry/aggregate.js +0 -40
  501. package/dist/src/telemetry/capture-core.d.ts +0 -87
  502. package/dist/src/telemetry/capture-core.js +0 -67
  503. package/dist/src/telemetry/capture.d.ts +0 -1
  504. package/dist/src/telemetry/capture.js +0 -3
  505. package/dist/src/telemetry/classify.d.ts +0 -58
  506. package/dist/src/telemetry/classify.js +0 -60
  507. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  508. package/dist/src/telemetry/emitter.d.ts +0 -30
  509. package/dist/src/telemetry/emitter.js +1 -62
  510. package/dist/src/telemetry/gate.d.ts +0 -29
  511. package/dist/src/telemetry/gate.js +0 -22
  512. package/dist/src/telemetry/identity.d.ts +0 -13
  513. package/dist/src/telemetry/identity.js +0 -29
  514. package/dist/src/telemetry/outbox.d.ts +0 -64
  515. package/dist/src/telemetry/outbox.js +1 -108
  516. package/dist/src/telemetry/schema.d.ts +1 -49
  517. package/dist/src/telemetry/schema.js +1 -82
  518. package/dist/src/telemetry/state.d.ts +0 -53
  519. package/dist/src/telemetry/state.js +0 -64
  520. package/dist/src/telemetry/surface.d.ts +0 -31
  521. package/dist/src/telemetry/surface.js +1 -39
  522. package/dist/src/telemetry/uploader.d.ts +0 -11
  523. package/dist/src/telemetry/uploader.js +0 -46
  524. package/dist/src/telemetry/uploads.d.ts +0 -11
  525. package/dist/src/telemetry/uploads.js +0 -11
  526. package/dist/src/telemetry/version.d.ts +0 -4
  527. package/dist/src/telemetry/version.js +0 -14
  528. package/dist/src/telemetry/workspace.d.ts +0 -7
  529. package/dist/src/telemetry/workspace.js +1 -22
  530. package/dist/src/terminal-ui.d.ts +14 -523
  531. package/dist/src/terminal-ui.js +74 -876
  532. package/dist/src/test-edit-guard.d.ts +74 -0
  533. package/dist/src/test-edit-guard.js +269 -0
  534. package/dist/src/text.d.ts +0 -1
  535. package/dist/src/text.js +0 -1
  536. package/dist/src/time-limit.d.ts +0 -36
  537. package/dist/src/time-limit.js +0 -37
  538. package/dist/src/timers.d.ts +0 -161
  539. package/dist/src/timers.js +0 -126
  540. package/dist/src/todos.d.ts +0 -1
  541. package/dist/src/todos.js +0 -3
  542. package/dist/src/token-rate.d.ts +0 -94
  543. package/dist/src/token-rate.js +0 -154
  544. package/dist/src/tool-activity.d.ts +0 -6
  545. package/dist/src/tool-activity.js +0 -7
  546. package/dist/src/tool-availability.d.ts +0 -13
  547. package/dist/src/tool-availability.js +1 -14
  548. package/dist/src/tool-call-clock.d.ts +1 -4
  549. package/dist/src/tool-call-clock.js +0 -13
  550. package/dist/src/tool-catalog.d.ts +0 -11
  551. package/dist/src/tool-catalog.js +0 -23
  552. package/dist/src/tool-dependencies.d.ts +0 -5
  553. package/dist/src/tool-dependencies.js +0 -4
  554. package/dist/src/tool-diff-stats.d.ts +0 -23
  555. package/dist/src/tool-diff-stats.js +0 -49
  556. package/dist/src/tool-errors.d.ts +9 -7
  557. package/dist/src/tool-errors.js +13 -6
  558. package/dist/src/tool-failure-tracker.d.ts +3 -11
  559. package/dist/src/tool-failure-tracker.js +19 -27
  560. package/dist/src/tool-names.d.ts +0 -16
  561. package/dist/src/tool-names.js +0 -12
  562. package/dist/src/tool-profile.d.ts +6 -0
  563. package/dist/src/tool-profile.js +23 -0
  564. package/dist/src/tool-result-filter.d.ts +0 -19
  565. package/dist/src/tool-result-filter.js +1 -66
  566. package/dist/src/tool-schema-compatibility.d.ts +0 -6
  567. package/dist/src/tool-schema-compatibility.js +0 -9
  568. package/dist/src/tools.d.ts +0 -4
  569. package/dist/src/tools.js +11 -114
  570. package/dist/src/trajectory.d.ts +0 -13
  571. package/dist/src/trajectory.js +23 -79
  572. package/dist/src/transcript.d.ts +0 -41
  573. package/dist/src/transcript.js +2 -60
  574. package/dist/src/types.d.ts +1 -168
  575. package/dist/src/untracked-file-removal.js +0 -20
  576. package/dist/src/update-check.d.ts +0 -14
  577. package/dist/src/update-check.js +1 -15
  578. package/dist/src/update.d.ts +0 -35
  579. package/dist/src/update.js +0 -100
  580. package/dist/src/usage-analytics.d.ts +17 -17
  581. package/dist/src/usage-analytics.js +168 -209
  582. package/dist/src/web-search.d.ts +0 -23
  583. package/dist/src/web-search.js +1 -27
  584. package/dist/src/widgets.d.ts +0 -25
  585. package/dist/src/widgets.js +0 -24
  586. package/dist/src/workspace-facts.d.ts +0 -12
  587. package/dist/src/workspace-facts.js +1 -18
  588. package/dist/src/workspace-git-metadata.d.ts +0 -16
  589. package/dist/src/workspace-git-metadata.js +0 -21
  590. package/dist/src/workspace-instructions.d.ts +3 -15
  591. package/dist/src/workspace-instructions.js +6 -19
  592. package/package.json +2 -2
@@ -9,52 +9,14 @@ import { providerAuthHeaders } from './anthropic-credentials.js';
9
9
  import { generateEngineResponse, isEngineContextOverflow } from './provider-engine.js';
10
10
  import { estimateStreamedTokens } from './token-rate.js';
11
11
  export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
12
- /** Every provider type a configuration may name. */
13
12
  export const PROVIDER_TYPES = ['openai-compatible', 'anthropic', 'codex', 'claude', 'opencode-go', 'grok', 'opencode'];
14
- /**
15
- * Types that run through a vendor CLI's own sign-in on this machine instead of a key Andorra holds.
16
- *
17
- * They carry no credential fields, use a fixed marker base URL, and bound each request themselves,
18
- * so configuration rejects key and timeout overrides on them rather than silently ignoring them.
19
- */
20
13
  export const SIGN_IN_PROVIDER_TYPES = ['codex', 'claude', 'grok', 'opencode'];
21
14
  export function isSignInProviderType(type) {
22
15
  return SIGN_IN_PROVIDER_TYPES.includes(type);
23
16
  }
24
- /** The product name messages use for a sign-in type. */
25
17
  const SIGN_IN_PRODUCT = { codex: 'Codex', claude: 'Claude', grok: 'Grok', opencode: 'OpenCode' };
26
- /**
27
- * Inactivity bound for inference, and wall-clock bound for other HTTP requests,
28
- * in milliseconds, when a provider does not configure its own.
29
- *
30
- * Its job is to end a request that will never be answered — a wedged server, a black-holed
31
- * connection — never to cap a slow model. One inference call is bounded by the tokens it must
32
- * decode, and the request asks for thousands of them, so a bound short enough to fire on a
33
- * healthy self-hosted endpoint converts completed work into `infrastructure_error`. Inference
34
- * refreshes this timer whenever response bytes arrive; active decoding may run longer. A
35
- * provider that needs longer silent intervals raises it, and
36
- * `0` removes it entirely for a caller that is bounded some other way.
37
- */
38
18
  export const DEFAULT_REQUEST_TIMEOUT_MS = 10 * 60_000;
39
- /**
40
- * The largest per-request bound a provider may configure: one day.
41
- *
42
- * Node's timers accept only a signed 32-bit millisecond delay. A larger value is reduced to a
43
- * 1 ms timer with a `TimeoutOverflowWarning` — and above `2 ** 32 - 1` `AbortSignal.timeout`
44
- * throws — so a bound meant to be generous would instead fail every request almost immediately.
45
- * Configuration and the exported adapter constructor enforce this same ceiling: a consumer that
46
- * builds an adapter directly must not be able to arm that timer.
47
- */
48
19
  export const MAX_REQUEST_TIMEOUT_MS = 86_400_000;
49
- /**
50
- * The single validation of a configured request bound, shared by the configuration loader and
51
- * {@link createAdapter} so the two can never disagree about what a provider will honour.
52
- *
53
- * It rejects the whole override, not just an out-of-range value: a Codex provider applies its own
54
- * fixed bound, so accepting `requestTimeoutMs` here would silently ignore what the caller asked
55
- * for.
56
- * @param provider - the provider whose bound is being checked.
57
- */
58
20
  export function assertRequestTimeout(provider) {
59
21
  const value = provider.requestTimeoutMs;
60
22
  if (value === undefined)
@@ -65,16 +27,6 @@ export function assertRequestTimeout(provider) {
65
27
  throw new Error(`Provider requestTimeoutMs must be 0 (no timeout) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
66
28
  }
67
29
  }
68
- /**
69
- * The single validation of a configured inference inactivity bound, shared by the configuration
70
- * loader and {@link createAdapter} so the two can never disagree about what a provider honours.
71
- *
72
- * `streamIdleTimeoutMs` separates the bound on a silent inference exchange from
73
- * `requestTimeoutMs`: a provider that removed the request bound to tolerate a slow prefill can
74
- * still end a stream that stopped delivering bytes. Like the request bound it accepts `0` to
75
- * remove the bound; Codex owns its fixed bound, so the override is rejected rather than ignored.
76
- * @param provider - the provider whose inactivity bound is being checked.
77
- */
78
30
  export function assertStreamIdleTimeout(provider) {
79
31
  const value = provider.streamIdleTimeoutMs;
80
32
  if (value === undefined)
@@ -85,38 +37,13 @@ export function assertStreamIdleTimeout(provider) {
85
37
  throw new Error(`Provider streamIdleTimeoutMs must be 0 (no bound) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
86
38
  }
87
39
  }
88
- /**
89
- * Bound for model listing, which is a discovery GET rather than inference.
90
- *
91
- * A listing is never worth the inference bound: an endpoint that accepts the connection and never
92
- * answers must not leave the model screen loading for minutes, and a provider that removed its
93
- * inference bound with `requestTimeoutMs: 0` must still not make discovery unbounded. A caller
94
- * may pass a shorter bound of its own; this is a ceiling, not a floor.
95
- *
96
- * Callers pass their *cancellation* signal only. A deadline the caller arms here would fire before
97
- * this one, and a caller's signal aborting is reported as a cancellation — so wrapping this call
98
- * in `AbortSignal.timeout` would report a stalled endpoint as something the user did.
99
- */
100
40
  export const MODEL_LISTING_TIMEOUT_MS = 30_000;
101
- /** How a deadline reads in the phrase that reports it hitting: "15 seconds", "1 second", "40 milliseconds". */
102
41
  export function deadlinePhrase(ms) {
103
42
  if (ms % 1000 !== 0)
104
43
  return `${ms} milliseconds`;
105
44
  const seconds = ms / 1000;
106
45
  return `${seconds} second${seconds === 1 ? '' : 's'}`;
107
46
  }
108
- /**
109
- * The name a person reads for a provider in a list or picker.
110
- *
111
- * An explicit {@link ProviderConfig.name} wins everywhere: the id is an immutable identity, so the
112
- * editable name is the only way a provider can be renamed, and preferring it here is what makes a
113
- * rename reach records that still carry the old identity. Codex entries are otherwise the one case
114
- * where the id is not the name: several ChatGPT accounts can be configured at once, and the label
115
- * carries the account's email localpart so the rows are told apart. A configuration holding a
116
- * single Codex provider keeps the plain `codex` name, and a provider whose sign-in never reported
117
- * an email falls back to its id. The selection value stays the provider id everywhere; only the
118
- * text changes.
119
- */
120
47
  export function providerLabel(provider, providers) {
121
48
  if (provider.name?.trim())
122
49
  return provider.name.trim();
@@ -127,21 +54,8 @@ export function providerLabel(provider, providers) {
127
54
  const local = provider.codexEmail?.split('@')[0] || provider.id;
128
55
  return `codex - ${local.length > 32 ? `${local.slice(0, 31)}…` : local}`;
129
56
  }
130
- /** The longest account-slot key validation accepts; the key names a directory under the config home. */
131
57
  export const MAX_CODEX_ACCOUNT_KEY_LENGTH = 100;
132
- /** The longest display name validation accepts; the name is text a list row or picker renders. */
133
58
  export const MAX_PROVIDER_NAME_LENGTH = 64;
134
- /**
135
- * An account-slot key no configured provider binds yet, based on the entry's identifier.
136
- *
137
- * The key becomes a directory name, so it is compared case-insensitively, exactly as validation
138
- * compares it: `work-fast` may already be bound to the key `work`, and a new provider whose own id
139
- * is `work` must not take that account over. The first free `id`, `id-2`, `id-3`… is returned.
140
- *
141
- * A provider id may be longer than a slot key validation accepts, and appending a collision suffix
142
- * to a key already at the limit would overrun it, so the base is trimmed to leave the suffix room:
143
- * allocating an account must never produce a key the configuration it is written into rejects.
144
- */
145
59
  export function freeCodexAccountSlot(base, providers) {
146
60
  const taken = new Set(providers.flatMap(provider => provider.codexAccount === undefined ? [] : [provider.codexAccount.toLowerCase()]));
147
61
  const key = (suffix) => `${base.slice(0, MAX_CODEX_ACCOUNT_KEY_LENGTH - suffix.length)}${suffix}`;
@@ -150,28 +64,9 @@ export function freeCodexAccountSlot(base, providers) {
150
64
  slot = key(`-${suffix}`);
151
65
  return slot;
152
66
  }
153
- /**
154
- * A free slot key for an entry a draft is adding, reserving the saved configuration as well.
155
- *
156
- * A draft may remove a slot-bearing entry and add a new Codex provider in the same save. The
157
- * removed home outlives the draft until its retirement completes, so a key computed against the
158
- * draft alone can be handed to the newcomer: that entry would sign in as the removed account, and
159
- * the retirement would find the key bound and skip it. Reserving both sets closes that path for
160
- * every draft editor, since the engine only allocates for writes that arrive without a key.
161
- */
162
67
  export function freeDraftCodexAccountSlot(base, draft, saved) {
163
68
  return freeCodexAccountSlot(base, [...draft, ...saved]);
164
69
  }
165
- /**
166
- * Give every Codex entry that is a later account binding its own slot key.
167
- *
168
- * An entry binds an account when it is Codex now but was not Codex before — a new entry, or another
169
- * type converted. A configuration that held no Codex provider keeps its inherited sign-in on the
170
- * first Codex entry this write leaves; every other new binding gets a free key. An entry that was
171
- * already Codex keeps whatever binding (or lack of one) it had: a save is not a migration. Allocation
172
- * happens here rather than in each client so no two clients can disagree about which keys are taken,
173
- * and a bulk write orders the entries exactly as adding them one at a time would.
174
- */
175
70
  export function allocateCodexAccountSlots(stored, next) {
176
71
  const storedHadCodex = stored.some(item => item.type === 'codex');
177
72
  const firstCodexId = next.find(item => item.type === 'codex')?.id;
@@ -186,29 +81,15 @@ export function allocateCodexAccountSlots(stored, next) {
186
81
  result.push(provider);
187
82
  continue;
188
83
  }
189
- // The key is chosen against everything this write leaves configured: entries already placed and
190
- // entries still to come, and `freeCodexAccountSlot` reads every binding among them. Bindings the
191
- // write removes are reserved too, because their homes outlive the write until retirement
192
- // completes: reusing a removed key here would hand the new entry an account it never signed in
193
- // to, and the retirement would then find the key bound and skip it.
194
84
  result.push({ ...provider, codexAccount: freeCodexAccountSlot(provider.id, [...result, ...next.slice(index + 1), ...stored]) });
195
85
  }
196
86
  return result;
197
87
  }
198
- /** The models a provider is configured to offer: the saved list, or the active model alone. */
199
88
  export function providerModels(provider) {
200
89
  if (provider.models !== undefined)
201
90
  return provider.models.filter(model => model.trim());
202
91
  return provider.model.trim() ? [provider.model] : [];
203
92
  }
204
- /**
205
- * The context window saved for one model, if the provider has one.
206
- *
207
- * `Object.hasOwn` rather than a plain lookup: a model id is user input, so `constructor` or
208
- * `toString` must read as "no saved window" instead of an inherited member. Values are required to
209
- * be positive safe integers because a hand-edited configuration can reach this before validation
210
- * runs in an adapter built directly.
211
- */
212
93
  export function configuredContextWindow(provider, model) {
213
94
  const id = model ?? provider.model;
214
95
  if (!provider.modelContextWindows || !Object.hasOwn(provider.modelContextWindows, id))
@@ -216,15 +97,6 @@ export function configuredContextWindow(provider, model) {
216
97
  const window = provider.modelContextWindows[id];
217
98
  return Number.isSafeInteger(window) && window > 0 ? window : undefined;
218
99
  }
219
- /**
220
- * Point a provider's own window at one model's saved limit.
221
- *
222
- * A model switch must not keep the previous model's limit, and a model with no saved entry must
223
- * not inherit one: the saved window for the target model is applied when the map holds it, and the
224
- * provider-level value is dropped when it does not. `/status` and the run budget read
225
- * `contextWindow` directly, so a switch that only deleted it would report an unknown limit for a
226
- * model whose limit the provider already knows.
227
- */
228
100
  export function applyModelContextWindow(provider, model) {
229
101
  const saved = configuredContextWindow(provider, model);
230
102
  if (saved !== undefined)
@@ -232,21 +104,9 @@ export function applyModelContextWindow(provider, model) {
232
104
  else
233
105
  delete provider.contextWindow;
234
106
  }
235
- /**
236
- * Raw provider secrets: stored API keys plus the current values of their named environment
237
- * variables. The trajectory's own credential-name heuristic cannot know an arbitrary
238
- * `apiKeyEnv` name, so every place providers (re)register secrets uses this helper — initial
239
- * config load and mid-session provider edits alike.
240
- */
241
107
  export function providerSecrets(providers, env = process.env) {
242
108
  return providers.flatMap(provider => [provider.apiKey, provider.apiKeyEnv ? env[provider.apiKeyEnv] : undefined].filter((key) => !!key));
243
109
  }
244
- /**
245
- * Record one model as configured for the provider, keeping the saved list consistent with it.
246
- *
247
- * The list is materialized only once it holds more than the active model, or once it exists at all:
248
- * a provider edited without ever touching its model list keeps the configuration shape it had.
249
- */
250
110
  export function recordProviderModel(provider, model) {
251
111
  const list = providerModels(provider);
252
112
  if (!list.includes(model))
@@ -254,7 +114,6 @@ export function recordProviderModel(provider, model) {
254
114
  if (list.length > 1 || provider.models !== undefined)
255
115
  provider.models = list;
256
116
  }
257
- /** Validate credentials without including their contents in errors. */
258
117
  export function assertProviderCredentials(provider) {
259
118
  if (provider.anthropicAuth !== undefined && (provider.type !== 'anthropic' || provider.anthropicAuth !== 'console')) {
260
119
  throw new Error('anthropicAuth is an Anthropic-only setting whose only value is console.');
@@ -278,7 +137,6 @@ export function assertProviderCredentials(provider) {
278
137
  throw new Error('Invalid API key environment variable name.');
279
138
  }
280
139
  }
281
- /** Shared credential precedence for inference and model discovery. */
282
140
  export function resolveProviderApiKey(provider) {
283
141
  assertProviderCredentials(provider);
284
142
  if (provider.apiKey !== undefined)
@@ -305,11 +163,6 @@ const MALFORMED_STREAM_RETRY_DELAYS_MS = [1_000, 3_000, 10_000];
305
163
  const MAX_AUTOMATIC_RETRY_AFTER_MS = REQUEST_RETRY_DELAYS_MS.at(-1);
306
164
  export class ProviderRequestError extends Error {
307
165
  contextOverflow;
308
- /**
309
- * Set when this request was classified as exceeding the context window. It travels structured so
310
- * telemetry reports a limit without re-deriving one from an error message, and so a provider
311
- * failure rate never absorbs an input that was simply too large.
312
- */
313
166
  constructor(message, contextOverflow = false) {
314
167
  super(message);
315
168
  this.contextOverflow = contextOverflow;
@@ -326,36 +179,16 @@ class RetryableProviderError extends ProviderRequestError {
326
179
  this.name = 'Error';
327
180
  }
328
181
  }
329
- /** A malformed SSE completion is safe to replay because no tool from that response has executed. */
330
182
  class MalformedStreamProviderError extends RetryableProviderError {
331
183
  constructor() { super('Provider returned a malformed response.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
332
184
  }
333
- /**
334
- * How much blank tool-call output a stream may carry in a row before it is abandoned: whitespace
335
- * characters in a call's arguments, plus one for every tool-call fragment that adds nothing.
336
- *
337
- * A model sometimes opens a tool call and then generates whitespace until the provider's output
338
- * cap stops it. On DeepSeek V4.1 Flash that was 131,072 completion tokens over eight minutes for a
339
- * call whose arguments arrived empty, about once in three thousand requests, and it was 16% of
340
- * all output in a 90-task SWE-bench run. Real arguments never hold this much consecutive
341
- * whitespace: line breaks inside a JSON string are escaped, and indentation between tokens is a
342
- * few characters. The stream is cut here and the request replayed, which is safe because no tool
343
- * from the abandoned response ran.
344
- */
345
185
  export const BLANK_TOOL_CALL_LIMIT = 4096;
346
- /** A stream abandoned because a tool call kept generating blank output; replayed like a malformed one. */
347
186
  class BlankToolCallProviderError extends RetryableProviderError {
348
187
  constructor() { super('Provider streamed a tool call that kept generating blank output.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
349
188
  }
350
- /**
351
- * Counts consecutive blank tool-call output across a stream and throws once it passes
352
- * {@link BLANK_TOOL_CALL_LIMIT}. Anything the model visibly produces (argument text, a tool
353
- * name, answer text, reasoning) ends the run of blanks.
354
- */
355
189
  export function createBlankToolCallGuard(limit = BLANK_TOOL_CALL_LIMIT) {
356
190
  let blank = 0;
357
191
  return {
358
- /** One tool-call fragment's text: its name and argument pieces joined. */
359
192
  fragment(text) {
360
193
  if (/\S/.test(text)) {
361
194
  blank = 0;
@@ -365,11 +198,9 @@ export function createBlankToolCallGuard(limit = BLANK_TOOL_CALL_LIMIT) {
365
198
  if (blank > limit)
366
199
  throw new BlankToolCallProviderError();
367
200
  },
368
- /** The model produced something other than a tool-call fragment. */
369
201
  progress() { blank = 0; },
370
202
  };
371
203
  }
372
- /** A completed HTTP exchange the provider refused outright; `status` drives compatibility fallbacks. */
373
204
  class HttpProviderError extends ProviderRequestError {
374
205
  status;
375
206
  constructor(message, status) {
@@ -393,21 +224,12 @@ function permanentConnectionFailure(error) {
393
224
  || /^(?:unexpected redirect|redirect count exceeded|bad port|unknown scheme|invalid redirect|URL scheme must be)/i.test(failure.message ?? '')
394
225
  || (failure.cause !== error && permanentConnectionFailure(failure.cause));
395
226
  }
396
- /**
397
- * The transport code behind a failed fetch, preferring the cause's over the wrapper's.
398
- *
399
- * Only the code is surfaced. An exception's message is free text that has been seen to embed
400
- * credentials, while the code is the part that tells an operator whether this is DNS, TLS, a
401
- * refused port or a bad certificate anyway.
402
- */
403
227
  function connectionFailureDetail(error) {
404
228
  if (!error || typeof error !== 'object')
405
229
  return undefined;
406
230
  const failure = error;
407
231
  const cause = failure.cause && typeof failure.cause === 'object' ? failure.cause : undefined;
408
232
  const code = typeof cause?.code === 'string' && cause.code ? cause.code : typeof failure.code === 'string' && failure.code ? failure.code : undefined;
409
- // Transport codes are errno-style (ENOTFOUND, ECONNRESET, ERR_TLS_...). Anything else is an
410
- // arbitrary string some library attached, and echoing it would expose whatever it put there.
411
233
  return code && /^[A-Z][A-Z0-9_]*$/.test(code) ? code : undefined;
412
234
  }
413
235
  function cancelled() { throw new Error('Provider request cancelled.'); }
@@ -444,14 +266,6 @@ function record(value) {
444
266
  return malformed();
445
267
  return value;
446
268
  }
447
- /**
448
- * The provider's own explanation of a rejected request, from its bounded error body.
449
- *
450
- * Envelopes differ: OpenAI and DeepSeek nest `{error:{message}}`, Anthropic adds its own
451
- * `{type,error}`, and vLLM's proxy puts a JSON string in `detail`. Only message-bearing fields
452
- * are read, because the rest of an error body can echo request content or credentials and belongs
453
- * in the provider's logs, not in the run record the person keeps.
454
- */
455
269
  function providerErrorDetail(value, depth = 0) {
456
270
  if (!value || typeof value !== 'object' || Array.isArray(value) || depth > 2)
457
271
  return undefined;
@@ -472,8 +286,6 @@ function providerErrorDetail(value, depth = 0) {
472
286
  const detail = providerErrorDetail(safeJson(trimmed), depth + 1);
473
287
  if (detail)
474
288
  return detail;
475
- // A structured payload is subject to the same allowlist as a structured body: without an
476
- // approved message field inside it, the serialized text stays in the provider's logs.
477
289
  continue;
478
290
  }
479
291
  return boundedProviderDetail(trimmed);
@@ -494,7 +306,6 @@ function boundedProviderDetail(text) {
494
306
  return undefined;
495
307
  return collapsed.length > 400 ? `${collapsed.slice(0, 397)}...` : collapsed;
496
308
  }
497
- /** Masks the configured credential, which providers have been seen to echo back in error bodies. */
498
309
  function redactCredential(text, key) {
499
310
  return key ? text.split(key).join('[redacted]') : text;
500
311
  }
@@ -511,15 +322,6 @@ function usage(value, anthropic) {
511
322
  const details = data.prompt_tokens_details && typeof data.prompt_tokens_details === 'object' && !Array.isArray(data.prompt_tokens_details)
512
323
  ? data.prompt_tokens_details : {};
513
324
  const input = tokenCount(anthropic ? data.input_tokens : data.prompt_tokens);
514
- // Anthropic omits cache counts when caching is unused. Missing base usage is
515
- // unavailable, whereas an explicitly reported zero is a valid measurement.
516
- // OpenAI-compatible cache reads follow the vendored parser's precedence:
517
- // prompt_tokens_details.cached_tokens (OpenAI/vLLM), prompt_cache_hit_tokens
518
- // (DeepSeek) or top-level cached_tokens (Kimi). prompt_tokens is already
519
- // inclusive of cache traffic, so inputTokens needs no adjustment.
520
- // Reported means the field was there: an explicit zero is a measurement, and dropping it would make
521
- // "we measured nothing cached" indistinguishable from "caching was never mentioned". Surfaces that
522
- // show cache figures key on that presence, so it has to survive this mapping.
523
325
  const created = anthropic ? tokenCount(data.cache_creation_input_tokens) : tokenCount(details.cache_write_tokens);
524
326
  const read = anthropic ? tokenCount(data.cache_read_input_tokens) : tokenCount(details.cached_tokens ?? data.prompt_cache_hit_tokens ?? data.cached_tokens);
525
327
  const inputTokens = anthropic
@@ -544,26 +346,16 @@ function argumentsObject(value) {
544
346
  }
545
347
  }
546
348
  function checkCalls(calls, completionAdvertised) {
547
- // Names are authorized by the executor so unadvertised calls become repairable observations.
548
349
  const ids = new Set();
549
350
  for (const call of calls) {
550
351
  if (ids.has(call.id))
551
352
  malformed();
552
353
  ids.add(call.id);
553
- // Completion is control data validated by the bounded runtime repair loop.
554
- // Executable tools retain strict adapter validation before any side effects.
555
354
  if (call.name !== COMPLETION_TOOL || !completionAdvertised)
556
355
  argumentsObject(call.arguments);
557
356
  }
558
357
  return calls;
559
358
  }
560
- /**
561
- * Validate one whole-body chat completion into a {@link ModelResponse}.
562
- *
563
- * Shared by the unstreamed request path and by the streaming path's whole-body fallback,
564
- * so a server that answers `stream: true` with plain JSON is held to exactly the checks a
565
- * server that never streamed must pass.
566
- */
567
359
  function wholeBodyCompletion(data, requests, completionAdvertised) {
568
360
  if (!Array.isArray(data.choices) || data.choices.length !== 1)
569
361
  return malformed();
@@ -580,13 +372,9 @@ function wholeBodyCompletion(data, requests, completionAdvertised) {
580
372
  .find((value) => typeof value === 'string' && value.length > 0)
581
373
  ?? (typeof message.reasoning_content === 'string' ? message.reasoning_content : undefined);
582
374
  const reasoning = reasoningText !== undefined ? { reasoningContent: reasoningText } : {};
583
- // Refusals are valid model output, even when content is null. Preserve the
584
- // text for normal bounded completion handling instead of a transport error.
585
375
  const text = [message.content, message.refusal].filter((value) => typeof value === 'string' && value.length > 0).join('\n');
586
376
  if (message.tool_calls != null && !Array.isArray(message.tool_calls))
587
377
  return malformed();
588
- // Truncated function arguments may not be JSON (or even contain a name yet).
589
- // Discard the entire batch and let the runtime apply its bounded repair policy.
590
378
  if (choice.finish_reason === 'length' || choice.finish_reason === 'content_filter') {
591
379
  return { text, toolCalls: [], usage: { ...usage(data.usage, false), requests }, stopReason: choice.finish_reason };
592
380
  }
@@ -604,33 +392,10 @@ function wholeBodyCompletion(data, requests, completionAdvertised) {
604
392
  return malformed();
605
393
  return { text, toolCalls: checkCalls(calls, completionAdvertised), usage: { ...usage(data.usage, false), requests }, stopReason: nonempty(choice.finish_reason), ...reasoning };
606
394
  }
607
- /**
608
- * How long after the first generated fragment later fragments still belong to the opening burst.
609
- *
610
- * A server that streams token by token puts a few tokens inside this span; a relay or tool-call
611
- * parser that holds output back and releases it at once puts hundreds there.
612
- */
613
395
  const DECODE_HEAD_BURST_MS = 50;
614
- /**
615
- * Measure a streamed response's decode time from when its fragments arrive.
616
- *
617
- * Whatever arrives in the opening burst was generated before the first fragment was seen, so the
618
- * time it took is not observable: it is hidden in the wait that also holds prompt processing.
619
- * Only output that arrives after the burst has a measured pace - its share of the stream over the
620
- * span from the end of the burst to the last fragment. The reading is that pace applied to the
621
- * whole response: the span scaled up by the share of the output that arrived inside it. A stream
622
- * delivered fragment by fragment loses one fragment and scales by almost nothing. A stream whose
623
- * output mostly landed in the opening burst - a short answer released in one or two clumps by a
624
- * buffering proxy - has no pace worth extrapolating, and claims no window rather than dividing
625
- * every token by the few milliseconds the clump took to arrive.
626
- *
627
- * Fragments are weighed by {@link estimateStreamedTokens}; only the proportions matter, since
628
- * the provider's own token count is what gets divided by the result.
629
- */
630
396
  export function createDecodeWindow(now = Date.now) {
631
397
  let firstAt, headEndAt = 0, lastAt = 0, head = 0, paced = 0;
632
398
  return {
633
- /** Record a generated fragment's arrival; `text` is what it carried. */
634
399
  stamp(text) {
635
400
  const at = now(), weight = estimateStreamedTokens(text);
636
401
  if (firstAt === undefined) {
@@ -645,7 +410,6 @@ export function createDecodeWindow(now = Date.now) {
645
410
  paced += weight;
646
411
  lastAt = at;
647
412
  },
648
- /** Decode time attributable to the whole response, or undefined when it was not observable. */
649
413
  measure() {
650
414
  if (firstAt === undefined || lastAt <= headEndAt || paced <= 0 || paced < head)
651
415
  return undefined;
@@ -653,14 +417,6 @@ export function createDecodeWindow(now = Date.now) {
653
417
  },
654
418
  };
655
419
  }
656
- /**
657
- * Assemble a streamed chat completion, validating it to the same rules as the whole-body path.
658
- *
659
- * Every streamed fragment type is checked as it arrives, so a malformed stream fails at the
660
- * offending chunk rather than after silently accumulating garbage. Tool-call fragments are
661
- * keyed by their `index` and concatenated in arrival order, which is how every
662
- * OpenAI-compatible server splits them.
663
- */
664
420
  function createStreamAccumulator(onReasoning, now = Date.now) {
665
421
  let content = '', refusal, reasoning = '', finishReason, chunkUsage;
666
422
  let sawChoice = false, sawText = false;
@@ -674,16 +430,10 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
674
430
  return malformed();
675
431
  return value;
676
432
  };
677
- // The decode window opens at the first generated fragment and closes at the last: prompt
678
- // processing ends where the first stamp falls, and everything between requests (tool runs,
679
- // retries, the usage tail) is outside the pair. A stream that answers in a single fragment or
680
- // a single burst gives no pace, and no window is claimed (see createDecodeWindow).
681
433
  const stampOutput = (text) => decode.stamp(text);
682
434
  const decodeWindow = () => decode.measure();
683
435
  return {
684
- /** Whether the stream delivered a choice with a finish reason, i.e. truly completed. */
685
436
  get completed() { return sawChoice && finishReason !== undefined; },
686
- /** The measured decode window, or undefined when the stream never gave one. */
687
437
  get decodeMs() { return decodeWindow(); },
688
438
  event(data) {
689
439
  if (data === '[DONE]')
@@ -703,7 +453,6 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
703
453
  }
704
454
  const choices = chunk.choices;
705
455
  if (choices === undefined) {
706
- // The usage-only final chunk carries no choices; a chunk without either is malformed.
707
456
  if (chunkUsage === undefined)
708
457
  return malformed();
709
458
  return;
@@ -724,20 +473,12 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
724
473
  reasoning += reasoningDelta;
725
474
  onReasoning(reasoningDelta);
726
475
  }
727
- // The decode window counts every representation the production parser streams as thinking:
728
- // openai-completions.ts takes the first non-empty of reasoning_content, reasoning, and
729
- // reasoning_text, so a model that answers its reasoning through the other fields is still
730
- // generating, and its window must open at that first fragment rather than at the answer.
731
476
  const thinking = reasoningDelta || text(delta.reasoning) || text(delta.reasoning_text);
732
477
  if (thinking) {
733
478
  stampOutput(thinking);
734
479
  blankCalls.progress();
735
480
  }
736
481
  const contentDelta = text(delta.content);
737
- // An empty content string still records the field's presence: the whole-body path
738
- // distinguishes `content: ""` from `null`, and the streamed answer must keep that
739
- // distinction so an empty completion reaches the runtime's bounded repair loop
740
- // instead of failing as a malformed response.
741
482
  if (contentDelta !== null) {
742
483
  sawText = true;
743
484
  if (contentDelta) {
@@ -794,12 +535,8 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
794
535
  finish(requests, completionAdvertised) {
795
536
  if (!sawChoice)
796
537
  return malformed();
797
- // Refusals are valid model output, even when content is null. Preserve the
798
- // text for normal bounded completion handling instead of a transport error.
799
538
  const body = [content, refusal].filter((value) => typeof value === 'string' && value.length > 0).join('\n');
800
539
  const measured = decodeWindow();
801
- // Truncated function arguments may not be JSON (or even contain a name yet).
802
- // Discard the entire batch and let the runtime apply its bounded repair policy.
803
540
  if (finishReason === 'length' || finishReason === 'content_filter') {
804
541
  return { text: body, toolCalls: [], usage: { ...usage(chunkUsage, false), requests, ...(measured === undefined ? {} : { decodeMs: measured }) }, stopReason: finishReason };
805
542
  }
@@ -814,7 +551,6 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
814
551
  },
815
552
  };
816
553
  }
817
- /** Validate original Anthropic JSON fragments before upstream's display-oriented JSON salvage. */
818
554
  function createAnthropicStreamAccumulator(now = Date.now) {
819
555
  const blocks = new Map();
820
556
  let started = false, stopped = false, finishReason;
@@ -827,12 +563,9 @@ function createAnthropicStreamAccumulator(now = Date.now) {
827
563
  return malformed();
828
564
  return block;
829
565
  };
830
- // Same decode-window rule as the OpenAI-compatible accumulator: the first generated fragment
831
- // opens the window and the last closes it, so prompt processing and inter-request time stay out.
832
566
  const stampOutput = (text) => decode.stamp(text);
833
567
  const decodeWindow = () => decode.measure();
834
568
  return {
835
- /** The measured decode window, or undefined when the stream never gave one. */
836
569
  get decodeMs() { return decodeWindow(); },
837
570
  event(data) {
838
571
  let parsed;
@@ -889,9 +622,6 @@ function createAnthropicStreamAccumulator(now = Date.now) {
889
622
  const piece = delta[delta.type === 'thinking_delta' ? 'thinking' : 'signature'];
890
623
  if (typeof piece !== 'string')
891
624
  return malformed();
892
- // A signature is continuation metadata (stored as `thinkingSignature`), not generated
893
- // text: weighing it would let a long signature in the opening burst outweigh a paced
894
- // answer, and the window must not open at it either.
895
625
  if (piece && delta.type === 'thinking_delta')
896
626
  stampOutput(piece);
897
627
  }
@@ -922,7 +652,6 @@ function createAnthropicStreamAccumulator(now = Date.now) {
922
652
  const text = ordered.filter(block => block.type === 'text').map(block => block.text).join('\n');
923
653
  const measured = decodeWindow();
924
654
  const measuredUsage = { requests, ...(measured === undefined ? {} : { decodeMs: measured }) };
925
- // An explicit output limit discards the entire tool batch, including unfinished fragments.
926
655
  if (finishReason === 'max_tokens')
927
656
  return { text, toolCalls: [], stopReason: 'length', usage: { ...measuredUsage } };
928
657
  if (ordered.some(block => !block.stopped))
@@ -964,28 +693,12 @@ export function createAdapter(config) {
964
693
  if (config.type !== 'openai-compatible' && config.type !== 'anthropic')
965
694
  throw new Error('Unsupported provider type.');
966
695
  const anthropic = config.type === 'anthropic';
967
- // Resolved once per adapter: `0` is the explicit "no bound" spelling, so the caller's signal
968
- // stays the only abort source and a slow-but-working request is never cut short.
969
696
  const requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
970
- // Discovery keeps its own bound even when inference has none, but a provider that asked for
971
- // something shorter than that still gets it.
972
697
  const listingTimeoutMs = requestTimeoutMs > 0 ? Math.min(requestTimeoutMs, MODEL_LISTING_TIMEOUT_MS) : MODEL_LISTING_TIMEOUT_MS;
973
- // A configured stream inactivity bound owns inference idleness on its own, so a provider that
974
- // removed `requestTimeoutMs` for a slow prefill still ends a stream that stops delivering bytes.
975
698
  const inferenceTimeoutMs = config.streamIdleTimeoutMs ?? requestTimeoutMs;
976
- /**
977
- * One HTTP exchange under the caller's signal plus this call's own deadline.
978
- *
979
- * The deadline is kept separate from the caller's signal rather than pre-combined, because the
980
- * two failures must not be confused: a caller that cancelled is a cancellation, while a deadline
981
- * this adapter armed is a timeout. Collapsing them reported a stalled endpoint as a user
982
- * cancellation. The deadline is returned so a failure while reading the body afterwards can
983
- * still be told apart the same way.
984
- */
985
699
  async function send(path, signal, body, timeoutMs, inference = false, forceRefresh = false) {
986
700
  if (signal.aborted)
987
701
  cancelled();
988
- // Credentials can need a token refresh, which is bounded by this request's own deadline too.
989
702
  const authDeadline = timeoutMs > 0 ? AbortSignal.timeout(timeoutMs) : undefined;
990
703
  let credential;
991
704
  try {
@@ -999,7 +712,6 @@ export function createAdapter(config) {
999
712
  throw error;
1000
713
  }
1001
714
  const headers = { 'content-type': 'application/json', ...credential };
1002
- // The credential this request carries, whichever header holds it, so a rejection that echoes it is redacted.
1003
715
  const key = headers['x-api-key'] ?? headers.authorization?.replace(/^Bearer /, '');
1004
716
  const idle = inference && timeoutMs > 0 ? new AbortController() : undefined;
1005
717
  let timer;
@@ -1027,16 +739,12 @@ export function createAdapter(config) {
1027
739
  throw new Error('Provider request cancelled.');
1028
740
  if (deadline?.aborted)
1029
741
  throw new RetryableProviderError('Provider request timed out.');
1030
- // The transport's own code is what tells an operator whether this is DNS, TLS, a refused
1031
- // port or a bad certificate; without it the sentence repeats the base URL they already know.
1032
742
  const cause = connectionFailureDetail(error);
1033
743
  const message = `Provider connection failed${cause ? ` (${cause})` : ''}. Check its URL and network connection.`;
1034
744
  if (permanentConnectionFailure(error))
1035
745
  throw new ProviderRequestError(message);
1036
746
  throw new RetryableProviderError(message);
1037
747
  }
1038
- // A Console token can be revoked before its recorded expiry; one refresh tells that apart from a
1039
- // login that is really gone, which then fails below like any other rejected credential.
1040
748
  if (response.status === 401 && config.anthropicAuth === 'console' && !forceRefresh) {
1041
749
  dispose();
1042
750
  await response.body?.cancel().catch(() => { });
@@ -1044,22 +752,15 @@ export function createAdapter(config) {
1044
752
  }
1045
753
  if (!response.ok) {
1046
754
  try {
1047
- // HTTP 413 is sufficient evidence that this payload exceeds the gateway's
1048
- // allowance. Do not depend on error-body format or read an unbounded body.
1049
755
  if (response.status === 413) {
1050
756
  await response.body?.cancel().catch(() => { });
1051
757
  throw new ProviderRequestError('Provider input exceeds the context window.', true);
1052
758
  }
1053
759
  const errorData = await boundedJson(response).catch(() => undefined);
1054
- // Context overflow is a classification, not a provider message: reporting it the same
1055
- // way every time keeps retry policy and the run record stable across providers.
1056
760
  if ([400, 422].includes(response.status) && errorData !== undefined && isEngineContextOverflow(JSON.stringify(errorData))) {
1057
761
  throw new ProviderRequestError('Provider input exceeds the context window.', true);
1058
762
  }
1059
763
  await response.body?.cancel().catch(() => { });
1060
- // A provider that echoes the submitted key back in its rejection message must not have it
1061
- // copied into the thrown error, which lands in the run record outside the trajectory
1062
- // sanitizer's reach.
1063
764
  const detail = providerErrorDetail(errorData);
1064
765
  const shown = detail === undefined ? undefined : redactCredential(detail, key);
1065
766
  const message = `Provider request failed (HTTP ${response.status})${shown ? `: ${shown}` : ''}. Check credentials, model, and provider availability.`;
@@ -1158,11 +859,6 @@ export function createAdapter(config) {
1158
859
  return malformed();
1159
860
  }
1160
861
  }
1161
- /**
1162
- * Run one serialized inference attempt under the shared retry policy; never re-enter the
1163
- * agent/tool loop. Both the whole-body and the streaming request use it, so a connection
1164
- * that drops mid-stream restarts the same request exactly like a failed handshake.
1165
- */
1166
862
  async function withRetries(attempt, signal, onRetry, prepareRetry) {
1167
863
  for (let retry = 0;; retry++) {
1168
864
  if (signal.aborted)
@@ -1175,14 +871,9 @@ export function createAdapter(config) {
1175
871
  cancelled();
1176
872
  if (!(error instanceof RetryableProviderError))
1177
873
  throw error;
1178
- // Record request-local recovery state even when this was the final allowed attempt.
1179
- // In particular, a malformed fourth response must still trip the adapter's sticky
1180
- // whole-body circuit breaker for the next independent generation.
1181
874
  prepareRetry?.(error);
1182
875
  if (retry >= MAX_REQUEST_RETRIES)
1183
876
  throw error;
1184
- // Never retry earlier than the server requests. The staged schedule gives transient
1185
- // local/network failures time to recover without hammering the endpoint.
1186
877
  if (error.retryAfterMs > MAX_AUTOMATIC_RETRY_AFTER_MS)
1187
878
  throw new ProviderRequestError(`${error.message} Retry-After exceeds the 120-second automatic retry limit.`);
1188
879
  const delayMs = Math.max(error.retryDelaysMs[retry] ?? error.retryDelaysMs.at(-1) ?? 0, error.retryAfterMs);
@@ -1199,9 +890,6 @@ export function createAdapter(config) {
1199
890
  }
1200
891
  }
1201
892
  }
1202
- // A provider that emits malformed SSE is kept on whole-body responses for this adapter's
1203
- // lifetime. Recreating/switching the provider probes streaming again without repeatedly
1204
- // sacrificing long generations to a known-bad stream path.
1205
893
  let preferNonStreaming = false;
1206
894
  return {
1207
895
  async generate(input) {
@@ -1218,14 +906,11 @@ export function createAdapter(config) {
1218
906
  contextWindow: model === config.model ? config.contextWindow ?? 128_000 : 128_000,
1219
907
  reasoningEffort: model === config.model ? config.reasoningEffort : undefined,
1220
908
  async send(body) {
1221
- // A failed send must not inherit an expired deadline from an earlier response.
1222
909
  deadline = undefined;
1223
910
  dispose?.();
1224
911
  dispose = undefined;
1225
912
  requests++;
1226
913
  onRequest?.();
1227
- // Re-read the adapter-wide breaker for every attempt: another concurrent
1228
- // invocation may have discovered a broken stream while this one was backing off.
1229
914
  currentRequestNonStreaming = forceNonStreaming || preferNonStreaming;
1230
915
  const requestBody = currentRequestNonStreaming
1231
916
  ? (() => { const plain = { ...body }; delete plain.stream_options; plain.stream = false; return plain; })()