workermill 0.3.0 → 0.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.
|
@@ -1,11 +1,1525 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
1
30
|
// node_modules/tsup/assets/esm_shims.js
|
|
2
31
|
import path from "path";
|
|
3
32
|
import { fileURLToPath } from "url";
|
|
4
|
-
var getFilename
|
|
5
|
-
var
|
|
6
|
-
|
|
33
|
+
var getFilename, getDirname, __dirname;
|
|
34
|
+
var init_esm_shims = __esm({
|
|
35
|
+
"node_modules/tsup/assets/esm_shims.js"() {
|
|
36
|
+
"use strict";
|
|
37
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
38
|
+
getDirname = () => path.dirname(getFilename());
|
|
39
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// ../api/src/config/pricing.js
|
|
44
|
+
var require_pricing = __commonJS({
|
|
45
|
+
"../api/src/config/pricing.js"(exports) {
|
|
46
|
+
"use strict";
|
|
47
|
+
init_esm_shims();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.ECS_FARGATE_SPOT_RATE_PER_HOUR = exports.MODEL_PRICING = void 0;
|
|
50
|
+
exports.getModelPricing = getModelPricing;
|
|
51
|
+
exports.calculateClaudeCost = calculateClaudeCost;
|
|
52
|
+
exports.calculateEcsCost = calculateEcsCost;
|
|
53
|
+
exports.calculateTotalCost = calculateTotalCost;
|
|
54
|
+
exports.formatCostUsd = formatCostUsd;
|
|
55
|
+
exports.MODEL_PRICING = {
|
|
56
|
+
// Haiku 4.5 (current default) - $1.00/$5.00 per MTok
|
|
57
|
+
"claude-haiku-4-5-20251001": {
|
|
58
|
+
input: 1e-3,
|
|
59
|
+
output: 5e-3,
|
|
60
|
+
cacheWrite: 125e-5,
|
|
61
|
+
// 1.25x input
|
|
62
|
+
cacheRead: 1e-4
|
|
63
|
+
// 0.1x input
|
|
64
|
+
},
|
|
65
|
+
// Haiku 3.5 (legacy alias - resolves to 4.5)
|
|
66
|
+
"claude-3-5-haiku-20241022": {
|
|
67
|
+
input: 1e-3,
|
|
68
|
+
output: 5e-3,
|
|
69
|
+
cacheWrite: 125e-5,
|
|
70
|
+
cacheRead: 1e-4
|
|
71
|
+
},
|
|
72
|
+
haiku: {
|
|
73
|
+
input: 1e-3,
|
|
74
|
+
output: 5e-3,
|
|
75
|
+
cacheWrite: 125e-5,
|
|
76
|
+
cacheRead: 1e-4
|
|
77
|
+
},
|
|
78
|
+
// Sonnet 4.6 (current balanced tier)
|
|
79
|
+
"claude-sonnet-4-6": {
|
|
80
|
+
input: 3e-3,
|
|
81
|
+
output: 0.015,
|
|
82
|
+
cacheWrite: 375e-5,
|
|
83
|
+
cacheRead: 3e-4
|
|
84
|
+
},
|
|
85
|
+
// Sonnet 4.5 (legacy)
|
|
86
|
+
"claude-sonnet-4-5-20250929": {
|
|
87
|
+
input: 3e-3,
|
|
88
|
+
output: 0.015,
|
|
89
|
+
cacheWrite: 375e-5,
|
|
90
|
+
cacheRead: 3e-4
|
|
91
|
+
},
|
|
92
|
+
// Sonnet 4 (legacy)
|
|
93
|
+
"claude-sonnet-4-20250514": {
|
|
94
|
+
input: 3e-3,
|
|
95
|
+
output: 0.015,
|
|
96
|
+
cacheWrite: 375e-5,
|
|
97
|
+
cacheRead: 3e-4
|
|
98
|
+
},
|
|
99
|
+
sonnet: {
|
|
100
|
+
input: 3e-3,
|
|
101
|
+
output: 0.015,
|
|
102
|
+
cacheWrite: 375e-5,
|
|
103
|
+
cacheRead: 3e-4
|
|
104
|
+
},
|
|
105
|
+
// Opus 4.6
|
|
106
|
+
"claude-opus-4-6": {
|
|
107
|
+
input: 5e-3,
|
|
108
|
+
output: 0.025,
|
|
109
|
+
cacheWrite: 625e-5,
|
|
110
|
+
cacheRead: 5e-4
|
|
111
|
+
},
|
|
112
|
+
// Opus 4.5 (legacy)
|
|
113
|
+
"claude-opus-4-5-20251101": {
|
|
114
|
+
input: 5e-3,
|
|
115
|
+
output: 0.025,
|
|
116
|
+
cacheWrite: 625e-5,
|
|
117
|
+
cacheRead: 5e-4
|
|
118
|
+
},
|
|
119
|
+
opus: {
|
|
120
|
+
input: 5e-3,
|
|
121
|
+
output: 0.025,
|
|
122
|
+
cacheWrite: 625e-5,
|
|
123
|
+
cacheRead: 5e-4
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var DEFAULT_PRICING = {
|
|
127
|
+
input: 3e-3,
|
|
128
|
+
output: 0.015,
|
|
129
|
+
cacheWrite: 375e-5,
|
|
130
|
+
cacheRead: 3e-4
|
|
131
|
+
};
|
|
132
|
+
exports.ECS_FARGATE_SPOT_RATE_PER_HOUR = 0.033;
|
|
133
|
+
function getModelPricing(model) {
|
|
134
|
+
if (exports.MODEL_PRICING[model]) {
|
|
135
|
+
return exports.MODEL_PRICING[model];
|
|
136
|
+
}
|
|
137
|
+
const modelLower = model.toLowerCase();
|
|
138
|
+
if (modelLower.includes("haiku")) {
|
|
139
|
+
return exports.MODEL_PRICING["haiku"];
|
|
140
|
+
}
|
|
141
|
+
if (modelLower.includes("opus")) {
|
|
142
|
+
return exports.MODEL_PRICING["opus"];
|
|
143
|
+
}
|
|
144
|
+
if (modelLower.includes("sonnet")) {
|
|
145
|
+
return exports.MODEL_PRICING["sonnet"];
|
|
146
|
+
}
|
|
147
|
+
return DEFAULT_PRICING;
|
|
148
|
+
}
|
|
149
|
+
function calculateClaudeCost(tokens, model) {
|
|
150
|
+
const rates = getModelPricing(model);
|
|
151
|
+
const inputCost = tokens.inputTokens / 1e3 * rates.input;
|
|
152
|
+
const outputCost = tokens.outputTokens / 1e3 * rates.output;
|
|
153
|
+
const cacheWriteCost = tokens.cacheCreationTokens / 1e3 * rates.cacheWrite;
|
|
154
|
+
const cacheReadCost = tokens.cacheReadTokens / 1e3 * rates.cacheRead;
|
|
155
|
+
return inputCost + outputCost + cacheWriteCost + cacheReadCost;
|
|
156
|
+
}
|
|
157
|
+
function calculateEcsCost(durationSeconds) {
|
|
158
|
+
return durationSeconds / 3600 * exports.ECS_FARGATE_SPOT_RATE_PER_HOUR;
|
|
159
|
+
}
|
|
160
|
+
function calculateTotalCost(tokens, model, durationSeconds) {
|
|
161
|
+
return calculateClaudeCost(tokens, model) + calculateEcsCost(durationSeconds);
|
|
162
|
+
}
|
|
163
|
+
function formatCostUsd(cost) {
|
|
164
|
+
return `$${cost.toFixed(4)}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ../api/src/providers/anthropic/pricing.js
|
|
170
|
+
var require_pricing2 = __commonJS({
|
|
171
|
+
"../api/src/providers/anthropic/pricing.js"(exports) {
|
|
172
|
+
"use strict";
|
|
173
|
+
init_esm_shims();
|
|
174
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
175
|
+
exports.AnthropicPricingEngine = void 0;
|
|
176
|
+
var pricing_js_1 = require_pricing();
|
|
177
|
+
var ANTHROPIC_MODELS = {
|
|
178
|
+
// Haiku 4.5 (budget tier) - $1.00/$5.00 per MTok
|
|
179
|
+
"claude-haiku-4-5-20251001": {
|
|
180
|
+
id: "claude-haiku-4-5-20251001",
|
|
181
|
+
displayName: "Claude Haiku 4.5",
|
|
182
|
+
tier: "budget",
|
|
183
|
+
inputRate: 1e-3,
|
|
184
|
+
outputRate: 5e-3,
|
|
185
|
+
cacheWriteRate: 125e-5,
|
|
186
|
+
// 1.25x input
|
|
187
|
+
cacheReadRate: 1e-4,
|
|
188
|
+
// 0.1x input
|
|
189
|
+
contextWindow: 2e5,
|
|
190
|
+
supportsStreaming: true,
|
|
191
|
+
supportsCaching: true
|
|
192
|
+
},
|
|
193
|
+
// Legacy Haiku 3.5 alias (resolves to 4.5 pricing)
|
|
194
|
+
"claude-3-5-haiku-20241022": {
|
|
195
|
+
id: "claude-3-5-haiku-20241022",
|
|
196
|
+
displayName: "Claude 3.5 Haiku",
|
|
197
|
+
tier: "budget",
|
|
198
|
+
inputRate: 1e-3,
|
|
199
|
+
outputRate: 5e-3,
|
|
200
|
+
cacheWriteRate: 125e-5,
|
|
201
|
+
cacheReadRate: 1e-4,
|
|
202
|
+
contextWindow: 2e5,
|
|
203
|
+
supportsStreaming: true,
|
|
204
|
+
supportsCaching: true
|
|
205
|
+
},
|
|
206
|
+
// Sonnet 4.6 (current balanced tier)
|
|
207
|
+
"claude-sonnet-4-6": {
|
|
208
|
+
id: "claude-sonnet-4-6",
|
|
209
|
+
displayName: "Claude Sonnet 4.6",
|
|
210
|
+
tier: "balanced",
|
|
211
|
+
inputRate: 3e-3,
|
|
212
|
+
outputRate: 0.015,
|
|
213
|
+
cacheWriteRate: 375e-5,
|
|
214
|
+
// 1.25x input
|
|
215
|
+
cacheReadRate: 3e-4,
|
|
216
|
+
// 0.1x input
|
|
217
|
+
contextWindow: 2e5,
|
|
218
|
+
supportsStreaming: true,
|
|
219
|
+
supportsCaching: true
|
|
220
|
+
},
|
|
221
|
+
// Sonnet 4.5 (legacy)
|
|
222
|
+
"claude-sonnet-4-5-20250929": {
|
|
223
|
+
id: "claude-sonnet-4-5-20250929",
|
|
224
|
+
displayName: "Claude Sonnet 4.5",
|
|
225
|
+
tier: "balanced",
|
|
226
|
+
inputRate: 3e-3,
|
|
227
|
+
outputRate: 0.015,
|
|
228
|
+
cacheWriteRate: 375e-5,
|
|
229
|
+
// 1.25x input
|
|
230
|
+
cacheReadRate: 3e-4,
|
|
231
|
+
// 0.1x input
|
|
232
|
+
contextWindow: 2e5,
|
|
233
|
+
supportsStreaming: true,
|
|
234
|
+
supportsCaching: true
|
|
235
|
+
},
|
|
236
|
+
// Sonnet 4 (legacy)
|
|
237
|
+
"claude-sonnet-4-20250514": {
|
|
238
|
+
id: "claude-sonnet-4-20250514",
|
|
239
|
+
displayName: "Claude Sonnet 4",
|
|
240
|
+
tier: "balanced",
|
|
241
|
+
inputRate: 3e-3,
|
|
242
|
+
outputRate: 0.015,
|
|
243
|
+
cacheWriteRate: 375e-5,
|
|
244
|
+
cacheReadRate: 3e-4,
|
|
245
|
+
contextWindow: 2e5,
|
|
246
|
+
supportsStreaming: true,
|
|
247
|
+
supportsCaching: true
|
|
248
|
+
},
|
|
249
|
+
// Opus 4.6 (powerful tier)
|
|
250
|
+
"claude-opus-4-6": {
|
|
251
|
+
id: "claude-opus-4-6",
|
|
252
|
+
displayName: "Claude Opus 4.6",
|
|
253
|
+
tier: "powerful",
|
|
254
|
+
inputRate: 5e-3,
|
|
255
|
+
outputRate: 0.025,
|
|
256
|
+
cacheWriteRate: 625e-5,
|
|
257
|
+
// 1.25x input
|
|
258
|
+
cacheReadRate: 5e-4,
|
|
259
|
+
// 0.1x input
|
|
260
|
+
contextWindow: 2e5,
|
|
261
|
+
supportsStreaming: true,
|
|
262
|
+
supportsCaching: true
|
|
263
|
+
},
|
|
264
|
+
// Opus 4.5 (legacy powerful tier)
|
|
265
|
+
"claude-opus-4-5-20251101": {
|
|
266
|
+
id: "claude-opus-4-5-20251101",
|
|
267
|
+
displayName: "Claude Opus 4.5",
|
|
268
|
+
tier: "powerful",
|
|
269
|
+
inputRate: 5e-3,
|
|
270
|
+
outputRate: 0.025,
|
|
271
|
+
cacheWriteRate: 625e-5,
|
|
272
|
+
// 1.25x input
|
|
273
|
+
cacheReadRate: 5e-4,
|
|
274
|
+
// 0.1x input
|
|
275
|
+
contextWindow: 2e5,
|
|
276
|
+
supportsStreaming: true,
|
|
277
|
+
supportsCaching: true
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var MODEL_ALIASES = {
|
|
281
|
+
haiku: "claude-haiku-4-5-20251001",
|
|
282
|
+
sonnet: "claude-sonnet-4-6",
|
|
283
|
+
opus: "claude-opus-4-6"
|
|
284
|
+
};
|
|
285
|
+
var DEFAULT_MODEL_INFO = {
|
|
286
|
+
id: "default",
|
|
287
|
+
displayName: "Unknown Claude Model",
|
|
288
|
+
tier: "balanced",
|
|
289
|
+
inputRate: 3e-3,
|
|
290
|
+
outputRate: 0.015,
|
|
291
|
+
cacheWriteRate: 375e-5,
|
|
292
|
+
cacheReadRate: 3e-4,
|
|
293
|
+
contextWindow: 2e5,
|
|
294
|
+
supportsStreaming: true,
|
|
295
|
+
supportsCaching: true
|
|
296
|
+
};
|
|
297
|
+
var AnthropicPricingEngine = class {
|
|
298
|
+
provider = "anthropic";
|
|
299
|
+
getModels() {
|
|
300
|
+
return Object.values(ANTHROPIC_MODELS);
|
|
301
|
+
}
|
|
302
|
+
getModelInfo(modelId) {
|
|
303
|
+
if (ANTHROPIC_MODELS[modelId]) {
|
|
304
|
+
return ANTHROPIC_MODELS[modelId];
|
|
305
|
+
}
|
|
306
|
+
const aliasedId = MODEL_ALIASES[modelId.toLowerCase()];
|
|
307
|
+
if (aliasedId && ANTHROPIC_MODELS[aliasedId]) {
|
|
308
|
+
return ANTHROPIC_MODELS[aliasedId];
|
|
309
|
+
}
|
|
310
|
+
const modelLower = modelId.toLowerCase();
|
|
311
|
+
if (modelLower.includes("haiku")) {
|
|
312
|
+
return ANTHROPIC_MODELS["claude-haiku-4-5-20251001"];
|
|
313
|
+
}
|
|
314
|
+
if (modelLower.includes("opus")) {
|
|
315
|
+
return ANTHROPIC_MODELS["claude-opus-4-6"];
|
|
316
|
+
}
|
|
317
|
+
if (modelLower.includes("sonnet")) {
|
|
318
|
+
return ANTHROPIC_MODELS["claude-sonnet-4-6"];
|
|
319
|
+
}
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
validateModel(model) {
|
|
323
|
+
return this.getModelInfo(model) !== void 0;
|
|
324
|
+
}
|
|
325
|
+
calculateTokenCost(tokens, model) {
|
|
326
|
+
const modelInfo = this.getModelInfo(model) || DEFAULT_MODEL_INFO;
|
|
327
|
+
const inputCost = tokens.inputTokens / 1e3 * modelInfo.inputRate;
|
|
328
|
+
const outputCost = tokens.outputTokens / 1e3 * modelInfo.outputRate;
|
|
329
|
+
let cacheCost = 0;
|
|
330
|
+
if (modelInfo.cacheWriteRate && tokens.cacheCreationTokens) {
|
|
331
|
+
cacheCost += tokens.cacheCreationTokens / 1e3 * modelInfo.cacheWriteRate;
|
|
332
|
+
}
|
|
333
|
+
if (modelInfo.cacheReadRate && tokens.cacheReadTokens) {
|
|
334
|
+
cacheCost += tokens.cacheReadTokens / 1e3 * modelInfo.cacheReadRate;
|
|
335
|
+
}
|
|
336
|
+
return inputCost + outputCost + cacheCost;
|
|
337
|
+
}
|
|
338
|
+
calculateTotalCost(tokens, model, durationSeconds) {
|
|
339
|
+
const tokenCost = this.calculateTokenCost(tokens, model);
|
|
340
|
+
const computeCost = durationSeconds / 3600 * pricing_js_1.ECS_FARGATE_SPOT_RATE_PER_HOUR;
|
|
341
|
+
return tokenCost + computeCost;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
exports.AnthropicPricingEngine = AnthropicPricingEngine;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// ../api/src/providers/openai/pricing.js
|
|
349
|
+
var require_pricing3 = __commonJS({
|
|
350
|
+
"../api/src/providers/openai/pricing.js"(exports) {
|
|
351
|
+
"use strict";
|
|
352
|
+
init_esm_shims();
|
|
353
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
354
|
+
exports.OpenAIPricingEngine = void 0;
|
|
355
|
+
var pricing_js_1 = require_pricing();
|
|
356
|
+
var OPENAI_MODELS = {
|
|
357
|
+
// GPT-4o (flagship model)
|
|
358
|
+
"gpt-4o": {
|
|
359
|
+
id: "gpt-4o",
|
|
360
|
+
displayName: "GPT-4o",
|
|
361
|
+
tier: "powerful",
|
|
362
|
+
inputRate: 25e-4,
|
|
363
|
+
// $2.50 per 1M = $0.0025 per 1K
|
|
364
|
+
outputRate: 0.01,
|
|
365
|
+
// $10 per 1M = $0.01 per 1K
|
|
366
|
+
contextWindow: 128e3,
|
|
367
|
+
supportsStreaming: true,
|
|
368
|
+
supportsCaching: false
|
|
369
|
+
},
|
|
370
|
+
// GPT-4o mini (efficient version)
|
|
371
|
+
"gpt-4o-mini": {
|
|
372
|
+
id: "gpt-4o-mini",
|
|
373
|
+
displayName: "GPT-4o Mini",
|
|
374
|
+
tier: "budget",
|
|
375
|
+
inputRate: 15e-5,
|
|
376
|
+
// $0.15 per 1M
|
|
377
|
+
outputRate: 6e-4,
|
|
378
|
+
// $0.60 per 1M
|
|
379
|
+
contextWindow: 128e3,
|
|
380
|
+
supportsStreaming: true,
|
|
381
|
+
supportsCaching: false
|
|
382
|
+
},
|
|
383
|
+
// GPT-4 Turbo (legacy but still available)
|
|
384
|
+
"gpt-4-turbo": {
|
|
385
|
+
id: "gpt-4-turbo",
|
|
386
|
+
displayName: "GPT-4 Turbo",
|
|
387
|
+
tier: "balanced",
|
|
388
|
+
inputRate: 0.01,
|
|
389
|
+
// $10 per 1M
|
|
390
|
+
outputRate: 0.03,
|
|
391
|
+
// $30 per 1M
|
|
392
|
+
contextWindow: 128e3,
|
|
393
|
+
supportsStreaming: true,
|
|
394
|
+
supportsCaching: false
|
|
395
|
+
},
|
|
396
|
+
// o1 (reasoning model)
|
|
397
|
+
o1: {
|
|
398
|
+
id: "o1",
|
|
399
|
+
displayName: "o1",
|
|
400
|
+
tier: "powerful",
|
|
401
|
+
inputRate: 0.015,
|
|
402
|
+
// $15 per 1M
|
|
403
|
+
outputRate: 0.06,
|
|
404
|
+
// $60 per 1M
|
|
405
|
+
// o1 has "cached" pricing but we track it separately
|
|
406
|
+
cacheReadRate: 75e-4,
|
|
407
|
+
// $7.50 per 1M (cached input)
|
|
408
|
+
contextWindow: 2e5,
|
|
409
|
+
supportsStreaming: false,
|
|
410
|
+
// o1 does not support streaming
|
|
411
|
+
supportsCaching: true
|
|
412
|
+
},
|
|
413
|
+
// o1-mini (smaller reasoning model)
|
|
414
|
+
"o1-mini": {
|
|
415
|
+
id: "o1-mini",
|
|
416
|
+
displayName: "o1 Mini",
|
|
417
|
+
tier: "budget",
|
|
418
|
+
inputRate: 3e-3,
|
|
419
|
+
// $3 per 1M
|
|
420
|
+
outputRate: 0.012,
|
|
421
|
+
// $12 per 1M
|
|
422
|
+
cacheReadRate: 15e-4,
|
|
423
|
+
// $1.50 per 1M (cached input)
|
|
424
|
+
contextWindow: 128e3,
|
|
425
|
+
supportsStreaming: false,
|
|
426
|
+
supportsCaching: true
|
|
427
|
+
},
|
|
428
|
+
// o1-pro (enhanced reasoning)
|
|
429
|
+
"o1-pro": {
|
|
430
|
+
id: "o1-pro",
|
|
431
|
+
displayName: "o1 Pro",
|
|
432
|
+
tier: "powerful",
|
|
433
|
+
inputRate: 0.15,
|
|
434
|
+
// $150 per 1M
|
|
435
|
+
outputRate: 0.6,
|
|
436
|
+
// $600 per 1M
|
|
437
|
+
contextWindow: 2e5,
|
|
438
|
+
supportsStreaming: false,
|
|
439
|
+
supportsCaching: false
|
|
440
|
+
},
|
|
441
|
+
// GPT-5 models (Responses API - 500K TPM)
|
|
442
|
+
// Pricing from OpenAI: https://platform.openai.com/docs/pricing
|
|
443
|
+
"gpt-5": {
|
|
444
|
+
id: "gpt-5",
|
|
445
|
+
displayName: "GPT-5",
|
|
446
|
+
tier: "powerful",
|
|
447
|
+
inputRate: 125e-5,
|
|
448
|
+
// $1.25 per 1M
|
|
449
|
+
outputRate: 0.01,
|
|
450
|
+
// $10 per 1M
|
|
451
|
+
cacheReadRate: 125e-6,
|
|
452
|
+
// $0.125 per 1M (cached input)
|
|
453
|
+
contextWindow: 128e3,
|
|
454
|
+
supportsStreaming: false,
|
|
455
|
+
supportsCaching: true
|
|
456
|
+
},
|
|
457
|
+
"gpt-5-mini": {
|
|
458
|
+
id: "gpt-5-mini",
|
|
459
|
+
displayName: "GPT-5 Mini",
|
|
460
|
+
tier: "budget",
|
|
461
|
+
inputRate: 25e-5,
|
|
462
|
+
// $0.25 per 1M
|
|
463
|
+
outputRate: 2e-3,
|
|
464
|
+
// $2 per 1M
|
|
465
|
+
cacheReadRate: 25e-6,
|
|
466
|
+
// $0.025 per 1M
|
|
467
|
+
contextWindow: 128e3,
|
|
468
|
+
supportsStreaming: false,
|
|
469
|
+
supportsCaching: true
|
|
470
|
+
},
|
|
471
|
+
"gpt-5-nano": {
|
|
472
|
+
id: "gpt-5-nano",
|
|
473
|
+
displayName: "GPT-5 Nano",
|
|
474
|
+
tier: "budget",
|
|
475
|
+
inputRate: 5e-5,
|
|
476
|
+
// $0.05 per 1M
|
|
477
|
+
outputRate: 4e-4,
|
|
478
|
+
// $0.40 per 1M
|
|
479
|
+
cacheReadRate: 5e-6,
|
|
480
|
+
// $0.005 per 1M
|
|
481
|
+
contextWindow: 128e3,
|
|
482
|
+
supportsStreaming: false,
|
|
483
|
+
supportsCaching: true
|
|
484
|
+
},
|
|
485
|
+
"gpt-5.1-codex": {
|
|
486
|
+
id: "gpt-5.1-codex",
|
|
487
|
+
displayName: "GPT-5.1 Codex",
|
|
488
|
+
tier: "powerful",
|
|
489
|
+
inputRate: 125e-5,
|
|
490
|
+
// $1.25 per 1M
|
|
491
|
+
outputRate: 0.01,
|
|
492
|
+
// $10 per 1M
|
|
493
|
+
cacheReadRate: 125e-6,
|
|
494
|
+
// $0.125 per 1M
|
|
495
|
+
contextWindow: 128e3,
|
|
496
|
+
supportsStreaming: false,
|
|
497
|
+
supportsCaching: true
|
|
498
|
+
},
|
|
499
|
+
"gpt-5.1-codex-max": {
|
|
500
|
+
id: "gpt-5.1-codex-max",
|
|
501
|
+
displayName: "GPT-5.1 Codex Max",
|
|
502
|
+
tier: "powerful",
|
|
503
|
+
inputRate: 125e-5,
|
|
504
|
+
// $1.25 per 1M
|
|
505
|
+
outputRate: 0.01,
|
|
506
|
+
// $10 per 1M
|
|
507
|
+
cacheReadRate: 125e-6,
|
|
508
|
+
// $0.125 per 1M
|
|
509
|
+
contextWindow: 2e5,
|
|
510
|
+
supportsStreaming: false,
|
|
511
|
+
supportsCaching: true
|
|
512
|
+
},
|
|
513
|
+
"gpt-5.2-codex": {
|
|
514
|
+
id: "gpt-5.2-codex",
|
|
515
|
+
displayName: "GPT-5.2 Codex",
|
|
516
|
+
tier: "powerful",
|
|
517
|
+
inputRate: 175e-5,
|
|
518
|
+
// $1.75 per 1M
|
|
519
|
+
outputRate: 0.014,
|
|
520
|
+
// $14 per 1M
|
|
521
|
+
cacheReadRate: 175e-6,
|
|
522
|
+
// $0.175 per 1M
|
|
523
|
+
contextWindow: 128e3,
|
|
524
|
+
supportsStreaming: false,
|
|
525
|
+
supportsCaching: true
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
var MODEL_ALIASES = {
|
|
529
|
+
"gpt4o": "gpt-4o",
|
|
530
|
+
"gpt-4-o": "gpt-4o",
|
|
531
|
+
"gpt4": "gpt-4-turbo"
|
|
532
|
+
};
|
|
533
|
+
var OpenAIPricingEngine = class {
|
|
534
|
+
provider = "openai";
|
|
535
|
+
getModels() {
|
|
536
|
+
return Object.values(OPENAI_MODELS);
|
|
537
|
+
}
|
|
538
|
+
getModelInfo(modelId) {
|
|
539
|
+
if (OPENAI_MODELS[modelId]) {
|
|
540
|
+
return OPENAI_MODELS[modelId];
|
|
541
|
+
}
|
|
542
|
+
const aliasedId = MODEL_ALIASES[modelId.toLowerCase()];
|
|
543
|
+
if (aliasedId && OPENAI_MODELS[aliasedId]) {
|
|
544
|
+
return OPENAI_MODELS[aliasedId];
|
|
545
|
+
}
|
|
546
|
+
return void 0;
|
|
547
|
+
}
|
|
548
|
+
validateModel(model) {
|
|
549
|
+
return this.getModelInfo(model) !== void 0;
|
|
550
|
+
}
|
|
551
|
+
calculateTokenCost(tokens, model) {
|
|
552
|
+
const modelInfo = this.getModelInfo(model);
|
|
553
|
+
if (!modelInfo) {
|
|
554
|
+
return 0;
|
|
555
|
+
}
|
|
556
|
+
const inputCost = tokens.inputTokens / 1e3 * modelInfo.inputRate;
|
|
557
|
+
const outputCost = tokens.outputTokens / 1e3 * modelInfo.outputRate;
|
|
558
|
+
let cacheCost = 0;
|
|
559
|
+
if (modelInfo.cacheReadRate && tokens.cacheReadTokens) {
|
|
560
|
+
cacheCost = tokens.cacheReadTokens / 1e3 * modelInfo.cacheReadRate;
|
|
561
|
+
}
|
|
562
|
+
return inputCost + outputCost + cacheCost;
|
|
563
|
+
}
|
|
564
|
+
calculateTotalCost(tokens, model, durationSeconds) {
|
|
565
|
+
const tokenCost = this.calculateTokenCost(tokens, model);
|
|
566
|
+
const computeCost = durationSeconds / 3600 * pricing_js_1.ECS_FARGATE_SPOT_RATE_PER_HOUR;
|
|
567
|
+
return tokenCost + computeCost;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
exports.OpenAIPricingEngine = OpenAIPricingEngine;
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// ../api/src/providers/google/pricing.js
|
|
575
|
+
var require_pricing4 = __commonJS({
|
|
576
|
+
"../api/src/providers/google/pricing.js"(exports) {
|
|
577
|
+
"use strict";
|
|
578
|
+
init_esm_shims();
|
|
579
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
580
|
+
exports.GooglePricingEngine = void 0;
|
|
581
|
+
var pricing_js_1 = require_pricing();
|
|
582
|
+
var GOOGLE_MODELS = {
|
|
583
|
+
// Gemini 2.5 Pro (latest powerful model) - $1.25/$5.00 per MTok (≤200K context)
|
|
584
|
+
"gemini-2.5-pro": {
|
|
585
|
+
id: "gemini-2.5-pro",
|
|
586
|
+
displayName: "Gemini 2.5 Pro",
|
|
587
|
+
tier: "powerful",
|
|
588
|
+
inputRate: 125e-5,
|
|
589
|
+
// $1.25 per 1M
|
|
590
|
+
outputRate: 5e-3,
|
|
591
|
+
// $5 per 1M
|
|
592
|
+
cacheReadRate: 3125e-7,
|
|
593
|
+
// 25% of input rate for cached
|
|
594
|
+
contextWindow: 1e6,
|
|
595
|
+
supportsStreaming: true,
|
|
596
|
+
supportsCaching: true
|
|
597
|
+
},
|
|
598
|
+
// Gemini 2.5 Flash (latest balanced model) - $0.30/$2.50 per MTok
|
|
599
|
+
"gemini-2.5-flash": {
|
|
600
|
+
id: "gemini-2.5-flash",
|
|
601
|
+
displayName: "Gemini 2.5 Flash",
|
|
602
|
+
tier: "balanced",
|
|
603
|
+
inputRate: 3e-4,
|
|
604
|
+
// $0.30 per 1M
|
|
605
|
+
outputRate: 25e-4,
|
|
606
|
+
// $2.50 per 1M
|
|
607
|
+
cacheReadRate: 75e-6,
|
|
608
|
+
// 25% of input rate for cached
|
|
609
|
+
contextWindow: 1e6,
|
|
610
|
+
supportsStreaming: true,
|
|
611
|
+
supportsCaching: true
|
|
612
|
+
},
|
|
613
|
+
// Gemini 2.0 Flash (fast model) - $0.10/$0.40 per MTok
|
|
614
|
+
"gemini-2.0-flash": {
|
|
615
|
+
id: "gemini-2.0-flash",
|
|
616
|
+
displayName: "Gemini 2.0 Flash",
|
|
617
|
+
tier: "balanced",
|
|
618
|
+
inputRate: 1e-4,
|
|
619
|
+
// $0.10 per 1M
|
|
620
|
+
outputRate: 4e-4,
|
|
621
|
+
// $0.40 per 1M
|
|
622
|
+
cacheReadRate: 25e-6,
|
|
623
|
+
// 25% of input rate for cached
|
|
624
|
+
contextWindow: 1e6,
|
|
625
|
+
supportsStreaming: true,
|
|
626
|
+
supportsCaching: true
|
|
627
|
+
},
|
|
628
|
+
// Gemini 2.0 Flash Thinking (experimental reasoning)
|
|
629
|
+
"gemini-2.0-flash-thinking-exp": {
|
|
630
|
+
id: "gemini-2.0-flash-thinking-exp",
|
|
631
|
+
displayName: "Gemini 2.0 Flash Thinking",
|
|
632
|
+
tier: "balanced",
|
|
633
|
+
// Experimental model - using flash pricing as baseline
|
|
634
|
+
inputRate: 75e-6,
|
|
635
|
+
outputRate: 3e-4,
|
|
636
|
+
contextWindow: 1e6,
|
|
637
|
+
supportsStreaming: true,
|
|
638
|
+
supportsCaching: true
|
|
639
|
+
},
|
|
640
|
+
// Gemini 1.5 Flash (previous generation fast)
|
|
641
|
+
"gemini-1.5-flash": {
|
|
642
|
+
id: "gemini-1.5-flash",
|
|
643
|
+
displayName: "Gemini 1.5 Flash",
|
|
644
|
+
tier: "budget",
|
|
645
|
+
inputRate: 75e-6,
|
|
646
|
+
// $0.075 per 1M
|
|
647
|
+
outputRate: 3e-4,
|
|
648
|
+
// $0.30 per 1M
|
|
649
|
+
cacheReadRate: 1875e-8,
|
|
650
|
+
contextWindow: 1e6,
|
|
651
|
+
supportsStreaming: true,
|
|
652
|
+
supportsCaching: true
|
|
653
|
+
},
|
|
654
|
+
// Gemini 1.5 Pro (powerful model)
|
|
655
|
+
"gemini-1.5-pro": {
|
|
656
|
+
id: "gemini-1.5-pro",
|
|
657
|
+
displayName: "Gemini 1.5 Pro",
|
|
658
|
+
tier: "powerful",
|
|
659
|
+
inputRate: 125e-5,
|
|
660
|
+
// $1.25 per 1M
|
|
661
|
+
outputRate: 5e-3,
|
|
662
|
+
// $5 per 1M
|
|
663
|
+
cacheReadRate: 3125e-7,
|
|
664
|
+
// 25% of input rate for cached
|
|
665
|
+
contextWindow: 2e6,
|
|
666
|
+
// 2M context window!
|
|
667
|
+
supportsStreaming: true,
|
|
668
|
+
supportsCaching: true
|
|
669
|
+
},
|
|
670
|
+
// Gemini 1.0 Pro (legacy)
|
|
671
|
+
"gemini-1.0-pro": {
|
|
672
|
+
id: "gemini-1.0-pro",
|
|
673
|
+
displayName: "Gemini 1.0 Pro",
|
|
674
|
+
tier: "budget",
|
|
675
|
+
inputRate: 5e-4,
|
|
676
|
+
// $0.50 per 1M
|
|
677
|
+
outputRate: 15e-4,
|
|
678
|
+
// $1.50 per 1M
|
|
679
|
+
contextWindow: 32e3,
|
|
680
|
+
supportsStreaming: true,
|
|
681
|
+
supportsCaching: false
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var MODEL_ALIASES = {
|
|
685
|
+
"gemini-flash": "gemini-2.5-flash",
|
|
686
|
+
"gemini-pro": "gemini-2.5-pro",
|
|
687
|
+
flash: "gemini-2.5-flash",
|
|
688
|
+
pro: "gemini-2.5-pro"
|
|
689
|
+
};
|
|
690
|
+
var GooglePricingEngine = class {
|
|
691
|
+
provider = "google";
|
|
692
|
+
getModels() {
|
|
693
|
+
return Object.values(GOOGLE_MODELS);
|
|
694
|
+
}
|
|
695
|
+
getModelInfo(modelId) {
|
|
696
|
+
if (GOOGLE_MODELS[modelId]) {
|
|
697
|
+
return GOOGLE_MODELS[modelId];
|
|
698
|
+
}
|
|
699
|
+
const aliasedId = MODEL_ALIASES[modelId.toLowerCase()];
|
|
700
|
+
if (aliasedId && GOOGLE_MODELS[aliasedId]) {
|
|
701
|
+
return GOOGLE_MODELS[aliasedId];
|
|
702
|
+
}
|
|
703
|
+
const modelLower = modelId.toLowerCase();
|
|
704
|
+
if (modelLower.includes("flash") && modelLower.includes("2.5")) {
|
|
705
|
+
return GOOGLE_MODELS["gemini-2.5-flash"];
|
|
706
|
+
}
|
|
707
|
+
if (modelLower.includes("flash") && modelLower.includes("2.0")) {
|
|
708
|
+
return GOOGLE_MODELS["gemini-2.0-flash"];
|
|
709
|
+
}
|
|
710
|
+
if (modelLower.includes("flash")) {
|
|
711
|
+
return GOOGLE_MODELS["gemini-2.5-flash"];
|
|
712
|
+
}
|
|
713
|
+
if (modelLower.includes("pro") && modelLower.includes("2.5")) {
|
|
714
|
+
return GOOGLE_MODELS["gemini-2.5-pro"];
|
|
715
|
+
}
|
|
716
|
+
if (modelLower.includes("pro") && modelLower.includes("1.5")) {
|
|
717
|
+
return GOOGLE_MODELS["gemini-1.5-pro"];
|
|
718
|
+
}
|
|
719
|
+
if (modelLower.includes("pro")) {
|
|
720
|
+
return GOOGLE_MODELS["gemini-2.5-pro"];
|
|
721
|
+
}
|
|
722
|
+
return void 0;
|
|
723
|
+
}
|
|
724
|
+
validateModel(model) {
|
|
725
|
+
return this.getModelInfo(model) !== void 0;
|
|
726
|
+
}
|
|
727
|
+
calculateTokenCost(tokens, model) {
|
|
728
|
+
const modelInfo = this.getModelInfo(model);
|
|
729
|
+
if (!modelInfo) {
|
|
730
|
+
return 0;
|
|
731
|
+
}
|
|
732
|
+
const inputCost = tokens.inputTokens / 1e3 * modelInfo.inputRate;
|
|
733
|
+
const outputCost = tokens.outputTokens / 1e3 * modelInfo.outputRate;
|
|
734
|
+
let cacheCost = 0;
|
|
735
|
+
if (modelInfo.cacheReadRate && tokens.cacheReadTokens) {
|
|
736
|
+
cacheCost = tokens.cacheReadTokens / 1e3 * modelInfo.cacheReadRate;
|
|
737
|
+
}
|
|
738
|
+
return inputCost + outputCost + cacheCost;
|
|
739
|
+
}
|
|
740
|
+
calculateTotalCost(tokens, model, durationSeconds) {
|
|
741
|
+
const tokenCost = this.calculateTokenCost(tokens, model);
|
|
742
|
+
const computeCost = durationSeconds / 3600 * pricing_js_1.ECS_FARGATE_SPOT_RATE_PER_HOUR;
|
|
743
|
+
return tokenCost + computeCost;
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
exports.GooglePricingEngine = GooglePricingEngine;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// ../api/src/providers/ollama/pricing.js
|
|
751
|
+
var require_pricing5 = __commonJS({
|
|
752
|
+
"../api/src/providers/ollama/pricing.js"(exports) {
|
|
753
|
+
"use strict";
|
|
754
|
+
init_esm_shims();
|
|
755
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
756
|
+
exports.OllamaPricingEngine = void 0;
|
|
757
|
+
var pricing_js_1 = require_pricing();
|
|
758
|
+
var OLLAMA_MODELS = {
|
|
759
|
+
// Llama 3.1 variants
|
|
760
|
+
"llama3.1:8b": {
|
|
761
|
+
id: "llama3.1:8b",
|
|
762
|
+
displayName: "Llama 3.1 8B",
|
|
763
|
+
tier: "budget",
|
|
764
|
+
inputRate: 0,
|
|
765
|
+
// Free - local model
|
|
766
|
+
outputRate: 0,
|
|
767
|
+
contextWindow: 128e3,
|
|
768
|
+
supportsStreaming: true,
|
|
769
|
+
supportsCaching: false
|
|
770
|
+
},
|
|
771
|
+
"llama3.1:70b": {
|
|
772
|
+
id: "llama3.1:70b",
|
|
773
|
+
displayName: "Llama 3.1 70B",
|
|
774
|
+
tier: "balanced",
|
|
775
|
+
inputRate: 0,
|
|
776
|
+
outputRate: 0,
|
|
777
|
+
contextWindow: 128e3,
|
|
778
|
+
supportsStreaming: true,
|
|
779
|
+
supportsCaching: false
|
|
780
|
+
},
|
|
781
|
+
"llama3.1:405b": {
|
|
782
|
+
id: "llama3.1:405b",
|
|
783
|
+
displayName: "Llama 3.1 405B",
|
|
784
|
+
tier: "powerful",
|
|
785
|
+
inputRate: 0,
|
|
786
|
+
outputRate: 0,
|
|
787
|
+
contextWindow: 128e3,
|
|
788
|
+
supportsStreaming: true,
|
|
789
|
+
supportsCaching: false
|
|
790
|
+
},
|
|
791
|
+
// Llama 3.2 variants
|
|
792
|
+
"llama3.2:1b": {
|
|
793
|
+
id: "llama3.2:1b",
|
|
794
|
+
displayName: "Llama 3.2 1B",
|
|
795
|
+
tier: "budget",
|
|
796
|
+
inputRate: 0,
|
|
797
|
+
outputRate: 0,
|
|
798
|
+
contextWindow: 128e3,
|
|
799
|
+
supportsStreaming: true,
|
|
800
|
+
supportsCaching: false
|
|
801
|
+
},
|
|
802
|
+
"llama3.2:3b": {
|
|
803
|
+
id: "llama3.2:3b",
|
|
804
|
+
displayName: "Llama 3.2 3B",
|
|
805
|
+
tier: "budget",
|
|
806
|
+
inputRate: 0,
|
|
807
|
+
outputRate: 0,
|
|
808
|
+
contextWindow: 128e3,
|
|
809
|
+
supportsStreaming: true,
|
|
810
|
+
supportsCaching: false
|
|
811
|
+
},
|
|
812
|
+
// Code Llama variants
|
|
813
|
+
"codellama:7b": {
|
|
814
|
+
id: "codellama:7b",
|
|
815
|
+
displayName: "Code Llama 7B",
|
|
816
|
+
tier: "budget",
|
|
817
|
+
inputRate: 0,
|
|
818
|
+
outputRate: 0,
|
|
819
|
+
contextWindow: 16e3,
|
|
820
|
+
supportsStreaming: true,
|
|
821
|
+
supportsCaching: false
|
|
822
|
+
},
|
|
823
|
+
"codellama:13b": {
|
|
824
|
+
id: "codellama:13b",
|
|
825
|
+
displayName: "Code Llama 13B",
|
|
826
|
+
tier: "balanced",
|
|
827
|
+
inputRate: 0,
|
|
828
|
+
outputRate: 0,
|
|
829
|
+
contextWindow: 16e3,
|
|
830
|
+
supportsStreaming: true,
|
|
831
|
+
supportsCaching: false
|
|
832
|
+
},
|
|
833
|
+
"codellama:34b": {
|
|
834
|
+
id: "codellama:34b",
|
|
835
|
+
displayName: "Code Llama 34B",
|
|
836
|
+
tier: "balanced",
|
|
837
|
+
inputRate: 0,
|
|
838
|
+
outputRate: 0,
|
|
839
|
+
contextWindow: 16e3,
|
|
840
|
+
supportsStreaming: true,
|
|
841
|
+
supportsCaching: false
|
|
842
|
+
},
|
|
843
|
+
// Mistral variants
|
|
844
|
+
"mistral:7b": {
|
|
845
|
+
id: "mistral:7b",
|
|
846
|
+
displayName: "Mistral 7B",
|
|
847
|
+
tier: "budget",
|
|
848
|
+
inputRate: 0,
|
|
849
|
+
outputRate: 0,
|
|
850
|
+
contextWindow: 32e3,
|
|
851
|
+
supportsStreaming: true,
|
|
852
|
+
supportsCaching: false
|
|
853
|
+
},
|
|
854
|
+
"mixtral:8x7b": {
|
|
855
|
+
id: "mixtral:8x7b",
|
|
856
|
+
displayName: "Mixtral 8x7B",
|
|
857
|
+
tier: "balanced",
|
|
858
|
+
inputRate: 0,
|
|
859
|
+
outputRate: 0,
|
|
860
|
+
contextWindow: 32e3,
|
|
861
|
+
supportsStreaming: true,
|
|
862
|
+
supportsCaching: false
|
|
863
|
+
},
|
|
864
|
+
// DeepSeek Coder
|
|
865
|
+
"deepseek-coder:6.7b": {
|
|
866
|
+
id: "deepseek-coder:6.7b",
|
|
867
|
+
displayName: "DeepSeek Coder 6.7B",
|
|
868
|
+
tier: "budget",
|
|
869
|
+
inputRate: 0,
|
|
870
|
+
outputRate: 0,
|
|
871
|
+
contextWindow: 16e3,
|
|
872
|
+
supportsStreaming: true,
|
|
873
|
+
supportsCaching: false
|
|
874
|
+
},
|
|
875
|
+
"deepseek-coder:33b": {
|
|
876
|
+
id: "deepseek-coder:33b",
|
|
877
|
+
displayName: "DeepSeek Coder 33B",
|
|
878
|
+
tier: "balanced",
|
|
879
|
+
inputRate: 0,
|
|
880
|
+
outputRate: 0,
|
|
881
|
+
contextWindow: 16e3,
|
|
882
|
+
supportsStreaming: true,
|
|
883
|
+
supportsCaching: false
|
|
884
|
+
},
|
|
885
|
+
// Qwen variants
|
|
886
|
+
"qwen2.5-coder:7b": {
|
|
887
|
+
id: "qwen2.5-coder:7b",
|
|
888
|
+
displayName: "Qwen 2.5 Coder 7B",
|
|
889
|
+
tier: "budget",
|
|
890
|
+
inputRate: 0,
|
|
891
|
+
outputRate: 0,
|
|
892
|
+
contextWindow: 32e3,
|
|
893
|
+
supportsStreaming: true,
|
|
894
|
+
supportsCaching: false
|
|
895
|
+
},
|
|
896
|
+
"qwen2.5-coder:32b": {
|
|
897
|
+
id: "qwen2.5-coder:32b",
|
|
898
|
+
displayName: "Qwen 2.5 Coder 32B",
|
|
899
|
+
tier: "balanced",
|
|
900
|
+
inputRate: 0,
|
|
901
|
+
outputRate: 0,
|
|
902
|
+
contextWindow: 32e3,
|
|
903
|
+
supportsStreaming: true,
|
|
904
|
+
supportsCaching: false
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
var MODEL_ALIASES = {
|
|
908
|
+
llama: "llama3.1:8b",
|
|
909
|
+
codellama: "codellama:13b",
|
|
910
|
+
mistral: "mistral:7b",
|
|
911
|
+
mixtral: "mixtral:8x7b",
|
|
912
|
+
deepseek: "deepseek-coder:6.7b",
|
|
913
|
+
qwen: "qwen2.5-coder:7b"
|
|
914
|
+
};
|
|
915
|
+
var OllamaPricingEngine = class {
|
|
916
|
+
provider = "ollama";
|
|
917
|
+
getModels() {
|
|
918
|
+
return Object.values(OLLAMA_MODELS);
|
|
919
|
+
}
|
|
920
|
+
getModelInfo(modelId) {
|
|
921
|
+
if (OLLAMA_MODELS[modelId]) {
|
|
922
|
+
return OLLAMA_MODELS[modelId];
|
|
923
|
+
}
|
|
924
|
+
const aliasedId = MODEL_ALIASES[modelId.toLowerCase()];
|
|
925
|
+
if (aliasedId && OLLAMA_MODELS[aliasedId]) {
|
|
926
|
+
return OLLAMA_MODELS[aliasedId];
|
|
927
|
+
}
|
|
928
|
+
return void 0;
|
|
929
|
+
}
|
|
930
|
+
validateModel(_model) {
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
calculateTokenCost(_tokens, _model) {
|
|
934
|
+
return 0;
|
|
935
|
+
}
|
|
936
|
+
calculateTotalCost(_tokens, _model, durationSeconds) {
|
|
937
|
+
const computeCost = durationSeconds / 3600 * pricing_js_1.ECS_FARGATE_SPOT_RATE_PER_HOUR;
|
|
938
|
+
return computeCost;
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
exports.OllamaPricingEngine = OllamaPricingEngine;
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// ../api/src/providers/generic/pricing.js
|
|
946
|
+
var require_pricing6 = __commonJS({
|
|
947
|
+
"../api/src/providers/generic/pricing.js"(exports) {
|
|
948
|
+
"use strict";
|
|
949
|
+
init_esm_shims();
|
|
950
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
951
|
+
exports.AZURE_MODELS = exports.BEDROCK_MODELS = exports.XAI_MODELS = exports.MISTRAL_MODELS = exports.DEEPSEEK_MODELS = exports.GROQ_MODELS = exports.OPENROUTER_MODELS = exports.GenericPricingEngine = void 0;
|
|
952
|
+
var GenericPricingEngine = class {
|
|
953
|
+
provider;
|
|
954
|
+
models;
|
|
955
|
+
defaultModel;
|
|
956
|
+
constructor(provider, models, defaultModel) {
|
|
957
|
+
this.provider = provider;
|
|
958
|
+
this.models = models;
|
|
959
|
+
this.defaultModel = defaultModel || {
|
|
960
|
+
id: "unknown",
|
|
961
|
+
displayName: "Unknown Model",
|
|
962
|
+
tier: "balanced",
|
|
963
|
+
inputRate: 1e-3,
|
|
964
|
+
// $1/1M tokens default
|
|
965
|
+
outputRate: 2e-3,
|
|
966
|
+
contextWindow: 128e3,
|
|
967
|
+
supportsStreaming: true,
|
|
968
|
+
supportsCaching: false
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
getModels() {
|
|
972
|
+
return Object.values(this.models);
|
|
973
|
+
}
|
|
974
|
+
getModelInfo(modelId) {
|
|
975
|
+
return this.models[modelId];
|
|
976
|
+
}
|
|
977
|
+
validateModel(model) {
|
|
978
|
+
return model in this.models;
|
|
979
|
+
}
|
|
980
|
+
calculateTokenCost(tokens, model) {
|
|
981
|
+
const modelInfo = this.getModelInfo(model) || this.defaultModel;
|
|
982
|
+
const inputCost = tokens.inputTokens / 1e3 * modelInfo.inputRate;
|
|
983
|
+
const outputCost = tokens.outputTokens / 1e3 * modelInfo.outputRate;
|
|
984
|
+
return inputCost + outputCost;
|
|
985
|
+
}
|
|
986
|
+
calculateTotalCost(tokens, model, _durationSeconds) {
|
|
987
|
+
return this.calculateTokenCost(tokens, model);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
exports.GenericPricingEngine = GenericPricingEngine;
|
|
991
|
+
exports.OPENROUTER_MODELS = {
|
|
992
|
+
"anthropic/claude-sonnet-4": {
|
|
993
|
+
id: "anthropic/claude-sonnet-4",
|
|
994
|
+
displayName: "Claude Sonnet 4 (via OR)",
|
|
995
|
+
tier: "balanced",
|
|
996
|
+
inputRate: 3e-3,
|
|
997
|
+
outputRate: 0.015,
|
|
998
|
+
contextWindow: 2e5,
|
|
999
|
+
supportsStreaming: true,
|
|
1000
|
+
supportsCaching: false
|
|
1001
|
+
},
|
|
1002
|
+
"openai/gpt-4o": {
|
|
1003
|
+
id: "openai/gpt-4o",
|
|
1004
|
+
displayName: "GPT-4o (via OR)",
|
|
1005
|
+
tier: "balanced",
|
|
1006
|
+
inputRate: 25e-4,
|
|
1007
|
+
outputRate: 0.01,
|
|
1008
|
+
contextWindow: 128e3,
|
|
1009
|
+
supportsStreaming: true,
|
|
1010
|
+
supportsCaching: false
|
|
1011
|
+
},
|
|
1012
|
+
"google/gemini-2.5-flash": {
|
|
1013
|
+
id: "google/gemini-2.5-flash",
|
|
1014
|
+
displayName: "Gemini 2.5 Flash (via OR)",
|
|
1015
|
+
tier: "balanced",
|
|
1016
|
+
inputRate: 15e-5,
|
|
1017
|
+
outputRate: 6e-4,
|
|
1018
|
+
contextWindow: 1e6,
|
|
1019
|
+
supportsStreaming: true,
|
|
1020
|
+
supportsCaching: false
|
|
1021
|
+
},
|
|
1022
|
+
"deepseek/deepseek-r1": {
|
|
1023
|
+
id: "deepseek/deepseek-r1",
|
|
1024
|
+
displayName: "DeepSeek R1 (via OR)",
|
|
1025
|
+
tier: "powerful",
|
|
1026
|
+
inputRate: 55e-5,
|
|
1027
|
+
outputRate: 219e-5,
|
|
1028
|
+
contextWindow: 128e3,
|
|
1029
|
+
supportsStreaming: true,
|
|
1030
|
+
supportsCaching: false
|
|
1031
|
+
},
|
|
1032
|
+
"meta-llama/llama-3.3-70b-instruct": {
|
|
1033
|
+
id: "meta-llama/llama-3.3-70b-instruct",
|
|
1034
|
+
displayName: "Llama 3.3 70B (via OR)",
|
|
1035
|
+
tier: "powerful",
|
|
1036
|
+
inputRate: 59e-5,
|
|
1037
|
+
outputRate: 79e-5,
|
|
1038
|
+
contextWindow: 131072,
|
|
1039
|
+
supportsStreaming: true,
|
|
1040
|
+
supportsCaching: false
|
|
1041
|
+
},
|
|
1042
|
+
"mistralai/mistral-large": {
|
|
1043
|
+
id: "mistralai/mistral-large",
|
|
1044
|
+
displayName: "Mistral Large (via OR)",
|
|
1045
|
+
tier: "powerful",
|
|
1046
|
+
inputRate: 2e-3,
|
|
1047
|
+
outputRate: 6e-3,
|
|
1048
|
+
contextWindow: 128e3,
|
|
1049
|
+
supportsStreaming: true,
|
|
1050
|
+
supportsCaching: false
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
exports.GROQ_MODELS = {
|
|
1054
|
+
"llama-3.3-70b-versatile": {
|
|
1055
|
+
id: "llama-3.3-70b-versatile",
|
|
1056
|
+
displayName: "Llama 3.3 70B",
|
|
1057
|
+
tier: "powerful",
|
|
1058
|
+
inputRate: 59e-5,
|
|
1059
|
+
outputRate: 79e-5,
|
|
1060
|
+
contextWindow: 131072,
|
|
1061
|
+
supportsStreaming: true,
|
|
1062
|
+
supportsCaching: false
|
|
1063
|
+
},
|
|
1064
|
+
"llama-3.1-8b-instant": {
|
|
1065
|
+
id: "llama-3.1-8b-instant",
|
|
1066
|
+
displayName: "Llama 3.1 8B Instant",
|
|
1067
|
+
tier: "budget",
|
|
1068
|
+
inputRate: 5e-5,
|
|
1069
|
+
outputRate: 8e-5,
|
|
1070
|
+
contextWindow: 131072,
|
|
1071
|
+
supportsStreaming: true,
|
|
1072
|
+
supportsCaching: false
|
|
1073
|
+
},
|
|
1074
|
+
"mixtral-8x7b-32768": {
|
|
1075
|
+
id: "mixtral-8x7b-32768",
|
|
1076
|
+
displayName: "Mixtral 8x7B",
|
|
1077
|
+
tier: "balanced",
|
|
1078
|
+
inputRate: 24e-5,
|
|
1079
|
+
outputRate: 24e-5,
|
|
1080
|
+
contextWindow: 32768,
|
|
1081
|
+
supportsStreaming: true,
|
|
1082
|
+
supportsCaching: false
|
|
1083
|
+
},
|
|
1084
|
+
"gemma2-9b-it": {
|
|
1085
|
+
id: "gemma2-9b-it",
|
|
1086
|
+
displayName: "Gemma 2 9B",
|
|
1087
|
+
tier: "budget",
|
|
1088
|
+
inputRate: 2e-4,
|
|
1089
|
+
outputRate: 2e-4,
|
|
1090
|
+
contextWindow: 8192,
|
|
1091
|
+
supportsStreaming: true,
|
|
1092
|
+
supportsCaching: false
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
exports.DEEPSEEK_MODELS = {
|
|
1096
|
+
"deepseek-chat": {
|
|
1097
|
+
id: "deepseek-chat",
|
|
1098
|
+
displayName: "DeepSeek Chat",
|
|
1099
|
+
tier: "balanced",
|
|
1100
|
+
inputRate: 14e-5,
|
|
1101
|
+
outputRate: 28e-5,
|
|
1102
|
+
contextWindow: 128e3,
|
|
1103
|
+
supportsStreaming: true,
|
|
1104
|
+
supportsCaching: true
|
|
1105
|
+
},
|
|
1106
|
+
"deepseek-reasoner": {
|
|
1107
|
+
id: "deepseek-reasoner",
|
|
1108
|
+
displayName: "DeepSeek Reasoner",
|
|
1109
|
+
tier: "powerful",
|
|
1110
|
+
inputRate: 55e-5,
|
|
1111
|
+
outputRate: 219e-5,
|
|
1112
|
+
contextWindow: 128e3,
|
|
1113
|
+
supportsStreaming: true,
|
|
1114
|
+
supportsCaching: true
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
exports.MISTRAL_MODELS = {
|
|
1118
|
+
"mistral-large-latest": {
|
|
1119
|
+
id: "mistral-large-latest",
|
|
1120
|
+
displayName: "Mistral Large",
|
|
1121
|
+
tier: "powerful",
|
|
1122
|
+
inputRate: 2e-3,
|
|
1123
|
+
outputRate: 6e-3,
|
|
1124
|
+
contextWindow: 128e3,
|
|
1125
|
+
supportsStreaming: true,
|
|
1126
|
+
supportsCaching: false
|
|
1127
|
+
},
|
|
1128
|
+
"mistral-medium-latest": {
|
|
1129
|
+
id: "mistral-medium-latest",
|
|
1130
|
+
displayName: "Mistral Medium",
|
|
1131
|
+
tier: "balanced",
|
|
1132
|
+
inputRate: 275e-5,
|
|
1133
|
+
outputRate: 81e-4,
|
|
1134
|
+
contextWindow: 32e3,
|
|
1135
|
+
supportsStreaming: true,
|
|
1136
|
+
supportsCaching: false
|
|
1137
|
+
},
|
|
1138
|
+
"mistral-small-latest": {
|
|
1139
|
+
id: "mistral-small-latest",
|
|
1140
|
+
displayName: "Mistral Small",
|
|
1141
|
+
tier: "budget",
|
|
1142
|
+
inputRate: 2e-4,
|
|
1143
|
+
outputRate: 6e-4,
|
|
1144
|
+
contextWindow: 32e3,
|
|
1145
|
+
supportsStreaming: true,
|
|
1146
|
+
supportsCaching: false
|
|
1147
|
+
},
|
|
1148
|
+
"codestral-latest": {
|
|
1149
|
+
id: "codestral-latest",
|
|
1150
|
+
displayName: "Codestral (Code)",
|
|
1151
|
+
tier: "balanced",
|
|
1152
|
+
inputRate: 3e-4,
|
|
1153
|
+
outputRate: 9e-4,
|
|
1154
|
+
contextWindow: 32e3,
|
|
1155
|
+
supportsStreaming: true,
|
|
1156
|
+
supportsCaching: false
|
|
1157
|
+
},
|
|
1158
|
+
"pixtral-large-latest": {
|
|
1159
|
+
id: "pixtral-large-latest",
|
|
1160
|
+
displayName: "Pixtral Large (Vision)",
|
|
1161
|
+
tier: "powerful",
|
|
1162
|
+
inputRate: 2e-3,
|
|
1163
|
+
outputRate: 6e-3,
|
|
1164
|
+
contextWindow: 128e3,
|
|
1165
|
+
supportsStreaming: true,
|
|
1166
|
+
supportsCaching: false
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
exports.XAI_MODELS = {
|
|
1170
|
+
"grok-3": {
|
|
1171
|
+
id: "grok-3",
|
|
1172
|
+
displayName: "Grok 3",
|
|
1173
|
+
tier: "powerful",
|
|
1174
|
+
inputRate: 3e-3,
|
|
1175
|
+
outputRate: 0.015,
|
|
1176
|
+
contextWindow: 131072,
|
|
1177
|
+
supportsStreaming: true,
|
|
1178
|
+
supportsCaching: false
|
|
1179
|
+
},
|
|
1180
|
+
"grok-3-fast": {
|
|
1181
|
+
id: "grok-3-fast",
|
|
1182
|
+
displayName: "Grok 3 Fast",
|
|
1183
|
+
tier: "balanced",
|
|
1184
|
+
inputRate: 5e-3,
|
|
1185
|
+
outputRate: 0.025,
|
|
1186
|
+
contextWindow: 131072,
|
|
1187
|
+
supportsStreaming: true,
|
|
1188
|
+
supportsCaching: false
|
|
1189
|
+
},
|
|
1190
|
+
"grok-2": {
|
|
1191
|
+
id: "grok-2",
|
|
1192
|
+
displayName: "Grok 2",
|
|
1193
|
+
tier: "balanced",
|
|
1194
|
+
inputRate: 2e-3,
|
|
1195
|
+
outputRate: 0.01,
|
|
1196
|
+
contextWindow: 131072,
|
|
1197
|
+
supportsStreaming: true,
|
|
1198
|
+
supportsCaching: false
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
exports.BEDROCK_MODELS = {
|
|
1202
|
+
"anthropic.claude-3-5-sonnet-20241022-v2:0": {
|
|
1203
|
+
id: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
1204
|
+
displayName: "Claude 3.5 Sonnet v2 (Bedrock)",
|
|
1205
|
+
tier: "balanced",
|
|
1206
|
+
inputRate: 3e-3,
|
|
1207
|
+
outputRate: 0.015,
|
|
1208
|
+
contextWindow: 2e5,
|
|
1209
|
+
supportsStreaming: true,
|
|
1210
|
+
supportsCaching: false
|
|
1211
|
+
},
|
|
1212
|
+
"anthropic.claude-3-5-haiku-20241022-v1:0": {
|
|
1213
|
+
id: "anthropic.claude-3-5-haiku-20241022-v1:0",
|
|
1214
|
+
displayName: "Claude 3.5 Haiku (Bedrock)",
|
|
1215
|
+
tier: "budget",
|
|
1216
|
+
inputRate: 8e-4,
|
|
1217
|
+
outputRate: 4e-3,
|
|
1218
|
+
contextWindow: 2e5,
|
|
1219
|
+
supportsStreaming: true,
|
|
1220
|
+
supportsCaching: false
|
|
1221
|
+
},
|
|
1222
|
+
"anthropic.claude-3-opus-20240229-v1:0": {
|
|
1223
|
+
id: "anthropic.claude-3-opus-20240229-v1:0",
|
|
1224
|
+
displayName: "Claude 3 Opus (Bedrock)",
|
|
1225
|
+
tier: "powerful",
|
|
1226
|
+
inputRate: 0.015,
|
|
1227
|
+
outputRate: 0.075,
|
|
1228
|
+
contextWindow: 2e5,
|
|
1229
|
+
supportsStreaming: true,
|
|
1230
|
+
supportsCaching: false
|
|
1231
|
+
},
|
|
1232
|
+
"amazon.nova-pro-v1:0": {
|
|
1233
|
+
id: "amazon.nova-pro-v1:0",
|
|
1234
|
+
displayName: "Amazon Nova Pro",
|
|
1235
|
+
tier: "balanced",
|
|
1236
|
+
inputRate: 8e-4,
|
|
1237
|
+
outputRate: 32e-4,
|
|
1238
|
+
contextWindow: 3e5,
|
|
1239
|
+
supportsStreaming: true,
|
|
1240
|
+
supportsCaching: false
|
|
1241
|
+
},
|
|
1242
|
+
"amazon.nova-lite-v1:0": {
|
|
1243
|
+
id: "amazon.nova-lite-v1:0",
|
|
1244
|
+
displayName: "Amazon Nova Lite",
|
|
1245
|
+
tier: "budget",
|
|
1246
|
+
inputRate: 6e-5,
|
|
1247
|
+
outputRate: 24e-5,
|
|
1248
|
+
contextWindow: 3e5,
|
|
1249
|
+
supportsStreaming: true,
|
|
1250
|
+
supportsCaching: false
|
|
1251
|
+
},
|
|
1252
|
+
"meta.llama3-70b-instruct-v1:0": {
|
|
1253
|
+
id: "meta.llama3-70b-instruct-v1:0",
|
|
1254
|
+
displayName: "Llama 3 70B (Bedrock)",
|
|
1255
|
+
tier: "powerful",
|
|
1256
|
+
inputRate: 265e-5,
|
|
1257
|
+
outputRate: 35e-4,
|
|
1258
|
+
contextWindow: 8192,
|
|
1259
|
+
supportsStreaming: true,
|
|
1260
|
+
supportsCaching: false
|
|
1261
|
+
},
|
|
1262
|
+
"mistral.mistral-large-2407-v1:0": {
|
|
1263
|
+
id: "mistral.mistral-large-2407-v1:0",
|
|
1264
|
+
displayName: "Mistral Large (Bedrock)",
|
|
1265
|
+
tier: "powerful",
|
|
1266
|
+
inputRate: 4e-3,
|
|
1267
|
+
outputRate: 0.012,
|
|
1268
|
+
contextWindow: 128e3,
|
|
1269
|
+
supportsStreaming: true,
|
|
1270
|
+
supportsCaching: false
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
exports.AZURE_MODELS = {
|
|
1274
|
+
"gpt-4o": {
|
|
1275
|
+
id: "gpt-4o",
|
|
1276
|
+
displayName: "GPT-4o (Foundry)",
|
|
1277
|
+
tier: "balanced",
|
|
1278
|
+
inputRate: 25e-4,
|
|
1279
|
+
outputRate: 0.01,
|
|
1280
|
+
contextWindow: 128e3,
|
|
1281
|
+
supportsStreaming: true,
|
|
1282
|
+
supportsCaching: false
|
|
1283
|
+
},
|
|
1284
|
+
"gpt-4o-mini": {
|
|
1285
|
+
id: "gpt-4o-mini",
|
|
1286
|
+
displayName: "GPT-4o Mini (Foundry)",
|
|
1287
|
+
tier: "budget",
|
|
1288
|
+
inputRate: 15e-5,
|
|
1289
|
+
outputRate: 6e-4,
|
|
1290
|
+
contextWindow: 128e3,
|
|
1291
|
+
supportsStreaming: true,
|
|
1292
|
+
supportsCaching: false
|
|
1293
|
+
},
|
|
1294
|
+
"gpt-4-turbo": {
|
|
1295
|
+
id: "gpt-4-turbo",
|
|
1296
|
+
displayName: "GPT-4 Turbo (Foundry)",
|
|
1297
|
+
tier: "powerful",
|
|
1298
|
+
inputRate: 0.01,
|
|
1299
|
+
outputRate: 0.03,
|
|
1300
|
+
contextWindow: 128e3,
|
|
1301
|
+
supportsStreaming: true,
|
|
1302
|
+
supportsCaching: false
|
|
1303
|
+
},
|
|
1304
|
+
"o1-preview": {
|
|
1305
|
+
id: "o1-preview",
|
|
1306
|
+
displayName: "o1-preview (Foundry)",
|
|
1307
|
+
tier: "powerful",
|
|
1308
|
+
inputRate: 0.015,
|
|
1309
|
+
outputRate: 0.06,
|
|
1310
|
+
contextWindow: 128e3,
|
|
1311
|
+
supportsStreaming: false,
|
|
1312
|
+
supportsCaching: false
|
|
1313
|
+
},
|
|
1314
|
+
"o1-mini": {
|
|
1315
|
+
id: "o1-mini",
|
|
1316
|
+
displayName: "o1-mini (Foundry)",
|
|
1317
|
+
tier: "balanced",
|
|
1318
|
+
inputRate: 3e-3,
|
|
1319
|
+
outputRate: 0.012,
|
|
1320
|
+
contextWindow: 128e3,
|
|
1321
|
+
supportsStreaming: false,
|
|
1322
|
+
supportsCaching: false
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
7
1327
|
|
|
8
|
-
// src/
|
|
1328
|
+
// ../api/src/providers/types.js
|
|
1329
|
+
var require_types = __commonJS({
|
|
1330
|
+
"../api/src/providers/types.js"(exports) {
|
|
1331
|
+
"use strict";
|
|
1332
|
+
init_esm_shims();
|
|
1333
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1334
|
+
exports.isValidProviderId = isValidProviderId;
|
|
1335
|
+
function isValidProviderId(id) {
|
|
1336
|
+
return ["anthropic", "openai", "google", "ollama", "openrouter", "groq", "deepseek", "mistral", "xai", "bedrock", "azure", "ai-sdk"].includes(id);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
// ../api/src/providers/index.js
|
|
1342
|
+
var require_providers = __commonJS({
|
|
1343
|
+
"../api/src/providers/index.js"(exports) {
|
|
1344
|
+
"use strict";
|
|
1345
|
+
init_esm_shims();
|
|
1346
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1347
|
+
if (k2 === void 0) k2 = k;
|
|
1348
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1349
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1350
|
+
desc = { enumerable: true, get: function() {
|
|
1351
|
+
return m[k];
|
|
1352
|
+
} };
|
|
1353
|
+
}
|
|
1354
|
+
Object.defineProperty(o, k2, desc);
|
|
1355
|
+
}) : (function(o, m, k, k2) {
|
|
1356
|
+
if (k2 === void 0) k2 = k;
|
|
1357
|
+
o[k2] = m[k];
|
|
1358
|
+
}));
|
|
1359
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
1360
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
1361
|
+
};
|
|
1362
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1363
|
+
exports.DEFAULT_PROVIDER_ID = void 0;
|
|
1364
|
+
exports.getProvider = getProvider;
|
|
1365
|
+
exports.getPricingEngine = getPricingEngine2;
|
|
1366
|
+
exports.listProviders = listProviders;
|
|
1367
|
+
exports.getProviderIds = getProviderIds;
|
|
1368
|
+
exports.hasProvider = hasProvider;
|
|
1369
|
+
exports.getDefaultModel = getDefaultModel;
|
|
1370
|
+
exports.findModelInfo = findModelInfo;
|
|
1371
|
+
exports.detectProviderForModel = detectProviderForModel;
|
|
1372
|
+
exports.getProviderSummary = getProviderSummary;
|
|
1373
|
+
var pricing_js_1 = require_pricing2();
|
|
1374
|
+
var pricing_js_2 = require_pricing3();
|
|
1375
|
+
var pricing_js_3 = require_pricing4();
|
|
1376
|
+
var pricing_js_4 = require_pricing5();
|
|
1377
|
+
var pricing_js_5 = require_pricing6();
|
|
1378
|
+
__exportStar(require_types(), exports);
|
|
1379
|
+
var providers = {
|
|
1380
|
+
anthropic: {
|
|
1381
|
+
id: "anthropic",
|
|
1382
|
+
name: "Anthropic (Claude)",
|
|
1383
|
+
pricingEngine: new pricing_js_1.AnthropicPricingEngine(),
|
|
1384
|
+
defaultModel: "claude-sonnet-4-6",
|
|
1385
|
+
requiresApiKey: true,
|
|
1386
|
+
apiKeyEnvVar: "ANTHROPIC_API_KEY"
|
|
1387
|
+
},
|
|
1388
|
+
openai: {
|
|
1389
|
+
id: "openai",
|
|
1390
|
+
name: "OpenAI",
|
|
1391
|
+
pricingEngine: new pricing_js_2.OpenAIPricingEngine(),
|
|
1392
|
+
defaultModel: "gpt-4o",
|
|
1393
|
+
requiresApiKey: true,
|
|
1394
|
+
apiKeyEnvVar: "OPENAI_API_KEY"
|
|
1395
|
+
},
|
|
1396
|
+
google: {
|
|
1397
|
+
id: "google",
|
|
1398
|
+
name: "Google (Gemini)",
|
|
1399
|
+
pricingEngine: new pricing_js_3.GooglePricingEngine(),
|
|
1400
|
+
defaultModel: "gemini-2.0-flash",
|
|
1401
|
+
requiresApiKey: true,
|
|
1402
|
+
apiKeyEnvVar: "GOOGLE_API_KEY"
|
|
1403
|
+
},
|
|
1404
|
+
ollama: {
|
|
1405
|
+
id: "ollama",
|
|
1406
|
+
name: "Ollama (Local)",
|
|
1407
|
+
pricingEngine: new pricing_js_4.OllamaPricingEngine(),
|
|
1408
|
+
defaultModel: "llama3.1:8b",
|
|
1409
|
+
requiresApiKey: false
|
|
1410
|
+
},
|
|
1411
|
+
openrouter: {
|
|
1412
|
+
id: "openrouter",
|
|
1413
|
+
name: "OpenRouter",
|
|
1414
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("openrouter", pricing_js_5.OPENROUTER_MODELS),
|
|
1415
|
+
defaultModel: "anthropic/claude-sonnet-4",
|
|
1416
|
+
requiresApiKey: true,
|
|
1417
|
+
apiKeyEnvVar: "OPENROUTER_API_KEY"
|
|
1418
|
+
},
|
|
1419
|
+
groq: {
|
|
1420
|
+
id: "groq",
|
|
1421
|
+
name: "Groq",
|
|
1422
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("groq", pricing_js_5.GROQ_MODELS),
|
|
1423
|
+
defaultModel: "llama-3.3-70b-versatile",
|
|
1424
|
+
requiresApiKey: true,
|
|
1425
|
+
apiKeyEnvVar: "GROQ_API_KEY"
|
|
1426
|
+
},
|
|
1427
|
+
deepseek: {
|
|
1428
|
+
id: "deepseek",
|
|
1429
|
+
name: "DeepSeek",
|
|
1430
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("deepseek", pricing_js_5.DEEPSEEK_MODELS),
|
|
1431
|
+
defaultModel: "deepseek-chat",
|
|
1432
|
+
requiresApiKey: true,
|
|
1433
|
+
apiKeyEnvVar: "DEEPSEEK_API_KEY"
|
|
1434
|
+
},
|
|
1435
|
+
mistral: {
|
|
1436
|
+
id: "mistral",
|
|
1437
|
+
name: "Mistral AI",
|
|
1438
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("mistral", pricing_js_5.MISTRAL_MODELS),
|
|
1439
|
+
defaultModel: "mistral-large-latest",
|
|
1440
|
+
requiresApiKey: true,
|
|
1441
|
+
apiKeyEnvVar: "MISTRAL_API_KEY"
|
|
1442
|
+
},
|
|
1443
|
+
xai: {
|
|
1444
|
+
id: "xai",
|
|
1445
|
+
name: "xAI (Grok)",
|
|
1446
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("xai", pricing_js_5.XAI_MODELS),
|
|
1447
|
+
defaultModel: "grok-3",
|
|
1448
|
+
requiresApiKey: true,
|
|
1449
|
+
apiKeyEnvVar: "XAI_API_KEY"
|
|
1450
|
+
},
|
|
1451
|
+
bedrock: {
|
|
1452
|
+
id: "bedrock",
|
|
1453
|
+
name: "AWS Bedrock",
|
|
1454
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("bedrock", pricing_js_5.BEDROCK_MODELS),
|
|
1455
|
+
defaultModel: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
1456
|
+
requiresApiKey: true,
|
|
1457
|
+
apiKeyEnvVar: "AWS_BEDROCK_CREDENTIALS"
|
|
1458
|
+
},
|
|
1459
|
+
azure: {
|
|
1460
|
+
id: "azure",
|
|
1461
|
+
name: "Azure AI Foundry",
|
|
1462
|
+
pricingEngine: new pricing_js_5.GenericPricingEngine("azure", pricing_js_5.AZURE_MODELS),
|
|
1463
|
+
defaultModel: "gpt-4o",
|
|
1464
|
+
requiresApiKey: true,
|
|
1465
|
+
apiKeyEnvVar: "AZURE_OPENAI_CREDENTIALS"
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
exports.DEFAULT_PROVIDER_ID = "anthropic";
|
|
1469
|
+
function getProvider(providerId) {
|
|
1470
|
+
return providers[providerId] ?? providers.anthropic;
|
|
1471
|
+
}
|
|
1472
|
+
function getPricingEngine2(providerId) {
|
|
1473
|
+
return getProvider(providerId).pricingEngine;
|
|
1474
|
+
}
|
|
1475
|
+
function listProviders() {
|
|
1476
|
+
return Object.values(providers);
|
|
1477
|
+
}
|
|
1478
|
+
function getProviderIds() {
|
|
1479
|
+
return Object.keys(providers);
|
|
1480
|
+
}
|
|
1481
|
+
function hasProvider(providerId) {
|
|
1482
|
+
return providerId in providers;
|
|
1483
|
+
}
|
|
1484
|
+
function getDefaultModel(providerId) {
|
|
1485
|
+
return getProvider(providerId).defaultModel;
|
|
1486
|
+
}
|
|
1487
|
+
function findModelInfo(modelId) {
|
|
1488
|
+
for (const provider of Object.values(providers)) {
|
|
1489
|
+
const modelInfo = provider.pricingEngine.getModelInfo(modelId);
|
|
1490
|
+
if (modelInfo) {
|
|
1491
|
+
return modelInfo;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return void 0;
|
|
1495
|
+
}
|
|
1496
|
+
function detectProviderForModel(modelId) {
|
|
1497
|
+
for (const [providerId, provider] of Object.entries(providers)) {
|
|
1498
|
+
if (provider.pricingEngine.validateModel(modelId)) {
|
|
1499
|
+
if (providerId !== "ollama") {
|
|
1500
|
+
return providerId;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
if (modelId.includes(":")) {
|
|
1505
|
+
return "ollama";
|
|
1506
|
+
}
|
|
1507
|
+
return void 0;
|
|
1508
|
+
}
|
|
1509
|
+
function getProviderSummary() {
|
|
1510
|
+
return Object.values(providers).map((provider) => ({
|
|
1511
|
+
id: provider.id,
|
|
1512
|
+
name: provider.name,
|
|
1513
|
+
modelCount: provider.pricingEngine.getModels().length,
|
|
1514
|
+
defaultModel: provider.defaultModel,
|
|
1515
|
+
requiresApiKey: provider.requiresApiKey
|
|
1516
|
+
}));
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
|
|
1521
|
+
// src/config.ts
|
|
1522
|
+
init_esm_shims();
|
|
9
1523
|
import fs from "fs";
|
|
10
1524
|
import path2 from "path";
|
|
11
1525
|
import os from "os";
|
|
@@ -13,8 +1527,7 @@ var CONFIG_DIR = path2.join(os.homedir(), ".workermill");
|
|
|
13
1527
|
var CONFIG_FILE = path2.join(CONFIG_DIR, "cli.json");
|
|
14
1528
|
function loadConfig() {
|
|
15
1529
|
try {
|
|
16
|
-
if (!fs.existsSync(CONFIG_FILE))
|
|
17
|
-
return null;
|
|
1530
|
+
if (!fs.existsSync(CONFIG_FILE)) return null;
|
|
18
1531
|
const raw = fs.readFileSync(CONFIG_FILE, "utf-8");
|
|
19
1532
|
return JSON.parse(raw);
|
|
20
1533
|
} catch {
|
|
@@ -43,6 +1556,7 @@ function getProviderForPersona(config, persona) {
|
|
|
43
1556
|
}
|
|
44
1557
|
|
|
45
1558
|
// ../packages/engine/src/model-factory.js
|
|
1559
|
+
init_esm_shims();
|
|
46
1560
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
47
1561
|
import { openai } from "@ai-sdk/openai";
|
|
48
1562
|
import { google } from "@ai-sdk/google";
|
|
@@ -78,11 +1592,13 @@ function createModel(provider, modelName, ollamaHost, ollamaContextLength) {
|
|
|
78
1592
|
}
|
|
79
1593
|
|
|
80
1594
|
// ../packages/engine/src/tools/index.js
|
|
1595
|
+
init_esm_shims();
|
|
81
1596
|
import { tool } from "ai";
|
|
82
1597
|
import { z } from "zod";
|
|
83
1598
|
import path10 from "path";
|
|
84
1599
|
|
|
85
1600
|
// ../packages/engine/src/tools/bash.js
|
|
1601
|
+
init_esm_shims();
|
|
86
1602
|
import { spawn } from "child_process";
|
|
87
1603
|
var activeChild = null;
|
|
88
1604
|
function killActiveProcess() {
|
|
@@ -221,6 +1737,7 @@ async function execute({ command, cwd, timeout = 12e4 }) {
|
|
|
221
1737
|
}
|
|
222
1738
|
|
|
223
1739
|
// ../packages/engine/src/tools/read-file.js
|
|
1740
|
+
init_esm_shims();
|
|
224
1741
|
import fs2 from "fs";
|
|
225
1742
|
import path3 from "path";
|
|
226
1743
|
var description2 = "Read the contents of a file. Returns the file content as a string. Supports text files of any type.";
|
|
@@ -278,6 +1795,7 @@ async function execute2({ path: filePath, encoding = "utf8", maxLines, startLine
|
|
|
278
1795
|
}
|
|
279
1796
|
|
|
280
1797
|
// ../packages/engine/src/tools/write-file.js
|
|
1798
|
+
init_esm_shims();
|
|
281
1799
|
import fs3 from "fs";
|
|
282
1800
|
import path4 from "path";
|
|
283
1801
|
var description3 = "Write content to a file. Creates the file if it does not exist, and creates any necessary parent directories. Overwrites existing content.";
|
|
@@ -319,6 +1837,7 @@ async function execute3({ path: filePath, content, encoding = "utf8", append = f
|
|
|
319
1837
|
}
|
|
320
1838
|
|
|
321
1839
|
// ../packages/engine/src/tools/edit-file.js
|
|
1840
|
+
init_esm_shims();
|
|
322
1841
|
import fs4 from "fs";
|
|
323
1842
|
import path5 from "path";
|
|
324
1843
|
var description4 = "Edit a file by finding and replacing text. The old_string must be unique in the file (or use replaceAll for multiple occurrences). Use this instead of write_file when making targeted changes to existing files.";
|
|
@@ -390,6 +1909,7 @@ async function execute4({ path: filePath, old_string, new_string, replaceAll = f
|
|
|
390
1909
|
}
|
|
391
1910
|
|
|
392
1911
|
// ../packages/engine/src/tools/glob.js
|
|
1912
|
+
init_esm_shims();
|
|
393
1913
|
import fs5 from "fs";
|
|
394
1914
|
import path6 from "path";
|
|
395
1915
|
function globToRegex(pattern) {
|
|
@@ -525,6 +2045,7 @@ async function execute5({ pattern, cwd, maxResults = 1e3, includeHidden = false
|
|
|
525
2045
|
}
|
|
526
2046
|
|
|
527
2047
|
// ../packages/engine/src/tools/grep.js
|
|
2048
|
+
init_esm_shims();
|
|
528
2049
|
import fs6 from "fs";
|
|
529
2050
|
import path7 from "path";
|
|
530
2051
|
function walkDir2(dir, files = [], maxDepth = 20, currentDepth = 0) {
|
|
@@ -695,6 +2216,7 @@ async function execute6({ pattern, path: searchPath, filePattern, ignoreCase = f
|
|
|
695
2216
|
}
|
|
696
2217
|
|
|
697
2218
|
// ../packages/engine/src/tools/ls.js
|
|
2219
|
+
init_esm_shims();
|
|
698
2220
|
import fs7 from "fs";
|
|
699
2221
|
import path8 from "path";
|
|
700
2222
|
var description7 = "List directory contents in a tree format. Shows file names, types, and sizes. More efficient than bash ls \u2014 no subprocess needed, returns structured output.";
|
|
@@ -781,6 +2303,7 @@ async function execute7({ path: dirPath, ignore, maxDepth = 3, maxFiles = 1e3 })
|
|
|
781
2303
|
}
|
|
782
2304
|
|
|
783
2305
|
// ../packages/engine/src/tools/fetch.js
|
|
2306
|
+
init_esm_shims();
|
|
784
2307
|
var description8 = "Fetch content from a URL and return it as text or markdown. Useful for reading documentation, API references, error pages, and other web content.";
|
|
785
2308
|
function htmlToText(html) {
|
|
786
2309
|
return html.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<\/?(p|div|br|h[1-6]|li|tr|blockquote|pre|hr)[^>]*>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, " ").replace(/\n{3,}/g, "\n\n").trim();
|
|
@@ -846,6 +2369,7 @@ async function execute8({ url, format = "markdown", timeout = 3e4 }) {
|
|
|
846
2369
|
}
|
|
847
2370
|
|
|
848
2371
|
// ../packages/engine/src/tools/patch.js
|
|
2372
|
+
init_esm_shims();
|
|
849
2373
|
import fs8 from "fs";
|
|
850
2374
|
import path9 from "path";
|
|
851
2375
|
var description9 = "Apply a unified diff patch to one or more files atomically. All hunks are validated before any changes are written. If any hunk fails to apply, no files are modified. Use standard unified diff format (output of `git diff` or `diff -u`).";
|
|
@@ -1031,6 +2555,7 @@ ${errors.join("\n")}`,
|
|
|
1031
2555
|
}
|
|
1032
2556
|
|
|
1033
2557
|
// ../packages/engine/src/tools/sub-agent.js
|
|
2558
|
+
init_esm_shims();
|
|
1034
2559
|
import { streamText, stepCountIs } from "ai";
|
|
1035
2560
|
var description10 = "Spawn a read-only sub-agent to explore the codebase. The sub-agent can read files, search with glob/grep, and list directories, but cannot write files, edit, or run commands. Use this for parallel codebase exploration \u2014 understanding architecture, finding patterns, or researching how something works before making changes.";
|
|
1036
2561
|
function createSubAgentExecutor(model, workingDir, readOnlyTools) {
|
|
@@ -1068,6 +2593,7 @@ function createSubAgentExecutor(model, workingDir, readOnlyTools) {
|
|
|
1068
2593
|
}
|
|
1069
2594
|
|
|
1070
2595
|
// ../packages/engine/src/tools/git.js
|
|
2596
|
+
init_esm_shims();
|
|
1071
2597
|
import { execSync } from "child_process";
|
|
1072
2598
|
var description11 = "Execute git operations. Supports: status, diff, log, add, commit, branch, checkout, stash. Blocks destructive operations like force-push or reset --hard.";
|
|
1073
2599
|
var BLOCKED_PATTERNS = [
|
|
@@ -1117,6 +2643,7 @@ async function execute10({ action, args, cwd }) {
|
|
|
1117
2643
|
}
|
|
1118
2644
|
|
|
1119
2645
|
// ../packages/engine/src/tools/web-search.js
|
|
2646
|
+
init_esm_shims();
|
|
1120
2647
|
var description12 = "Search the web for documentation, error messages, library usage, or any information. Returns search results with titles, URLs, and snippets. Use this when you need up-to-date information that might not be in your training data.";
|
|
1121
2648
|
async function execute11(input) {
|
|
1122
2649
|
const { query, maxResults = 8 } = input;
|
|
@@ -1161,6 +2688,7 @@ async function execute11(input) {
|
|
|
1161
2688
|
}
|
|
1162
2689
|
|
|
1163
2690
|
// ../packages/engine/src/tools/todo.js
|
|
2691
|
+
init_esm_shims();
|
|
1164
2692
|
var description13 = "Track your progress within a task. Create todo items, mark them complete, and list status. Use this to stay organized on multi-step work.";
|
|
1165
2693
|
var todos = /* @__PURE__ */ new Map();
|
|
1166
2694
|
var nextId = 1;
|
|
@@ -1586,27 +3114,17 @@ ${result.content}`;
|
|
|
1586
3114
|
};
|
|
1587
3115
|
}
|
|
1588
3116
|
|
|
1589
|
-
// src/cost-tracker.
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
"claude-opus-4-6": { input: 15, output: 75 },
|
|
1593
|
-
"claude-sonnet-4-6": { input: 3, output: 15 },
|
|
1594
|
-
"claude-haiku-4-5": { input: 0.8, output: 4 },
|
|
1595
|
-
// OpenAI (GPT-5.x)
|
|
1596
|
-
"gpt-5.4": { input: 0.75, output: 4.5 },
|
|
1597
|
-
"gpt-5.4-mini": { input: 0.15, output: 0.6 },
|
|
1598
|
-
"gpt-5.4-pro": { input: 5, output: 20 },
|
|
1599
|
-
"gpt-5.3": { input: 1, output: 5 },
|
|
1600
|
-
// Google (Gemini 3.x)
|
|
1601
|
-
"gemini-3.1-pro": { input: 1.25, output: 10 },
|
|
1602
|
-
"gemini-3.1-flash-lite": { input: 0.15, output: 0.6 }
|
|
1603
|
-
// Ollama (free, local)
|
|
1604
|
-
};
|
|
3117
|
+
// src/cost-tracker.ts
|
|
3118
|
+
init_esm_shims();
|
|
3119
|
+
var import_providers = __toESM(require_providers(), 1);
|
|
1605
3120
|
var CostTracker = class {
|
|
1606
3121
|
entries = [];
|
|
1607
3122
|
addUsage(persona, provider, model, inputTokens, outputTokens) {
|
|
1608
|
-
const
|
|
1609
|
-
const cost =
|
|
3123
|
+
const engine = (0, import_providers.getPricingEngine)(provider);
|
|
3124
|
+
const cost = engine.calculateTokenCost(
|
|
3125
|
+
{ inputTokens, outputTokens, cacheCreationTokens: 0, cacheReadTokens: 0 },
|
|
3126
|
+
model
|
|
3127
|
+
);
|
|
1610
3128
|
this.entries.push({
|
|
1611
3129
|
persona,
|
|
1612
3130
|
provider,
|
|
@@ -1620,7 +3138,10 @@ var CostTracker = class {
|
|
|
1620
3138
|
return this.entries.reduce((sum, e) => sum + e.cost, 0);
|
|
1621
3139
|
}
|
|
1622
3140
|
getTotalTokens() {
|
|
1623
|
-
return this.entries.reduce(
|
|
3141
|
+
return this.entries.reduce(
|
|
3142
|
+
(sum, e) => sum + e.inputTokens + e.outputTokens,
|
|
3143
|
+
0
|
|
3144
|
+
);
|
|
1624
3145
|
}
|
|
1625
3146
|
getBreakdown() {
|
|
1626
3147
|
return [...this.entries];
|
|
@@ -1633,49 +3154,17 @@ var CostTracker = class {
|
|
|
1633
3154
|
`Session cost: $${total.toFixed(4)} (${totalIn.toLocaleString()} in / ${totalOut.toLocaleString()} out)`
|
|
1634
3155
|
];
|
|
1635
3156
|
for (const entry of this.entries) {
|
|
1636
|
-
lines.push(
|
|
3157
|
+
lines.push(
|
|
3158
|
+
` * ${entry.persona}: $${entry.cost.toFixed(4)} (${entry.provider}/${entry.model})`
|
|
3159
|
+
);
|
|
1637
3160
|
}
|
|
1638
3161
|
return lines.join("\n");
|
|
1639
3162
|
}
|
|
1640
3163
|
};
|
|
1641
3164
|
|
|
1642
|
-
// src/logger.js
|
|
1643
|
-
import fs9 from "fs";
|
|
1644
|
-
import path11 from "path";
|
|
1645
|
-
var LOG_DIR = path11.join(process.cwd(), ".workermill");
|
|
1646
|
-
var LOG_FILE = path11.join(LOG_DIR, "cli.log");
|
|
1647
|
-
var logStream = null;
|
|
1648
|
-
function ensureLogDir() {
|
|
1649
|
-
if (!fs9.existsSync(LOG_DIR)) {
|
|
1650
|
-
fs9.mkdirSync(LOG_DIR, { recursive: true });
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
function getStream() {
|
|
1654
|
-
if (!logStream) {
|
|
1655
|
-
ensureLogDir();
|
|
1656
|
-
logStream = fs9.createWriteStream(LOG_FILE, { flags: "a" });
|
|
1657
|
-
}
|
|
1658
|
-
return logStream;
|
|
1659
|
-
}
|
|
1660
|
-
function timestamp() {
|
|
1661
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1662
|
-
}
|
|
1663
|
-
function log(level, message, data) {
|
|
1664
|
-
const entry = data ? `[${timestamp()}] ${level}: ${message} ${JSON.stringify(data)}` : `[${timestamp()}] ${level}: ${message}`;
|
|
1665
|
-
getStream().write(entry + "\n");
|
|
1666
|
-
}
|
|
1667
|
-
function info(message, data) {
|
|
1668
|
-
log("INFO", message, data);
|
|
1669
|
-
}
|
|
1670
|
-
function error(message, data) {
|
|
1671
|
-
log("ERROR", message, data);
|
|
1672
|
-
}
|
|
1673
|
-
function debug(message, data) {
|
|
1674
|
-
log("DEBUG", message, data);
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
3165
|
export {
|
|
1678
3166
|
__dirname,
|
|
3167
|
+
init_esm_shims,
|
|
1679
3168
|
loadConfig,
|
|
1680
3169
|
saveConfig,
|
|
1681
3170
|
getProviderForPersona,
|
|
@@ -1683,8 +3172,5 @@ export {
|
|
|
1683
3172
|
createModel,
|
|
1684
3173
|
killActiveProcess,
|
|
1685
3174
|
createToolDefinitions,
|
|
1686
|
-
CostTracker
|
|
1687
|
-
info,
|
|
1688
|
-
error,
|
|
1689
|
-
debug
|
|
3175
|
+
CostTracker
|
|
1690
3176
|
};
|