@desplega.ai/agent-swarm 2.7.6 → 2.7.7

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 (244) hide show
  1. package/dist/{acp-adapter-bp91d37f.js → acp-adapter-7b4vk3h5.js} +5 -4
  2. package/dist/{actions-yj0eeaqh.js → actions-3tt153af.js} +18 -18
  3. package/dist/{amp-adapter-4pg9h34q.js → amp-adapter-njpts0yr.js} +1 -1
  4. package/dist/{anthropic-messages-x4q6rfq5.js → anthropic-messages-xey2skwx.js} +7 -7
  5. package/dist/{app-909e97cr.js → app-nky4378f.js} +3 -3
  6. package/dist/{assistant-qdyb5fyy.js → assistant-jnb669pa.js} +19 -19
  7. package/dist/{azure-openai-responses-s1w5n70z.js → azure-openai-responses-26t7j9ra.js} +5 -5
  8. package/dist/{boot-reembed-fk0s9z18.js → boot-reembed-9mgvaztt.js} +1 -1
  9. package/dist/{boot-reembed-gs1rzrnh.js → boot-reembed-qs2djdej.js} +1 -1
  10. package/dist/{boot-scrub-sweep-4qfd4kfx.js → boot-scrub-sweep-yjpdj7s1.js} +3 -3
  11. package/dist/{boot-seeds-yr00k13d.js → boot-seeds-5cm6ambd.js} +4 -4
  12. package/dist/{boxd-vdmfssd9.js → boxd-nv507va8.js} +1 -1
  13. package/dist/{claude-adapter-qta1f1xn.js → claude-adapter-fn287zmm.js} +5 -4
  14. package/dist/{claude-managed-setup-sc6j4dm0.js → claude-managed-setup-wtdz2mj2.js} +1 -1
  15. package/dist/{claude-sdk-session-zgrz6yvc.js → claude-sdk-session-x91kqyhm.js} +8288 -8224
  16. package/dist/{cli-wp9sp1qb.js → cli-08bmz9z9.js} +1 -1
  17. package/dist/{cli-yy3rhsdw.js → cli-1c6tzt8g.js} +7 -7
  18. package/dist/{cli-q0k1w5zd.js → cli-35rsp8ye.js} +1 -1
  19. package/dist/{cli-xnrwazav.js → cli-3fg0bdcv.js} +1 -1
  20. package/dist/{cli-89knwags.js → cli-5b456bpf.js} +2 -2
  21. package/dist/{cli-drr5v6av.js → cli-5jnhv72d.js} +1 -1
  22. package/dist/{cli-dxae2yg7.js → cli-5zx699j9.js} +2 -2
  23. package/dist/{cli-0at8w34w.js → cli-6g0hb4cp.js} +8 -8
  24. package/dist/{cli-e3r2neck.js → cli-6pfd54vx.js} +5 -5
  25. package/dist/{cli-bsn8nhrq.js → cli-6vcp76qk.js} +3 -3
  26. package/dist/{cli-ekwks2vs.js → cli-72v799xn.js} +1 -1
  27. package/dist/cli-82j36f2m.js +45 -0
  28. package/dist/{cli-yx4kfngt.js → cli-8305gbq0.js} +29 -16
  29. package/dist/{cli-4necwtsv.js → cli-8sckt74b.js} +8 -8
  30. package/dist/{cli-vvpx3gsx.js → cli-95jzxcp3.js} +1 -1
  31. package/dist/{cli-hr2e2fft.js → cli-adeegh7d.js} +7 -7
  32. package/dist/{cli-m48g6p95.js → cli-afkqkrtw.js} +3 -3
  33. package/dist/{cli-0qatpy8q.js → cli-ayayvfg4.js} +24 -4
  34. package/dist/{cli-bqt1mptt.js → cli-az48n0nr.js} +4 -4
  35. package/dist/{cli-zm72anhg.js → cli-bfv7vdg6.js} +9 -9
  36. package/dist/{cli-hgaazk69.js → cli-caj33vcq.js} +5 -5
  37. package/dist/{cli-3ypk9vk1.js → cli-cb2a8pna.js} +1 -1
  38. package/dist/{cli-waqbxg08.js → cli-cppkf404.js} +17 -17
  39. package/dist/{cli-yn4kxs06.js → cli-ddaanqkd.js} +4 -4
  40. package/dist/{cli-386tyxxg.js → cli-e0kmphd6.js} +2 -2
  41. package/dist/{cli-54t00gt8.js → cli-e46hg0xw.js} +1 -1
  42. package/dist/{cli-jm2vfpfd.js → cli-e5bzrn01.js} +1 -1
  43. package/dist/{cli-436532ck.js → cli-excnnjg2.js} +165 -153
  44. package/dist/{cli-71ptav7x.js → cli-ferkkrg9.js} +1 -1
  45. package/dist/{cli-vpf89f34.js → cli-fmjd0t1y.js} +3 -3
  46. package/dist/{cli-pd7vagab.js → cli-fyt2g4wd.js} +3 -3
  47. package/dist/{cli-gdhpcbhf.js → cli-g08zdaec.js} +1 -1
  48. package/dist/{cli-ehq736cn.js → cli-g7s47cc5.js} +4 -4
  49. package/dist/{cli-svj5090z.js → cli-gz6q4eve.js} +3 -3
  50. package/dist/{cli-8snvgs5r.js → cli-je518txm.js} +10 -10
  51. package/dist/{cli-rmmmrjkd.js → cli-jtjtabxe.js} +1 -1
  52. package/dist/{cli-611a1294.js → cli-k0wwfqbg.js} +18 -1
  53. package/dist/{cli-es6va8jk.js → cli-k1nje3v3.js} +38 -43
  54. package/dist/{cli-p5gp8pcx.js → cli-k8196sh2.js} +6 -6
  55. package/dist/{cli-nwj0ee2w.js → cli-k899ehvh.js} +2 -2
  56. package/dist/{cli-decfb6v8.js → cli-m0da8j35.js} +23 -9
  57. package/dist/{cli-he9wchme.js → cli-mkk9rnzz.js} +4 -4
  58. package/dist/{cli-nhrvpaj7.js → cli-n6bv12jn.js} +510 -4
  59. package/dist/{cli-8bc1w0tw.js → cli-nmzhp1b5.js} +14 -12
  60. package/dist/{cli-0yv5z2pg.js → cli-p82cnnjq.js} +1 -1
  61. package/dist/{cli-c60vetmm.js → cli-pc6n7fre.js} +1 -1
  62. package/dist/{cli-xds5f77d.js → cli-pjctyea3.js} +2 -2
  63. package/dist/{cli-xbbndvjy.js → cli-pq73h5mz.js} +3 -3
  64. package/dist/{cli-aa6yxc7m.js → cli-pz4rk021.js} +1 -1
  65. package/dist/{cli-xnqgpshy.js → cli-q3tkegby.js} +1 -1
  66. package/dist/cli-qghe0h66.js +67 -0
  67. package/dist/{cli-zbbwez0r.js → cli-qh4d4tvk.js} +4 -4
  68. package/dist/{cli-w6dt9ged.js → cli-rtt8g4v9.js} +1 -1
  69. package/dist/{cli-1h3wcpbw.js → cli-snpj5zbj.js} +2 -2
  70. package/dist/{cli-a7v854rf.js → cli-tgrv9cjx.js} +263 -12
  71. package/dist/{cli-faxe6thg.js → cli-vz22fyqv.js} +186 -54
  72. package/dist/{cli-k2gzwsj2.js → cli-wk5yrfwd.js} +160 -26
  73. package/dist/{cli-shpbx5ee.js → cli-ws19768n.js} +1641 -49
  74. package/dist/{cli-70r77n04.js → cli-xae4g51r.js} +1 -1
  75. package/dist/{cli-kqdg1bsb.js → cli-yndmfxb3.js} +2 -2
  76. package/dist/{cli-bjb3z51z.js → cli-yyj3j5m4.js} +2 -2
  77. package/dist/cli.js +21 -21
  78. package/dist/{cloudflare-workers-ai-system-one-bm60fjm0.js → cloudflare-workers-ai-system-one-ef2a980q.js} +2 -2
  79. package/dist/{codex-adapter-ayd1fb6h.js → codex-adapter-cf2yxe9m.js} +3 -2
  80. package/dist/{codex-hook-9efm2x1m.js → codex-hook-a0c6g6t6.js} +1 -1
  81. package/dist/{codex-session-runner-jesa32xc.js → codex-session-runner-6vfzdgbd.js} +3 -2
  82. package/dist/{commands-hanewgf2.js → commands-t3mfy7vn.js} +3 -3
  83. package/dist/{controller-dt1n3c1q.js → controller-q7xrbaz0.js} +3 -3
  84. package/dist/{controllers-connect-xx8x64n5.js → controllers-connect-c6nm70kg.js} +19 -19
  85. package/dist/{cursor-adapter-9s4dwwdw.js → cursor-adapter-ftd81ga8.js} +1 -1
  86. package/dist/{db-3vttcbv4.js → db-dk572x25.js} +3 -3
  87. package/dist/{db-9dv0g1ab.js → db-vemtpmcc.js} +4 -2
  88. package/dist/{dispatcher-tx9hd1sv.js → dispatcher-kh7ecxh9.js} +17 -17
  89. package/dist/{dsh-adapter-007y4ejs.js → dsh-adapter-v8628r89.js} +1 -1
  90. package/dist/{e2b-we6hs6q5.js → e2b-fr12yccx.js} +1 -1
  91. package/dist/{e2b-a19d28rz.js → e2b-x6ywzak3.js} +1 -1
  92. package/dist/{easter-egg-3d-rgbrqb8s.js → easter-egg-3d-nenw4x63.js} +1 -1
  93. package/dist/{embedding-space-ny1e2940.js → embedding-space-0jepb239.js} +6 -6
  94. package/dist/{embeddings-2t386t13.js → embeddings-xxt49yxg.js} +1 -1
  95. package/dist/{execute-pksh0ceh.js → execute-1mhw6e4x.js} +1 -1
  96. package/dist/{external-channel-phgmhmd7.js → external-channel-55v12e60.js} +2 -2
  97. package/dist/{fx-adapter-fy8rr921.js → fx-adapter-bs8wqrk5.js} +6 -5
  98. package/dist/{google-generative-ai-8y3m3k4b.js → google-generative-ai-v94hr7h0.js} +5 -5
  99. package/dist/{google-vertex-w3v98n7b.js → google-vertex-g7vr6cf8.js} +5 -5
  100. package/dist/{grok-adapter-q0abvpaj.js → grok-adapter-gpjqmkcq.js} +6 -5
  101. package/dist/handlers-zxmp1ta4.js +32 -0
  102. package/dist/{heartbeat-kadyek8p.js → heartbeat-k42svnr0.js} +20 -20
  103. package/dist/{hook-9k551xnj.js → hook-114m7hap.js} +4 -3
  104. package/dist/{hook-5zs3msf6.js → hook-6nphweh0.js} +24 -9
  105. package/dist/{http-mhz9vw1f.js → http-r8cc4wz7.js} +1025 -173
  106. package/dist/index-a8phxqnk.js +37 -0
  107. package/dist/{index-vdygbq10.js → index-e3s8wmxy.js} +1 -1
  108. package/dist/{index-q361cg2f.js → index-fpk4bcd9.js} +1 -1
  109. package/dist/index-k6h00t4c.js +30 -0
  110. package/dist/{index-rvr00sg7.js → index-nh3wyqdt.js} +1017 -574
  111. package/dist/index-xrz7te8h.js +33 -0
  112. package/dist/{keepalive-w56f32cg.js → keepalive-x060nt9p.js} +3 -3
  113. package/dist/lead-956sd2yc.js +71 -0
  114. package/dist/{maintenance-7mdgxcea.js → maintenance-2xxfexhf.js} +1 -1
  115. package/dist/{mistral-conversations-4pmwj1c0.js → mistral-conversations-3gjpdb4b.js} +4 -4
  116. package/dist/{oauth-refresh-sweep-29txy9vk.js → oauth-refresh-sweep-fckc4ar5.js} +2 -2
  117. package/dist/{onboard-kpsrkarj.js → onboard-zc48j237.js} +3 -3
  118. package/dist/{openai-codex-responses-44j573nm.js → openai-codex-responses-8pbxq9h5.js} +5 -5
  119. package/dist/{openai-completions-a4gee2a8.js → openai-completions-rm00s912.js} +4 -4
  120. package/dist/{openai-decisions-w4qkrcar.js → openai-decisions-8v957r2r.js} +1 -1
  121. package/dist/{openai-responses-rbp6h5kr.js → openai-responses-agxpf96k.js} +5 -5
  122. package/dist/{opencode-adapter-j25vm3rr.js → opencode-adapter-r690h1cr.js} +4 -3
  123. package/dist/{otel-impl-6kkct7a8.js → otel-impl-r5xbh81q.js} +4 -4
  124. package/dist/{pi-mono-adapter-exhkzhn2.js → pi-mono-adapter-c7v8sdec.js} +7 -6
  125. package/dist/{pricing-refresh-n2x7jh6k.js → pricing-refresh-3pmre11v.js} +3 -3
  126. package/dist/{rbac-roles-81ypx6es.js → rbac-roles-3vbshwsb.js} +1 -1
  127. package/dist/{rbac-roles-b5htkjby.js → rbac-roles-910mmkgz.js} +2 -2
  128. package/dist/{render-v2-qn6jmpk4.js → render-v2-pxykkbab.js} +3 -3
  129. package/dist/{resume-wd30wx23.js → resume-adda0bwy.js} +6 -6
  130. package/dist/{runtime-4hsg7h60.js → runtime-fnbm7stk.js} +1 -1
  131. package/dist/{session-access-5qvfevhk.js → session-access-2fvamrdc.js} +4 -4
  132. package/dist/{session-source-backfill-n1czavbr.js → session-source-backfill-08xvv0sm.js} +2 -2
  133. package/dist/{setup-dnb56qy5.js → setup-1aqmvmh1.js} +1 -1
  134. package/dist/{typesafe-system-one-5mavm259.js → typesafe-system-one-0bmqcxfg.js} +2 -2
  135. package/dist/{virtual-modules-76xxv9fs.js → virtual-modules-d2pjk9j1.js} +5 -5
  136. package/dist/{work-objects-4n21tfkm.js → work-objects-9s0yrm5j.js} +20 -20
  137. package/dist/{worker-follow-up-77hvzxww.js → worker-follow-up-3q78fqmr.js} +17 -17
  138. package/dist/worker-y15hy08h.js +71 -0
  139. package/openapi.json +197 -4
  140. package/package.json +5 -5
  141. package/src/apps/definition.ts +6 -5
  142. package/src/be/db/page-theme-tokens.ts +12 -0
  143. package/src/be/db/tasks/read.ts +9 -1
  144. package/src/be/db/tasks/write.ts +19 -0
  145. package/src/be/db-client.ts +107 -7
  146. package/src/be/db.ts +34 -2
  147. package/src/be/migrations/269_pages_design_system.sql +23 -0
  148. package/src/be/seed/schedules-seeder.ts +0 -10
  149. package/src/be/seed-scripts/catalog/catalog-report.inline.ts +2 -0
  150. package/src/be/seed-scripts/catalog/catalog-report.ts +2 -0
  151. package/src/be/seed-scripts/catalog/memory-eval.ts +2 -0
  152. package/src/be/seed-scripts/catalog/swarm-update-check.ts +150 -0
  153. package/src/be/seed-scripts/index.ts +9 -0
  154. package/src/be/seed-skills/bundled-files.generated.json +3 -3
  155. package/src/be/swarm-config-guard.ts +32 -0
  156. package/src/be/task-auto-title-listener.ts +127 -0
  157. package/src/commands/onboard/agent-fs-version.ts +1 -1
  158. package/src/commands/profile-sync.ts +151 -16
  159. package/src/commands/runner.ts +15 -7
  160. package/src/hooks/hook.ts +20 -9
  161. package/src/http/index.ts +3 -0
  162. package/src/http/pages-public.ts +93 -129
  163. package/src/http/pages.ts +94 -21
  164. package/src/pages/browser-sdk.ts +48 -21
  165. package/src/pages/color-literals.ts +115 -0
  166. package/src/pages/page-head.ts +766 -0
  167. package/src/pages/version.ts +3 -0
  168. package/src/providers/amp-adapter.ts +1 -1
  169. package/src/providers/codex-adapter.ts +1 -0
  170. package/src/providers/codex-app-server.ts +27 -1
  171. package/src/providers/pi-mono-extension.ts +30 -15
  172. package/src/tasks/follow-up-gate.ts +318 -0
  173. package/src/tasks/worker-follow-up.ts +21 -1
  174. package/src/tests/codex-app-server.test.ts +59 -0
  175. package/src/tests/codex-gateway-route.test.ts +50 -1
  176. package/src/tests/create-page-tool.test.ts +501 -0
  177. package/src/tests/db-client-busy-retry.test.ts +81 -0
  178. package/src/tests/db-task-read-contract.test.ts +1 -0
  179. package/src/tests/db-task-write-contract.test.ts +2 -0
  180. package/src/tests/db-tasks-read.test.ts +21 -0
  181. package/src/tests/fixtures/pages/head-v1.html +56 -0
  182. package/src/tests/follow-up-gate-shadow.test.ts +513 -0
  183. package/src/tests/identity-field-budget.test.ts +1 -1
  184. package/src/tests/internal-ai/credentials.test.ts +62 -0
  185. package/src/tests/internal-ai/task-title.test.ts +283 -0
  186. package/src/tests/merge-gate-detect-changes.test.ts +145 -0
  187. package/src/tests/page-proxy.test.ts +1 -1
  188. package/src/tests/page-session-dev-cookie.test.ts +188 -0
  189. package/src/tests/pages-frame-ancestors.test.ts +28 -1
  190. package/src/tests/pages-head-v2.test.ts +534 -0
  191. package/src/tests/pages-http.test.ts +330 -0
  192. package/src/tests/pages-public-html.test.ts +43 -0
  193. package/src/tests/pages-storage.test.ts +182 -0
  194. package/src/tests/pages-versioning.test.ts +72 -0
  195. package/src/tests/profile-sync-stale-writeback.test.ts +334 -0
  196. package/src/tests/profile-sync.test.ts +11 -15
  197. package/src/tests/scheduled-task-required-params-migration.test.ts +3 -1
  198. package/src/tests/script-connections.test.ts +2 -0
  199. package/src/tests/seed-registry.test.ts +28 -6
  200. package/src/tests/seed-schedules.test.ts +61 -8
  201. package/src/tests/seed-scripts.test.ts +142 -2
  202. package/src/tests/swarm-diff.test.ts +121 -2
  203. package/src/tests/task-auto-title-config-guard.test.ts +37 -0
  204. package/src/tests/task-auto-title-listener.test.ts +165 -0
  205. package/src/tests/theme-import.test.ts +758 -0
  206. package/src/tests/themes-page-theme.test.ts +155 -0
  207. package/src/tests/themes-presets.test.ts +172 -0
  208. package/src/tests/workflow-script-principal.test.ts +2 -1
  209. package/src/themes/classics.ts +949 -0
  210. package/src/themes/import.ts +420 -0
  211. package/src/themes/page-fields.ts +40 -0
  212. package/src/themes/page-theme.ts +102 -0
  213. package/src/themes/presets.ts +561 -0
  214. package/src/themes/tokens.ts +218 -0
  215. package/src/tools/app-upsert.ts +1 -1
  216. package/src/tools/create-page.ts +118 -12
  217. package/src/tools/utils.ts +33 -0
  218. package/src/types.ts +45 -3
  219. package/src/utils/constants.ts +19 -0
  220. package/src/utils/follow-up-gate-schedule-ids.ts +13 -0
  221. package/src/utils/internal-ai/credentials.ts +146 -93
  222. package/src/utils/internal-ai/index.ts +10 -0
  223. package/src/utils/internal-ai/models.ts +18 -0
  224. package/src/utils/internal-ai/task-title.ts +282 -0
  225. package/src/utils/page-session.ts +37 -0
  226. package/templates/schedules/daily-status-report/content.md +88 -2
  227. package/templates/schedules/daily-swarm-update-check/content.md +16 -40
  228. package/templates/skills/apps/SKILL.md +1 -1
  229. package/templates/skills/apps/content.md +1 -1
  230. package/templates/skills/heartbeat-runbook/content.md +1 -1
  231. package/templates/skills/pages/config.json +1 -1
  232. package/templates/skills/pages/content.md +539 -86
  233. package/templates/skills/pages/files/examples/annotated-pr.html +21 -12
  234. package/templates/skills/pages/files/examples/multiplayer-board.html +41 -41
  235. package/templates/skills/pages/files/examples/report-page.html +125 -124
  236. package/dist/cli-2pnswgh8.js +0 -189
  237. package/dist/handlers-by3sfxyx.js +0 -32
  238. package/dist/index-4f2pvxae.js +0 -37
  239. package/dist/index-98gz7tmp.js +0 -30
  240. package/dist/index-k08z2cak.js +0 -33
  241. package/dist/lead-enq35nqp.js +0 -70
  242. package/dist/worker-gg1576j3.js +0 -70
  243. package/templates/schedules/daily-workflow-health-audit/config.json +0 -19
  244. package/templates/schedules/daily-workflow-health-audit/content.md +0 -191
