@bastani/atomic 0.9.13 → 0.9.14-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 (762) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +3 -3
  3. package/dist/builtin/intercom/package.json +2 -2
  4. package/dist/builtin/mcp/package.json +3 -3
  5. package/dist/builtin/subagents/CHANGELOG.md +14 -0
  6. package/dist/builtin/subagents/README.md +6 -4
  7. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  8. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  9. package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
  11. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
  12. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  13. package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
  14. package/dist/builtin/subagents/agents/debugger.md +1 -1
  15. package/dist/builtin/subagents/agents/worker.md +1 -1
  16. package/dist/builtin/subagents/package.json +6 -5
  17. package/dist/builtin/subagents/src/agents/agent-discovery.ts +17 -11
  18. package/dist/builtin/subagents/src/agents/agent-loaders.ts +115 -43
  19. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +10 -8
  20. package/dist/builtin/subagents/src/agents/agent-management.ts +8 -7
  21. package/dist/builtin/subagents/src/agents/agent-overrides.ts +2 -2
  22. package/dist/builtin/subagents/src/agents/agent-scope.ts +1 -1
  23. package/dist/builtin/subagents/src/agents/agent-selection.ts +1 -1
  24. package/dist/builtin/subagents/src/agents/agent-serializer.ts +24 -3
  25. package/dist/builtin/subagents/src/agents/agent-types.ts +3 -1
  26. package/dist/builtin/subagents/src/agents/agents.ts +7 -5
  27. package/dist/builtin/subagents/src/agents/frontmatter.ts +67 -22
  28. package/dist/builtin/subagents/src/agents/identity.ts +1 -1
  29. package/dist/builtin/subagents/src/agents/skills-paths.ts +1 -1
  30. package/dist/builtin/subagents/src/agents/skills.ts +64 -6
  31. package/dist/builtin/subagents/src/extension/config.ts +1 -1
  32. package/dist/builtin/subagents/src/extension/control-notices.ts +2 -2
  33. package/dist/builtin/subagents/src/extension/doctor.ts +15 -5
  34. package/dist/builtin/subagents/src/extension/fanout-child.ts +12 -12
  35. package/dist/builtin/subagents/src/extension/index.ts +23 -23
  36. package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
  37. package/dist/builtin/subagents/src/extension/schemas.ts +1 -1
  38. package/dist/builtin/subagents/src/extension/startup-maintenance.ts +3 -3
  39. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +3 -3
  40. package/dist/builtin/subagents/src/intercom/result-intercom.ts +1 -1
  41. package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +1 -1
  42. package/dist/builtin/subagents/src/runs/foreground/completion-notification.ts +2 -2
  43. package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +1 -1
  44. package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +3 -3
  45. package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +1 -1
  46. package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +2 -2
  47. package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +1 -1
  48. package/dist/builtin/subagents/src/runs/foreground/execution.ts +2 -2
  49. package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +27 -11
  50. package/dist/builtin/subagents/src/runs/foreground/notify.ts +3 -3
  51. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +11 -11
  52. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +3 -3
  53. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +15 -14
  54. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +19 -19
  55. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +2 -2
  56. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +14 -13
  57. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +9 -9
  58. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +7 -7
  59. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +6 -6
  60. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +24 -23
  61. package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +1 -1
  62. package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +3 -3
  63. package/dist/builtin/subagents/src/runs/inprocess/index.ts +3 -3
  64. package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +17 -8
  65. package/dist/builtin/subagents/src/runs/inprocess/runner.ts +60 -12
  66. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +8 -8
  67. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-control.ts +3 -3
  68. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +4 -4
  69. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +4 -4
  70. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-registry.ts +5 -5
  71. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-rendering.ts +3 -3
  72. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +3 -3
  73. package/dist/builtin/subagents/src/runs/inprocess.ts +1 -1
  74. package/dist/builtin/subagents/src/runs/shared/long-running-guard.ts +1 -1
  75. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
  76. package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +3 -3
  77. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +2 -2
  78. package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +1 -1
  79. package/dist/builtin/subagents/src/runs/shared/single-output.ts +1 -1
  80. package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +1 -1
  81. package/dist/builtin/subagents/src/shared/artifacts.ts +2 -2
  82. package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +1 -1
  83. package/dist/builtin/subagents/src/shared/fast-mode.ts +1 -1
  84. package/dist/builtin/subagents/src/shared/formatters.ts +2 -2
  85. package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -1
  86. package/dist/builtin/subagents/src/shared/model-resolution.ts +1 -1
  87. package/dist/builtin/subagents/src/shared/session-tokens.ts +1 -1
  88. package/dist/builtin/subagents/src/shared/settings.ts +4 -4
  89. package/dist/builtin/subagents/src/shared/status-format.ts +1 -1
  90. package/dist/builtin/subagents/src/shared/types-config.ts +16 -4
  91. package/dist/builtin/subagents/src/shared/types-depth.ts +1 -1
  92. package/dist/builtin/subagents/src/shared/types-nested.ts +1 -1
  93. package/dist/builtin/subagents/src/shared/types-output.ts +1 -1
  94. package/dist/builtin/subagents/src/shared/types-results.ts +1 -1
  95. package/dist/builtin/subagents/src/shared/types-runtime.ts +1 -1
  96. package/dist/builtin/subagents/src/shared/types.ts +6 -6
  97. package/dist/builtin/subagents/src/shared/utils.ts +3 -3
  98. package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +1 -1
  99. package/dist/builtin/subagents/src/slash/slash-bridge.ts +3 -3
  100. package/dist/builtin/subagents/src/slash/slash-commands.ts +6 -6
  101. package/dist/builtin/subagents/src/slash/slash-live-state.ts +3 -3
  102. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
  103. package/dist/builtin/subagents/src/tui/render-layout.ts +1 -1
  104. package/dist/builtin/subagents/src/tui/render-progress.ts +2 -2
  105. package/dist/builtin/subagents/src/tui/render-result-compact.ts +7 -7
  106. package/dist/builtin/subagents/src/tui/render-result.ts +10 -10
  107. package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -1
  108. package/dist/builtin/subagents/src/tui/render-status-progress.ts +5 -5
  109. package/dist/builtin/subagents/src/tui/render.ts +4 -4
  110. package/dist/builtin/web-access/package.json +2 -2
  111. package/dist/builtin/workflows/CHANGELOG.md +57 -0
  112. package/dist/builtin/workflows/README.md +39 -8
  113. package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +16 -5
  114. package/dist/builtin/workflows/builtin/adversarial-verification.ts +4 -0
  115. package/dist/builtin/workflows/builtin/classify-and-act.ts +4 -0
  116. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +4 -0
  117. package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +12 -4
  118. package/dist/builtin/workflows/builtin/generate-and-filter.ts +4 -0
  119. package/dist/builtin/workflows/builtin/goal-models.ts +8 -10
  120. package/dist/builtin/workflows/builtin/goal.ts +4 -0
  121. package/dist/builtin/workflows/builtin/index.d.ts +0 -4
  122. package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +4 -2
  123. package/dist/builtin/workflows/builtin/loop-until-done.ts +4 -0
  124. package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +305 -0
  125. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +115 -171
  126. package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +9 -25
  127. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +19 -86
  128. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -6
  129. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +0 -5
  130. package/dist/builtin/workflows/builtin/open-claude-design.ts +11 -15
  131. package/dist/builtin/workflows/builtin/ralph-models.ts +24 -29
  132. package/dist/builtin/workflows/builtin/ralph.ts +4 -0
  133. package/dist/builtin/workflows/builtin/tournament-runner.ts +6 -3
  134. package/dist/builtin/workflows/builtin/tournament.ts +4 -0
  135. package/dist/builtin/workflows/package.json +2 -2
  136. package/dist/builtin/workflows/skills/impeccable/SKILL.md +3 -3
  137. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +25 -31
  138. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +1 -0
  139. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +16 -10
  140. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +2 -2
  141. package/dist/builtin/workflows/skills/impeccable/reference/android.md +6 -0
  142. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +3 -0
  143. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +3 -1
  144. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +6 -1
  145. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +18 -2
  146. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +24 -30
  147. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +1 -0
  148. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +16 -10
  149. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +2 -2
  150. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +1 -1
  151. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -0
  152. package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
  153. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  154. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +12 -6
  155. package/dist/builtin/workflows/skills/impeccable/reference/init.md +12 -3
  156. package/dist/builtin/workflows/skills/impeccable/reference/ios.md +6 -0
  157. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +102 -0
  158. package/dist/builtin/workflows/skills/impeccable/reference/live.md +113 -521
  159. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +39 -26
  160. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  161. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +3 -3
  162. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +1 -1
  163. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +25 -11
  164. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +332 -221
  165. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +10 -19
  166. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +91 -38
  167. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +19 -10
  168. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +56 -6
  169. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +10 -16
  170. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +140 -2
  171. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +1174 -694
  172. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +1 -0
  173. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +5 -1
  174. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +431 -45
  175. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +10 -1
  176. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +47 -6
  177. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +23 -22
  178. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -10
  179. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +384 -384
  180. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +466 -2
  181. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +2 -0
  182. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +270 -0
  183. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +51 -6
  184. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +70 -10
  185. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +336 -90
  186. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +38 -3
  187. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +77 -11
  188. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +102 -19
  189. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +44 -59
  190. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +3 -0
  191. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +57 -0
  192. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +369 -0
  193. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +31 -3
  194. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +73 -2
  195. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +617 -0
  196. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +71 -0
  197. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +29 -2
  198. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +54 -7
  199. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +47 -0
  200. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +157 -0
  201. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +143 -0
  202. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +205 -0
  203. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
  204. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +170 -0
  205. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +26 -0
  206. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +26 -0
  207. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
  208. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
  209. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
  210. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
  211. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +169 -0
  212. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +670 -0
  213. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +232 -35
  214. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +969 -0
  215. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +621 -74
  216. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +66 -28
  217. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +12 -12
  218. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +75 -0
  219. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +135 -0
  220. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +23 -37
  221. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +945 -115
  222. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +33 -1
  223. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +132 -15
  224. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +173 -425
  225. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +2 -0
  226. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +16 -3
  227. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +39 -10
  228. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +194 -27
  229. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +10 -4
  230. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +50 -31
  231. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +91 -28
  232. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +8 -5
  233. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +759 -109
  234. package/dist/builtin/workflows/src/authoring/workflow.ts +9 -0
  235. package/dist/builtin/workflows/src/authoring.d.ts +3 -0
  236. package/dist/builtin/workflows/src/durable/completed-catalog.ts +23 -2
  237. package/dist/builtin/workflows/src/durable/dbos-backend.ts +30 -17
  238. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +14 -0
  239. package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +60 -57
  240. package/dist/builtin/workflows/src/durable/dbos-process-owner.ts +87 -0
  241. package/dist/builtin/workflows/src/durable/dbos-registration-diagnostics.ts +113 -0
  242. package/dist/builtin/workflows/src/durable/factory.ts +11 -8
  243. package/dist/builtin/workflows/src/durable/tool-failure-checkpoint.ts +5 -0
  244. package/dist/builtin/workflows/src/durable/tool-primitive.ts +186 -20
  245. package/dist/builtin/workflows/src/durable/types.ts +4 -0
  246. package/dist/builtin/workflows/src/durable/workflow-heartbeat-anchor.ts +153 -0
  247. package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +28 -0
  248. package/dist/builtin/workflows/src/engine/run-tool-control-registry.ts +9 -1
  249. package/dist/builtin/workflows/src/engine/run.ts +1 -0
  250. package/dist/builtin/workflows/src/extension/adopt-session-run-state.ts +20 -0
  251. package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +9 -30
  252. package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
  253. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +28 -10
  254. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +138 -0
  255. package/dist/builtin/workflows/src/extension/index.bundle.mjs +3365 -1341
  256. package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +197 -0
  257. package/dist/builtin/workflows/src/extension/workflow-heartbeat-notice.ts +115 -0
  258. package/dist/builtin/workflows/src/extension/workflow-heartbeat-scheduler.ts +962 -0
  259. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +4 -1
  260. package/dist/builtin/workflows/src/extension/workflow-schema.ts +29 -5
  261. package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +32 -1
  262. package/dist/builtin/workflows/src/runs/background/cancellation-registry.ts +10 -1
  263. package/dist/builtin/workflows/src/runs/background/job-tracker.ts +10 -1
  264. package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +16 -11
  265. package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +31 -1
  266. package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +41 -10
  267. package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +48 -0
  268. package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +4 -1
  269. package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +45 -12
  270. package/dist/builtin/workflows/src/sdk-surface.ts +9 -0
  271. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +10 -0
  272. package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +10 -0
  273. package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +14 -2
  274. package/dist/builtin/workflows/src/shared/persistence-restore.ts +12 -0
  275. package/dist/builtin/workflows/src/shared/prompt-answer.ts +130 -0
  276. package/dist/builtin/workflows/src/shared/session-scoped-singleton.ts +98 -0
  277. package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +9 -1
  278. package/dist/builtin/workflows/src/shared/store-factory.ts +9 -1
  279. package/dist/builtin/workflows/src/shared/store-public-types.ts +2 -1
  280. package/dist/builtin/workflows/src/shared/store-tool-node-methods.ts +7 -0
  281. package/dist/builtin/workflows/src/shared/store-types.ts +18 -1
  282. package/dist/builtin/workflows/src/shared/tool-payload-bounds.ts +576 -0
  283. package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +1 -0
  284. package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +1 -0
  285. package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
  286. package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.ts +25 -0
  287. package/dist/builtin/workflows/src/tui/graph-theme.ts +8 -1
  288. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +11 -0
  289. package/dist/builtin/workflows/src/tui/graph-view-input.ts +100 -5
  290. package/dist/builtin/workflows/src/tui/graph-view-layout.ts +42 -11
  291. package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +55 -6
  292. package/dist/builtin/workflows/src/tui/graph-view-render.ts +71 -6
  293. package/dist/builtin/workflows/src/tui/graph-view-state.ts +43 -0
  294. package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +2 -0
  295. package/dist/builtin/workflows/src/tui/node-card.ts +5 -1
  296. package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +11 -2
  297. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +36 -10
  298. package/dist/builtin/workflows/src/tui/switcher.ts +11 -4
  299. package/dist/builtin/workflows/src/tui/tool-detail.ts +348 -0
  300. package/dist/builtin/workflows/src/tui/workflow-status.ts +5 -2
  301. package/dist/cli/args.d.ts +1 -0
  302. package/dist/cli/args.d.ts.map +1 -1
  303. package/dist/cli/args.js +11 -0
  304. package/dist/cli/args.js.map +1 -1
  305. package/dist/cli/auth-check.d.ts +1 -1
  306. package/dist/cli/auth-check.js.map +1 -1
  307. package/dist/cli/credential-print.d.ts +1 -1
  308. package/dist/cli/credential-print.js.map +1 -1
  309. package/dist/cli/list-models.d.ts +1 -1
  310. package/dist/cli/list-models.js.map +1 -1
  311. package/dist/cli/startup-ui.d.ts +9 -0
  312. package/dist/cli/startup-ui.d.ts.map +1 -1
  313. package/dist/cli/startup-ui.js +7 -1
  314. package/dist/cli/startup-ui.js.map +1 -1
  315. package/dist/core/agent-session-custom-message-commit.js +2 -2
  316. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  317. package/dist/core/agent-session-export.d.ts +6 -1
  318. package/dist/core/agent-session-export.d.ts.map +1 -1
  319. package/dist/core/agent-session-export.js +6 -3
  320. package/dist/core/agent-session-export.js.map +1 -1
  321. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  322. package/dist/core/agent-session-extension-bindings.js +6 -4
  323. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  324. package/dist/core/agent-session-methods.d.ts +5 -2
  325. package/dist/core/agent-session-methods.d.ts.map +1 -1
  326. package/dist/core/agent-session-methods.js.map +1 -1
  327. package/dist/core/agent-session-prompt.d.ts +12 -1
  328. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  329. package/dist/core/agent-session-prompt.js +31 -10
  330. package/dist/core/agent-session-prompt.js.map +1 -1
  331. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  332. package/dist/core/agent-session-services.d.ts +1 -1
  333. package/dist/core/agent-session-services.js.map +1 -1
  334. package/dist/core/agent-session-skill-block.d.ts +1 -0
  335. package/dist/core/agent-session-skill-block.d.ts.map +1 -1
  336. package/dist/core/agent-session-skill-block.js +18 -2
  337. package/dist/core/agent-session-skill-block.js.map +1 -1
  338. package/dist/core/agent-session-state.d.ts.map +1 -1
  339. package/dist/core/agent-session-state.js +2 -1
  340. package/dist/core/agent-session-state.js.map +1 -1
  341. package/dist/core/agent-session-types.d.ts +2 -1
  342. package/dist/core/agent-session-types.d.ts.map +1 -1
  343. package/dist/core/agent-session-types.js.map +1 -1
  344. package/dist/core/agent-session.d.ts +1 -1
  345. package/dist/core/agent-session.js.map +1 -1
  346. package/dist/core/atomic-guide-command.js +2 -2
  347. package/dist/core/atomic-guide-command.js.map +1 -1
  348. package/dist/core/builtin-packages.d.ts.map +1 -1
  349. package/dist/core/builtin-packages.js +0 -6
  350. package/dist/core/builtin-packages.js.map +1 -1
  351. package/dist/core/cloudflare-gateway-binding.d.ts +11 -0
  352. package/dist/core/cloudflare-gateway-binding.d.ts.map +1 -0
  353. package/dist/core/cloudflare-gateway-binding.js +11 -0
  354. package/dist/core/cloudflare-gateway-binding.js.map +1 -0
  355. package/dist/core/codex-fast-mode-transport.d.ts +12 -0
  356. package/dist/core/codex-fast-mode-transport.d.ts.map +1 -0
  357. package/dist/core/codex-fast-mode-transport.js +130 -0
  358. package/dist/core/codex-fast-mode-transport.js.map +1 -0
  359. package/dist/core/codex-fast-mode.d.ts +20 -6
  360. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  361. package/dist/core/codex-fast-mode.js +111 -3
  362. package/dist/core/codex-fast-mode.js.map +1 -1
  363. package/dist/core/diagnostics.d.ts +4 -0
  364. package/dist/core/diagnostics.d.ts.map +1 -1
  365. package/dist/core/diagnostics.js.map +1 -1
  366. package/dist/core/event-bus.d.ts +12 -0
  367. package/dist/core/event-bus.d.ts.map +1 -1
  368. package/dist/core/event-bus.js +22 -0
  369. package/dist/core/event-bus.js.map +1 -1
  370. package/dist/core/experimental.d.ts +25 -0
  371. package/dist/core/experimental.d.ts.map +1 -1
  372. package/dist/core/experimental.js +24 -0
  373. package/dist/core/experimental.js.map +1 -1
  374. package/dist/core/export-html/template-js/tree-filter-render.js +4 -3
  375. package/dist/core/export-html/template.js +4 -3
  376. package/dist/core/extension-session-state.d.ts +28 -0
  377. package/dist/core/extension-session-state.d.ts.map +1 -0
  378. package/dist/core/extension-session-state.js +55 -0
  379. package/dist/core/extension-session-state.js.map +1 -0
  380. package/dist/core/extensions/api-types.d.ts +6 -0
  381. package/dist/core/extensions/api-types.d.ts.map +1 -1
  382. package/dist/core/extensions/api-types.js.map +1 -1
  383. package/dist/core/extensions/context-types.d.ts +4 -0
  384. package/dist/core/extensions/context-types.d.ts.map +1 -1
  385. package/dist/core/extensions/context-types.js.map +1 -1
  386. package/dist/core/extensions/index.d.ts +1 -0
  387. package/dist/core/extensions/index.d.ts.map +1 -1
  388. package/dist/core/extensions/index.js +1 -0
  389. package/dist/core/extensions/index.js.map +1 -1
  390. package/dist/core/extensions/loader-api.d.ts +1 -1
  391. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  392. package/dist/core/extensions/loader-api.js +16 -10
  393. package/dist/core/extensions/loader-api.js.map +1 -1
  394. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  395. package/dist/core/extensions/loader-virtual-modules.js +12 -1
  396. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  397. package/dist/core/extensions/runner-context.d.ts +2 -0
  398. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  399. package/dist/core/extensions/runner-context.js +8 -0
  400. package/dist/core/extensions/runner-context.js.map +1 -1
  401. package/dist/core/extensions/runner.d.ts +1 -0
  402. package/dist/core/extensions/runner.d.ts.map +1 -1
  403. package/dist/core/extensions/runner.js +3 -0
  404. package/dist/core/extensions/runner.js.map +1 -1
  405. package/dist/core/extensions/runtime-types.d.ts +3 -0
  406. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  407. package/dist/core/extensions/runtime-types.js.map +1 -1
  408. package/dist/core/extensions/ui-types.d.ts +26 -0
  409. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  410. package/dist/core/extensions/ui-types.js +17 -1
  411. package/dist/core/extensions/ui-types.js.map +1 -1
  412. package/dist/core/http-dispatcher.d.ts.map +1 -1
  413. package/dist/core/http-dispatcher.js +5 -0
  414. package/dist/core/http-dispatcher.js.map +1 -1
  415. package/dist/core/keybindings.d.ts +24 -0
  416. package/dist/core/keybindings.d.ts.map +1 -1
  417. package/dist/core/keybindings.js +6 -0
  418. package/dist/core/keybindings.js.map +1 -1
  419. package/dist/core/model-config.d.ts +5 -0
  420. package/dist/core/model-config.d.ts.map +1 -1
  421. package/dist/core/model-config.js +1 -0
  422. package/dist/core/model-config.js.map +1 -1
  423. package/dist/core/model-registry.d.ts +1 -1
  424. package/dist/core/model-registry.js.map +1 -1
  425. package/dist/core/model-resolver-cli.d.ts +1 -1
  426. package/dist/core/model-resolver-cli.js.map +1 -1
  427. package/dist/core/model-resolver-defaults.js +3 -3
  428. package/dist/core/model-resolver-defaults.js.map +1 -1
  429. package/dist/core/model-resolver-initial.d.ts +1 -1
  430. package/dist/core/model-resolver-initial.js.map +1 -1
  431. package/dist/core/model-resolver-scope.d.ts +1 -1
  432. package/dist/core/model-resolver-scope.js.map +1 -1
  433. package/dist/core/model-runtime.d.ts +54 -0
  434. package/dist/core/model-runtime.d.ts.map +1 -1
  435. package/dist/core/model-runtime.js +96 -13
  436. package/dist/core/model-runtime.js.map +1 -1
  437. package/dist/core/oauth-login.js.map +1 -1
  438. package/dist/core/project-trust.d.ts +10 -0
  439. package/dist/core/project-trust.d.ts.map +1 -1
  440. package/dist/core/project-trust.js +12 -0
  441. package/dist/core/project-trust.js.map +1 -1
  442. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  443. package/dist/core/resource-loader-assets.js +14 -5
  444. package/dist/core/resource-loader-assets.js.map +1 -1
  445. package/dist/core/resource-loader-core.d.ts +3 -0
  446. package/dist/core/resource-loader-core.d.ts.map +1 -1
  447. package/dist/core/resource-loader-core.js +5 -0
  448. package/dist/core/resource-loader-core.js.map +1 -1
  449. package/dist/core/resource-loader-internals.d.ts +2 -0
  450. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  451. package/dist/core/resource-loader-internals.js.map +1 -1
  452. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  453. package/dist/core/resource-loader-reload.js +2 -0
  454. package/dist/core/resource-loader-reload.js.map +1 -1
  455. package/dist/core/resource-loader-types.d.ts +2 -0
  456. package/dist/core/resource-loader-types.d.ts.map +1 -1
  457. package/dist/core/resource-loader-types.js.map +1 -1
  458. package/dist/core/resource-loader.d.ts +2 -0
  459. package/dist/core/resource-loader.d.ts.map +1 -1
  460. package/dist/core/resource-loader.js +1 -0
  461. package/dist/core/resource-loader.js.map +1 -1
  462. package/dist/core/sdk-types.d.ts +7 -6
  463. package/dist/core/sdk-types.d.ts.map +1 -1
  464. package/dist/core/sdk-types.js.map +1 -1
  465. package/dist/core/sdk.d.ts.map +1 -1
  466. package/dist/core/sdk.js +17 -6
  467. package/dist/core/sdk.js.map +1 -1
  468. package/dist/core/session-manager-core.d.ts +7 -1
  469. package/dist/core/session-manager-core.d.ts.map +1 -1
  470. package/dist/core/session-manager-core.js +11 -2
  471. package/dist/core/session-manager-core.js.map +1 -1
  472. package/dist/core/session-manager-entries.d.ts +2 -2
  473. package/dist/core/session-manager-entries.d.ts.map +1 -1
  474. package/dist/core/session-manager-entries.js +6 -4
  475. package/dist/core/session-manager-entries.js.map +1 -1
  476. package/dist/core/session-manager-list.d.ts.map +1 -1
  477. package/dist/core/session-manager-list.js +5 -1
  478. package/dist/core/session-manager-list.js.map +1 -1
  479. package/dist/core/session-manager-types.d.ts +25 -2
  480. package/dist/core/session-manager-types.d.ts.map +1 -1
  481. package/dist/core/session-manager-types.js.map +1 -1
  482. package/dist/core/session-manager.d.ts +1 -1
  483. package/dist/core/session-manager.d.ts.map +1 -1
  484. package/dist/core/session-manager.js.map +1 -1
  485. package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
  486. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  487. package/dist/core/settings-manager-basic-accessors.js +8 -0
  488. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  489. package/dist/core/settings-manager-ui-accessors.d.ts +3 -1
  490. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  491. package/dist/core/settings-manager-ui-accessors.js +9 -0
  492. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  493. package/dist/core/settings-manager.d.ts +1 -1
  494. package/dist/core/settings-manager.d.ts.map +1 -1
  495. package/dist/core/settings-manager.js.map +1 -1
  496. package/dist/core/settings-types.d.ts +4 -0
  497. package/dist/core/settings-types.d.ts.map +1 -1
  498. package/dist/core/settings-types.js.map +1 -1
  499. package/dist/core/skill-catalog.d.ts +35 -0
  500. package/dist/core/skill-catalog.d.ts.map +1 -0
  501. package/dist/core/skill-catalog.js +264 -0
  502. package/dist/core/skill-catalog.js.map +1 -0
  503. package/dist/core/skills-async.d.ts.map +1 -1
  504. package/dist/core/skills-async.js +12 -6
  505. package/dist/core/skills-async.js.map +1 -1
  506. package/dist/core/skills.d.ts +2 -0
  507. package/dist/core/skills.d.ts.map +1 -1
  508. package/dist/core/skills.js +8 -5
  509. package/dist/core/skills.js.map +1 -1
  510. package/dist/core/slash-commands.d.ts.map +1 -1
  511. package/dist/core/slash-commands.js +1 -5
  512. package/dist/core/slash-commands.js.map +1 -1
  513. package/dist/core/system-prompt.js +2 -2
  514. package/dist/core/system-prompt.js.map +1 -1
  515. package/dist/core/tools/ask-user-question/ask-user-question.d.ts +25 -2
  516. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  517. package/dist/core/tools/ask-user-question/ask-user-question.js +47 -18
  518. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  519. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  520. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +5 -2
  521. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  522. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
  523. package/dist/core/tools/ask-user-question/view/components/submit-picker.js +3 -1
  524. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  525. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  526. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +8 -1
  527. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  528. package/dist/core/tools/bash.d.ts.map +1 -1
  529. package/dist/core/tools/bash.js +2 -0
  530. package/dist/core/tools/bash.js.map +1 -1
  531. package/dist/core/tools/edit.d.ts.map +1 -1
  532. package/dist/core/tools/edit.js +2 -0
  533. package/dist/core/tools/edit.js.map +1 -1
  534. package/dist/core/tools/find.d.ts.map +1 -1
  535. package/dist/core/tools/find.js +3 -1
  536. package/dist/core/tools/find.js.map +1 -1
  537. package/dist/core/tools/grep.js +1 -1
  538. package/dist/core/tools/grep.js.map +1 -1
  539. package/dist/core/tools/hashline-engine/format.d.ts +2 -0
  540. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
  541. package/dist/core/tools/hashline-engine/format.js +4 -2
  542. package/dist/core/tools/hashline-engine/format.js.map +1 -1
  543. package/dist/core/tools/hashline-engine/messages.d.ts +2 -0
  544. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -1
  545. package/dist/core/tools/hashline-engine/messages.js +4 -2
  546. package/dist/core/tools/hashline-engine/messages.js.map +1 -1
  547. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -1
  548. package/dist/core/tools/hashline-engine/parser.js +16 -4
  549. package/dist/core/tools/hashline-engine/parser.js.map +1 -1
  550. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -1
  551. package/dist/core/tools/hashline-engine/tokenizer.js +37 -27
  552. package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -1
  553. package/dist/core/tools/hashline.d.ts.map +1 -1
  554. package/dist/core/tools/hashline.js +8 -2
  555. package/dist/core/tools/hashline.js.map +1 -1
  556. package/dist/core/tools/ls.d.ts.map +1 -1
  557. package/dist/core/tools/ls.js +2 -0
  558. package/dist/core/tools/ls.js.map +1 -1
  559. package/dist/core/tools/read.d.ts.map +1 -1
  560. package/dist/core/tools/read.js +8 -1
  561. package/dist/core/tools/read.js.map +1 -1
  562. package/dist/core/tools/search.d.ts.map +1 -1
  563. package/dist/core/tools/search.js +2 -0
  564. package/dist/core/tools/search.js.map +1 -1
  565. package/dist/core/tools/todos.d.ts +3 -12
  566. package/dist/core/tools/todos.d.ts.map +1 -1
  567. package/dist/core/tools/todos.js +19 -4
  568. package/dist/core/tools/todos.js.map +1 -1
  569. package/dist/core/tools/write.d.ts.map +1 -1
  570. package/dist/core/tools/write.js +2 -0
  571. package/dist/core/tools/write.js.map +1 -1
  572. package/dist/index-extensions.d.ts +1 -1
  573. package/dist/index-extensions.d.ts.map +1 -1
  574. package/dist/index-extensions.js +1 -1
  575. package/dist/index-extensions.js.map +1 -1
  576. package/dist/index.d.ts +8 -5
  577. package/dist/index.d.ts.map +1 -1
  578. package/dist/index.js +6 -2
  579. package/dist/index.js.map +1 -1
  580. package/dist/main-runtime-api-key.d.ts +1 -1
  581. package/dist/main-runtime-api-key.js.map +1 -1
  582. package/dist/main-session-options.d.ts +1 -1
  583. package/dist/main-session-options.js.map +1 -1
  584. package/dist/main.d.ts.map +1 -1
  585. package/dist/main.js +10 -2
  586. package/dist/main.js.map +1 -1
  587. package/dist/modes/interactive/components/chat-session-host-rendering.js +1 -1
  588. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  589. package/dist/modes/interactive/components/chat-session-host-state.d.ts +8 -0
  590. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  591. package/dist/modes/interactive/components/chat-session-host-state.js +8 -0
  592. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  593. package/dist/modes/interactive/components/chat-session-host.d.ts +26 -0
  594. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  595. package/dist/modes/interactive/components/chat-session-host.js +38 -0
  596. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  597. package/dist/modes/interactive/components/chat-transcript.d.ts +37 -0
  598. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  599. package/dist/modes/interactive/components/chat-transcript.js +54 -1
  600. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  601. package/dist/modes/interactive/components/fast-mode-selector.js +1 -1
  602. package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
  603. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  604. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  605. package/dist/modes/interactive/components/model-selector.js +2 -1
  606. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  607. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
  608. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  609. package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +95 -0
  610. package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts.map +1 -0
  611. package/dist/modes/interactive/components/reserved-bottom-overlay.js +234 -0
  612. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -0
  613. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  614. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  615. package/dist/modes/interactive/components/session-selector-search.js +4 -0
  616. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  617. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  618. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  619. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  620. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  621. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  622. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  623. package/dist/modes/interactive/components/settings-selector-types.d.ts +3 -1
  624. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  625. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  626. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  627. package/dist/modes/interactive/components/tool-execution.js +12 -1
  628. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  629. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  630. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  631. package/dist/modes/interactive/interactive-autocomplete.js +5 -4
  632. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  633. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  634. package/dist/modes/interactive/interactive-bash-compact.js +2 -2
  635. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  636. package/dist/modes/interactive/interactive-extension-custom-ui.js +94 -6
  637. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  638. package/dist/modes/interactive/interactive-mode-base.d.ts +41 -3
  639. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  640. package/dist/modes/interactive/interactive-mode-base.js +80 -11
  641. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  642. package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -1
  643. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  644. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  645. package/dist/modes/interactive/interactive-mode-types.d.ts +2 -0
  646. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  647. package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
  648. package/dist/modes/interactive/interactive-model-catalog-startup.d.ts +8 -1
  649. package/dist/modes/interactive/interactive-model-catalog-startup.d.ts.map +1 -1
  650. package/dist/modes/interactive/interactive-model-catalog-startup.js +13 -3
  651. package/dist/modes/interactive/interactive-model-catalog-startup.js.map +1 -1
  652. package/dist/modes/interactive/interactive-model-routing.js +3 -4
  653. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  654. package/dist/modes/interactive/interactive-render-chat.js +6 -0
  655. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  656. package/dist/modes/interactive/interactive-resource-disclosure.js +2 -2
  657. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  658. package/dist/modes/interactive/interactive-selectors.js +7 -3
  659. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  660. package/dist/modes/interactive/interactive-session-runtime.js +7 -1
  661. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  662. package/dist/modes/interactive/interactive-slash-commands.js +2 -2
  663. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  664. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  665. package/dist/modes/interactive/interactive-startup.js +34 -9
  666. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  667. package/dist/modes/interactive/interactive-tui.d.ts +21 -1
  668. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  669. package/dist/modes/interactive/interactive-tui.js +140 -38
  670. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  671. package/dist/modes/interactive/model-catalog-refresh.d.ts +17 -0
  672. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  673. package/dist/modes/interactive/model-catalog-refresh.js +84 -0
  674. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  675. package/dist/modes/interactive/theme/dark.json +2 -0
  676. package/dist/modes/interactive/theme/light.json +2 -0
  677. package/dist/modes/interactive/theme/theme-class.d.ts +12 -3
  678. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  679. package/dist/modes/interactive/theme/theme-class.js +6 -1
  680. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  681. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  682. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  683. package/dist/modes/interactive/theme/theme-controller.js +23 -10
  684. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  685. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  686. package/dist/modes/interactive/theme/theme-loading.js +1 -0
  687. package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
  688. package/dist/modes/interactive/theme/theme-schema.d.ts +8 -0
  689. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  690. package/dist/modes/interactive/theme/theme-schema.js +3 -1
  691. package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
  692. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  693. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +2 -0
  694. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  695. package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
  696. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  697. package/dist/modes/interactive-engine/protocol.d.ts +1 -0
  698. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  699. package/dist/modes/interactive-engine/protocol.js +1 -0
  700. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  701. package/dist/modes/interactive-engine/remote-component.d.ts +3 -1
  702. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  703. package/dist/modes/interactive-engine/remote-component.js +3 -2
  704. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  705. package/dist/modes/json-event.d.ts +6 -1
  706. package/dist/modes/json-event.d.ts.map +1 -1
  707. package/dist/modes/json-event.js +17 -2
  708. package/dist/modes/json-event.js.map +1 -1
  709. package/dist/modes/rpc/rpc-client.js.map +1 -1
  710. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  711. package/dist/modes/rpc/rpc-command-handler.js +5 -4
  712. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  713. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  714. package/dist/modes/rpc/rpc-responses.js.map +1 -1
  715. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  716. package/dist/modes/rpc/rpc-types.js.map +1 -1
  717. package/dist/package-manager-cli.js.map +1 -1
  718. package/dist/server/create-harness.d.ts.map +1 -1
  719. package/dist/server/create-harness.js +11 -0
  720. package/dist/server/create-harness.js.map +1 -1
  721. package/dist/utils/abort.d.ts +9 -0
  722. package/dist/utils/abort.d.ts.map +1 -0
  723. package/dist/utils/abort.js +19 -0
  724. package/dist/utils/abort.js.map +1 -0
  725. package/dist/utils/tools-manager.d.ts +16 -1
  726. package/dist/utils/tools-manager.d.ts.map +1 -1
  727. package/dist/utils/tools-manager.js +19 -19
  728. package/dist/utils/tools-manager.js.map +1 -1
  729. package/docs/custom-provider.md +9 -8
  730. package/docs/development.md +0 -1
  731. package/docs/docs.json +0 -1
  732. package/docs/environment-variables.md +3 -0
  733. package/docs/extensions.md +100 -2
  734. package/docs/json.md +3 -1
  735. package/docs/keybindings.md +8 -3
  736. package/docs/models/artificial-analysis-index.md +2 -2
  737. package/docs/models/model-selection.md +32 -23
  738. package/docs/models/pareto-efficiency.md +25 -24
  739. package/docs/providers.md +95 -2
  740. package/docs/quickstart.md +4 -2
  741. package/docs/rpc.md +21 -7
  742. package/docs/sdk.md +26 -1
  743. package/docs/session-format.md +5 -2
  744. package/docs/settings.md +34 -3
  745. package/docs/skills.md +16 -1
  746. package/docs/terminal-setup.md +15 -2
  747. package/docs/themes.md +22 -4
  748. package/docs/tools.md +3 -1
  749. package/docs/tui.md +2 -0
  750. package/docs/usage.md +5 -4
  751. package/docs/workflows.md +96 -19
  752. package/npm-shrinkwrap.json +211 -232
  753. package/package.json +8 -8
  754. package/dist/builtin/i-have-adhd/CHANGELOG.md +0 -30
  755. package/dist/builtin/i-have-adhd/LICENSE +0 -21
  756. package/dist/builtin/i-have-adhd/README.md +0 -18
  757. package/dist/builtin/i-have-adhd/index.ts +0 -238
  758. package/dist/builtin/i-have-adhd/package.json +0 -56
  759. package/dist/builtin/i-have-adhd/skills/i-have-adhd/SKILL.md +0 -140
  760. package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +0 -359
  761. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-core.mjs +0 -180
  762. package/docs/i-have-adhd.md +0 -36
