micro-models-agent 0.55.0 → 0.56.0

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 (232) hide show
  1. package/README.md +358 -358
  2. package/dist/certification/certifications.json +493 -493
  3. package/dist/main.js +2301 -1213
  4. package/dist/modules/browser/bridge-server.mjs +219 -202
  5. package/dist/skills/builtin/git.md +36 -36
  6. package/dist/skills/builtin/typescript.md +35 -35
  7. package/package.json +1 -1
  8. package/dist/cli/commands.js +0 -447
  9. package/dist/cli/completer.js +0 -167
  10. package/dist/cli/index.js +0 -2
  11. package/dist/cli/main.js +0 -153
  12. package/dist/cli/plugin-commands.js +0 -36
  13. package/dist/cli/repl-commands.js +0 -761
  14. package/dist/cli/repl.js +0 -702
  15. package/dist/cli/run-result.js +0 -33
  16. package/dist/cli/security-commands.js +0 -164
  17. package/dist/cli/setup.js +0 -237
  18. package/dist/config/config.js +0 -276
  19. package/dist/config/defaults.js +0 -141
  20. package/dist/config/domains.js +0 -179
  21. package/dist/config/experts.js +0 -15
  22. package/dist/config/index.js +0 -4
  23. package/dist/config/security.js +0 -213
  24. package/dist/config/types.js +0 -1
  25. package/dist/core/agent-moe.js +0 -102
  26. package/dist/core/agent.js +0 -1018
  27. package/dist/core/bootstrap.js +0 -481
  28. package/dist/core/crash-handler.js +0 -51
  29. package/dist/core/environment.js +0 -199
  30. package/dist/core/index.js +0 -2
  31. package/dist/core/prompt-builder.js +0 -76
  32. package/dist/core/session-logger.js +0 -251
  33. package/dist/core/types.js +0 -1
  34. package/dist/core/version.js +0 -26
  35. package/dist/core/workspace.js +0 -76
  36. package/dist/i18n/en.json +0 -679
  37. package/dist/i18n/index.js +0 -46
  38. package/dist/i18n/ru.json +0 -679
  39. package/dist/index.js +0 -22
  40. package/dist/llm/image-utils.js +0 -143
  41. package/dist/llm/index.js +0 -4
  42. package/dist/llm/model-loader.js +0 -78
  43. package/dist/llm/openai-compat.js +0 -497
  44. package/dist/llm/orchestrator.js +0 -200
  45. package/dist/llm/provider.js +0 -10
  46. package/dist/llm/response.js +0 -39
  47. package/dist/llm/token-counter.js +0 -39
  48. package/dist/llm/types.js +0 -1
  49. package/dist/logger/app-logger.js +0 -189
  50. package/dist/logger/file-log.js +0 -151
  51. package/dist/logger/index.js +0 -1
  52. package/dist/migration/backup.js +0 -45
  53. package/dist/migration/detect.js +0 -50
  54. package/dist/migration/index.js +0 -2
  55. package/dist/modules/artifacts/store.js +0 -61
  56. package/dist/modules/browser/actions.js +0 -76
  57. package/dist/modules/browser/bridge-client.js +0 -199
  58. package/dist/modules/browser/bridge-path.js +0 -10
  59. package/dist/modules/browser/cookie-store.js +0 -24
  60. package/dist/modules/browser/driver.js +0 -136
  61. package/dist/modules/browser/index.js +0 -7
  62. package/dist/modules/browser/module.js +0 -29
  63. package/dist/modules/browser/session.js +0 -342
  64. package/dist/modules/browser/snapshot.js +0 -148
  65. package/dist/modules/browser/types.js +0 -12
  66. package/dist/modules/certification/cli.js +0 -213
  67. package/dist/modules/certification/fact-checker.js +0 -82
  68. package/dist/modules/certification/loader.js +0 -106
  69. package/dist/modules/certification/manifest.js +0 -58
  70. package/dist/modules/certification/runner.js +0 -245
  71. package/dist/modules/certification/scenarios.js +0 -407
  72. package/dist/modules/certification/types.js +0 -1
  73. package/dist/modules/context/chunk-query.js +0 -100
  74. package/dist/modules/context/fact-extractor.js +0 -168
  75. package/dist/modules/context/history.js +0 -15
  76. package/dist/modules/context/index.js +0 -1
  77. package/dist/modules/context/manager.js +0 -440
  78. package/dist/modules/execution/audit-runners.js +0 -206
  79. package/dist/modules/execution/auditor.js +0 -218
  80. package/dist/modules/execution/execution-plugin.js +0 -431
  81. package/dist/modules/execution/index.js +0 -8
  82. package/dist/modules/execution/module.js +0 -625
  83. package/dist/modules/execution/moe-executor.js +0 -304
  84. package/dist/modules/execution/plan-coverage.js +0 -68
  85. package/dist/modules/execution/plan-persister.js +0 -46
  86. package/dist/modules/execution/plan-store.js +0 -196
  87. package/dist/modules/execution/plan-tool.js +0 -677
  88. package/dist/modules/execution/plan-validator.js +0 -153
  89. package/dist/modules/execution/planner.js +0 -94
  90. package/dist/modules/execution/stuck-detector.js +0 -746
  91. package/dist/modules/execution/tracker.js +0 -69
  92. package/dist/modules/execution/types.js +0 -1
  93. package/dist/modules/execution/verifier.js +0 -235
  94. package/dist/modules/execution/windows-commands.js +0 -41
  95. package/dist/modules/hallucination/confidence.js +0 -66
  96. package/dist/modules/hallucination/consistency.js +0 -26
  97. package/dist/modules/hallucination/detector.js +0 -47
  98. package/dist/modules/hallucination/factual.js +0 -169
  99. package/dist/modules/hallucination/index.js +0 -5
  100. package/dist/modules/hallucination/js-identifiers.js +0 -262
  101. package/dist/modules/hallucination/llm-judge.js +0 -101
  102. package/dist/modules/index.js +0 -5
  103. package/dist/modules/indexer/cache.js +0 -40
  104. package/dist/modules/indexer/index.js +0 -3
  105. package/dist/modules/indexer/module.js +0 -246
  106. package/dist/modules/indexer/project-profile.js +0 -183
  107. package/dist/modules/indexer/walker.js +0 -101
  108. package/dist/modules/lsp/check-tool.js +0 -58
  109. package/dist/modules/lsp/client.js +0 -389
  110. package/dist/modules/lsp/command.js +0 -60
  111. package/dist/modules/lsp/config.js +0 -135
  112. package/dist/modules/lsp/index.js +0 -3
  113. package/dist/modules/lsp/module.js +0 -260
  114. package/dist/modules/lsp/probe.js +0 -86
  115. package/dist/modules/lsp/project-root.js +0 -32
  116. package/dist/modules/lsp/startup-check.js +0 -144
  117. package/dist/modules/lsp/types.js +0 -1
  118. package/dist/modules/mcp/client.js +0 -399
  119. package/dist/modules/mcp/index.js +0 -3
  120. package/dist/modules/mcp/module.js +0 -142
  121. package/dist/modules/mcp/registry.js +0 -15
  122. package/dist/modules/memory/index.js +0 -1
  123. package/dist/modules/memory/module.js +0 -96
  124. package/dist/modules/memory/search.js +0 -42
  125. package/dist/modules/memory/store.js +0 -69
  126. package/dist/modules/pipelines/engine.js +0 -60
  127. package/dist/modules/pipelines/index.js +0 -3
  128. package/dist/modules/pipelines/parser.js +0 -56
  129. package/dist/modules/pipelines/template.js +0 -14
  130. package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
  131. package/dist/modules/plugins/builtin/notify.js +0 -9
  132. package/dist/modules/plugins/index.js +0 -1
  133. package/dist/modules/plugins/loader.js +0 -70
  134. package/dist/modules/plugins/manager.js +0 -261
  135. package/dist/modules/plugins/types.js +0 -1
  136. package/dist/modules/pricing/index.js +0 -61
  137. package/dist/modules/pricing/prices.js +0 -129
  138. package/dist/modules/processes/detect.js +0 -34
  139. package/dist/modules/processes/index.js +0 -2
  140. package/dist/modules/processes/registry.js +0 -327
  141. package/dist/modules/processes/runner.js +0 -23
  142. package/dist/modules/providers/create.js +0 -22
  143. package/dist/modules/providers/fallback.js +0 -79
  144. package/dist/modules/providers/health.js +0 -46
  145. package/dist/modules/providers/index.js +0 -5
  146. package/dist/modules/providers/manager.js +0 -161
  147. package/dist/modules/providers/presets.js +0 -128
  148. package/dist/modules/providers/registry.js +0 -22
  149. package/dist/modules/providers/types.js +0 -1
  150. package/dist/modules/registry.js +0 -48
  151. package/dist/modules/security/audit-log.js +0 -136
  152. package/dist/modules/security/audit-notifier.js +0 -292
  153. package/dist/modules/security/command-validator.js +0 -219
  154. package/dist/modules/security/content-scanner.js +0 -53
  155. package/dist/modules/security/data-sanitizer.js +0 -89
  156. package/dist/modules/security/encryption.js +0 -242
  157. package/dist/modules/security/index.js +0 -14
  158. package/dist/modules/security/network-validator.js +0 -88
  159. package/dist/modules/security/path-validator.js +0 -203
  160. package/dist/modules/security/rate-limiter.js +0 -119
  161. package/dist/modules/security/security-policies.js +0 -531
  162. package/dist/modules/security/session-encryption.js +0 -210
  163. package/dist/modules/security/session-isolation.js +0 -95
  164. package/dist/modules/session/index.js +0 -3
  165. package/dist/modules/session/manager.js +0 -172
  166. package/dist/modules/session/module.js +0 -24
  167. package/dist/modules/session/store.js +0 -222
  168. package/dist/modules/session/types.js +0 -1
  169. package/dist/modules/skills/index.js +0 -2
  170. package/dist/modules/skills/loader.js +0 -72
  171. package/dist/modules/skills/matcher.js +0 -27
  172. package/dist/modules/skills/module.js +0 -129
  173. package/dist/modules/types.js +0 -1
  174. package/dist/modules/updater/checker.js +0 -96
  175. package/dist/modules/updater/index.js +0 -2
  176. package/dist/modules/updater/module.js +0 -116
  177. package/dist/modules/user-profile/compressor.js +0 -16
  178. package/dist/modules/user-profile/index.js +0 -1
  179. package/dist/modules/user-profile/profile.js +0 -68
  180. package/dist/tools/approve.js +0 -33
  181. package/dist/tools/attach-image.js +0 -101
  182. package/dist/tools/bash.js +0 -519
  183. package/dist/tools/browser.js +0 -115
  184. package/dist/tools/chunk-query.js +0 -100
  185. package/dist/tools/create-dir.js +0 -56
  186. package/dist/tools/delete-file.js +0 -63
  187. package/dist/tools/download-file.js +0 -117
  188. package/dist/tools/edit-file.js +0 -80
  189. package/dist/tools/enable-tools.js +0 -59
  190. package/dist/tools/executor.js +0 -154
  191. package/dist/tools/file-info.js +0 -47
  192. package/dist/tools/filter-tools.js +0 -17
  193. package/dist/tools/glob-tool.js +0 -27
  194. package/dist/tools/grep-tool.js +0 -125
  195. package/dist/tools/hidden-tools-block.js +0 -37
  196. package/dist/tools/index.js +0 -78
  197. package/dist/tools/list-dir.js +0 -49
  198. package/dist/tools/load-skill.js +0 -43
  199. package/dist/tools/mcp-call.js +0 -69
  200. package/dist/tools/move-file.js +0 -86
  201. package/dist/tools/path-utils.js +0 -101
  202. package/dist/tools/pipeline-run.js +0 -145
  203. package/dist/tools/preview.js +0 -2
  204. package/dist/tools/process-kill.js +0 -40
  205. package/dist/tools/process-list.js +0 -37
  206. package/dist/tools/process-log.js +0 -54
  207. package/dist/tools/question.js +0 -141
  208. package/dist/tools/read-file.js +0 -179
  209. package/dist/tools/recall.js +0 -118
  210. package/dist/tools/registry.js +0 -47
  211. package/dist/tools/remember.js +0 -68
  212. package/dist/tools/scope-check.js +0 -32
  213. package/dist/tools/search-history.js +0 -85
  214. package/dist/tools/subagent.js +0 -196
  215. package/dist/tools/types.js +0 -1
  216. package/dist/tools/user-input.js +0 -123
  217. package/dist/tools/web-browse.js +0 -87
  218. package/dist/tools/web-fetch.js +0 -119
  219. package/dist/tools/web-search.js +0 -105
  220. package/dist/tools/write-file.js +0 -82
  221. package/dist/ui/box.js +0 -77
  222. package/dist/ui/colors.js +0 -4
  223. package/dist/ui/diff.js +0 -178
  224. package/dist/ui/index.js +0 -6
  225. package/dist/ui/line-editor.js +0 -822
  226. package/dist/ui/line-math.js +0 -73
  227. package/dist/ui/md-formatter.js +0 -212
  228. package/dist/ui/output.js +0 -13
  229. package/dist/ui/plan-view.js +0 -103
  230. package/dist/ui/renderer.js +0 -259
  231. package/dist/ui/spinner.js +0 -70
  232. package/dist/ui/table.js +0 -144
