@bastani/atomic 0.9.20-alpha.7 → 0.9.20-alpha.9

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 (315) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/builtin/intercom/package.json +3 -5
  3. package/dist/builtin/mcp/package.json +3 -3
  4. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/src/extension/index.bundle.mjs +11 -2
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/builtin/workflows/CHANGELOG.md +37 -0
  9. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  10. package/dist/builtin/workflows/builtin/{chunk-ffdrv23t.js → chunk-18yz7r43.js} +1 -1
  11. package/dist/builtin/workflows/builtin/{chunk-9z3ztr2a.js → chunk-1pd5zcfa.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-5724b0cf.js → chunk-24c235x7.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-vn0wb31x.js → chunk-2jv44yz7.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-hmt5w62g.js → chunk-2npg6daz.js} +1 -1
  15. package/dist/builtin/workflows/builtin/{chunk-njmf5ze7.js → chunk-7ps7bnb4.js} +1 -1
  16. package/dist/builtin/workflows/builtin/{chunk-jngsbbpm.js → chunk-ad864596.js} +3 -3
  17. package/dist/builtin/workflows/builtin/{chunk-7n51c5gh.js → chunk-f8jjd90r.js} +1 -1
  18. package/dist/builtin/workflows/builtin/{chunk-3tx8ry44.js → chunk-gxrhbnaj.js} +2 -1
  19. package/dist/builtin/workflows/builtin/{chunk-2hzrv5y8.js → chunk-twefqrv0.js} +986 -199
  20. package/dist/builtin/workflows/builtin/{chunk-7bzcersz.js → chunk-ynded223.js} +3 -3
  21. package/dist/builtin/workflows/builtin/{chunk-dxjxtgmp.js → chunk-z5xdqrs6.js} +1 -1
  22. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  23. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  24. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  25. package/dist/builtin/workflows/builtin/goal.js +4 -4
  26. package/dist/builtin/workflows/builtin/index.js +12 -12
  27. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  28. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  29. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  30. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  31. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  32. package/dist/builtin/workflows/package.json +4 -4
  33. package/dist/builtin/workflows/src/authoring.d.ts +6 -3
  34. package/dist/builtin/workflows/src/extension/index.bundle.mjs +26991 -26238
  35. package/dist/builtin/workflows/src/index.js +41619 -12907
  36. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +13 -0
  37. package/dist/core/agent-session-boundaries.d.ts.map +1 -1
  38. package/dist/core/agent-session-boundaries.js +9 -4
  39. package/dist/core/agent-session-boundaries.js.map +1 -1
  40. package/dist/core/agent-session-events.d.ts.map +1 -1
  41. package/dist/core/agent-session-events.js +4 -0
  42. package/dist/core/agent-session-events.js.map +1 -1
  43. package/dist/core/agent-session-methods.d.ts +3 -0
  44. package/dist/core/agent-session-methods.d.ts.map +1 -1
  45. package/dist/core/agent-session-methods.js.map +1 -1
  46. package/dist/core/agent-session-tasks.js +4 -4
  47. package/dist/core/agent-session-tasks.js.map +1 -1
  48. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  49. package/dist/core/agent-session-tool-registry.js +4 -3
  50. package/dist/core/agent-session-tool-registry.js.map +1 -1
  51. package/dist/core/agent-session.d.ts +3 -0
  52. package/dist/core/agent-session.d.ts.map +1 -1
  53. package/dist/core/agent-session.js +3 -0
  54. package/dist/core/agent-session.js.map +1 -1
  55. package/dist/core/cache-stats.d.ts +7 -1
  56. package/dist/core/cache-stats.d.ts.map +1 -1
  57. package/dist/core/cache-stats.js +24 -5
  58. package/dist/core/cache-stats.js.map +1 -1
  59. package/dist/core/execution-model-router.d.ts +1 -1
  60. package/dist/core/execution-model-router.d.ts.map +1 -1
  61. package/dist/core/execution-model-router.js +23 -14
  62. package/dist/core/execution-model-router.js.map +1 -1
  63. package/dist/core/extensions/agent-events.d.ts +9 -1
  64. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  65. package/dist/core/extensions/agent-events.js.map +1 -1
  66. package/dist/core/extensions/api-types.d.ts +2 -1
  67. package/dist/core/extensions/api-types.d.ts.map +1 -1
  68. package/dist/core/extensions/api-types.js.map +1 -1
  69. package/dist/core/extensions/event-types.d.ts +2 -2
  70. package/dist/core/extensions/event-types.d.ts.map +1 -1
  71. package/dist/core/extensions/event-types.js.map +1 -1
  72. package/dist/core/extensions/index.d.ts +1 -1
  73. package/dist/core/extensions/index.d.ts.map +1 -1
  74. package/dist/core/extensions/index.js.map +1 -1
  75. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  76. package/dist/core/extensions/loader-core.js +1 -0
  77. package/dist/core/extensions/loader-core.js.map +1 -1
  78. package/dist/core/extensions/provider-types.d.ts +34 -16
  79. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  80. package/dist/core/extensions/provider-types.js.map +1 -1
  81. package/dist/core/extensions/runtime-types.d.ts +4 -0
  82. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  83. package/dist/core/extensions/runtime-types.js.map +1 -1
  84. package/dist/core/extensions/tool-types.d.ts +9 -0
  85. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  86. package/dist/core/extensions/tool-types.js.map +1 -1
  87. package/dist/core/fast-model-routing.d.ts.map +1 -1
  88. package/dist/core/fast-model-routing.js +1 -0
  89. package/dist/core/fast-model-routing.js.map +1 -1
  90. package/dist/core/fast-model-variants.d.ts +10 -0
  91. package/dist/core/fast-model-variants.d.ts.map +1 -1
  92. package/dist/core/fast-model-variants.js +13 -1
  93. package/dist/core/fast-model-variants.js.map +1 -1
  94. package/dist/core/model-registry.d.ts +3 -1
  95. package/dist/core/model-registry.d.ts.map +1 -1
  96. package/dist/core/model-registry.js +6 -0
  97. package/dist/core/model-registry.js.map +1 -1
  98. package/dist/core/model-runtime-auth.d.ts +2 -2
  99. package/dist/core/model-runtime-auth.d.ts.map +1 -1
  100. package/dist/core/model-runtime-auth.js.map +1 -1
  101. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  102. package/dist/core/model-runtime-streaming.js +2 -1
  103. package/dist/core/model-runtime-streaming.js.map +1 -1
  104. package/dist/core/model-runtime.d.ts +11 -3
  105. package/dist/core/model-runtime.d.ts.map +1 -1
  106. package/dist/core/model-runtime.js +41 -6
  107. package/dist/core/model-runtime.js.map +1 -1
  108. package/dist/core/package-manager-npm.d.ts.map +1 -1
  109. package/dist/core/package-manager-npm.js +32 -8
  110. package/dist/core/package-manager-npm.js.map +1 -1
  111. package/dist/core/package-manager-resolver.js +3 -1
  112. package/dist/core/package-manager-resolver.js.map +1 -1
  113. package/dist/core/package-manager-types.d.ts +1 -0
  114. package/dist/core/package-manager-types.d.ts.map +1 -1
  115. package/dist/core/package-manager-types.js.map +1 -1
  116. package/dist/core/provider-composer-internal.d.ts +40 -21
  117. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  118. package/dist/core/provider-composer-internal.js +22 -20
  119. package/dist/core/provider-composer-internal.js.map +1 -1
  120. package/dist/core/provider-composer.d.ts +3 -3
  121. package/dist/core/provider-composer.d.ts.map +1 -1
  122. package/dist/core/provider-composer.js +54 -10
  123. package/dist/core/provider-composer.js.map +1 -1
  124. package/dist/core/remote-catalog-provider.d.ts +8 -1
  125. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  126. package/dist/core/remote-catalog-provider.js +46 -4
  127. package/dist/core/remote-catalog-provider.js.map +1 -1
  128. package/dist/core/resource-loader-core.d.ts.map +1 -1
  129. package/dist/core/resource-loader-core.js +7 -3
  130. package/dist/core/resource-loader-core.js.map +1 -1
  131. package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
  132. package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
  133. package/dist/core/resource-loader-extension-warnings.js +54 -0
  134. package/dist/core/resource-loader-extension-warnings.js.map +1 -0
  135. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  136. package/dist/core/resource-loader-extensions.js +1 -0
  137. package/dist/core/resource-loader-extensions.js.map +1 -1
  138. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  139. package/dist/core/resource-loader-reload.js +6 -0
  140. package/dist/core/resource-loader-reload.js.map +1 -1
  141. package/dist/core/runtime-credentials.d.ts.map +1 -1
  142. package/dist/core/runtime-credentials.js +3 -1
  143. package/dist/core/runtime-credentials.js.map +1 -1
  144. package/dist/core/sdk.js +16 -6
  145. package/dist/core/sdk.js.map +1 -1
  146. package/dist/core/settings-manager-basic-accessors.js +4 -4
  147. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  148. package/dist/core/skill-catalog.d.ts.map +1 -1
  149. package/dist/core/skill-catalog.js +18 -6
  150. package/dist/core/skill-catalog.js.map +1 -1
  151. package/dist/core/structured-output/choice-schema.d.ts +8 -0
  152. package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
  153. package/dist/core/structured-output/choice-schema.js +79 -0
  154. package/dist/core/structured-output/choice-schema.js.map +1 -0
  155. package/dist/core/structured-output/index.d.ts +3 -5
  156. package/dist/core/structured-output/index.d.ts.map +1 -1
  157. package/dist/core/structured-output/index.js +218 -41
  158. package/dist/core/structured-output/index.js.map +1 -1
  159. package/dist/core/structured-output/resolver.d.ts +0 -46
  160. package/dist/core/structured-output/resolver.d.ts.map +1 -1
  161. package/dist/core/structured-output/resolver.js +15 -93
  162. package/dist/core/structured-output/resolver.js.map +1 -1
  163. package/dist/core/structured-output/types.d.ts +27 -21
  164. package/dist/core/structured-output/types.d.ts.map +1 -1
  165. package/dist/core/structured-output/types.js.map +1 -1
  166. package/dist/core/system-prompt.d.ts.map +1 -1
  167. package/dist/core/system-prompt.js +9 -1
  168. package/dist/core/system-prompt.js.map +1 -1
  169. package/dist/core/tasks/owner-store.d.ts +6 -0
  170. package/dist/core/tasks/owner-store.d.ts.map +1 -1
  171. package/dist/core/tasks/owner-store.js +16 -3
  172. package/dist/core/tasks/owner-store.js.map +1 -1
  173. package/dist/core/tasks/pause.js +1 -1
  174. package/dist/core/tasks/pause.js.map +1 -1
  175. package/dist/core/tasks/supervisor.d.ts +4 -2
  176. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  177. package/dist/core/tasks/supervisor.js +9 -3
  178. package/dist/core/tasks/supervisor.js.map +1 -1
  179. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  180. package/dist/core/tools/ask-user-question/ask-user-question.js +1 -0
  181. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  182. package/dist/core/tools/bash.d.ts.map +1 -1
  183. package/dist/core/tools/bash.js +16 -13
  184. package/dist/core/tools/bash.js.map +1 -1
  185. package/dist/core/tools/edit.d.ts.map +1 -1
  186. package/dist/core/tools/edit.js +1 -0
  187. package/dist/core/tools/edit.js.map +1 -1
  188. package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
  189. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
  190. package/dist/core/tools/file-mutation-coordinator.js +45 -38
  191. package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
  192. package/dist/core/tools/powershell.d.ts +16 -0
  193. package/dist/core/tools/powershell.d.ts.map +1 -1
  194. package/dist/core/tools/structured-output.d.ts +9 -6
  195. package/dist/core/tools/structured-output.d.ts.map +1 -1
  196. package/dist/core/tools/structured-output.js +36 -8
  197. package/dist/core/tools/structured-output.js.map +1 -1
  198. package/dist/core/tools/todos.d.ts.map +1 -1
  199. package/dist/core/tools/todos.js +1 -0
  200. package/dist/core/tools/todos.js.map +1 -1
  201. package/dist/core/tools/tool-concurrency.d.ts +23 -0
  202. package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
  203. package/dist/core/tools/tool-concurrency.js +58 -0
  204. package/dist/core/tools/tool-concurrency.js.map +1 -0
  205. package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
  206. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  207. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  208. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  209. package/dist/core/tools/write.d.ts.map +1 -1
  210. package/dist/core/tools/write.js +1 -0
  211. package/dist/core/tools/write.js.map +1 -1
  212. package/dist/index-extensions.d.ts +1 -1
  213. package/dist/index-extensions.d.ts.map +1 -1
  214. package/dist/index-extensions.js.map +1 -1
  215. package/dist/index.d.ts +2 -2
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +2 -2
  218. package/dist/index.js.map +1 -1
  219. package/dist/main.d.ts.map +1 -1
  220. package/dist/main.js +4 -0
  221. package/dist/main.js.map +1 -1
  222. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  223. package/dist/modes/interactive/components/atomic-banner.js +3 -2
  224. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  225. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  226. package/dist/modes/interactive/components/settings-selector-items.js +11 -9
  227. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  228. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -1
  229. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  230. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  231. package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
  232. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
  233. package/dist/modes/interactive/components/startup-identity.js +11 -2
  234. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  235. package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
  236. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  237. package/dist/modes/interactive/components/task-inspector.js +11 -11
  238. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  239. package/dist/modes/interactive/components/task-list.d.ts +9 -3
  240. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  241. package/dist/modes/interactive/components/task-list.js +26 -2
  242. package/dist/modes/interactive/components/task-list.js.map +1 -1
  243. package/dist/modes/interactive/interactive-agent-events.js +3 -9
  244. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  245. package/dist/modes/interactive/interactive-auth-login.js +1 -1
  246. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  247. package/dist/modes/interactive/interactive-render-chat.js +3 -9
  248. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  249. package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
  250. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  251. package/dist/modes/interactive/interactive-selectors.js +1 -0
  252. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  253. package/dist/modes/interactive/interactive-slash-commands.js +2 -4
  254. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  255. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  256. package/dist/modes/interactive/interactive-tui.js +2 -0
  257. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  258. package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
  259. package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
  260. package/dist/modes/interactive/overlay-line-composite.js +24 -0
  261. package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
  262. package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -0
  263. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  264. package/dist/modes/interactive-engine/isolated-runtime.js +5 -0
  265. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  266. package/dist/utils/child-process.d.ts +1 -0
  267. package/dist/utils/child-process.d.ts.map +1 -1
  268. package/dist/utils/child-process.js +7 -8
  269. package/dist/utils/child-process.js.map +1 -1
  270. package/dist/utils/clipboard-image.d.ts.map +1 -1
  271. package/dist/utils/clipboard-image.js +14 -17
  272. package/dist/utils/clipboard-image.js.map +1 -1
  273. package/dist/utils/shell.d.ts.map +1 -1
  274. package/dist/utils/shell.js +18 -1
  275. package/dist/utils/shell.js.map +1 -1
  276. package/docs/background-tasks.md +1 -0
  277. package/docs/computer-use.md +2 -2
  278. package/docs/custom-provider/registration.md +1 -1
  279. package/docs/custom-provider.md +43 -1
  280. package/docs/extensions/authoring.md +22 -3
  281. package/docs/extensions/events.md +18 -0
  282. package/docs/extensions/examples.md +1 -0
  283. package/docs/models/evals.md +31 -79
  284. package/docs/models/model-selection.md +5 -1
  285. package/docs/packages/authoring.md +3 -1
  286. package/docs/providers.md +11 -12
  287. package/docs/sdk/reference.md +18 -42
  288. package/docs/sdk/structured-decisions.md +44 -89
  289. package/docs/sdk.md +1 -1
  290. package/docs/settings.md +6 -6
  291. package/docs/subagents/reference.md +7 -8
  292. package/docs/usage.md +13 -0
  293. package/docs/workflows/api-reference.md +38 -35
  294. package/docs/workflows/authoring.md +113 -1
  295. package/docs/workflows/builtins.md +1 -1
  296. package/docs/workflows/operations.md +51 -29
  297. package/docs/workflows/verification.md +13 -0
  298. package/examples/extensions/README.md +1 -0
  299. package/examples/extensions/debug-provider.ts +90 -0
  300. package/examples/extensions/structured-output.ts +6 -0
  301. package/npm-shrinkwrap.json +32 -32
  302. package/package.json +3 -3
  303. package/dist/builtin/workflows/src/durable/dependency-doctor-types.d.ts +0 -42
  304. package/dist/core/decision-provider.d.ts +0 -4
  305. package/dist/core/decision-provider.d.ts.map +0 -1
  306. package/dist/core/decision-provider.js +0 -12
  307. package/dist/core/decision-provider.js.map +0 -1
  308. package/dist/core/structured-output/jev-client.d.ts +0 -25
  309. package/dist/core/structured-output/jev-client.d.ts.map +0 -1
  310. package/dist/core/structured-output/jev-client.js +0 -174
  311. package/dist/core/structured-output/jev-client.js.map +0 -1
  312. package/dist/core/structured-output/jev.d.ts +0 -5
  313. package/dist/core/structured-output/jev.d.ts.map +0 -1
  314. package/dist/core/structured-output/jev.js +0 -249
  315. package/dist/core/structured-output/jev.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"provider-types.js","sourceRoot":"","sources":["../../../src/core/extensions/provider-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RefreshModelsContext } from \"@bastani/pi-ai\";\nimport type {\n\tApi,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tSimpleStreamOptions,\n} from \"@bastani/pi-ai/compat\";\nimport type { AtomicProviderCompat } from \"../model-capabilities.ts\";\nimport type { ExtensionAPI } from \"./api-types.ts\";\n\nexport type { AtomicProviderCompat } from \"../model-capabilities.ts\";\n\n/** Configuration for registering a provider via pi.registerProvider(). */\nexport interface ProviderConfig {\n\t/** Display name for the provider in UI. */\n\tname?: string;\n\t/** Base URL for the API endpoint. Required when defining models. */\n\tbaseUrl?: string;\n\t/** API key or environment variable name. Required when defining models (unless oauth provided). */\n\tapiKey?: string;\n\t/** API type. Required at provider or model level when defining models. */\n\tapi?: Api;\n\t/** Optional streamSimple handler for custom APIs. */\n\tstreamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\t/** Custom headers to include in requests. */\n\theaders?: Record<string, string>;\n\t/** If true, adds Authorization: Bearer header with the resolved API key. */\n\tauthHeader?: boolean;\n\t/** Models to register. If provided, replaces all existing models for this provider. */\n\tmodels?: ProviderModelConfig[];\n\t/** Refresh this provider's catalog. Successful results replace its extension-provided models. */\n\trefreshModels?(context: RefreshModelsContext): Promise<ProviderModelConfig[]>;\n\t/** OAuth provider for /login support. The `id` is set automatically from the provider name. */\n\toauth?: {\n\t\t/** Display name for the provider in login UI. */\n\t\tname: string;\n\t\t/** Optional provider-specific login label. */\n\t\tloginLabel?: string;\n\t\t/** Whether the flow accepts a browser callback/manual redirect. */\n\t\tusesCallbackServer?: boolean;\n\t\t/** Run the login flow, return credentials to persist. */\n\t\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t\t/**\n\t\t * Refresh expired credentials, return updated credentials to persist.\n\t\t * `signal` is the caller's cancellation signal — forward it into the\n\t\t * network call so an aborted refresh is actually abandoned.\n\t\t */\n\t\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\t\t/** Convert credentials to API key string for the provider. */\n\t\tgetApiKey(credentials: OAuthCredentials): string;\n\t\t/** Optional: modify models for this provider (e.g., update baseUrl based on credentials). */\n\t\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n\t};\n}\n\n/** Configuration for a model within a provider. */\nexport interface ProviderModelConfig {\n\t/** Model ID (e.g., \"claude-sonnet-4-20250514\"). */\n\tid: string;\n\t/** Display name (e.g., \"Claude 4 Sonnet\"). */\n\tname: string;\n\t/** API type override for this model. */\n\tapi?: Api;\n\t/** API endpoint URL override for this model. */\n\tbaseUrl?: string;\n\t/** Whether the model supports extended thinking. */\n\treasoning: boolean;\n\t/** Maps pi thinking levels to provider/model-specific values; null marks a level unsupported. */\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\t/** Supported input types. `\"pdf\"` only on runtimes that can serialize a document block. */\n\tinput: Model<Api>[\"input\"];\n\t/** Provider input limits and cache-safe image preprocessing metadata. */\n\tinputLimits?: Model<Api>[\"inputLimits\"];\n\t/** Request pricing, including optional request-wide long-context tiers. */\n\tcost: Model<Api>[\"cost\"];\n\t/** Default/effective context window size in tokens. */\n\tcontextWindow: number;\n\t/** Maximum output tokens. */\n\tmaxTokens: number;\n\t/** Default sampling parameters merged into OpenAI-compatible request bodies. */\n\tsamplingParams?: Record<string, unknown>;\n\t/** Custom headers for this model. */\n\theaders?: Record<string, string>;\n\t/** Provider capability settings, including Atomic's `supportsGrammarTools` alias. */\n\tcompat?: AtomicProviderCompat;\n}\n\n/** Extension factory function type. Supports both sync and async initialization. */\nexport type ExtensionFactory = (pi: ExtensionAPI) => void | Promise<void>;\n\n/** Inline extension factory, optionally carrying a stable name and display visibility. */\nexport type InlineExtension =\n\t| ExtensionFactory\n\t| { name: string; factory: ExtensionFactory; hidden?: boolean; bundled?: boolean };\n"]}
