@bastani/atomic 0.9.17 → 0.9.18-alpha.2

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 (310) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/builtin/intercom/index.bundle.mjs +349 -57517
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/index.bundle.mjs +28948 -58339
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/mcp/xdg-open +1267 -0
  7. package/dist/builtin/subagents/package.json +1 -1
  8. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7929 -78021
  9. package/dist/builtin/web-access/index.bundle.mjs +70791 -57707
  10. package/dist/builtin/web-access/package.json +1 -1
  11. package/dist/builtin/workflows/builtin/adversarial-verification.js +0 -1
  12. package/dist/builtin/workflows/builtin/{chunk-3y1hmzw6.js → chunk-6v0yv8tj.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-w9c7rkrk.js → chunk-brerg33r.js} +5 -7
  14. package/dist/builtin/workflows/builtin/{chunk-bz1c9732.js → chunk-ngffz3y8.js} +1 -1
  15. package/dist/builtin/workflows/builtin/{chunk-6rbajjf5.js → chunk-szz1ajz9.js} +1 -3
  16. package/dist/builtin/workflows/builtin/classify-and-act.js +0 -1
  17. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +0 -1
  18. package/dist/builtin/workflows/builtin/generate-and-filter.js +0 -1
  19. package/dist/builtin/workflows/builtin/goal.js +2 -5
  20. package/dist/builtin/workflows/builtin/index.js +4 -7
  21. package/dist/builtin/workflows/builtin/loop-until-done.js +0 -1
  22. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -4
  23. package/dist/builtin/workflows/builtin/ralph.js +2 -5
  24. package/dist/builtin/workflows/builtin/steering-context.js +0 -1
  25. package/dist/builtin/workflows/builtin/tournament.js +0 -1
  26. package/dist/builtin/workflows/package.json +1 -1
  27. package/dist/builtin/workflows/src/extension/index.bundle.mjs +39989 -81500
  28. package/dist/builtin/workflows/src/index.js +1253 -58524
  29. package/dist/bun/cli.js.map +1 -1
  30. package/dist/bun/split-loader.js +2 -0
  31. package/dist/bun/split-loader.js.map +1 -1
  32. package/dist/cli/args.js.map +1 -1
  33. package/dist/cli/auth-command.js.map +1 -1
  34. package/dist/cli/session-picker.js.map +1 -1
  35. package/dist/cli/startup-ui.js.map +1 -1
  36. package/dist/cli.js +5 -2
  37. package/dist/cli.js.map +1 -1
  38. package/dist/core/agent-session-extension-bindings.d.ts +19 -2
  39. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  40. package/dist/core/agent-session-extension-bindings.js +253 -74
  41. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  42. package/dist/core/agent-session-methods.d.ts +8 -3
  43. package/dist/core/agent-session-methods.d.ts.map +1 -1
  44. package/dist/core/agent-session-methods.js.map +1 -1
  45. package/dist/core/agent-session-prompt.d.ts +2 -7
  46. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  47. package/dist/core/agent-session-prompt.js +1 -35
  48. package/dist/core/agent-session-prompt.js.map +1 -1
  49. package/dist/core/agent-session-services.d.ts.map +1 -1
  50. package/dist/core/agent-session-services.js +2 -0
  51. package/dist/core/agent-session-services.js.map +1 -1
  52. package/dist/core/agent-session-types.d.ts +2 -0
  53. package/dist/core/agent-session-types.d.ts.map +1 -1
  54. package/dist/core/agent-session-types.js.map +1 -1
  55. package/dist/core/agent-session.d.ts +1 -0
  56. package/dist/core/agent-session.d.ts.map +1 -1
  57. package/dist/core/agent-session.js +2 -0
  58. package/dist/core/agent-session.js.map +1 -1
  59. package/dist/core/auth-guidance.js.map +1 -1
  60. package/dist/core/auth-storage-backends.js.map +1 -1
  61. package/dist/core/auth-storage.js.map +1 -1
  62. package/dist/core/bash-executor.js.map +1 -1
  63. package/dist/core/builtin-packages.d.ts +8 -0
  64. package/dist/core/builtin-packages.d.ts.map +1 -1
  65. package/dist/core/builtin-packages.js +11 -5
  66. package/dist/core/builtin-packages.js.map +1 -1
  67. package/dist/core/event-bus.d.ts +11 -0
  68. package/dist/core/event-bus.d.ts.map +1 -1
  69. package/dist/core/event-bus.js +96 -0
  70. package/dist/core/event-bus.js.map +1 -1
  71. package/dist/core/experimental.js.map +1 -1
  72. package/dist/core/export-html/index.js.map +1 -1
  73. package/dist/core/extensions/builtin-extension-entry-labels.d.ts +6 -0
  74. package/dist/core/extensions/builtin-extension-entry-labels.d.ts.map +1 -0
  75. package/dist/core/extensions/builtin-extension-entry-labels.js +22 -0
  76. package/dist/core/extensions/builtin-extension-entry-labels.js.map +1 -0
  77. package/dist/core/extensions/host-module-bridge.d.ts +22 -0
  78. package/dist/core/extensions/host-module-bridge.d.ts.map +1 -0
  79. package/dist/core/extensions/host-module-bridge.js +39 -0
  80. package/dist/core/extensions/host-module-bridge.js.map +1 -0
  81. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  82. package/dist/core/extensions/loader-api.js +2 -2
  83. package/dist/core/extensions/loader-api.js.map +1 -1
  84. package/dist/core/extensions/loader-core.js.map +1 -1
  85. package/dist/core/extensions/loader-discovery.js.map +1 -1
  86. package/dist/core/extensions/loader-host-modules.d.ts +10 -0
  87. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -0
  88. package/dist/core/extensions/loader-host-modules.js +88 -0
  89. package/dist/core/extensions/loader-host-modules.js.map +1 -0
  90. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  91. package/dist/core/extensions/loader-runtime.js +1 -0
  92. package/dist/core/extensions/loader-runtime.js.map +1 -1
  93. package/dist/core/extensions/loader-virtual-modules.d.ts +5 -2
  94. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  95. package/dist/core/extensions/loader-virtual-modules.js +51 -71
  96. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  97. package/dist/core/extensions/loader.d.ts +1 -1
  98. package/dist/core/extensions/loader.js.map +1 -1
  99. package/dist/core/extensions/native-builtin-entries.d.ts +6 -0
  100. package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -0
  101. package/dist/core/extensions/native-builtin-entries.js +23 -0
  102. package/dist/core/extensions/native-builtin-entries.js.map +1 -0
  103. package/dist/core/extensions/runtime-types.d.ts +2 -0
  104. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  105. package/dist/core/extensions/runtime-types.js.map +1 -1
  106. package/dist/core/keybindings.js.map +1 -1
  107. package/dist/core/lifecycle-timings.d.ts +21 -0
  108. package/dist/core/lifecycle-timings.d.ts.map +1 -0
  109. package/dist/core/lifecycle-timings.js +57 -0
  110. package/dist/core/lifecycle-timings.js.map +1 -0
  111. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  112. package/dist/core/mandatory-resource-loader.js +43 -0
  113. package/dist/core/mandatory-resource-loader.js.map +1 -1
  114. package/dist/core/model-runtime.d.ts +8 -0
  115. package/dist/core/model-runtime.d.ts.map +1 -1
  116. package/dist/core/model-runtime.js +82 -0
  117. package/dist/core/model-runtime.js.map +1 -1
  118. package/dist/core/models-store.js.map +1 -1
  119. package/dist/core/package-manager-auto-resources.js.map +1 -1
  120. package/dist/core/package-manager-env.js.map +1 -1
  121. package/dist/core/package-manager-git.js.map +1 -1
  122. package/dist/core/package-manager-manifest.js.map +1 -1
  123. package/dist/core/package-manager-npm.js.map +1 -1
  124. package/dist/core/package-manager-paths.js.map +1 -1
  125. package/dist/core/package-manager-resolver.js.map +1 -1
  126. package/dist/core/project-trust.js.map +1 -1
  127. package/dist/core/prompt-templates-async.js.map +1 -1
  128. package/dist/core/prompt-templates.js.map +1 -1
  129. package/dist/core/provider-attribution.js.map +1 -1
  130. package/dist/core/remote-catalog-provider.js.map +1 -1
  131. package/dist/core/resource-loader-assets.js.map +1 -1
  132. package/dist/core/resource-loader-context-files.js.map +1 -1
  133. package/dist/core/resource-loader-core.d.ts +5 -1
  134. package/dist/core/resource-loader-core.d.ts.map +1 -1
  135. package/dist/core/resource-loader-core.js +90 -1
  136. package/dist/core/resource-loader-core.js.map +1 -1
  137. package/dist/core/resource-loader-discovery.js.map +1 -1
  138. package/dist/core/resource-loader-paths.js.map +1 -1
  139. package/dist/core/resource-loader-source-info.js.map +1 -1
  140. package/dist/core/resource-loader-types.d.ts +16 -0
  141. package/dist/core/resource-loader-types.d.ts.map +1 -1
  142. package/dist/core/resource-loader-types.js.map +1 -1
  143. package/dist/core/sdk.d.ts.map +1 -1
  144. package/dist/core/sdk.js +4 -1
  145. package/dist/core/sdk.js.map +1 -1
  146. package/dist/core/session-manager-core.js.map +1 -1
  147. package/dist/core/session-manager-list.js.map +1 -1
  148. package/dist/core/session-manager-paths.js.map +1 -1
  149. package/dist/core/settings-manager-core.d.ts +6 -0
  150. package/dist/core/settings-manager-core.d.ts.map +1 -1
  151. package/dist/core/settings-manager-core.js +24 -0
  152. package/dist/core/settings-manager-core.js.map +1 -1
  153. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  154. package/dist/core/settings-storage.js.map +1 -1
  155. package/dist/core/skills-async.js.map +1 -1
  156. package/dist/core/skills.js.map +1 -1
  157. package/dist/core/slash-commands.d.ts.map +1 -1
  158. package/dist/core/slash-commands.js +0 -6
  159. package/dist/core/slash-commands.js.map +1 -1
  160. package/dist/core/system-prompt.js.map +1 -1
  161. package/dist/core/telemetry.js.map +1 -1
  162. package/dist/core/timings.js.map +1 -1
  163. package/dist/core/tools/bash.js.map +1 -1
  164. package/dist/core/tools/output-accumulator.js.map +1 -1
  165. package/dist/core/tools/powershell.js.map +1 -1
  166. package/dist/core/tools/read.js.map +1 -1
  167. package/dist/core/tools/session-temp-cleanup.js.map +1 -1
  168. package/dist/core/tools/session-temp-dir.js.map +1 -1
  169. package/dist/core/tools/todos-paths.js.map +1 -1
  170. package/dist/core/trust-manager.js.map +1 -1
  171. package/dist/index.d.ts +1 -1
  172. package/dist/index.js.map +1 -1
  173. package/dist/main-deferred-startup.d.ts +16 -0
  174. package/dist/main-deferred-startup.d.ts.map +1 -1
  175. package/dist/main-deferred-startup.js +14 -0
  176. package/dist/main-deferred-startup.js.map +1 -1
  177. package/dist/main-session.js.map +1 -1
  178. package/dist/main.d.ts.map +1 -1
  179. package/dist/main.js +41 -22
  180. package/dist/main.js.map +1 -1
  181. package/dist/migrations.js.map +1 -1
  182. package/dist/modes/interactive/chat-input-actions.js.map +1 -1
  183. package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
  184. package/dist/modes/interactive/components/config-selector-project-scope.js.map +1 -1
  185. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  186. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  187. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  188. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
  189. package/dist/modes/interactive/components/startup-identity.js +4 -0
  190. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  191. package/dist/modes/interactive/external-editor.js.map +1 -1
  192. package/dist/modes/interactive/interactive-editor-actions.js +13 -5
  193. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  194. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  195. package/dist/modes/interactive/interactive-input-handling.js +2 -5
  196. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  197. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  198. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  199. package/dist/modes/interactive/interactive-mode-surface.d.ts +8 -8
  200. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  201. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  202. package/dist/modes/interactive/interactive-onboarding.js +1 -1
  203. package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
  204. package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
  205. package/dist/modes/interactive/interactive-prompt-restore.js +2 -1
  206. package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
  207. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  208. package/dist/modes/interactive/interactive-render-chat.js +2 -0
  209. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  210. package/dist/modes/interactive/interactive-resource-disclosure.js +21 -53
  211. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  212. package/dist/modes/interactive/interactive-resource-paths.js +29 -5
  213. package/dist/modes/interactive/interactive-resource-paths.js.map +1 -1
  214. package/dist/modes/interactive/interactive-resource-rendering.js +66 -69
  215. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  216. package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -1
  217. package/dist/modes/interactive/interactive-startup-chat-container.js +2 -0
  218. package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
  219. package/dist/modes/interactive/interactive-startup.d.ts +2 -0
  220. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  221. package/dist/modes/interactive/interactive-startup.js +30 -10
  222. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  223. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  224. package/dist/modes/interactive/interactive-tui.js +12 -2
  225. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  226. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  227. package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
  228. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  229. package/dist/modes/interactive-engine/engine-child-liveness.d.ts +2 -0
  230. package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -1
  231. package/dist/modes/interactive-engine/engine-child-liveness.js +16 -2
  232. package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -1
  233. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  234. package/dist/modes/interactive-engine/engine-monitor.d.ts +5 -0
  235. package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -1
  236. package/dist/modes/interactive-engine/engine-monitor.js +24 -0
  237. package/dist/modes/interactive-engine/engine-monitor.js.map +1 -1
  238. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  239. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
  240. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  241. package/dist/modes/interactive-engine/extension-ui-bridge.js +6 -0
  242. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  243. package/dist/modes/interactive-engine/isolated-runtime.d.ts +21 -2
  244. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  245. package/dist/modes/interactive-engine/isolated-runtime.js +160 -7
  246. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  247. package/dist/modes/interactive-engine/protocol.d.ts +9 -4
  248. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  249. package/dist/modes/interactive-engine/protocol.js +8 -4
  250. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  251. package/dist/modes/interactive-engine/resource-readiness-error.d.ts +6 -0
  252. package/dist/modes/interactive-engine/resource-readiness-error.d.ts.map +1 -0
  253. package/dist/modes/interactive-engine/resource-readiness-error.js +11 -0
  254. package/dist/modes/interactive-engine/resource-readiness-error.js.map +1 -0
  255. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  256. package/dist/modes/rpc/rpc-client-process.js +3 -0
  257. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  258. package/dist/modes/rpc/rpc-client.d.ts +1 -0
  259. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  260. package/dist/modes/rpc/rpc-client.js +5 -1
  261. package/dist/modes/rpc/rpc-client.js.map +1 -1
  262. package/dist/modes/rpc/rpc-command-handler.d.ts +4 -1
  263. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  264. package/dist/modes/rpc/rpc-command-handler.js +59 -18
  265. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  266. package/dist/modes/rpc/rpc-mode.d.ts +4 -13
  267. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  268. package/dist/modes/rpc/rpc-mode.js +31 -2
  269. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  270. package/dist/modes/rpc/rpc-resource-readiness.d.ts +11 -0
  271. package/dist/modes/rpc/rpc-resource-readiness.d.ts.map +1 -0
  272. package/dist/modes/rpc/rpc-resource-readiness.js +51 -0
  273. package/dist/modes/rpc/rpc-resource-readiness.js.map +1 -0
  274. package/dist/modes/rpc/rpc-session-binding.d.ts +2 -0
  275. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  276. package/dist/modes/rpc/rpc-session-binding.js +21 -0
  277. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  278. package/dist/modes/rpc/rpc-types.d.ts +7 -0
  279. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  280. package/dist/modes/rpc/rpc-types.js.map +1 -1
  281. package/dist/package-manager-cli-parser.js.map +1 -1
  282. package/dist/package-manager-cli.js.map +1 -1
  283. package/dist/rpc-entry.js.map +1 -1
  284. package/dist/self-update-plan.js.map +1 -1
  285. package/dist/utils/changelog.d.ts +1 -1
  286. package/dist/utils/changelog.js.map +1 -1
  287. package/dist/utils/module-require.js.map +1 -1
  288. package/dist/utils/pi-user-agent.js.map +1 -1
  289. package/dist/utils/shell.js.map +1 -1
  290. package/dist/utils/tools-manager.js.map +1 -1
  291. package/dist/utils/version-check.js.map +1 -1
  292. package/dist/utils/windows-self-update.js.map +1 -1
  293. package/docs/development.md +28 -1
  294. package/docs/extensions.md +5 -3
  295. package/docs/quickstart.md +1 -3
  296. package/docs/sdk.md +2 -0
  297. package/docs/usage.md +3 -1
  298. package/docs/windows.md +8 -0
  299. package/npm-shrinkwrap.json +32 -32
  300. package/package.json +4 -4
  301. package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +0 -264
  302. package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +0 -4
  303. package/dist/builtin/workflows/builtin/chunk-dattsgxg.js +0 -529
  304. package/dist/builtin/workflows/builtin/chunk-gdx0avpx.js +0 -70082
  305. package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +0 -215
  306. package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +0 -4110
  307. package/dist/core/atomic-guide-command.d.ts +0 -41
  308. package/dist/core/atomic-guide-command.d.ts.map +0 -1
  309. package/dist/core/atomic-guide-command.js +0 -311
  310. package/dist/core/atomic-guide-command.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-timings.js","sourceRoot":"","sources":["../../src/core/lifecycle-timings.ts"],"names":[],"mappings":"AA8BA,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAClE,MAAM,wBAAwB,GAAG,UAEhC,CAAC;AAEF,SAAS,QAAQ;IAChB,MAAM,QAAQ,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACrD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,OAAO,GAAyB;QACrC,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM;QAC5B,QAAQ,EAAE,IAAI,GAAG,EAAE;KACnB,CAAC;IACF,wBAAwB,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;IAC9C,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,wBAAwB;IACvC,OAAO,QAAQ,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACzC,IAAyB,EACzB,KAAK,GAAiB,OAAO,CAAC,MAAM,CAAC,MAAM;IAE3C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC;IAChC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC;IAClC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACvB,OAAO,GAAG,EAAE;QACX,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC;QAC1B,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC;QAC5B,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,gBAAgB;YAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC,CAAC;AACH,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,mBAAmB,CAAC,KAA2B;IAC9D,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO;IAC/C,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,CAAC;QACJ,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACR,8DAA8D;IAC/D,CAAC;AACF,CAAC","sourcesContent":["export type LifecycleTimingLabel =\n\t| \"process-entry\"\n\t| \"interactive-engine-spawn\"\n\t| \"engine-ready\"\n\t| \"tui-start\"\n\t| \"header-mounted\"\n\t| \"first-terminal-write\"\n\t| \"startup-coherent\"\n\t| \"startup-complete\"\n\t| \"engine-bound\"\n\t| \"engine-resources-ready\"\n\t| \"chat-output-release\"\n\t| \"interactive-input-handler-ready\"\n\t| \"interactive-first-submit\"\n\t| \"before-provider-request\";\n\nexport interface LifecycleTimingRecord {\n\treadonly label: LifecycleTimingLabel;\n\treadonly atNs: bigint;\n\treadonly pid: number;\n}\n\nexport type LifecycleTimingSink = (record: LifecycleTimingRecord) => void;\n\ninterface LifecycleTimingState {\n\tsink: LifecycleTimingSink | undefined;\n\tclock: () => bigint;\n\treadonly recorded: Set<LifecycleTimingLabel>;\n}\n\nconst STATE_KEY = Symbol.for(\"@bastani/atomic/lifecycle-timings\");\nconst globalWithLifecycleState = globalThis as typeof globalThis & {\n\t[STATE_KEY]?: LifecycleTimingState;\n};\n\nfunction getState(): LifecycleTimingState {\n\tconst existing = globalWithLifecycleState[STATE_KEY];\n\tif (existing) return existing;\n\tconst created: LifecycleTimingState = {\n\t\tsink: undefined,\n\t\tclock: process.hrtime.bigint,\n\t\trecorded: new Set(),\n\t};\n\tglobalWithLifecycleState[STATE_KEY] = created;\n\treturn created;\n}\n\n/** True only when an internal diagnostic adapter has installed a synchronous sink. */\nexport function isLifecycleTimingEnabled(): boolean {\n\treturn getState().sink !== undefined;\n}\n\n/**\n * Install a process-local diagnostic sink.\n *\n * The sink must stay synchronous and must not write to the terminal. External\n * ConPTY and TCP timestamps remain authoritative; these records only attribute\n * time inside the process. Installing a sink resets the one-shot labels for a\n * new diagnostic run. The returned function restores the previous adapter.\n */\nexport function installLifecycleTimingSink(\n\tsink: LifecycleTimingSink,\n\tclock: () => bigint = process.hrtime.bigint,\n): () => void {\n\tconst state = getState();\n\tconst previousSink = state.sink;\n\tconst previousClock = state.clock;\n\tconst previousRecorded = new Set(state.recorded);\n\tstate.sink = sink;\n\tstate.clock = clock;\n\tstate.recorded.clear();\n\treturn () => {\n\t\tstate.sink = previousSink;\n\t\tstate.clock = previousClock;\n\t\tstate.recorded.clear();\n\t\tfor (const label of previousRecorded) state.recorded.add(label);\n\t};\n}\n\n/** Record the first occurrence of a lifecycle boundary when diagnostics are active. */\nexport function markLifecycleTiming(label: LifecycleTimingLabel): void {\n\tconst state = getState();\n\tconst sink = state.sink;\n\tif (!sink || state.recorded.has(label)) return;\n\tstate.recorded.add(label);\n\ttry {\n\t\tsink({ label, atNs: state.clock(), pid: process.pid });\n\t} catch {\n\t\t// Diagnostics must never alter the startup path they observe.\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mandatory-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/mandatory-resource-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA0B,cAAc,EAA+B,MAAM,4BAA4B,CAAC;AAyGtH,4FAA4F;AAC5F,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAI9G;AAED,kGAAkG;AAClG,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAEzE"}