@@ -1,7 +1,11 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
1
3
  import { dirname, join } from "node:path";
2
4
  import { createModels, } from "@earendil-works/pi-ai";
3
5
  import * as builtinProviderCatalog from "@earendil-works/pi-ai/providers/all";
4
6
  import { getAgentDir } from "../config.js";
7
+ import { operationSignal, raceWithAbortSignal } from "../utils/abort.js";
8
+ import { normalizePath } from "../utils/paths.js";
5
9
  import { AuthStorage as DefaultAuthStorage } from "./auth-storage.js";
6
10
  import { ModelConfig } from "./model-config.js";
7
11
  import { POST_LOGOUT_AUTH_CHECK_TIMEOUT_MS } from "./model-refresh-timeout.js";
@@ -37,18 +41,6 @@ export class CredentialSynchronizationError extends Error {
37
41
  });
38
42
  }
39
43
  }
40
- function operationSignal(signal) {
41
- return signal ?? new AbortController().signal;
42
- }
43
- function raceWithAbortSignal(promise, signal) {
44
- if (signal.aborted)
45
- return Promise.reject(signal.reason ?? new DOMException("The operation was aborted", "AbortError"));
46
- return new Promise((resolve, reject) => {
47
- const onAbort = () => reject(signal.reason ?? new DOMException("The operation was aborted", "AbortError"));
48
- signal.addEventListener("abort", onAbort, { once: true });
49
- promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
50
- });
51
- }
52
44
  /** Configured pi-ai Models collection used by coding-agent and SDK consumers. */