1
+ {"version":3,"file":"provider-types.js","sourceRoot":"","sources":["../../../src/core/extensions/provider-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tAnyModel,\n\tClassifierApi,\n\tImageApi,\n\tProviderClassifier,\n\tProviderImages,\n\tRefreshModelsContext,\n} from \"@bastani/pi-ai\";\nimport type {\n\tApi,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tSimpleStreamOptions,\n} from \"@bastani/pi-ai/compat\";\nimport type { AtomicProviderCompat } from \"../model-capabilities.ts\";\nimport type { ExtensionAPI } from \"./api-types.ts\";\n\nexport type { AtomicProviderCompat } from \"../model-capabilities.ts\";\n\n/** Configuration for registering a provider via pi.registerProvider(). */\nexport interface ProviderConfig {\n\t/** Display name for the provider in UI. */\n\tname?: string;\n\t/** Base URL for the API endpoint. Required when defining models. */\n\tbaseUrl?: string;\n\t/** API key or environment variable name. Required when defining models (unless oauth provided). */\n\tapiKey?: string;\n\t/** API type. Required at provider or model level when defining models. */\n\tapi?: Api;\n\t/**\n\t * Optional streamSimple handler for custom APIs. Implementations may invoke\n\t * `options.onProviderStreamEvent(data, model)` with parsed stream events before normalization.\n\t * Event data is adapter-owned and must be treated as read-only.\n\t */\n\tstreamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\t/** Image API implementations keyed by each image model's api. */\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\t/** Classifier API implementations keyed by each classifier model's api. */\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n\t/** Custom headers to include in requests. */\n\theaders?: Record<string, string>;\n\t/** If true, adds Authorization: Bearer header with the resolved API key. */\n\tauthHeader?: boolean;\n\t/** Models to register. If provided, replaces all existing models for this provider. */\n\tmodels?: ProviderModelConfig[];\n\t/** Refresh this provider's catalog. Successful results replace its extension-provided models. */\n\trefreshModels?(context: RefreshModelsContext): Promise<ProviderModelConfig[]>;\n\t/** OAuth provider for /login support. The `id` is set automatically from the provider name. */\n\toauth?: {\n\t\t/** Display name for the provider in login UI. */\n\t\tname: string;\n\t\t/** Optional provider-specific login label. */\n\t\tloginLabel?: string;\n\t\t/** Whether the flow accepts a browser callback/manual redirect. */\n\t\tusesCallbackServer?: boolean;\n\t\t/** Run the login flow, return credentials to persist. */\n\t\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t\t/**\n\t\t * Refresh expired credentials, return updated credentials to persist.\n\t\t * `signal` is the caller's cancellation signal — forward it into the\n\t\t * network call so an aborted refresh is actually abandoned.\n\t\t */\n\t\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\t\t/** Convert credentials to API key string for the provider. */\n\t\tgetApiKey(credentials: OAuthCredentials): string;\n\t\t/** Optional: modify models for this provider (e.g., update baseUrl based on credentials). */\n\t\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n\t};\n}\n\ninterface ProviderModelConfigBase {\n\t/** Model ID (e.g., \"claude-sonnet-4-20250514\"). */\n\tid: string;\n\t/** Display name. */\n\tname: string;\n\tapi?: string;\n\tbaseUrl?: string;\n\tinput: AnyModel[\"input\"];\n\tinputLimits?: AnyModel[\"inputLimits\"];\n\tcost: AnyModel[\"cost\"];\n\theaders?: Record<string, string>;\n}\n\n/** Chat models are the default when `type` is omitted. */\nexport interface ProviderChatModelConfig extends ProviderModelConfigBase {\n\ttype?: \"chat\";\n\tapi?: Api;\n\t/** Whether the model supports extended thinking. */\n\treasoning: boolean;\n\t/** Maps pi thinking levels to provider/model-specific values; null marks a level unsupported. */\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\t/** Default/effective context window size in tokens. */\n\tcontextWindow: number;\n\t/** Maximum output tokens. */\n\tmaxTokens: number;\n\t/** Default sampling parameters merged into OpenAI-compatible request bodies. */\n\tsamplingParams?: Record<string, unknown>;\n\t/** Provider capability settings, including Atomic's `supportsGrammarTools` alias. */\n\tcompat?: AtomicProviderCompat;\n}\n\nexport interface ProviderImageModelConfig extends ProviderModelConfigBase {\n\ttype: \"image\";\n\tapi?: ImageApi;\n\toutput: (\"text\" | \"image\")[];\n}\n\nexport interface ProviderClassifierModelConfig extends ProviderModelConfigBase {\n\ttype: \"classifier\";\n\tapi?: ClassifierApi;\n\tcontextWindow: number;\n}\n\n/** Models for all supported operations in a provider registration. */\nexport type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig;\n\n/** Extension factory function type. Supports both sync and async initialization. */\nexport type ExtensionFactory = (pi: ExtensionAPI) => void | Promise<void>;\n\n/** Inline extension factory, optionally carrying a stable name and display visibility. */\nexport type InlineExtension =\n\t| ExtensionFactory\n\t| { name: string; factory: ExtensionFactory; hidden?: boolean; bundled?: boolean };\n"]}
@@ -217,6 +217,10 @@ export interface LoadExtensionsResult {
217
217
  path: string;
218
218
  error: string;
219
219
  }>;
220
+ warnings?: Array<{
221
+ path: string;
222
+ warning: string;
223
+ }>;
220
224
  overlaps?: ResourceOverlap[];
221
225
  /** Shared runtime - actions are throwing stubs until runner.initialize() */