1
+ {"version":3,"file":"mandatory-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/mandatory-resource-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEX,cAAc,EAGd,MAAM,4BAA4B,CAAC;AAuJpC,4FAA4F;AAC5F,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAI9G;AAED,kGAAkG;AAClG,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAEzE"}
@@ -78,6 +78,49 @@ class MandatoryResourceLoader {
78
78
  if (this.toolOnly)
79
79
  this.removeLocalInteractionSurfaces();
80
80
  }
81
+ supportsTransactionalReload() {
82
+ return this.delegate.prepareReload !== undefined && this.delegate.supportsTransactionalReload?.() !== false;
83
+ }
84
+ async prepareReload(settingsManager, options) {
85
+ if (!this.delegate.prepareReload) {
86
+ throw new Error("Resource loader does not support transactional reload");
87
+ }
88
+ const delegateTransaction = await this.delegate.prepareReload(settingsManager, options);
89
+ const extensionsResult = await restoreMandatoryExtensions(delegateTransaction.loader.getExtensions(), this.cwd);
90
+ const candidate = new MandatoryResourceLoader(delegateTransaction.loader, this.cwd, extensionsResult);
91
+ if (this.toolOnly)
92
+ candidate.limitToTool();
93
+ const prepareCommit = delegateTransaction.prepareCommit
94
+ ? () => {
95
+ const delegateCommit = delegateTransaction.prepareCommit();
96
+ let settled = false;
97
+ return {
98
+ commit: () => {
99
+ if (settled)
100
+ return;
101
+ settled = true;
102
+ delegateCommit.commit();
103
+ this.extensionsResult = candidate.extensionsResult;
104
+ },
105
+ rollback: () => {
106
+ if (settled)
107
+ return;
108
+ settled = true;
109
+ delegateCommit.rollback();
110
+ },
111
+ };
112
+ }
113
+ : undefined;
114
+ return {
115
+ loader: candidate,
116
+ activate: (liveSettingsManager) => delegateTransaction.activate(liveSettingsManager),
117
+ ...(prepareCommit ? { prepareCommit } : {}),
118
+ commit: () => {
119
+ delegateTransaction.commit();
120
+ this.extensionsResult = candidate.extensionsResult;
121
+ },
122
+ };
123
+ }
81
124
  }