53
45
  export class ModelRuntime {
54
46
  constructor(credentials, config, modelsPath, modelsStore, providers, modelNetworkEnabled) {
@@ -58,6 +50,7 @@ export class ModelRuntime {
58
50
  this.compositionErrors = new Map();
59
51
  this.snapshot = createEmptyModelRuntimeSnapshot();
60
52
  this.snapshotGeneration = 0;
53
+ this.catalogInputsGeneration = 0;
61
54
  this.externalProviderAuthStatuses = new Map();
62
55
  this.availabilityRefreshSeq = 0;
63
56
  this.availabilityErrorSeq = 0;
@@ -321,9 +314,78 @@ export class ModelRuntime {
321
314
  return undefined;
322
315
  return mergeConfiguredAuthHeaders(resolution, providerOrModel, this.config, this.extensionProviders.get(providerOrModel.provider), overrides);
323
316
  }
317
+ /**
318
+ * Monotonic count of changes to any input a catalog refresh reads.
319
+ *
320
+ * `refresh()` reloads models.json, recomposes every provider from it, the
321
+ * extension registrations, and the builtin catalog, resolves credentials as
322
+ * it runs, and publishes ONE snapshot at the end. So a pass belongs to the
323
+ * inputs it started under, and joining a pass across a bump is unsound in
324
+ * both directions: the joiner reads models and credentials the user has
325
+ * already replaced, and the pass's late publish overwrites the newer state
326
+ * with them.
327
+ *
328
+ * Every mutation source bumps this counter, which is why callers need only
329
+ * this one number rather than a growing tuple of per-input keys:
330
+ *
331
+ * - credential writes — `login`, `logout`, `saveCredential`,
332
+ * `setRuntimeApiKey`, `removeRuntimeApiKey`, an external
333
+ * `reloadCredentials`, and an applied external auth status;
334
+ * - provider registrations — `registerProvider`, `registerNativeProvider`,
335
+ * and `unregisterProvider`, through the refresh they schedule;
336
+ * - models.json content — provider `baseUrl`, `apiKey`, `api`, headers,
337
+ * model definitions, and overrides, which every pass reloads.
338
+ *
339
+ * The first two are this runtime's own writes and bump where they happen.
340
+ * The third is an external edit nothing here observes, so reading the
341
+ * generation samples the file and bumps when its content moved since the
342
+ * last sample. That read is synchronous so the answer belongs to the same
343
+ * tick as the decision that depends on it, and it hashes content rather
344
+ * than trusting an mtime: a same-size rewrite inside one filesystem
345
+ * timestamp tick — an edited key, a renamed model — is exactly the change a
346
+ * shared pass must not hide.
347
+ */
348
+ getCatalogInputsGeneration() {
349
+ this.observeModelsFile();
350
+ return this.catalogInputsGeneration;
351
+ }
352
+ /**
353
+ * Record that an input a catalog refresh reads changed. Every pass started
354
+ * before this call answers for inputs that no longer exist.
355
+ */
356
+ markCatalogInputsChanged() {
357
+ this.catalogInputsGeneration += 1;
358
+ }
359
+ /** Bump the generation when models.json changed since the last observation. */
360
+ observeModelsFile() {
361
+ const token = this.readModelsFileToken();
362
+ if (this.observedModelsFileToken === token)
363
+ return;
364
+ const first = this.observedModelsFileToken === undefined;
365
+ this.observedModelsFileToken = token;
366
+ // The first observation is a baseline, not a change: no pass can predate it.
367
+ if (!first)
368
+ this.markCatalogInputsChanged();
369
+ }
370
+ readModelsFileToken() {
371
+ if (!this.modelsPath)
372
+ return "none";
373
+ try {
374
+ return createHash("sha1")
375
+ .update(readFileSync(normalizePath(this.modelsPath)))
376
+ .digest("hex");
377
+ }
378
+ catch (error) {
379
+ const code = error.code;
380
+ // An absent file is a stable state passes can share; any other read
381
+ // failure keys on its own code rather than pretending the file is empty.
382
+ return code === "ENOENT" ? "absent" : `unreadable:${code ?? "unknown"}`;
383
+ }
384
+ }
324
385
  /** Reload credentials changed by the authoritative isolated engine and update auth status snapshots. */
325
386
  async reloadCredentials(options = {}) {
326
387
  await this.credentials.reload();
388
+ this.markCatalogInputsChanged();
327
389
  if (options.refreshAvailability === false) {
328
390
  const credentials = await this.credentials.list();
329
391
  for (const credential of credentials)
@@ -401,6 +463,7 @@ export class ModelRuntime {
401
463
  const signal = operationSignal(undefined);
402
464
  await this.enqueueCredentialOperation(providerId, signal, async () => {
403
465
  await this.credentials.modify(providerId, async () => credential);
466
+ this.markCatalogInputsChanged();
404
467
  await this.synchronizeCredentialState(providerId, "saveCredential", credential, async () => {
405
468
  const result = await this.refresh({ providers: [providerId] });
406
469
  this.assertCredentialRefreshSucceeded(providerId, result);
@@ -417,6 +480,7 @@ export class ModelRuntime {
417
480
  const signal = operationSignal(options.signal);
418
481
  await this.enqueueCredentialOperation(providerId, signal, async () => {
419
482
  this.credentials.setRuntimeApiKey(providerId, apiKey);
483
+ this.markCatalogInputsChanged();
420
484
  await this.synchronizeCredentialState(providerId, "setRuntimeApiKey", { type: "api_key", key: apiKey }, () => {
421
485
  this.snapshot = addRuntimeApiKeyProvider(this.snapshot, providerId);
422
486
  });
@@ -426,6 +490,7 @@ export class ModelRuntime {
426
490
  const signal = operationSignal(options.signal);
427
491
  await this.enqueueCredentialOperation(providerId, signal, async () => {
428
492
  this.credentials.removeRuntimeApiKey(providerId);
493
+ this.markCatalogInputsChanged();
429
494
  await this.synchronizeCredentialState(providerId, "removeRuntimeApiKey", undefined, async () => {
430
495
  const result = await this.refresh({ allowNetwork: this.modelNetworkEnabled, signal });
431
496
  this.assertCredentialRefreshSucceeded(providerId, result, signal);
@@ -446,6 +511,7 @@ export class ModelRuntime {
446
511
  }
447
512
  /** Apply authoritative auth state returned by an isolated engine mutation. */
448
513
  applyExternalProviderAuthStatus(providerId, status) {
514
+ this.markCatalogInputsChanged();
449
515
  this.snapshotGeneration += 1;
450
516
  const remainingAuth = status.configured && status.source === "environment"
451
517
  ? { type: "api_key", source: status.label ?? "environment" }
@@ -475,6 +541,7 @@ export class ModelRuntime {
475
541
  const signal = operationSignal(interaction.signal);
476
542
  return this.enqueueCredentialOperation(providerId, signal, async () => {
477
543
  const credential = await this.models.login(providerId, type, { ...interaction, signal });
544
+ this.markCatalogInputsChanged();
478
545
  await this.synchronizeCredentialState(providerId, "login", credential, () => {
479
546
  // Credential acquisition and persistence are the login transaction. Publish
480
547
  // the provider against the current snapshot immediately; catalog restoration,
@@ -491,6 +558,7 @@ export class ModelRuntime {
491
558
  const signal = operationSignal(options.signal);
492
559
  const logoutGeneration = await this.enqueueCredentialOperation(providerId, signal, async () => {
493
560
  await this.models.logout(providerId, { signal });
561
+ this.markCatalogInputsChanged();
494
562
  let generation = 0;
495
563
  await this.synchronizeCredentialState(providerId, "logout", undefined, () => {
496
564
  // Reset credential-dependent compatibility projections, then publish the
@@ -505,14 +573,29 @@ export class ModelRuntime {
505
573
  });
506
574
  await this.refreshRemainingAuthAfterLogout(providerId, logoutGeneration);
507
575
  }
576
+ /**
577
+ * The network policy a refresh with an omitted `allowNetwork` resolves to.
578
+ *
579
+ * Callers that share one in-flight refresh key on the effective policy, so
580
+ * they need the same answer `runRefresh` computes rather than a second guess
581
+ * at the offline setting this runtime was created under.
582
+ */
583
+ isNetworkRefreshEnabled() {
584
+ return this.modelNetworkEnabled;
585
+ }
508
586
  async refresh(options = {}) {
509
587
  return this.runRefresh(options, ++this.refreshSequence);
510
588
  }
511
589
  /**
512
590
  * A registration's offline catalog pass must not publish after a newer refresh
513
591
  * that resolves configured credentials.
592
+ *
593
+ * The registration is also a catalog-input change: it adds, replaces, or drops
594
+ * a provider every later pass composes from, so no pass that predates it can
595
+ * answer for the provider set a caller now sees.
514
596
  */
515
597
  scheduleRegistrationRefresh() {
598
+ this.markCatalogInputsChanged();
516
599
  const sequence = ++this.refreshSequence;
517
600
  void this.runRefresh({ allowNetwork: false }, sequence, true);
518
601
  }
@@ -530,7 +613,7 @@ export class ModelRuntime {
530
613
  }
531
614
  else
532
615
  this.rebuildProviders();
533
- const refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.modelNetworkEnabled };
616
+ const refreshOptions = { ...options, allowNetwork: options.allowNetwork ?? this.isNetworkRefreshEnabled() };
534
617
  const result = await this.models.refresh(refreshOptions);
535
618
  const errors = new Map(result.errors);
536
619
  this.updateModelSnapshot();
@@ -1 +1 @@
1
- {"version":3,"file":"model-runtime.js","sourceRoot":"","sources":["../../src/core/model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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 \"@earendil-works/pi-ai\";\nimport * as builtinProviderCatalog from \"@earendil-works/pi-ai/providers/all\";\nimport { getAgentDir } from \"../config.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\nfunction operationSignal(signal: AbortSignal | undefined): AbortSignal {\n\treturn signal ?? new AbortController().signal;\n}\n\nfunction raceWithAbortSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n\tif (signal.aborted)\n\t\treturn Promise.reject(signal.reason ?? new DOMException(\"The operation was aborted\", \"AbortError\"));\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = () => reject(signal.reason ?? new DOMException(\"The operation was aborted\", \"AbortError\"));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tpromise.then(resolve, reject).finally(() => signal.removeEventListener(\"abort\", onAbort));\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 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) => this.getAuth(model, overrides));\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\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\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\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\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\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\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.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\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\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\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\tprivate scheduleRegistrationRefresh(): void {\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.modelNetworkEnabled };\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,uBAAuB,CAAC;AAC/B,OAAO,KAAK,sBAAsB,MAAM,qCAAqC,CAAC;AAC9E,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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esContent":["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 \"@earendil-works/pi-ai\";\nimport * as builtinProviderCatalog from \"@earendil-works/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) => this.getAuth(model, overrides));\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\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\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 +1 @@
1
- {"version":3,"file":"oauth-login.js","sourceRoot":"","sources":["../../src/core/oauth-login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAepE,sHAAsH;AACtH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACpD,YAAY,KAAc;QACzB,KA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UAAU;oBACd,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACtC,MAAM;gBACP,KAAK,MAAM;oBACV,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACrD,MAAM;YACR,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { AuthInfoLink, AuthInteraction, OAuthLoginCallbacks } from \"@earendil-works/pi-ai\";\nimport { CredentialSynchronizationError } from \"./model-runtime.ts\";\n\nexport interface AtomicOAuthLoginCallbacks extends OAuthLoginCallbacks {\n\tonManualCodeCancel?(): void;\n\tonInfo?(message: string, links: readonly AuthInfoLink[]): void;\n}\n\n/** JSON-safe provider-owned OAuth metadata transported across isolated-engine boundaries. */\nexport interface OAuthProviderMetadata {\n\tid: string;\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n}\n\n/** Marks failures after credential acquisition so presentation never mistakes nested AbortErrors for cancellation. */\nexport class OAuthLoginTransactionError extends Error {\n\tconstructor(cause: unknown) {\n\t\tsuper(cause instanceof Error ? cause.message : String(cause), { cause });\n\t\tthis.name = \"OAuthLoginTransactionError\";\n\t}\n}\n\nexport function isOAuthLoginCancelled(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions: { includeActiveSignal?: boolean } = {},\n): boolean {\n\tif (error instanceof OAuthLoginTransactionError || error instanceof CredentialSynchronizationError) return false;\n\tif (options.includeActiveSignal !== false && signal?.aborted) return true;\n\tconst reason = signal?.reason;\n\tconst seen = new Set<object>();\n\tlet current: unknown = error;\n\twhile (current !== undefined && current !== null) {\n\t\tif (current === reason && reason !== undefined) return true;\n\t\tif (current === \"Login cancelled\") return true;\n\t\tif (typeof current !== \"object\") return false;\n\t\tif (seen.has(current)) return false;\n\t\tseen.add(current);\n\t\tconst candidate = current as { name?: unknown; message?: unknown; cause?: unknown };\n\t\tif (candidate.name === \"AbortError\" || candidate.message === \"Login cancelled\") return true;\n\t\tcurrent = candidate.cause;\n\t}\n\treturn false;\n}\n\nexport function normalizeOAuthLoginError(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions?: { includeActiveSignal?: boolean },\n): unknown {\n\tif (error instanceof Error && error.message === \"Login cancelled\" && error.cause !== undefined) return error;\n\tif (!isOAuthLoginCancelled(error, signal, options)) return error;\n\treturn new Error(\"Login cancelled\", { cause: error });\n}\n\nfunction abortable<T>(promise: Promise<T>, signal: AbortSignal | undefined, onAbort?: () => void): Promise<T> {\n\tif (!signal) return promise;\n\tif (signal.aborted) {\n\t\tonAbort?.();\n\t\treturn Promise.reject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t}\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst abort = () => {\n\t\t\tonAbort?.();\n\t\t\treject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t\t};\n\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\tpromise.then(resolve, reject).finally(() => signal.removeEventListener(\"abort\", abort));\n\t});\n}\n\nexport function createAuthInteraction(callbacks: AtomicOAuthLoginCallbacks): AuthInteraction {\n\treturn {\n\t\tsignal: callbacks.signal,\n\t\tprompt: async (prompt) => {\n\t\t\tswitch (prompt.type) {\n\t\t\t\tcase \"select\":\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(await callbacks.onSelect({\n\t\t\t\t\t\t\tmessage: prompt.message,\n\t\t\t\t\t\t\toptions: prompt.options.map(({ id, label }) => ({ id, label })),\n\t\t\t\t\t\t})) ?? \"\"\n\t\t\t\t\t);\n\t\t\t\tcase \"manual_code\":\n\t\t\t\t\treturn abortable(\n\t\t\t\t\t\tcallbacks.onManualCodeInput\n\t\t\t\t\t\t\t? callbacks.onManualCodeInput()\n\t\t\t\t\t\t\t: callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder }),\n\t\t\t\t\t\tprompt.signal,\n\t\t\t\t\t\tcallbacks.onManualCodeCancel,\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder });\n\t\t\t}\n\t\t},\n\t\tnotify: (event) => {\n\t\t\tswitch (event.type) {\n\t\t\t\tcase \"auth_url\":\n\t\t\t\t\tcallbacks.onAuth({ url: event.url, instructions: event.instructions });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"device_code\":\n\t\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"progress\":\n\t\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"info\":\n\t\t\t\t\tcallbacks.onInfo?.(event.message, event.links ?? []);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"oauth-login.js","sourceRoot":"","sources":["../../src/core/oauth-login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAepE,sHAAsH;AACtH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACpD,YAAY,KAAc;QACzB,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAED,MAAM,UAAU,qBAAqB,CACpC,KAAc,EACd,MAAoB,EACpB,OAAO,GAAsC,EAAE;IAE/C,IAAI,KAAK,YAAY,0BAA0B,IAAI,KAAK,YAAY,8BAA8B;QAAE,OAAO,KAAK,CAAC;IACjH,IAAI,OAAO,CAAC,mBAAmB,KAAK,KAAK,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1E,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,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AiB;wBAC1B,CAAC,CAAC,SAAS,CAAC,iBAAiB,EAAE;wBAC/B,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,EACnF,MAAM,CAAC,MAAM,EACb,SAAS,CAAC,kBAAkB,CAC5B,CAAC;gBACH;oBACC,OAAO,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;QACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,UAAU;oBACd,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;oBACvE,MAAM;gBACP,KAAK,aAAa;oBACjB,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;oBAC9B,MAAM;gBACP,KAAK,UAAU;oBACd,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACtC,MAAM;gBACP,KAAK,MAAM;oBACV,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACrD,MAAM;YACR,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { AuthInfoLink, AuthInteraction, OAuthLoginCallbacks } from \"@earendil-works/pi-ai\";\nimport { CredentialSynchronizationError } from \"./model-runtime.js\";\n\nexport interface AtomicOAuthLoginCallbacks extends OAuthLoginCallbacks {\n\tonManualCodeCancel?(): void;\n\tonInfo?(message: string, links: readonly AuthInfoLink[]): void;\n}\n\n/** JSON-safe provider-owned OAuth metadata transported across isolated-engine boundaries. */\nexport interface OAuthProviderMetadata {\n\tid: string;\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n}\n\n/** Marks failures after credential acquisition so presentation never mistakes nested AbortErrors for cancellation. */\nexport class OAuthLoginTransactionError extends Error {\n\tconstructor(cause: unknown) {\n\t\tsuper(cause instanceof Error ? cause.message : String(cause), { cause });\n\t\tthis.name = \"OAuthLoginTransactionError\";\n\t}\n}\n\nexport function isOAuthLoginCancelled(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions: { includeActiveSignal?: boolean } = {},\n): boolean {\n\tif (error instanceof OAuthLoginTransactionError || error instanceof CredentialSynchronizationError) return false;\n\tif (options.includeActiveSignal !== false && signal?.aborted) return true;\n\tconst reason = signal?.reason;\n\tconst seen = new Set<object>();\n\tlet current: unknown = error;\n\twhile (current !== undefined && current !== null) {\n\t\tif (current === reason && reason !== undefined) return true;\n\t\tif (current === \"Login cancelled\") return true;\n\t\tif (typeof current !== \"object\") return false;\n\t\tif (seen.has(current)) return false;\n\t\tseen.add(current);\n\t\tconst candidate = current as { name?: unknown; message?: unknown; cause?: unknown };\n\t\tif (candidate.name === \"AbortError\" || candidate.message === \"Login cancelled\") return true;\n\t\tcurrent = candidate.cause;\n\t}\n\treturn false;\n}\n\nexport function normalizeOAuthLoginError(\n\terror: unknown,\n\tsignal?: AbortSignal,\n\toptions?: { includeActiveSignal?: boolean },\n): unknown {\n\tif (error instanceof Error && error.message === \"Login cancelled\" && error.cause !== undefined) return error;\n\tif (!isOAuthLoginCancelled(error, signal, options)) return error;\n\treturn new Error(\"Login cancelled\", { cause: error });\n}\n\nfunction abortable<T>(promise: Promise<T>, signal: AbortSignal | undefined, onAbort?: () => void): Promise<T> {\n\tif (!signal) return promise;\n\tif (signal.aborted) {\n\t\tonAbort?.();\n\t\treturn Promise.reject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t}\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst abort = () => {\n\t\t\tonAbort?.();\n\t\t\treject(signal.reason ?? new Error(\"Authentication prompt cancelled\"));\n\t\t};\n\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\tpromise.then(resolve, reject).finally(() => signal.removeEventListener(\"abort\", abort));\n\t});\n}\n\nexport function createAuthInteraction(callbacks: AtomicOAuthLoginCallbacks): AuthInteraction {\n\treturn {\n\t\tsignal: callbacks.signal,\n\t\tprompt: async (prompt) => {\n\t\t\tswitch (prompt.type) {\n\t\t\t\tcase \"select\":\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(await callbacks.onSelect({\n\t\t\t\t\t\t\tmessage: prompt.message,\n\t\t\t\t\t\t\toptions: prompt.options.map(({ id, label }) => ({ id, label })),\n\t\t\t\t\t\t})) ?? \"\"\n\t\t\t\t\t);\n\t\t\t\tcase \"manual_code\":\n\t\t\t\t\treturn abortable(\n\t\t\t\t\t\tcallbacks.onManualCodeInput\n\t\t\t\t\t\t\t? callbacks.onManualCodeInput()\n\t\t\t\t\t\t\t: callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder }),\n\t\t\t\t\t\tprompt.signal,\n\t\t\t\t\t\tcallbacks.onManualCodeCancel,\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn callbacks.onPrompt({ message: prompt.message, placeholder: prompt.placeholder });\n\t\t\t}\n\t\t},\n\t\tnotify: (event) => {\n\t\t\tswitch (event.type) {\n\t\t\t\tcase \"auth_url\":\n\t\t\t\t\tcallbacks.onAuth({ url: event.url, instructions: event.instructions });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"device_code\":\n\t\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"progress\":\n\t\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"info\":\n\t\t\t\t\tcallbacks.onInfo?.(event.message, event.links ?? []);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -12,5 +12,15 @@ export interface ResolveProjectTrustedOptions {
12
12
  promptMessage?: string;
13
13
  onExtensionError?: (message: string) => void;
14
14
  }
15
+ /**
16
+ * The prompt shown for a `-e` extension source outside the project.
17
+ *
18
+ * Named through `APP_TITLE` for the same reason as the project-folder prompt
19
+ * above: branding is configurable, so a hardcoded product name lies in a
20
+ * rebranded distribution. The `.atomic/.pi` directory names stay literal —
21
+ * they are the two compatibility paths the resource loader reads from that
22
+ * source, not a product name.
23
+ */
24
+ export declare function formatBorrowedExtensionSourceTrustPrompt(source: string): string;
15
25
  export declare function resolveProjectTrusted(options: ResolveProjectTrustedOptions): Promise<boolean>;
16
26
  //# sourceMappingURL=project-trust.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAE/D,MAAM,WAAW,4BAA4B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAyBD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC,CAkDnG"}
1
+ {"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAE/D,MAAM,WAAW,4BAA4B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAMD;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/E;AAqBD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC,CAkDnG"}
@@ -4,6 +4,18 @@ import { getProjectTrustOptions, hasProjectTrustInputs, } from "./trust-manager.
4
4
  function formatProjectTrustPrompt(cwd) {
5
5
  return `Trust project folder?\n${cwd}\n\nThis allows ${APP_TITLE} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;
6
6
  }
7
+ /**
8
+ * The prompt shown for a `-e` extension source outside the project.
9
+ *
10
+ * Named through `APP_TITLE` for the same reason as the project-folder prompt
11
+ * above: branding is configurable, so a hardcoded product name lies in a
12
+ * rebranded distribution. The `.atomic/.pi` directory names stay literal —
13
+ * they are the two compatibility paths the resource loader reads from that
14
+ * source, not a product name.
15
+ */
16
+ export function formatBorrowedExtensionSourceTrustPrompt(source) {
17
+ return `Trust extension source?\n${source}\n\nThis allows ${APP_TITLE} to load project-local .atomic/.pi resources and .agents/skills from this -e source, including extensions and workflows that can execute code.`;
18
+ }
7
19
  async function selectProjectTrustOption(cwd, ctx, promptMessage) {
8
20
  const options = getProjectTrustOptions(cwd, { includeSessionOnly: true });
9
21
  const selected = await ctx.ui.select(promptMessage ?? formatProjectTrustPrompt(cwd), options.map((option) => option.label));
@@ -1 +1 @@
1
- {"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EACN,sBAAsB,EACtB,qBAAqB,GAGrB,MAAM,oBAAoB,CAAC;AAe5B,SAAS,wBAAwB,CAAC,GAAW;IAC5C,OAAO,0BAA0B,GAAG,mBAAmB,SAAS,YAAY,eAAe,4FAA4F,CAAC;AACzL,CAAC;AAED,KAAK,UAAU,wBAAwB,CACtC,GAAW,EACX,GAAwB,EACxB,aAAsB;IAEtB,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CACnC,aAAa,IAAI,wBAAwB,CAAC,GAAG,CAAC,EAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CACrC,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAA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U,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,QAAQ,OAAO,CAAC,mBAAmB,IAAI,KAAK,EAAE,CAAC;QAC9C,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC;QACb,KAAK,OAAO;YACX,OAAO,KAAK,CAAC;QACd,KAAK,KAAK;YACT,MAAM;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACjH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { APP_TITLE, CONFIG_DIR_NAME } from \"../config.ts\";\nimport { emitProjectTrustEvent } from \"./extensions/runner.ts\";\nimport type { LoadExtensionsResult, ProjectTrustContext } from \"./extensions/types.ts\";\nimport type { DefaultProjectTrust } from \"./settings-manager.ts\";\nimport {\n\tgetProjectTrustOptions,\n\thasProjectTrustInputs,\n\ttype ProjectTrustOption,\n\ttype ProjectTrustStore,\n} from \"./trust-manager.ts\";\n\nexport type AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nexport interface ResolveProjectTrustedOptions {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tdefaultProjectTrust?: DefaultProjectTrust;\n\textensionsResult?: LoadExtensionsResult;\n\tprojectTrustContext: ProjectTrustContext;\n\tpromptMessage?: string;\n\tonExtensionError?: (message: string) => void;\n}\n\nfunction formatProjectTrustPrompt(cwd: string): string {\n\treturn `Trust project folder?\\n${cwd}\\n\\nThis allows ${APP_TITLE} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;\n}\n\nasync function selectProjectTrustOption(\n\tcwd: string,\n\tctx: ProjectTrustContext,\n\tpromptMessage?: string,\n): Promise<ProjectTrustOption | undefined> {\n\tconst options = getProjectTrustOptions(cwd, { includeSessionOnly: true });\n\tconst selected = await ctx.ui.select(\n\t\tpromptMessage ?? formatProjectTrustPrompt(cwd),\n\t\toptions.map((option) => option.label),\n\t);\n\treturn options.find((option) => option.label === selected);\n}\n\nfunction saveProjectTrustPromptResult(trustStore: ProjectTrustStore, result: ProjectTrustOption): void {\n\tif (result.updates.length > 0) {\n\t\ttrustStore.setMany(result.updates);\n\t}\n}\n\nexport async function resolveProjectTrusted(options: ResolveProjectTrustedOptions): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasProjectTrustInputs(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tif (options.extensionsResult) {\n\t\tconst { result, errors } = await emitProjectTrustEvent(\n\t\t\toptions.extensionsResult,\n\t\t\t{ type: \"project_trust\", cwd: options.cwd },\n\t\t\toptions.projectTrustContext,\n\t\t);\n\t\tfor (const error of errors) {\n\t\t\toptions.onExtensionError?.(`Extension \"${error.extensionPath}\" project_trust error: ${error.error}`);\n\t\t}\n\t\tif (result) {\n\t\t\tconst trusted = result.trusted === \"yes\";\n\t\t\tif (result.remember === true) {\n\t\t\t\toptions.trustStore.set(options.cwd, trusted);\n\t\t\t}\n\t\t\treturn trusted;\n\t\t}\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\n\tswitch (options.defaultProjectTrust ?? \"ask\") {\n\t\tcase \"always\":\n\t\t\treturn true;\n\t\tcase \"never\":\n\t\t\treturn false;\n\t\tcase \"ask\":\n\t\t\tbreak;\n\t}\n\n\tif (!options.projectTrustContext.hasUI) {\n\t\treturn false;\n\t}\n\n\tconst selected = await selectProjectTrustOption(options.cwd, options.projectTrustContext, options.promptMessage);\n\tif (selected !== undefined) {\n\t\tsaveProjectTrustPromptResult(options.trustStore, selected);\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EACN,sBAAsB,EACtB,qBAAqB,GAGrB,MAAM,oBAAoB,CAAC;AAe5B,SAAS,wBAAwB,CAAC,GAAW;IAC5C,OAAO,0BAA0B,GAAG,mBAAmB,SAAS,YAAY,eAAe,4FAA4F,CAAC;AACzL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wCAAwC,CAAC,MAAc;IACtE,OAAO,4BAA4B,MAAM,mBAAmB,SAAS,gJAAgJ,CAAC;AACvN,CAAC;AAED,KAAK,UAAU,wBAAwB,CACtC,GAAW,EACX,GAAwB,EACxB,aAAsB;IAEtB,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CACnC,aAAa,IAAI,wBAAwB,CAAC,GAAG,CAAC,EAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CACrC,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,SA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C,CAAC;IACrD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,QAAQ,OAAO,CAAC,mBAAmB,IAAI,KAAK,EAAE,CAAC;QAC9C,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC;QACb,KAAK,OAAO;YACX,OAAO,KAAK,CAAC;QACd,KAAK,KAAK;YACT,MAAM;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACjH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { APP_TITLE, CONFIG_DIR_NAME } from \"../config.ts\";\nimport { emitProjectTrustEvent } from \"./extensions/runner.ts\";\nimport type { LoadExtensionsResult, ProjectTrustContext } from \"./extensions/types.ts\";\nimport type { DefaultProjectTrust } from \"./settings-manager.ts\";\nimport {\n\tgetProjectTrustOptions,\n\thasProjectTrustInputs,\n\ttype ProjectTrustOption,\n\ttype ProjectTrustStore,\n} from \"./trust-manager.ts\";\n\nexport type AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nexport interface ResolveProjectTrustedOptions {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tdefaultProjectTrust?: DefaultProjectTrust;\n\textensionsResult?: LoadExtensionsResult;\n\tprojectTrustContext: ProjectTrustContext;\n\tpromptMessage?: string;\n\tonExtensionError?: (message: string) => void;\n}\n\nfunction formatProjectTrustPrompt(cwd: string): string {\n\treturn `Trust project folder?\\n${cwd}\\n\\nThis allows ${APP_TITLE} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;\n}\n\n/**\n * The prompt shown for a `-e` extension source outside the project.\n *\n * Named through `APP_TITLE` for the same reason as the project-folder prompt\n * above: branding is configurable, so a hardcoded product name lies in a\n * rebranded distribution. The `.atomic/.pi` directory names stay literal —\n * they are the two compatibility paths the resource loader reads from that\n * source, not a product name.\n */\nexport function formatBorrowedExtensionSourceTrustPrompt(source: string): string {\n\treturn `Trust extension source?\\n${source}\\n\\nThis allows ${APP_TITLE} to load project-local .atomic/.pi resources and .agents/skills from this -e source, including extensions and workflows that can execute code.`;\n}\n\nasync function selectProjectTrustOption(\n\tcwd: string,\n\tctx: ProjectTrustContext,\n\tpromptMessage?: string,\n): Promise<ProjectTrustOption | undefined> {\n\tconst options = getProjectTrustOptions(cwd, { includeSessionOnly: true });\n\tconst selected = await ctx.ui.select(\n\t\tpromptMessage ?? formatProjectTrustPrompt(cwd),\n\t\toptions.map((option) => option.label),\n\t);\n\treturn options.find((option) => option.label === selected);\n}\n\nfunction saveProjectTrustPromptResult(trustStore: ProjectTrustStore, result: ProjectTrustOption): void {\n\tif (result.updates.length > 0) {\n\t\ttrustStore.setMany(result.updates);\n\t}\n}\n\nexport async function resolveProjectTrusted(options: ResolveProjectTrustedOptions): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasProjectTrustInputs(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tif (options.extensionsResult) {\n\t\tconst { result, errors } = await emitProjectTrustEvent(\n\t\t\toptions.extensionsResult,\n\t\t\t{ type: \"project_trust\", cwd: options.cwd },\n\t\t\toptions.projectTrustContext,\n\t\t);\n\t\tfor (const error of errors) {\n\t\t\toptions.onExtensionError?.(`Extension \"${error.extensionPath}\" project_trust error: ${error.error}`);\n\t\t}\n\t\tif (result) {\n\t\t\tconst trusted = result.trusted === \"yes\";\n\t\t\tif (result.remember === true) {\n\t\t\t\toptions.trustStore.set(options.cwd, trusted);\n\t\t\t}\n\t\t\treturn trusted;\n\t\t}\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\n\tswitch (options.defaultProjectTrust ?? \"ask\") {\n\t\tcase \"always\":\n\t\t\treturn true;\n\t\tcase \"never\":\n\t\t\treturn false;\n\t\tcase \"ask\":\n\t\t\tbreak;\n\t}\n\n\tif (!options.projectTrustContext.hasUI) {\n\t\treturn false;\n\t}\n\n\tconst selected = await selectProjectTrustOption(options.cwd, options.projectTrustContext, options.promptMessage);\n\tif (selected !== undefined) {\n\t\tsaveProjectTrustPromptResult(options.trustStore, selected);\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n"]}