222
226
  runtime: ExtensionRuntime;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/runtime-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,E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GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACnC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAClC,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;CACzC;AAED,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAE7B,4EAA4E;IAC5E,OAAO,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-types.js","sourceRoot":"","sources":["../../../src/core/extensions/runtime-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Provider } from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { ResourceOverlap } from \"../diagnostics.ts\";\nimport type { CustomMessage } from \"../messages.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { SlashCommandInfo } from \"../slash-commands.js\";\nimport type { SourceInfo } from \"../source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport type { RegisteredCommand } from \"./command-types.ts\";\nimport type { CompactOptions, ContextUsage, ExtensionContext, ReplacedSessionContext } from \"./context-types.ts\";\nimport type {\n\tEntryRenderer,\n\tMarkdownTransformer,\n\tMessageRenderer,\n\tSendMessageOptions,\n\tSendMessagesOptions,\n} from \"./message-types.ts\";\nimport type { ProviderConfig } from \"./provider-types.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tool-types.ts\";\nimport type { WorkflowActivityHub } from \"./workflow-activity-hub.js\";\n\nexport interface RegisteredTool {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface ExtensionFlag {\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\tdefault?: boolean | string;\n\textensionPath: string;\n}\n\nexport interface ExtensionShortcut {\n\tshortcut: KeyId;\n\tdescription?: string;\n\tkeybinding?: import(\"../keybindings.ts\").Keybinding;\n\tpreferEditor?: boolean;\n\t/** Resolved editor-owned keys; dispatch must yield only for input these keys accept. */\n\teditorKeys?: KeyId[];\n\thandler: (ctx: ExtensionContext) => Promise<void> | void;\n\textensionPath: string;\n}\n\ntype HandlerFn = (...args: unknown[]) => Promise<unknown>;\n\nexport type SendMessageHandler = <T = unknown>(\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n) => void | Promise<void>;\n\nexport type SendMessagesHandler = <T = unknown>(\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n) => void | Promise<void>;\n\nexport type SendUserMessageHandler = (\n\tcontent: string | (TextContent | ImageContent)[],\n\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n) => void;\n\nexport type AppendEntryHandler = <T = unknown>(customType: string, data?: T) => void;\n\nexport type SetSessionNameHandler = (name: string) => void;\n\nexport type GetSessionNameHandler = () => string | undefined;\n\nexport type GetActiveToolsHandler = () => string[];\n\nexport type GetAllToolsHandler = () => ToolInfo[];\n\nexport type GetCommandsHandler = () => SlashCommandInfo[];\n\nexport type SetActiveToolsHandler = (toolNames: string[]) => void;\n\nexport type RefreshToolsHandler = () => void;\n\nexport type SetModelHandler = (model: Model<Api>) => Promise<boolean>;\n\nexport type GetThinkingLevelHandler = () => ThinkingLevel;\n\nexport type SetThinkingLevelHandler = (level: ThinkingLevel) => void;\n\nexport type SetLabelHandler = (entryId: string, label: string | undefined) => void;\n\n/**\n * Shared state created by loader, used during registration and runtime.\n * Contains flag values (defaults set during registration, CLI values set after).\n */\nexport interface ExtensionRuntimeState {\n\tgetChildSessionOptions?: import(\"../child-session-options.ts\").ChildSessionOptionsResolver;\n\t/** Shared by extension loading and its runner generation. */\n\tworkflowActivityHub: WorkflowActivityHub;\n\tflagValues: Map<string, boolean | string>;\n\texplicitFlagNames?: Set<string>;\n\t/** Extension path that owns each active flag registration. */\n\tflagOwners?: Map<string, string>;\n\t/** Configuration origin of each active flag owner. */\n\tflagOwnerOrigins?: Map<string, Extension[\"sourceInfo\"][\"configurationOrigin\"]>;\n\t/** Provider registrations queued during extension loading, processed when runner binds */\n\tpendingProviderRegistrations: Array<\n\t\t{ provider: Provider; extensionPath: string } | { name: string; config: ProviderConfig; extensionPath: string }\n\t>;\n\t/** Provider IDs already published on behalf of this extension generation. */\n\textensionProviderIds: Set<string>;\n\t/** Resource-level compatibility gate installed after extension provenance is resolved. */\n\tcanRegisterResource?: (extension: Extension, resourceType: ResourceOverlap[\"resourceType\"], name: string) => boolean;\n\tbeginResourceRegistrationBatch?: () => void;\n\tendResourceRegistrationBatch?: () => void;\n\trefreshToolsAfterRegistration?: () => void;\n\tapplyFlagDefaultAfterRegistration?: (\n\t\tname: string,\n\t\townerPath: string,\n\t\tvalue: boolean | string,\n\t\tconfigurationOrigin?: Extension[\"sourceInfo\"][\"configurationOrigin\"],\n\t) => void;\n\tstageToolRegistration?: (extension: Extension, name: string, registration: RegisteredTool) => boolean;\n\tstageCommandRegistration?: (extension: Extension, name: string, registration: RegisteredCommand) => boolean;\n\tstageFlagRegistration?: (\n\t\textension: Extension,\n\t\tname: string,\n\t\tregistration: ExtensionFlag,\n\t\tdefaultValue?: boolean | string,\n\t) => boolean;\n\tstageShortcutRegistration?: (extension: Extension, name: KeyId, registration: ExtensionShortcut) => boolean;\n\thasPendingResourceRegistration?: (\n\t\textension: Extension,\n\t\tresourceType: ResourceOverlap[\"resourceType\"],\n\t\tname: string,\n\t) => boolean;\n\tdeletePendingResourceRegistration?: (\n\t\textension: Extension,\n\t\tresourceType: ResourceOverlap[\"resourceType\"],\n\t\tname: string,\n\t) => void;\n\tgetPendingFlagDefault?: (ownerPath: string, name: string) => boolean | string | undefined;\n\tgetAllToolsAfterRegistration?: (extension: Extension) => ToolInfo[];\n\tgetCommandsAfterRegistration?: (extension: Extension) => SlashCommandInfo[];\n\t/** Throws when this extension instance is stale after runtime replacement. */\n\tgetActiveToolsAfterRegistration?: (extension: Extension) => string[];\n\tsetActiveToolsAfterRegistration?: (extension: Extension, toolNames: string[]) => boolean;\n\tassertActive: () => void;\n\t/** Marks this extension instance as stale after runtime replacement or reload. */\n\tinvalidate: (message?: string) => void;\n\t/** Retain an event-bus subscription until this runtime is invalidated. */\n\ttrackEventBusSubscription: (unsubscribe: () => void) => () => void;\n\t/**\n\t * Register or unregister a provider.\n\t *\n\t * Before bindCore(): queues registrations / removes from queue.\n\t * After bindCore(): calls ModelRegistry directly for immediate effect.\n\t */\n\tregisterProvider: ((name: string, config: ProviderConfig, extensionPath?: string) => void) &\n\t\t((provider: Provider, extensionPath?: string) => void);\n\tunregisterProvider: (name: string, extensionPath?: string) => void;\n}\n\n/**\n * Action implementations for pi.* API methods.\n * Provided to runner.initialize(), copied into the shared runtime.\n */\nexport interface ExtensionActions {\n\tsendMessage: SendMessageHandler;\n\tsendMessages: SendMessagesHandler;\n\tsendUserMessage: SendUserMessageHandler;\n\tappendEntry: AppendEntryHandler;\n\tsetSessionName: SetSessionNameHandler;\n\tgetSessionName: GetSessionNameHandler;\n\tsetLabel: SetLabelHandler;\n\tgetActiveTools: GetActiveToolsHandler;\n\tgetAllTools: GetAllToolsHandler;\n\tsetActiveTools: SetActiveToolsHandler;\n\trefreshTools: RefreshToolsHandler;\n\tgetCommands: GetCommandsHandler;\n\tsetModel: SetModelHandler;\n\tgetThinkingLevel: GetThinkingLevelHandler;\n\tsetThinkingLevel: SetThinkingLevelHandler;\n}\n\n/**\n * Actions for ExtensionContext (ctx.* in event handlers).\n * Required by all modes.\n */\nexport interface ExtensionContextActions {\n\tgetModel: () => Model<Api> | undefined;\n\tgetScopedModels: () => readonly ScopedModel[];\n\tgetThinkingLevel: () => ThinkingLevel | undefined;\n\tisIdle: () => boolean;\n\tisProjectTrusted: () => boolean;\n\tgetSignal: () => AbortSignal | undefined;\n\tabort: () => void;\n\thasPendingMessages: () => boolean;\n\tshutdown: () => void;\n\tgetContextUsage: () => ContextUsage | undefined;\n\tcompact: (options?: CompactOptions) => void;\n\tgetSystemPrompt: () => string;\n\tgetSkillCatalog?: () => SkillCatalog;\n\tgetSystemPromptOptions?: () => BuildSystemPromptOptions;\n\tgetRouterModel?: () => string;\n}\n\n/**\n * Actions for ExtensionCommandContext (ctx.* in command handlers).\n * Only needed for interactive mode where extension commands are invokable.\n */\nexport interface ExtensionCommandContextActions {\n\twaitForIdle: () => Promise<void>;\n\tnewSession: (options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}) => Promise<{ cancelled: boolean }>;\n\tfork: (\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t) => Promise<{ cancelled: boolean }>;\n\tnavigateTree: (\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t) => Promise<{ cancelled: boolean }>;\n\tswitchSession: (\n\t\tsessionPath: string,\n\t\toptions?: { withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t) => Promise<{ cancelled: boolean }>;\n\treload: () => Promise<void>;\n}\n\n/**\n * Full runtime = state + actions.\n * Created by loader with throwing action stubs, completed by runner.initialize().\n */\nexport interface ExtensionRuntime extends ExtensionRuntimeState, ExtensionActions {}\n\n/** Loaded extension with all registered items. */\nexport interface Extension {\n\tpath: string;\n\thidden?: boolean;\n\tresolvedPath: string;\n\tsourceInfo: SourceInfo;\n\thandlers: Map<string, HandlerFn[]>;\n\ttools: Map<string, RegisteredTool>;\n\tmessageRenderers: Map<string, MessageRenderer>;\n\tmarkdownTransformer?: MarkdownTransformer;\n\tentryRenderers: Map<string, EntryRenderer>;\n\tcommands: Map<string, RegisteredCommand>;\n\tflags: Map<string, ExtensionFlag>;\n\tshortcuts: Map<KeyId, ExtensionShortcut>;\n}\n\n/** Result of loading extensions. */\nexport interface LoadExtensionsResult {\n\textensions: Extension[];\n\terrors: Array<{ path: string; error: string }>;\n\toverlaps?: ResourceOverlap[];\n\n\t/** Shared runtime - actions are throwing stubs until runner.initialize() */\n\truntime: ExtensionRuntime;\n}\n\nexport interface ExtensionError {\n\textensionPath: string;\n\tevent: string;\n\terror: string;\n\tstack?: string;\n}\n"]}
1
+ {"version":3,"file":"runtime-types.js","sourceRoot":"","sources":["../../../src/core/extensions/runtime-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Provider } from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { ResourceOverlap } from \"../diagnostics.ts\";\nimport type { CustomMessage } from \"../messages.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { SlashCommandInfo } from \"../slash-commands.js\";\nimport type { SourceInfo } from \"../source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport type { RegisteredCommand } from \"./command-types.ts\";\nimport type { CompactOptions, ContextUsage, ExtensionContext, ReplacedSessionContext } from \"./context-types.ts\";\nimport type {\n\tEntryRenderer,\n\tMarkdownTransformer,\n\tMessageRenderer,\n\tSendMessageOptions,\n\tSendMessagesOptions,\n} from \"./message-types.ts\";\nimport type { ProviderConfig } from \"./provider-types.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tool-types.ts\";\nimport type { WorkflowActivityHub } from \"./workflow-activity-hub.js\";\n\nexport interface RegisteredTool {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface ExtensionFlag {\n\tname: string;\n\tdescription?: string;\n\ttype: \"boolean\" | \"string\";\n\tdefault?: boolean | string;\n\textensionPath: string;\n}\n\nexport interface ExtensionShortcut {\n\tshortcut: KeyId;\n\tdescription?: string;\n\tkeybinding?: import(\"../keybindings.ts\").Keybinding;\n\tpreferEditor?: boolean;\n\t/** Resolved editor-owned keys; dispatch must yield only for input these keys accept. */\n\teditorKeys?: KeyId[];\n\thandler: (ctx: ExtensionContext) => Promise<void> | void;\n\textensionPath: string;\n}\n\ntype HandlerFn = (...args: unknown[]) => Promise<unknown>;\n\nexport type SendMessageHandler = <T = unknown>(\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n) => void | Promise<void>;\n\nexport type SendMessagesHandler = <T = unknown>(\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n) => void | Promise<void>;\n\nexport type SendUserMessageHandler = (\n\tcontent: string | (TextContent | ImageContent)[],\n\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n) => void;\n\nexport type AppendEntryHandler = <T = unknown>(customType: string, data?: T) => void;\n\nexport type SetSessionNameHandler = (name: string) => void;\n\nexport type GetSessionNameHandler = () => string | undefined;\n\nexport type GetActiveToolsHandler = () => string[];\n\nexport type GetAllToolsHandler = () => ToolInfo[];\n\nexport type GetCommandsHandler = () => SlashCommandInfo[];\n\nexport type SetActiveToolsHandler = (toolNames: string[]) => void;\n\nexport type RefreshToolsHandler = () => void;\n\nexport type SetModelHandler = (model: Model<Api>) => Promise<boolean>;\n\nexport type GetThinkingLevelHandler = () => ThinkingLevel;\n\nexport type SetThinkingLevelHandler = (level: ThinkingLevel) => void;\n\nexport type SetLabelHandler = (entryId: string, label: string | undefined) => void;\n\n/**\n * Shared state created by loader, used during registration and runtime.\n * Contains flag values (defaults set during registration, CLI values set after).\n */\nexport interface ExtensionRuntimeState {\n\tgetChildSessionOptions?: import(\"../child-session-options.ts\").ChildSessionOptionsResolver;\n\t/** Shared by extension loading and its runner generation. */\n\tworkflowActivityHub: WorkflowActivityHub;\n\tflagValues: Map<string, boolean | string>;\n\texplicitFlagNames?: Set<string>;\n\t/** Extension path that owns each active flag registration. */\n\tflagOwners?: Map<string, string>;\n\t/** Configuration origin of each active flag owner. */\n\tflagOwnerOrigins?: Map<string, Extension[\"sourceInfo\"][\"configurationOrigin\"]>;\n\t/** Provider registrations queued during extension loading, processed when runner binds */\n\tpendingProviderRegistrations: Array<\n\t\t{ provider: Provider; extensionPath: string } | { name: string; config: ProviderConfig; extensionPath: string }\n\t>;\n\t/** Provider IDs already published on behalf of this extension generation. */\n\textensionProviderIds: Set<string>;\n\t/** Resource-level compatibility gate installed after extension provenance is resolved. */\n\tcanRegisterResource?: (extension: Extension, resourceType: ResourceOverlap[\"resourceType\"], name: string) => boolean;\n\tbeginResourceRegistrationBatch?: () => void;\n\tendResourceRegistrationBatch?: () => void;\n\trefreshToolsAfterRegistration?: () => void;\n\tapplyFlagDefaultAfterRegistration?: (\n\t\tname: string,\n\t\townerPath: string,\n\t\tvalue: boolean | string,\n\t\tconfigurationOrigin?: Extension[\"sourceInfo\"][\"configurationOrigin\"],\n\t) => void;\n\tstageToolRegistration?: (extension: Extension, name: string, registration: RegisteredTool) => boolean;\n\tstageCommandRegistration?: (extension: Extension, name: string, registration: RegisteredCommand) => boolean;\n\tstageFlagRegistration?: (\n\t\textension: Extension,\n\t\tname: string,\n\t\tregistration: ExtensionFlag,\n\t\tdefaultValue?: boolean | string,\n\t) => boolean;\n\tstageShortcutRegistration?: (extension: Extension, name: KeyId, registration: ExtensionShortcut) => boolean;\n\thasPendingResourceRegistration?: (\n\t\textension: Extension,\n\t\tresourceType: ResourceOverlap[\"resourceType\"],\n\t\tname: string,\n\t) => boolean;\n\tdeletePendingResourceRegistration?: (\n\t\textension: Extension,\n\t\tresourceType: ResourceOverlap[\"resourceType\"],\n\t\tname: string,\n\t) => void;\n\tgetPendingFlagDefault?: (ownerPath: string, name: string) => boolean | string | undefined;\n\tgetAllToolsAfterRegistration?: (extension: Extension) => ToolInfo[];\n\tgetCommandsAfterRegistration?: (extension: Extension) => SlashCommandInfo[];\n\t/** Throws when this extension instance is stale after runtime replacement. */\n\tgetActiveToolsAfterRegistration?: (extension: Extension) => string[];\n\tsetActiveToolsAfterRegistration?: (extension: Extension, toolNames: string[]) => boolean;\n\tassertActive: () => void;\n\t/** Marks this extension instance as stale after runtime replacement or reload. */\n\tinvalidate: (message?: string) => void;\n\t/** Retain an event-bus subscription until this runtime is invalidated. */\n\ttrackEventBusSubscription: (unsubscribe: () => void) => () => void;\n\t/**\n\t * Register or unregister a provider.\n\t *\n\t * Before bindCore(): queues registrations / removes from queue.\n\t * After bindCore(): calls ModelRegistry directly for immediate effect.\n\t */\n\tregisterProvider: ((name: string, config: ProviderConfig, extensionPath?: string) => void) &\n\t\t((provider: Provider, extensionPath?: string) => void);\n\tunregisterProvider: (name: string, extensionPath?: string) => void;\n}\n\n/**\n * Action implementations for pi.* API methods.\n * Provided to runner.initialize(), copied into the shared runtime.\n */\nexport interface ExtensionActions {\n\tsendMessage: SendMessageHandler;\n\tsendMessages: SendMessagesHandler;\n\tsendUserMessage: SendUserMessageHandler;\n\tappendEntry: AppendEntryHandler;\n\tsetSessionName: SetSessionNameHandler;\n\tgetSessionName: GetSessionNameHandler;\n\tsetLabel: SetLabelHandler;\n\tgetActiveTools: GetActiveToolsHandler;\n\tgetAllTools: GetAllToolsHandler;\n\tsetActiveTools: SetActiveToolsHandler;\n\trefreshTools: RefreshToolsHandler;\n\tgetCommands: GetCommandsHandler;\n\tsetModel: SetModelHandler;\n\tgetThinkingLevel: GetThinkingLevelHandler;\n\tsetThinkingLevel: SetThinkingLevelHandler;\n}\n\n/**\n * Actions for ExtensionContext (ctx.* in event handlers).\n * Required by all modes.\n */\nexport interface ExtensionContextActions {\n\tgetModel: () => Model<Api> | undefined;\n\tgetScopedModels: () => readonly ScopedModel[];\n\tgetThinkingLevel: () => ThinkingLevel | undefined;\n\tisIdle: () => boolean;\n\tisProjectTrusted: () => boolean;\n\tgetSignal: () => AbortSignal | undefined;\n\tabort: () => void;\n\thasPendingMessages: () => boolean;\n\tshutdown: () => void;\n\tgetContextUsage: () => ContextUsage | undefined;\n\tcompact: (options?: CompactOptions) => void;\n\tgetSystemPrompt: () => string;\n\tgetSkillCatalog?: () => SkillCatalog;\n\tgetSystemPromptOptions?: () => BuildSystemPromptOptions;\n\tgetRouterModel?: () => string;\n}\n\n/**\n * Actions for ExtensionCommandContext (ctx.* in command handlers).\n * Only needed for interactive mode where extension commands are invokable.\n */\nexport interface ExtensionCommandContextActions {\n\twaitForIdle: () => Promise<void>;\n\tnewSession: (options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}) => Promise<{ cancelled: boolean }>;\n\tfork: (\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t) => Promise<{ cancelled: boolean }>;\n\tnavigateTree: (\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t) => Promise<{ cancelled: boolean }>;\n\tswitchSession: (\n\t\tsessionPath: string,\n\t\toptions?: { withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t) => Promise<{ cancelled: boolean }>;\n\treload: () => Promise<void>;\n}\n\n/**\n * Full runtime = state + actions.\n * Created by loader with throwing action stubs, completed by runner.initialize().\n */\nexport interface ExtensionRuntime extends ExtensionRuntimeState, ExtensionActions {}\n\n/** Loaded extension with all registered items. */\nexport interface Extension {\n\tpath: string;\n\thidden?: boolean;\n\tresolvedPath: string;\n\tsourceInfo: SourceInfo;\n\thandlers: Map<string, HandlerFn[]>;\n\ttools: Map<string, RegisteredTool>;\n\tmessageRenderers: Map<string, MessageRenderer>;\n\tmarkdownTransformer?: MarkdownTransformer;\n\tentryRenderers: Map<string, EntryRenderer>;\n\tcommands: Map<string, RegisteredCommand>;\n\tflags: Map<string, ExtensionFlag>;\n\tshortcuts: Map<KeyId, ExtensionShortcut>;\n}\n\n/** Result of loading extensions. */\nexport interface LoadExtensionsResult {\n\textensions: Extension[];\n\terrors: Array<{ path: string; error: string }>;\n\twarnings?: Array<{ path: string; warning: string }>;\n\toverlaps?: ResourceOverlap[];\n\n\t/** Shared runtime - actions are throwing stubs until runner.initialize() */\n\truntime: ExtensionRuntime;\n}\n\nexport interface ExtensionError {\n\textensionPath: string;\n\tevent: string;\n\terror: string;\n\tstack?: string;\n}\n"]}
@@ -4,6 +4,8 @@ import type { Component } from "@earendil-works/pi-tui";
4
4
  import type { Static, TSchema } from "typebox";