@@ -1,261 +0,0 @@
1
- import { semverGt } from "../updater/checker";
2
- export class PluginManager {
3
- plugins = [];
4
- hostBridge = null;
5
- /**
6
- * Register the host bridge (set once by the REPL). It is merged into every
7
- * hook context as `ctx.hostBridge` unless the caller already provided one.
8
- */
9
- setHostBridge(bridge) {
10
- this.hostBridge = bridge;
11
- }
12
- /** Merge the host bridge into a hook context (caller-provided value wins). */
13
- withHost(ctx) {
14
- if (!ctx || typeof ctx !== "object")
15
- return ctx;
16
- if (!this.hostBridge || ctx.hostBridge !== undefined) {
17
- return ctx;
18
- }
19
- return { ...ctx, hostBridge: this.hostBridge };
20
- }
21
- /**
22
- * Register a plugin. Plugins with the same `name` are deduplicated — the
23
- * higher `version` wins (unversioned plugins count as "0.0.0"). The loser is
24
- * discarded; `skipped_older` lets the caller warn about the dropped copy.
25
- */
26
- register(plugin, source) {
27
- if (source)
28
- plugin.source = source;
29
- const existing = this.plugins.find((p) => p.name === plugin.name);
30
- if (existing) {
31
- if (semverGt(plugin.version || "0.0.0", existing.version || "0.0.0")) {
32
- this.plugins = this.plugins.filter((p) => p.name !== plugin.name);
33
- this.plugins.push(plugin);
34
- this.sort();
35
- return { status: "registered" };
36
- }
37
- return { status: "skipped_older", existing };
38
- }
39
- this.plugins.push(plugin);
40
- this.sort();
41
- return { status: "registered" };
42
- }
43
- sort() {
44
- this.plugins.sort((a, b) => (b.priority || 0) - (a.priority || 0));
45
- }
46
- getAllPlugins() {
47
- return [...this.plugins];
48
- }
49
- /** Detailed plugin list (name, version, source) for REPL / CLI display. */
50
- getPluginInfos() {
51
- return [...this.plugins].map((plugin) => ({ plugin, source: plugin.source }));
52
- }
53
- /** Find a registered plugin by name, or null. */
54
- getPlugin(name) {
55
- return this.plugins.find((p) => p.name === name) ?? null;
56
- }
57
- runOnBuildPrompt() {
58
- return this.plugins.map((p) => {
59
- try {
60
- return p.onBuildPrompt?.() ?? null;
61
- }
62
- catch {
63
- return null;
64
- }
65
- });
66
- }
67
- async runOnBeforeTool(rawCtx, call) {
68
- const ctx = this.withHost(rawCtx);
69
- for (const plugin of this.plugins) {
70
- if (plugin.onBeforeTool) {
71
- try {
72
- const result = await plugin.onBeforeTool(ctx, call);
73
- if (result === false)
74
- return false;
75
- }
76
- catch {
77
- /* error isolation */
78
- }
79
- }
80
- }
81
- return true;
82
- }
83
- async runOnAfterTool(rawCtx, call, result) {
84
- const ctx = this.withHost(rawCtx);
85
- for (const plugin of this.plugins) {
86
- if (plugin.onAfterTool) {
87
- try {
88
- await plugin.onAfterTool(ctx, call, result);
89
- }
90
- catch {
91
- /* error isolation */
92
- }
93
- }
94
- }
95
- }
96
- async runOnError(rawCtx, error) {
97
- const ctx = this.withHost(rawCtx);
98
- for (const plugin of this.plugins) {
99
- if (plugin.onError) {
100
- try {
101
- await plugin.onError(ctx, error);
102
- }
103
- catch {
104
- /* error isolation */
105
- }
106
- }
107
- }
108
- }
109
- runOnSessionStart(rawCtx) {
110
- const ctx = this.withHost(rawCtx);
111
- for (const plugin of this.plugins) {
112
- if (plugin.onSessionStart) {
113
- try {
114
- plugin.onSessionStart(ctx);
115
- }
116
- catch {
117
- /* error isolation */
118
- }
119
- }
120
- }
121
- }
122
- runOnBeforeThink(rawCtx) {
123
- const ctx = this.withHost(rawCtx);
124
- for (const plugin of this.plugins) {
125
- if (plugin.onBeforeThink) {
126
- try {
127
- plugin.onBeforeThink(ctx);
128
- }
129
- catch {
130
- /* error isolation */
131
- }
132
- }
133
- }
134
- }
135
- runOnAfterThink(rawCtx, response) {
136
- const ctx = this.withHost(rawCtx);
137
- for (const plugin of this.plugins) {
138
- if (plugin.onAfterThink) {
139
- try {
140
- plugin.onAfterThink(ctx, response);
141
- }
142
- catch {
143
- /* error isolation */
144
- }
145
- }
146
- }
147
- }
148
- runOnSessionEnd(rawCtx) {
149
- const ctx = this.withHost(rawCtx);
150
- for (const plugin of this.plugins) {
151
- if (plugin.onSessionEnd) {
152
- try {
153
- plugin.onSessionEnd(ctx);
154
- }
155
- catch {
156
- /* error isolation */
157
- }
158
- }
159
- }
160
- }
161
- runOnToolCall(rawCtx) {
162
- const ctx = this.withHost(rawCtx);
163
- for (const plugin of this.plugins) {
164
- if (plugin.onToolCall) {
165
- try {
166
- plugin.onToolCall(ctx);
167
- }
168
- catch {
169
- /* error isolation */
170
- }
171
- }
172
- }
173
- }
174
- runOnPhase(rawCtx, phase) {
175
- const ctx = this.withHost(rawCtx);
176
- for (const plugin of this.plugins) {
177
- if (plugin.onPhase) {
178
- try {
179
- plugin.onPhase(ctx, phase);
180
- }
181
- catch {
182
- /* error isolation */
183
- }
184
- }
185
- }
186
- }
187
- runOnToolStart(rawCtx, call) {
188
- const ctx = this.withHost(rawCtx);
189
- for (const plugin of this.plugins) {
190
- if (plugin.onToolStart) {
191
- try {
192
- plugin.onToolStart(ctx, call);
193
- }
194
- catch {
195
- /* error isolation */
196
- }
197
- }
198
- }
199
- }
200
- runOnToolEnd(rawCtx, call, result, durationMs) {
201
- const ctx = this.withHost(rawCtx);
202
- for (const plugin of this.plugins) {
203
- if (plugin.onToolEnd) {
204
- try {
205
- plugin.onToolEnd(ctx, call, result, durationMs);
206
- }
207
- catch {
208
- /* error isolation */
209
- }
210
- }
211
- }
212
- }
213
- /** Pipe a text chunk through plugin transforms; returns the (possibly replaced) chunk. */
214
- runOnText(rawCtx, chunk) {
215
- const ctx = this.withHost(rawCtx);
216
- for (const plugin of this.plugins) {
217
- if (plugin.onText) {
218
- try {
219
- const out = plugin.onText(ctx, chunk);
220
- if (typeof out === "string")
221
- chunk = out;
222
- }
223
- catch {
224
- /* error isolation */
225
- }
226
- }
227
- }
228
- return chunk;
229
- }
230
- /** Pipe a meta chunk through plugin transforms; returns the (possibly replaced) chunk. */
231
- runOnMeta(rawCtx, chunk) {
232
- const ctx = this.withHost(rawCtx);
233
- for (const plugin of this.plugins) {
234
- if (plugin.onMeta) {
235
- try {
236
- const out = plugin.onMeta(ctx, chunk);
237
- if (typeof out === "string")
238
- chunk = out;
239
- }
240
- catch {
241
- /* error isolation */
242
- }
243
- }
244
- }
245
- return chunk;
246
- }
247
- /** Dispatch a completed-run summary to all plugins (once per Agent.run()). */
248
- runOnTurnEnd(rawCtx, summary) {
249
- const ctx = this.withHost(rawCtx);
250
- for (const plugin of this.plugins) {
251
- if (plugin.onTurnEnd) {
252
- try {
253
- plugin.onTurnEnd(ctx, summary);
254
- }
255
- catch {
256
- /* error isolation */
257
- }
258
- }
259
- }
260
- }
261
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,61 +0,0 @@
1
- import { calculateCost, formatCost } from "./prices";
2
- /**
3
- * Accumulates per-call LLM cost for a session, attributed to the provider
4
- * that served the call. Call `record()` after each LLM call with the
5
- * (estimated or API) token usage and the provider name; read `total` for the
6
- * running total, `totalFor(provider)` / `breakdown()` for per-provider
7
- * attribution. When the model has no known price, `record` is a no-op.
8
- */
9
- export class CostTracker {
10
- config;
11
- model;
12
- _total = 0;
13
- _known = false;
14
- byProvider = new Map();
15
- constructor(model, config) {
16
- this.model = model;
17
- this.config = config;
18
- }
19
- /** Update the model (on /model switch). Later records use the new price. */
20
- setModel(model) {
21
- this.model = model;
22
- }
23
- /** Record a single LLM call's token usage, attributed to `provider`. */
24
- record(promptTokens, completionTokens, provider) {
25
- const key = provider || "unknown";
26
- const cost = calculateCost(this.model, promptTokens, completionTokens, this.config);
27
- if (cost === undefined)
28
- return;
29
- this._known = true;
30
- this._total += cost;
31
- let entry = this.byProvider.get(key);
32
- if (!entry) {
33
- entry = { total: 0, known: false };
34
- this.byProvider.set(key, entry);
35
- }
36
- entry.known = true;
37
- entry.total += cost;
38
- }
39
- /** Running total cost in USD, or undefined if no model price is known. */
40
- get total() {
41
- return this._known ? this._total : undefined;
42
- }
43
- /** Total for one provider, or undefined when nothing was priced for it. */
44
- totalFor(provider) {
45
- const entry = this.byProvider.get(provider);
46
- return entry && entry.known ? entry.total : undefined;
47
- }
48
- /** Per-provider totals sorted by cost descending (priced providers only). */
49
- breakdown() {
50
- const entries = [];
51
- for (const [provider, entry] of this.byProvider) {
52
- if (entry.known)
53
- entries.push({ provider, cost: entry.total });
54
- }
55
- return entries.sort((a, b) => b.cost - a.cost);
56
- }
57
- /** Human-readable total, or undefined when pricing is unavailable. */
58
- get formatted() {
59
- return this._known ? formatCost(this._total) : undefined;
60
- }
61
- }
@@ -1,129 +0,0 @@
1
- /**
2
- * Built-in price table (USD per 1M tokens) for OpenCode Zen / Go models.
3
- * Values from https://opencode.ai/docs/zen/ and /docs/go/ (August 2026).
4
- * Model ids are stored WITHOUT the `opencode/` or `opencode-go/` prefix so a
5
- * single table serves both providers; lookup strips the prefix.
6
- */
7
- const ZEN_PRICES = {
8
- // Free models
9
- "big-pickle": { input: 0, output: 0 },
10
- "mimo-v2.5-free": { input: 0, output: 0 },
11
- "hy3-free": { input: 0, output: 0 },
12
- "nemotron-3-ultra-free": { input: 0, output: 0 },
13
- "nemotron-3.5-lightning-free": { input: 0, output: 0 },
14
- "muse-spark-1.2-contributor-free": { input: 0, output: 0 },
15
- // MiniMax
16
- "minimax-m3": { input: 0.3, output: 1.2 },
17
- "minimax-m2.7": { input: 0.3, output: 1.2 },
18
- "minimax-m2.5": { input: 0.3, output: 1.2 },
19
- // GLM
20
- "glm-5.2": { input: 1.4, output: 4.4 },
21
- "glm-5.1": { input: 1.4, output: 4.4 },
22
- "glm-5": { input: 1.0, output: 3.2 },
23
- "glm-5.3": { input: 1.4, output: 4.4 },
24
- // Kimi
25
- "kimi-k2.7-code": { input: 0.95, output: 4.0 },
26
- "kimi-k3": { input: 3.0, output: 15.0 },
27
- "kimi-k2.6": { input: 0.95, output: 4.0 },
28
- "kimi-k2.5": { input: 0.6, output: 3.0 },
29
- // Qwen
30
- "qwen3.7-max": { input: 2.5, output: 7.5 },
31
- "qwen3.7-plus": { input: 0.4, output: 1.6 },
32
- "qwen3.6-plus": { input: 0.5, output: 3.0 },
33
- "qwen3.5-plus": { input: 0.2, output: 1.2 },
34
- "qwen3.8-max": { input: 2.5, output: 7.5 },
35
- // DeepSeek (off-peak)
36
- "deepseek-v4-pro": { input: 0.66, output: 1.98 },
37
- "deepseek-v4-flash": { input: 0.22, output: 0.66 },
38
- // Claude
39
- "claude-fable-5": { input: 10, output: 50 },
40
- "claude-opus-5": { input: 5, output: 25 },
41
- "claude-opus-4-8": { input: 5, output: 25 },
42
- "claude-opus-4-7": { input: 5, output: 25 },
43
- "claude-opus-4-6": { input: 5, output: 25 },
44
- "claude-opus-4-5": { input: 5, output: 25 },
45
- "claude-sonnet-5": { input: 2, output: 10 },
46
- "claude-sonnet-4-6": { input: 3, output: 15 },
47
- "claude-sonnet-4-5": { input: 3, output: 15 },
48
- "claude-haiku-4-5": { input: 1, output: 5 },
49
- // Gemini
50
- "gemini-3.7-flash": { input: 1.5, output: 7.5 },
51
- "gemini-3.6-flash": { input: 1.5, output: 7.5 },
52
- "gemini-3.5-flash": { input: 1.5, output: 9.0 },
53
- "gemini-3.5-flash-lite": { input: 0.3, output: 2.5 },
54
- "gemini-3.1-pro": { input: 2, output: 12 },
55
- "gemini-3-flash": { input: 0.5, output: 3.0 },
56
- // Grok
57
- "grok-4.6": { input: 2, output: 6 },
58
- "grok-4.5": { input: 2, output: 6 },
59
- "grok-build-0.1": { input: 1, output: 2 },
60
- // Muse Spark
61
- "muse-spark-1.2": { input: 1.25, output: 4.25 },
62
- // GPT-5.x (Zen pricing; Go may differ)
63
- "gpt-5.6-sol": { input: 5, output: 30 },
64
- "gpt-5.6-terra": { input: 2, output: 12 },
65
- "gpt-5.6-luna": { input: 0.2, output: 1.2 },
66
- "gpt-5.5": { input: 5, output: 30 },
67
- "gpt-5.5-pro": { input: 30, output: 180 },
68
- "gpt-5.4": { input: 2.5, output: 15 },
69
- "gpt-5.4-pro": { input: 30, output: 180 },
70
- "gpt-5.4-mini": { input: 0.75, output: 4.5 },
71
- "gpt-5.4-nano": { input: 0.2, output: 1.25 },
72
- "gpt-5.3-codex": { input: 1.75, output: 14 },
73
- "gpt-5.3-codex-spark": { input: 1.75, output: 14 },
74
- "gpt-5.2": { input: 1.75, output: 14 },
75
- "gpt-5.2-codex": { input: 1.75, output: 14 },
76
- "gpt-5.1": { input: 1.07, output: 8.5 },
77
- "gpt-5.1-codex": { input: 1.07, output: 8.5 },
78
- "gpt-5.1-codex-max": { input: 1.25, output: 10 },
79
- "gpt-5.1-codex-mini": { input: 0.25, output: 2 },
80
- "gpt-5": { input: 1.07, output: 8.5 },
81
- "gpt-5-codex": { input: 1.07, output: 8.5 },
82
- "gpt-5-nano": { input: 0.05, output: 0.4 },
83
- };
84
- /** Provider prefixes stripped before a price lookup. */
85
- const PROVIDER_PREFIXES = ["opencode-go/", "opencode/", "openai/", "anthropic/"];
86
- /** Normalize a model id to its bare form for the price table lookup. */
87
- export function normalizeModelId(model) {
88
- let id = model.trim();
89
- for (const prefix of PROVIDER_PREFIXES) {
90
- if (id.startsWith(prefix)) {
91
- id = id.slice(prefix.length);
92
- break;
93
- }
94
- }
95
- // Strip a vendor path like qwen/qwen3.5-9b -> qwen3.5-9b (keeps bare ids).
96
- const parts = id.split("/");
97
- return parts[parts.length - 1];
98
- }
99
- /** Resolve the price for a model id. Overrides win, then the builtin table. */
100
- export function resolvePrice(model, config) {
101
- if (!config?.enabled)
102
- return undefined;
103
- const bare = normalizeModelId(model);
104
- const overrides = config.overrides ?? {};
105
- const direct = overrides[model] ?? overrides[bare];
106
- if (direct)
107
- return direct;
108
- return ZEN_PRICES[bare];
109
- }
110
- /**
111
- * Compute the cost in USD of a single call given its token usage and the
112
- * model price. Returns undefined when the model has no known price.
113
- */
114
- export function calculateCost(model, promptTokens, completionTokens, config) {
115
- const price = resolvePrice(model, config);
116
- if (!price)
117
- return undefined;
118
- return (promptTokens / 1_000_000) * price.input + (completionTokens / 1_000_000) * price.output;
119
- }
120
- /** Format a USD cost for display. Zero and very small amounts stay readable. */
121
- export function formatCost(cost) {
122
- if (cost === 0)
123
- return "$0.00";
124
- if (cost >= 0.01)
125
- return `$${cost.toFixed(2)}`;
126
- if (cost >= 0.0001)
127
- return `$${cost.toFixed(4)}`;
128
- return `$${cost.toFixed(6)}`;
129
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Heuristic detection of long-running (server/watch) commands.
3
- *
4
- * The explicit `background: true` bash parameter always wins; this list is a
5
- * convenience so dev servers don't block the agent. It only inspects the raw
6
- * shell command (a technical process-type decision, not task classification).
7
- */
8
- const LONG_RUNNING_PATTERNS = [
9
- /\b(npm|pnpm|yarn|bun|npx)\s+(run\s+)?(dev|start|serve|preview|watch|server)\b/i,
10
- /\b(deno|node)\s+.*\b(run\s+)?(dev|serve|watch|server)\b/i,
11
- /(^|\s)--watch\b/i,
12
- /(^|\s)-w\b/i,
13
- /\bnodemon\b/i,
14
- /\btsx watch\b/i,
15
- /\b(ts-node|tsc)\s+.*--watch\b/i,
16
- /\bvite(?!\s+(build|create))\b/i,
17
- /\bwebpack(-dev-server|\s+serve)\b/i,
18
- /\bastro dev\b/i,
19
- /\bnext (dev|start)\b/i,
20
- /\bnuxt (dev|start)\b/i,
21
- /\bsvelte-kit (dev|preview)\b/i,
22
- /\bgatsby develop\b/i,
23
- /\bdocker(-compose)?\s+.*\bup\b/i,
24
- /\buvicorn\b|\bgunicorn\b/i,
25
- /\bpython\s+-m\s+http\.server\b/i,
26
- /\bflask run\b/i,
27
- /\bphp artisan serve\b/i,
28
- /\brails (server|s)\b/i,
29
- /\bvitest watch\b/i,
30
- /\bjest --watch\b/i,
31
- ];
32
- export function isLongRunningCommand(command) {
33
- return LONG_RUNNING_PATTERNS.some((pattern) => pattern.test(command));
34
- }
@@ -1,2 +0,0 @@
1
- export { registerKillable, unregisterKillable, killByCallId } from "./runner";
2
- export { processRegistry } from "./registry";