@@ -32,7 +32,7 @@ import {
32
32
  setBedrockProviderModule,
33
33
  bedrockConverseStreamApi,
34
34
  init_bedrock_converse_stream_lazy
35
- } from "./cli-aa6yxc7m.js";
35
+ } from "./cli-pz4rk021.js";
36
36
  import {
37
37
  getProviderEnvValue,
38
38
  init_provider_env
@@ -87,8 +87,8 @@ import {
87
87
  getSupportedThinkingLevels,
88
88
  clampThinkingLevel,
89
89
  modelsAreEqual,
90
- init_models2
91
- } from "./cli-1h3wcpbw.js";
90
+ init_models
91
+ } from "./cli-snpj5zbj.js";
92
92
  import {
93
93
  EventStream,
94
94
  AssistantMessageEventStream,
@@ -113,6 +113,10 @@ import {
113
113
  withClientIdentity,
114
114
  init_identity2
115
115
  } from "./cli-r9jqcehk.js";
116
+ import {
117
+ resolveRaterModelString,
118
+ init_models2
119
+ } from "./cli-82j36f2m.js";
116
120
  import {
117
121
  isFirstPartyAnthropicUrl,
118
122
  init_src,
@@ -7734,7 +7738,7 @@ function fauxProvider(options = {}) {
7734
7738
  }
7735
7739
  var DEFAULT_API = "faux", DEFAULT_PROVIDER = "faux", DEFAULT_MODEL_ID = "faux-1", DEFAULT_MODEL_NAME = "Faux Model", DEFAULT_BASE_URL = "http://localhost:0", DEFAULT_MIN_TOKEN_SIZE = 3, DEFAULT_MAX_TOKEN_SIZE = 5, DEFAULT_USAGE;
7736
7740
  var init_faux = __esm(() => {
7737
- init_models2();
7741
+ init_models();
7738
7742
  init_event_stream();
7739
7743
  init_text();
7740
7744
  DEFAULT_USAGE = {
@@ -14497,7 +14501,7 @@ var init_dist5 = __esm(() => {
14497
14501
  init_credential_store();
14498
14502
  init_helpers2();
14499
14503
  init_types2();
14500
- init_models2();
14504
+ init_models();
14501
14505
  init_models_store();
14502
14506
  init_faux();
14503
14507
  init_session_resources();
@@ -17076,49 +17080,49 @@ var init_bun_oauth = __esm(() => {
17076
17080
  });
17077
17081
 
17078
17082
  // node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.lazy.js
17079
- var anthropicMessagesApi = () => lazyApi(() => import("./anthropic-messages-x4q6rfq5.js"));
17083
+ var anthropicMessagesApi = () => lazyApi(() => import("./anthropic-messages-xey2skwx.js"));
17080
17084
  var init_anthropic_messages_lazy = __esm(() => {
17081
17085
  init_lazy();
17082
17086
  });
17083
17087
 
17084
17088
  // node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.lazy.js
17085
- var azureOpenAIResponsesApi = () => lazyApi(() => import("./azure-openai-responses-s1w5n70z.js"));
17089
+ var azureOpenAIResponsesApi = () => lazyApi(() => import("./azure-openai-responses-26t7j9ra.js"));
17086
17090
  var init_azure_openai_responses_lazy = __esm(() => {
17087
17091
  init_lazy();
17088
17092
  });
17089
17093
 
17090
17094
  // node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.lazy.js
17091
- var googleGenerativeAIApi = () => lazyApi(() => import("./google-generative-ai-8y3m3k4b.js"));
17095
+ var googleGenerativeAIApi = () => lazyApi(() => import("./google-generative-ai-v94hr7h0.js"));
17092
17096
  var init_google_generative_ai_lazy = __esm(() => {
17093
17097
  init_lazy();
17094
17098
  });
17095
17099
 
17096
17100
  // node_modules/@earendil-works/pi-ai/dist/api/google-vertex.lazy.js
17097
- var googleVertexApi = () => lazyApi(() => import("./google-vertex-w3v98n7b.js"));
17101
+ var googleVertexApi = () => lazyApi(() => import("./google-vertex-g7vr6cf8.js"));
17098
17102
  var init_google_vertex_lazy = __esm(() => {
17099
17103
  init_lazy();
17100
17104
  });
17101
17105
 
17102
17106
  // node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.js
17103
- var mistralConversationsApi = () => lazyApi(() => import("./mistral-conversations-4pmwj1c0.js"));
17107
+ var mistralConversationsApi = () => lazyApi(() => import("./mistral-conversations-3gjpdb4b.js"));
17104
17108
  var init_mistral_conversations_lazy = __esm(() => {
17105
17109
  init_lazy();
17106
17110
  });
17107
17111
 
17108
17112
  // node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.js
17109
- var openAICodexResponsesApi = () => lazyApi(() => import("./openai-codex-responses-44j573nm.js"));
17113
+ var openAICodexResponsesApi = () => lazyApi(() => import("./openai-codex-responses-8pbxq9h5.js"));
17110
17114
  var init_openai_codex_responses_lazy = __esm(() => {
17111
17115
  init_lazy();
17112
17116
  });
17113
17117
 
17114
17118
  // node_modules/@earendil-works/pi-ai/dist/api/openai-completions.lazy.js
17115
- var openAICompletionsApi = () => lazyApi(() => import("./openai-completions-a4gee2a8.js"));
17119
+ var openAICompletionsApi = () => lazyApi(() => import("./openai-completions-rm00s912.js"));
17116
17120
  var init_openai_completions_lazy = __esm(() => {
17117
17121
  init_lazy();
17118
17122
  });
17119
17123
 
17120
17124
  // node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.js
17121
- var openAIResponsesApi = () => lazyApi(() => import("./openai-responses-rbp6h5kr.js"));
17125
+ var openAIResponsesApi = () => lazyApi(() => import("./openai-responses-agxpf96k.js"));
17122
17126
  var init_openai_responses_lazy = __esm(() => {
17123
17127
  init_lazy();
17124
17128
  });
@@ -18216,7 +18220,7 @@ function amazonBedrockProvider() {
18216
18220
  var bedrockAuth;
18217
18221
  var init_amazon_bedrock2 = __esm(() => {
18218
18222
  init_bedrock_converse_stream_lazy();
18219
- init_models2();
18223
+ init_models();
18220
18224
  init_amazon_bedrock_models();
18221
18225
  bedrockAuth = {
18222
18226
  name: "AWS credentials or bearer token",
@@ -18309,7 +18313,7 @@ function antLingProvider() {
18309
18313
  var init_ant_ling2 = __esm(() => {
18310
18314
  init_openai_completions_lazy();
18311
18315
  init_helpers2();
18312
- init_models2();
18316
+ init_models();
18313
18317
  init_ant_ling_models();
18314
18318
  });
18315
18319
 
@@ -18386,7 +18390,7 @@ var init_anthropic3 = __esm(() => {
18386
18390
  init_helpers2();
18387
18391
  init_load();
18388
18392
  init_env_api_keys();
18389
- init_models2();
18393
+ init_models();
18390
18394
  init_anthropic_models();
18391
18395
  });
18392
18396
 
@@ -18430,7 +18434,7 @@ var init_azure2 = __esm(() => {
18430
18434
  init_lazy();
18431
18435
  init_openai_completions_lazy();
18432
18436
  init_helpers2();
18433
- init_models2();
18437
+ init_models();
18434
18438
  init_azure_models();
18435
18439
  });
18436
18440
 
@@ -18448,7 +18452,7 @@ function basetenProvider() {
18448
18452
  var init_baseten2 = __esm(() => {
18449
18453
  init_openai_completions_lazy();
18450
18454
  init_helpers2();
18451
- init_models2();
18455
+ init_models();
18452
18456
  init_baseten_models();
18453
18457
  });
18454
18458
 
@@ -18466,7 +18470,7 @@ function cerebrasProvider() {
18466
18470
  var init_cerebras2 = __esm(() => {
18467
18471
  init_openai_completions_lazy();
18468
18472
  init_helpers2();
18469
- init_models2();
18473
+ init_models();
18470
18474
  init_cerebras_models();
18471
18475
  });
18472
18476
 
@@ -18588,7 +18592,7 @@ var init_cloudflare_ai_gateway2 = __esm(() => {
18588
18592
  init_anthropic_messages_lazy();
18589
18593
  init_openai_completions_lazy();
18590
18594
  init_openai_responses_lazy();
18591
- init_models2();
18595
+ init_models();
18592
18596
  init_cloudflare_ai_gateway_models();
18593
18597
  init_cloudflare_auth();
18594
18598
  init_cloudflare_stream();
@@ -18596,7 +18600,7 @@ var init_cloudflare_ai_gateway2 = __esm(() => {
18596
18600
 
18597
18601
  // node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.lazy.js
18598
18602
  var cloudflareWorkersAISystemOneApi = () => ({
18599
- classify: async (model, context, options) => (await import("./cloudflare-workers-ai-system-one-bm60fjm0.js")).classify(model, context, options)
18603
+ classify: async (model, context, options) => (await import("./cloudflare-workers-ai-system-one-ef2a980q.js")).classify(model, context, options)
18600
18604
  });
18601
18605
  var init_cloudflare_workers_ai_system_one_lazy = () => {};
18602
18606
 
@@ -18619,7 +18623,7 @@ function cloudflareWorkersAIProvider() {
18619
18623
  var init_cloudflare_workers_ai2 = __esm(() => {
18620
18624
  init_cloudflare_workers_ai_system_one_lazy();
18621
18625
  init_openai_completions_lazy();
18622
- init_models2();
18626
+ init_models();
18623
18627
  init_cloudflare_auth();
18624
18628
  init_cloudflare_stream();
18625
18629
  init_cloudflare_workers_ai_models();
@@ -18650,7 +18654,7 @@ function deepseekProvider() {
18650
18654
  var init_deepseek2 = __esm(() => {
18651
18655
  init_openai_completions_lazy();
18652
18656
  init_helpers2();
18653
- init_models2();
18657
+ init_models();
18654
18658
  init_deepseek_models();
18655
18659
  });
18656
18660
 
@@ -18672,7 +18676,7 @@ var init_fireworks2 = __esm(() => {
18672
18676
  init_anthropic_messages_lazy();
18673
18677
  init_openai_completions_lazy();
18674
18678
  init_helpers2();
18675
- init_models2();
18679
+ init_models();
18676
18680
  init_fireworks_models();
18677
18681
  });
18678
18682
 
@@ -18710,7 +18714,7 @@ var init_github_copilot3 = __esm(() => {
18710
18714
  init_openai_responses_lazy();
18711
18715
  init_helpers2();
18712
18716
  init_load();
18713
- init_models2();
18717
+ init_models();
18714
18718
  init_github_copilot_models();
18715
18719
  });
18716
18720
 
@@ -18728,7 +18732,7 @@ function googleProvider() {
18728
18732
  var init_google2 = __esm(() => {
18729
18733
  init_google_generative_ai_lazy();
18730
18734
  init_helpers2();
18731
- init_models2();
18735
+ init_models();
18732
18736
  init_google_models();
18733
18737
  });
18734
18738
 
@@ -18745,7 +18749,7 @@ function googleVertexProvider() {
18745
18749
  var VERTEX_ADC_PATH = "~/.config/gcloud/application_default_credentials.json", vertexAuth;
18746
18750
  var init_google_vertex2 = __esm(() => {
18747
18751
  init_google_vertex_lazy();
18748
- init_models2();
18752
+ init_models();
18749
18753
  init_google_vertex_models();
18750
18754
  vertexAuth = {
18751
18755
  name: "Google Cloud credentials",
@@ -18834,7 +18838,7 @@ function groqProvider() {
18834
18838
  var init_groq2 = __esm(() => {
18835
18839
  init_openai_completions_lazy();
18836
18840
  init_helpers2();
18837
- init_models2();
18841
+ init_models();
18838
18842
  init_groq_models();
18839
18843
  });
18840
18844
 
@@ -18852,7 +18856,7 @@ function huggingfaceProvider() {
18852
18856
  var init_huggingface2 = __esm(() => {
18853
18857
  init_openai_completions_lazy();
18854
18858
  init_helpers2();
18855
- init_models2();
18859
+ init_models();
18856
18860
  init_huggingface_models();
18857
18861
  });
18858
18862
 
@@ -18879,7 +18883,7 @@ var init_kimi_coding3 = __esm(() => {
18879
18883
  init_openai_completions_lazy();
18880
18884
  init_helpers2();
18881
18885
  init_load();
18882
- init_models2();
18886
+ init_models();
18883
18887
  init_kimi_coding_models();
18884
18888
  });
18885
18889
 
@@ -18906,7 +18910,7 @@ var init_meta3 = __esm(() => {
18906
18910
  init_openai_responses_lazy();
18907
18911
  init_helpers2();
18908
18912
  init_load();
18909
- init_models2();
18913
+ init_models();
18910
18914
  init_meta_models();
18911
18915
  });
18912
18916
 
@@ -18924,7 +18928,7 @@ function minimaxProvider() {
18924
18928
  var init_minimax2 = __esm(() => {
18925
18929
  init_anthropic_messages_lazy();
18926
18930
  init_helpers2();
18927
- init_models2();
18931
+ init_models();
18928
18932
  init_minimax_models();
18929
18933
  });
18930
18934
 
@@ -18942,7 +18946,7 @@ function minimaxCnProvider() {
18942
18946
  var init_minimax_cn2 = __esm(() => {
18943
18947
  init_anthropic_messages_lazy();
18944
18948
  init_helpers2();
18945
- init_models2();
18949
+ init_models();
18946
18950
  init_minimax_cn_models();
18947
18951
  });
18948
18952
 
@@ -18960,7 +18964,7 @@ function mistralProvider() {
18960
18964
  var init_mistral2 = __esm(() => {
18961
18965
  init_mistral_conversations_lazy();
18962
18966
  init_helpers2();
18963
- init_models2();
18967
+ init_models();
18964
18968
  init_mistral_models();
18965
18969
  });
18966
18970
 
@@ -18978,7 +18982,7 @@ function moonshotaiProvider() {
18978
18982
  var init_moonshotai2 = __esm(() => {
18979
18983
  init_openai_completions_lazy();
18980
18984
  init_helpers2();
18981
- init_models2();
18985
+ init_models();
18982
18986
  init_moonshotai_models();
18983
18987
  });
18984
18988
 
@@ -18996,7 +19000,7 @@ function moonshotaiCnProvider() {
18996
19000
  var init_moonshotai_cn2 = __esm(() => {
18997
19001
  init_openai_completions_lazy();
18998
19002
  init_helpers2();
18999
- init_models2();
19003
+ init_models();
19000
19004
  init_moonshotai_cn_models();
19001
19005
  });
19002
19006
 
@@ -19014,13 +19018,13 @@ function nvidiaProvider() {
19014
19018
  var init_nvidia2 = __esm(() => {
19015
19019
  init_openai_completions_lazy();
19016
19020
  init_helpers2();
19017
- init_models2();
19021
+ init_models();
19018
19022
  init_nvidia_models();
19019
19023
  });
19020
19024
 
19021
19025
  // node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.js
19022
19026
  var openAIDecisionsApi = () => ({
19023
- classify: async (model, context, options) => (await import("./openai-decisions-w4qkrcar.js")).classify(model, context, options)
19027
+ classify: async (model, context, options) => (await import("./openai-decisions-8v957r2r.js")).classify(model, context, options)
19024
19028
  });
19025
19029
  var init_openai_decisions_lazy = () => {};
19026
19030
 
@@ -19055,7 +19059,7 @@ var init_openai2 = __esm(() => {
19055
19059
  init_openai_responses_lazy();
19056
19060
  init_helpers2();
19057
19061
  init_load();
19058
- init_models2();
19062
+ init_models();
19059
19063
  init_openai_models();
19060
19064
  });
19061
19065
 
@@ -19080,13 +19084,13 @@ var init_openai_codex3 = __esm(() => {
19080
19084
  init_openai_codex_responses_lazy();
19081
19085
  init_helpers2();
19082
19086
  init_load();
19083
- init_models2();
19087
+ init_models();
19084
19088
  init_openai_codex_models();
19085
19089
  });
19086
19090
 
19087
19091
  // node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.lazy.js
19088
19092
  var typesafeSystemOneApi = () => ({
19089
- classify: async (model, context, options) => (await import("./typesafe-system-one-5mavm259.js")).classify(model, context, options)
19093
+ classify: async (model, context, options) => (await import("./typesafe-system-one-0bmqcxfg.js")).classify(model, context, options)
19090
19094
  });
19091
19095
  var init_typesafe_system_one_lazy = () => {};
19092
19096
 
@@ -19136,7 +19140,7 @@ var init_opencode2 = __esm(() => {
19136
19140
  init_openai_responses_lazy();
19137
19141
  init_typesafe_system_one_lazy();
19138
19142
  init_helpers2();
19139
- init_models2();
19143
+ init_models();
19140
19144
  init_opencode_models();
19141
19145
  init_opencode_headers();
19142
19146
  });
@@ -19162,7 +19166,7 @@ var init_opencode_go2 = __esm(() => {
19162
19166
  init_openai_completions_lazy();
19163
19167
  init_openai_responses_lazy();
19164
19168
  init_helpers2();
19165
- init_models2();
19169
+ init_models();
19166
19170
  init_opencode_go_models();
19167
19171
  init_opencode_headers();
19168
19172
  });
@@ -19276,7 +19280,7 @@ var init_openrouter = __esm(() => {
19276
19280
  init_typesafe_system_one_lazy();
19277
19281
  init_helpers2();
19278
19282
  init_load();
19279
- init_models2();
19283
+ init_models();
19280
19284
  init_model_operations();
19281
19285
  init_openrouter_models();
19282
19286
  init_openrouter_api();
@@ -19296,7 +19300,7 @@ function qwenTokenPlanProvider() {
19296
19300
  var init_qwen_token_plan2 = __esm(() => {
19297
19301
  init_openai_completions_lazy();
19298
19302
  init_helpers2();
19299
- init_models2();
19303
+ init_models();
19300
19304
  init_qwen_token_plan_models();
19301
19305
  });
19302
19306
 
@@ -19314,7 +19318,7 @@ function qwenTokenPlanCnProvider() {
19314
19318
  var init_qwen_token_plan_cn2 = __esm(() => {
19315
19319
  init_openai_completions_lazy();
19316
19320
  init_helpers2();
19317
- init_models2();
19321
+ init_models();
19318
19322
  init_qwen_token_plan_cn_models();
19319
19323
  });
19320
19324
 
@@ -19332,7 +19336,7 @@ function qwenTokenPlanIndividualProvider() {
19332
19336
  var init_qwen_token_plan_individual2 = __esm(() => {
19333
19337
  init_openai_completions_lazy();
19334
19338
  init_helpers2();
19335
- init_models2();
19339
+ init_models();
19336
19340
  init_qwen_token_plan_individual_models();
19337
19341
  });
19338
19342
 
@@ -19417,7 +19421,7 @@ function togetherProvider() {
19417
19421
  var init_together2 = __esm(() => {
19418
19422
  init_openai_completions_lazy();
19419
19423
  init_helpers2();
19420
- init_models2();
19424
+ init_models();
19421
19425
  init_together_models();
19422
19426
  });
19423
19427
 
@@ -19438,7 +19442,7 @@ function typesafeProvider() {
19438
19442
  var init_typesafe2 = __esm(() => {
19439
19443
  init_typesafe_system_one_lazy();
19440
19444
  init_helpers2();
19441
- init_models2();
19445
+ init_models();
19442
19446
  init_typesafe_models();
19443
19447
  });
19444
19448
 
@@ -19458,7 +19462,7 @@ var init_vercel_ai_gateway2 = __esm(() => {
19458
19462
  init_anthropic_messages_lazy();
19459
19463
  init_typesafe_system_one_lazy();
19460
19464
  init_helpers2();
19461
- init_models2();
19465
+ init_models();
19462
19466
  init_vercel_ai_gateway_models();
19463
19467
  });
19464
19468
 
@@ -19485,7 +19489,7 @@ var init_xai3 = __esm(() => {
19485
19489
  init_openai_responses_lazy();
19486
19490
  init_helpers2();
19487
19491
  init_load();
19488
- init_models2();
19492
+ init_models();
19489
19493
  init_xai_models();
19490
19494
  });
19491
19495
 
@@ -19503,7 +19507,7 @@ function xiaomiProvider() {
19503
19507
  var init_xiaomi2 = __esm(() => {
19504
19508
  init_openai_completions_lazy();
19505
19509
  init_helpers2();
19506
- init_models2();
19510
+ init_models();
19507
19511
  init_xiaomi_models();
19508
19512
  });
19509
19513
 
@@ -19521,7 +19525,7 @@ function xiaomiTokenPlanAmsProvider() {
19521
19525
  var init_xiaomi_token_plan_ams2 = __esm(() => {
19522
19526
  init_openai_completions_lazy();
19523
19527
  init_helpers2();
19524
- init_models2();
19528
+ init_models();
19525
19529
  init_xiaomi_token_plan_ams_models();
19526
19530
  });
19527
19531
 
@@ -19539,7 +19543,7 @@ function xiaomiTokenPlanCnProvider() {
19539
19543
  var init_xiaomi_token_plan_cn2 = __esm(() => {
19540
19544
  init_openai_completions_lazy();
19541
19545
  init_helpers2();
19542
- init_models2();
19546
+ init_models();
19543
19547
  init_xiaomi_token_plan_cn_models();
19544
19548
  });
19545
19549
 
@@ -19557,7 +19561,7 @@ function xiaomiTokenPlanSgpProvider() {
19557
19561
  var init_xiaomi_token_plan_sgp2 = __esm(() => {
19558
19562
  init_openai_completions_lazy();
19559
19563
  init_helpers2();
19560
- init_models2();
19564
+ init_models();
19561
19565
  init_xiaomi_token_plan_sgp_models();
19562
19566
  });
19563
19567
 
@@ -19575,7 +19579,7 @@ function zaiProvider() {
19575
19579
  var init_zai2 = __esm(() => {
19576
19580
  init_openai_completions_lazy();
19577
19581
  init_helpers2();
19578
- init_models2();
19582
+ init_models();
19579
19583
  init_zai_models();
19580
19584
  });
19581
19585
 
@@ -19593,7 +19597,7 @@ function zaiCodingCnProvider() {
19593
19597
  var init_zai_coding_cn2 = __esm(() => {
19594
19598
  init_openai_completions_lazy();
19595
19599
  init_helpers2();
19596
- init_models2();
19600
+ init_models();
19597
19601
  init_zai_coding_cn_models();
19598
19602
  });
19599
19603
 
@@ -19699,7 +19703,7 @@ function builtinModels(options) {
19699
19703
  }
19700
19704
  var init_all = __esm(() => {
19701
19705
  init_models_generated();
19702
- init_models2();
19706
+ init_models();
19703
19707
  init_amazon_bedrock2();
19704
19708
  init_ant_ling2();
19705
19709
  init_anthropic3();
@@ -20070,111 +20074,112 @@ var init_compat = __esm(() => {
20070
20074
  compatModels = builtinModels();
20071
20075
  });
20072
20076
 
20073
- // src/utils/internal-ai/models.ts
20074
- function resolveRaterModelString(kind) {
20075
- return process.env.MEMORY_RATER_MODEL ?? MEMORY_RATER_DEFAULT_MODEL[kind];
20076
- }
20077
- function parseModelStr(modelStr) {
20078
- const idx = modelStr.indexOf("/");
20079
- if (idx < 0)
20080
- throw new Error(`invalid model string (no '/'): ${modelStr}`);
20081
- return [modelStr.slice(0, idx), modelStr.slice(idx + 1)];
20082
- }
20083
- var DEFAULT_MODEL, MEMORY_RATER_DEFAULT_MODEL;
20084
- var init_models = __esm(() => {
20085
- DEFAULT_MODEL = {
20086
- openrouter: "openrouter/deepseek/deepseek-v4.1-flash",
20087
- anthropic: "anthropic/claude-haiku-4-5",
20088
- openai: "openai/gpt-6-luna",
20089
- "openai-codex": "openai-codex/gpt-6-luna",
20090
- "claude-cli": "haiku"
20091
- };
20092
- MEMORY_RATER_DEFAULT_MODEL = {
20093
- openrouter: "openrouter/deepseek/deepseek-v4.1-flash",
20094
- anthropic: "anthropic/claude-haiku-4-5",
20095
- openai: "openai/gpt-6-luna",
20096
- "openai-codex": "openai-codex/gpt-6-luna",
20097
- "claude-cli": "haiku"
20098
- };
20099
- });
20100
-
20101
20077
  // src/utils/internal-ai/credentials.ts
20102
20078
  async function resolveCredential(opts = {}) {
20079
+ const [first] = await resolveCredentials({ ...opts, limit: 1 });
20080
+ return first ?? null;
20081
+ }
20082
+ async function resolveCredentials(opts = {}) {
20103
20083
  const env = opts.env ?? process.env;
20104
20084
  const getEnvKey = opts._getEnvApiKey ?? getEnvApiKey;
20085
+ const wanted = opts.kinds ?? CREDENTIAL_KIND_PRECEDENCE;
20086
+ const limit = opts.limit ?? Number.POSITIVE_INFINITY;
20087
+ const found = [];
20088
+ for (const kind of CREDENTIAL_KIND_PRECEDENCE) {
20089
+ if (found.length >= limit)
20090
+ break;
20091
+ if (!wanted.includes(kind))
20092
+ continue;
20093
+ const cred = await resolveKind(kind, opts, env, getEnvKey);
20094
+ if (cred)
20095
+ found.push(cred);
20096
+ }
20097
+ return found;
20098
+ }
20099
+ async function resolveKind(kind, opts, env, getEnvKey) {
20100
+ switch (kind) {
20101
+ case "openrouter": {
20102
+ const key = env.OPENROUTER_API_KEY ?? getEnvKey("openrouter");
20103
+ if (!key)
20104
+ return null;
20105
+ return {
20106
+ kind,
20107
+ apiKey: selectCredential(key, undefined, "OPENROUTER_API_KEY").selected,
20108
+ modelDefault: resolveRaterModelString(kind)
20109
+ };
20110
+ }
20111
+ case "anthropic": {
20112
+ const anthropicBaseUrl = env.ANTHROPIC_BASE_URL?.trim();
20113
+ const keyIsForGateway = Boolean(anthropicBaseUrl) && !isFirstPartyAnthropicUrl(anthropicBaseUrl ?? "");
20114
+ const key = keyIsForGateway ? undefined : env.ANTHROPIC_API_KEY ?? getEnvKey("anthropic");
20115
+ if (!key)
20116
+ return null;
20117
+ return {
20118
+ kind,
20119
+ apiKey: selectCredential(key, undefined, "ANTHROPIC_API_KEY").selected,
20120
+ modelDefault: resolveRaterModelString(kind)
20121
+ };
20122
+ }
20123
+ case "openai": {
20124
+ const key = env.OPENAI_API_KEY ?? getEnvKey("openai");
20125
+ if (!key)
20126
+ return null;
20127
+ return {
20128
+ kind,
20129
+ apiKey: selectCredential(key, undefined, "OPENAI_API_KEY").selected,
20130
+ modelDefault: resolveRaterModelString(kind)
20131
+ };
20132
+ }
20133
+ case "openai-codex":
20134
+ if (!opts.apiUrl || !opts.apiKey)
20135
+ return null;
20136
+ return resolveCodexOAuthCredential(opts, opts.apiUrl, opts.apiKey);
20137
+ case "claude-cli":
20138
+ if (!env.AGENT_SWARM_CLAUDE_OAUTH_TOKEN && !env.CLAUDE_CODE_OAUTH_TOKEN)
20139
+ return null;
20140
+ return { kind, modelDefault: resolveRaterModelString(kind) };
20141
+ }
20142
+ }
20143
+ async function resolveCodexOAuthCredential(opts, apiUrl, apiKey) {
20105
20144
  const getCodex = opts._getValidCodexOAuth ?? getValidCodexOAuth;
20106
20145
  const getOAuth = opts._getOAuthApiKey ?? resolveOAuthApiKey;
20107
20146
  const persistCodex = opts._persistCodexOAuth ?? persistCodexOAuth;
20108
- const openrouterKey = env.OPENROUTER_API_KEY ?? getEnvKey("openrouter");
20109
- if (openrouterKey) {
20110
- return {
20111
- kind: "openrouter",
20112
- apiKey: selectCredential(openrouterKey, undefined, "OPENROUTER_API_KEY").selected,
20113
- modelDefault: resolveRaterModelString("openrouter")
20114
- };
20115
- }
20116
- const anthropicBaseUrl = env.ANTHROPIC_BASE_URL?.trim();
20117
- const anthropicKeyIsForGateway = Boolean(anthropicBaseUrl) && !isFirstPartyAnthropicUrl(anthropicBaseUrl ?? "");
20118
- const anthropicKey = anthropicKeyIsForGateway ? undefined : env.ANTHROPIC_API_KEY ?? getEnvKey("anthropic");
20119
- if (anthropicKey) {
20120
- return {
20121
- kind: "anthropic",
20122
- apiKey: selectCredential(anthropicKey, undefined, "ANTHROPIC_API_KEY").selected,
20123
- modelDefault: resolveRaterModelString("anthropic")
20124
- };
20125
- }
20126
- const openaiKey = env.OPENAI_API_KEY ?? getEnvKey("openai");
20127
- if (openaiKey) {
20128
- return {
20129
- kind: "openai",
20130
- apiKey: selectCredential(openaiKey, undefined, "OPENAI_API_KEY").selected,
20131
- modelDefault: resolveRaterModelString("openai")
20147
+ try {
20148
+ const codexCreds = await getCodex(apiUrl, apiKey);
20149
+ if (!codexCreds)
20150
+ return null;
20151
+ const credMap = {
20152
+ "openai-codex": {
20153
+ access: codexCreds.access,
20154
+ refresh: codexCreds.refresh,
20155
+ expires: codexCreds.expires
20156
+ }
20132
20157
  };
20133
- }
20134
- if (opts.apiUrl && opts.apiKey) {
20135
- try {
20136
- const codexCreds = await getCodex(opts.apiUrl, opts.apiKey);
20137
- if (codexCreds) {
20138
- const credMap = {
20139
- "openai-codex": {
20140
- access: codexCreds.access,
20141
- refresh: codexCreds.refresh,
20142
- expires: codexCreds.expires
20143
- }
20144
- };
20145
- const oauthResult = await getOAuth("openai-codex", credMap);
20146
- if (oauthResult) {
20147
- if (oauthResult.newCredentials) {
20148
- const updated = oauthResult.newCredentials;
20149
- try {
20150
- await persistCodex(opts.apiUrl, opts.apiKey, {
20151
- access: String(updated.access),
20152
- refresh: String(updated.refresh),
20153
- expires: Number(updated.expires),
20154
- accountId: codexCreds.accountId
20155
- });
20156
- } catch (err) {
20157
- console.error(`internal-ai: persistCodexOAuth failed (callerTag=${opts.callerTag ?? "<unset>"}):`, err);
20158
- }
20159
- }
20160
- return {
20161
- kind: "openai-codex",
20162
- apiKey: oauthResult.apiKey,
20163
- modelDefault: resolveRaterModelString("openai-codex")
20164
- };
20165
- }
20158
+ const oauthResult = await getOAuth("openai-codex", credMap);
20159
+ if (!oauthResult)
20160
+ return null;
20161
+ if (oauthResult.newCredentials) {
20162
+ const updated = oauthResult.newCredentials;
20163
+ try {
20164
+ await persistCodex(apiUrl, apiKey, {
20165
+ access: String(updated.access),
20166
+ refresh: String(updated.refresh),
20167
+ expires: Number(updated.expires),
20168
+ accountId: codexCreds.accountId
20169
+ });
20170
+ } catch (err) {
20171
+ console.error(`internal-ai: persistCodexOAuth failed (callerTag=${opts.callerTag ?? "<unset>"}):`, err);
20166
20172
  }
20167
- } catch (err) {
20168
- console.error(`internal-ai: codex OAuth probe failed (callerTag=${opts.callerTag ?? "<unset>"}):`, err);
20169
20173
  }
20170
- }
20171
- if (env.AGENT_SWARM_CLAUDE_OAUTH_TOKEN || env.CLAUDE_CODE_OAUTH_TOKEN) {
20172
20174
  return {
20173
- kind: "claude-cli",
20174
- modelDefault: resolveRaterModelString("claude-cli")
20175
+ kind: "openai-codex",
20176
+ apiKey: oauthResult.apiKey,
20177
+ modelDefault: resolveRaterModelString("openai-codex")
20175
20178
  };
20179
+ } catch (err) {
20180
+ console.error(`internal-ai: codex OAuth probe failed (callerTag=${opts.callerTag ?? "<unset>"}):`, err);
20181
+ return null;
20176
20182
  }
20177
- return null;
20178
20183
  }
20179
20184
  var resolveOAuthApiKey = async (providerId, credentials) => {
20180
20185
  const input = credentials[providerId];
@@ -20194,7 +20199,7 @@ var resolveOAuthApiKey = async (providerId, credentials) => {
20194
20199
  apiKey,
20195
20200
  newCredentials: changed && current?.type === "oauth" ? current : undefined
20196
20201
  };
20197
- };
20202
+ }, CREDENTIAL_KIND_PRECEDENCE;
20198
20203
  var init_credentials = __esm(() => {
20199
20204
  init_src();
20200
20205
  init_dist5();
@@ -20203,8 +20208,15 @@ var init_credentials = __esm(() => {
20203
20208
  init_all();
20204
20209
  init_storage();
20205
20210
  init_credentials2();
20206
- init_models();
20211
+ init_models2();
20207
20212
  registerBunOAuthFlows();
20213
+ CREDENTIAL_KIND_PRECEDENCE = [
20214
+ "openrouter",
20215
+ "anthropic",
20216
+ "openai",
20217
+ "openai-codex",
20218
+ "claude-cli"
20219
+ ];
20208
20220
  });
20209
20221
 
20210
- export { _Array_, Optional, _Object_, Unknown, Unsafe, Enum, Boolean2, Integer, Literal, Null, Number2, String2, Union, Record, Partial, exports_build, init_build, isContextOverflow, isRecoverableLength, DEFAULT_MAX_AGENT_RETRY_DELAY_MS, retryDelayMs, retryAssistantCall, isRetryableAssistantError, init_retry, exports_value, init_value, Compile, exports_compile, init_compile, validateToolArguments, init_dist5, oauthSuccessHtml, oauthErrorHtml, init_oauth_page, DEFAULT_RADIUS_GATEWAY, normalizeRadiusGatewayUrl, init_radius_config, typesafeSystemOneApi, init_typesafe_system_one_lazy, personalizeOpenRouterCatalog, init_openrouter, radiusProvider, getBuiltinModel, getBuiltinModelDataGeneratedAt, getBuiltinModels, builtinProviders, exports_all, init_all, getApiProvider, resetApiProviders, stream4, complete, streamSimple2, completeSimple, exports_compat, init_compat, DEFAULT_MODEL, parseModelStr, init_models, resolveCredential, init_credentials };
20222
+ export { _Array_, Optional, _Object_, Unknown, Unsafe, Enum, Boolean2, Integer, Literal, Null, Number2, String2, Union, Record, Partial, exports_build, init_build, isContextOverflow, isRecoverableLength, DEFAULT_MAX_AGENT_RETRY_DELAY_MS, retryDelayMs, retryAssistantCall, isRetryableAssistantError, init_retry, exports_value, init_value, Compile, exports_compile, init_compile, validateToolArguments, init_dist5, oauthSuccessHtml, oauthErrorHtml, init_oauth_page, DEFAULT_RADIUS_GATEWAY, normalizeRadiusGatewayUrl, init_radius_config, typesafeSystemOneApi, init_typesafe_system_one_lazy, personalizeOpenRouterCatalog, init_openrouter, radiusProvider, getBuiltinModel, getBuiltinModelDataGeneratedAt, getBuiltinModels, builtinProviders, exports_all, init_all, getApiProvider, resetApiProviders, stream4, complete, streamSimple2, completeSimple, exports_compat, init_compat, resolveCredential, resolveCredentials, init_credentials };