@travisennis/acai 0.0.1 → 0.0.3

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 (324) hide show
  1. package/README.md +3 -4
  2. package/dist/commands/health-command.d.ts +2 -0
  3. package/dist/commands/health-command.js +59 -0
  4. package/dist/commands/manager.js +2 -0
  5. package/dist/commands/paste-command.d.ts +1 -1
  6. package/dist/commands/paste-command.js +155 -11
  7. package/dist/commands/reset-command.js +1 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +2 -1
  10. package/dist/models/openrouter-provider.d.ts +4 -1
  11. package/dist/models/openrouter-provider.js +46 -4
  12. package/dist/models/providers.d.ts +1 -1
  13. package/dist/prompts/manager.d.ts +1 -0
  14. package/dist/prompts/manager.js +10 -0
  15. package/dist/prompts.js +8 -6
  16. package/dist/repl.js +49 -26
  17. package/dist/terminal/formatting.d.ts +16 -5
  18. package/dist/terminal/formatting.js +40 -6
  19. package/dist/terminal/index.d.ts +1 -1
  20. package/dist/terminal/index.js +54 -14
  21. package/dist/terminal/markdown.js +0 -1
  22. package/dist/terminal/supports-color.d.ts +16 -0
  23. package/dist/terminal/supports-color.js +121 -0
  24. package/dist/terminal/supports-hyperlinks.d.ts +7 -0
  25. package/dist/terminal/supports-hyperlinks.js +98 -0
  26. package/dist/tools/bash.js +95 -117
  27. package/dist/tools/code-interpreter.js +11 -1
  28. package/dist/tools/command-validation.d.ts +7 -3
  29. package/dist/tools/command-validation.js +67 -23
  30. package/dist/tools/delete-file.d.ts +4 -1
  31. package/dist/tools/delete-file.js +47 -3
  32. package/dist/tools/git-utils.d.ts +6 -0
  33. package/dist/tools/git-utils.js +89 -12
  34. package/dist/tools/grep.d.ts +20 -0
  35. package/dist/tools/grep.js +128 -40
  36. package/dist/tools/index.d.ts +2 -18
  37. package/dist/tools/index.js +4 -18
  38. package/package.json +30 -20
  39. package/.acai/acai.json +0 -9
  40. package/.acai/prompts/add-openrouter-model.md +0 -13
  41. package/.acai/prompts/project-status.md +0 -4
  42. package/.acai/prompts/update-architecture-document.md +0 -9
  43. package/.acai/rules/learned-rules.md +0 -9
  44. package/.ai/docs/available-tools.txt +0 -3
  45. package/.ai/docs/cognitive_complexity_refactoring_progress.md +0 -65
  46. package/.ai/docs/deleted_tools.md +0 -168
  47. package/.ai/docs/deleted_tools_88ced9ef.md +0 -56
  48. package/.ai/docs/image-pasting.md +0 -46
  49. package/.ai/docs/initialize-app.md +0 -117
  50. package/.ai/docs/issue-4-plan.md +0 -44
  51. package/.ai/docs/marked-renderer-debug.md +0 -15
  52. package/.ai/docs/marked-renderer-refactor-plan.md +0 -64
  53. package/.ai/docs/memory-use-cases.md +0 -55
  54. package/.ai/docs/prompt-consistency.md +0 -31
  55. package/.ai/docs/refactoring-tools.md +0 -98
  56. package/.ai/docs/system-prompt-update.md +0 -174
  57. package/.ai/docs/system_prompt.txt +0 -210
  58. package/.ai/docs/tasks.md +0 -49
  59. package/.ai/plan.md +0 -131
  60. package/.ai/prompt.md +0 -1
  61. package/.ai/scripts/fetch_models.js +0 -27
  62. package/.ai/scripts/generateSystemPrompt.ts +0 -15
  63. package/.ai/scripts/list-tools.mjs +0 -4
  64. package/.ai/scripts/p5_geometric_shapes.js +0 -149
  65. package/.husky/commit-msg +0 -1
  66. package/.husky/pre-commit +0 -3
  67. package/.husky/pre-push +0 -1
  68. package/.ignore +0 -4
  69. package/AGENTS.md +0 -25
  70. package/ARCHITECTURE.md +0 -304
  71. package/TODO.md +0 -2
  72. package/biome.json +0 -61
  73. package/commitlint.config.js +0 -3
  74. package/dist/source/cli.d.ts +0 -19
  75. package/dist/source/cli.js +0 -116
  76. package/dist/source/commands/application-log-command.d.ts +0 -2
  77. package/dist/source/commands/application-log-command.js +0 -43
  78. package/dist/source/commands/clear-command.d.ts +0 -2
  79. package/dist/source/commands/clear-command.js +0 -12
  80. package/dist/source/commands/compact-command.d.ts +0 -2
  81. package/dist/source/commands/compact-command.js +0 -51
  82. package/dist/source/commands/copy-command.d.ts +0 -2
  83. package/dist/source/commands/copy-command.js +0 -51
  84. package/dist/source/commands/edit-command.d.ts +0 -2
  85. package/dist/source/commands/edit-command.js +0 -53
  86. package/dist/source/commands/edit-prompt-command.d.ts +0 -2
  87. package/dist/source/commands/edit-prompt-command.js +0 -25
  88. package/dist/source/commands/exit-command.d.ts +0 -2
  89. package/dist/source/commands/exit-command.js +0 -14
  90. package/dist/source/commands/files-command.d.ts +0 -2
  91. package/dist/source/commands/files-command.js +0 -63
  92. package/dist/source/commands/generate-rules-command.d.ts +0 -2
  93. package/dist/source/commands/generate-rules-command.js +0 -61
  94. package/dist/source/commands/help-command.d.ts +0 -2
  95. package/dist/source/commands/help-command.js +0 -19
  96. package/dist/source/commands/init-command.d.ts +0 -2
  97. package/dist/source/commands/init-command.js +0 -40
  98. package/dist/source/commands/last-log-command.d.ts +0 -2
  99. package/dist/source/commands/last-log-command.js +0 -76
  100. package/dist/source/commands/manager.d.ts +0 -22
  101. package/dist/source/commands/manager.js +0 -123
  102. package/dist/source/commands/model-command.d.ts +0 -2
  103. package/dist/source/commands/model-command.js +0 -84
  104. package/dist/source/commands/paste-command.d.ts +0 -2
  105. package/dist/source/commands/paste-command.js +0 -40
  106. package/dist/source/commands/prompt-command.d.ts +0 -2
  107. package/dist/source/commands/prompt-command.js +0 -111
  108. package/dist/source/commands/reset-command.d.ts +0 -2
  109. package/dist/source/commands/reset-command.js +0 -16
  110. package/dist/source/commands/rules-command.d.ts +0 -2
  111. package/dist/source/commands/rules-command.js +0 -68
  112. package/dist/source/commands/save-command.d.ts +0 -2
  113. package/dist/source/commands/save-command.js +0 -14
  114. package/dist/source/commands/types.d.ts +0 -26
  115. package/dist/source/commands/types.js +0 -1
  116. package/dist/source/commands/usage-command.d.ts +0 -2
  117. package/dist/source/commands/usage-command.js +0 -21
  118. package/dist/source/config.d.ts +0 -60
  119. package/dist/source/config.js +0 -193
  120. package/dist/source/conversation-analyzer.d.ts +0 -10
  121. package/dist/source/conversation-analyzer.js +0 -88
  122. package/dist/source/dedent.d.ts +0 -3
  123. package/dist/source/dedent.js +0 -38
  124. package/dist/source/formatting.d.ts +0 -17
  125. package/dist/source/formatting.js +0 -103
  126. package/dist/source/index.d.ts +0 -18
  127. package/dist/source/index.js +0 -213
  128. package/dist/source/logger.d.ts +0 -2
  129. package/dist/source/logger.js +0 -24
  130. package/dist/source/mentions.d.ts +0 -9
  131. package/dist/source/mentions.js +0 -182
  132. package/dist/source/messages.d.ts +0 -69
  133. package/dist/source/messages.js +0 -261
  134. package/dist/source/middleware/audit-message.d.ts +0 -5
  135. package/dist/source/middleware/audit-message.js +0 -95
  136. package/dist/source/middleware/index.d.ts +0 -2
  137. package/dist/source/middleware/index.js +0 -2
  138. package/dist/source/middleware/rate-limit.d.ts +0 -4
  139. package/dist/source/middleware/rate-limit.js +0 -17
  140. package/dist/source/models/ai-config.d.ts +0 -12
  141. package/dist/source/models/ai-config.js +0 -87
  142. package/dist/source/models/anthropic-provider.d.ts +0 -25
  143. package/dist/source/models/anthropic-provider.js +0 -184
  144. package/dist/source/models/deepseek-provider.d.ts +0 -20
  145. package/dist/source/models/deepseek-provider.js +0 -42
  146. package/dist/source/models/google-provider.d.ts +0 -19
  147. package/dist/source/models/google-provider.js +0 -56
  148. package/dist/source/models/manager.d.ts +0 -15
  149. package/dist/source/models/manager.js +0 -48
  150. package/dist/source/models/openai-provider.d.ts +0 -22
  151. package/dist/source/models/openai-provider.js +0 -70
  152. package/dist/source/models/openrouter-provider.d.ts +0 -36
  153. package/dist/source/models/openrouter-provider.js +0 -276
  154. package/dist/source/models/providers.d.ts +0 -33
  155. package/dist/source/models/providers.js +0 -116
  156. package/dist/source/models/xai-provider.d.ts +0 -20
  157. package/dist/source/models/xai-provider.js +0 -47
  158. package/dist/source/parsing.d.ts +0 -2
  159. package/dist/source/parsing.js +0 -18
  160. package/dist/source/prompts/manager.d.ts +0 -19
  161. package/dist/source/prompts/manager.js +0 -71
  162. package/dist/source/prompts.d.ts +0 -4
  163. package/dist/source/prompts.js +0 -158
  164. package/dist/source/repl-prompt.d.ts +0 -14
  165. package/dist/source/repl-prompt.js +0 -147
  166. package/dist/source/repl.d.ts +0 -27
  167. package/dist/source/repl.js +0 -431
  168. package/dist/source/terminal/formatting.d.ts +0 -37
  169. package/dist/source/terminal/formatting.js +0 -106
  170. package/dist/source/terminal/index.d.ts +0 -94
  171. package/dist/source/terminal/index.js +0 -420
  172. package/dist/source/terminal/markdown-utils.d.ts +0 -2
  173. package/dist/source/terminal/markdown-utils.js +0 -81
  174. package/dist/source/terminal/markdown.d.ts +0 -1
  175. package/dist/source/terminal/markdown.js +0 -111
  176. package/dist/source/terminal/types.d.ts +0 -71
  177. package/dist/source/terminal/types.js +0 -1
  178. package/dist/source/terminal-output.d.ts +0 -8
  179. package/dist/source/terminal-output.js +0 -213
  180. package/dist/source/terminal-output.test.d.ts +0 -8
  181. package/dist/source/terminal-output.test.js +0 -213
  182. package/dist/source/token-tracker.d.ts +0 -14
  183. package/dist/source/token-tracker.js +0 -53
  184. package/dist/source/token-utils.d.ts +0 -7
  185. package/dist/source/token-utils.js +0 -13
  186. package/dist/source/tools/agent.d.ts +0 -17
  187. package/dist/source/tools/agent.js +0 -87
  188. package/dist/source/tools/bash.d.ts +0 -19
  189. package/dist/source/tools/bash.js +0 -294
  190. package/dist/source/tools/code-interpreter.d.ts +0 -12
  191. package/dist/source/tools/code-interpreter.js +0 -131
  192. package/dist/source/tools/command-validation.d.ts +0 -8
  193. package/dist/source/tools/command-validation.js +0 -69
  194. package/dist/source/tools/delete-file.d.ts +0 -12
  195. package/dist/source/tools/delete-file.js +0 -56
  196. package/dist/source/tools/directory-tree.d.ts +0 -12
  197. package/dist/source/tools/directory-tree.js +0 -38
  198. package/dist/source/tools/edit-file.d.ts +0 -19
  199. package/dist/source/tools/edit-file.js +0 -107
  200. package/dist/source/tools/filesystem-utils.d.ts +0 -22
  201. package/dist/source/tools/filesystem-utils.js +0 -191
  202. package/dist/source/tools/git-utils.d.ts +0 -14
  203. package/dist/source/tools/git-utils.js +0 -64
  204. package/dist/source/tools/grep.d.ts +0 -17
  205. package/dist/source/tools/grep.js +0 -138
  206. package/dist/source/tools/index.d.ts +0 -161
  207. package/dist/source/tools/index.js +0 -209
  208. package/dist/source/tools/memory-read.d.ts +0 -13
  209. package/dist/source/tools/memory-read.js +0 -135
  210. package/dist/source/tools/memory-write.d.ts +0 -12
  211. package/dist/source/tools/memory-write.js +0 -83
  212. package/dist/source/tools/move-file.d.ts +0 -13
  213. package/dist/source/tools/move-file.js +0 -44
  214. package/dist/source/tools/read-file.d.ts +0 -17
  215. package/dist/source/tools/read-file.js +0 -86
  216. package/dist/source/tools/read-multiple-files.d.ts +0 -14
  217. package/dist/source/tools/read-multiple-files.js +0 -55
  218. package/dist/source/tools/save-file.d.ts +0 -17
  219. package/dist/source/tools/save-file.js +0 -98
  220. package/dist/source/tools/think.d.ts +0 -11
  221. package/dist/source/tools/think.js +0 -45
  222. package/dist/source/tools/types.d.ts +0 -29
  223. package/dist/source/tools/types.js +0 -14
  224. package/dist/source/tools/web-fetch.d.ts +0 -47
  225. package/dist/source/tools/web-fetch.js +0 -246
  226. package/dist/source/tools/web-search.d.ts +0 -13
  227. package/dist/source/tools/web-search.js +0 -80
  228. package/dist/source/utils/process.d.ts +0 -36
  229. package/dist/source/utils/process.js +0 -75
  230. package/dist/source/version.d.ts +0 -1
  231. package/dist/source/version.js +0 -21
  232. package/dist/terminal-output.d.ts +0 -8
  233. package/dist/terminal-output.js +0 -213
  234. package/dist/tools/memory-read.d.ts +0 -13
  235. package/dist/tools/memory-read.js +0 -135
  236. package/dist/tools/memory-write.d.ts +0 -12
  237. package/dist/tools/memory-write.js +0 -83
  238. package/knip.json +0 -5
  239. package/source/cli.ts +0 -172
  240. package/source/commands/application-log-command.ts +0 -53
  241. package/source/commands/clear-command.ts +0 -14
  242. package/source/commands/compact-command.ts +0 -64
  243. package/source/commands/copy-command.ts +0 -55
  244. package/source/commands/edit-command.ts +0 -63
  245. package/source/commands/edit-prompt-command.ts +0 -31
  246. package/source/commands/exit-command.ts +0 -18
  247. package/source/commands/files-command.ts +0 -85
  248. package/source/commands/generate-rules-command.ts +0 -82
  249. package/source/commands/help-command.ts +0 -27
  250. package/source/commands/init-command.ts +0 -48
  251. package/source/commands/last-log-command.ts +0 -88
  252. package/source/commands/manager.ts +0 -151
  253. package/source/commands/model-command.ts +0 -123
  254. package/source/commands/paste-command.ts +0 -62
  255. package/source/commands/prompt-command.ts +0 -150
  256. package/source/commands/reset-command.ts +0 -22
  257. package/source/commands/rules-command.ts +0 -76
  258. package/source/commands/save-command.ts +0 -20
  259. package/source/commands/types.ts +0 -28
  260. package/source/commands/usage-command.ts +0 -26
  261. package/source/config.ts +0 -223
  262. package/source/conversation-analyzer.ts +0 -115
  263. package/source/dedent.ts +0 -53
  264. package/source/formatting.ts +0 -132
  265. package/source/index.ts +0 -240
  266. package/source/logger.ts +0 -29
  267. package/source/mentions.ts +0 -227
  268. package/source/messages.ts +0 -360
  269. package/source/middleware/audit-message.ts +0 -133
  270. package/source/middleware/index.ts +0 -2
  271. package/source/middleware/rate-limit.ts +0 -24
  272. package/source/models/ai-config.ts +0 -109
  273. package/source/models/anthropic-provider.ts +0 -199
  274. package/source/models/deepseek-provider.ts +0 -53
  275. package/source/models/google-provider.ts +0 -68
  276. package/source/models/manager.ts +0 -84
  277. package/source/models/openai-provider.ts +0 -81
  278. package/source/models/openrouter-provider.ts +0 -288
  279. package/source/models/providers.ts +0 -197
  280. package/source/models/xai-provider.ts +0 -59
  281. package/source/parsing.ts +0 -20
  282. package/source/prompts/manager.ts +0 -90
  283. package/source/prompts.ts +0 -172
  284. package/source/repl-prompt.ts +0 -196
  285. package/source/repl.ts +0 -572
  286. package/source/terminal/formatting.ts +0 -121
  287. package/source/terminal/index.ts +0 -518
  288. package/source/terminal/markdown-utils.ts +0 -89
  289. package/source/terminal/markdown.ts +0 -155
  290. package/source/terminal/types.ts +0 -84
  291. package/source/terminal-output.test.ts +0 -266
  292. package/source/token-tracker.ts +0 -78
  293. package/source/token-utils.ts +0 -17
  294. package/source/tools/agent.ts +0 -107
  295. package/source/tools/bash.ts +0 -367
  296. package/source/tools/code-interpreter.ts +0 -172
  297. package/source/tools/command-validation.ts +0 -81
  298. package/source/tools/delete-file.ts +0 -71
  299. package/source/tools/directory-tree.ts +0 -54
  300. package/source/tools/edit-file.ts +0 -155
  301. package/source/tools/filesystem-utils.ts +0 -265
  302. package/source/tools/git-utils.ts +0 -70
  303. package/source/tools/grep.ts +0 -184
  304. package/source/tools/index.ts +0 -278
  305. package/source/tools/memory-read.ts +0 -174
  306. package/source/tools/memory-write.ts +0 -105
  307. package/source/tools/move-file.ts +0 -59
  308. package/source/tools/read-file.ts +0 -129
  309. package/source/tools/read-multiple-files.ts +0 -80
  310. package/source/tools/save-file.ts +0 -147
  311. package/source/tools/think.ts +0 -51
  312. package/source/tools/types.ts +0 -58
  313. package/source/tools/web-fetch.ts +0 -327
  314. package/source/tools/web-search.ts +0 -101
  315. package/source/utils/process.ts +0 -121
  316. package/source/version.ts +0 -21
  317. package/test/commands/copy-command.test.ts +0 -69
  318. package/test/config.test.ts +0 -200
  319. package/test/terminal/markdown-utils.test.ts +0 -124
  320. package/test/tools/bash-tool.test.ts +0 -58
  321. package/test/tools/code-interpreter.test.ts +0 -91
  322. package/test/tools/command-validation.test.ts +0 -48
  323. package/tsconfig.build.json +0 -9
  324. package/tsconfig.json +0 -30
