anymous 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (924) hide show
  1. package/bin/anymous.js +31 -0
  2. package/package.json +20 -135
  3. package/bin/anymous.cjs +0 -45
  4. package/skills/algorithmic-art/LICENSE.txt +0 -202
  5. package/skills/algorithmic-art/SKILL.md +0 -405
  6. package/skills/algorithmic-art/templates/generator_template.js +0 -223
  7. package/skills/algorithmic-art/templates/viewer.html +0 -599
  8. package/skills/artifacts-builder/LICENSE.txt +0 -202
  9. package/skills/artifacts-builder/SKILL.md +0 -74
  10. package/skills/artifacts-builder/scripts/bundle-artifact.sh +0 -54
  11. package/skills/artifacts-builder/scripts/init-artifact.sh +0 -322
  12. package/skills/artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  13. package/skills/brainstorming/SKILL.md +0 -151
  14. package/skills/brainstorming/scripts/frame-template.html +0 -213
  15. package/skills/brainstorming/scripts/helper.js +0 -167
  16. package/skills/brainstorming/scripts/server.cjs +0 -723
  17. package/skills/brainstorming/scripts/start-server.sh +0 -209
  18. package/skills/brainstorming/scripts/stop-server.sh +0 -120
  19. package/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  20. package/skills/brainstorming/visual-companion.md +0 -298
  21. package/skills/brand-guidelines/LICENSE.txt +0 -202
  22. package/skills/brand-guidelines/SKILL.md +0 -73
  23. package/skills/canvas-design/LICENSE.txt +0 -202
  24. package/skills/canvas-design/SKILL.md +0 -130
  25. package/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +0 -93
  26. package/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  27. package/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  28. package/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +0 -93
  29. package/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  30. package/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +0 -93
  31. package/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
  32. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  33. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +0 -93
  34. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  35. package/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  36. package/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  37. package/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +0 -93
  38. package/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  39. package/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +0 -93
  40. package/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
  41. package/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +0 -94
  42. package/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
  43. package/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
  44. package/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +0 -93
  45. package/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
  46. package/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +0 -93
  47. package/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
  48. package/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  49. package/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +0 -93
  50. package/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  51. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  52. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  53. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  54. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  55. package/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  56. package/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  57. package/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  58. package/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +0 -93
  59. package/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  60. package/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  61. package/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  62. package/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +0 -93
  63. package/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
  64. package/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  65. package/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +0 -93
  66. package/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  67. package/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
  68. package/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
  69. package/skills/canvas-design/canvas-fonts/Jura-OFL.txt +0 -93
  70. package/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +0 -93
  71. package/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  72. package/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  73. package/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  74. package/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  75. package/skills/canvas-design/canvas-fonts/Lora-OFL.txt +0 -93
  76. package/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  77. package/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
  78. package/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +0 -93
  79. package/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
  80. package/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +0 -93
  81. package/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  82. package/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  83. package/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +0 -93
  84. package/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
  85. package/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  86. package/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +0 -93
  87. package/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +0 -93
  88. package/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  89. package/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  90. package/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +0 -93
  91. package/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  92. package/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +0 -93
  93. package/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  94. package/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  95. package/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +0 -93
  96. package/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  97. package/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +0 -93
  98. package/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
  99. package/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
  100. package/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  101. package/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
  102. package/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +0 -93
  103. package/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
  104. package/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +0 -93
  105. package/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  106. package/skills/changelog-generator/SKILL.md +0 -110
  107. package/skills/claude-api/LICENSE.txt +0 -202
  108. package/skills/claude-api/SKILL.md +0 -546
  109. package/skills/claude-api/csharp/claude-api/README.md +0 -362
  110. package/skills/claude-api/csharp/claude-api/batches.md +0 -14
  111. package/skills/claude-api/csharp/claude-api/files-api.md +0 -23
  112. package/skills/claude-api/csharp/claude-api/streaming.md +0 -28
  113. package/skills/claude-api/csharp/claude-api/tool-use.md +0 -164
  114. package/skills/claude-api/curl/examples.md +0 -256
  115. package/skills/claude-api/curl/managed-agents.md +0 -340
  116. package/skills/claude-api/go/claude-api/README.md +0 -188
  117. package/skills/claude-api/go/claude-api/files-api.md +0 -21
  118. package/skills/claude-api/go/claude-api/streaming.md +0 -43
  119. package/skills/claude-api/go/claude-api/tool-use.md +0 -220
  120. package/skills/claude-api/go/managed-agents/README.md +0 -564
  121. package/skills/claude-api/java/claude-api/README.md +0 -238
  122. package/skills/claude-api/java/claude-api/files-api.md +0 -25
  123. package/skills/claude-api/java/claude-api/streaming.md +0 -24
  124. package/skills/claude-api/java/claude-api/tool-use.md +0 -228
  125. package/skills/claude-api/java/managed-agents/README.md +0 -443
  126. package/skills/claude-api/php/claude-api/README.md +0 -174
  127. package/skills/claude-api/php/claude-api/batches.md +0 -15
  128. package/skills/claude-api/php/claude-api/files-api.md +0 -11
  129. package/skills/claude-api/php/claude-api/streaming.md +0 -27
  130. package/skills/claude-api/php/claude-api/tool-use.md +0 -253
  131. package/skills/claude-api/php/managed-agents/README.md +0 -443
  132. package/skills/claude-api/python/claude-api/README.md +0 -565
  133. package/skills/claude-api/python/claude-api/batches.md +0 -198
  134. package/skills/claude-api/python/claude-api/files-api.md +0 -170
  135. package/skills/claude-api/python/claude-api/streaming.md +0 -179
  136. package/skills/claude-api/python/claude-api/tool-use.md +0 -629
  137. package/skills/claude-api/python/managed-agents/README.md +0 -335
  138. package/skills/claude-api/ruby/claude-api/README.md +0 -134
  139. package/skills/claude-api/ruby/claude-api/streaming.md +0 -16
  140. package/skills/claude-api/ruby/claude-api/tool-use.md +0 -41
  141. package/skills/claude-api/ruby/managed-agents/README.md +0 -394
  142. package/skills/claude-api/shared/agent-design.md +0 -101
  143. package/skills/claude-api/shared/anthropic-cli.md +0 -246
  144. package/skills/claude-api/shared/claude-platform-on-aws.md +0 -59
  145. package/skills/claude-api/shared/error-codes.md +0 -257
  146. package/skills/claude-api/shared/live-sources.md +0 -143
  147. package/skills/claude-api/shared/managed-agents-api-reference.md +0 -448
  148. package/skills/claude-api/shared/managed-agents-client-patterns.md +0 -217
  149. package/skills/claude-api/shared/managed-agents-core.md +0 -319
  150. package/skills/claude-api/shared/managed-agents-environments.md +0 -219
  151. package/skills/claude-api/shared/managed-agents-events.md +0 -270
  152. package/skills/claude-api/shared/managed-agents-memory.md +0 -199
  153. package/skills/claude-api/shared/managed-agents-multiagent.md +0 -125
  154. package/skills/claude-api/shared/managed-agents-onboarding.md +0 -82
  155. package/skills/claude-api/shared/managed-agents-outcomes.md +0 -108
  156. package/skills/claude-api/shared/managed-agents-overview.md +0 -71
  157. package/skills/claude-api/shared/managed-agents-scheduled-deployments.md +0 -146
  158. package/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +0 -174
  159. package/skills/claude-api/shared/managed-agents-tools.md +0 -371
  160. package/skills/claude-api/shared/managed-agents-webhooks.md +0 -143
  161. package/skills/claude-api/shared/model-migration.md +0 -1548
  162. package/skills/claude-api/shared/models.md +0 -138
  163. package/skills/claude-api/shared/platform-availability.md +0 -97
  164. package/skills/claude-api/shared/prompt-caching.md +0 -235
  165. package/skills/claude-api/shared/token-counting.md +0 -56
  166. package/skills/claude-api/shared/tool-use-concepts.md +0 -514
  167. package/skills/claude-api/typescript/claude-api/README.md +0 -405
  168. package/skills/claude-api/typescript/claude-api/batches.md +0 -106
  169. package/skills/claude-api/typescript/claude-api/files-api.md +0 -98
  170. package/skills/claude-api/typescript/claude-api/streaming.md +0 -178
  171. package/skills/claude-api/typescript/claude-api/tool-use.md +0 -589
  172. package/skills/claude-api/typescript/managed-agents/README.md +0 -358
  173. package/skills/code-security-auditor/SKILL.md +0 -164
  174. package/skills/code-security-auditor/references/package_checks.md +0 -59
  175. package/skills/competitive-ads-extractor/SKILL.md +0 -298
  176. package/skills/content-research-writer/SKILL.md +0 -538
  177. package/skills/developer-growth-analysis/SKILL.md +0 -322
  178. package/skills/dispatching-parallel-agents/SKILL.md +0 -167
  179. package/skills/doc-coauthoring/SKILL.md +0 -375
  180. package/skills/docx/LICENSE.txt +0 -30
  181. package/skills/docx/SKILL.md +0 -91
  182. package/skills/docx/scripts/__init__.py +0 -1
  183. package/skills/docx/scripts/accept_changes.py +0 -135
  184. package/skills/docx/scripts/comment.py +0 -368
  185. package/skills/docx/scripts/merge_runs.py +0 -310
  186. package/skills/docx/scripts/office/helpers/__init__.py +0 -111
  187. package/skills/docx/scripts/office/helpers/pptx_chart.py +0 -170
  188. package/skills/docx/scripts/office/helpers/pptx_slide.py +0 -60
  189. package/skills/docx/scripts/office/helpers/pptx_theme.py +0 -114
  190. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  191. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  192. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  193. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  194. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  195. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  196. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  197. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  198. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  199. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  200. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  201. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  202. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  203. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  204. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  205. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  206. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  207. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  208. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  209. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  210. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  211. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  212. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  213. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  214. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  215. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  216. package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  217. package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  218. package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  219. package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  220. package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  221. package/skills/docx/scripts/office/schemas/mce/mc.xsd +0 -75
  222. package/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +0 -560
  223. package/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +0 -67
  224. package/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +0 -14
  225. package/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +0 -20
  226. package/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +0 -13
  227. package/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  228. package/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +0 -8
  229. package/skills/docx/scripts/office/soffice.py +0 -192
  230. package/skills/docx/scripts/office/validate.py +0 -173
  231. package/skills/docx/scripts/office/validators/__init__.py +0 -15
  232. package/skills/docx/scripts/office/validators/base.py +0 -875
  233. package/skills/docx/scripts/office/validators/docx.py +0 -466
  234. package/skills/docx/scripts/office/validators/pptx.py +0 -441
  235. package/skills/docx/scripts/office/validators/redlining.py +0 -299
  236. package/skills/docx/scripts/templates/comments.xml +0 -3
  237. package/skills/docx/scripts/templates/commentsExtended.xml +0 -3
  238. package/skills/docx/scripts/templates/commentsExtensible.xml +0 -3
  239. package/skills/docx/scripts/templates/commentsIds.xml +0 -3
  240. package/skills/docx/scripts/templates/people.xml +0 -3
  241. package/skills/domain-name-brainstormer/SKILL.md +0 -217
  242. package/skills/executing-plans/SKILL.md +0 -64
  243. package/skills/file-organizer/SKILL.md +0 -433
  244. package/skills/finishing-a-development-branch/SKILL.md +0 -201
  245. package/skills/frontend-design/LICENSE.txt +0 -177
  246. package/skills/frontend-design/SKILL.md +0 -55
  247. package/skills/image-enhancer/SKILL.md +0 -106
  248. package/skills/internal-comms/LICENSE.txt +0 -202
  249. package/skills/internal-comms/SKILL.md +0 -32
  250. package/skills/internal-comms/examples/3p-updates.md +0 -47
  251. package/skills/internal-comms/examples/company-newsletter.md +0 -65
  252. package/skills/internal-comms/examples/faq-answers.md +0 -30
  253. package/skills/internal-comms/examples/general-comms.md +0 -16
  254. package/skills/invoice-organizer/SKILL.md +0 -452
  255. package/skills/lead-research-assistant/SKILL.md +0 -205
  256. package/skills/mcp-builder/LICENSE.txt +0 -202
  257. package/skills/mcp-builder/SKILL.md +0 -236
  258. package/skills/mcp-builder/reference/evaluation.md +0 -602
  259. package/skills/mcp-builder/reference/mcp_best_practices.md +0 -249
  260. package/skills/mcp-builder/reference/node_mcp_server.md +0 -970
  261. package/skills/mcp-builder/reference/python_mcp_server.md +0 -719
  262. package/skills/mcp-builder/scripts/connections.py +0 -151
  263. package/skills/mcp-builder/scripts/evaluation.py +0 -373
  264. package/skills/mcp-builder/scripts/example_evaluation.xml +0 -22
  265. package/skills/mcp-builder/scripts/requirements.txt +0 -2
  266. package/skills/meeting-insights-analyzer/SKILL.md +0 -327
  267. package/skills/pdf/LICENSE.txt +0 -30
  268. package/skills/pdf/SKILL.md +0 -314
  269. package/skills/pdf/forms.md +0 -294
  270. package/skills/pdf/reference.md +0 -612
  271. package/skills/pdf/scripts/check_bounding_boxes.py +0 -65
  272. package/skills/pdf/scripts/check_fillable_fields.py +0 -11
  273. package/skills/pdf/scripts/convert_pdf_to_images.py +0 -33
  274. package/skills/pdf/scripts/create_validation_image.py +0 -37
  275. package/skills/pdf/scripts/extract_form_field_info.py +0 -122
  276. package/skills/pdf/scripts/extract_form_structure.py +0 -115
  277. package/skills/pdf/scripts/fill_fillable_fields.py +0 -98
  278. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +0 -107
  279. package/skills/pptx/LICENSE.txt +0 -30
  280. package/skills/pptx/SKILL.md +0 -238
  281. package/skills/pptx/scripts/__init__.py +0 -0
  282. package/skills/pptx/scripts/add_slide.py +0 -367
  283. package/skills/pptx/scripts/clean.py +0 -309
  284. package/skills/pptx/scripts/office/helpers/__init__.py +0 -111
  285. package/skills/pptx/scripts/office/helpers/pptx_chart.py +0 -170
  286. package/skills/pptx/scripts/office/helpers/pptx_slide.py +0 -60
  287. package/skills/pptx/scripts/office/helpers/pptx_theme.py +0 -114
  288. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  289. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  290. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  291. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  292. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  293. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  294. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  295. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  296. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  297. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  298. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  299. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  300. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  301. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  302. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  303. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  304. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  305. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  306. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  307. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  308. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  309. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  310. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  311. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  312. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  313. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  314. package/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  315. package/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  316. package/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  317. package/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  318. package/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  319. package/skills/pptx/scripts/office/schemas/mce/mc.xsd +0 -75
  320. package/skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +0 -560
  321. package/skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +0 -67
  322. package/skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +0 -14
  323. package/skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +0 -20
  324. package/skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +0 -13
  325. package/skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  326. package/skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +0 -8
  327. package/skills/pptx/scripts/office/soffice.py +0 -192
  328. package/skills/pptx/scripts/office/validate.py +0 -173
  329. package/skills/pptx/scripts/office/validators/__init__.py +0 -15
  330. package/skills/pptx/scripts/office/validators/base.py +0 -875
  331. package/skills/pptx/scripts/office/validators/docx.py +0 -466
  332. package/skills/pptx/scripts/office/validators/pptx.py +0 -441
  333. package/skills/pptx/scripts/office/validators/redlining.py +0 -299
  334. package/skills/pptx/scripts/thumbnail.py +0 -311
  335. package/skills/raffle-winner-picker/SKILL.md +0 -165
  336. package/skills/receiving-code-review/SKILL.md +0 -205
  337. package/skills/requesting-code-review/SKILL.md +0 -95
  338. package/skills/requesting-code-review/code-reviewer.md +0 -172
  339. package/skills/skill-creator/LICENSE.txt +0 -202
  340. package/skills/skill-creator/SKILL.md +0 -485
  341. package/skills/skill-creator/agents/analyzer.md +0 -274
  342. package/skills/skill-creator/agents/comparator.md +0 -202
  343. package/skills/skill-creator/agents/grader.md +0 -223
  344. package/skills/skill-creator/assets/eval_review.html +0 -146
  345. package/skills/skill-creator/eval-viewer/generate_review.py +0 -471
  346. package/skills/skill-creator/eval-viewer/viewer.html +0 -1325
  347. package/skills/skill-creator/references/schemas.md +0 -430
  348. package/skills/skill-creator/scripts/__init__.py +0 -0
  349. package/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
  350. package/skills/skill-creator/scripts/generate_report.py +0 -326
  351. package/skills/skill-creator/scripts/improve_description.py +0 -247
  352. package/skills/skill-creator/scripts/package_skill.py +0 -136
  353. package/skills/skill-creator/scripts/quick_validate.py +0 -103
  354. package/skills/skill-creator/scripts/run_eval.py +0 -310
  355. package/skills/skill-creator/scripts/run_loop.py +0 -328
  356. package/skills/skill-creator/scripts/utils.py +0 -47
  357. package/skills/skill-share/SKILL.md +0 -80
  358. package/skills/slack-gif-creator/LICENSE.txt +0 -202
  359. package/skills/slack-gif-creator/SKILL.md +0 -254
  360. package/skills/slack-gif-creator/core/easing.py +0 -234
  361. package/skills/slack-gif-creator/core/frame_composer.py +0 -176
  362. package/skills/slack-gif-creator/core/gif_builder.py +0 -269
  363. package/skills/slack-gif-creator/core/validators.py +0 -136
  364. package/skills/slack-gif-creator/requirements.txt +0 -4
  365. package/skills/staff-engineer-review/SKILL.md +0 -172
  366. package/skills/subagent-driven-development/SKILL.md +0 -503
  367. package/skills/subagent-driven-development/implementer-prompt.md +0 -142
  368. package/skills/subagent-driven-development/re-review-prompt.md +0 -106
  369. package/skills/subagent-driven-development/scripts/review-package +0 -46
  370. package/skills/subagent-driven-development/scripts/sdd-workspace +0 -40
  371. package/skills/subagent-driven-development/scripts/task-brief +0 -41
  372. package/skills/subagent-driven-development/task-reviewer-prompt.md +0 -185
  373. package/skills/systematic-debugging/CREATION-LOG.md +0 -119
  374. package/skills/systematic-debugging/SKILL.md +0 -283
  375. package/skills/systematic-debugging/condition-based-waiting-example.ts +0 -158
  376. package/skills/systematic-debugging/condition-based-waiting.md +0 -115
  377. package/skills/systematic-debugging/defense-in-depth.md +0 -122
  378. package/skills/systematic-debugging/find-polluter.sh +0 -72
  379. package/skills/systematic-debugging/root-cause-tracing.md +0 -169
  380. package/skills/systematic-debugging/test-academic.md +0 -14
  381. package/skills/systematic-debugging/test-pressure-1.md +0 -58
  382. package/skills/systematic-debugging/test-pressure-2.md +0 -68
  383. package/skills/systematic-debugging/test-pressure-3.md +0 -69
  384. package/skills/test-driven-development/SKILL.md +0 -320
  385. package/skills/test-driven-development/writing-good-tests.md +0 -198
  386. package/skills/theme-factory/LICENSE.txt +0 -202
  387. package/skills/theme-factory/SKILL.md +0 -59
  388. package/skills/theme-factory/theme-showcase.pdf +0 -0
  389. package/skills/theme-factory/themes/arctic-frost.md +0 -19
  390. package/skills/theme-factory/themes/botanical-garden.md +0 -19
  391. package/skills/theme-factory/themes/desert-rose.md +0 -19
  392. package/skills/theme-factory/themes/forest-canopy.md +0 -19
  393. package/skills/theme-factory/themes/golden-hour.md +0 -19
  394. package/skills/theme-factory/themes/midnight-galaxy.md +0 -19
  395. package/skills/theme-factory/themes/modern-minimalist.md +0 -19
  396. package/skills/theme-factory/themes/ocean-depths.md +0 -19
  397. package/skills/theme-factory/themes/sunset-boulevard.md +0 -19
  398. package/skills/theme-factory/themes/tech-innovation.md +0 -19
  399. package/skills/using-git-worktrees/SKILL.md +0 -167
  400. package/skills/using-superpowers/SKILL.md +0 -62
  401. package/skills/using-superpowers/references/antigravity-tools.md +0 -23
  402. package/skills/using-superpowers/references/codex-tools.md +0 -39
  403. package/skills/using-superpowers/references/gemini-tools.md +0 -63
  404. package/skills/using-superpowers/references/pi-tools.md +0 -16
  405. package/skills/verification-before-completion/SKILL.md +0 -120
  406. package/skills/video-downloader/SKILL.md +0 -112
  407. package/skills/web-artifacts-builder/LICENSE.txt +0 -202
  408. package/skills/web-artifacts-builder/SKILL.md +0 -74
  409. package/skills/web-artifacts-builder/scripts/bundle-artifact.sh +0 -54
  410. package/skills/web-artifacts-builder/scripts/init-artifact.sh +0 -322
  411. package/skills/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  412. package/skills/webapp-testing/LICENSE.txt +0 -202
  413. package/skills/webapp-testing/SKILL.md +0 -96
  414. package/skills/webapp-testing/examples/console_logging.py +0 -35
  415. package/skills/webapp-testing/examples/element_discovery.py +0 -40
  416. package/skills/webapp-testing/examples/static_html_automation.py +0 -33
  417. package/skills/webapp-testing/scripts/with_server.py +0 -106
  418. package/skills/writing-plans/SKILL.md +0 -168
  419. package/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
  420. package/skills/writing-skills/SKILL.md +0 -679
  421. package/skills/writing-skills/anthropic-best-practices.md +0 -1150
  422. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  423. package/skills/writing-skills/graphviz-conventions.dot +0 -172
  424. package/skills/writing-skills/persuasion-principles.md +0 -187
  425. package/skills/writing-skills/render-graphs.js +0 -168
  426. package/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  427. package/skills/xlsx/LICENSE.txt +0 -30
  428. package/skills/xlsx/SKILL.md +0 -99
  429. package/skills/xlsx/scripts/office/helpers/__init__.py +0 -111
  430. package/skills/xlsx/scripts/office/helpers/pptx_chart.py +0 -170
  431. package/skills/xlsx/scripts/office/helpers/pptx_slide.py +0 -60
  432. package/skills/xlsx/scripts/office/helpers/pptx_theme.py +0 -114
  433. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  434. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  435. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  436. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  437. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  438. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  439. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  440. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  441. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  442. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  443. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  444. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  445. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  446. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  447. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  448. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  449. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  450. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  451. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  452. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  453. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  454. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  455. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  456. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  457. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  458. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  459. package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  460. package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  461. package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  462. package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  463. package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  464. package/skills/xlsx/scripts/office/schemas/mce/mc.xsd +0 -75
  465. package/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +0 -560
  466. package/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +0 -67
  467. package/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +0 -14
  468. package/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +0 -20
  469. package/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +0 -13
  470. package/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  471. package/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +0 -8
  472. package/skills/xlsx/scripts/office/soffice.py +0 -192
  473. package/skills/xlsx/scripts/office/validate.py +0 -173
  474. package/skills/xlsx/scripts/office/validators/__init__.py +0 -15
  475. package/skills/xlsx/scripts/office/validators/base.py +0 -875
  476. package/skills/xlsx/scripts/office/validators/docx.py +0 -466
  477. package/skills/xlsx/scripts/office/validators/pptx.py +0 -441
  478. package/skills/xlsx/scripts/office/validators/redlining.py +0 -299
  479. package/skills/xlsx/scripts/recalc.py +0 -308
  480. package/src/account/account.ts +0 -472
  481. package/src/account/repo.ts +0 -172
  482. package/src/account/schema.ts +0 -99
  483. package/src/account/url.ts +0 -8
  484. package/src/acp/agent.ts +0 -95
  485. package/src/acp/config-option.ts +0 -203
  486. package/src/acp/content.ts +0 -269
  487. package/src/acp/directory.ts +0 -212
  488. package/src/acp/error.ts +0 -97
  489. package/src/acp/event.ts +0 -342
  490. package/src/acp/permission.ts +0 -254
  491. package/src/acp/profile.ts +0 -42
  492. package/src/acp/service.ts +0 -1097
  493. package/src/acp/session.ts +0 -232
  494. package/src/acp/tool.ts +0 -364
  495. package/src/acp/usage.ts +0 -239
  496. package/src/agent/agent.ts +0 -1004
  497. package/src/agent/generate.txt +0 -75
  498. package/src/agent/prompt/architect.txt +0 -26
  499. package/src/agent/prompt/backend.txt +0 -26
  500. package/src/agent/prompt/build.txt +0 -31
  501. package/src/agent/prompt/code-reviewer.txt +0 -29
  502. package/src/agent/prompt/compaction.txt +0 -45
  503. package/src/agent/prompt/database.txt +0 -27
  504. package/src/agent/prompt/debug-tools.txt +0 -40
  505. package/src/agent/prompt/debug.txt +0 -23
  506. package/src/agent/prompt/devops.txt +0 -26
  507. package/src/agent/prompt/docs.txt +0 -23
  508. package/src/agent/prompt/exe-extractor.txt +0 -39
  509. package/src/agent/prompt/explore.txt +0 -42
  510. package/src/agent/prompt/frontend.txt +0 -29
  511. package/src/agent/prompt/general.txt +0 -25
  512. package/src/agent/prompt/memory-dump.txt +0 -37
  513. package/src/agent/prompt/pentest-critic.txt +0 -51
  514. package/src/agent/prompt/pentest-enumerator.txt +0 -72
  515. package/src/agent/prompt/pentest-exploiter.txt +0 -69
  516. package/src/agent/prompt/pentest-identity.txt +0 -59
  517. package/src/agent/prompt/pentest-lead.txt +0 -46
  518. package/src/agent/prompt/pentest-postexploit.txt +0 -84
  519. package/src/agent/prompt/pentest-recon.txt +0 -50
  520. package/src/agent/prompt/pentest-reporter.txt +0 -76
  521. package/src/agent/prompt/pentest-scanner.txt +0 -57
  522. package/src/agent/prompt/pentest-webapp.txt +0 -94
  523. package/src/agent/prompt/performance.txt +0 -27
  524. package/src/agent/prompt/plan.txt +0 -35
  525. package/src/agent/prompt/refactor.txt +0 -31
  526. package/src/agent/prompt/reverser-automator.txt +0 -96
  527. package/src/agent/prompt/reverser-binary.txt +0 -62
  528. package/src/agent/prompt/reverser-dynamic.txt +0 -76
  529. package/src/agent/prompt/reverser-source.txt +0 -93
  530. package/src/agent/prompt/reverser-static.txt +0 -76
  531. package/src/agent/prompt/security.txt +0 -34
  532. package/src/agent/prompt/summary.txt +0 -22
  533. package/src/agent/prompt/test-writer.txt +0 -34
  534. package/src/agent/prompt/title.txt +0 -44
  535. package/src/agent/prompt/web-designer.txt +0 -23
  536. package/src/agent/subagent-permissions.ts +0 -27
  537. package/src/audio.d.ts +0 -14
  538. package/src/auth/index.ts +0 -97
  539. package/src/background/job.ts +0 -37
  540. package/src/bus/global.ts +0 -22
  541. package/src/cli/bootstrap.ts +0 -11
  542. package/src/cli/cmd/account.ts +0 -265
  543. package/src/cli/cmd/acp.ts +0 -73
  544. package/src/cli/cmd/agent.ts +0 -259
  545. package/src/cli/cmd/attach.ts +0 -148
  546. package/src/cli/cmd/cmd.ts +0 -7
  547. package/src/cli/cmd/db.ts +0 -62
  548. package/src/cli/cmd/debug/agent.handler.ts +0 -193
  549. package/src/cli/cmd/debug/agent.ts +0 -27
  550. package/src/cli/cmd/debug/config.ts +0 -14
  551. package/src/cli/cmd/debug/file.ts +0 -73
  552. package/src/cli/cmd/debug/index.ts +0 -87
  553. package/src/cli/cmd/debug/lsp.ts +0 -50
  554. package/src/cli/cmd/debug/ripgrep.ts +0 -79
  555. package/src/cli/cmd/debug/scrap.ts +0 -16
  556. package/src/cli/cmd/debug/skill.ts +0 -15
  557. package/src/cli/cmd/debug/snapshot.ts +0 -50
  558. package/src/cli/cmd/debug/startup.ts +0 -11
  559. package/src/cli/cmd/debug/v2.ts +0 -42
  560. package/src/cli/cmd/export.ts +0 -292
  561. package/src/cli/cmd/generate.ts +0 -54
  562. package/src/cli/cmd/github.handler.ts +0 -1595
  563. package/src/cli/cmd/github.shared.ts +0 -30
  564. package/src/cli/cmd/github.ts +0 -42
  565. package/src/cli/cmd/import.ts +0 -230
  566. package/src/cli/cmd/mcp.ts +0 -840
  567. package/src/cli/cmd/models.ts +0 -66
  568. package/src/cli/cmd/plug.ts +0 -230
  569. package/src/cli/cmd/pr.ts +0 -115
  570. package/src/cli/cmd/prompt-display.ts +0 -1
  571. package/src/cli/cmd/providers.ts +0 -534
  572. package/src/cli/cmd/run/demo.ts +0 -1274
  573. package/src/cli/cmd/run/entry.body.ts +0 -205
  574. package/src/cli/cmd/run/footer.command.tsx +0 -1070
  575. package/src/cli/cmd/run/footer.menu.tsx +0 -351
  576. package/src/cli/cmd/run/footer.permission.tsx +0 -472
  577. package/src/cli/cmd/run/footer.prompt.tsx +0 -1320
  578. package/src/cli/cmd/run/footer.question.tsx +0 -573
  579. package/src/cli/cmd/run/footer.subagent.tsx +0 -175
  580. package/src/cli/cmd/run/footer.ts +0 -1129
  581. package/src/cli/cmd/run/footer.view.tsx +0 -945
  582. package/src/cli/cmd/run/footer.width.ts +0 -27
  583. package/src/cli/cmd/run/permission.shared.ts +0 -256
  584. package/src/cli/cmd/run/prompt.editor.ts +0 -157
  585. package/src/cli/cmd/run/prompt.shared.ts +0 -153
  586. package/src/cli/cmd/run/question.shared.ts +0 -340
  587. package/src/cli/cmd/run/runtime.boot.ts +0 -202
  588. package/src/cli/cmd/run/runtime.lifecycle.ts +0 -410
  589. package/src/cli/cmd/run/runtime.queue.ts +0 -349
  590. package/src/cli/cmd/run/runtime.shared.ts +0 -17
  591. package/src/cli/cmd/run/runtime.stdin.ts +0 -37
  592. package/src/cli/cmd/run/runtime.ts +0 -821
  593. package/src/cli/cmd/run/scrollback.shared.ts +0 -92
  594. package/src/cli/cmd/run/scrollback.surface.ts +0 -431
  595. package/src/cli/cmd/run/scrollback.writer.tsx +0 -352
  596. package/src/cli/cmd/run/session-data.ts +0 -1113
  597. package/src/cli/cmd/run/session-replay.ts +0 -374
  598. package/src/cli/cmd/run/session.shared.ts +0 -196
  599. package/src/cli/cmd/run/splash.ts +0 -289
  600. package/src/cli/cmd/run/stream.transport.ts +0 -1462
  601. package/src/cli/cmd/run/stream.ts +0 -175
  602. package/src/cli/cmd/run/subagent-data.ts +0 -876
  603. package/src/cli/cmd/run/theme.ts +0 -690
  604. package/src/cli/cmd/run/tool.ts +0 -1486
  605. package/src/cli/cmd/run/trace.ts +0 -94
  606. package/src/cli/cmd/run/turn-summary.ts +0 -47
  607. package/src/cli/cmd/run/types.ts +0 -350
  608. package/src/cli/cmd/run/variant.shared.ts +0 -216
  609. package/src/cli/cmd/run.ts +0 -1011
  610. package/src/cli/cmd/serve.ts +0 -24
  611. package/src/cli/cmd/session.ts +0 -147
  612. package/src/cli/cmd/stats.ts +0 -393
  613. package/src/cli/cmd/tui.ts +0 -309
  614. package/src/cli/cmd/uninstall.ts +0 -353
  615. package/src/cli/cmd/upgrade.ts +0 -113
  616. package/src/cli/cmd/web.ts +0 -84
  617. package/src/cli/effect/prompt.ts +0 -37
  618. package/src/cli/effect-cmd.ts +0 -96
  619. package/src/cli/error.ts +0 -130
  620. package/src/cli/heap.ts +0 -45
  621. package/src/cli/logo.ts +0 -1
  622. package/src/cli/network.ts +0 -80
  623. package/src/cli/tui/layer.ts +0 -8
  624. package/src/cli/tui/validate-session.ts +0 -29
  625. package/src/cli/tui/worker.ts +0 -80
  626. package/src/cli/ui.ts +0 -146
  627. package/src/cli/upgrade.ts +0 -79
  628. package/src/cli/version.ts +0 -14
  629. package/src/command/index.ts +0 -177
  630. package/src/command/template/initialize.txt +0 -66
  631. package/src/command/template/review.txt +0 -101
  632. package/src/config/agent.ts +0 -59
  633. package/src/config/command.ts +0 -39
  634. package/src/config/config.ts +0 -687
  635. package/src/config/entry-name.ts +0 -19
  636. package/src/config/managed.ts +0 -69
  637. package/src/config/markdown.ts +0 -36
  638. package/src/config/parse.ts +0 -79
  639. package/src/config/paths.ts +0 -45
  640. package/src/config/plugin.ts +0 -79
  641. package/src/config/tui-cwd.ts +0 -5
  642. package/src/config/tui-host-attention.ts +0 -21
  643. package/src/config/tui-migrate.ts +0 -132
  644. package/src/config/tui.ts +0 -276
  645. package/src/config/variable.ts +0 -91
  646. package/src/control-plane/adapters/index.ts +0 -41
  647. package/src/control-plane/adapters/worktree.ts +0 -96
  648. package/src/control-plane/dev/README.md +0 -19
  649. package/src/control-plane/dev/debug-workspace-plugin.ts +0 -73
  650. package/src/control-plane/types.ts +0 -59
  651. package/src/control-plane/util.ts +0 -39
  652. package/src/control-plane/workspace-adapter-runtime.ts +0 -51
  653. package/src/control-plane/workspace-context.ts +0 -26
  654. package/src/control-plane/workspace.ts +0 -965
  655. package/src/effect/app-node-builder-v1.ts +0 -12
  656. package/src/effect/app-runtime.ts +0 -137
  657. package/src/effect/bootstrap-runtime.ts +0 -19
  658. package/src/effect/bridge.ts +0 -84
  659. package/src/effect/config-service.ts +0 -67
  660. package/src/effect/instance-ref.ts +0 -11
  661. package/src/effect/instance-registry.ts +0 -12
  662. package/src/effect/instance-state.ts +0 -70
  663. package/src/effect/promise.ts +0 -17
  664. package/src/effect/run-service.ts +0 -47
  665. package/src/effect/runner.ts +0 -218
  666. package/src/effect/runtime-flags.ts +0 -80
  667. package/src/env/index.ts +0 -41
  668. package/src/event-manifest.ts +0 -3
  669. package/src/event-v2-bridge.ts +0 -71
  670. package/src/format/formatter.ts +0 -404
  671. package/src/format/index.ts +0 -203
  672. package/src/git/index.ts +0 -348
  673. package/src/id/id.ts +0 -80
  674. package/src/ide/index.ts +0 -54
  675. package/src/image/image.ts +0 -172
  676. package/src/index.ts +0 -142
  677. package/src/installation/index.ts +0 -332
  678. package/src/lsp/client.ts +0 -650
  679. package/src/lsp/diagnostic.ts +0 -29
  680. package/src/lsp/language.ts +0 -121
  681. package/src/lsp/launch.ts +0 -21
  682. package/src/lsp/lsp.ts +0 -507
  683. package/src/lsp/server.ts +0 -1983
  684. package/src/markdown.d.ts +0 -4
  685. package/src/mcp/auth.ts +0 -163
  686. package/src/mcp/browser.ts +0 -37
  687. package/src/mcp/catalog.ts +0 -170
  688. package/src/mcp/index.ts +0 -1004
  689. package/src/mcp/oauth-callback.ts +0 -194
  690. package/src/mcp/oauth-provider.ts +0 -259
  691. package/src/memory/memory.ts +0 -133
  692. package/src/node.ts +0 -4
  693. package/src/patch/index.ts +0 -686
  694. package/src/permission/arity.ts +0 -163
  695. package/src/permission/evaluate.ts +0 -1
  696. package/src/permission/index.ts +0 -233
  697. package/src/plugin/azure.ts +0 -26
  698. package/src/plugin/cloudflare.ts +0 -76
  699. package/src/plugin/digitalocean.ts +0 -325
  700. package/src/plugin/github-copilot/copilot.ts +0 -414
  701. package/src/plugin/github-copilot/models.ts +0 -258
  702. package/src/plugin/index.ts +0 -315
  703. package/src/plugin/install.ts +0 -439
  704. package/src/plugin/loader.ts +0 -237
  705. package/src/plugin/meta.ts +0 -188
  706. package/src/plugin/openai/README.md +0 -31
  707. package/src/plugin/openai/codex.ts +0 -565
  708. package/src/plugin/openai/ws-pool.ts +0 -270
  709. package/src/plugin/openai/ws.ts +0 -381
  710. package/src/plugin/pty-environment.ts +0 -24
  711. package/src/plugin/shared.ts +0 -323
  712. package/src/plugin/snowflake-cortex.ts +0 -507
  713. package/src/plugin/tui/internal.ts +0 -10
  714. package/src/plugin/tui/runtime.ts +0 -1131
  715. package/src/plugin/xai.ts +0 -626
  716. package/src/project/bootstrap-service.ts +0 -10
  717. package/src/project/bootstrap.ts +0 -58
  718. package/src/project/instance-context.ts +0 -24
  719. package/src/project/instance-runtime.ts +0 -16
  720. package/src/project/instance-store.ts +0 -213
  721. package/src/project/project.ts +0 -484
  722. package/src/project/vcs.ts +0 -423
  723. package/src/provider/auth.ts +0 -229
  724. package/src/provider/error.ts +0 -188
  725. package/src/provider/model-status.ts +0 -8
  726. package/src/provider/provider.ts +0 -2007
  727. package/src/provider/transform.ts +0 -1832
  728. package/src/question/index.ts +0 -161
  729. package/src/question/schema.ts +0 -4
  730. package/src/server/auth.ts +0 -49
  731. package/src/server/event.ts +0 -10
  732. package/src/server/global-lifecycle.ts +0 -28
  733. package/src/server/init-projectors.ts +0 -3
  734. package/src/server/mdns.ts +0 -47
  735. package/src/server/projectors.ts +0 -1
  736. package/src/server/proxy-util.ts +0 -48
  737. package/src/server/routes/instance/httpapi/AGENTS.md +0 -39
  738. package/src/server/routes/instance/httpapi/api.ts +0 -97
  739. package/src/server/routes/instance/httpapi/errors.ts +0 -193
  740. package/src/server/routes/instance/httpapi/groups/config.ts +0 -65
  741. package/src/server/routes/instance/httpapi/groups/control-plane.ts +0 -35
  742. package/src/server/routes/instance/httpapi/groups/control.ts +0 -76
  743. package/src/server/routes/instance/httpapi/groups/event.ts +0 -29
  744. package/src/server/routes/instance/httpapi/groups/experimental.ts +0 -275
  745. package/src/server/routes/instance/httpapi/groups/file.ts +0 -185
  746. package/src/server/routes/instance/httpapi/groups/global.ts +0 -136
  747. package/src/server/routes/instance/httpapi/groups/instance.ts +0 -206
  748. package/src/server/routes/instance/httpapi/groups/mcp.ts +0 -156
  749. package/src/server/routes/instance/httpapi/groups/metadata.ts +0 -18
  750. package/src/server/routes/instance/httpapi/groups/permission.ts +0 -61
  751. package/src/server/routes/instance/httpapi/groups/project-copy.ts +0 -32
  752. package/src/server/routes/instance/httpapi/groups/project.ts +0 -93
  753. package/src/server/routes/instance/httpapi/groups/provider.ts +0 -101
  754. package/src/server/routes/instance/httpapi/groups/pty.ts +0 -172
  755. package/src/server/routes/instance/httpapi/groups/query.ts +0 -12
  756. package/src/server/routes/instance/httpapi/groups/question.ts +0 -74
  757. package/src/server/routes/instance/httpapi/groups/session.ts +0 -462
  758. package/src/server/routes/instance/httpapi/groups/sync.ts +0 -113
  759. package/src/server/routes/instance/httpapi/groups/tui.ts +0 -208
  760. package/src/server/routes/instance/httpapi/groups/workspace.ts +0 -141
  761. package/src/server/routes/instance/httpapi/handlers/config.ts +0 -34
  762. package/src/server/routes/instance/httpapi/handlers/control-plane.ts +0 -38
  763. package/src/server/routes/instance/httpapi/handlers/control.ts +0 -43
  764. package/src/server/routes/instance/httpapi/handlers/event.ts +0 -99
  765. package/src/server/routes/instance/httpapi/handlers/experimental.ts +0 -194
  766. package/src/server/routes/instance/httpapi/handlers/file.ts +0 -139
  767. package/src/server/routes/instance/httpapi/handlers/global.ts +0 -157
  768. package/src/server/routes/instance/httpapi/handlers/instance.ts +0 -110
  769. package/src/server/routes/instance/httpapi/handlers/mcp.ts +0 -112
  770. package/src/server/routes/instance/httpapi/handlers/permission.ts +0 -41
  771. package/src/server/routes/instance/httpapi/handlers/project-copy.ts +0 -83
  772. package/src/server/routes/instance/httpapi/handlers/project.ts +0 -63
  773. package/src/server/routes/instance/httpapi/handlers/provider.ts +0 -114
  774. package/src/server/routes/instance/httpapi/handlers/pty.ts +0 -273
  775. package/src/server/routes/instance/httpapi/handlers/question.ts +0 -54
  776. package/src/server/routes/instance/httpapi/handlers/session-errors.ts +0 -21
  777. package/src/server/routes/instance/httpapi/handlers/session.ts +0 -442
  778. package/src/server/routes/instance/httpapi/handlers/sync.ts +0 -89
  779. package/src/server/routes/instance/httpapi/handlers/tui.ts +0 -131
  780. package/src/server/routes/instance/httpapi/handlers/workspace.ts +0 -103
  781. package/src/server/routes/instance/httpapi/lifecycle.ts +0 -55
  782. package/src/server/routes/instance/httpapi/middleware/authorization.ts +0 -150
  783. package/src/server/routes/instance/httpapi/middleware/compression.ts +0 -64
  784. package/src/server/routes/instance/httpapi/middleware/cors-vary.ts +0 -29
  785. package/src/server/routes/instance/httpapi/middleware/error.ts +0 -43
  786. package/src/server/routes/instance/httpapi/middleware/fence.ts +0 -25
  787. package/src/server/routes/instance/httpapi/middleware/instance-context.ts +0 -43
  788. package/src/server/routes/instance/httpapi/middleware/proxy.ts +0 -109
  789. package/src/server/routes/instance/httpapi/middleware/schema-error.ts +0 -41
  790. package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +0 -250
  791. package/src/server/routes/instance/httpapi/public.ts +0 -537
  792. package/src/server/routes/instance/httpapi/server.ts +0 -328
  793. package/src/server/routes/instance/httpapi/websocket-tracker.ts +0 -60
  794. package/src/server/server.ts +0 -226
  795. package/src/server/shared/fence.ts +0 -60
  796. package/src/server/shared/pty-ticket.ts +0 -15
  797. package/src/server/shared/public-ui.ts +0 -12
  798. package/src/server/shared/tui-control.ts +0 -28
  799. package/src/server/shared/ui.ts +0 -109
  800. package/src/server/shared/workspace-routing.ts +0 -38
  801. package/src/server/tui-event.ts +0 -1
  802. package/src/session/compaction.ts +0 -563
  803. package/src/session/instruction.ts +0 -237
  804. package/src/session/llm/AGENTS.md +0 -90
  805. package/src/session/llm/ai-sdk.ts +0 -288
  806. package/src/session/llm/native-request.ts +0 -196
  807. package/src/session/llm/native-runtime.ts +0 -196
  808. package/src/session/llm/request.ts +0 -226
  809. package/src/session/llm.ts +0 -404
  810. package/src/session/message-error.ts +0 -14
  811. package/src/session/message-v2.ts +0 -723
  812. package/src/session/message.ts +0 -148
  813. package/src/session/overflow.ts +0 -34
  814. package/src/session/processor.ts +0 -718
  815. package/src/session/prompt/anthropic.txt +0 -96
  816. package/src/session/prompt/beast.txt +0 -147
  817. package/src/session/prompt/build-switch.txt +0 -5
  818. package/src/session/prompt/codex.txt +0 -79
  819. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  820. package/src/session/prompt/default.txt +0 -89
  821. package/src/session/prompt/gemini.txt +0 -155
  822. package/src/session/prompt/gpt.txt +0 -107
  823. package/src/session/prompt/kimi.txt +0 -95
  824. package/src/session/prompt/meta.txt +0 -64
  825. package/src/session/prompt/plan-mode.txt +0 -70
  826. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  827. package/src/session/prompt/plan.txt +0 -26
  828. package/src/session/prompt/trinity.txt +0 -97
  829. package/src/session/prompt.ts +0 -1637
  830. package/src/session/reminders.ts +0 -92
  831. package/src/session/retry.ts +0 -201
  832. package/src/session/revert.ts +0 -146
  833. package/src/session/run-state.ts +0 -152
  834. package/src/session/schema.ts +0 -26
  835. package/src/session/session.ts +0 -1019
  836. package/src/session/status.ts +0 -56
  837. package/src/session/summary.ts +0 -160
  838. package/src/session/system.ts +0 -145
  839. package/src/session/todo.ts +0 -74
  840. package/src/session/tools.ts +0 -590
  841. package/src/share/session.ts +0 -58
  842. package/src/share/share-next.ts +0 -371
  843. package/src/skill/discovery.ts +0 -140
  844. package/src/skill/index.ts +0 -354
  845. package/src/snapshot/index.ts +0 -807
  846. package/src/sql.d.ts +0 -4
  847. package/src/storage/schema.ts +0 -5
  848. package/src/storage/storage.ts +0 -327
  849. package/src/sync/README.md +0 -179
  850. package/src/sync/schema.ts +0 -11
  851. package/src/temporary.ts +0 -31
  852. package/src/tool/apply_patch.ts +0 -313
  853. package/src/tool/apply_patch.txt +0 -33
  854. package/src/tool/code-mode.ts +0 -310
  855. package/src/tool/computer.ts +0 -535
  856. package/src/tool/computer.txt +0 -25
  857. package/src/tool/edit.ts +0 -737
  858. package/src/tool/edit.txt +0 -10
  859. package/src/tool/external-directory.ts +0 -49
  860. package/src/tool/glob.ts +0 -76
  861. package/src/tool/glob.txt +0 -6
  862. package/src/tool/grep.ts +0 -115
  863. package/src/tool/grep.txt +0 -8
  864. package/src/tool/invalid.ts +0 -21
  865. package/src/tool/json-schema.ts +0 -164
  866. package/src/tool/lsp.ts +0 -113
  867. package/src/tool/lsp.txt +0 -24
  868. package/src/tool/mcp-websearch.ts +0 -97
  869. package/src/tool/memory.ts +0 -59
  870. package/src/tool/memory.txt +0 -14
  871. package/src/tool/plan-enter.txt +0 -14
  872. package/src/tool/plan-exit.txt +0 -13
  873. package/src/tool/plan.ts +0 -79
  874. package/src/tool/question.ts +0 -44
  875. package/src/tool/question.txt +0 -10
  876. package/src/tool/read.ts +0 -386
  877. package/src/tool/read.txt +0 -14
  878. package/src/tool/registry.ts +0 -460
  879. package/src/tool/schema.ts +0 -14
  880. package/src/tool/shell/id.ts +0 -19
  881. package/src/tool/shell/prompt.ts +0 -293
  882. package/src/tool/shell/shell.txt +0 -21
  883. package/src/tool/shell.ts +0 -645
  884. package/src/tool/skill.ts +0 -70
  885. package/src/tool/skill.txt +0 -5
  886. package/src/tool/task.ts +0 -360
  887. package/src/tool/task.txt +0 -19
  888. package/src/tool/todo.ts +0 -46
  889. package/src/tool/todowrite.txt +0 -44
  890. package/src/tool/tool.ts +0 -183
  891. package/src/tool/truncate.ts +0 -156
  892. package/src/tool/truncation-dir.ts +0 -4
  893. package/src/tool/webfetch.ts +0 -192
  894. package/src/tool/webfetch.txt +0 -13
  895. package/src/tool/websearch.ts +0 -143
  896. package/src/tool/websearch.txt +0 -14
  897. package/src/tool/write.ts +0 -104
  898. package/src/tool/write.txt +0 -8
  899. package/src/util/archive.ts +0 -17
  900. package/src/util/bom.ts +0 -27
  901. package/src/util/data-url.ts +0 -9
  902. package/src/util/defer.ts +0 -10
  903. package/src/util/effect-http-client.ts +0 -11
  904. package/src/util/error.ts +0 -1
  905. package/src/util/filesystem.ts +0 -251
  906. package/src/util/html.ts +0 -8
  907. package/src/util/iife.ts +0 -3
  908. package/src/util/lazy.ts +0 -20
  909. package/src/util/local-context.ts +0 -25
  910. package/src/util/locale.ts +0 -2
  911. package/src/util/media.ts +0 -26
  912. package/src/util/process.ts +0 -177
  913. package/src/util/proxy-env.ts +0 -72
  914. package/src/util/queue.ts +0 -32
  915. package/src/util/record.ts +0 -1
  916. package/src/util/repository.ts +0 -232
  917. package/src/util/rpc.ts +0 -66
  918. package/src/util/signal.ts +0 -12
  919. package/src/util/timeout.ts +0 -13
  920. package/src/util/token.ts +0 -1
  921. package/src/util/wildcard.ts +0 -59
  922. package/src/worktree/index.ts +0 -623
  923. package/tsconfig.json +0 -17
  924. /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