5
5
  import type { Theme } from "../../modes/interactive/theme/theme.js";
6
6
  import type { SourceInfo } from "../source-info.ts";
7
+ import type { ToolConcurrency } from "../tools/tool-concurrency.ts";
8
+ export type { ToolConcurrency, ToolConcurrencyMode } from "../tools/tool-concurrency.ts";
7
9
  import type { ExtensionContext } from "./context-types.ts";
8
10
  /** Rendering options for tool results */
9
11
  export interface ToolRenderResultOptions {
@@ -79,6 +81,13 @@ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = un
79
81
  * If omitted, the default execution mode applies.
80
82
  */
81
83
  executionMode?: ToolExecutionMode;
84
+ /**
85
+ * Ordering against the other calls of the same assistant message.
86
+ * - "shared": may overlap other shared calls, but starts after the latest earlier exclusive call (default)
87
+ * - "exclusive": starts after every earlier call finishes; later calls start after it finishes
88
+ * - function: resolved per call from its arguments; a throwing resolver means "exclusive"
89
+ */
90
+ concurrency?: ToolConcurrency<Static<TParams>>;
82
91
  /** Execute the tool. */
83
92
  execute(toolCallId: string, params: Static<TParams>, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<TDetails> | undefined, ctx: ExtensionContext): Promise<AgentToolResult<TDetails>>;
84
93
  /** Custom rendering for tool call display */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/tool-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,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ts"],"names":[],"mappings":"AAgHA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,IAA+C;IAE/C,OAAO,IAAqE,CAAC;AAC9E,CAAC","sourcesContent":["import type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\nimport type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from \"@earendil-works/pi-agent-core\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { SourceInfo } from \"../source-info.ts\";\nimport type { ExtensionContext } from \"./context-types.ts\";\n\n/** Rendering options for tool results */\nexport interface ToolRenderResultOptions {\n\t/** Whether the result view is expanded */\n\texpanded: boolean;\n\t/** Whether this is a partial/streaming result */\n\tisPartial: boolean;\n}\n\n/** Context passed to tool renderers. */\nexport interface ToolRenderContext<TState = unknown, TArgs = unknown> {\n\t/** Current tool call arguments. Shared across call/result renders for the same tool call. */\n\targs: TArgs;\n\t/** Unique id for this tool execution. Stable across call/result renders for the same tool call. */\n\ttoolCallId: string;\n\t/** Invalidate just this tool execution component for redraw. */\n\tinvalidate: () => void;\n\t/** Previously returned component for this render slot, if any. */\n\tlastComponent: Component | undefined;\n\t/** Shared renderer state for this tool row. Initialized by tool-execution.ts. */\n\tstate: TState;\n\t/** Working directory for this tool execution. */\n\tcwd: string;\n\t/** Whether the tool execution has started. */\n\texecutionStarted: boolean;\n\t/** Whether the tool call arguments are complete. */\n\targsComplete: boolean;\n\t/** Whether the tool result is partial/streaming. */\n\tisPartial: boolean;\n\t/** Whether the result view is expanded. */\n\texpanded: boolean;\n\t/** Whether inline images are currently shown in the TUI. */\n\tshowImages: boolean;\n\t/** Whether the current result is an error. */\n\tisError: boolean;\n}\n\ntype ToolRenderCall<TParams extends TSchema, TState> = {\n\tbivarianceHack(args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>): Component;\n}[\"bivarianceHack\"];\n\ntype ToolRenderResult<TParams extends TSchema, TDetails, TState> = {\n\tbivarianceHack(\n\t\tresult: AgentToolResult<TDetails>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<TState, Static<TParams>>,\n\t): Component;\n}[\"bivarianceHack\"];\n\n/**\n * Tool definition for registerTool().\n */\nexport interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown, TState = unknown> {\n\t/** Tool name (used in LLM tool calls) */\n\tname: string;\n\t/** Human-readable label for UI */\n\tlabel: string;\n\t/** Description for LLM */\n\tdescription: string;\n\t/** Optional one-line snippet for the Available tools section in the default system prompt. Custom tools are omitted from that section when this is not provided. */\n\tpromptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\tpromptGuidelines?: string[];\n\t/** Parameter schema (TypeBox) */\n\tparameters: TParams;\n\t/** Optional provider-side constrained sampling request. `false` explicitly disables it. */\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n\t/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out for self-bounded tools. */\n\tmaxResultSizeChars?: number;\n\t/** Marks a terminating tool created by createStructuredOutputTool() so print mode can emit custom-named final JSON without treating every terminating tool as printable. */\n\tstructuredOutput?: true;\n\t/** Controls whether ToolExecutionComponent renders the standard colored shell or the tool renders its own framing. */\n\trenderShell?: \"default\" | \"self\";\n\n\t/** Optional compatibility shim to prepare raw tool call arguments before schema validation. Must return an object conforming to TParams. */\n\tprepareArguments?: (args: unknown) => Static<TParams>;\n\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n\n\t/** Execute the tool. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParams>,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: AgentToolUpdateCallback<TDetails> | undefined,\n\t\tctx: ExtensionContext,\n\t): Promise<AgentToolResult<TDetails>>;\n\n\t/** Custom rendering for tool call display */\n\trenderCall?: ToolRenderCall<TParams, TState>;\n\n\t/** Custom rendering for tool result display */\n\trenderResult?: ToolRenderResult<TParams, TDetails, TState>;\n}\n\ntype AnyToolDefinition = ToolDefinition<TSchema, unknown, unknown>;\n\n/**\n * Preserve parameter inference for standalone tool definitions.\n *\n * Use this when assigning a tool to a variable or passing it through arrays such\n * as `customTools`, where contextual typing would otherwise widen params to\n * `unknown`.\n */\nexport function defineTool<TParams extends TSchema, TDetails = unknown, TState = unknown>(\n\ttool: ToolDefinition<TParams, TDetails, TState>,\n): ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition {\n\treturn tool as ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition;\n}\n\n/** Public constrained-sampling shape inherited from pi-ai. */\nexport type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\n\n/** Tool info with name, description, parameter schema, constraint, and source metadata */\nexport type ToolInfo = Pick<\n\tToolDefinition,\n\t\"name\" | \"description\" | \"parameters\" | \"constrainedSampling\" | \"promptGuidelines\"\n> & {\n\tsourceInfo: SourceInfo;\n};\n"]}