@@ -1,288 +0,0 @@
1
- import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
2
- import { objectKeys } from "@travisennis/stdlib/object";
3
- import { customProvider } from "ai";
4
- import type { ModelMetadata } from "./providers.ts";
5
-
6
- const openRouterClient = createOpenAICompatible({
7
- name: "openrouter",
8
- apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
9
- // biome-ignore lint/style/useNamingConvention: third-party controlled
10
- baseURL: "https://openrouter.ai/api/v1",
11
- headers: {
12
- "HTTP-Referer": "https://github.com/travisennis/acai-ts",
13
- "X-Title": "acai",
14
- },
15
- });
16
-
17
- const openrouterModels = {
18
- "deepseek-v3": openRouterClient("deepseek/deepseek-chat-v3-0324"),
19
- "deepseek-r1": openRouterClient("deepseek/deepseek-r1-0528"),
20
- "deepseek-v3-free": openRouterClient("deepseek/deepseek-chat-v3-0324:free"),
21
- "deepseek-r1-free": openRouterClient("deepseek/deepseek-r1-0528:free"),
22
- "gemini-flash25": openRouterClient("google/gemini-2.5-flash"),
23
- "gemini-pro25": openRouterClient("google/gemini-2.5-pro"),
24
- sonnet4: openRouterClient("anthropic/claude-sonnet-4"),
25
- opus4: openRouterClient("anthropic/claude-opus-4"),
26
- "opus-4.1": openRouterClient("anthropic/claude-opus-4.1"),
27
- "gpt-4.1": openRouterClient("openai/gpt-4.1"),
28
- "kimi-k2": openRouterClient("moonshotai/kimi-k2:nitro"),
29
- "kimi-k2-free": openRouterClient("moonshotai/kimi-k2:free"),
30
- "devstral-medium": openRouterClient("mistralai/devstral-medium"),
31
- "qwen3-coder": openRouterClient("qwen/qwen3-coder"),
32
- "qwen3-coder-free": openRouterClient("qwen/qwen3-coder:free"),
33
- "glm-4.5": openRouterClient("z-ai/glm-4.5"),
34
- "gpt-5": openRouterClient("openai/gpt-5"),
35
- "gpt-5-mini": openRouterClient("openai/gpt-5-mini"),
36
- } as const;
37
-
38
- type ModelName = `openrouter:${keyof typeof openrouterModels}`;
39
-
40
- export const openrouterModelNames: ModelName[] = objectKeys(
41
- openrouterModels,
42
- ).map((key) => `openrouter:${key}` as const);
43
-
44
- export const openrouterProvider = {
45
- openrouter: customProvider({
46
- languageModels: openrouterModels,
47
- fallbackProvider: openRouterClient,
48
- }),
49
- };
50
-
51
- export const openrouterModelRegistry: {
52
- [K in ModelName]: ModelMetadata<ModelName>;
53
- } = {
54
- "openrouter:deepseek-v3": {
55
- id: "openrouter:deepseek-v3",
56
- provider: "openrouter",
57
- contextWindow: 128000,
58
- maxOutputTokens: 8000,
59
- defaultTemperature: 0.3,
60
- promptFormat: "bracket",
61
- supportsReasoning: false,
62
- supportsToolCalling: true,
63
- costPerInputToken: 0, // Assuming free tier or unknown cost
64
- costPerOutputToken: 0, // Assuming free tier or unknown cost
65
- category: "balanced",
66
- },
67
- "openrouter:deepseek-r1": {
68
- id: "openrouter:deepseek-r1",
69
- provider: "openrouter",
70
- contextWindow: 128000,
71
- maxOutputTokens: 32768,
72
- defaultTemperature: 0.6,
73
- promptFormat: "bracket",
74
- supportsReasoning: true,
75
- supportsToolCalling: true,
76
- costPerInputToken: 0, // Assuming free tier or unknown cost
77
- costPerOutputToken: 0, // Assuming free tier or unknown cost
78
- category: "balanced",
79
- },
80
- "openrouter:deepseek-v3-free": {
81
- id: "openrouter:deepseek-v3-free",
82
- provider: "openrouter",
83
- contextWindow: 128000,
84
- maxOutputTokens: 8000,
85
- defaultTemperature: 0.3,
86
- promptFormat: "bracket",
87
- supportsReasoning: false,
88
- supportsToolCalling: true,
89
- costPerInputToken: 0, // Assuming free tier or unknown cost
90
- costPerOutputToken: 0, // Assuming free tier or unknown cost
91
- category: "balanced",
92
- },
93
- "openrouter:deepseek-r1-free": {
94
- id: "openrouter:deepseek-r1-free",
95
- provider: "openrouter",
96
- contextWindow: 128000,
97
- maxOutputTokens: 32768,
98
- defaultTemperature: 0.6,
99
- promptFormat: "bracket",
100
- supportsReasoning: true,
101
- supportsToolCalling: true,
102
- costPerInputToken: 0, // Assuming free tier or unknown cost
103
- costPerOutputToken: 0, // Assuming free tier or unknown cost
104
- category: "balanced",
105
- },
106
- "openrouter:gemini-flash25": {
107
- id: "openrouter:gemini-flash25",
108
- provider: "openrouter",
109
- contextWindow: 1000000,
110
- maxOutputTokens: 66000,
111
- defaultTemperature: 0.5,
112
- promptFormat: "markdown",
113
- supportsReasoning: true,
114
- supportsToolCalling: true,
115
- costPerInputToken: 0,
116
- costPerOutputToken: 0,
117
- category: "fast",
118
- },
119
- "openrouter:gemini-pro25": {
120
- id: "openrouter:gemini-pro25",
121
- provider: "openrouter",
122
- contextWindow: 1000000,
123
- maxOutputTokens: 64000,
124
- defaultTemperature: 0.5,
125
- promptFormat: "markdown",
126
- supportsReasoning: true,
127
- supportsToolCalling: true,
128
- costPerInputToken: 0,
129
- costPerOutputToken: 0,
130
- category: "powerful",
131
- },
132
- "openrouter:opus4": {
133
- id: "openrouter:opus4",
134
- provider: "openrouter",
135
- contextWindow: 200000,
136
- maxOutputTokens: 64000,
137
- defaultTemperature: 0.5,
138
- promptFormat: "markdown",
139
- supportsReasoning: true,
140
- supportsToolCalling: true,
141
- costPerInputToken: 0,
142
- costPerOutputToken: 0,
143
- category: "powerful",
144
- },
145
- "openrouter:opus-4.1": {
146
- id: "openrouter:opus-4.1",
147
- provider: "openrouter",
148
- contextWindow: 200000,
149
- maxOutputTokens: 32000,
150
- defaultTemperature: 0.5,
151
- promptFormat: "markdown",
152
- supportsReasoning: true,
153
- supportsToolCalling: true,
154
- costPerInputToken: 0.000015,
155
- costPerOutputToken: 0.000075,
156
- category: "powerful",
157
- },
158
- "openrouter:sonnet4": {
159
- id: "openrouter:sonnet4",
160
- provider: "openrouter",
161
- contextWindow: 200000,
162
- maxOutputTokens: 64000,
163
- defaultTemperature: 0.5,
164
- promptFormat: "markdown",
165
- supportsReasoning: true,
166
- supportsToolCalling: true,
167
- costPerInputToken: 0,
168
- costPerOutputToken: 0,
169
- category: "balanced",
170
- },
171
- "openrouter:gpt-4.1": {
172
- id: "openrouter:gpt-4.1",
173
- provider: "openrouter",
174
- contextWindow: 1000000,
175
- maxOutputTokens: 32768,
176
- defaultTemperature: 0.3,
177
- promptFormat: "markdown",
178
- supportsReasoning: false,
179
- supportsToolCalling: true,
180
- costPerInputToken: 0.000002,
181
- costPerOutputToken: 0.000008,
182
- category: "balanced",
183
- },
184
- "openrouter:kimi-k2": {
185
- id: "openrouter:kimi-k2",
186
- provider: "openrouter",
187
- contextWindow: 131072,
188
- maxOutputTokens: 8192,
189
- defaultTemperature: 0.6,
190
- promptFormat: "markdown",
191
- supportsReasoning: false,
192
- supportsToolCalling: true,
193
- costPerInputToken: 0.00000057,
194
- costPerOutputToken: 0.0000023,
195
- category: "balanced",
196
- },
197
- "openrouter:kimi-k2-free": {
198
- id: "openrouter:kimi-k2-free",
199
- provider: "openrouter",
200
- contextWindow: 65536,
201
- maxOutputTokens: 8192,
202
- defaultTemperature: 0.6,
203
- promptFormat: "markdown",
204
- supportsReasoning: false,
205
- supportsToolCalling: true,
206
- costPerInputToken: 0,
207
- costPerOutputToken: 0,
208
- category: "balanced",
209
- },
210
- "openrouter:devstral-medium": {
211
- id: "openrouter:devstral-medium",
212
- provider: "openrouter",
213
- contextWindow: 131000,
214
- maxOutputTokens: 8192,
215
- defaultTemperature: 0.3,
216
- promptFormat: "markdown",
217
- supportsReasoning: false,
218
- supportsToolCalling: true,
219
- costPerInputToken: 0.0000004,
220
- costPerOutputToken: 0.000002,
221
- category: "balanced",
222
- },
223
- "openrouter:qwen3-coder": {
224
- id: "openrouter:qwen3-coder",
225
- provider: "openrouter",
226
- contextWindow: 262000,
227
- maxOutputTokens: 66000,
228
- defaultTemperature: 0.7,
229
- promptFormat: "markdown",
230
- supportsReasoning: false,
231
- supportsToolCalling: true,
232
- costPerInputToken: 0.0000004,
233
- costPerOutputToken: 0.000002,
234
- category: "balanced",
235
- },
236
- "openrouter:qwen3-coder-free": {
237
- id: "openrouter:qwen3-coder-free",
238
- provider: "openrouter",
239
- contextWindow: 262000,
240
- maxOutputTokens: 66000,
241
- defaultTemperature: 0.7,
242
- promptFormat: "markdown",
243
- supportsReasoning: false,
244
- supportsToolCalling: true,
245
- costPerInputToken: 0.0000004,
246
- costPerOutputToken: 0.000002,
247
- category: "balanced",
248
- },
249
- "openrouter:glm-4.5": {
250
- id: "openrouter:glm-4.5",
251
- provider: "openrouter",
252
- contextWindow: 128000,
253
- maxOutputTokens: 8192,
254
- defaultTemperature: 0.7,
255
- promptFormat: "markdown",
256
- supportsReasoning: true,
257
- supportsToolCalling: true,
258
- costPerInputToken: 0.0000006,
259
- costPerOutputToken: 0.0000022,
260
- category: "balanced",
261
- },
262
- "openrouter:gpt-5": {
263
- id: "openrouter:gpt-5",
264
- provider: "openrouter",
265
- contextWindow: 400000,
266
- maxOutputTokens: 128000,
267
- defaultTemperature: 0.3,
268
- promptFormat: "markdown",
269
- supportsReasoning: true,
270
- supportsToolCalling: true,
271
- costPerInputToken: 0.00000125,
272
- costPerOutputToken: 0.00001,
273
- category: "powerful",
274
- },
275
- "openrouter:gpt-5-mini": {
276
- id: "openrouter:gpt-5-mini",
277
- provider: "openrouter",
278
- contextWindow: 200000,
279
- maxOutputTokens: 64000,
280
- defaultTemperature: 0.3,
281
- promptFormat: "markdown",
282
- supportsReasoning: true,
283
- supportsToolCalling: true,
284
- costPerInputToken: 0.00000015,
285
- costPerOutputToken: 0.0000006,
286
- category: "balanced",
287
- },
288
- };
@@ -1,197 +0,0 @@
1
- import { isString } from "@travisennis/stdlib/typeguards";
2
- import { createProviderRegistry } from "ai";
3
- import { z } from "zod";
4
- import {
5
- anthropicModelNames,
6
- anthropicModelRegistry,
7
- anthropicProvider,
8
- } from "./anthropic-provider.ts";
9
- import {
10
- deepseekModelNames,
11
- deepseekModelRegistry,
12
- deepseekProvider,
13
- } from "./deepseek-provider.ts";
14
- import {
15
- googleModelNames,
16
- googleModelRegistry,
17
- googleProvider,
18
- } from "./google-provider.ts";
19
- import {
20
- openaiModelNames,
21
- openaiModelRegistry,
22
- openaiProvider,
23
- } from "./openai-provider.ts";
24
- import {
25
- openrouterModelNames,
26
- openrouterModelRegistry,
27
- openrouterProvider,
28
- } from "./openrouter-provider.ts";
29
- import {
30
- xaiModelNames,
31
- xaiModelRegistry,
32
- xaiProvider,
33
- } from "./xai-provider.ts";
34
-
35
- export const providers = [
36
- "anthropic",
37
- "openai",
38
- "google",
39
- "deepseek",
40
- "openrouter",
41
- "xai",
42
- ] as const;
43
-
44
- export type ModelProvider = (typeof providers)[number];
45
-
46
- const registry = createProviderRegistry({
47
- ...anthropicProvider,
48
- ...deepseekProvider,
49
- ...googleProvider,
50
- ...openaiProvider,
51
- ...openrouterProvider,
52
- ...xaiProvider,
53
- });
54
-
55
- export const models = [
56
- ...anthropicModelNames,
57
- ...openaiModelNames,
58
- ...googleModelNames,
59
- ...deepseekModelNames,
60
- ...openrouterModelNames,
61
- ...xaiModelNames,
62
- ] as const;
63
-
64
- export type ModelName =
65
- | (typeof models)[number]
66
- | (`xai:${string}` & {})
67
- | (`openai:${string}` & {})
68
- | (`anthropic:${string}` & {})
69
- | (`google:${string}` & {})
70
- | (`deepseek:${string}` & {})
71
- | (`openrouter:${string}` & {});
72
-
73
- export function isSupportedModel(model: unknown): model is ModelName {
74
- return (
75
- models.includes(model as (typeof models)[number]) ||
76
- (isString(model) &&
77
- (model.startsWith("openrouter:") ||
78
- model.startsWith("anthropic:") ||
79
- model.startsWith("openai:") ||
80
- model.startsWith("google:") ||
81
- model.startsWith("xai:") ||
82
- model.startsWith("deepseek:")))
83
- );
84
- }
85
-
86
- export function languageModel(model: ModelName) {
87
- return registry.languageModel(model as (typeof models)[number]);
88
- }
89
-
90
- export interface ModelMetadata<T = ModelName> {
91
- id: T;
92
- provider: ModelProvider;
93
- // displayName: string;
94
- // description: string;
95
- contextWindow: number;
96
- supportsToolCalling: boolean;
97
- supportsReasoning: boolean;
98
- costPerInputToken: number;
99
- costPerOutputToken: number;
100
- maxOutputTokens: number;
101
- defaultTemperature: number;
102
- promptFormat: "xml" | "markdown" | "bracket";
103
- category: "fast" | "balanced" | "powerful";
104
- }
105
-
106
- // https://openrouter.ai/api/v1/models
107
- export const modelRegistry: Record<ModelName, ModelMetadata> = {
108
- ...anthropicModelRegistry,
109
- ...openaiModelRegistry,
110
- ...googleModelRegistry,
111
- ...deepseekModelRegistry,
112
- ...openrouterModelRegistry,
113
- ...xaiModelRegistry,
114
- };
115
-
116
- // Schema for validating model selection
117
- export const ModelSelectionSchema = z.enum(
118
- Object.keys(modelRegistry) as [string, ...string[]],
119
- );
120
-
121
- // Get available models grouped by provider
122
- export function getModelsByProvider(): Record<ModelProvider, ModelMetadata[]> {
123
- const result: Record<ModelProvider, ModelMetadata[]> = {
124
- anthropic: [],
125
- openai: [],
126
- google: [],
127
- deepseek: [],
128
- openrouter: [],
129
- xai: [],
130
- };
131
-
132
- for (const model of Object.values(modelRegistry)) {
133
- result[model.provider].push(model);
134
- }
135
-
136
- return result;
137
- }
138
-
139
- export function getModelsById(): Record<ModelName, string> {
140
- const result: Map<ModelName, string> = new Map();
141
-
142
- for (const name of models) {
143
- const langModel = registry.languageModel(name);
144
- result.set(name, langModel.modelId);
145
- }
146
-
147
- return Object.fromEntries(result) as Record<ModelName, string>;
148
- }
149
-
150
- // Get detailed information about a specific model
151
- export function getModelInfo(modelName: ModelName): ModelMetadata | undefined {
152
- return modelRegistry[modelName];
153
- }
154
-
155
- // Get models by category
156
- export function getModelsByCategory(
157
- category: "fast" | "balanced" | "powerful",
158
- ): ModelMetadata[] {
159
- return Object.values(modelRegistry).filter(
160
- (model) => model.category === category,
161
- );
162
- }
163
-
164
- // Format model information for display
165
- export function formatModelInfo(model: ModelMetadata): string {
166
- return `${model.id} [${model.category}] - Tools: ${model.supportsToolCalling ? "✓" : "✗"}, Reasoning: ${model.supportsReasoning ? "✓" : "✗"}`;
167
- }
168
-
169
- // Check if a model name is valid
170
- export function isValidModel(modelName: string): modelName is ModelName {
171
- return modelName in modelRegistry;
172
- }
173
-
174
- // Get recommended models based on task requirements
175
- export function getRecommendedModels(options: {
176
- requiresTools?: boolean;
177
- requiresReasoning?: boolean;
178
- speedPriority?: boolean;
179
- }): ModelName[] {
180
- return Object.values(modelRegistry)
181
- .filter((model) => {
182
- if (options.requiresTools && !model.supportsToolCalling) {
183
- return false;
184
- }
185
- if (options.requiresReasoning && !model.supportsReasoning) {
186
- return false;
187
- }
188
- return true;
189
- })
190
- .sort((a, b) => {
191
- if (options.speedPriority) {
192
- return a.category === "fast" ? -1 : 1;
193
- }
194
- return b.contextWindow - a.contextWindow;
195
- })
196
- .map((model) => model.id);
197
- }
@@ -1,59 +0,0 @@
1
- import { createOpenAI } from "@ai-sdk/openai";
2
- import { objectKeys } from "@travisennis/stdlib/object";
3
- import { customProvider } from "ai";
4
- import type { ModelMetadata } from "./providers.ts";
5
-
6
- const xaiClient = createOpenAI({
7
- apiKey: process.env["X_AI_API_KEY"] ?? process.env["XAI_API_KEY"],
8
- // biome-ignore lint/style/useNamingConvention: third-party controlled
9
- baseURL: "https://api.x.ai/v1",
10
- });
11
-
12
- const xaiModels = {
13
- grok3: xaiClient("grok-3"),
14
- "grok3-mini": xaiClient("grok-3-mini-beta"),
15
- } as const;
16
-
17
- type ModelName = `xai:${keyof typeof xaiModels}`;
18
-
19
- export const xaiModelNames: ModelName[] = objectKeys(xaiModels).map(
20
- (key) => `xai:${key}` as const,
21
- );
22
-
23
- export const xaiProvider = {
24
- xai: customProvider({
25
- languageModels: xaiModels,
26
- fallbackProvider: xaiClient,
27
- }),
28
- };
29
-
30
- export const xaiModelRegistry: {
31
- [K in ModelName]: ModelMetadata<ModelName>;
32
- } = {
33
- "xai:grok3": {
34
- id: "xai:grok3",
35
- provider: "xai",
36
- contextWindow: 131072,
37
- maxOutputTokens: 131072, // Note: API docs might specify lower practical limits
38
- defaultTemperature: 0.6,
39
- promptFormat: "markdown",
40
- supportsReasoning: false, // Assuming based on typical chat models
41
- supportsToolCalling: true,
42
- costPerInputToken: 0.000003, // Placeholder, check official pricing
43
- costPerOutputToken: 0.000015, // Placeholder, check official pricing
44
- category: "balanced",
45
- },
46
- "xai:grok3-mini": {
47
- id: "xai:grok3-mini",
48
- provider: "xai",
49
- contextWindow: 131072,
50
- maxOutputTokens: 131072, // Note: API docs might specify lower practical limits
51
- defaultTemperature: 0.6,
52
- promptFormat: "markdown",
53
- supportsReasoning: true, // Assuming based on typical chat models
54
- supportsToolCalling: true,
55
- costPerInputToken: 0.0000003, // Placeholder, check official pricing
56
- costPerOutputToken: 0.0000005, // Placeholder, check official pricing
57
- category: "fast", // Or "fast" depending on performance
58
- },
59
- };
package/source/parsing.ts DELETED
@@ -1,20 +0,0 @@
1
- import { ZodIssueCode, z } from "zod";
2
-
3
- const parseJsonPreprocessor = (value: unknown, ctx: z.RefinementCtx) => {
4
- if (typeof value === "string") {
5
- try {
6
- return JSON.parse(value);
7
- } catch (e) {
8
- ctx.addIssue({
9
- code: ZodIssueCode.custom,
10
- message: (e as Error).message,
11
- });
12
- }
13
- }
14
-
15
- return value;
16
- };
17
-
18
- export function jsonParser<T extends z.ZodTypeAny>(input: T) {
19
- return z.preprocess(parseJsonPreprocessor, input);
20
- }
@@ -1,90 +0,0 @@
1
- import { isString } from "@travisennis/stdlib/typeguards";
2
- import type { TextPart, UserModelMessage } from "ai"; // Corrected import
3
- import { createUserMessage, type UserMessageContentItem } from "../messages.ts";
4
- import type { TokenCounter } from "../token-utils.ts";
5
-
6
- export type ContextItem = UserMessageContentItem;
7
-
8
- export class PromptManager {
9
- private prompt: string | undefined;
10
- private context: ContextItem[];
11
- private tokenCounter: TokenCounter;
12
-
13
- constructor(tokenCounter: TokenCounter) {
14
- this.prompt = undefined;
15
- this.context = [];
16
- this.tokenCounter = tokenCounter;
17
- }
18
-
19
- set(prompt: string) {
20
- this.prompt = prompt;
21
- }
22
-
23
- get() {
24
- const prompt = this.prompt;
25
- if (isString(prompt) && prompt.trim().length > 0) {
26
- return prompt;
27
- }
28
- throw new Error("No prompt available.");
29
- }
30
-
31
- getUserMessage(): UserModelMessage {
32
- const currentPrompt = this.prompt;
33
- if (isString(currentPrompt) && currentPrompt.trim().length > 0) {
34
- let userMessage: UserModelMessage;
35
- if (this.hasContext()) {
36
- // Pass context items and the prompt string to createUserMessage
37
- userMessage = createUserMessage([...this.context], currentPrompt);
38
- this.clearAll(); // Clear context and prompt after using
39
- } else {
40
- // Pass an empty array for context items if no context
41
- userMessage = createUserMessage([], currentPrompt);
42
- this.prompt = undefined; // Clear only prompt if no context was used
43
- }
44
-
45
- return this._applyProviderOptionsToMessage(userMessage);
46
- }
47
- throw new Error("No prompt available.");
48
- }
49
-
50
- private _applyProviderOptionsToMessage(
51
- userMessage: UserModelMessage,
52
- ): UserModelMessage {
53
- if (Array.isArray(userMessage.content)) {
54
- for (const part of userMessage.content) {
55
- if (typeof part === "object" && part !== null && part.type === "text") {
56
- const textPart = part as TextPart & {
57
- providerOptions?: Record<string, unknown>;
58
- };
59
- if (this.tokenCounter.count(textPart.text) > 4096) {
60
- textPart.providerOptions = {
61
- anthropic: { cacheControl: { type: "ephemeral" } },
62
- };
63
- }
64
- }
65
- }
66
- }
67
- return userMessage;
68
- }
69
-
70
- isPending() {
71
- return isString(this.prompt) && this.prompt.trim().length > 0;
72
- }
73
-
74
- addContext(item: ContextItem): void {
75
- this.context.push(item);
76
- }
77
-
78
- hasContext() {
79
- return this.context.length > 0;
80
- }
81
-
82
- clearContext() {
83
- this.context.length = 0;
84
- }
85
-
86
- clearAll() {
87
- this.clearContext();
88
- this.prompt = undefined;
89
- }
90
- }