82
125
  /** Preserve caller-owned resources while restoring Atomic's mandatory bundled extension. */
83
126
  export async function withMandatoryResourceLoader(loader, cwd) {
@@ -1 +1 @@
1
- {"version":3,"file":"mandatory-resource-loader.js","sourceRoot":"","sources":["../../src/core/mandatory-resource-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAAE,6BAA6B,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAC;AAEnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,SAAS,kBAAkB,CAAC,SAAoB;IAC/C,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACrD,OAAO,YAAY,KAAK,SAAS,IAAI,6BAA6B,CAAC,YAAY,CAAC,CAAC;AAClF,CAAC;AAED,KAAK,UAAU,0BAA0B,CAAC,MAA4B,EAAE,GAAW;IAClF,IAAI,MAA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AAK,CAAC,MAAM,CAAC,OAAqC;QACjD,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,MAAM,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAClG,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,8BAA8B,EAAE,CAAC;IAC1D,CAAC;CACD;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,MAAsB,EAAE,GAAW;IACpF,IAAI,MAAM,YAAY,uBAAuB;QAAE,OAAO,MAAM,CAAC;IAC7D,MAAM,gBAAgB,GAAG,MAAM,0BAA0B,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,GAAG,CAAC,CAAC;IACvF,OAAO,IAAI,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACnE,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,4BAA4B,CAAC,MAAsB;IAClE,IAAI,MAAM,YAAY,uBAAuB;QAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import { getMandatoryBuiltinExtensionPaths } from \"./builtin-packages.ts\";\nimport { getExtensionRuntimeEventBus, loadExtensions } from \"./extensions/loader.ts\";\nimport type { Extension, LoadExtensionsResult } from \"./extensions/types.ts\";\nimport { isTrustedMandatoryRuntimeTool, markTrustedMandatoryRuntimeExtension } from \"./mandatory-runtime-tools.ts\";\nimport type { ResourceExtensionPaths, ResourceLoader, ResourceLoaderReloadOptions } from \"./resource-loader-types.ts\";\nimport { buildSkillCatalog } from \"./skill-catalog.ts\";\n\nfunction hasTrustedIntercom(extension: Extension): boolean {\n\tconst registration = extension.tools.get(\"intercom\");\n\treturn registration !== undefined && isTrustedMandatoryRuntimeTool(registration);\n}\n\nasync function restoreMandatoryExtensions(target: LoadExtensionsResult, cwd: string): Promise<LoadExtensionsResult> {\n\tif (target.extensions.some(hasTrustedIntercom)) return target;\n\n\tconst loaded = await loadExtensions(\n\t\tgetMandatoryBuiltinExtensionPaths(),\n\t\tcwd,\n\t\tgetExtensionRuntimeEventBus(target.runtime),\n\t\tundefined,\n\t\ttarget.runtime,\n\t);\n\tfor (const extension of loaded.extensions) markTrustedMandatoryRuntimeExtension(extension);\n\tconst restored: LoadExtensionsResult = {\n\t\t...target,\n\t\textensions: [...target.extensions, ...loaded.extensions],\n\t\terrors: [...target.errors, ...loaded.errors],\n\t};\n\tif (!restored.extensions.some(hasTrustedIntercom)) {\n\t\tconst detail = loaded.errors.map(({ error }) => error).join(\"; \") || \"extension did not register intercom\";\n\t\tthrow new Error(`Mandatory bundled Intercom is unavailable: ${detail}`);\n\t}\n\treturn restored;\n}\n\nclass MandatoryResourceLoader implements ResourceLoader {\n\tprivate readonly delegate: ResourceLoader;\n\tprivate readonly cwd: string;\n\tprivate extensionsResult: LoadExtensionsResult;\n\tprivate toolOnly = false;\n\n\tconstructor(delegate: ResourceLoader, cwd: string, extensionsResult: LoadExtensionsResult) {\n\t\tthis.delegate = delegate;\n\t\tthis.cwd = cwd;\n\t\tthis.extensionsResult = extensionsResult;\n\t}\n\n\tlimitToTool(): void {\n\t\tthis.toolOnly = true;\n\t\tthis.removeLocalInteractionSurfaces();\n\t}\n\n\tprivate removeLocalInteractionSurfaces(): void {\n\t\tconst extension = this.extensionsResult.extensions.find(hasTrustedIntercom);\n\t\textension?.commands.delete(\"intercom\");\n\t\textension?.shortcuts.delete(\"alt+m\");\n\t}\n\n\tgetExtensions(): LoadExtensionsResult {\n\t\treturn this.extensionsResult;\n\t}\n\n\tgetSkills(): ReturnType<ResourceLoader[\"getSkills\"]> {\n\t\treturn this.delegate.getSkills();\n\t}\n\n\tgetSkillCatalog(): ReturnType<NonNullable<ResourceLoader[\"getSkillCatalog\"]>> {\n\t\treturn this.delegate.getSkillCatalog?.() ?? buildSkillCatalog(this.delegate.getSkills().skills);\n\t}\n\n\tgetPrompts(): ReturnType<ResourceLoader[\"getPrompts\"]> {\n\t\treturn this.delegate.getPrompts();\n\t}\n\n\tgetThemes(): ReturnType<ResourceLoader[\"getThemes\"]> {\n\t\treturn this.delegate.getThemes();\n\t}\n\n\tgetAgentsFiles(): ReturnType<ResourceLoader[\"getAgentsFiles\"]> {\n\t\treturn this.delegate.getAgentsFiles();\n\t}\n\n\tgetSystemPrompt(): ReturnType<ResourceLoader[\"getSystemPrompt\"]> {\n\t\treturn this.delegate.getSystemPrompt();\n\t}\n\n\tgetSystemPromptSource(): ReturnType<ResourceLoader[\"getSystemPromptSource\"]> {\n\t\treturn this.delegate.getSystemPromptSource();\n\t}\n\n\tgetAppendSystemPrompt(): ReturnType<ResourceLoader[\"getAppendSystemPrompt\"]> {\n\t\treturn this.delegate.getAppendSystemPrompt();\n\t}\n\n\tgetAppendSystemPromptSources(): ReturnType<ResourceLoader[\"getAppendSystemPromptSources\"]> {\n\t\treturn this.delegate.getAppendSystemPromptSources();\n\t}\n\n\textendResources(paths: ResourceExtensionPaths): Promise<void> {\n\t\treturn this.delegate.extendResources(paths);\n\t}\n\n\tasync reload(options?: ResourceLoaderReloadOptions): Promise<void> {\n\t\tawait this.delegate.reload(options);\n\t\tthis.extensionsResult = await restoreMandatoryExtensions(this.delegate.getExtensions(), this.cwd);\n\t\tif (this.toolOnly) this.removeLocalInteractionSurfaces();\n\t}\n}\n\n/** Preserve caller-owned resources while restoring Atomic's mandatory bundled extension. */\nexport async function withMandatoryResourceLoader(loader: ResourceLoader, cwd: string): Promise<ResourceLoader> {\n\tif (loader instanceof MandatoryResourceLoader) return loader;\n\tconst extensionsResult = await restoreMandatoryExtensions(loader.getExtensions(), cwd);\n\treturn new MandatoryResourceLoader(loader, cwd, extensionsResult);\n}\n\n/** Keep a non-model interactive host from shadowing the engine's command and shortcut proxies. */\nexport function limitMandatoryIntercomToTool(loader: ResourceLoader): void {\n\tif (loader instanceof MandatoryResourceLoader) loader.limitToTool();\n}\n"]}
1
+ {"version":3,"file":"mandatory-resource-loader.js","sourceRoot":"","sources":["../../src/core/mandatory-resource-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAAE,6BAA6B,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAC;AAQnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,SAAS,kBAAkB,CAAC,SAAoB;IAC/C,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACrD,OAAO,YAAY,KAAK,SAAS,IAAI,6BAA6B,CAAC,YAAY,CAAC,CAAC;AAClF,CAAC;AAED,KAAK,UAAU,0BAA0B,CAAC,MAA4B,EAAE,GAAW;IAClF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9D,MAAM,MAAM,GAAG,MAAM,cAAc,CAClC,iCAAiC,EAAE,EACnC,GAAG,EACH,2BAA2B,CAAC,MAAM,CAAC,OAAO,CAAC,EAC3C,SAAS,EACT,MAAM,CAAC,OAAO,CACd,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU;QAAE,oCAAoC,CAAC,SAAS,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAyB;QACtC,GAAG,MAAM;QACT,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;QACxD,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;KAC5C,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,EA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,MAAM,EAAE,GAAG,EAAE;gBACZ,mBAAmB,CAAC,MAAM,EAAE,CAAC;gBAC7B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAC;YACpD,CAAC;SACD,CAAC;IACH,CAAC;CACD;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,MAAsB,EAAE,GAAW;IACpF,IAAI,MAAM,YAAY,uBAAuB;QAAE,OAAO,MAAM,CAAC;IAC7D,MAAM,gBAAgB,GAAG,MAAM,0BAA0B,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,GAAG,CAAC,CAAC;IACvF,OAAO,IAAI,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACnE,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,4BAA4B,CAAC,MAAsB;IAClE,IAAI,MAAM,YAAY,uBAAuB;QAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import { getMandatoryBuiltinExtensionPaths } from \"./builtin-packages.ts\";\nimport { getExtensionRuntimeEventBus, loadExtensions } from \"./extensions/loader.ts\";\nimport type { Extension, LoadExtensionsResult } from \"./extensions/types.ts\";\nimport { isTrustedMandatoryRuntimeTool, markTrustedMandatoryRuntimeExtension } from \"./mandatory-runtime-tools.ts\";\nimport type {\n\tResourceExtensionPaths,\n\tResourceLoader,\n\tResourceLoaderReloadOptions,\n\tResourceLoaderReloadTransaction,\n} from \"./resource-loader-types.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport { buildSkillCatalog } from \"./skill-catalog.ts\";\n\nfunction hasTrustedIntercom(extension: Extension): boolean {\n\tconst registration = extension.tools.get(\"intercom\");\n\treturn registration !== undefined && isTrustedMandatoryRuntimeTool(registration);\n}\n\nasync function restoreMandatoryExtensions(target: LoadExtensionsResult, cwd: string): Promise<LoadExtensionsResult> {\n\tif (target.extensions.some(hasTrustedIntercom)) return target;\n\n\tconst loaded = await loadExtensions(\n\t\tgetMandatoryBuiltinExtensionPaths(),\n\t\tcwd,\n\t\tgetExtensionRuntimeEventBus(target.runtime),\n\t\tundefined,\n\t\ttarget.runtime,\n\t);\n\tfor (const extension of loaded.extensions) markTrustedMandatoryRuntimeExtension(extension);\n\tconst restored: LoadExtensionsResult = {\n\t\t...target,\n\t\textensions: [...target.extensions, ...loaded.extensions],\n\t\terrors: [...target.errors, ...loaded.errors],\n\t};\n\tif (!restored.extensions.some(hasTrustedIntercom)) {\n\t\tconst detail = loaded.errors.map(({ error }) => error).join(\"; \") || \"extension did not register intercom\";\n\t\tthrow new Error(`Mandatory bundled Intercom is unavailable: ${detail}`);\n\t}\n\treturn restored;\n}\n\nclass MandatoryResourceLoader implements ResourceLoader {\n\tprivate delegate: ResourceLoader;\n\tprivate readonly cwd: string;\n\tprivate extensionsResult: LoadExtensionsResult;\n\tprivate toolOnly = false;\n\n\tconstructor(delegate: ResourceLoader, cwd: string, extensionsResult: LoadExtensionsResult) {\n\t\tthis.delegate = delegate;\n\t\tthis.cwd = cwd;\n\t\tthis.extensionsResult = extensionsResult;\n\t}\n\n\tlimitToTool(): void {\n\t\tthis.toolOnly = true;\n\t\tthis.removeLocalInteractionSurfaces();\n\t}\n\n\tprivate removeLocalInteractionSurfaces(): void {\n\t\tconst extension = this.extensionsResult.extensions.find(hasTrustedIntercom);\n\t\textension?.commands.delete(\"intercom\");\n\t\textension?.shortcuts.delete(\"alt+m\");\n\t}\n\n\tgetExtensions(): LoadExtensionsResult {\n\t\treturn this.extensionsResult;\n\t}\n\n\tgetSkills(): ReturnType<ResourceLoader[\"getSkills\"]> {\n\t\treturn this.delegate.getSkills();\n\t}\n\n\tgetSkillCatalog(): ReturnType<NonNullable<ResourceLoader[\"getSkillCatalog\"]>> {\n\t\treturn this.delegate.getSkillCatalog?.() ?? buildSkillCatalog(this.delegate.getSkills().skills);\n\t}\n\n\tgetPrompts(): ReturnType<ResourceLoader[\"getPrompts\"]> {\n\t\treturn this.delegate.getPrompts();\n\t}\n\n\tgetThemes(): ReturnType<ResourceLoader[\"getThemes\"]> {\n\t\treturn this.delegate.getThemes();\n\t}\n\n\tgetAgentsFiles(): ReturnType<ResourceLoader[\"getAgentsFiles\"]> {\n\t\treturn this.delegate.getAgentsFiles();\n\t}\n\n\tgetSystemPrompt(): ReturnType<ResourceLoader[\"getSystemPrompt\"]> {\n\t\treturn this.delegate.getSystemPrompt();\n\t}\n\n\tgetSystemPromptSource(): ReturnType<ResourceLoader[\"getSystemPromptSource\"]> {\n\t\treturn this.delegate.getSystemPromptSource();\n\t}\n\n\tgetAppendSystemPrompt(): ReturnType<ResourceLoader[\"getAppendSystemPrompt\"]> {\n\t\treturn this.delegate.getAppendSystemPrompt();\n\t}\n\n\tgetAppendSystemPromptSources(): ReturnType<ResourceLoader[\"getAppendSystemPromptSources\"]> {\n\t\treturn this.delegate.getAppendSystemPromptSources();\n\t}\n\n\textendResources(paths: ResourceExtensionPaths): Promise<void> {\n\t\treturn this.delegate.extendResources(paths);\n\t}\n\n\tasync reload(options?: ResourceLoaderReloadOptions): Promise<void> {\n\t\tawait this.delegate.reload(options);\n\t\tthis.extensionsResult = await restoreMandatoryExtensions(this.delegate.getExtensions(), this.cwd);\n\t\tif (this.toolOnly) this.removeLocalInteractionSurfaces();\n\t}\n\n\tsupportsTransactionalReload(): boolean {\n\t\treturn this.delegate.prepareReload !== undefined && this.delegate.supportsTransactionalReload?.() !== false;\n\t}\n\n\tasync prepareReload(\n\t\tsettingsManager: SettingsManager,\n\t\toptions?: ResourceLoaderReloadOptions,\n\t): Promise<ResourceLoaderReloadTransaction> {\n\t\tif (!this.delegate.prepareReload) {\n\t\t\tthrow new Error(\"Resource loader does not support transactional reload\");\n\t\t}\n\t\tconst delegateTransaction = await this.delegate.prepareReload(settingsManager, options);\n\t\tconst extensionsResult = await restoreMandatoryExtensions(delegateTransaction.loader.getExtensions(), this.cwd);\n\t\tconst candidate = new MandatoryResourceLoader(delegateTransaction.loader, this.cwd, extensionsResult);\n\t\tif (this.toolOnly) candidate.limitToTool();\n\t\tconst prepareCommit = delegateTransaction.prepareCommit\n\t\t\t? () => {\n\t\t\t\t\tconst delegateCommit = delegateTransaction.prepareCommit!();\n\t\t\t\t\tlet settled = false;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcommit: () => {\n\t\t\t\t\t\t\tif (settled) return;\n\t\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\t\tdelegateCommit.commit();\n\t\t\t\t\t\t\tthis.extensionsResult = candidate.extensionsResult;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tif (settled) return;\n\t\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\t\tdelegateCommit.rollback();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tloader: candidate,\n\t\t\tactivate: (liveSettingsManager) => delegateTransaction.activate(liveSettingsManager),\n\t\t\t...(prepareCommit ? { prepareCommit } : {}),\n\t\t\tcommit: () => {\n\t\t\t\tdelegateTransaction.commit();\n\t\t\t\tthis.extensionsResult = candidate.extensionsResult;\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** Preserve caller-owned resources while restoring Atomic's mandatory bundled extension. */\nexport async function withMandatoryResourceLoader(loader: ResourceLoader, cwd: string): Promise<ResourceLoader> {\n\tif (loader instanceof MandatoryResourceLoader) return loader;\n\tconst extensionsResult = await restoreMandatoryExtensions(loader.getExtensions(), cwd);\n\treturn new MandatoryResourceLoader(loader, cwd, extensionsResult);\n}\n\n/** Keep a non-model interactive host from shadowing the engine's command and shortcut proxies. */\nexport function limitMandatoryIntercomToTool(loader: ResourceLoader): void {\n\tif (loader instanceof MandatoryResourceLoader) loader.limitToTool();\n}\n"]}
@@ -10,6 +10,13 @@ export declare class CredentialSynchronizationError extends Error {
10
10
  readonly credential: Credential | undefined;
11
11
  constructor(providerId: string, operation: CredentialSynchronizationOperation, credential: Credential | undefined, options: ErrorOptions);
12
12
  }
13
+ export interface ExtensionProviderTransaction {
14
+ registerNativeProvider(provider: Provider): void;
15
+ registerProvider(providerId: string, config: ProviderConfigInput): void;
16
+ unregisterProvider(providerId: string): void;
17
+ hasConfiguredAuth(providerId: string): boolean;
18
+ commit(): Promise<void>;
19
+ }
13
20
  /** Configured pi-ai Models collection used by coding-agent and SDK consumers. */
14
21
  export declare class ModelRuntime implements Models {
15
22
  private readonly models;
@@ -162,6 +169,7 @@ export declare class ModelRuntime implements Models {
162
169
  */
163
170
  private scheduleRegistrationRefresh;
164
171
  private runRefresh;
172
+ createExtensionProviderTransaction(replacedProviderIds?: Iterable<string>): ExtensionProviderTransaction;
165
173
  registerNativeProvider(provider: Provider): void;
166
174
  registerProvider(providerId: string, config: ProviderConfigInput): void;
167
175
  unregisterProvider(providerId: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAG9B,KAAK,QAAQ,EACb,MAAM,gBAAgB,CAAC;AAuBxB,OAAO,EACN,KAAK,UAAU,EACf,KAAK,0BAA0B,EAG/B,KAAK,mBAAmB,EAGxB,MAAM,wBAAwB,CAAC;AAIhC,YAAY,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAMr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AE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAgBjG;IAEK,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBlF;IAED;;;;;;OAMG;IACH,uBAAuB,IAAI,OAAO,CAEjC;IACK,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE9E;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,2BAA2B;YAMrB,UAAU;IAwCxB,kCAAkC,CAAC,mBAAmB,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,4BAA4B,CA+E3G;IAED,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAO/C;IAED,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CA2CtE;IAED,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAM3C;CACD"}
@@ -654,6 +654,88 @@ export class ModelRuntime {
654
654
  }
655
655
  return { aborted: result.aborted || (options.signal?.aborted ?? false), errors };
656
656
  }
657
+ createExtensionProviderTransaction(replacedProviderIds = []) {
658
+ const nativeProviders = new Map(this.nativeExtensionProviders);
659
+ const providers = new Map(this.extensionProviders);
660
+ for (const providerId of replacedProviderIds) {
661
+ nativeProviders.delete(providerId);
662
+ providers.delete(providerId);
663
+ }
664
+ const configuredProviders = new Set(this.snapshot.configuredProviders);
665
+ for (const providerId of replacedProviderIds)
666
+ configuredProviders.delete(providerId);
667
+ return {
668
+ registerNativeProvider: (provider) => {
669
+ if (!provider.id.trim())
670
+ throw new Error("Provider id must not be empty.");
671
+ providers.delete(provider.id);
672
+ if (this.snapshot.storedProviders.has(provider.id))
673
+ configuredProviders.add(provider.id);
674
+ nativeProviders.set(provider.id, provider);
675
+ },
676
+ registerProvider: (providerId, config) => {
677
+ validateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);
678
+ nativeProviders.delete(providerId);
679
+ const effective = { ...providers.get(providerId) };
680
+ for (const [key, value] of Object.entries(config)) {
681
+ if (value !== undefined)
682
+ effective[key] = value;
683
+ }
684
+ if (this.snapshot.storedProviders.has(providerId) ||
685
+ configuredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured) {
686
+ configuredProviders.add(providerId);
687
+ }
688
+ else
689
+ configuredProviders.delete(providerId);
690
+ providers.set(providerId, effective);
691
+ },
692
+ unregisterProvider: (providerId) => {
693
+ providers.delete(providerId);
694
+ configuredProviders.delete(providerId);
695
+ nativeProviders.delete(providerId);
696
+ },
697
+ hasConfiguredAuth: (providerId) => configuredProviders.has(providerId),
698
+ commit: async () => {
699
+ const previous = {
700
+ extensionProviders: new Map(this.extensionProviders),
701
+ nativeExtensionProviders: new Map(this.nativeExtensionProviders),
702
+ builtins: new Map(this.builtins),
703
+ config: this.config,
704
+ snapshot: this.snapshot,
705
+ compositionErrors: new Map(this.compositionErrors),
706
+ };
707
+ try {
708
+ this.extensionProviders.clear();
709
+ for (const [providerId, config] of providers)
710
+ this.extensionProviders.set(providerId, config);
711
+ this.nativeExtensionProviders.clear();
712
+ for (const [providerId, provider] of nativeProviders)
713
+ this.nativeExtensionProviders.set(providerId, provider);
714
+ this.rebuildProviders();
715
+ this.markCatalogInputsChanged();
716
+ await this.runRefresh({ allowNetwork: false }, ++this.refreshSequence, true);
717
+ }
718
+ catch (error) {
719
+ this.extensionProviders.clear();
720
+ for (const [providerId, config] of previous.extensionProviders)
721
+ this.extensionProviders.set(providerId, config);
722
+ this.nativeExtensionProviders.clear();
723
+ for (const [providerId, provider] of previous.nativeExtensionProviders)
724
+ this.nativeExtensionProviders.set(providerId, provider);
725
+ this.builtins.clear();
726
+ for (const [providerId, provider] of previous.builtins)
727
+ this.builtins.set(providerId, provider);
728
+ this.config = previous.config;
729
+ this.rebuildProviders();
730
+ this.snapshot = previous.snapshot;
731
+ this.compositionErrors.clear();
732
+ for (const [providerId, message] of previous.compositionErrors)
733
+ this.compositionErrors.set(providerId, message);
734
+ throw error;
735
+ }
736
+ },
737
+ };
738
+ }
657
739
  registerNativeProvider(provider) {
658
740
  if (!provider.id.trim())
659
741
  throw new Error("Provider id must not be empty.");
@@ -1 +1 @@
1
- {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAYN,YAAY,GAaZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACN,wBAAwB,EACxB,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC1B,6BAA6B,EAE7B,8BAA8B,EAC9B,gCAAgC,EAChC,gBAAgB,EAChB,oBAAoB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAGN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AQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC;QAC5E,CAAC;QACD,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACpC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\tcreateModels,\n\ttype DeferredHandle,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype MutableModels,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport * as builtinProviderCatalog from \"@bastani/pi-ai/providers/all\";\nimport { getAgentDir } from \"../config.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.js\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS } from \"./model-refresh-timeout.ts\";\nimport {\n\taddRuntimeApiKeyProvider,\n\taddStoredCredentialProvider,\n\tcreateEmptyModelRuntimeSnapshot,\n\tcreateModelRuntimeSnapshot,\n\tgetSnapshotProviderAuthStatus,\n\ttype ModelRuntimeSnapshot,\n\tremoveStoredCredentialProvider,\n\treplaceStoredCredentialProviders,\n\tsnapshotModelKey,\n\tupdateSnapshotModels,\n} from \"./model-runtime-snapshot.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport { collectOAuthProviderMetadata } from \"./oauth-provider-metadata.ts\";\nimport { isOfflineModeEnabled } from \"./package-manager-env.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\n\nexport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nimport { mergeConfiguredAuthHeaders } from \"./model-runtime-auth.ts\";\nimport { configureBuiltinProviders } from \"./model-runtime-providers.ts\";\nimport { canRestoreUnknownModel as canRestoreUnknownModelProvider } from \"./model-runtime-restoration.ts\";\nimport { ModelRuntimeStreaming } from \"./model-runtime-streaming.ts\";\nimport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"saveCredential\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but local model state could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\t// One call rather than assign-then-redefine: the two-step form is\n\t\t// equivalent (defineProperty with only `enumerable` preserves the existing\n\t\t// value) but reads as a redundant write and trips static analysis. The\n\t\t// non-enumerable descriptor is the load-bearing part — it keeps the\n\t\t// credential out of JSON.stringify, console.log, and structured error\n\t\t// reporting.\n\t\tObject.defineProperty(this, \"credential\", {\n\t\t\tvalue: credential,\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly streaming: ModelRuntimeStreaming;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = createEmptyModelRuntimeSnapshot();\n\tprivate snapshotGeneration = 0;\n\tprivate catalogInputsGeneration = 0;\n\tprivate observedModelsFileToken: string | undefined;\n\tprivate readonly externalProviderAuthStatuses = new Map<string, AuthStatus>();\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate availabilityError: string | undefined;\n\tprivate refreshSequence = 0;\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) =>\n\t\t\tthis.getRequestAuth(model, overrides),\n\t\t);\n\t\tthis.rebuildProviders();\n\t}\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.id === \"radius\"\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\t!isOfflineModeEnabled(),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller = refreshFromNetwork ? new AbortController() : undefined;\n\t\tconst timeout = controller\n\t\t\t? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs ?? 15_000)\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal: controller?.signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\tprivate configureRadiusProviders(): void {\n\t\tconfigureBuiltinProviders(this.builtins, this.defaultBuiltins, this.config);\n\t}\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t]);\n\t}\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.models.setProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(composeModelProvider(providerId, base, this.config, extension));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(base);\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\tprivate updateModelSnapshot(): void {\n\t\tthis.snapshotGeneration += 1;\n\t\tthis.snapshot = updateSnapshotModels(this.snapshot, [...this.models.getModels()]);\n\t}\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tthis.snapshot = createModelRuntimeSnapshot([...this.models.getModels()], [...available], checks, credentials);\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq)\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders),\n\t\t\t\tstoredProviders = new Set(this.snapshot.storedProviders),\n\t\t\t\tstoredCredentialTypes = new Map(this.snapshot.storedCredentialTypes),\n\t\t\t\tauthByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) {\n\t\t\t\tstoredProviders.add(providerId);\n\t\t\t\tstoredCredentialTypes.set(providerId, credential.type);\n\t\t\t} else {\n\t\t\t\tstoredProviders.delete(providerId);\n\t\t\t\tstoredCredentialTypes.delete(providerId);\n\t\t\t}\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tstoredCredentialTypes,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\t/** Whether an authenticated provider may reconstruct an absent saved model ID. */\n\tcanRestoreUnknownModel(providerId: string): boolean {\n\t\treturn canRestoreUnknownModelProvider(\n\t\t\tproviderId,\n\t\t\tthis.defaultBuiltins.get(providerId),\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t\tthis.nativeExtensionProviders.get(providerId),\n\t\t);\n\t}\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted)\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\t/** Return stored credential metadata synchronously without refreshing auth. */\n\tgetCredentialSnapshot(providerId: string): Credential | undefined {\n\t\treturn this.credentials.peek(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.streaming.stream(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\t// A provider that was already configured has an availability result — possibly\n\t\t\t// a credential-filtered subset of its catalog, as with an additive GitHub\n\t\t\t// Copilot override — and keeps it until the refresh this registration schedules\n\t\t\t// republishes it. Only a provider this registration newly configures has no\n\t\t\t// result to keep, so only its catalog is exposed provisionally.\n\t\t\tlet available = this.snapshot.available;\n\t\t\tif (!this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t\tconst preserved = new Set(available.map(snapshotModelKey));\n\t\t\t\tavailable = this.snapshot.all.filter(\n\t\t\t\t\t(model) => model.provider === providerId || preserved.has(snapshotModelKey(model)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders, available };\n\t\t}\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n}\n"]}
1
+ {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAYN,YAAY,GAaZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,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IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACpC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACpC,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n\ttype Api,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthOperationOptions,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\tcreateModels,\n\ttype DeferredHandle,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\ttype ModelsDeferredCancelOptions,\n\ttype ModelsDeferredFetchOptions,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype MutableModels,\n\ttype Provider,\n} from \"@bastani/pi-ai\";\nimport * as builtinProviderCatalog from \"@bastani/pi-ai/providers/all\";\nimport { getAgentDir } from \"../config.js\";\nimport { operationSignal, raceWithAbortSignal } from \"../utils/abort.js\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { AuthStorage as DefaultAuthStorage } from \"./auth-storage.ts\";\nimport { ModelConfig } from \"./model-config.ts\";\nimport { POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS } from \"./model-refresh-timeout.ts\";\nimport {\n\taddRuntimeApiKeyProvider,\n\taddStoredCredentialProvider,\n\tcreateEmptyModelRuntimeSnapshot,\n\tcreateModelRuntimeSnapshot,\n\tgetSnapshotProviderAuthStatus,\n\ttype ModelRuntimeSnapshot,\n\tremoveStoredCredentialProvider,\n\treplaceStoredCredentialProviders,\n\tsnapshotModelKey,\n\tupdateSnapshotModels,\n} from \"./model-runtime-snapshot.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport { collectOAuthProviderMetadata } from \"./oauth-provider-metadata.ts\";\nimport { isOfflineModeEnabled } from \"./package-manager-env.ts\";\nimport {\n\ttype AuthStatus,\n\ttype CompatibilityRequestConfig,\n\tcomposeModelProvider,\n\tconfiguredRequestAuthStatus,\n\ttype ProviderConfigInput,\n\tresolveCompatibilityRequestConfig,\n\tvalidateExtensionProvider,\n} from \"./provider-composer.ts\";\nimport { withRemoteCatalog } from \"./remote-catalog-provider.ts\";\nimport { RuntimeCredentials } from \"./runtime-credentials.ts\";\n\nexport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nimport { mergeConfiguredAuthHeaders } from \"./model-runtime-auth.ts\";\nimport { configureBuiltinProviders } from \"./model-runtime-providers.ts\";\nimport { canRestoreUnknownModel as canRestoreUnknownModelProvider } from \"./model-runtime-restoration.ts\";\nimport { ModelRuntimeStreaming } from \"./model-runtime-streaming.ts\";\nimport type { CreateModelRuntimeOptions, ModelRuntimeAuthOverrides } from \"./model-runtime-types.ts\";\n\nexport type CredentialSynchronizationOperation =\n\t| \"login\"\n\t| \"logout\"\n\t| \"saveCredential\"\n\t| \"setRuntimeApiKey\"\n\t| \"removeRuntimeApiKey\";\n\n/** Credentials changed successfully, but local model state could not be synchronized. */\nexport class CredentialSynchronizationError extends Error {\n\treadonly providerId: string;\n\treadonly operation: CredentialSynchronizationOperation;\n\treadonly credential: Credential | undefined;\n\n\tconstructor(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\toptions: ErrorOptions,\n\t) {\n\t\tsuper(`Credential ${operation} committed for ${providerId}, but local synchronization failed`, options);\n\t\tthis.name = \"CredentialSynchronizationError\";\n\t\tthis.providerId = providerId;\n\t\tthis.operation = operation;\n\t\t// One call rather than assign-then-redefine: the two-step form is\n\t\t// equivalent (defineProperty with only `enumerable` preserves the existing\n\t\t// value) but reads as a redundant write and trips static analysis. The\n\t\t// non-enumerable descriptor is the load-bearing part — it keeps the\n\t\t// credential out of JSON.stringify, console.log, and structured error\n\t\t// reporting.\n\t\tObject.defineProperty(this, \"credential\", {\n\t\t\tvalue: credential,\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n}\nexport interface ExtensionProviderTransaction {\n\tregisterNativeProvider(provider: Provider): void;\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void;\n\tunregisterProvider(providerId: string): void;\n\thasConfiguredAuth(providerId: string): boolean;\n\tcommit(): Promise<void>;\n}\n\n/** Configured pi-ai Models collection used by coding-agent and SDK consumers. */\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly streaming: ModelRuntimeStreaming;\n\tprivate readonly defaultBuiltins: ReadonlyMap<string, Provider>;\n\tprivate readonly builtins = new Map<string, Provider>();\n\tprivate readonly nativeExtensionProviders = new Map<string, Provider>();\n\tprivate readonly extensionProviders = new Map<string, ProviderConfigInput>();\n\tprivate readonly compositionErrors = new Map<string, string>();\n\tprivate readonly modelsPath: string | undefined;\n\tprivate readonly modelNetworkEnabled: boolean;\n\tprivate config: ModelConfig;\n\tprivate snapshot: ModelRuntimeSnapshot = createEmptyModelRuntimeSnapshot();\n\tprivate snapshotGeneration = 0;\n\tprivate catalogInputsGeneration = 0;\n\tprivate observedModelsFileToken: string | undefined;\n\tprivate readonly externalProviderAuthStatuses = new Map<string, AuthStatus>();\n\tprivate availabilityRefreshSeq = 0;\n\tprivate availabilityErrorSeq = 0;\n\tprivate readonly providerAvailabilitySeq = new Map<string, number>();\n\tprivate readonly credentialOperations = new Map<string, Promise<unknown>>();\n\tprivate availabilityError: string | undefined;\n\tprivate refreshSequence = 0;\n\tprivate constructor(\n\t\tcredentials: RuntimeCredentials,\n\t\tconfig: ModelConfig,\n\t\tmodelsPath: string | undefined,\n\t\tmodelsStore: ModelsStore,\n\t\tproviders: readonly Provider[],\n\t\tmodelNetworkEnabled: boolean,\n\t) {\n\t\tthis.credentials = credentials;\n\t\tthis.config = config;\n\t\tthis.modelsPath = modelsPath;\n\t\tthis.modelNetworkEnabled = modelNetworkEnabled;\n\t\tthis.defaultBuiltins = new Map(providers.map((provider) => [provider.id, provider]));\n\t\tfor (const [providerId, provider] of this.defaultBuiltins) this.builtins.set(providerId, provider);\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.streaming = new ModelRuntimeStreaming(this.models, (model, overrides) =>\n\t\t\tthis.getRequestAuth(model, overrides),\n\t\t);\n\t\tthis.rebuildProviders();\n\t}\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials(options.credentials ?? DefaultAuthStorage.create(options.authPath));\n\t\tconst modelsPath =\n\t\t\toptions.modelsPath === null ? undefined : (options.modelsPath ?? join(getAgentDir(), \"models.json\"));\n\t\tconst config = await ModelConfig.load(modelsPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(modelsPath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath ?? join(dirname(modelsPath), \"models-store.json\"))\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst builtinModelDataGeneratedAt = builtinProviderCatalog.getBuiltinModelDataGeneratedAt();\n\t\tconst providers = builtinProviderCatalog\n\t\t\t.builtinProviders()\n\t\t\t.map((provider) =>\n\t\t\t\tprovider.id === \"radius\"\n\t\t\t\t\t? provider\n\t\t\t\t\t: withRemoteCatalog(provider, options.catalogBaseUrl, builtinModelDataGeneratedAt),\n\t\t\t);\n\t\tconst runtime = new ModelRuntime(\n\t\t\tcredentials,\n\t\t\tconfig,\n\t\t\tmodelsPath,\n\t\t\tmodelsStore,\n\t\t\tproviders,\n\t\t\t!isOfflineModeEnabled(),\n\t\t);\n\t\truntime.configureRadiusProviders();\n\t\truntime.rebuildProviders();\n\t\tconst refreshFromNetwork = runtime.modelNetworkEnabled && options.allowModelNetwork === true;\n\t\tconst controller = refreshFromNetwork ? new AbortController() : undefined;\n\t\tconst timeout = controller\n\t\t\t? setTimeout(() => controller.abort(), options.modelRefreshTimeoutMs ?? 15_000)\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tif (options.refreshOnCreate !== false) {\n\t\t\t\tawait runtime.refresh({ allowNetwork: refreshFromNetwork, signal: controller?.signal });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t\treturn runtime;\n\t}\n\tprivate configureRadiusProviders(): void {\n\t\tconfigureBuiltinProviders(this.builtins, this.defaultBuiltins, this.config);\n\t}\n\tprivate providerIds(): Set<string> {\n\t\treturn new Set([\n\t\t\t...this.builtins.keys(),\n\t\t\t...this.nativeExtensionProviders.keys(),\n\t\t\t...this.config.getProviderIds(),\n\t\t\t...this.extensionProviders.keys(),\n\t\t]);\n\t}\n\tprivate recomposeProvider(providerId: string): void {\n\t\tconst base = this.nativeExtensionProviders.get(providerId) ?? this.builtins.get(providerId);\n\t\tconst extension = this.extensionProviders.get(providerId);\n\t\tif (!base && !this.config.getProvider(providerId) && !extension) {\n\t\t\tthis.models.deleteProvider(providerId);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\tif (base && !this.config.getProvider(providerId) && !extension) {\n\t\t\t// No overlays: use the builtin untouched so its auth/login/stream behavior is exact.\n\t\t\tthis.models.setProvider(base);\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.models.setProvider(composeModelProvider(providerId, base, this.config, extension));\n\t\t\tthis.compositionErrors.delete(providerId);\n\t\t} catch (error) {\n\t\t\tthis.compositionErrors.set(providerId, error instanceof Error ? error.message : String(error));\n\t\t\tif (base) this.models.setProvider(base);\n\t\t\telse this.models.deleteProvider(providerId);\n\t\t}\n\t}\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tthis.compositionErrors.clear();\n\t\tfor (const providerId of this.providerIds()) this.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t}\n\tprivate updateModelSnapshot(): void {\n\t\tthis.snapshotGeneration += 1;\n\t\tthis.snapshot = updateSnapshotModels(this.snapshot, [...this.models.getModels()]);\n\t}\n\tprivate async runAvailabilityRefresh(seq: number, errorSeq: number, signal: AbortSignal): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst [available, checks, credentials] = await Promise.all([\n\t\t\tthis.models.getAvailable(undefined, { signal }),\n\t\t\tPromise.all(\n\t\t\t\tproviders.map(\n\t\t\t\t\tasync (provider): Promise<[string, AuthCheck | undefined]> => [\n\t\t\t\t\t\tprovider.id,\n\t\t\t\t\t\tawait this.models.checkAuth(provider.id, { signal }),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t),\n\t\t\tthis.credentials.list({ signal }),\n\t\t]);\n\t\tif (seq !== this.availabilityRefreshSeq) return;\n\t\tthis.snapshot = createModelRuntimeSnapshot([...this.models.getModels()], [...available], checks, credentials);\n\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t}\n\tprivate queueAvailabilityRefresh(signal?: AbortSignal): Promise<void> {\n\t\tconst seq = ++this.availabilityRefreshSeq;\n\t\tfor (const [providerId, providerSeq] of this.providerAvailabilitySeq)\n\t\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq + 1);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\tconst effectiveSignal = operationSignal(signal);\n\t\treturn this.runAvailabilityRefresh(seq, errorSeq, effectiveSignal).catch((error) => {\n\t\t\tif (errorSeq === this.availabilityErrorSeq && !effectiveSignal.aborted)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\tprivate async refreshProviderAvailability(providerId: string, signal: AbortSignal): Promise<void> {\n\t\t++this.availabilityRefreshSeq;\n\t\tconst providerSeq = (this.providerAvailabilitySeq.get(providerId) ?? 0) + 1;\n\t\tthis.providerAvailabilitySeq.set(providerId, providerSeq);\n\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\ttry {\n\t\t\tconst [available, auth, credential] = await Promise.all([\n\t\t\t\tthis.models.getAvailable(providerId, { signal }),\n\t\t\t\tthis.models.checkAuth(providerId, { signal }),\n\t\t\t\tthis.credentials.read(providerId, { signal }),\n\t\t\t]);\n\t\t\tsignal.throwIfAborted();\n\t\t\tif (this.providerAvailabilitySeq.get(providerId) !== providerSeq) return;\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders),\n\t\t\t\tstoredProviders = new Set(this.snapshot.storedProviders),\n\t\t\t\tstoredCredentialTypes = new Map(this.snapshot.storedCredentialTypes),\n\t\t\t\tauthByProvider = new Map(this.snapshot.auth);\n\t\t\tif (auth) {\n\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\tauthByProvider.set(providerId, auth);\n\t\t\t} else {\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tauthByProvider.delete(providerId);\n\t\t\t}\n\t\t\tif (credential) {\n\t\t\t\tstoredProviders.add(providerId);\n\t\t\t\tstoredCredentialTypes.set(providerId, credential.type);\n\t\t\t} else {\n\t\t\t\tstoredProviders.delete(providerId);\n\t\t\t\tstoredCredentialTypes.delete(providerId);\n\t\t\t}\n\t\t\tconst all = [...this.models.getModels()];\n\t\t\tconst availableById = new Map(\n\t\t\t\t[...this.snapshot.available.filter((model) => model.provider !== providerId), ...available].map((model) => [\n\t\t\t\t\t`${model.provider}\\0${model.id}`,\n\t\t\t\t\tmodel,\n\t\t\t\t]),\n\t\t\t);\n\t\t\tthis.snapshot = {\n\t\t\t\tall,\n\t\t\t\tavailable: all.flatMap((model) => availableById.get(`${model.provider}\\0${model.id}`) ?? []),\n\t\t\t\tconfiguredProviders,\n\t\t\t\tstoredProviders,\n\t\t\t\tstoredCredentialTypes,\n\t\t\t\tauth: authByProvider,\n\t\t\t};\n\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\tthis.providerAvailabilitySeq.get(providerId) === providerSeq &&\n\t\t\t\terrorSeq === this.availabilityErrorSeq &&\n\t\t\t\t!signal.aborted\n\t\t\t)\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\t/** Whether an authenticated provider may reconstruct an absent saved model ID. */\n\tcanRestoreUnknownModel(providerId: string): boolean {\n\t\treturn canRestoreUnknownModelProvider(\n\t\t\tproviderId,\n\t\t\tthis.defaultBuiltins.get(providerId),\n\t\t\tthis.config.getProvider(providerId),\n\t\t\tthis.extensionProviders.get(providerId),\n\t\t\tthis.nativeExtensionProviders.get(providerId),\n\t\t);\n\t}\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\tasync getAvailable(providerId?: string, options?: AuthOperationOptions): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tconst errorSeq = ++this.availabilityErrorSeq;\n\t\t\ttry {\n\t\t\t\tconst available = await this.models.getAvailable(providerId, options);\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq) this.availabilityError = undefined;\n\t\t\t\treturn available;\n\t\t\t} catch (error) {\n\t\t\t\tif (errorSeq === this.availabilityErrorSeq && !options?.signal?.aborted)\n\t\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.queueAvailabilityRefresh(options?.signal);\n\t\treturn this.snapshot.available;\n\t}\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\tgetError(): string | undefined {\n\t\tconst errors: string[] = [];\n\t\tconst configError = this.config.getError();\n\t\tif (configError) errors.push(configError);\n\t\tfor (const [providerId, error] of this.compositionErrors) {\n\t\t\terrors.push(`Provider \"${providerId}\": ${error}`);\n\t\t}\n\t\tif (this.availabilityError) errors.push(`Availability refresh: ${this.availabilityError}`);\n\t\treturn errors.length > 0 ? errors.join(\"\\n\\n\") : undefined;\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfigInput | undefined {\n\t\treturn this.extensionProviders.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn [...new Set([...this.extensionProviders.keys(), ...this.nativeExtensionProviders.keys()])];\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.nativeExtensionProviders.get(providerId);\n\t}\n\tgetOAuthProviderMetadata() {\n\t\treturn collectOAuthProviderMetadata(this.getProviders(), this.extensionProviders);\n\t}\n\t/** @internal Compatibility fallback for ModelRegistry when provider auth is unconfigured. */\n\tgetCompatibilityRequestConfig(model: Model<Api>): CompatibilityRequestConfig {\n\t\treturn resolveCompatibilityRequestConfig(\n\t\t\tmodel,\n\t\t\tthis.config.getProvider(model.provider),\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t);\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\t/** Return stored credential metadata synchronously without refreshing auth. */\n\tgetCredentialSnapshot(providerId: string): Credential | undefined {\n\t\treturn this.credentials.peek(providerId);\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\tconst resolution = await this.models.getAuth(providerOrModel, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tproviderOrModel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(providerOrModel.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Resolve request-owned auth/config headers without copying the model's static\n\t * catalog headers into the per-request override layer. The API provider reads\n\t * static headers from the model itself; duplicating them in auth would make\n\t * them override API-computed defaults that intentionally replace catalog values.\n\t */\n\tasync getRequestAuth(model: Model<Api>, overrides: ModelRuntimeAuthOverrides = {}): Promise<AuthResult | undefined> {\n\t\tconst resolution = await this.getAuth(model.provider, overrides);\n\t\tif (!resolution) return undefined;\n\t\treturn mergeConfiguredAuthHeaders(\n\t\t\tresolution,\n\t\t\tmodel,\n\t\t\tthis.config,\n\t\t\tthis.extensionProviders.get(model.provider),\n\t\t\toverrides,\n\t\t);\n\t}\n\n\t/**\n\t * Monotonic count of changes to any input a catalog refresh reads.\n\t *\n\t * `refresh()` reloads models.json, recomposes every provider from it, the\n\t * extension registrations, and the builtin catalog, resolves credentials as\n\t * it runs, and publishes ONE snapshot at the end. So a pass belongs to the\n\t * inputs it started under, and joining a pass across a bump is unsound in\n\t * both directions: the joiner reads models and credentials the user has\n\t * already replaced, and the pass's late publish overwrites the newer state\n\t * with them.\n\t *\n\t * Every mutation source bumps this counter, which is why callers need only\n\t * this one number rather than a growing tuple of per-input keys:\n\t *\n\t * - credential writes — `login`, `logout`, `saveCredential`,\n\t * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external\n\t * `reloadCredentials`, and an applied external auth status;\n\t * - provider registrations — `registerProvider`, `registerNativeProvider`,\n\t * and `unregisterProvider`, through the refresh they schedule;\n\t * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,\n\t * model definitions, and overrides, which every pass reloads.\n\t *\n\t * The first two are this runtime's own writes and bump where they happen.\n\t * The third is an external edit nothing here observes, so reading the\n\t * generation samples the file and bumps when its content moved since the\n\t * last sample. That read is synchronous so the answer belongs to the same\n\t * tick as the decision that depends on it, and it hashes content rather\n\t * than trusting an mtime: a same-size rewrite inside one filesystem\n\t * timestamp tick — an edited key, a renamed model — is exactly the change a\n\t * shared pass must not hide.\n\t */\n\tgetCatalogInputsGeneration(): number {\n\t\tthis.observeModelsFile();\n\t\treturn this.catalogInputsGeneration;\n\t}\n\n\t/**\n\t * Record that an input a catalog refresh reads changed. Every pass started\n\t * before this call answers for inputs that no longer exist.\n\t */\n\tprivate markCatalogInputsChanged(): void {\n\t\tthis.catalogInputsGeneration += 1;\n\t}\n\n\t/** Bump the generation when models.json changed since the last observation. */\n\tprivate observeModelsFile(): void {\n\t\tconst token = this.readModelsFileToken();\n\t\tif (this.observedModelsFileToken === token) return;\n\t\tconst first = this.observedModelsFileToken === undefined;\n\t\tthis.observedModelsFileToken = token;\n\t\t// The first observation is a baseline, not a change: no pass can predate it.\n\t\tif (!first) this.markCatalogInputsChanged();\n\t}\n\n\tprivate readModelsFileToken(): string {\n\t\tif (!this.modelsPath) return \"none\";\n\t\ttry {\n\t\t\treturn createHash(\"sha1\")\n\t\t\t\t.update(readFileSync(normalizePath(this.modelsPath)))\n\t\t\t\t.digest(\"hex\");\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\t// An absent file is a stable state passes can share; any other read\n\t\t\t// failure keys on its own code rather than pretending the file is empty.\n\t\t\treturn code === \"ENOENT\" ? \"absent\" : `unreadable:${code ?? \"unknown\"}`;\n\t\t}\n\t}\n\n\t/** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */\n\tasync reloadCredentials(options: { refreshAvailability?: boolean } = {}): Promise<void> {\n\t\tawait this.credentials.reload();\n\t\tthis.markCatalogInputsChanged();\n\t\tif (options.refreshAvailability === false) {\n\t\t\tconst credentials = await this.credentials.list();\n\t\t\tfor (const credential of credentials) this.externalProviderAuthStatuses.delete(credential.providerId);\n\t\t\tthis.snapshotGeneration += 1;\n\t\t\tthis.snapshot = replaceStoredCredentialProviders(this.snapshot, credentials);\n\t\t\treturn;\n\t\t}\n\t\tawait this.queueAvailabilityRefresh();\n\t}\n\n\tprivate assertCredentialRefreshSucceeded(\n\t\tproviderId: string,\n\t\tresult: ModelsRefreshResult,\n\t\tsignal?: AbortSignal,\n\t): void {\n\t\tif (result.aborted) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tthrow new Error(`Model refresh aborted for ${providerId}`);\n\t\t}\n\t\tconst refreshError = result.errors.get(providerId);\n\t\tif (refreshError) throw refreshError;\n\t\tconst compositionError = this.compositionErrors.get(providerId);\n\t\tif (compositionError) throw new Error(compositionError);\n\t}\n\n\tprivate enqueueCredentialOperation<T>(providerId: string, signal: AbortSignal, task: () => Promise<T>): Promise<T> {\n\t\tconst previous = this.credentialOperations.get(providerId) ?? Promise.resolve();\n\t\tlet markStarted: (() => void) | undefined;\n\t\tconst started = new Promise<void>((resolve) => {\n\t\t\tmarkStarted = resolve;\n\t\t});\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\tsignal.throwIfAborted();\n\t\t\tmarkStarted?.();\n\t\t\treturn task();\n\t\t})();\n\t\tconst tail = operation.catch(() => {});\n\t\tthis.credentialOperations.set(providerId, tail);\n\t\tvoid tail.then(() => {\n\t\t\tif (this.credentialOperations.get(providerId) === tail) this.credentialOperations.delete(providerId);\n\t\t});\n\t\treturn raceWithAbortSignal(started, signal).then(() => operation);\n\t}\n\tprivate async synchronizeCredentialState(\n\t\tproviderId: string,\n\t\toperation: CredentialSynchronizationOperation,\n\t\tcredential: Credential | undefined,\n\t\tsynchronize: () => void | Promise<void>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait synchronize();\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof CredentialSynchronizationError) throw cause;\n\t\t\tthrow new CredentialSynchronizationError(providerId, operation, credential, { cause });\n\t\t}\n\t}\n\tprivate async refreshRemainingAuthAfterLogout(providerId: string, logoutGeneration: number): Promise<void> {\n\t\t// Environment/runtime auth can remain after stored auth is removed. The\n\t\t// probe is normally synchronous, but its deadline is authoritative because\n\t\t// extension checks are third-party code and need not honor cancellation.\n\t\tlet timeout: number | undefined;\n\t\ttry {\n\t\t\tconst remainingAuth = await Promise.race([\n\t\t\t\tthis.checkAuth(providerId).catch(() => undefined),\n\t\t\t\tnew Promise<undefined>((resolve) => {\n\t\t\t\t\ttimeout = setTimeout(resolve, POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS);\n\t\t\t\t}),\n\t\t\t]);\n\t\t\tif (logoutGeneration === this.snapshotGeneration && !this.snapshot.storedProviders.has(providerId)) {\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (timeout) clearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync saveCredential(providerId: string, credential: Credential): Promise<void> {\n\t\tconst signal = operationSignal(undefined);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.credentials.modify(providerId, async () => credential);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"saveCredential\", credential, async () => {\n\t\t\t\tconst result = await this.refresh({ providers: [providerId] });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result);\n\t\t\t});\n\t\t});\n\t}\n\t/**\n\t * Apply a process-scoped API key override. This publishes the provider against\n\t * the current snapshot and deliberately does not refresh the model catalog;\n\t * callers needing catalog freshness call refresh({ providers: [providerId], signal })\n\t * separately.\n\t */\n\tasync setRuntimeApiKey(providerId: string, apiKey: string, options: AuthOperationOptions): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"setRuntimeApiKey\", { type: \"api_key\", key: apiKey }, () => {\n\t\t\t\tthis.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);\n\t\t\t});\n\t\t});\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tawait this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"removeRuntimeApiKey\", undefined, async () => {\n\t\t\t\tconst result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });\n\t\t\t\tthis.assertCredentialRefreshSucceeded(providerId, result, signal);\n\t\t\t});\n\t\t});\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tgetStoredCredentialType(providerId: string): CredentialInfo[\"type\"] | undefined {\n\t\treturn this.snapshot.storedCredentialTypes.get(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): AuthStatus {\n\t\tconst localStatus = getSnapshotProviderAuthStatus(\n\t\t\tthis.snapshot,\n\t\t\tproviderId,\n\t\t\tthis.credentials.hasRuntimeApiKey(providerId),\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), this.extensionProviders.get(providerId)),\n\t\t);\n\t\tif (localStatus.source === \"stored\" || localStatus.source === \"runtime\") return localStatus;\n\t\treturn this.externalProviderAuthStatuses.get(providerId) ?? localStatus;\n\t}\n\n\t/** Apply authoritative auth state returned by an isolated engine mutation. */\n\tapplyExternalProviderAuthStatus(providerId: string, status: AuthStatus): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tthis.snapshotGeneration += 1;\n\t\tconst remainingAuth =\n\t\t\tstatus.configured && status.source === \"environment\"\n\t\t\t\t? ({ type: \"api_key\", source: status.label ?? \"environment\" } as const)\n\t\t\t\t: undefined;\n\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId, remainingAuth);\n\t\tthis.externalProviderAuthStatuses.set(providerId, status);\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn this.streaming.stream(model, context, options);\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.complete(model, context, options);\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn this.streaming.streamSimple(model, context, options);\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streaming.completeSimple(model, context, options);\n\t}\n\n\tfetchDeferred(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: ModelsDeferredFetchOptions,\n\t): Promise<AssistantMessage> {\n\t\treturn this.streaming.fetchDeferred(model, handle, options);\n\t}\n\n\tcancelDeferred(model: Model<Api>, handle: DeferredHandle, options?: ModelsDeferredCancelOptions): Promise<void> {\n\t\treturn this.streaming.cancelDeferred(model, handle, options);\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\tconst signal = operationSignal(interaction.signal);\n\t\treturn this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tconst credential = await this.models.login(providerId, type, { ...interaction, signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tawait this.synchronizeCredentialState(providerId, \"login\", credential, () => {\n\t\t\t\t// Credential acquisition and persistence are the login transaction. Publish\n\t\t\t\t// the provider against the current snapshot immediately; catalog restoration,\n\t\t\t\t// ambient availability checks, and networking belong to /model's bounded\n\t\t\t\t// background refresh and must never keep a successful login dialog open.\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = addStoredCredentialProvider(this.snapshot, providerId, credential.type);\n\t\t\t});\n\t\t\treturn credential;\n\t\t});\n\t}\n\n\tasync logout(providerId: string, options: AuthOperationOptions = {}): Promise<void> {\n\t\tconst signal = operationSignal(options.signal);\n\t\tconst logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {\n\t\t\tawait this.models.logout(providerId, { signal });\n\t\t\tthis.markCatalogInputsChanged();\n\t\t\tlet generation = 0;\n\t\t\tawait this.synchronizeCredentialState(providerId, \"logout\", undefined, () => {\n\t\t\t\t// Reset credential-dependent compatibility projections, then publish the\n\t\t\t\t// persisted deletion without waiting for model stores or remote catalogs.\n\t\t\t\tthis.recomposeProvider(providerId);\n\t\t\t\tthis.updateModelSnapshot();\n\t\t\t\tthis.externalProviderAuthStatuses.delete(providerId);\n\t\t\t\tthis.snapshot = removeStoredCredentialProvider(this.snapshot, providerId);\n\t\t\t\tgeneration = this.snapshotGeneration;\n\t\t\t});\n\t\t\treturn generation;\n\t\t});\n\t\tawait this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);\n\t}\n\n\t/**\n\t * The network policy a refresh with an omitted `allowNetwork` resolves to.\n\t *\n\t * Callers that share one in-flight refresh key on the effective policy, so\n\t * they need the same answer `runRefresh` computes rather than a second guess\n\t * at the offline setting this runtime was created under.\n\t */\n\tisNetworkRefreshEnabled(): boolean {\n\t\treturn this.modelNetworkEnabled;\n\t}\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\treturn this.runRefresh(options, ++this.refreshSequence);\n\t}\n\n\t/**\n\t * A registration's offline catalog pass must not publish after a newer refresh\n\t * that resolves configured credentials.\n\t *\n\t * The registration is also a catalog-input change: it adds, replaces, or drops\n\t * a provider every later pass composes from, so no pass that predates it can\n\t * answer for the provider set a caller now sees.\n\t */\n\tprivate scheduleRegistrationRefresh(): void {\n\t\tthis.markCatalogInputsChanged();\n\t\tconst sequence = ++this.refreshSequence;\n\t\tvoid this.runRefresh({ allowNetwork: false }, sequence, true);\n\t}\n\n\tprivate async runRefresh(\n\t\toptions: ModelsRefreshOptions,\n\t\tsequence: number,\n\t\tdiscardIfSuperseded = false,\n\t): Promise<ModelsRefreshResult> {\n\t\tconst config = await ModelConfig.load(this.modelsPath);\n\t\tif (discardIfSuperseded && sequence !== this.refreshSequence) {\n\t\t\treturn { aborted: true, errors: new Map<string, Error>() };\n\t\t}\n\t\tthis.config = config;\n\t\tthis.configureRadiusProviders();\n\t\tif (options.providers) {\n\t\t\tfor (const providerId of new Set(options.providers)) this.recomposeProvider(providerId);\n\t\t\tthis.updateModelSnapshot();\n\t\t} else this.rebuildProviders();\n\t\tconst refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };\n\t\tconst result = await this.models.refresh(refreshOptions);\n\t\tconst errors = new Map(result.errors);\n\t\tthis.updateModelSnapshot();\n\t\tif (options.providers) {\n\t\t\tawait Promise.all(\n\t\t\t\t[...new Set(options.providers)].map(async (providerId) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.refreshProviderAvailability(providerId, operationSignal(options.signal));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!options.signal?.aborted)\n\t\t\t\t\t\t\terrors.set(providerId, error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait this.queueAvailabilityRefresh(options.signal);\n\t\t\t} catch {\n\t\t\t\t// Availability errors are recorded by the latest pass; refreshed models remain usable.\n\t\t\t}\n\t\t}\n\t\treturn { aborted: result.aborted || (options.signal?.aborted ?? false), errors };\n\t}\n\n\tcreateExtensionProviderTransaction(replacedProviderIds: Iterable<string> = []): ExtensionProviderTransaction {\n\t\tconst nativeProviders = new Map(this.nativeExtensionProviders);\n\t\tconst providers = new Map(this.extensionProviders);\n\t\tfor (const providerId of replacedProviderIds) {\n\t\t\tnativeProviders.delete(providerId);\n\t\t\tproviders.delete(providerId);\n\t\t}\n\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders);\n\t\tfor (const providerId of replacedProviderIds) configuredProviders.delete(providerId);\n\t\treturn {\n\t\t\tregisterNativeProvider: (provider) => {\n\t\t\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\t\t\tproviders.delete(provider.id);\n\t\t\t\tif (this.snapshot.storedProviders.has(provider.id)) configuredProviders.add(provider.id);\n\t\t\t\tnativeProviders.set(provider.id, provider);\n\t\t\t},\n\t\t\tregisterProvider: (providerId, config) => {\n\t\t\t\tvalidateExtensionProvider(\n\t\t\t\t\tproviderId,\n\t\t\t\t\tthis.builtins.get(providerId),\n\t\t\t\t\tthis.config.getProvider(providerId),\n\t\t\t\t\tconfig,\n\t\t\t\t);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t\tconst effective: ProviderConfigInput = { ...providers.get(providerId) };\n\t\t\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t\t\t) {\n\t\t\t\t\tconfiguredProviders.add(providerId);\n\t\t\t\t} else configuredProviders.delete(providerId);\n\t\t\t\tproviders.set(providerId, effective);\n\t\t\t},\n\t\t\tunregisterProvider: (providerId) => {\n\t\t\t\tproviders.delete(providerId);\n\t\t\t\tconfiguredProviders.delete(providerId);\n\t\t\t\tnativeProviders.delete(providerId);\n\t\t\t},\n\t\t\thasConfiguredAuth: (providerId) => configuredProviders.has(providerId),\n\t\t\tcommit: async () => {\n\t\t\t\tconst previous = {\n\t\t\t\t\textensionProviders: new Map(this.extensionProviders),\n\t\t\t\t\tnativeExtensionProviders: new Map(this.nativeExtensionProviders),\n\t\t\t\t\tbuiltins: new Map(this.builtins),\n\t\t\t\t\tconfig: this.config,\n\t\t\t\t\tsnapshot: this.snapshot,\n\t\t\t\t\tcompositionErrors: new Map(this.compositionErrors),\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of providers) this.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of nativeProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.markCatalogInputsChanged();\n\t\t\t\t\tawait this.runRefresh({ allowNetwork: false }, ++this.refreshSequence, true);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.extensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, config] of previous.extensionProviders)\n\t\t\t\t\t\tthis.extensionProviders.set(providerId, config);\n\t\t\t\t\tthis.nativeExtensionProviders.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.nativeExtensionProviders)\n\t\t\t\t\t\tthis.nativeExtensionProviders.set(providerId, provider);\n\t\t\t\t\tthis.builtins.clear();\n\t\t\t\t\tfor (const [providerId, provider] of previous.builtins) this.builtins.set(providerId, provider);\n\t\t\t\t\tthis.config = previous.config;\n\t\t\t\t\tthis.rebuildProviders();\n\t\t\t\t\tthis.snapshot = previous.snapshot;\n\t\t\t\t\tthis.compositionErrors.clear();\n\t\t\t\t\tfor (const [providerId, message] of previous.compositionErrors)\n\t\t\t\t\t\tthis.compositionErrors.set(providerId, message);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tif (!provider.id.trim()) throw new Error(\"Provider id must not be empty.\");\n\t\tthis.extensionProviders.delete(provider.id);\n\t\tthis.nativeExtensionProviders.set(provider.id, provider);\n\t\tthis.recomposeProvider(provider.id);\n\t\tthis.updateModelSnapshot();\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfigInput): void {\n\t\t// Validate the incoming registration on its own, like the legacy registry:\n\t\t// a broken re-registration must throw without touching the stored config.\n\t\tvalidateExtensionProvider(providerId, this.builtins.get(providerId), this.config.getProvider(providerId), config);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\t// Re-registration merges defined values over the previous registration and\n\t\t// preserves undefined ones, matching the legacy ModelRegistry contract.\n\t\tconst previous = this.extensionProviders.get(providerId);\n\t\tconst effective: ProviderConfigInput = { ...previous };\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value !== undefined) (effective as Record<string, unknown>)[key] = value;\n\t\t}\n\t\tthis.extensionProviders.set(providerId, effective);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tif (\n\t\t\tthis.snapshot.storedProviders.has(providerId) ||\n\t\t\tconfiguredRequestAuthStatus(this.config.getProvider(providerId), effective)?.configured\n\t\t) {\n\t\t\tconst configuredProviders = new Set(this.snapshot.configuredProviders).add(providerId);\n\t\t\tconst auth = new Map(this.snapshot.auth);\n\t\t\t// Provisional entry until the async refresh lands; never clobber a real check result.\n\t\t\tif (!auth.get(providerId)) {\n\t\t\t\tauth.set(providerId, {\n\t\t\t\t\ttype: effective.oauth && !effective.apiKey ? \"oauth\" : \"api_key\",\n\t\t\t\t\tsource: \"configured provider\",\n\t\t\t\t});\n\t\t\t}\n\t\t\t// A provider that was already configured has an availability result — possibly\n\t\t\t// a credential-filtered subset of its catalog, as with an additive GitHub\n\t\t\t// Copilot override — and keeps it until the refresh this registration schedules\n\t\t\t// republishes it. Only a provider this registration newly configures has no\n\t\t\t// result to keep, so only its catalog is exposed provisionally.\n\t\t\tlet available = this.snapshot.available;\n\t\t\tif (!this.snapshot.configuredProviders.has(providerId)) {\n\t\t\t\tconst preserved = new Set(available.map(snapshotModelKey));\n\t\t\t\tavailable = this.snapshot.all.filter(\n\t\t\t\t\t(model) => model.provider === providerId || preserved.has(snapshotModelKey(model)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.snapshot = { ...this.snapshot, auth, configuredProviders, available };\n\t\t}\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.extensionProviders.delete(providerId);\n\t\tthis.nativeExtensionProviders.delete(providerId);\n\t\tthis.recomposeProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tthis.scheduleRegistrationRefresh();\n\t}\n}\n"]}