1
+ {"version":3,"file":"tool-types.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-types.ts"],"names":[],"mappings":"AA4HA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,IAA+C;IAE/C,OAAO,IAAqE,CAAC;AAC9E,CAAC","sourcesContent":["import type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\nimport type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from \"@earendil-works/pi-agent-core\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { SourceInfo } from \"../source-info.ts\";\nimport type { ToolConcurrency } from \"../tools/tool-concurrency.ts\";\n\nexport type { ToolConcurrency, ToolConcurrencyMode } from \"../tools/tool-concurrency.ts\";\n\nimport type { ExtensionContext } from \"./context-types.ts\";\n\n/** Rendering options for tool results */\nexport interface ToolRenderResultOptions {\n\t/** Whether the result view is expanded */\n\texpanded: boolean;\n\t/** Whether this is a partial/streaming result */\n\tisPartial: boolean;\n}\n\n/** Context passed to tool renderers. */\nexport interface ToolRenderContext<TState = unknown, TArgs = unknown> {\n\t/** Current tool call arguments. Shared across call/result renders for the same tool call. */\n\targs: TArgs;\n\t/** Unique id for this tool execution. Stable across call/result renders for the same tool call. */\n\ttoolCallId: string;\n\t/** Invalidate just this tool execution component for redraw. */\n\tinvalidate: () => void;\n\t/** Previously returned component for this render slot, if any. */\n\tlastComponent: Component | undefined;\n\t/** Shared renderer state for this tool row. Initialized by tool-execution.ts. */\n\tstate: TState;\n\t/** Working directory for this tool execution. */\n\tcwd: string;\n\t/** Whether the tool execution has started. */\n\texecutionStarted: boolean;\n\t/** Whether the tool call arguments are complete. */\n\targsComplete: boolean;\n\t/** Whether the tool result is partial/streaming. */\n\tisPartial: boolean;\n\t/** Whether the result view is expanded. */\n\texpanded: boolean;\n\t/** Whether inline images are currently shown in the TUI. */\n\tshowImages: boolean;\n\t/** Whether the current result is an error. */\n\tisError: boolean;\n}\n\ntype ToolRenderCall<TParams extends TSchema, TState> = {\n\tbivarianceHack(args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>): Component;\n}[\"bivarianceHack\"];\n\ntype ToolRenderResult<TParams extends TSchema, TDetails, TState> = {\n\tbivarianceHack(\n\t\tresult: AgentToolResult<TDetails>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<TState, Static<TParams>>,\n\t): Component;\n}[\"bivarianceHack\"];\n\n/**\n * Tool definition for registerTool().\n */\nexport interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = unknown, TState = unknown> {\n\t/** Tool name (used in LLM tool calls) */\n\tname: string;\n\t/** Human-readable label for UI */\n\tlabel: string;\n\t/** Description for LLM */\n\tdescription: string;\n\t/** Optional one-line snippet for the Available tools section in the default system prompt. Custom tools are omitted from that section when this is not provided. */\n\tpromptSnippet?: string;\n\t/** Optional guideline bullets appended to the default system prompt Guidelines section when this tool is active. */\n\tpromptGuidelines?: string[];\n\t/** Parameter schema (TypeBox) */\n\tparameters: TParams;\n\t/** Optional provider-side constrained sampling request. `false` explicitly disables it. */\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n\t/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out for self-bounded tools. */\n\tmaxResultSizeChars?: number;\n\t/** Marks a terminating tool created by createStructuredOutputTool() so print mode can emit custom-named final JSON without treating every terminating tool as printable. */\n\tstructuredOutput?: true;\n\t/** Controls whether ToolExecutionComponent renders the standard colored shell or the tool renders its own framing. */\n\trenderShell?: \"default\" | \"self\";\n\n\t/** Optional compatibility shim to prepare raw tool call arguments before schema validation. Must return an object conforming to TParams. */\n\tprepareArguments?: (args: unknown) => Static<TParams>;\n\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n\n\t/**\n\t * Ordering against the other calls of the same assistant message.\n\t * - \"shared\": may overlap other shared calls, but starts after the latest earlier exclusive call (default)\n\t * - \"exclusive\": starts after every earlier call finishes; later calls start after it finishes\n\t * - function: resolved per call from its arguments; a throwing resolver means \"exclusive\"\n\t */\n\tconcurrency?: ToolConcurrency<Static<TParams>>;\n\n\t/** Execute the tool. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParams>,\n\t\tsignal: AbortSignal | undefined,\n\t\tonUpdate: AgentToolUpdateCallback<TDetails> | undefined,\n\t\tctx: ExtensionContext,\n\t): Promise<AgentToolResult<TDetails>>;\n\n\t/** Custom rendering for tool call display */\n\trenderCall?: ToolRenderCall<TParams, TState>;\n\n\t/** Custom rendering for tool result display */\n\trenderResult?: ToolRenderResult<TParams, TDetails, TState>;\n}\n\ntype AnyToolDefinition = ToolDefinition<TSchema, unknown, unknown>;\n\n/**\n * Preserve parameter inference for standalone tool definitions.\n *\n * Use this when assigning a tool to a variable or passing it through arrays such\n * as `customTools`, where contextual typing would otherwise widen params to\n * `unknown`.\n */\nexport function defineTool<TParams extends TSchema, TDetails = unknown, TState = unknown>(\n\ttool: ToolDefinition<TParams, TDetails, TState>,\n): ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition {\n\treturn tool as ToolDefinition<TParams, TDetails, TState> & AnyToolDefinition;\n}\n\n/** Public constrained-sampling shape inherited from pi-ai. */\nexport type { ConstrainedSamplingConfig } from \"@bastani/pi-ai/compat\";\n\n/** Tool info with name, description, parameter schema, constraint, and source metadata */\nexport type ToolInfo = Pick<\n\tToolDefinition,\n\t\"name\" | \"description\" | \"parameters\" | \"constrainedSampling\" | \"promptGuidelines\"\n> & {\n\tsourceInfo: SourceInfo;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fast-model-routing.d.ts","sourceRoot":"","sources":["../../src/core/fast-model-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EACN,KAAK,GAAG,EACR,KAAK,2BAA2B,EAChC,KAAK,OAAO,EAEZ,KAAK,KAAK,EACV,KAAK,cAAc,EAEnB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAIlB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,uBAAuB,EAAwB,MAAM,0BAA0B,CAAC;AAEzF,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IAClE,WAAW,CAAC,EAAE,OAAO,uBAAuB,CAAC;CAC7C;AAED,MAAM,WAA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C,GAAG,CAAC,EACjB,OAAO,EAAE,sBAAsB,GAAG,SAAS,GACzC,2BAA2B,CAM7B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,sBAAsB,GAAG,SAAS,EAC3C,SAAS,GAAE,kBAAiD,GAC1D,2BAA2B,CAyB7B"}
@@ -150,6 +150,7 @@ function buildFastRouteBaseProviderOptions(model, options) {
150
150
  sessionId: options?.sessionId,
151
151
  onPayload: options?.onPayload,
152
152
  onResponse: options?.onResponse,
153
+ onProviderStreamEvent: options?.onProviderStreamEvent,
153
154
  headers: options?.headers,
154
155
  timeoutMs: options?.timeoutMs,
155
156
  websocketConnectTimeoutMs: options?.websocketConnectTimeoutMs,
@@ -1 +1 @@
1
- {"version":3,"file":"fast-model-routing.js","sourceRoot":"","sources":["../../src/core/fast-model-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAIN,kBAAkB,EAGlB,gBAAgB,EAMhB,0BAA0B,EAC1B,qBAAqB,EACrB,YAAY,GAGZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,gCAAgC,EAChC,sCAAsC,EACtC,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoBzF,MAAM,4BAA4B,GAAuB;IACxD,YAAY;IACZ,qBAAqB;IACrB,0BAA0B;CAC1B,CAAC;AAEF,MAAM,qCAAqC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5D,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAwE,CAAC;AAEnH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA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OAAO,EAAE,SAAS,KAAK,KAAK,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,sCAAsC,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,SAAS,CAAC,0BAA0B,CAC1C,KAAwC,EACxC,gBAAgB,CAAC,OAAO,CAAC,EACzB,yCAAyC,CAAC,KAAK,EAAE,OAAO,CAAC,CACzD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { closeOpenAICodexWebSocketSessions } from \"@bastani/pi-ai/api/openai-codex-responses\";\nimport {\n\ttype Api,\n\ttype AssistantMessageEventStream,\n\ttype Context,\n\tclampThinkingLevel,\n\ttype Model,\n\ttype ModelFastRoute,\n\tnormalizeContext,\n\ttype OpenAICodexResponsesOptions,\n\ttype OpenAIResponsesOptions,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\tstreamOpenAICodexResponses,\n\tstreamOpenAIResponses,\n\tstreamSimple,\n\ttype ThinkingLevel,\n\ttype TranscriptContext,\n} from \"@bastani/pi-ai/compat\";\nimport {\n\tCODEX_FAST_ROUTE_HEADER,\n\tCODEX_FAST_ROUTE_ORIGINATOR,\n\tclearCodexFastRouteRequestMarker,\n\tinstallCodexFastRouteWebSocketIdentity,\n\tisFirstPartyCodexBaseUrl,\n\tmarkCodexFastRouteRequest,\n\twrapCodexFastRouteFetch,\n} from \"./fast-model-routing-transport.ts\";\nimport { FAST_MODEL_SERVICE_TIER, isNativeFastRouteApi } from \"./fast-model-variants.ts\";\n\nexport interface FastRouteStreamOptions extends SimpleStreamOptions {\n\tserviceTier?: typeof FAST_MODEL_SERVICE_TIER;\n}\n\nexport interface FastRouteStreamers {\n\tstreamSimple: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\tstreamOpenAIResponses: (\n\t\tmodel: Model<\"openai-responses\">,\n\t\tcontext: TranscriptContext,\n\t\toptions?: OpenAIResponsesOptions,\n\t) => AssistantMessageEventStream;\n\tstreamOpenAICodexResponses: (\n\t\tmodel: Model<\"openai-codex-responses\">,\n\t\tcontext: TranscriptContext,\n\t\toptions?: OpenAICodexResponsesOptions,\n\t) => AssistantMessageEventStream;\n}\n\nconst DEFAULT_FAST_ROUTE_STREAMERS: FastRouteStreamers = {\n\tstreamSimple,\n\tstreamOpenAIResponses,\n\tstreamOpenAICodexResponses,\n};\n\nconst CODEX_WEBSOCKET_ROUTING_STATE_IDLE_MS = 6 * 60 * 1000;\nconst codexWebSocketRoutingState = new Map<string, { signature: string; expiry: ReturnType<typeof setTimeout> }>();\n\n/**\n * Explicit route metadata is the only source of fast semantics. A model whose ID merely ends in\n * `-fast` — a provider, `models.json`, or extension model that owns that exact ID — routes normally.\n */\nexport function getModelFastRoute(model: Pick<Model<Api>, \"fastRoute\">): ModelFastRoute | undefined {\n\treturn model.fastRoute;\n}\n\n/**\n * The model ID this request sends upstream. An OpenAI-style fast route sends the base model and\n * carries a priority service tier instead; a provider with real fast siblings sends its own\n * advertised ID, which is already the canonical one. The canonical `-fast` identity always stays on\n * the model object Atomic selected, persisted, and records — only the serialized request differs.\n */\nexport function resolveUpstreamModelId(model: Pick<Model<Api>, \"fastRoute\" | \"id\">): string {\n\treturn model.fastRoute?.upstreamModelId ?? model.id;\n}\n\n/**\n * Whether a model uses the first-party OpenAI Codex provider identity and endpoint.\n * A renamed provider on the same protocol remains non-first-party.\n */\nexport function usesFirstPartyCodexRouting(model: Pick<Model<Api>, \"baseUrl\" | \"provider\">): boolean {\n\treturn model.provider === \"openai-codex\" && isFirstPartyCodexBaseUrl(model.baseUrl);\n}\n\n/** A provider alias or proxy still uses the shared ChatGPT Codex protocol when its API does. */\nexport function usesChatGptCodexTransport(model: Pick<Model<Api>, \"api\">): boolean {\n\treturn model.api === \"openai-codex-responses\";\n}\n\nfunction deleteHeader(headers: ProviderHeaders, name: string): void {\n\tfor (const existingName of Object.keys(headers)) {\n\t\tif (existingName.toLowerCase() === name.toLowerCase()) delete headers[existingName];\n\t}\n}\n\nfunction setHeader(headers: ProviderHeaders, name: string, value: string): void {\n\tdeleteHeader(headers, name);\n\theaders[name] = value;\n}\n\n/**\n * Eager first-party routing headers for a model that carries an OpenAI-style fast route.\n *\n * Derived entirely from the model: the headers are added only when the model's own `fastRoute`\n * declares the priority tier and the model uses first-party Codex routing, and the hint names the\n * route's upstream model ID — the same value the request serializes and\n * `withChatGptCodexTransportRouting` reads from route metadata. There is no caller-supplied enable\n * flag, so a model without a route can never be granted this identity.\n */\nexport function withCodexFastRouteHeaders(\n\tmodel: Pick<Model<Api>, \"baseUrl\" | \"fastRoute\" | \"id\" | \"provider\">,\n\theaders: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (getModelFastRoute(model)?.serviceTier !== FAST_MODEL_SERVICE_TIER || !usesFirstPartyCodexRouting(model)) {\n\t\treturn headers;\n\t}\n\tconst fastHeaders: ProviderHeaders = { ...(headers ?? {}) };\n\tsetHeader(fastHeaders, \"originator\", CODEX_FAST_ROUTE_ORIGINATOR);\n\tsetHeader(\n\t\tfastHeaders,\n\t\tCODEX_FAST_ROUTE_HEADER,\n\t\t`model=${resolveUpstreamModelId(model)};tier=${FAST_MODEL_SERVICE_TIER}`,\n\t);\n\treturn fastHeaders;\n}\n\n/** Attach the route's service tier to the outgoing stream options. */\nexport function withFastRouteStreamOptions(\n\tfastRoute: ModelFastRoute | undefined,\n\toptions: SimpleStreamOptions | undefined,\n): FastRouteStreamOptions | undefined {\n\tif (fastRoute?.serviceTier === undefined) return options;\n\treturn { ...(options ?? {}), headers: options?.headers, serviceTier: fastRoute.serviceTier };\n}\n\n/** A service-tier route needs pi-ai's native adapters; `streamSimple` drops `serviceTier`. */\nexport function shouldUseNativeFastRoute(\n\tmodel: Pick<Model<Api>, \"api\">,\n\toptions: FastRouteStreamOptions | undefined,\n): boolean {\n\treturn isNativeFastRouteApi(model.api) && options?.serviceTier === FAST_MODEL_SERVICE_TIER;\n}\n\nfunction codexEnvironmentScope(env: StreamOptions[\"env\"]): string {\n\tif (!env) return \"none\";\n\tconst serialized = JSON.stringify(Object.entries(env).sort(([left], [right]) => left.localeCompare(right)));\n\tlet hash = 2166136261;\n\tfor (let index = 0; index < serialized.length; index += 1) {\n\t\thash = Math.imul(hash ^ serialized.charCodeAt(index), 16777619);\n\t}\n\treturn (hash >>> 0).toString(16);\n}\n\ntype CloseCodexWebSocketSessions = typeof closeOpenAICodexWebSocketSessions;\nfunction updateCodexWebSocketRoutingState(\n\tmodel: Pick<Model<Api>, \"baseUrl\" | \"provider\">,\n\troutedModel: string,\n\toptions: Pick<StreamOptions, \"env\" | \"sessionId\" | \"transport\">,\n\tpriority: boolean,\n\tcloseWebSocketSessions: CloseCodexWebSocketSessions,\n): void {\n\tif (options.transport === \"sse\" || !options.sessionId) return;\n\tconst signature = `${model.provider}\\0${model.baseUrl}\\0${codexEnvironmentScope(options.env)}\\0${priority ? `priority:${routedModel}` : \"normal\"}`;\n\tconst previous = codexWebSocketRoutingState.get(options.sessionId);\n\tif (previous?.signature !== undefined && previous.signature !== signature) {\n\t\tcloseWebSocketSessions(options.sessionId);\n\t}\n\tif (previous) clearTimeout(previous.expiry);\n\tconst expiry = setTimeout(() => {\n\t\tif (codexWebSocketRoutingState.get(options.sessionId!)?.signature === signature) {\n\t\t\tcodexWebSocketRoutingState.delete(options.sessionId!);\n\t\t}\n\t}, CODEX_WEBSOCKET_ROUTING_STATE_IDLE_MS);\n\texpiry.unref?.();\n\tcodexWebSocketRoutingState.set(options.sessionId, { signature, expiry });\n}\n\nexport function withChatGptCodexTransportRouting<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions,\n\tcloseWebSocketSessions: CloseCodexWebSocketSessions = closeOpenAICodexWebSocketSessions,\n): TOptions {\n\tconst headers: ProviderHeaders = { ...(options.headers ?? {}) };\n\tconst onPayload = options.onPayload;\n\tconst priority =\n\t\tgetModelFastRoute(model)?.serviceTier === FAST_MODEL_SERVICE_TIER && usesFirstPartyCodexRouting(model);\n\tconst routedModel = resolveUpstreamModelId(model);\n\treturn {\n\t\t...options,\n\t\theaders,\n\t\tfetch: wrapCodexFastRouteFetch(options.fetch ?? globalThis.fetch),\n\t\tonPayload: async (payload, requestModel) => {\n\t\t\tconst replacement = await onPayload?.(payload, requestModel);\n\t\t\tconst finalPayload = replacement === undefined ? payload : replacement;\n\t\t\tdeleteHeader(headers, CODEX_FAST_ROUTE_HEADER);\n\t\t\tclearCodexFastRouteRequestMarker(headers);\n\t\t\tif (priority) {\n\t\t\t\tsetHeader(headers, CODEX_FAST_ROUTE_HEADER, `model=${routedModel};tier=${FAST_MODEL_SERVICE_TIER}`);\n\t\t\t} else {\n\t\t\t\tfor (const [name, value] of Object.entries(headers)) {\n\t\t\t\t\tif (name.toLowerCase() === \"originator\" && value === CODEX_FAST_ROUTE_ORIGINATOR) delete headers[name];\n\t\t\t\t}\n\t\t\t}\n\t\t\tmarkCodexFastRouteRequest(headers, priority);\n\t\t\tupdateCodexWebSocketRoutingState(model, routedModel, options, priority, closeWebSocketSessions);\n\t\t\treturn finalPayload;\n\t\t},\n\t} as TOptions;\n}\n\nfunction buildFastRouteBaseProviderOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): StreamOptions {\n\t// Native fast-route streams bypass pi-ai's streamSimple base-options merge.\n\tconst samplingParams =\n\t\tmodel.samplingParams || options?.samplingParams\n\t\t\t? { ...model.samplingParams, ...options?.samplingParams }\n\t\t\t: undefined;\n\tconst providerOptions: StreamOptions = {\n\t\tsamplingParams,\n\t\ttemperature: options?.temperature,\n\t\tmaxTokens: options?.maxTokens,\n\t\tsignal: options?.signal,\n\t\tapiKey: options?.apiKey,\n\t\tfetch: options?.fetch,\n\t\tenv: options?.env,\n\t\ttelemetryContext: options?.telemetryContext,\n\t\ttransport: options?.transport,\n\t\tcacheRetention: options?.cacheRetention,\n\t\tsessionId: options?.sessionId,\n\t\tonPayload: options?.onPayload,\n\t\tonResponse: options?.onResponse,\n\t\theaders: options?.headers,\n\t\ttimeoutMs: options?.timeoutMs,\n\t\twebsocketConnectTimeoutMs: options?.websocketConnectTimeoutMs,\n\t\tstreamDeadlineMs: options?.streamDeadlineMs,\n\t\tmaxRetries: options?.maxRetries,\n\t\tmaxRetryDelayMs: options?.maxRetryDelayMs,\n\t\tmetadata: options?.metadata,\n\t};\n\treturn usesChatGptCodexTransport(model) ? withChatGptCodexTransportRouting(model, providerOptions) : providerOptions;\n}\n\nexport function mapFastRouteReasoningEffort(\n\tmodel: Model<Api>,\n\treasoning: ThinkingLevel | undefined,\n): ThinkingLevel | undefined {\n\tconst clampedReasoning = reasoning ? clampThinkingLevel(model, reasoning) : undefined;\n\treturn clampedReasoning === \"off\" ? undefined : clampedReasoning;\n}\n\nexport function buildOpenAIResponsesFastRouteOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): OpenAIResponsesOptions {\n\treturn {\n\t\t...buildFastRouteBaseProviderOptions(model, options),\n\t\treasoningEffort: mapFastRouteReasoningEffort(model, options?.reasoning),\n\t\tserviceTier: options?.serviceTier,\n\t};\n}\n\nexport function buildOpenAICodexResponsesFastRouteOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): OpenAICodexResponsesOptions {\n\treturn {\n\t\t...buildFastRouteBaseProviderOptions(model, options),\n\t\treasoningEffort: mapFastRouteReasoningEffort(model, options?.reasoning),\n\t\tserviceTier: options?.serviceTier,\n\t};\n}\n\n/**\n * Stream a request whose canonical selected model carries fast-route metadata. The provider adapter\n * translates only the serialized request to the route's upstream ID; the model object keeps its\n * canonical `-fast` identity.\n */\nexport function streamWithFastRoute(\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions: FastRouteStreamOptions | undefined,\n\tstreamers: FastRouteStreamers = DEFAULT_FAST_ROUTE_STREAMERS,\n): AssistantMessageEventStream {\n\tif (shouldUseNativeFastRoute(model, options)) {\n\t\tif (model.api === \"openai-responses\") {\n\t\t\treturn streamers.streamOpenAIResponses(\n\t\t\t\tmodel as Model<\"openai-responses\">,\n\t\t\t\tnormalizeContext(context),\n\t\t\t\tbuildOpenAIResponsesFastRouteOptions(model, options),\n\t\t\t);\n\t\t}\n\n\t\t// The WebSocket handshake builds its headers inside pi-ai, and the runtime\n\t\t// constructor can be cached before the first turn, so repair the identity\n\t\t// through the global constructor rather than per-request options.\n\t\tif (options?.transport !== \"sse\" && usesChatGptCodexTransport(model)) {\n\t\t\tinstallCodexFastRouteWebSocketIdentity();\n\t\t}\n\n\t\treturn streamers.streamOpenAICodexResponses(\n\t\t\tmodel as Model<\"openai-codex-responses\">,\n\t\t\tnormalizeContext(context),\n\t\t\tbuildOpenAICodexResponsesFastRouteOptions(model, options),\n\t\t);\n\t}\n\n\treturn streamers.streamSimple(model, context, options);\n}\n"]}
1
+ {"version":3,"file":"fast-model-routing.js","sourceRoot":"","sources":["../../src/core/fast-model-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAC9F,OAAO,EAIN,kBAAkB,EAGlB,gBAAgB,EAMhB,0BAA0B,EAC1B,qBAAqB,EACrB,YAAY,GAGZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,gCAAgC,EAChC,sCAAsC,EACtC,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoBzF,MAAM,4BAA4B,GAAuB;IACxD,YAAY;IACZ,qBAAqB;IACrB,0BAA0B;CAC1B,CAAC;AAEF,MAAM,qCAAqC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5D,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAwE,CA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AE,OAAO,CAAC,CACpD,CAAC;QACH,CAAC;QAED,2EAA2E;QAC3E,0EAA0E;QAC1E,kEAAkE;QAClE,IAAI,OAAO,EAAE,SAAS,KAAK,KAAK,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,sCAAsC,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,SAAS,CAAC,0BAA0B,CAC1C,KAAwC,EACxC,gBAAgB,CAAC,OAAO,CAAC,EACzB,yCAAyC,CAAC,KAAK,EAAE,OAAO,CAAC,CACzD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { closeOpenAICodexWebSocketSessions } from \"@bastani/pi-ai/api/openai-codex-responses\";\nimport {\n\ttype Api,\n\ttype AssistantMessageEventStream,\n\ttype Context,\n\tclampThinkingLevel,\n\ttype Model,\n\ttype ModelFastRoute,\n\tnormalizeContext,\n\ttype OpenAICodexResponsesOptions,\n\ttype OpenAIResponsesOptions,\n\ttype ProviderHeaders,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n\tstreamOpenAICodexResponses,\n\tstreamOpenAIResponses,\n\tstreamSimple,\n\ttype ThinkingLevel,\n\ttype TranscriptContext,\n} from \"@bastani/pi-ai/compat\";\nimport {\n\tCODEX_FAST_ROUTE_HEADER,\n\tCODEX_FAST_ROUTE_ORIGINATOR,\n\tclearCodexFastRouteRequestMarker,\n\tinstallCodexFastRouteWebSocketIdentity,\n\tisFirstPartyCodexBaseUrl,\n\tmarkCodexFastRouteRequest,\n\twrapCodexFastRouteFetch,\n} from \"./fast-model-routing-transport.ts\";\nimport { FAST_MODEL_SERVICE_TIER, isNativeFastRouteApi } from \"./fast-model-variants.ts\";\n\nexport interface FastRouteStreamOptions extends SimpleStreamOptions {\n\tserviceTier?: typeof FAST_MODEL_SERVICE_TIER;\n}\n\nexport interface FastRouteStreamers {\n\tstreamSimple: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;\n\tstreamOpenAIResponses: (\n\t\tmodel: Model<\"openai-responses\">,\n\t\tcontext: TranscriptContext,\n\t\toptions?: OpenAIResponsesOptions,\n\t) => AssistantMessageEventStream;\n\tstreamOpenAICodexResponses: (\n\t\tmodel: Model<\"openai-codex-responses\">,\n\t\tcontext: TranscriptContext,\n\t\toptions?: OpenAICodexResponsesOptions,\n\t) => AssistantMessageEventStream;\n}\n\nconst DEFAULT_FAST_ROUTE_STREAMERS: FastRouteStreamers = {\n\tstreamSimple,\n\tstreamOpenAIResponses,\n\tstreamOpenAICodexResponses,\n};\n\nconst CODEX_WEBSOCKET_ROUTING_STATE_IDLE_MS = 6 * 60 * 1000;\nconst codexWebSocketRoutingState = new Map<string, { signature: string; expiry: ReturnType<typeof setTimeout> }>();\n\n/**\n * Explicit route metadata is the only source of fast semantics. A model whose ID merely ends in\n * `-fast` — a provider, `models.json`, or extension model that owns that exact ID — routes normally.\n */\nexport function getModelFastRoute(model: Pick<Model<Api>, \"fastRoute\">): ModelFastRoute | undefined {\n\treturn model.fastRoute;\n}\n\n/**\n * The model ID this request sends upstream. An OpenAI-style fast route sends the base model and\n * carries a priority service tier instead; a provider with real fast siblings sends its own\n * advertised ID, which is already the canonical one. The canonical `-fast` identity always stays on\n * the model object Atomic selected, persisted, and records — only the serialized request differs.\n */\nexport function resolveUpstreamModelId(model: Pick<Model<Api>, \"fastRoute\" | \"id\">): string {\n\treturn model.fastRoute?.upstreamModelId ?? model.id;\n}\n\n/**\n * Whether a model uses the first-party OpenAI Codex provider identity and endpoint.\n * A renamed provider on the same protocol remains non-first-party.\n */\nexport function usesFirstPartyCodexRouting(model: Pick<Model<Api>, \"baseUrl\" | \"provider\">): boolean {\n\treturn model.provider === \"openai-codex\" && isFirstPartyCodexBaseUrl(model.baseUrl);\n}\n\n/** A provider alias or proxy still uses the shared ChatGPT Codex protocol when its API does. */\nexport function usesChatGptCodexTransport(model: Pick<Model<Api>, \"api\">): boolean {\n\treturn model.api === \"openai-codex-responses\";\n}\n\nfunction deleteHeader(headers: ProviderHeaders, name: string): void {\n\tfor (const existingName of Object.keys(headers)) {\n\t\tif (existingName.toLowerCase() === name.toLowerCase()) delete headers[existingName];\n\t}\n}\n\nfunction setHeader(headers: ProviderHeaders, name: string, value: string): void {\n\tdeleteHeader(headers, name);\n\theaders[name] = value;\n}\n\n/**\n * Eager first-party routing headers for a model that carries an OpenAI-style fast route.\n *\n * Derived entirely from the model: the headers are added only when the model's own `fastRoute`\n * declares the priority tier and the model uses first-party Codex routing, and the hint names the\n * route's upstream model ID — the same value the request serializes and\n * `withChatGptCodexTransportRouting` reads from route metadata. There is no caller-supplied enable\n * flag, so a model without a route can never be granted this identity.\n */\nexport function withCodexFastRouteHeaders(\n\tmodel: Pick<Model<Api>, \"baseUrl\" | \"fastRoute\" | \"id\" | \"provider\">,\n\theaders: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (getModelFastRoute(model)?.serviceTier !== FAST_MODEL_SERVICE_TIER || !usesFirstPartyCodexRouting(model)) {\n\t\treturn headers;\n\t}\n\tconst fastHeaders: ProviderHeaders = { ...(headers ?? {}) };\n\tsetHeader(fastHeaders, \"originator\", CODEX_FAST_ROUTE_ORIGINATOR);\n\tsetHeader(\n\t\tfastHeaders,\n\t\tCODEX_FAST_ROUTE_HEADER,\n\t\t`model=${resolveUpstreamModelId(model)};tier=${FAST_MODEL_SERVICE_TIER}`,\n\t);\n\treturn fastHeaders;\n}\n\n/** Attach the route's service tier to the outgoing stream options. */\nexport function withFastRouteStreamOptions(\n\tfastRoute: ModelFastRoute | undefined,\n\toptions: SimpleStreamOptions | undefined,\n): FastRouteStreamOptions | undefined {\n\tif (fastRoute?.serviceTier === undefined) return options;\n\treturn { ...(options ?? {}), headers: options?.headers, serviceTier: fastRoute.serviceTier };\n}\n\n/** A service-tier route needs pi-ai's native adapters; `streamSimple` drops `serviceTier`. */\nexport function shouldUseNativeFastRoute(\n\tmodel: Pick<Model<Api>, \"api\">,\n\toptions: FastRouteStreamOptions | undefined,\n): boolean {\n\treturn isNativeFastRouteApi(model.api) && options?.serviceTier === FAST_MODEL_SERVICE_TIER;\n}\n\nfunction codexEnvironmentScope(env: StreamOptions[\"env\"]): string {\n\tif (!env) return \"none\";\n\tconst serialized = JSON.stringify(Object.entries(env).sort(([left], [right]) => left.localeCompare(right)));\n\tlet hash = 2166136261;\n\tfor (let index = 0; index < serialized.length; index += 1) {\n\t\thash = Math.imul(hash ^ serialized.charCodeAt(index), 16777619);\n\t}\n\treturn (hash >>> 0).toString(16);\n}\n\ntype CloseCodexWebSocketSessions = typeof closeOpenAICodexWebSocketSessions;\nfunction updateCodexWebSocketRoutingState(\n\tmodel: Pick<Model<Api>, \"baseUrl\" | \"provider\">,\n\troutedModel: string,\n\toptions: Pick<StreamOptions, \"env\" | \"sessionId\" | \"transport\">,\n\tpriority: boolean,\n\tcloseWebSocketSessions: CloseCodexWebSocketSessions,\n): void {\n\tif (options.transport === \"sse\" || !options.sessionId) return;\n\tconst signature = `${model.provider}\\0${model.baseUrl}\\0${codexEnvironmentScope(options.env)}\\0${priority ? `priority:${routedModel}` : \"normal\"}`;\n\tconst previous = codexWebSocketRoutingState.get(options.sessionId);\n\tif (previous?.signature !== undefined && previous.signature !== signature) {\n\t\tcloseWebSocketSessions(options.sessionId);\n\t}\n\tif (previous) clearTimeout(previous.expiry);\n\tconst expiry = setTimeout(() => {\n\t\tif (codexWebSocketRoutingState.get(options.sessionId!)?.signature === signature) {\n\t\t\tcodexWebSocketRoutingState.delete(options.sessionId!);\n\t\t}\n\t}, CODEX_WEBSOCKET_ROUTING_STATE_IDLE_MS);\n\texpiry.unref?.();\n\tcodexWebSocketRoutingState.set(options.sessionId, { signature, expiry });\n}\n\nexport function withChatGptCodexTransportRouting<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions,\n\tcloseWebSocketSessions: CloseCodexWebSocketSessions = closeOpenAICodexWebSocketSessions,\n): TOptions {\n\tconst headers: ProviderHeaders = { ...(options.headers ?? {}) };\n\tconst onPayload = options.onPayload;\n\tconst priority =\n\t\tgetModelFastRoute(model)?.serviceTier === FAST_MODEL_SERVICE_TIER && usesFirstPartyCodexRouting(model);\n\tconst routedModel = resolveUpstreamModelId(model);\n\treturn {\n\t\t...options,\n\t\theaders,\n\t\tfetch: wrapCodexFastRouteFetch(options.fetch ?? globalThis.fetch),\n\t\tonPayload: async (payload, requestModel) => {\n\t\t\tconst replacement = await onPayload?.(payload, requestModel);\n\t\t\tconst finalPayload = replacement === undefined ? payload : replacement;\n\t\t\tdeleteHeader(headers, CODEX_FAST_ROUTE_HEADER);\n\t\t\tclearCodexFastRouteRequestMarker(headers);\n\t\t\tif (priority) {\n\t\t\t\tsetHeader(headers, CODEX_FAST_ROUTE_HEADER, `model=${routedModel};tier=${FAST_MODEL_SERVICE_TIER}`);\n\t\t\t} else {\n\t\t\t\tfor (const [name, value] of Object.entries(headers)) {\n\t\t\t\t\tif (name.toLowerCase() === \"originator\" && value === CODEX_FAST_ROUTE_ORIGINATOR) delete headers[name];\n\t\t\t\t}\n\t\t\t}\n\t\t\tmarkCodexFastRouteRequest(headers, priority);\n\t\t\tupdateCodexWebSocketRoutingState(model, routedModel, options, priority, closeWebSocketSessions);\n\t\t\treturn finalPayload;\n\t\t},\n\t} as TOptions;\n}\n\nfunction buildFastRouteBaseProviderOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): StreamOptions {\n\t// Native fast-route streams bypass pi-ai's streamSimple base-options merge.\n\tconst samplingParams =\n\t\tmodel.samplingParams || options?.samplingParams\n\t\t\t? { ...model.samplingParams, ...options?.samplingParams }\n\t\t\t: undefined;\n\tconst providerOptions: StreamOptions = {\n\t\tsamplingParams,\n\t\ttemperature: options?.temperature,\n\t\tmaxTokens: options?.maxTokens,\n\t\tsignal: options?.signal,\n\t\tapiKey: options?.apiKey,\n\t\tfetch: options?.fetch,\n\t\tenv: options?.env,\n\t\ttelemetryContext: options?.telemetryContext,\n\t\ttransport: options?.transport,\n\t\tcacheRetention: options?.cacheRetention,\n\t\tsessionId: options?.sessionId,\n\t\tonPayload: options?.onPayload,\n\t\tonResponse: options?.onResponse,\n\t\tonProviderStreamEvent: options?.onProviderStreamEvent,\n\t\theaders: options?.headers,\n\t\ttimeoutMs: options?.timeoutMs,\n\t\twebsocketConnectTimeoutMs: options?.websocketConnectTimeoutMs,\n\t\tstreamDeadlineMs: options?.streamDeadlineMs,\n\t\tmaxRetries: options?.maxRetries,\n\t\tmaxRetryDelayMs: options?.maxRetryDelayMs,\n\t\tmetadata: options?.metadata,\n\t};\n\treturn usesChatGptCodexTransport(model) ? withChatGptCodexTransportRouting(model, providerOptions) : providerOptions;\n}\n\nexport function mapFastRouteReasoningEffort(\n\tmodel: Model<Api>,\n\treasoning: ThinkingLevel | undefined,\n): ThinkingLevel | undefined {\n\tconst clampedReasoning = reasoning ? clampThinkingLevel(model, reasoning) : undefined;\n\treturn clampedReasoning === \"off\" ? undefined : clampedReasoning;\n}\n\nexport function buildOpenAIResponsesFastRouteOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): OpenAIResponsesOptions {\n\treturn {\n\t\t...buildFastRouteBaseProviderOptions(model, options),\n\t\treasoningEffort: mapFastRouteReasoningEffort(model, options?.reasoning),\n\t\tserviceTier: options?.serviceTier,\n\t};\n}\n\nexport function buildOpenAICodexResponsesFastRouteOptions(\n\tmodel: Model<Api>,\n\toptions: FastRouteStreamOptions | undefined,\n): OpenAICodexResponsesOptions {\n\treturn {\n\t\t...buildFastRouteBaseProviderOptions(model, options),\n\t\treasoningEffort: mapFastRouteReasoningEffort(model, options?.reasoning),\n\t\tserviceTier: options?.serviceTier,\n\t};\n}\n\n/**\n * Stream a request whose canonical selected model carries fast-route metadata. The provider adapter\n * translates only the serialized request to the route's upstream ID; the model object keeps its\n * canonical `-fast` identity.\n */\nexport function streamWithFastRoute(\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions: FastRouteStreamOptions | undefined,\n\tstreamers: FastRouteStreamers = DEFAULT_FAST_ROUTE_STREAMERS,\n): AssistantMessageEventStream {\n\tif (shouldUseNativeFastRoute(model, options)) {\n\t\tif (model.api === \"openai-responses\") {\n\t\t\treturn streamers.streamOpenAIResponses(\n\t\t\t\tmodel as Model<\"openai-responses\">,\n\t\t\t\tnormalizeContext(context),\n\t\t\t\tbuildOpenAIResponsesFastRouteOptions(model, options),\n\t\t\t);\n\t\t}\n\n\t\t// The WebSocket handshake builds its headers inside pi-ai, and the runtime\n\t\t// constructor can be cached before the first turn, so repair the identity\n\t\t// through the global constructor rather than per-request options.\n\t\tif (options?.transport !== \"sse\" && usesChatGptCodexTransport(model)) {\n\t\t\tinstallCodexFastRouteWebSocketIdentity();\n\t\t}\n\n\t\treturn streamers.streamOpenAICodexResponses(\n\t\t\tmodel as Model<\"openai-codex-responses\">,\n\t\t\tnormalizeContext(context),\n\t\t\tbuildOpenAICodexResponsesFastRouteOptions(model, options),\n\t\t);\n\t}\n\n\treturn streamers.streamSimple(model, context, options);\n}\n"]}
@@ -69,6 +69,16 @@ export declare function isNativeFastRouteApi(api: Api): api is "openai-responses
69
69
  * because selecting it would send an ordinary request under a name that promises otherwise.
70
70
  */
71
71
  export declare function usesOpenAIFastServiceTier(model: Pick<Model<Api>, "api" | "provider">): boolean;
72
+ /**
73
+ * xAI Priority Processing keeps the base upstream Grok model ID and adds the same
74
+ * `service_tier: "priority"` field on the Responses API. xAI has no `-fast` model slugs for current
75
+ * Grok models; priority is billed at twice the standard token rates, and only when the response
76
+ * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing
77
+ *
78
+ * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI
79
+ * Gateway, and renamed or proxied xAI-compatible providers do not qualify.
80
+ */
81
+ export declare function usesXaiFastServiceTier(model: Pick<Model<Api>, "api" | "provider">): boolean;
72
82
  /** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */
73
83
  export declare function isGitHubCopilotModel(model: Pick<Model<Api>, "provider">): boolean;
74
84
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fast-model-variants.d.ts","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGjE,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,EAAG,UAAmB,CAAC;AAE3D,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,EAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAI5D,CAAC;AAEH,oGAAoG;AACpG,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IAC1C,MAAM,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,WAAW,EAAE,SAAS,0BAA0B,EAAE,CAAC;CACnD;AAED,MAAM,WAAW,8BAA8B;IAC9C,6FAA6F;IAC7F,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,8GAA8G;IAC9G,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC;IACnE,0GAA0G;IAC1G,kBAAkB,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IACtC,2GAA2G;IAC3G,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,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wBAAgB,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,GAAG,OAAO,CAE3F;AAED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,OAAO,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC,GAAG,OAAO,CAMjG;AAOD,yFAAyF;AACzF,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAG/G;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMrG;AAqBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,EAC7B,OAAO,GAAE,8BAAmC,GAC1C,0BAA0B,CAmC5B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,wBAA6B,GAAG,QAAQ,CAgB1G"}
@@ -39,6 +39,18 @@ export function isNativeFastRouteApi(api) {
39
39
  export function usesOpenAIFastServiceTier(model) {
40
40
  return isNativeFastRouteApi(model.api) && (model.provider === "openai" || model.provider === "openai-codex");
41
41
  }
42
+ /**
43
+ * xAI Priority Processing keeps the base upstream Grok model ID and adds the same
44
+ * `service_tier: "priority"` field on the Responses API. xAI has no `-fast` model slugs for current
45
+ * Grok models; priority is billed at twice the standard token rates, and only when the response
46
+ * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing
47
+ *
48
+ * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI
49
+ * Gateway, and renamed or proxied xAI-compatible providers do not qualify.
50
+ */
51
+ export function usesXaiFastServiceTier(model) {
52
+ return model.api === "openai-responses" && model.provider === "xai";
53
+ }
42
54
  /** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */
43
55
  export function isGitHubCopilotModel(model) {
44
56
  return model.provider === "github-copilot";
@@ -81,7 +93,7 @@ export function copilotAdvertisesModelId(credential, modelId) {
81
93
  advertisedModelIds(credential.fastModelIds)?.includes(modelId) === true);
82
94
  }
83
95
  function fastRouteForBaseModel(model, entitledCopilotFastModelIds) {
84
- if (usesOpenAIFastServiceTier(model)) {
96
+ if (usesOpenAIFastServiceTier(model) || usesXaiFastServiceTier(model)) {
85
97
  return { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };
86
98
  }
87
99
  if (usesAnthropicFastMode(model)) {
@@ -1 +1 @@
1
- {"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;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ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure OpenAI (`azure-openai-responses`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\tmodel.provider === \"anthropic\" &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\n * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a\n * selectable picker/policy model or as a fast sibling.\n *\n * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so\n * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary,\n * whatever its name ends in.\n */\nexport function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean {\n\tif (credential?.type !== \"oauth\") return false;\n\treturn (\n\t\tadvertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||\n\t\tadvertisedModelIds(credential.fastModelIds)?.includes(modelId) === true\n\t);\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (model.fastRoute !== undefined || model.id.endsWith(FAST_MODEL_ID_SUFFIX)) continue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tif (!fastRoute) continue;\n\t\tconst variantId = fastModelId(model.id);\n\t\tif (ownedModelIds.has(variantId)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tprovider: providerId,\n\t\t\t\tmodelId: variantId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t`so Atomic did not derive a fast variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived fast variant instead.`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst override = options.modelOverrides?.[variantId];\n\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (fast)`, fastRoute };\n\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\tchanged = true;\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"fast-model-variants.js","sourceRoot":"","sources":["../../src/core/fast-model-variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAmB,CAAC;AAE3D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACzE,iBAAiB;IACjB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AA6CH,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC9C,OAAO,GAAG,WAAW,GAAG,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,OAAO,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,wBAAwB,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAA2C;IACpF,OAAO,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,KAAK,cAAc,CAAC,CAAC;AAC9G,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA2C;IACjF,OAAO,KAAK,CAAC,GAAG,KAAK,kBAAkB,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC;AACrE,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,oBAAoB,CAAC,KAAmC;IACvE,OAAO,KAAK,CAAC,QAA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E,OAAO,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,OAAO,GAA6B,EAAE;IAC/F,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,GAAG,EAAE;YACf,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC1F,mBAAmB,EAAE,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACnE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE;oBACpC,CAAC,CAAC,SAAS;gBACZ,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;gBAC7C,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE;gBACrD,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,EAAE;aAC7C,CAAC,CAAC;YACH,OAAO,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { Api, Credential, Model, ModelFastRoute, Provider } from \"@bastani/pi-ai\";\nimport type { ModelsJsonModelOverride } from \"./model-config.ts\";\nimport { applyModelOverride } from \"./provider-composer-internal.ts\";\n\n/** Canonical suffix every selectable fast model variant carries. */\nexport const FAST_MODEL_ID_SUFFIX = \"-fast\";\n\n/** Service tier OpenAI-style providers use to route fast traffic. */\nexport const FAST_MODEL_SERVICE_TIER = \"priority\" as const;\n\n/** Inference speed Anthropic's Messages API uses to route fast traffic. */\nexport const FAST_MODEL_SPEED = \"fast\" as const;\n\n/**\n * Claude models Anthropic's fast mode accepts. Requesting `speed: \"fast\"` on any other model is an\n * error, so the list is explicit rather than a family-name pattern.\n * https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models\n */\nexport const ANTHROPIC_FAST_MODE_MODEL_IDS: ReadonlySet<string> = new Set([\n\t\"claude-opus-5-5\",\n\t\"claude-opus-5\",\n\t\"claude-opus-4-8\",\n]);\n\n/** A derived fast variant that was suppressed because something already owns its exact model ID. */\nexport interface FastModelVariantDiagnostic {\n\tprovider: string;\n\t/** The exact selectable model ID that collided. */\n\tmodelId: string;\n\tmessage: string;\n}\n\nexport interface FastModelVariantDerivation {\n\tmodels: readonly Model<Api>[];\n\tdiagnostics: readonly FastModelVariantDiagnostic[];\n}\n\nexport interface DeriveFastModelVariantsOptions {\n\t/** Exact fast model IDs the stored GitHub Copilot credential advertises for this account. */\n\tcopilotFastModelIds?: readonly string[];\n\t/** `models.json` `modelOverrides` for this provider, applied to derived entries by their exact `-fast` ID. */\n\tmodelOverrides?: Readonly<Record<string, ModelsJsonModelOverride>>;\n\t/** APIs whose transport a registered extension owns for this provider. No variant is derived for them. */\n\textensionOwnedApis?: ReadonlySet<Api>;\n\t/** IDs explicitly declared in this provider's models.json models array. Never derive siblings for them. */\n\tcustomModelIds?: ReadonlySet<string>;\n}\n\nexport interface FastModelVariantsOptions {\n\t/**\n\t * Synchronous read of the exact fast model IDs the stored GitHub Copilot credential advertises.\n\t * Read per call so a credential that lands after provider composition still takes effect.\n\t */\n\tgetCopilotFastModelIds?: () => readonly string[] | undefined;\n\t/** Synchronous read of this provider's `models.json` `modelOverrides`, so a reload takes effect. */\n\tgetModelOverrides?: () => Readonly<Record<string, ModelsJsonModelOverride>> | undefined;\n\t/** Read current custom model IDs per pass so models.json reloads update eligibility. */\n\tgetCustomModelIds?: () => ReadonlySet<string>;\n\t/**\n\t * Synchronous read of the APIs a registered extension supplies a stream function for. Read per call\n\t * because extensions register after initial composition on some paths.\n\t */\n\tgetExtensionOwnedApis?: () => ReadonlySet<Api> | undefined;\n\t/** Called after every derivation pass with the complete diagnostic list for this provider. */\n\tonDiagnostics?: (providerId: string, diagnostics: readonly FastModelVariantDiagnostic[]) => void;\n}\n\n/** Canonical selectable ID of the fast variant of `baseModelId`. */\nexport function fastModelId(baseModelId: string): string {\n\treturn `${baseModelId}${FAST_MODEL_ID_SUFFIX}`;\n}\n\n/**\n * The two pi-ai adapters that serialize `service_tier`. `azure-openai-responses` and\n * `openai-completions` have no such option, and `streamSimple` drops it, so a service-tier route on\n * any other API would silently degrade to an ordinary request.\n */\nexport function isNativeFastRouteApi(api: Api): api is \"openai-responses\" | \"openai-codex-responses\" {\n\treturn api === \"openai-responses\" || api === \"openai-codex-responses\";\n}\n\n/**\n * OpenAI-style fast routing keeps the base upstream model ID and adds a priority service tier.\n *\n * Eligibility requires both a first-party provider ID and an adapter that serializes\n * `service_tier`. A renamed provider, proxy, Azure OpenAI (`azure-openai-responses`), OpenRouter\n * (`openai-completions`), and generic OpenAI-compatible providers do not qualify. An `openai` or\n * `openai-codex` model on an adapter that cannot carry `service_tier` must not offer a fast variant,\n * because selecting it would send an ordinary request under a name that promises otherwise.\n */\nexport function usesOpenAIFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn isNativeFastRouteApi(model.api) && (model.provider === \"openai\" || model.provider === \"openai-codex\");\n}\n\n/**\n * xAI Priority Processing keeps the base upstream Grok model ID and adds the same\n * `service_tier: \"priority\"` field on the Responses API. xAI has no `-fast` model slugs for current\n * Grok models; priority is billed at twice the standard token rates, and only when the response\n * confirms the tier. https://docs.x.ai/developers/advanced-api-usage/priority-processing\n *\n * Eligibility requires the first-party `xai` provider on `openai-responses`. OpenRouter, Vercel AI\n * Gateway, and renamed or proxied xAI-compatible providers do not qualify.\n */\nexport function usesXaiFastServiceTier(model: Pick<Model<Api>, \"api\" | \"provider\">): boolean {\n\treturn model.api === \"openai-responses\" && model.provider === \"xai\";\n}\n\n/** GitHub Copilot advertises real fast sibling model IDs per account; it never uses a service tier. */\nexport function isGitHubCopilotModel(model: Pick<Model<Api>, \"provider\">): boolean {\n\treturn model.provider === \"github-copilot\";\n}\n\n/**\n * Anthropic fast mode keeps the base upstream model ID and adds `speed: \"fast\"` with the fast-mode beta.\n *\n * Eligibility requires the first-party `anthropic` provider on the Messages API and a supported model.\n * Fast mode is not offered through Amazon Bedrock, Google Vertex, GitHub Copilot, OpenRouter, or a\n * renamed or proxied Anthropic-compatible provider.\n */\nexport function usesAnthropicFastMode(model: Pick<Model<Api>, \"api\" | \"id\" | \"provider\">): boolean {\n\treturn (\n\t\tmodel.api === \"anthropic-messages\" &&\n\t\tmodel.provider === \"anthropic\" &&\n\t\tANTHROPIC_FAST_MODE_MODEL_IDS.has(model.id)\n\t);\n}\n\nfunction advertisedModelIds(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value) || !value.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn value;\n}\n\n/** Read the exact fast model IDs a stored GitHub Copilot OAuth credential advertises. */\nexport function copilotAdvertisedFastModelIds(credential: Credential | undefined): readonly string[] | undefined {\n\tif (credential?.type !== \"oauth\") return undefined;\n\treturn advertisedModelIds(credential.fastModelIds);\n}\n\n/**\n * Whether a stored GitHub Copilot OAuth credential advertises this exact model ID at all — as a\n * selectable picker/policy model or as a fast sibling.\n *\n * Copilot's per-account advertisement is the authority the provider's own `filterModels` uses, so\n * restoration consults the same lists. An ID the account advertises as an ordinary model is ordinary,\n * whatever its name ends in.\n */\nexport function copilotAdvertisesModelId(credential: Credential | undefined, modelId: string): boolean {\n\tif (credential?.type !== \"oauth\") return false;\n\treturn (\n\t\tadvertisedModelIds(credential.availableModelIds)?.includes(modelId) === true ||\n\t\tadvertisedModelIds(credential.fastModelIds)?.includes(modelId) === true\n\t);\n}\n\nfunction fastRouteForBaseModel(\n\tmodel: Model<Api>,\n\tentitledCopilotFastModelIds: ReadonlySet<string>,\n): ModelFastRoute | undefined {\n\tif (usesOpenAIFastServiceTier(model) || usesXaiFastServiceTier(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, serviceTier: FAST_MODEL_SERVICE_TIER };\n\t}\n\tif (usesAnthropicFastMode(model)) {\n\t\treturn { baseModelId: model.id, upstreamModelId: model.id, speed: FAST_MODEL_SPEED };\n\t}\n\tif (isGitHubCopilotModel(model)) {\n\t\tconst advertisedId = fastModelId(model.id);\n\t\treturn entitledCopilotFastModelIds.has(advertisedId)\n\t\t\t? { baseModelId: model.id, upstreamModelId: advertisedId }\n\t\t\t: undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * Add a selectable `<base-model-id>-fast` entry for every eligible model, carrying the explicit\n * {@link ModelFastRoute} metadata that gives it fast semantics. The input list is preserved verbatim\n * and in order; each derived entry is appended directly after the model it derives from.\n *\n * A model whose exact `-fast` ID is already owned by the provider, a `models.json` custom model, or an\n * extension wins: derivation is suppressed for it and a diagnostic is recorded. The owning model keeps\n * whatever semantics it declares, because fast behavior comes only from `fastRoute`, never from the\n * `-fast` suffix. For the same reason a base model whose ID already ends in `-fast` is never used to\n * derive a `-fast-fast` variant: that is not a canonical ID this scheme defines.\n *\n * A derived entry is a real catalog model, so a `modelOverrides` entry keyed on its exact `-fast` ID\n * applies to it after derivation. Without that pass the derived entry would inherit the *base* model's\n * overrides and its own would be silently inert.\n *\n * No variant is derived for an API whose transport a registered extension owns, because Atomic cannot\n * enforce the route through a transport it does not serialize.\n */\nexport function deriveFastModelVariants(\n\tproviderId: string,\n\tmodels: readonly Model<Api>[],\n\toptions: DeriveFastModelVariantsOptions = {},\n): FastModelVariantDerivation {\n\tconst ownedModelIds = new Set(models.map((model) => model.id));\n\tconst entitledCopilotFastModelIds = new Set(options.copilotFastModelIds ?? []);\n\tconst derived: Model<Api>[] = [];\n\tconst diagnostics: FastModelVariantDiagnostic[] = [];\n\tlet changed = false;\n\tfor (const model of models) {\n\t\tderived.push(model);\n\t\tif (model.fastRoute !== undefined || model.id.endsWith(FAST_MODEL_ID_SUFFIX)) continue;\n\t\tif (options.customModelIds?.has(model.id)) continue;\n\t\t// An extension that supplies this API's stream function owns its serialization, so Atomic cannot\n\t\t// guarantee the route reaches the wire. Publishing a `-fast` choice it may not honor is the same\n\t\t// hazard as publishing one for an adapter that cannot carry the tier.\n\t\tif (options.extensionOwnedApis?.has(model.api) === true) continue;\n\t\tconst fastRoute = fastRouteForBaseModel(model, entitledCopilotFastModelIds);\n\t\tif (!fastRoute) continue;\n\t\tconst variantId = fastModelId(model.id);\n\t\tif (ownedModelIds.has(variantId)) {\n\t\t\tdiagnostics.push({\n\t\t\t\tprovider: providerId,\n\t\t\t\tmodelId: variantId,\n\t\t\t\tmessage:\n\t\t\t\t\t`Model \"${providerId}/${variantId}\" is already defined by the provider, models.json, or an extension, ` +\n\t\t\t\t\t`so Atomic did not derive a fast variant of \"${providerId}/${model.id}\". ` +\n\t\t\t\t\t`That model routes exactly as declared. Rename or remove it to get the derived fast variant instead.`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst override = options.modelOverrides?.[variantId];\n\t\tconst variant: Model<Api> = { ...model, id: variantId, name: `${model.name} (fast)`, fastRoute };\n\t\tderived.push(override ? applyModelOverride(variant, override) : variant);\n\t\tchanged = true;\n\t}\n\tif (!changed && diagnostics.length === 0) return { models, diagnostics };\n\treturn { models: derived, diagnostics };\n}\n\n/**\n * Overlay derived fast model variants onto a composed provider. Apply this after built-in,\n * `models.json`, extension, and `modelOverrides` composition so exact user-owned `-fast` IDs are\n * already present and win the collision.\n */\nexport function withFastModelVariants(provider: Provider, options: FastModelVariantsOptions = {}): Provider {\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => {\n\t\t\tconst { models, diagnostics } = deriveFastModelVariants(provider.id, provider.getModels(), {\n\t\t\t\tcopilotFastModelIds: isGitHubCopilotModel({ provider: provider.id })\n\t\t\t\t\t? options.getCopilotFastModelIds?.()\n\t\t\t\t\t: undefined,\n\t\t\t\tmodelOverrides: options.getModelOverrides?.(),\n\t\t\t\textensionOwnedApis: options.getExtensionOwnedApis?.(),\n\t\t\t\tcustomModelIds: options.getCustomModelIds?.(),\n\t\t\t});\n\t\t\toptions.onDiagnostics?.(provider.id, diagnostics);\n\t\t\treturn models;\n\t\t},\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Api, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, Context, Model, ModelsApiStreamOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, Provider, ProviderHeaders } from "@bastani/pi-ai";
1
+ import type { Api, AssistantMessage, AssistantMessageEventStream, AuthOperationOptions, AuthResult, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, Context, Model, ModelsApiStreamOptions, ModelsClassifierOptions, ModelsRefreshOptions, ModelsRefreshResult, ModelsSimpleStreamOptions, Provider, ProviderHeaders } from "@bastani/pi-ai";
2
2
  import type { ModelRuntime } from "./model-runtime.js";
3
3
  import type { AuthStatus, ProviderConfigInput } from "./provider-composer.ts";
4
4
  export type { ProviderConfigInput } from "./provider-composer.ts";
@@ -30,6 +30,7 @@ export declare class ModelRegistry {
30
30
  getAll(): Model<Api>[];
31
31
  getAvailable(): Model<Api>[];
32
32
  find(provider: string, modelId: string): Model<Api> | undefined;
33
+ getClassifierModel(provider: string, modelId: string): ClassifierModel<ClassifierApi> | undefined;
33
34
  hasConfiguredAuth(model: Model<Api>): boolean;
34
35
  /** Boolean-only access to configured credential screening, without resolving request auth. */
35
36
  containsConfiguredCredential(serialized: string): Promise<boolean>;
@@ -42,6 +43,7 @@ export declare class ModelRegistry {
42
43
  streamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;
43
44
  /** Complete through the active runtime so provider composition and request auth apply. */
44
45
  complete<TApi extends Api>(model: Model<TApi>, context: Context, options?: ModelsApiStreamOptions<TApi>): Promise<AssistantMessage>;
46
+ classify(model: ClassifierModel<ClassifierApi>, context: ClassifierContext, options?: ModelsClassifierOptions): Promise<ClassifierResult>;
45
47
  getProviderDisplayName(provider: string): string;
46
48
  getProviderAuth(provider: string, options?: AuthOperationOptions): Promise<AuthResult | undefined>;
47
49
  getApiKeyForProvider(provider: string): Promise<string | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/core/model-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,UAAU,EACV,OAAO,EACP,KAAK,EACL,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,QAAQ,EACR,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAC5B;IACA,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC,YAAY,OAAO,EAAE,YAAY,EAEhC;IAED;;;;OAIG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE1E;IAED,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAErB;IAED,YAAY,IAAI,KAAK,CAA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,YAAY,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEjF;IAED,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEtE;IAED,wBAAwB,IAAI,SAAS,MAAM,EAAE,CAE5C;CACD"}
@@ -27,6 +27,9 @@ export class ModelRegistry {
27
27
  find(provider, modelId) {
28
28
  return this.runtime.getModel(provider, modelId);
29
29
  }
30
+ getClassifierModel(provider, modelId) {
31
+ return this.runtime.getModelOfType("classifier", provider, modelId);
32
+ }
30
33
  hasConfiguredAuth(model) {
31
34
  return this.runtime.hasConfiguredAuth(model.provider);
32
35
  }
@@ -81,6 +84,9 @@ export class ModelRegistry {
81
84
  complete(model, context, options) {
82
85
  return this.runtime.complete(model, context, options);
83
86
  }
87
+ classify(model, context, options) {
88
+ return this.runtime.classify(model, context, options);
89
+ }
84
90
  getProviderDisplayName(provider) {
85
91
  return this.runtime.getProvider(provider)?.name ?? provider;
86
92
  }