@@ -1,2007 +0,0 @@
1
- import { LayerNode } from "@anymous-ai/core/effect/layer-node"
2
- import os from "os"
3
- import type { ConfigV1 } from "@anymous-ai/core/v1/config/config"
4
- import fuzzysort from "fuzzysort"
5
- import { Config } from "@/config/config"
6
- import { mapValues, mergeDeep, omit, pickBy, sortBy } from "remeda"
7
- import { NoSuchModelError, type Provider as SDK } from "ai"
8
- import { Npm } from "@anymous-ai/core/npm"
9
- import { Hash } from "@anymous-ai/core/util/hash"
10
- import { Plugin } from "../plugin"
11
- import { serviceUse } from "@anymous-ai/core/effect/service-use"
12
- import { type LanguageModelV3 } from "@ai-sdk/provider"
13
- import { ModelsDev } from "@anymous-ai/core/models-dev"
14
- import { Auth } from "../auth"
15
- import { Env } from "../env"
16
- import { InstallationVersion } from "@anymous-ai/core/installation/version"
17
- import { iife } from "@/util/iife"
18
- import { Global } from "@anymous-ai/core/global"
19
- import path from "path"
20
- import { pathToFileURL } from "url"
21
- import type { Types } from "effect"
22
- import { Effect, Layer, Context, Schema } from "effect"
23
- import { EffectBridge } from "@/effect/bridge"
24
- import { InstanceState } from "@/effect/instance-state"
25
- import { EffectPromise } from "@/effect/promise"
26
- import { FSUtil } from "@anymous-ai/core/fs-util"
27
- import { isRecord } from "@/util/record"
28
- import { optional } from "@anymous-ai/core/schema"
29
- import { ProviderTransform } from "./transform"
30
- import { ProviderV2 } from "@anymous-ai/core/provider"
31
- import { ModelV2 } from "@anymous-ai/core/model"
32
- import { ModelStatus } from "./model-status"
33
- import { RuntimeFlags } from "@/effect/runtime-flags"
34
- import { ProviderError } from "./error"
35
-
36
- const OPENAI_HEADER_TIMEOUT_DEFAULT = 300_000
37
-
38
- function wrapSSE(res: Response, ms: number, ctl: AbortController) {
39
- if (typeof ms !== "number" || ms <= 0) return res
40
- if (!res.body) return res
41
- if (!res.headers.get("content-type")?.includes("text/event-stream")) return res
42
-
43
- const reader = res.body.getReader()
44
- const body = new ReadableStream<Uint8Array>({
45
- async pull(ctrl) {
46
- const part = await new Promise<Awaited<ReturnType<typeof reader.read>>>((resolve, reject) => {
47
- const id = setTimeout(() => {
48
- const err = new ProviderError.ResponseStreamError("SSE read timed out")
49
- ctl.abort(err)
50
- void reader.cancel(err)
51
- reject(err)
52
- }, ms)
53
-
54
- reader.read().then(
55
- (part) => {
56
- clearTimeout(id)
57
- resolve(part)
58
- },
59
- (err) => {
60
- clearTimeout(id)
61
- reject(err)
62
- },
63
- )
64
- })
65
-
66
- if (part.done) {
67
- ctrl.close()
68
- return
69
- }
70
-
71
- ctrl.enqueue(part.value)
72
- },
73
- async cancel(reason) {
74
- ctl.abort(reason)
75
- await reader.cancel(reason)
76
- },
77
- })
78
-
79
- return new Response(body, {
80
- headers: new Headers(res.headers),
81
- status: res.status,
82
- statusText: res.statusText,
83
- })
84
- }
85
-
86
- function timeoutController(ms: number) {
87
- const ctl = new AbortController()
88
- const id = setTimeout(() => ctl.abort(new ProviderError.HeaderTimeoutError(ms)), ms)
89
- return {
90
- signal: ctl.signal,
91
- clear: () => clearTimeout(id),
92
- }
93
- }
94
-
95
- function googleVertexAnthropicBaseURL(project: string | undefined, location: string | undefined) {
96
- if (!project) return
97
- if (location !== "eu" && location !== "us") return
98
- // Continental multi-regions require Regional Endpoint Platform domains.
99
- return `https://aiplatform.${location}.rep.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`
100
- }
101
-
102
- type BundledSDK = {
103
- languageModel(modelId: string): LanguageModelV3
104
- chat?: (modelId: string) => LanguageModelV3
105
- responses?: (modelId: string) => LanguageModelV3
106
- }
107
-
108
- const BUNDLED_PROVIDERS: Record<string, () => Promise<(opts: any) => BundledSDK>> = {
109
- "@ai-sdk/amazon-bedrock": () => import("@ai-sdk/amazon-bedrock").then((m) => m.createAmazonBedrock),
110
- "@ai-sdk/amazon-bedrock/mantle": () => import("@ai-sdk/amazon-bedrock/mantle").then((m) => m.createBedrockMantle),
111
- "@ai-sdk/anthropic": () => import("@ai-sdk/anthropic").then((m) => m.createAnthropic),
112
- "@ai-sdk/azure": () => import("@ai-sdk/azure").then((m) => m.createAzure),
113
- "@ai-sdk/google": () => import("@ai-sdk/google").then((m) => m.createGoogleGenerativeAI),
114
- "@ai-sdk/google-vertex": () => import("@ai-sdk/google-vertex").then((m) => m.createVertex),
115
- "@ai-sdk/google-vertex/anthropic": () =>
116
- import("@ai-sdk/google-vertex/anthropic").then((m) => m.createVertexAnthropic),
117
- "@ai-sdk/openai": () => import("@ai-sdk/openai").then((m) => m.createOpenAI),
118
- "@ai-sdk/openai-compatible": () => import("@ai-sdk/openai-compatible").then((m) => m.createOpenAICompatible),
119
- "@openrouter/ai-sdk-provider": () => import("@openrouter/ai-sdk-provider").then((m) => m.createOpenRouter),
120
- "@ai-sdk/xai": () => import("@ai-sdk/xai").then((m) => m.createXai),
121
- "@ai-sdk/mistral": () => import("@ai-sdk/mistral").then((m) => m.createMistral),
122
- "@ai-sdk/groq": () => import("@ai-sdk/groq").then((m) => m.createGroq),
123
- "@ai-sdk/deepinfra": () => import("@ai-sdk/deepinfra").then((m) => m.createDeepInfra),
124
- "@ai-sdk/cerebras": () => import("@ai-sdk/cerebras").then((m) => m.createCerebras),
125
- "@ai-sdk/cohere": () => import("@ai-sdk/cohere").then((m) => m.createCohere),
126
- "@ai-sdk/gateway": () => import("@ai-sdk/gateway").then((m) => m.createGateway),
127
- "@ai-sdk/togetherai": () => import("@ai-sdk/togetherai").then((m) => m.createTogetherAI),
128
- "@ai-sdk/perplexity": () => import("@ai-sdk/perplexity").then((m) => m.createPerplexity),
129
- "@ai-sdk/vercel": () => import("@ai-sdk/vercel").then((m) => m.createVercel),
130
- "@ai-sdk/alibaba": () => import("@ai-sdk/alibaba").then((m) => m.createAlibaba),
131
- "gitlab-ai-provider": () => import("gitlab-ai-provider").then((m) => m.createGitLab),
132
- "@ai-sdk/github-copilot": () =>
133
- import("@anymous-ai/core/github-copilot/copilot-provider").then((m) => m.createOpenaiCompatible),
134
- "venice-ai-sdk-provider": () => import("venice-ai-sdk-provider").then((m) => m.createVenice),
135
- }
136
-
137
- type CustomModelLoader = (sdk: any, modelID: string, options?: Record<string, any>, model?: Model) => Promise<any>
138
- type CustomVarsLoader = (options: Record<string, any>) => Record<string, string>
139
- type CustomDiscoverModels = () => Promise<Record<string, Model>>
140
- type CustomLoader = (provider: Info) => Effect.Effect<{
141
- autoload: boolean
142
- getModel?: CustomModelLoader
143
- vars?: CustomVarsLoader
144
- options?: Record<string, any>
145
- discoverModels?: CustomDiscoverModels
146
- }>
147
-
148
- type CustomDep = {
149
- auth: (id: string) => Effect.Effect<Auth.Info | undefined>
150
- config: () => Effect.Effect<ConfigV1.Info>
151
- env: () => Effect.Effect<Record<string, string | undefined>>
152
- get: (key: string) => Effect.Effect<string | undefined>
153
- }
154
-
155
- function selectAzureLanguageModel(sdk: any, modelID: string, useChat: boolean) {
156
- if (useChat && sdk.chat) return sdk.chat(modelID)
157
- if (sdk.responses) return sdk.responses(modelID)
158
- if (sdk.messages) return sdk.messages(modelID)
159
- if (sdk.chat) return sdk.chat(modelID)
160
- return sdk.languageModel(modelID)
161
- }
162
-
163
- function selectBedrockMantleLanguageModel(sdk: BundledSDK, modelID: string) {
164
- if (modelID === "openai.gpt-oss-safeguard-20b" || modelID === "openai.gpt-oss-safeguard-120b")
165
- return sdk.chat?.(modelID) ?? sdk.languageModel(modelID)
166
- return sdk.responses?.(modelID) ?? sdk.languageModel(modelID)
167
- }
168
-
169
- function custom(dep: CustomDep): Record<string, CustomLoader> {
170
- return {
171
- anthropic: () =>
172
- Effect.succeed({
173
- autoload: false,
174
- options: {
175
- headers: {
176
- "anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
177
- },
178
- },
179
- }),
180
- anymous: Effect.fnUntraced(function* (input: Info) {
181
- const env = yield* dep.env()
182
- const hasKey = iife(() => {
183
- if (input.env.some((item) => env[item])) return true
184
- return false
185
- })
186
- const ok =
187
- hasKey ||
188
- Boolean(yield* dep.auth(input.id)) ||
189
- Boolean((yield* dep.config()).provider?.["anymous"]?.options?.apiKey)
190
-
191
- if (!ok) {
192
- for (const [key, value] of Object.entries(input.models)) {
193
- if (value.cost.input === 0) continue
194
- delete input.models[key]
195
- }
196
- }
197
-
198
- return {
199
- autoload: Object.keys(input.models).length > 0,
200
- options: ok ? {} : { apiKey: "public" },
201
- }
202
- }),
203
- openai: () =>
204
- Effect.succeed({
205
- autoload: false,
206
- async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
207
- return sdk.responses(modelID)
208
- },
209
- options: { headerTimeout: OPENAI_HEADER_TIMEOUT_DEFAULT },
210
- }),
211
- meta: () =>
212
- Effect.succeed({
213
- autoload: false,
214
- async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
215
- return sdk.responses(modelID)
216
- },
217
- }),
218
- xai: () =>
219
- Effect.succeed({
220
- autoload: false,
221
- async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
222
- return sdk.responses(modelID)
223
- },
224
- options: {},
225
- }),
226
- "github-copilot": () =>
227
- Effect.succeed({
228
- autoload: false,
229
- async getModel(sdk: any, modelID: string, _options?: Record<string, any>, model?: Model) {
230
- if (sdk.responses === undefined && sdk.chat === undefined) return sdk.languageModel(modelID)
231
- if (model && "endpoint" in model.api) {
232
- if (model.api.endpoint === "responses" && sdk.responses) return sdk.responses(modelID)
233
- if (model.api.endpoint === "chat" && sdk.chat) return sdk.chat(modelID)
234
- }
235
- const match = /^gpt-(\d+)/.exec(modelID)
236
- if (match && Number(match[1]) >= 5 && !modelID.startsWith("gpt-5-mini")) return sdk.responses(modelID)
237
- return sdk.chat(modelID)
238
- },
239
- options: {},
240
- }),
241
- azure: Effect.fnUntraced(function* (provider: Info) {
242
- const env = yield* dep.env()
243
- const auth = yield* dep.auth(provider.id)
244
- const resource = iife(() => {
245
- return [
246
- provider.options?.resourceName,
247
- auth?.type === "api" ? auth.metadata?.resourceName : undefined,
248
- env["AZURE_RESOURCE_NAME"],
249
- ].find((name) => typeof name === "string" && name.trim() !== "")
250
- })
251
-
252
- if (!resource && !provider.options?.baseURL) {
253
- return {
254
- autoload: false,
255
- async getModel() {
256
- throw new Error(
257
- "AZURE_RESOURCE_NAME is missing, set it using env var or reconnecting the azure provider and setting it",
258
- )
259
- },
260
- }
261
- }
262
-
263
- return {
264
- autoload: false,
265
- async getModel(sdk: any, modelID: string, options?: Record<string, any>) {
266
- return selectAzureLanguageModel(sdk, modelID, Boolean(options?.["useCompletionUrls"]))
267
- },
268
- options: {
269
- resourceName: resource,
270
- },
271
- vars(_options): Record<string, string> {
272
- if (resource) {
273
- return {
274
- AZURE_RESOURCE_NAME: resource,
275
- }
276
- }
277
- return {}
278
- },
279
- }
280
- }),
281
- "azure-cognitive-services": Effect.fnUntraced(function* (provider: Info) {
282
- const resourceName = yield* dep.get("AZURE_COGNITIVE_SERVICES_RESOURCE_NAME")
283
- return {
284
- autoload: false,
285
- async getModel(sdk: any, modelID: string, options?: Record<string, any>) {
286
- return selectAzureLanguageModel(sdk, modelID, Boolean(options?.["useCompletionUrls"]))
287
- },
288
- options: {
289
- baseURL: resourceName
290
- ? `https://${resourceName}.cognitiveservices.azure.com/openai${provider.options?.useDeploymentBasedUrls ? "" : "/v1"}`
291
- : undefined,
292
- },
293
- }
294
- }),
295
- "amazon-bedrock": Effect.fnUntraced(function* () {
296
- const providerConfig = (yield* dep.config()).provider?.["amazon-bedrock"]
297
- const auth = yield* dep.auth("amazon-bedrock")
298
- const env = yield* dep.env()
299
-
300
- // Region precedence: 1) config file, 2) env var, 3) default
301
- const configRegion = providerConfig?.options?.region
302
- const envRegion = env["AWS_REGION"]
303
- const defaultRegion = configRegion ?? envRegion ?? "us-east-1"
304
-
305
- // Profile: config file takes precedence over env var
306
- const configProfile = providerConfig?.options?.profile
307
- const envProfile = env["AWS_PROFILE"]
308
- const profile = configProfile ?? envProfile
309
-
310
- const awsAccessKeyId = env["AWS_ACCESS_KEY_ID"]
311
- const configApiKey = providerConfig?.options?.apiKey
312
-
313
- // TODO: Using process.env directly because Env.set only updates a process.env shallow copy,
314
- // until the scope of the Env API is clarified (test only or runtime?)
315
- const awsBearerToken = iife(() => {
316
- const envToken = process.env.AWS_BEARER_TOKEN_BEDROCK
317
- if (envToken) return envToken
318
- if (auth?.type === "api") {
319
- process.env.AWS_BEARER_TOKEN_BEDROCK = auth.key
320
- return auth.key
321
- }
322
- return undefined
323
- })
324
-
325
- const awsWebIdentityTokenFile = env["AWS_WEB_IDENTITY_TOKEN_FILE"]
326
-
327
- const containerCreds = Boolean(
328
- process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI,
329
- )
330
-
331
- if (
332
- !profile &&
333
- !awsAccessKeyId &&
334
- !awsBearerToken &&
335
- !configApiKey &&
336
- !awsWebIdentityTokenFile &&
337
- !containerCreds
338
- )
339
- return { autoload: false }
340
-
341
- const { fromNodeProviderChain } = yield* Effect.promise(() => import("@aws-sdk/credential-providers"))
342
-
343
- const providerOptions: Record<string, any> = {
344
- region: defaultRegion,
345
- }
346
-
347
- // Only use credential chain if no bearer token exists
348
- // Bearer token takes precedence over credential chain (profiles, access keys, IAM roles, web identity tokens)
349
- if (!awsBearerToken && !configApiKey) {
350
- // Build credential provider options (only pass profile if specified)
351
- const credentialProviderOptions = profile ? { profile } : {}
352
-
353
- providerOptions.credentialProvider = fromNodeProviderChain(credentialProviderOptions)
354
- }
355
-
356
- // Add custom endpoint if specified (endpoint takes precedence over baseURL)
357
- const endpoint = providerConfig?.options?.endpoint ?? providerConfig?.options?.baseURL
358
- if (endpoint) {
359
- providerOptions.baseURL = endpoint
360
- }
361
-
362
- return {
363
- autoload: true,
364
- options: providerOptions,
365
- vars(options: Record<string, any>) {
366
- return { AWS_REGION: options.region ?? defaultRegion }
367
- },
368
- async getModel(sdk: any, modelID: string, options?: Record<string, any>, model?: Model) {
369
- if (model?.api.npm === "@ai-sdk/amazon-bedrock/mantle") return selectBedrockMantleLanguageModel(sdk, modelID)
370
-
371
- // Skip region prefixing if model already has a cross-region inference profile prefix
372
- // Models from models.dev may already include prefixes like us., eu., global., etc.
373
- const crossRegionPrefixes = ["global.", "us.", "eu.", "jp.", "apac.", "au."]
374
- if (crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))) {
375
- return sdk.languageModel(modelID)
376
- }
377
-
378
- // Region resolution precedence (highest to lowest):
379
- // 1. options.region from anymous.json provider config
380
- // 2. defaultRegion from AWS_REGION environment variable
381
- // 3. Default "us-east-1" (baked into defaultRegion)
382
- const region = options?.region ?? defaultRegion
383
-
384
- let regionPrefix = region.split("-")[0]
385
-
386
- switch (regionPrefix) {
387
- case "us": {
388
- const modelRequiresPrefix = [
389
- "nova-micro",
390
- "nova-lite",
391
- "nova-pro",
392
- "nova-premier",
393
- "nova-2",
394
- "claude",
395
- "deepseek",
396
- ].some((m) => modelID.includes(m))
397
- const isGovCloud = region.startsWith("us-gov")
398
- if (modelRequiresPrefix && !isGovCloud) {
399
- modelID = `${regionPrefix}.${modelID}`
400
- }
401
- break
402
- }
403
- case "eu": {
404
- const regionRequiresPrefix = [
405
- "eu-west-1",
406
- "eu-west-2",
407
- "eu-west-3",
408
- "eu-north-1",
409
- "eu-central-1",
410
- "eu-south-1",
411
- "eu-south-2",
412
- ].some((r) => region.includes(r))
413
- const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "llama3", "pixtral"].some((m) =>
414
- modelID.includes(m),
415
- )
416
- if (regionRequiresPrefix && modelRequiresPrefix) {
417
- modelID = `${regionPrefix}.${modelID}`
418
- }
419
- break
420
- }
421
- case "ap": {
422
- const isAustraliaRegion = ["ap-southeast-2", "ap-southeast-4"].includes(region)
423
- const isTokyoRegion = region === "ap-northeast-1"
424
- if (
425
- isAustraliaRegion &&
426
- ["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"].some((m) => modelID.includes(m))
427
- ) {
428
- regionPrefix = "au"
429
- modelID = `${regionPrefix}.${modelID}`
430
- } else if (isTokyoRegion) {
431
- // Tokyo region uses jp. prefix for cross-region inference
432
- const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "nova-pro"].some((m) =>
433
- modelID.includes(m),
434
- )
435
- if (modelRequiresPrefix) {
436
- regionPrefix = "jp"
437
- modelID = `${regionPrefix}.${modelID}`
438
- }
439
- } else {
440
- // Other APAC regions use apac. prefix
441
- const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "nova-pro"].some((m) =>
442
- modelID.includes(m),
443
- )
444
- if (modelRequiresPrefix) {
445
- regionPrefix = "apac"
446
- modelID = `${regionPrefix}.${modelID}`
447
- }
448
- }
449
- break
450
- }
451
- }
452
-
453
- return sdk.languageModel(modelID)
454
- },
455
- }
456
- }),
457
- llmgateway: () =>
458
- Effect.succeed({
459
- autoload: false,
460
- options: {
461
- headers: {
462
- "HTTP-Referer": "https://anymous-cli.vercel.app/",
463
- "X-Title": "anymous",
464
- "X-Source": "anymous",
465
- },
466
- },
467
- }),
468
- openrouter: () =>
469
- Effect.succeed({
470
- autoload: false,
471
- options: {
472
- headers: {
473
- "HTTP-Referer": "https://anymous-cli.vercel.app/",
474
- "X-Title": "anymous",
475
- },
476
- },
477
- }),
478
- nvidia: (provider) =>
479
- Effect.succeed({
480
- autoload: provider.source === "config",
481
- options: {
482
- headers: {
483
- "HTTP-Referer": "https://anymous-cli.vercel.app/",
484
- "X-Title": "anymous",
485
- "X-BILLING-INVOKE-ORIGIN": "anymous",
486
- },
487
- },
488
- }),
489
- vercel: () =>
490
- Effect.succeed({
491
- autoload: false,
492
- options: {
493
- headers: {
494
- "http-referer": "https://anymous-cli.vercel.app/",
495
- "x-title": "anymous",
496
- },
497
- },
498
- }),
499
- "google-vertex": Effect.fnUntraced(function* (provider: Info) {
500
- const env = yield* dep.env()
501
- // models.dev advertises GOOGLE_VERTEX_PROJECT for Vertex; keep the wider
502
- // Google Cloud project env names as fallbacks for existing ADC setups.
503
- const project =
504
- provider.options?.project ??
505
- env["GOOGLE_VERTEX_PROJECT"] ??
506
- env["GOOGLE_CLOUD_PROJECT"] ??
507
- env["GCP_PROJECT"] ??
508
- env["GCLOUD_PROJECT"]
509
-
510
- const location = String(
511
- provider.options?.location ??
512
- env["GOOGLE_VERTEX_LOCATION"] ??
513
- env["GOOGLE_CLOUD_LOCATION"] ??
514
- env["VERTEX_LOCATION"] ??
515
- "us-central1",
516
- )
517
-
518
- const autoload = Boolean(project)
519
- if (!autoload) return { autoload: false }
520
- return {
521
- autoload: true,
522
- vars(_options: Record<string, any>) {
523
- const endpoint = location === "global" ? "aiplatform.googleapis.com" : `${location}-aiplatform.googleapis.com`
524
- return {
525
- ...(project && { GOOGLE_VERTEX_PROJECT: project }),
526
- GOOGLE_VERTEX_LOCATION: location,
527
- GOOGLE_VERTEX_ENDPOINT: endpoint,
528
- }
529
- },
530
- options: {
531
- project,
532
- location,
533
- fetch: async (input: RequestInfo | URL, init?: RequestInit) => {
534
- const { GoogleAuth } = await import("google-auth-library")
535
- const auth = new GoogleAuth({ scopes: ["https://www.googleapis.com/auth/cloud-platform"] })
536
- const client = await auth.getClient()
537
- const token = await client.getAccessToken()
538
-
539
- const headers = new Headers(init?.headers)
540
- headers.set("Authorization", `Bearer ${token.token}`)
541
-
542
- return fetch(input, { ...init, headers })
543
- },
544
- },
545
- async getModel(sdk: any, modelID: string) {
546
- const id = String(modelID).trim()
547
- return sdk.languageModel(id)
548
- },
549
- }
550
- }),
551
- "google-vertex-anthropic": Effect.fnUntraced(function* () {
552
- const env = yield* dep.env()
553
- const project = env["GOOGLE_CLOUD_PROJECT"] ?? env["GCP_PROJECT"] ?? env["GCLOUD_PROJECT"]
554
- const location = env["GOOGLE_CLOUD_LOCATION"] ?? env["VERTEX_LOCATION"] ?? "global"
555
- const autoload = Boolean(project)
556
- if (!autoload) return { autoload: false }
557
- const baseURL = googleVertexAnthropicBaseURL(project, location)
558
- return {
559
- autoload: true,
560
- options: {
561
- project,
562
- location,
563
- ...(baseURL && { baseURL }),
564
- },
565
- async getModel(sdk: any, modelID) {
566
- const id = String(modelID).trim()
567
- return sdk.languageModel(id)
568
- },
569
- }
570
- }),
571
- "sap-ai-core": Effect.fnUntraced(function* () {
572
- const auth = yield* dep.auth("sap-ai-core")
573
- // TODO: Using process.env directly because Env.set only updates a shallow copy (not process.env),
574
- // until the scope of the Env API is clarified (test only or runtime?)
575
- const envServiceKey = iife(() => {
576
- const envAICoreServiceKey = process.env.AICORE_SERVICE_KEY
577
- if (envAICoreServiceKey) return envAICoreServiceKey
578
- if (auth?.type === "api") {
579
- process.env.AICORE_SERVICE_KEY = auth.key
580
- return auth.key
581
- }
582
- return undefined
583
- })
584
- const deploymentId = process.env.AICORE_DEPLOYMENT_ID
585
- const resourceGroup = process.env.AICORE_RESOURCE_GROUP
586
-
587
- return {
588
- autoload: !!envServiceKey,
589
- options: envServiceKey ? { deploymentId, resourceGroup } : {},
590
- async getModel(sdk: any, modelID: string) {
591
- return sdk(modelID)
592
- },
593
- }
594
- }),
595
- zenmux: () =>
596
- Effect.succeed({
597
- autoload: false,
598
- options: {
599
- headers: {
600
- "HTTP-Referer": "https://anymous-cli.vercel.app/",
601
- "X-Title": "anymous",
602
- },
603
- },
604
- }),
605
- gitlab: Effect.fnUntraced(function* (input: Info) {
606
- const {
607
- VERSION: GITLAB_PROVIDER_VERSION,
608
- isWorkflowModel,
609
- discoverWorkflowModels,
610
- } = yield* Effect.promise(() => import("gitlab-ai-provider"))
611
-
612
- const instanceUrl = (yield* dep.get("GITLAB_INSTANCE_URL")) || "https://gitlab.com"
613
-
614
- const auth = yield* dep.auth(input.id)
615
- const apiKey = auth?.type === "oauth" ? auth.access : auth?.type === "api" ? auth.key : undefined
616
- const token = apiKey ?? (yield* dep.get("GITLAB_TOKEN"))
617
-
618
- const providerConfig = (yield* dep.config()).provider?.["gitlab"]
619
- const directory = yield* InstanceState.directory
620
-
621
- const aiGatewayHeaders = {
622
- "User-Agent": `anymous/${InstallationVersion} gitlab-ai-provider/${GITLAB_PROVIDER_VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`,
623
- "anthropic-beta": "context-1m-2025-08-07",
624
- ...providerConfig?.options?.aiGatewayHeaders,
625
- }
626
-
627
- const featureFlags = {
628
- duo_agent_platform_agentic_chat: true,
629
- duo_agent_platform: true,
630
- ...providerConfig?.options?.featureFlags,
631
- }
632
-
633
- return {
634
- autoload: !!token,
635
- options: {
636
- instanceUrl,
637
- apiKey: token,
638
- aiGatewayHeaders,
639
- featureFlags,
640
- },
641
- async getModel(sdk: any, modelID: string, options?: Record<string, any>) {
642
- if (modelID.startsWith("duo-workflow-")) {
643
- const workflowRef = typeof options?.workflowRef === "string" ? options.workflowRef : undefined
644
- // Use the static mapping if it exists, otherwise use duo-workflow with selectedModelRef
645
- const sdkModelID = isWorkflowModel(modelID) ? modelID : "duo-workflow"
646
- const workflowDefinition =
647
- typeof options?.workflowDefinition === "string" ? options.workflowDefinition : undefined
648
- const model = sdk.workflowChat(sdkModelID, {
649
- featureFlags,
650
- workflowDefinition,
651
- })
652
- if (workflowRef) {
653
- model.selectedModelRef = workflowRef
654
- }
655
- return model
656
- }
657
- return sdk.agenticChat(modelID, {
658
- aiGatewayHeaders,
659
- featureFlags,
660
- })
661
- },
662
- async discoverModels(): Promise<Record<string, Model>> {
663
- if (!apiKey) {
664
- return {}
665
- }
666
-
667
- try {
668
- const token = apiKey
669
- const getHeaders = (): Record<string, string> =>
670
- auth?.type === "api" ? { "PRIVATE-TOKEN": token } : { Authorization: `Bearer ${token}` }
671
-
672
- const result = await discoverWorkflowModels({ instanceUrl, getHeaders }, { workingDirectory: directory })
673
-
674
- if (!result.models.length) {
675
- return {}
676
- }
677
-
678
- const models: Record<string, Model> = {}
679
- for (const m of result.models) {
680
- if (!input.models[m.id]) {
681
- models[m.id] = {
682
- id: ModelV2.ID.make(m.id),
683
- providerID: ProviderV2.ID.make("gitlab"),
684
- name: `Agent Platform (${m.name})`,
685
- family: "",
686
- api: {
687
- id: m.id,
688
- url: instanceUrl,
689
- npm: "gitlab-ai-provider",
690
- },
691
- status: "active",
692
- headers: {},
693
- options: { workflowRef: m.ref },
694
- cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
695
- limit: { context: m.context, output: m.output },
696
- capabilities: {
697
- temperature: false,
698
- reasoning: true,
699
- attachment: true,
700
- toolcall: true,
701
- input: {
702
- text: true,
703
- audio: false,
704
- image: true,
705
- video: false,
706
- pdf: true,
707
- },
708
- output: {
709
- text: true,
710
- audio: false,
711
- image: false,
712
- video: false,
713
- pdf: false,
714
- },
715
- interleaved: false,
716
- },
717
- release_date: "",
718
- variants: {},
719
- }
720
- }
721
- }
722
-
723
- return models
724
- } catch (e) {
725
- return {}
726
- }
727
- },
728
- }
729
- }),
730
- "cloudflare-workers-ai": Effect.fnUntraced(function* (input: Info) {
731
- // When baseURL is already configured (e.g. corporate config routing through a proxy/gateway),
732
- // skip the account ID check because the URL is already fully specified.
733
- if (input.options?.baseURL) return { autoload: false }
734
-
735
- const auth = yield* dep.auth(input.id)
736
- const env = yield* dep.env()
737
- const accountId = env["CLOUDFLARE_ACCOUNT_ID"] || (auth?.type === "api" ? auth.metadata?.accountId : undefined)
738
- if (!accountId)
739
- return {
740
- autoload: false,
741
- async getModel() {
742
- throw new Error(
743
- "CLOUDFLARE_ACCOUNT_ID is missing. Set it with: export CLOUDFLARE_ACCOUNT_ID=<your-account-id>",
744
- )
745
- },
746
- }
747
-
748
- const apiKey = env["CLOUDFLARE_API_KEY"] || (auth?.type === "api" ? auth.key : undefined)
749
-
750
- return {
751
- autoload: !!apiKey,
752
- options: {
753
- apiKey,
754
- headers: {
755
- "User-Agent": `anymous/${InstallationVersion} cloudflare-workers-ai (${os.platform()} ${os.release()}; ${os.arch()})`,
756
- },
757
- },
758
- async getModel(sdk: any, modelID: string) {
759
- return sdk.languageModel(modelID)
760
- },
761
- vars(_options) {
762
- return {
763
- CLOUDFLARE_ACCOUNT_ID: accountId,
764
- }
765
- },
766
- }
767
- }),
768
- "cloudflare-ai-gateway": Effect.fnUntraced(function* (input: Info) {
769
- // When baseURL is already configured (e.g. corporate config), skip the ID checks.
770
- if (input.options?.baseURL) return { autoload: false }
771
-
772
- const auth = yield* dep.auth(input.id)
773
- const env = yield* dep.env()
774
- const accountId = env["CLOUDFLARE_ACCOUNT_ID"] || (auth?.type === "api" ? auth.metadata?.accountId : undefined)
775
- // The Cloudflare auth prompt stores this value as gatewayId metadata.
776
- const gateway = env["CLOUDFLARE_GATEWAY_ID"] || (auth?.type === "api" ? auth.metadata?.gatewayId : undefined)
777
-
778
- if (!accountId || !gateway) {
779
- const missing = [
780
- !accountId ? "CLOUDFLARE_ACCOUNT_ID" : undefined,
781
- !gateway ? "CLOUDFLARE_GATEWAY_ID" : undefined,
782
- ].filter((x): x is string => Boolean(x))
783
- return {
784
- autoload: false,
785
- async getModel() {
786
- throw new Error(
787
- `${missing.join(" and ")} missing. Set with: ${missing.map((x) => `export ${x}=<value>`).join(" && ")}`,
788
- )
789
- },
790
- }
791
- }
792
-
793
- // Get API token from env or auth - required for authenticated gateways
794
- const apiToken =
795
- env["CLOUDFLARE_API_TOKEN"] || env["CF_AIG_TOKEN"] || (auth?.type === "api" ? auth.key : undefined)
796
-
797
- if (!apiToken) {
798
- throw new Error(
799
- "CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required for Cloudflare AI Gateway. " +
800
- "Set it via environment variable or run `anymous auth cloudflare-ai-gateway`.",
801
- )
802
- }
803
-
804
- // Use official ai-gateway-provider package (v2.x for AI SDK v5 compatibility)
805
- const { createAiGateway } = yield* Effect.promise(() => import("ai-gateway-provider"))
806
- const { createUnified } = yield* Effect.promise(() => import("ai-gateway-provider/providers/unified"))
807
-
808
- const metadata = iife(() => {
809
- if (input.options?.metadata) return input.options.metadata
810
- try {
811
- return JSON.parse(input.options?.headers?.["cf-aig-metadata"])
812
- } catch {
813
- return undefined
814
- }
815
- })
816
- const opts = {
817
- metadata,
818
- cacheTtl: input.options?.cacheTtl,
819
- cacheKey: input.options?.cacheKey,
820
- skipCache: input.options?.skipCache,
821
- collectLog: input.options?.collectLog,
822
- headers: {
823
- "User-Agent": `anymous/${InstallationVersion} cloudflare-ai-gateway (${os.platform()} ${os.release()}; ${os.arch()})`,
824
- },
825
- }
826
-
827
- const aigateway = createAiGateway({
828
- accountId,
829
- gateway,
830
- apiKey: apiToken,
831
- ...(Object.values(opts).some((v) => v !== undefined) ? { options: opts } : {}),
832
- })
833
- const unified = createUnified({ apiKey: apiToken })
834
-
835
- return {
836
- autoload: true,
837
- async getModel(_sdk: any, modelID: string, _options?: Record<string, any>) {
838
- // Model IDs use Unified API format: provider/model (e.g., "anthropic/claude-sonnet-4-5")
839
- return aigateway(unified(modelID))
840
- },
841
- options: {},
842
- }
843
- }),
844
- cerebras: () =>
845
- Effect.succeed({
846
- autoload: false,
847
- options: {
848
- headers: {
849
- "X-Cerebras-3rd-Party-Integration": "anymous",
850
- },
851
- },
852
- }),
853
- kilo: () =>
854
- Effect.succeed({
855
- autoload: false,
856
- options: {
857
- headers: {
858
- "HTTP-Referer": "https://anymous-cli.vercel.app/",
859
- "X-Title": "anymous",
860
- },
861
- },
862
- }),
863
- "snowflake-cortex": Effect.fnUntraced(function* (input: Info) {
864
- const env = yield* dep.env()
865
- const auth = yield* dep.auth(input.id)
866
-
867
- const account =
868
- env["SNOWFLAKE_ACCOUNT"] ??
869
- (auth?.type === "api" ? auth.metadata?.account : undefined) ??
870
- (auth?.type === "oauth" ? auth.accountId : undefined) ??
871
- input.options?.account
872
-
873
- const envToken = env["SNOWFLAKE_CORTEX_TOKEN"] ?? env["SNOWFLAKE_CORTEX_PAT"]
874
- const apiKeyToken = auth?.type === "api" ? auth.key : undefined
875
- const oauthToken = auth?.type === "oauth" ? auth.access : undefined
876
- const configToken = input.options?.token ?? input.options?.apiKey
877
-
878
- const token = envToken ?? apiKeyToken ?? oauthToken ?? configToken
879
-
880
- if (!account || !token) {
881
- const missing = [!account && "SNOWFLAKE_ACCOUNT", !token && "SNOWFLAKE_CORTEX_TOKEN"].filter(Boolean).join(", ")
882
- return {
883
- autoload: false,
884
- async getModel() {
885
- throw new Error(
886
- `Snowflake Cortex: missing credentials (${missing}). Provide a bearer token (OAuth, JWT, or PAT) via env var, anymous auth, or provider options.`,
887
- )
888
- },
889
- }
890
- }
891
-
892
- const baseURL = `https://${account}.snowflakecomputing.com/api/v2/cortex/v1`
893
-
894
- const options: Record<string, any> = { baseURL, apiKey: token }
895
-
896
- // Only skip provider-level fetch when the token is from OAuth with no override.
897
- // For OAuth tokens, the plugin auth loader's combined fetch handles
898
- // OAuth refresh + snowflake transformations in one place.
899
- // For env/config/API-key tokens, the provider fetch applies snowflake
900
- // transformations directly.
901
- const useOAuthHandler =
902
- oauthToken !== undefined && envToken === undefined && apiKeyToken === undefined && configToken === undefined
903
- if (!useOAuthHandler) {
904
- options.fetch = async (url: RequestInfo | URL, init?: RequestInit) => {
905
- if (init?.body && typeof init.body === "string") {
906
- try {
907
- const body = JSON.parse(init.body)
908
- if ("max_tokens" in body) {
909
- body.max_completion_tokens = body.max_tokens
910
- delete body.max_tokens
911
- init = { ...init, body: JSON.stringify(body) }
912
- }
913
- } catch {}
914
- }
915
-
916
- const response = await fetch(url, init)
917
-
918
- if (!response.ok && response.status === 400) {
919
- try {
920
- const errorData = await response.clone().json()
921
- const errorMessage = String(errorData.message || errorData.error || "")
922
- if (errorMessage.toLowerCase().includes("conversation complete")) {
923
- return new Response(
924
- JSON.stringify({
925
- choices: [{ finish_reason: "stop", message: { content: "", role: "assistant" } }],
926
- }),
927
- { status: 200, headers: new Headers({ "content-type": "application/json" }) },
928
- )
929
- }
930
- } catch {}
931
- }
932
-
933
- if (response.body && response.headers.get("content-type")?.includes("text/event-stream")) {
934
- const reader = response.body.getReader()
935
- const encoder = new TextEncoder()
936
- const decoder = new TextDecoder()
937
- const stream = new ReadableStream({
938
- async pull(ctrl) {
939
- const { done, value } = await reader.read()
940
- if (done) {
941
- ctrl.close()
942
- return
943
- }
944
- const text = decoder.decode(value, { stream: true })
945
- ctrl.enqueue(encoder.encode(text.replace(/"role"\s*:\s*""/g, '"role":"assistant"')))
946
- },
947
- cancel() {
948
- reader.cancel()
949
- },
950
- })
951
- return new Response(stream, { headers: response.headers, status: response.status })
952
- }
953
-
954
- return response
955
- }
956
- }
957
-
958
- return {
959
- autoload: input.source === "config",
960
- options,
961
- }
962
- }),
963
- }
964
- }
965
-
966
- const ProviderApiInfo = Schema.Struct({
967
- id: Schema.String,
968
- url: Schema.String,
969
- npm: Schema.String,
970
- })
971
-
972
- const ProviderModalities = Schema.Struct({
973
- text: Schema.Boolean,
974
- audio: Schema.Boolean,
975
- image: Schema.Boolean,
976
- video: Schema.Boolean,
977
- pdf: Schema.Boolean,
978
- })
979
-
980
- const ProviderInterleaved = Schema.Union([
981
- Schema.Boolean,
982
- Schema.Struct({
983
- field: Schema.Literals(["reasoning", "reasoning_content", "reasoning_details"]),
984
- }),
985
- ])
986
-
987
- const ProviderCapabilities = Schema.Struct({
988
- temperature: Schema.Boolean,
989
- reasoning: Schema.Boolean,
990
- attachment: Schema.Boolean,
991
- toolcall: Schema.Boolean,
992
- input: ProviderModalities,
993
- output: ProviderModalities,
994
- interleaved: ProviderInterleaved,
995
- })
996
-
997
- const ProviderCacheCost = Schema.Struct({
998
- read: Schema.Finite,
999
- write: Schema.Finite,
1000
- })
1001
-
1002
- const ProviderCostTier = Schema.Struct({
1003
- input: Schema.Finite,
1004
- output: Schema.Finite,
1005
- cache: ProviderCacheCost,
1006
- tier: Schema.Struct({
1007
- type: Schema.Literal("context"),
1008
- size: Schema.Finite,
1009
- }),
1010
- })
1011
-
1012
- const ProviderCost = Schema.Struct({
1013
- input: Schema.Finite,
1014
- output: Schema.Finite,
1015
- cache: ProviderCacheCost,
1016
- tiers: optional(Schema.Array(ProviderCostTier)),
1017
- experimentalOver200K: optional(
1018
- Schema.Struct({
1019
- input: Schema.Finite,
1020
- output: Schema.Finite,
1021
- cache: ProviderCacheCost,
1022
- }),
1023
- ),
1024
- })
1025
-
1026
- const ProviderLimit = Schema.Struct({
1027
- context: Schema.Finite,
1028
- input: optional(Schema.Finite),
1029
- output: Schema.Finite,
1030
- })
1031
-
1032
- export const Model = Schema.Struct({
1033
- id: ModelV2.ID,
1034
- providerID: ProviderV2.ID,
1035
- api: ProviderApiInfo,
1036
- name: Schema.String,
1037
- family: optional(Schema.String),
1038
- capabilities: ProviderCapabilities,
1039
- cost: ProviderCost,
1040
- limit: ProviderLimit,
1041
- status: ModelStatus,
1042
- options: Schema.Record(Schema.String, Schema.Any),
1043
- headers: Schema.Record(Schema.String, Schema.String),
1044
- release_date: Schema.String,
1045
- variants: optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Any))),
1046
- }).annotate({ identifier: "Model" })
1047
- export type Model = Types.DeepMutable<Schema.Schema.Type<typeof Model>>
1048
-
1049
- export const Info = Schema.Struct({
1050
- id: ProviderV2.ID,
1051
- name: Schema.String,
1052
- source: Schema.Literals(["env", "config", "custom", "api"]),
1053
- env: Schema.Array(Schema.String),
1054
- key: optional(Schema.String),
1055
- options: Schema.Record(Schema.String, Schema.Any),
1056
- models: Schema.Record(Schema.String, Model),
1057
- }).annotate({ identifier: "Provider" })
1058
- export type Info = Types.DeepMutable<Schema.Schema.Type<typeof Info>>
1059
-
1060
- const DefaultModelIDs = Schema.Record(Schema.String, Schema.String)
1061
-
1062
- export const ListResult = Schema.Struct({
1063
- all: Schema.Array(Info),
1064
- default: DefaultModelIDs,
1065
- connected: Schema.Array(Schema.String),
1066
- })
1067
- export type ListResult = Types.DeepMutable<Schema.Schema.Type<typeof ListResult>>
1068
-
1069
- export const ConfigProvidersResult = Schema.Struct({
1070
- providers: Schema.Array(Info),
1071
- default: DefaultModelIDs,
1072
- })
1073
- export type ConfigProvidersResult = Types.DeepMutable<Schema.Schema.Type<typeof ConfigProvidersResult>>
1074
-
1075
- export function toPublicInfo(provider: Info): Info {
1076
- return JSON.parse(
1077
- JSON.stringify(
1078
- {
1079
- ...provider,
1080
- models: Object.fromEntries(Object.entries(provider.models).filter(([, model]) => Schema.is(Model)(model))),
1081
- },
1082
- (_, value) => {
1083
- if (typeof value === "function" || typeof value === "symbol" || value === undefined) return undefined
1084
- if (typeof value === "bigint") return value.toString()
1085
- return value
1086
- },
1087
- ),
1088
- )
1089
- }
1090
-
1091
- export function defaultModelIDs<T extends { models: Record<string, { id: string }> }>(providers: Record<string, T>) {
1092
- return mapValues(providers, (item) => sort(Object.values(item.models))[0].id)
1093
- }
1094
-
1095
- export class ModelNotFoundError extends Schema.TaggedErrorClass<ModelNotFoundError>()("ProviderModelNotFoundError", {
1096
- providerID: ProviderV2.ID,
1097
- modelID: ModelV2.ID,
1098
- suggestions: Schema.optional(Schema.Array(Schema.String)),
1099
- cause: Schema.optional(Schema.Defect()),
1100
- }) {
1101
- override get message() {
1102
- const suggestions = this.suggestions?.length ? ` Did you mean: ${this.suggestions.join(", ")}?` : ""
1103
- return `Model not found: ${this.providerID}/${this.modelID}.${suggestions}`
1104
- }
1105
-
1106
- static isInstance(input: unknown): input is ModelNotFoundError {
1107
- return input instanceof ModelNotFoundError
1108
- }
1109
- }
1110
-
1111
- export class InitError extends Schema.TaggedErrorClass<InitError>()("ProviderInitError", {
1112
- providerID: ProviderV2.ID,
1113
- cause: Schema.optional(Schema.Defect()),
1114
- }) {
1115
- override get message() {
1116
- return `Failed to initialize provider: ${this.providerID}`
1117
- }
1118
-
1119
- static isInstance(input: unknown): input is InitError {
1120
- return input instanceof InitError
1121
- }
1122
- }
1123
-
1124
- export class NoProvidersError extends Schema.TaggedErrorClass<NoProvidersError>()("ProviderNoProvidersError", {}) {
1125
- override get message() {
1126
- return "No providers are available"
1127
- }
1128
-
1129
- static isInstance(input: unknown): input is NoProvidersError {
1130
- return input instanceof NoProvidersError
1131
- }
1132
- }
1133
-
1134
- export class NoModelsError extends Schema.TaggedErrorClass<NoModelsError>()("ProviderNoModelsError", {
1135
- providerID: ProviderV2.ID,
1136
- }) {
1137
- override get message() {
1138
- return `No models are available for provider: ${this.providerID}`
1139
- }
1140
-
1141
- static isInstance(input: unknown): input is NoModelsError {
1142
- return input instanceof NoModelsError
1143
- }
1144
- }
1145
-
1146
- export type DefaultModelError = ModelNotFoundError | NoProvidersError | NoModelsError
1147
- export type Error = ModelNotFoundError | InitError | NoProvidersError | NoModelsError
1148
-
1149
- export interface Interface {
1150
- readonly list: () => Effect.Effect<Record<ProviderV2.ID, Info>>
1151
- readonly getProvider: (providerID: ProviderV2.ID) => Effect.Effect<Info>
1152
- readonly getModel: (providerID: ProviderV2.ID, modelID: ModelV2.ID) => Effect.Effect<Model, ModelNotFoundError>
1153
- readonly getLanguage: (model: Model) => Effect.Effect<LanguageModelV3, ModelNotFoundError>
1154
- readonly closest: (
1155
- providerID: ProviderV2.ID,
1156
- query: string[],
1157
- ) => Effect.Effect<{ providerID: ProviderV2.ID; modelID: string } | undefined>
1158
- readonly getSmallModel: (providerID: ProviderV2.ID) => Effect.Effect<Model | undefined>
1159
- readonly defaultModel: () => Effect.Effect<{ providerID: ProviderV2.ID; modelID: ModelV2.ID }, DefaultModelError>
1160
- }
1161
-
1162
- interface State {
1163
- models: Map<string, LanguageModelV3>
1164
- providers: Record<ProviderV2.ID, Info>
1165
- catalog: Record<ProviderV2.ID, Info>
1166
- sdk: Map<string, BundledSDK>
1167
- modelLoaders: Record<string, CustomModelLoader>
1168
- varsLoaders: Record<string, CustomVarsLoader>
1169
- }
1170
-
1171
- export class Service extends Context.Service<Service, Interface>()("@anymous/Provider") {}
1172
-
1173
- export const use = serviceUse(Service)
1174
-
1175
- function cost(c: ModelsDev.Model["cost"]): Model["cost"] {
1176
- const result: Model["cost"] = {
1177
- input: c?.input ?? 0,
1178
- output: c?.output ?? 0,
1179
- cache: {
1180
- read: c?.cache_read ?? 0,
1181
- write: c?.cache_write ?? 0,
1182
- },
1183
- }
1184
- if (c?.tiers) {
1185
- result.tiers = c.tiers.map((item) => ({
1186
- input: item.input,
1187
- output: item.output,
1188
- cache: {
1189
- read: item.cache_read ?? 0,
1190
- write: item.cache_write ?? 0,
1191
- },
1192
- tier: item.tier,
1193
- }))
1194
- }
1195
- if (c?.context_over_200k) {
1196
- result.experimentalOver200K = {
1197
- cache: {
1198
- read: c.context_over_200k.cache_read ?? 0,
1199
- write: c.context_over_200k.cache_write ?? 0,
1200
- },
1201
- input: c.context_over_200k.input,
1202
- output: c.context_over_200k.output,
1203
- }
1204
- }
1205
- return result
1206
- }
1207
-
1208
- function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model): Model {
1209
- const base: Model = {
1210
- id: ModelV2.ID.make(model.id),
1211
- providerID: ProviderV2.ID.make(provider.id),
1212
- name: model.name,
1213
- family: model.family,
1214
- api: {
1215
- id: model.id,
1216
- url: model.provider?.api ?? provider.api ?? "",
1217
- npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible",
1218
- },
1219
- status: model.status ?? "active",
1220
- headers: {},
1221
- options: {},
1222
- cost: cost(model.cost),
1223
- limit: {
1224
- context: model.limit.context,
1225
- input: model.limit.input,
1226
- output: model.limit.output,
1227
- },
1228
- capabilities: {
1229
- temperature: model.temperature ?? false,
1230
- reasoning: model.reasoning ?? false,
1231
- attachment: model.attachment ?? false,
1232
- toolcall: model.tool_call ?? true,
1233
- input: {
1234
- text: model.modalities?.input?.includes("text") ?? false,
1235
- audio: model.modalities?.input?.includes("audio") ?? false,
1236
- image: model.modalities?.input?.includes("image") ?? false,
1237
- video: model.modalities?.input?.includes("video") ?? false,
1238
- pdf: model.modalities?.input?.includes("pdf") ?? false,
1239
- },
1240
- output: {
1241
- text: model.modalities?.output?.includes("text") ?? false,
1242
- audio: model.modalities?.output?.includes("audio") ?? false,
1243
- image: model.modalities?.output?.includes("image") ?? false,
1244
- video: model.modalities?.output?.includes("video") ?? false,
1245
- pdf: model.modalities?.output?.includes("pdf") ?? false,
1246
- },
1247
- interleaved: model.interleaved ?? false,
1248
- },
1249
- release_date: model.release_date ?? "",
1250
- variants: {},
1251
- }
1252
-
1253
- const variants = ProviderTransform.reasoningVariants(model, base) ?? ProviderTransform.variants(base)
1254
-
1255
- return {
1256
- ...base,
1257
- variants: mapValues(variants, (v) => v),
1258
- }
1259
- }
1260
-
1261
- export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
1262
- const models: Record<string, Model> = {}
1263
- for (const [key, model] of Object.entries(provider.models)) {
1264
- models[key] = fromModelsDevModel(provider, model)
1265
- for (const [mode, opts] of Object.entries(model.experimental?.modes ?? {})) {
1266
- const id = `${model.id}-${mode}`
1267
- const base = fromModelsDevModel(provider, model)
1268
- models[id] = {
1269
- ...base,
1270
- id: ModelV2.ID.make(id),
1271
- name: `${model.name} ${mode[0].toUpperCase()}${mode.slice(1)}`,
1272
- cost: opts.cost ? mergeDeep(base.cost, cost(opts.cost)) : base.cost,
1273
- options: modeOptions(base, opts.provider?.body),
1274
- headers: opts.provider?.headers ?? base.headers,
1275
- }
1276
- }
1277
- }
1278
- return {
1279
- id: ProviderV2.ID.make(provider.id),
1280
- source: "custom",
1281
- name: provider.name,
1282
- env: [...(provider.env ?? [])],
1283
- options: {},
1284
- models,
1285
- }
1286
- }
1287
-
1288
- function modeOptions(model: Model, body: Record<string, unknown> | undefined) {
1289
- if (!body) return model.options
1290
- const options = Object.fromEntries(
1291
- Object.entries(body).map(([key, value]) => [key.replace(/_([a-z])/g, (_, char) => char.toUpperCase()), value]),
1292
- )
1293
- const reasoning = body.reasoning
1294
- if (model.api.npm !== "@ai-sdk/openai" || !isRecord(reasoning) || typeof reasoning.mode !== "string") return options
1295
- const { reasoning: _, ...rest } = options
1296
- return { ...rest, reasoningMode: reasoning.mode }
1297
- }
1298
-
1299
- function modelSuggestions(provider: Info | undefined, modelID: ModelV2.ID, enableExperimentalModels: boolean) {
1300
- const available = provider
1301
- ? Object.keys(provider.models).filter((id) => {
1302
- const model = provider.models[id]
1303
- if (model.status === "deprecated") return false
1304
- if (model.status === "alpha" && !enableExperimentalModels) return false
1305
- return true
1306
- })
1307
- : []
1308
- const fuzzy = fuzzysort.go(modelID, available, { limit: 3, threshold: -10000 }).map((m) => m.target)
1309
- if (fuzzy.length) return fuzzy
1310
- const query = modelID
1311
- .toLowerCase()
1312
- .split(/[^a-z0-9]+/)
1313
- .filter((part) => part.length > 1)
1314
- return sortBy(
1315
- available
1316
- .map((id) => ({
1317
- id,
1318
- score: query.filter((part) => id.toLowerCase().includes(part)).length,
1319
- }))
1320
- .filter((item) => item.score > 0),
1321
- [(item) => item.score, "desc"],
1322
- [(item) => item.id, "asc"],
1323
- )
1324
- .slice(0, 3)
1325
- .map((item) => item.id)
1326
- }
1327
-
1328
- const layer = Layer.effect(
1329
- Service,
1330
- Effect.gen(function* () {
1331
- const fs = yield* FSUtil.Service
1332
- const config = yield* Config.Service
1333
- const auth = yield* Auth.Service
1334
- const env = yield* Env.Service
1335
- const plugin = yield* Plugin.Service
1336
- const modelsDevSvc = yield* ModelsDev.Service
1337
- const runtimeFlags = yield* RuntimeFlags.Service
1338
-
1339
- const state = yield* InstanceState.make<State>(() =>
1340
- Effect.gen(function* () {
1341
- const bridge = yield* EffectBridge.make()
1342
- const cfg = yield* config.get()
1343
- const modelsDev = yield* modelsDevSvc.get()
1344
- const catalog = mapValues(modelsDev, fromModelsDevProvider)
1345
- const database = mapValues(catalog, toPublicInfo)
1346
-
1347
- const providers: Record<ProviderV2.ID, Info> = {} as Record<ProviderV2.ID, Info>
1348
- const languages = new Map<string, LanguageModelV3>()
1349
- const modelLoaders: {
1350
- [providerID: string]: CustomModelLoader
1351
- } = {}
1352
- const varsLoaders: {
1353
- [providerID: string]: CustomVarsLoader
1354
- } = {}
1355
- const sdk = new Map<string, BundledSDK>()
1356
- const discoveryLoaders: {
1357
- [providerID: string]: CustomDiscoverModels
1358
- } = {}
1359
- const dep = {
1360
- auth: (id: string) => auth.get(id).pipe(Effect.orDie),
1361
- config: () => config.get(),
1362
- env: () => env.all(),
1363
- get: (key: string) => env.get(key),
1364
- }
1365
-
1366
- function mergeProvider(providerID: ProviderV2.ID, provider: Partial<Info>) {
1367
- const existing = providers[providerID]
1368
- if (existing) {
1369
- // @ts-expect-error
1370
- providers[providerID] = mergeDeep(existing, provider)
1371
- return
1372
- }
1373
- const match = database[providerID]
1374
- if (!match) return
1375
- // @ts-expect-error
1376
- providers[providerID] = mergeDeep(match, provider)
1377
- }
1378
-
1379
- // load plugins first so config() hook runs before reading cfg.provider
1380
- const plugins = yield* plugin.list()
1381
-
1382
- // now read config providers - includes any modifications from plugin config() hook
1383
- const configProviders = Object.entries(cfg.provider ?? {})
1384
- const disabled = new Set(cfg.disabled_providers ?? [])
1385
- const enabled = cfg.enabled_providers ? new Set(cfg.enabled_providers) : null
1386
-
1387
- function isProviderAllowed(providerID: ProviderV2.ID): boolean {
1388
- if (enabled && !enabled.has(providerID)) return false
1389
- if (disabled.has(providerID)) return false
1390
- return true
1391
- }
1392
-
1393
- for (const hook of plugins) {
1394
- const p = hook.provider
1395
- const models = p?.models
1396
- if (!p || !models) continue
1397
-
1398
- const providerID = ProviderV2.ID.make(p.id)
1399
- if (disabled.has(providerID)) continue
1400
-
1401
- const provider = database[providerID]
1402
- if (!provider) continue
1403
- const pluginAuth = yield* auth.get(providerID).pipe(Effect.orDie)
1404
-
1405
- provider.models = yield* Effect.promise(async () => {
1406
- const next = await models(toPublicInfo(provider), { auth: pluginAuth })
1407
- return Object.fromEntries(
1408
- Object.entries(next).map(([id, model]) => [
1409
- id,
1410
- {
1411
- ...model,
1412
- id: ModelV2.ID.make(id),
1413
- providerID,
1414
- },
1415
- ]),
1416
- )
1417
- })
1418
- }
1419
-
1420
- // extend database from config
1421
- for (const [providerID, provider] of configProviders) {
1422
- const existing = database[providerID]
1423
- const parsed: Info = {
1424
- id: ProviderV2.ID.make(providerID),
1425
- name: provider.name ?? existing?.name ?? providerID,
1426
- env: provider.env ?? existing?.env ?? [],
1427
- options: mergeDeep(existing?.options ?? {}, provider.options ?? {}),
1428
- source: "config",
1429
- models: existing?.models ?? {},
1430
- }
1431
-
1432
- for (const [modelID, model] of Object.entries(provider.models ?? {})) {
1433
- const existingModel = parsed.models[model.id ?? modelID]
1434
- const apiID = model.id ?? existingModel?.api.id ?? modelID
1435
- const apiNpm =
1436
- model.provider?.npm ??
1437
- provider.npm ??
1438
- existingModel?.api.npm ??
1439
- modelsDev[providerID]?.npm ??
1440
- "@ai-sdk/openai-compatible"
1441
- const name = iife(() => {
1442
- if (model.name) return model.name
1443
- if (model.id && model.id !== modelID) return modelID
1444
- return existingModel?.name ?? modelID
1445
- })
1446
- const parsedModel: Model = {
1447
- id: ModelV2.ID.make(modelID),
1448
- api: {
1449
- id: apiID,
1450
- npm: apiNpm,
1451
- url: model.provider?.api ?? provider?.api ?? existingModel?.api.url ?? modelsDev[providerID]?.api ?? "",
1452
- },
1453
- status: model.status ?? existingModel?.status ?? "active",
1454
- name,
1455
- providerID: ProviderV2.ID.make(providerID),
1456
- capabilities: {
1457
- temperature: model.temperature ?? existingModel?.capabilities.temperature ?? false,
1458
- reasoning: model.reasoning ?? existingModel?.capabilities.reasoning ?? false,
1459
- attachment: model.attachment ?? existingModel?.capabilities.attachment ?? false,
1460
- toolcall: model.tool_call ?? existingModel?.capabilities.toolcall ?? true,
1461
- input: {
1462
- text: model.modalities?.input?.includes("text") ?? existingModel?.capabilities.input.text ?? true,
1463
- audio: model.modalities?.input?.includes("audio") ?? existingModel?.capabilities.input.audio ?? false,
1464
- image: model.modalities?.input?.includes("image") ?? existingModel?.capabilities.input.image ?? false,
1465
- video: model.modalities?.input?.includes("video") ?? existingModel?.capabilities.input.video ?? false,
1466
- pdf: model.modalities?.input?.includes("pdf") ?? existingModel?.capabilities.input.pdf ?? false,
1467
- },
1468
- output: {
1469
- text: model.modalities?.output?.includes("text") ?? existingModel?.capabilities.output.text ?? true,
1470
- audio:
1471
- model.modalities?.output?.includes("audio") ?? existingModel?.capabilities.output.audio ?? false,
1472
- image:
1473
- model.modalities?.output?.includes("image") ?? existingModel?.capabilities.output.image ?? false,
1474
- video:
1475
- model.modalities?.output?.includes("video") ?? existingModel?.capabilities.output.video ?? false,
1476
- pdf: model.modalities?.output?.includes("pdf") ?? existingModel?.capabilities.output.pdf ?? false,
1477
- },
1478
- interleaved:
1479
- model.interleaved ??
1480
- existingModel?.capabilities.interleaved ??
1481
- (!existingModel && apiNpm === "@ai-sdk/openai-compatible" && apiID.includes("deepseek")
1482
- ? { field: "reasoning_content" }
1483
- : false),
1484
- },
1485
- cost: {
1486
- input: model?.cost?.input ?? existingModel?.cost?.input ?? 0,
1487
- output: model?.cost?.output ?? existingModel?.cost?.output ?? 0,
1488
- cache: {
1489
- read: model?.cost?.cache_read ?? existingModel?.cost?.cache.read ?? 0,
1490
- write: model?.cost?.cache_write ?? existingModel?.cost?.cache.write ?? 0,
1491
- },
1492
- },
1493
- options: mergeDeep(existingModel?.options ?? {}, model.options ?? {}),
1494
- limit: {
1495
- context: model.limit?.context ?? existingModel?.limit?.context ?? 0,
1496
- input: model.limit?.input ?? existingModel?.limit?.input,
1497
- output: model.limit?.output ?? existingModel?.limit?.output ?? 0,
1498
- },
1499
- headers: mergeDeep(existingModel?.headers ?? {}, model.headers ?? {}),
1500
- family: model.family ?? existingModel?.family ?? "",
1501
- release_date: model.release_date ?? existingModel?.release_date ?? "",
1502
- variants: {},
1503
- }
1504
- const variants =
1505
- existingModel?.api.npm === parsedModel.api.npm
1506
- ? (existingModel.variants ?? ProviderTransform.variants(parsedModel))
1507
- : ProviderTransform.variants(parsedModel)
1508
- const merged = mergeDeep(variants, model.variants ?? {})
1509
- parsedModel.variants = mapValues(
1510
- pickBy(merged, (v) => !v.disabled),
1511
- (v) => omit(v, ["disabled"]),
1512
- )
1513
- parsed.models[modelID] = parsedModel
1514
- }
1515
- database[providerID] = parsed
1516
- }
1517
-
1518
- // load env
1519
- const envs = yield* env.all()
1520
- for (const [id, provider] of Object.entries(database)) {
1521
- const providerID = ProviderV2.ID.make(id)
1522
- if (disabled.has(providerID)) continue
1523
- const apiKey = provider.env.map((item) => envs[item]).find(Boolean)
1524
- if (!apiKey) continue
1525
- mergeProvider(providerID, {
1526
- source: "env",
1527
- key: provider.env.length === 1 ? apiKey : undefined,
1528
- })
1529
- }
1530
-
1531
- // load apikeys
1532
- const auths = yield* auth.all().pipe(Effect.orDie)
1533
- for (const [id, provider] of Object.entries(auths)) {
1534
- const providerID = ProviderV2.ID.make(id)
1535
- if (disabled.has(providerID)) continue
1536
- if (provider.type === "api") {
1537
- mergeProvider(providerID, {
1538
- source: "api",
1539
- key: provider.key,
1540
- })
1541
- }
1542
- }
1543
-
1544
- // plugin auth loader - database now has entries for config providers
1545
- for (const plugin of plugins) {
1546
- if (!plugin.auth) continue
1547
- const providerID = ProviderV2.ID.make(plugin.auth.provider)
1548
- if (disabled.has(providerID)) continue
1549
-
1550
- const stored = yield* auth.get(providerID).pipe(Effect.orDie)
1551
- if (!stored) continue
1552
- if (!plugin.auth.loader) continue
1553
-
1554
- const options = yield* Effect.promise(() =>
1555
- plugin.auth!.loader!(
1556
- () => bridge.promise(auth.get(providerID).pipe(Effect.orDie)) as any,
1557
- toPublicInfo(database[plugin.auth!.provider]),
1558
- ),
1559
- )
1560
- const opts = options ?? {}
1561
- const patch: Partial<Info> = providers[providerID] ? { options: opts } : { source: "custom", options: opts }
1562
- mergeProvider(providerID, patch)
1563
- }
1564
-
1565
- for (const [id, fn] of Object.entries(custom(dep))) {
1566
- const providerID = ProviderV2.ID.make(id)
1567
- if (disabled.has(providerID)) continue
1568
- const data = database[providerID]
1569
- if (!data) {
1570
- continue
1571
- }
1572
- const result = yield* fn(data)
1573
- if (result && (result.autoload || providers[providerID])) {
1574
- if (result.getModel) modelLoaders[providerID] = result.getModel
1575
- if (result.vars) varsLoaders[providerID] = result.vars
1576
- if (result.discoverModels) discoveryLoaders[providerID] = result.discoverModels
1577
- const opts = result.options ?? {}
1578
- const patch: Partial<Info> = providers[providerID] ? { options: opts } : { source: "custom", options: opts }
1579
- mergeProvider(providerID, patch)
1580
- }
1581
- }
1582
-
1583
- // load config - re-apply with updated data
1584
- for (const [id, provider] of configProviders) {
1585
- const providerID = ProviderV2.ID.make(id)
1586
- const partial: Partial<Info> = { source: "config" }
1587
- if (provider.env) partial.env = provider.env
1588
- if (provider.name) partial.name = provider.name
1589
- if (provider.options) partial.options = provider.options
1590
- mergeProvider(providerID, partial)
1591
- }
1592
-
1593
- const gitlab = ProviderV2.ID.make("gitlab")
1594
- if (discoveryLoaders[gitlab] && providers[gitlab] && isProviderAllowed(gitlab)) {
1595
- yield* Effect.promise(async () => {
1596
- try {
1597
- const discovered = await discoveryLoaders[gitlab]()
1598
- for (const [modelID, model] of Object.entries(discovered)) {
1599
- if (!providers[gitlab].models[modelID]) {
1600
- providers[gitlab].models[modelID] = model
1601
- }
1602
- }
1603
- } catch (e) {}
1604
- })
1605
- }
1606
-
1607
- for (const [id, provider] of Object.entries(providers)) {
1608
- const providerID = ProviderV2.ID.make(id)
1609
- if (!isProviderAllowed(providerID)) {
1610
- delete providers[providerID]
1611
- continue
1612
- }
1613
-
1614
- const configProvider = cfg.provider?.[providerID]
1615
-
1616
- for (const [modelID, model] of Object.entries(provider.models)) {
1617
- model.api.id = model.api.id ?? model.id ?? modelID
1618
- if (
1619
- // These chat aliases are invalid for the special handling in the
1620
- // built-in providers below, but custom providers may support them.
1621
- (modelID === "gpt-5-chat-latest" &&
1622
- (providerID === ProviderV2.ID.openai ||
1623
- providerID === ProviderV2.ID.githubCopilot ||
1624
- providerID === ProviderV2.ID.openrouter)) ||
1625
- (providerID === ProviderV2.ID.openrouter && modelID === "openai/gpt-5-chat")
1626
- )
1627
- delete provider.models[modelID]
1628
- if (model.status === "alpha" && !runtimeFlags.enableExperimentalModels) delete provider.models[modelID]
1629
- if (model.status === "deprecated") delete provider.models[modelID]
1630
- if (
1631
- (configProvider?.blacklist && configProvider.blacklist.includes(modelID)) ||
1632
- (configProvider?.whitelist && !configProvider.whitelist.includes(modelID))
1633
- )
1634
- delete provider.models[modelID]
1635
-
1636
- if (model.variants === undefined) {
1637
- model.variants = mapValues(ProviderTransform.variants(model), (v) => v)
1638
- }
1639
-
1640
- const configVariants = configProvider?.models?.[modelID]?.variants
1641
- if (configVariants && model.variants) {
1642
- const merged = mergeDeep(model.variants, configVariants)
1643
- model.variants = mapValues(
1644
- pickBy(merged, (v) => !v.disabled),
1645
- (v) => omit(v, ["disabled"]),
1646
- )
1647
- }
1648
- }
1649
-
1650
- if (Object.keys(provider.models).length === 0) {
1651
- delete providers[providerID]
1652
- continue
1653
- }
1654
- }
1655
-
1656
- return {
1657
- models: languages,
1658
- providers,
1659
- catalog,
1660
- sdk,
1661
- modelLoaders,
1662
- varsLoaders,
1663
- }
1664
- }),
1665
- )
1666
-
1667
- const list = Effect.fn("Provider.list")(() => InstanceState.use(state, (s) => s.providers))
1668
-
1669
- async function resolveSDK(model: Model, s: State, envs: Record<string, string | undefined>) {
1670
- try {
1671
- const provider = s.providers[model.providerID]
1672
- const options = { ...provider.options }
1673
-
1674
- if (
1675
- model.providerID === "google-vertex" &&
1676
- model.api.npm === "@ai-sdk/google-vertex/anthropic" &&
1677
- !options.baseURL
1678
- ) {
1679
- const baseURL = googleVertexAnthropicBaseURL(
1680
- typeof options.project === "string" ? options.project : undefined,
1681
- typeof options.location === "string" ? options.location : undefined,
1682
- )
1683
- if (baseURL) options.baseURL = baseURL
1684
- }
1685
-
1686
- if (model.providerID === "google-vertex" && !model.api.npm.includes("@ai-sdk/openai-compatible")) {
1687
- delete options.fetch
1688
- }
1689
-
1690
- if (model.api.npm.includes("@ai-sdk/openai-compatible") && options["includeUsage"] !== false) {
1691
- options["includeUsage"] = true
1692
- }
1693
-
1694
- const baseURL = iife(() => {
1695
- let url =
1696
- typeof options["baseURL"] === "string" && options["baseURL"] !== "" ? options["baseURL"] : model.api.url
1697
- if (!url) return
1698
-
1699
- const loader = s.varsLoaders[model.providerID]
1700
- if (loader) {
1701
- const vars = loader(options)
1702
- for (const [key, value] of Object.entries(vars)) {
1703
- const field = "${" + key + "}"
1704
- url = url.replaceAll(field, value)
1705
- }
1706
- }
1707
-
1708
- url = url.replace(/\$\{([^}]+)\}/g, (item, key) => {
1709
- const val = envs[String(key)]
1710
- return val ?? item
1711
- })
1712
- return url
1713
- })
1714
-
1715
- if (baseURL !== undefined) options["baseURL"] = baseURL
1716
- if (options["apiKey"] === undefined && provider.key) options["apiKey"] = provider.key
1717
- if (model.headers)
1718
- options["headers"] = {
1719
- ...options["headers"],
1720
- ...model.headers,
1721
- }
1722
-
1723
- const key = Hash.fast(
1724
- JSON.stringify({
1725
- providerID: model.providerID,
1726
- npm: model.api.npm,
1727
- options,
1728
- }),
1729
- )
1730
- const existing = s.sdk.get(key)
1731
- if (existing) return existing
1732
-
1733
- const customFetch = options["fetch"]
1734
- const chunkTimeout = options["chunkTimeout"]
1735
- const headerTimeout = options["headerTimeout"]
1736
- delete options["chunkTimeout"]
1737
- delete options["headerTimeout"]
1738
-
1739
- options["fetch"] = async (input: any, init?: BunFetchRequestInit) => {
1740
- const fetchFn = customFetch ?? fetch
1741
- const opts = init ?? {}
1742
- const chunkAbortCtl = typeof chunkTimeout === "number" && chunkTimeout > 0 ? new AbortController() : undefined
1743
- const headerTimeoutMs = headerTimeout === false ? undefined : headerTimeout
1744
- const headerTimeoutCtl = typeof headerTimeoutMs === "number" ? timeoutController(headerTimeoutMs) : undefined
1745
- const signals: AbortSignal[] = []
1746
-
1747
- if (opts.signal) signals.push(opts.signal)
1748
- if (chunkAbortCtl) signals.push(chunkAbortCtl.signal)
1749
- if (headerTimeoutCtl) signals.push(headerTimeoutCtl.signal)
1750
- if (options["timeout"] !== undefined && options["timeout"] !== null && options["timeout"] !== false)
1751
- signals.push(AbortSignal.timeout(options["timeout"]))
1752
-
1753
- const combined = signals.length === 0 ? null : signals.length === 1 ? signals[0] : AbortSignal.any(signals)
1754
- if (combined) opts.signal = combined
1755
-
1756
- const res = await fetchFn(input, {
1757
- ...opts,
1758
- // @ts-ignore see here: https://github.com/oven-sh/bun/issues/16682
1759
- timeout: false,
1760
- }).finally(() => headerTimeoutCtl?.clear())
1761
-
1762
- if (!chunkAbortCtl) return res
1763
- return wrapSSE(res, chunkTimeout, chunkAbortCtl)
1764
- }
1765
-
1766
- const bundledLoader = BUNDLED_PROVIDERS[model.api.npm]
1767
- if (bundledLoader) {
1768
- const factory = await bundledLoader()
1769
- const loaded = factory({
1770
- name: model.providerID,
1771
- ...options,
1772
- })
1773
- s.sdk.set(key, loaded)
1774
- return loaded as SDK
1775
- }
1776
-
1777
- const installedPath = await (async () => {
1778
- if (model.api.npm.startsWith("file://")) {
1779
- return model.api.npm
1780
- }
1781
- const item = await Npm.add(model.api.npm)
1782
- if (!item.entrypoint) throw new Error(`Package ${model.api.npm} has no import entrypoint`)
1783
- return item.entrypoint
1784
- })()
1785
-
1786
- // `installedPath` is a local entry path or an existing `file://` URL. Normalize
1787
- // only path inputs so Node on Windows accepts the dynamic import.
1788
- const importSpec = installedPath.startsWith("file://") ? installedPath : pathToFileURL(installedPath).href
1789
- const mod = await import(importSpec)
1790
-
1791
- const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
1792
- const loaded = fn({
1793
- name: model.providerID,
1794
- ...options,
1795
- })
1796
- s.sdk.set(key, loaded)
1797
- return loaded as SDK
1798
- } catch (e) {
1799
- throw new InitError({ providerID: model.providerID, cause: e })
1800
- }
1801
- }
1802
-
1803
- const getProvider = Effect.fn("Provider.getProvider")((providerID: ProviderV2.ID) =>
1804
- InstanceState.use(state, (s) => s.providers[providerID]),
1805
- )
1806
-
1807
- const getModel = Effect.fn("Provider.getModel")(function* (providerID: ProviderV2.ID, modelID: ModelV2.ID) {
1808
- const s = yield* InstanceState.get(state)
1809
- const provider = s.providers[providerID]
1810
- if (!provider) {
1811
- const catalogProvider = s.catalog[providerID]
1812
- const suggestions = catalogProvider
1813
- ? modelSuggestions(catalogProvider, modelID, runtimeFlags.enableExperimentalModels)
1814
- : fuzzysort
1815
- .go(providerID, Object.keys({ ...s.catalog, ...s.providers }), { limit: 3, threshold: -10000 })
1816
- .map((m) => m.target)
1817
- return yield* new ModelNotFoundError({ providerID, modelID, suggestions })
1818
- }
1819
-
1820
- const info = provider.models[modelID]
1821
- if (!info) {
1822
- const current = modelSuggestions(provider, modelID, runtimeFlags.enableExperimentalModels)
1823
- const suggestions = current.length
1824
- ? current
1825
- : modelSuggestions(s.catalog[providerID], modelID, runtimeFlags.enableExperimentalModels)
1826
- return yield* new ModelNotFoundError({ providerID, modelID, suggestions })
1827
- }
1828
- return info
1829
- })
1830
-
1831
- const getLanguage = Effect.fn("Provider.getLanguage")(function* (model: Model) {
1832
- const s = yield* InstanceState.get(state)
1833
- const envs = yield* env.all()
1834
- const key = `${model.providerID}/${model.id}`
1835
- if (s.models.has(key)) return s.models.get(key)!
1836
-
1837
- const provider = s.providers[model.providerID]
1838
- return yield* EffectPromise.refineRejection(
1839
- async () => {
1840
- const sdk = await resolveSDK(model, s, envs)
1841
- const language = s.modelLoaders[model.providerID]
1842
- ? await s.modelLoaders[model.providerID](
1843
- sdk,
1844
- model.api.id,
1845
- {
1846
- ...provider.options,
1847
- ...model.options,
1848
- },
1849
- model,
1850
- )
1851
- : sdk.languageModel(model.api.id)
1852
- s.models.set(key, language)
1853
- return language
1854
- },
1855
- (cause) =>
1856
- cause instanceof NoSuchModelError
1857
- ? new ModelNotFoundError({ modelID: model.id, providerID: model.providerID, cause })
1858
- : undefined,
1859
- )
1860
- })
1861
-
1862
- const closest = Effect.fn("Provider.closest")(function* (providerID: ProviderV2.ID, query: string[]) {
1863
- const s = yield* InstanceState.get(state)
1864
- const provider = s.providers[providerID]
1865
- if (!provider) return undefined
1866
- for (const item of query) {
1867
- for (const modelID of Object.keys(provider.models)) {
1868
- if (modelID.includes(item)) return { providerID, modelID }
1869
- }
1870
- }
1871
- return undefined
1872
- })
1873
-
1874
- const getSmallModel = Effect.fn("Provider.getSmallModel")(function* (providerID: ProviderV2.ID) {
1875
- const cfg = yield* config.get()
1876
-
1877
- if (cfg.small_model) {
1878
- const parsed = parseModel(cfg.small_model)
1879
- return yield* getModel(parsed.providerID, parsed.modelID).pipe(
1880
- Effect.catchTag("ProviderModelNotFoundError", () => Effect.succeed(undefined)),
1881
- )
1882
- }
1883
-
1884
- const s = yield* InstanceState.get(state)
1885
- const provider = s.providers[providerID]
1886
- if (!provider) return undefined
1887
-
1888
- const experimental = yield* plugin.trigger<"experimental.provider.small_model">(
1889
- "experimental.provider.small_model",
1890
- { provider: toPublicInfo(provider) },
1891
- { model: undefined },
1892
- )
1893
- if (experimental.model) {
1894
- return {
1895
- ...experimental.model,
1896
- id: ModelV2.ID.make(experimental.model.id),
1897
- providerID: ProviderV2.ID.make(experimental.model.providerID),
1898
- }
1899
- }
1900
-
1901
- // TODO: Remove these provider-specific assumptions once model syncing reliably reports available deployments.
1902
- if (providerID === ProviderV2.ID.azure || providerID === ProviderV2.ID.make("azure-cognitive-services")) {
1903
- return undefined
1904
- }
1905
-
1906
- const priority = providerID.startsWith("anymous")
1907
- ? ["gpt-nano"]
1908
- : providerID.startsWith("github-copilot")
1909
- ? ["gpt-mini", ...smallModelFamilyPriority]
1910
- : smallModelFamilyPriority
1911
- const models = sortBy(
1912
- Object.values(provider.models),
1913
- [(model) => model.release_date, "desc"],
1914
- [(model) => model.id, "desc"],
1915
- )
1916
- for (const family of priority) {
1917
- const candidates = models.filter((model) => model.family === family)
1918
- if (providerID === ProviderV2.ID.amazonBedrock) {
1919
- const crossRegionPrefixes = ["global.", "us.", "eu."]
1920
-
1921
- const globalMatch = candidates.find((model) => model.id.startsWith("global."))
1922
- if (globalMatch) return globalMatch
1923
-
1924
- const region = provider.options?.region
1925
- if (region) {
1926
- const regionPrefix = region.split("-")[0]
1927
- if (regionPrefix === "us" || regionPrefix === "eu") {
1928
- const regionalMatch = candidates.find((model) => model.id.startsWith(`${regionPrefix}.`))
1929
- if (regionalMatch) return regionalMatch
1930
- }
1931
- }
1932
-
1933
- const unprefixed = candidates.find((model) => !crossRegionPrefixes.some((p) => model.id.startsWith(p)))
1934
- if (unprefixed) return unprefixed
1935
- continue
1936
- }
1937
- if (candidates[0]) return candidates[0]
1938
- }
1939
-
1940
- return undefined
1941
- })
1942
-
1943
- const defaultModel = Effect.fn("Provider.defaultModel")(function* () {
1944
- const cfg = yield* config.get()
1945
- if (cfg.model) return parseModel(cfg.model)
1946
-
1947
- const s = yield* InstanceState.get(state)
1948
- const recent = yield* fs.readJson(path.join(Global.Path.state, "model.json")).pipe(
1949
- Effect.map((x): { providerID: ProviderV2.ID; modelID: ModelV2.ID }[] => {
1950
- if (!isRecord(x) || !Array.isArray(x.recent)) return []
1951
- return x.recent.flatMap((item) => {
1952
- if (!isRecord(item)) return []
1953
- if (typeof item.providerID !== "string") return []
1954
- if (typeof item.modelID !== "string") return []
1955
- return [{ providerID: ProviderV2.ID.make(item.providerID), modelID: ModelV2.ID.make(item.modelID) }]
1956
- })
1957
- }),
1958
- Effect.catch(() => Effect.succeed([] as { providerID: ProviderV2.ID; modelID: ModelV2.ID }[])),
1959
- )
1960
- for (const entry of recent) {
1961
- const provider = s.providers[entry.providerID]
1962
- if (!provider) continue
1963
- if (!provider.models[entry.modelID]) continue
1964
- return { providerID: entry.providerID, modelID: entry.modelID }
1965
- }
1966
-
1967
- const configured = Object.keys(cfg.provider ?? {})
1968
- const provider = Object.values(s.providers).find((p) => configured.length === 0 || configured.includes(p.id))
1969
- if (!provider) return yield* new NoProvidersError()
1970
- const [model] = sort(Object.values(provider.models))
1971
- if (!model) return yield* new NoModelsError({ providerID: provider.id })
1972
- return {
1973
- providerID: provider.id,
1974
- modelID: model.id,
1975
- }
1976
- })
1977
-
1978
- return Service.of({ list, getProvider, getModel, getLanguage, closest, getSmallModel, defaultModel })
1979
- }),
1980
- )
1981
-
1982
- const priority = ["deepseek-free", "deepseek", "gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"]
1983
- const smallModelFamilyPriority = ["gemini-flash", "gpt-nano", "claude-haiku"]
1984
- export function sort<T extends { id: string }>(models: T[]) {
1985
- return sortBy(
1986
- models,
1987
- [(model) => priority.findIndex((filter) => model.id.includes(filter)), "desc"],
1988
- [(model) => (model.id.includes("latest") ? 0 : 1), "asc"],
1989
- [(model) => model.id, "desc"],
1990
- )
1991
- }
1992
-
1993
- export function parseModel(model: string) {
1994
- const [providerID, ...rest] = model.split("/")
1995
- return {
1996
- providerID: ProviderV2.ID.make(providerID),
1997
- modelID: ModelV2.ID.make(rest.join("/")),
1998
- }
1999
- }
2000
-
2001
- export const node = LayerNode.make({
2002
- service: Service,
2003
- layer: layer,
2004
- deps: [FSUtil.node, Config.node, Auth.node, Env.node, Plugin.node, ModelsDev.node, RuntimeFlags.node],
2005
- })
2006
-
2007
- export * as Provider from "./provider"