@usewhisper/mcp-server 0.3.0 → 0.5.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 (57) hide show
  1. package/README.md +182 -154
  2. package/dist/autosubscribe-6EDKPBE2.js +4068 -4068
  3. package/dist/autosubscribe-GHO6YR5A.js +4068 -4068
  4. package/dist/autosubscribe-ISDETQIB.js +435 -435
  5. package/dist/chunk-3WGYBAYR.js +8387 -8387
  6. package/dist/chunk-52VJYCZ7.js +455 -455
  7. package/dist/chunk-5KBZQHDL.js +189 -189
  8. package/dist/chunk-5KIJNY6Z.js +370 -370
  9. package/dist/chunk-7SN3CKDK.js +1076 -1076
  10. package/dist/chunk-B3VWOHUA.js +271 -271
  11. package/dist/chunk-C57DHKTL.js +459 -459
  12. package/dist/chunk-EI5CE3EY.js +616 -616
  13. package/dist/chunk-FTWUJBAH.js +386 -386
  14. package/dist/chunk-H3HSKH2P.js +4841 -4841
  15. package/dist/chunk-JO3ORBZD.js +616 -616
  16. package/dist/chunk-L6DXSM2U.js +456 -456
  17. package/dist/chunk-LMEYV4JD.js +368 -368
  18. package/dist/chunk-MEFLJ4PV.js +8385 -8385
  19. package/dist/chunk-OBLI4FE4.js +275 -275
  20. package/dist/chunk-PPGYJJED.js +271 -271
  21. package/dist/chunk-QGM4M3NI.js +37 -37
  22. package/dist/chunk-T7KMSTWP.js +399 -399
  23. package/dist/chunk-TWEIYHI6.js +399 -399
  24. package/dist/chunk-UYWE7HSU.js +368 -368
  25. package/dist/chunk-X2DL2GWT.js +32 -32
  26. package/dist/chunk-X7HNNNJJ.js +1079 -1079
  27. package/dist/consolidation-2GCKI4RE.js +220 -220
  28. package/dist/consolidation-4JOPW6BG.js +220 -220
  29. package/dist/consolidation-FOVQTWNQ.js +222 -222
  30. package/dist/consolidation-IFQ52E44.js +209 -209
  31. package/dist/context-sharing-4ITCNKG4.js +307 -307
  32. package/dist/context-sharing-6CCFIAKL.js +275 -275
  33. package/dist/context-sharing-GYKLXHZA.js +307 -307
  34. package/dist/context-sharing-PH64JTXS.js +308 -308
  35. package/dist/context-sharing-Y6LTZZOF.js +307 -307
  36. package/dist/cost-optimization-6OIKRSBV.js +195 -195
  37. package/dist/cost-optimization-7DVSTL6R.js +307 -307
  38. package/dist/cost-optimization-BH5NAX33.js +286 -286
  39. package/dist/cost-optimization-F3L5BS5F.js +303 -303
  40. package/dist/ingest-2LPTWUUM.js +16 -16
  41. package/dist/ingest-7T5FAZNC.js +15 -15
  42. package/dist/ingest-EBNIE7XB.js +15 -15
  43. package/dist/ingest-FSHT5BCS.js +15 -15
  44. package/dist/ingest-QE2BTV72.js +14 -14
  45. package/dist/oracle-3RLQF3DP.js +259 -259
  46. package/dist/oracle-FKRTQUUG.js +282 -282
  47. package/dist/oracle-J47QCSEW.js +263 -263
  48. package/dist/oracle-MDP5MZRC.js +256 -256
  49. package/dist/search-BLVHWLWC.js +14 -14
  50. package/dist/search-CZ5NYL5B.js +12 -12
  51. package/dist/search-EG6TYWWW.js +13 -13
  52. package/dist/search-I22QQA7T.js +13 -13
  53. package/dist/search-T7H5G6DW.js +13 -13
  54. package/dist/server.d.ts +2 -2
  55. package/dist/server.js +1973 -169
  56. package/dist/server.js.map +1 -1
  57. package/package.json +51 -51
@@ -1,303 +1,303 @@
1
- import {
2
- Anthropic
3
- } from "./chunk-H3HSKH2P.js";
4
- import "./chunk-QGM4M3NI.js";
5
-
6
- // ../src/engine/cost-optimization.ts
7
- var MODELS = {
8
- haiku: {
9
- model: "claude-haiku-4.5",
10
- maxTokens: 4096,
11
- temperature: 0,
12
- costPerMillion: 0.25
13
- // $0.25 per million input tokens
14
- },
15
- sonnet: {
16
- model: "claude-sonnet-4.5",
17
- maxTokens: 8192,
18
- temperature: 0,
19
- costPerMillion: 3
20
- // $3.00 per million input tokens
21
- },
22
- opus: {
23
- model: "claude-opus-4.5",
24
- maxTokens: 16384,
25
- temperature: 0,
26
- costPerMillion: 15
27
- // $15.00 per million input tokens
28
- }
29
- };
30
- var TASK_MODEL_MAP = {
31
- temporal_parsing: "haiku",
32
- // Fast, simple parsing
33
- simple_classification: "haiku",
34
- // Fast classification
35
- memory_extraction: "sonnet",
36
- // Needs accuracy for disambiguation
37
- relation_detection: "sonnet",
38
- // Needs reasoning
39
- consolidation: "sonnet",
40
- // Needs to merge intelligently
41
- summarization: "haiku",
42
- // Fast summarization
43
- complex_reasoning: "opus"
44
- // Deep reasoning tasks
45
- };
46
- function getOptimalModel(taskType, options = {}) {
47
- if (options.forceModel) {
48
- return MODELS[options.forceModel];
49
- }
50
- let tier = TASK_MODEL_MAP[taskType];
51
- if (options.minQuality && tier === "haiku") {
52
- tier = "sonnet";
53
- }
54
- return MODELS[tier];
55
- }
56
- function estimateCost(params) {
57
- const modelConfig = getOptimalModel(params.taskType, { forceModel: params.model });
58
- const inputCost = params.inputTokens / 1e6 * modelConfig.costPerMillion;
59
- const outputCostPerMillion = modelConfig.costPerMillion * 5;
60
- const outputCost = params.outputTokens / 1e6 * outputCostPerMillion;
61
- return {
62
- model: modelConfig.model,
63
- inputCost,
64
- outputCost,
65
- totalCost: inputCost + outputCost
66
- };
67
- }
68
- async function smartLLMCall(params) {
69
- const { taskType, prompt, systemPrompt, maxTokens, temperature, forceModel } = params;
70
- const modelConfig = getOptimalModel(taskType, { forceModel });
71
- const anthropic = new Anthropic({
72
- apiKey: process.env.ANTHROPIC_API_KEY || ""
73
- });
74
- const messages = [{ role: "user", content: prompt }];
75
- if (systemPrompt) {
76
- }
77
- const response = await anthropic.messages.create({
78
- model: modelConfig.model,
79
- max_tokens: maxTokens || modelConfig.maxTokens,
80
- temperature: temperature !== void 0 ? temperature : modelConfig.temperature,
81
- messages
82
- });
83
- const textContent = response.content.find((c) => c.type === "text");
84
- const responseText = textContent && textContent.type === "text" ? textContent.text : "";
85
- const tokensUsed = {
86
- input: response.usage.input_tokens,
87
- output: response.usage.output_tokens
88
- };
89
- const cost = estimateCost({
90
- taskType,
91
- inputTokens: tokensUsed.input,
92
- outputTokens: tokensUsed.output,
93
- model: forceModel
94
- });
95
- return {
96
- response: responseText,
97
- model: modelConfig.model,
98
- tokensUsed,
99
- cost: cost.totalCost
100
- };
101
- }
102
- async function batchOptimize(params) {
103
- const { items, processFn, batchSize = 10, delayMs = 100 } = params;
104
- const results = [];
105
- for (let i = 0; i < items.length; i += batchSize) {
106
- const batch = items.slice(i, i + batchSize);
107
- const batchResults = await Promise.all(batch.map(processFn));
108
- results.push(...batchResults);
109
- if (i + batchSize < items.length) {
110
- await new Promise((resolve) => setTimeout(resolve, delayMs));
111
- }
112
- }
113
- return results;
114
- }
115
- var costRecords = [];
116
- function trackCost(record) {
117
- costRecords.push({
118
- ...record,
119
- timestamp: /* @__PURE__ */ new Date()
120
- });
121
- }
122
- async function getCostSummary(params) {
123
- const { startDate, endDate } = params;
124
- let filtered = [...costRecords];
125
- if (startDate) {
126
- filtered = filtered.filter((r) => r.timestamp >= startDate);
127
- }
128
- if (endDate) {
129
- filtered = filtered.filter((r) => r.timestamp <= endDate);
130
- }
131
- const period = {
132
- start: filtered.length > 0 ? filtered[0].timestamp : /* @__PURE__ */ new Date(),
133
- end: filtered.length > 0 ? filtered[filtered.length - 1].timestamp : /* @__PURE__ */ new Date()
134
- };
135
- const totalCost = filtered.reduce((sum, r) => sum + r.cost, 0);
136
- const totalRequests = filtered.length;
137
- const costByModel = {};
138
- const costByTask = {};
139
- for (const record of filtered) {
140
- costByModel[record.model] = (costByModel[record.model] || 0) + record.cost;
141
- costByTask[record.taskType] = (costByTask[record.taskType] || 0) + record.cost;
142
- }
143
- const avgCostPerRequest = totalRequests > 0 ? totalCost / totalRequests : 0;
144
- const daysDiff = period.end.getTime() - period.start.getTime();
145
- const days = daysDiff > 0 ? daysDiff / (1e3 * 60 * 60 * 24) : 1;
146
- const estimatedMonthlyCost = totalCost / days * 30;
147
- return {
148
- period,
149
- totalCost,
150
- totalRequests,
151
- costByModel,
152
- costByTask,
153
- avgCostPerRequest,
154
- estimatedMonthlyCost
155
- };
156
- }
157
- function calculateSavings(params) {
158
- const { since } = params;
159
- const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
160
- const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
161
- const opusCost = filtered.reduce((sum, r) => {
162
- const cost = estimateCost({
163
- taskType: r.taskType,
164
- inputTokens: r.inputTokens,
165
- outputTokens: r.outputTokens,
166
- model: "opus"
167
- });
168
- return sum + cost.totalCost;
169
- }, 0);
170
- const savings = opusCost - actualCost;
171
- const savingsPercent = opusCost > 0 ? savings / opusCost * 100 : 0;
172
- return {
173
- actualCost,
174
- opusCost,
175
- savings,
176
- savingsPercent
177
- };
178
- }
179
- function recommendModelUpgrades(params) {
180
- const { errorRates, threshold = 0.05 } = params;
181
- const recommendations = [];
182
- for (const [taskType, errorRate] of Object.entries(errorRates)) {
183
- if (errorRate > threshold) {
184
- const currentModel = TASK_MODEL_MAP[taskType];
185
- let recommendedModel;
186
- if (currentModel === "haiku") {
187
- recommendedModel = "sonnet";
188
- } else if (currentModel === "sonnet") {
189
- recommendedModel = "opus";
190
- } else {
191
- continue;
192
- }
193
- recommendations.push({
194
- taskType,
195
- currentModel,
196
- recommendedModel
197
- });
198
- }
199
- }
200
- return recommendations;
201
- }
202
- async function getCostBreakdown(params) {
203
- const { groupBy, startDate, endDate } = params;
204
- let filtered = [...costRecords];
205
- if (startDate) {
206
- filtered = filtered.filter((r) => r.timestamp >= startDate);
207
- }
208
- if (endDate) {
209
- filtered = filtered.filter((r) => r.timestamp <= endDate);
210
- }
211
- const groups = {};
212
- for (const record of filtered) {
213
- let key;
214
- switch (groupBy) {
215
- case "model":
216
- key = record.model;
217
- break;
218
- case "task":
219
- key = record.taskType;
220
- break;
221
- case "day":
222
- key = record.timestamp.toISOString().split("T")[0];
223
- break;
224
- case "hour":
225
- key = record.timestamp.toISOString().slice(0, 13) + ":00";
226
- break;
227
- default:
228
- key = record.taskType;
229
- }
230
- if (!groups[key]) {
231
- groups[key] = { cost: 0, requests: 0 };
232
- }
233
- groups[key].cost += record.cost;
234
- groups[key].requests += 1;
235
- }
236
- const totalCost = filtered.reduce((sum, r) => sum + r.cost, 0);
237
- const totalRequests = filtered.length;
238
- return { groups, totalCost, totalRequests };
239
- }
240
- async function getSavingsReport(params) {
241
- const { startDate, endDate } = params;
242
- let filtered = [...costRecords];
243
- if (startDate) {
244
- filtered = filtered.filter((r) => r.timestamp >= startDate);
245
- }
246
- if (endDate) {
247
- filtered = filtered.filter((r) => r.timestamp <= endDate);
248
- }
249
- const period = {
250
- start: filtered.length > 0 ? filtered[0].timestamp : /* @__PURE__ */ new Date(),
251
- end: filtered.length > 0 ? filtered[filtered.length - 1].timestamp : /* @__PURE__ */ new Date()
252
- };
253
- const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
254
- let opusOnlyCost = 0;
255
- const requests = { total: filtered.length, haiku: 0, sonnet: 0, opus: 0 };
256
- for (const record of filtered) {
257
- opusOnlyCost += estimateCost({
258
- taskType: record.taskType,
259
- inputTokens: record.inputTokens,
260
- outputTokens: record.outputTokens,
261
- model: "opus"
262
- }).totalCost;
263
- if (record.model.includes("haiku")) {
264
- requests.haiku++;
265
- } else if (record.model.includes("sonnet")) {
266
- requests.sonnet++;
267
- } else if (record.model.includes("opus")) {
268
- requests.opus++;
269
- }
270
- }
271
- const savings = opusOnlyCost - actualCost;
272
- const savingsPercentage = opusOnlyCost > 0 ? savings / opusOnlyCost * 100 : 0;
273
- let recommendation = "";
274
- if (savingsPercentage > 50) {
275
- recommendation = "Excellent! Your model selection is highly optimized.";
276
- } else if (savingsPercentage > 30) {
277
- recommendation = "Good savings. Consider using Haiku for simpler tasks.";
278
- } else {
279
- recommendation = "Consider reviewing task complexity to better match models.";
280
- }
281
- return {
282
- period,
283
- actualCost,
284
- opusOnlyCost,
285
- savings,
286
- savingsPercentage,
287
- requests,
288
- recommendation
289
- };
290
- }
291
- export {
292
- MODELS,
293
- batchOptimize,
294
- calculateSavings,
295
- estimateCost,
296
- getCostBreakdown,
297
- getCostSummary,
298
- getOptimalModel,
299
- getSavingsReport,
300
- recommendModelUpgrades,
301
- smartLLMCall,
302
- trackCost
303
- };
1
+ import {
2
+ Anthropic
3
+ } from "./chunk-H3HSKH2P.js";
4
+ import "./chunk-QGM4M3NI.js";
5
+
6
+ // ../src/engine/cost-optimization.ts
7
+ var MODELS = {
8
+ haiku: {
9
+ model: "claude-haiku-4.5",
10
+ maxTokens: 4096,
11
+ temperature: 0,
12
+ costPerMillion: 0.25
13
+ // $0.25 per million input tokens
14
+ },
15
+ sonnet: {
16
+ model: "claude-sonnet-4.5",
17
+ maxTokens: 8192,
18
+ temperature: 0,
19
+ costPerMillion: 3
20
+ // $3.00 per million input tokens
21
+ },
22
+ opus: {
23
+ model: "claude-opus-4.5",
24
+ maxTokens: 16384,
25
+ temperature: 0,
26
+ costPerMillion: 15
27
+ // $15.00 per million input tokens
28
+ }
29
+ };
30
+ var TASK_MODEL_MAP = {
31
+ temporal_parsing: "haiku",
32
+ // Fast, simple parsing
33
+ simple_classification: "haiku",
34
+ // Fast classification
35
+ memory_extraction: "sonnet",
36
+ // Needs accuracy for disambiguation
37
+ relation_detection: "sonnet",
38
+ // Needs reasoning
39
+ consolidation: "sonnet",
40
+ // Needs to merge intelligently
41
+ summarization: "haiku",
42
+ // Fast summarization
43
+ complex_reasoning: "opus"
44
+ // Deep reasoning tasks
45
+ };
46
+ function getOptimalModel(taskType, options = {}) {
47
+ if (options.forceModel) {
48
+ return MODELS[options.forceModel];
49
+ }
50
+ let tier = TASK_MODEL_MAP[taskType];
51
+ if (options.minQuality && tier === "haiku") {
52
+ tier = "sonnet";
53
+ }
54
+ return MODELS[tier];
55
+ }
56
+ function estimateCost(params) {
57
+ const modelConfig = getOptimalModel(params.taskType, { forceModel: params.model });
58
+ const inputCost = params.inputTokens / 1e6 * modelConfig.costPerMillion;
59
+ const outputCostPerMillion = modelConfig.costPerMillion * 5;
60
+ const outputCost = params.outputTokens / 1e6 * outputCostPerMillion;
61
+ return {
62
+ model: modelConfig.model,
63
+ inputCost,
64
+ outputCost,
65
+ totalCost: inputCost + outputCost
66
+ };
67
+ }
68
+ async function smartLLMCall(params) {
69
+ const { taskType, prompt, systemPrompt, maxTokens, temperature, forceModel } = params;
70
+ const modelConfig = getOptimalModel(taskType, { forceModel });
71
+ const anthropic = new Anthropic({
72
+ apiKey: process.env.ANTHROPIC_API_KEY || ""
73
+ });
74
+ const messages = [{ role: "user", content: prompt }];
75
+ if (systemPrompt) {
76
+ }
77
+ const response = await anthropic.messages.create({
78
+ model: modelConfig.model,
79
+ max_tokens: maxTokens || modelConfig.maxTokens,
80
+ temperature: temperature !== void 0 ? temperature : modelConfig.temperature,
81
+ messages
82
+ });
83
+ const textContent = response.content.find((c) => c.type === "text");
84
+ const responseText = textContent && textContent.type === "text" ? textContent.text : "";
85
+ const tokensUsed = {
86
+ input: response.usage.input_tokens,
87
+ output: response.usage.output_tokens
88
+ };
89
+ const cost = estimateCost({
90
+ taskType,
91
+ inputTokens: tokensUsed.input,
92
+ outputTokens: tokensUsed.output,
93
+ model: forceModel
94
+ });
95
+ return {
96
+ response: responseText,
97
+ model: modelConfig.model,
98
+ tokensUsed,
99
+ cost: cost.totalCost
100
+ };
101
+ }
102
+ async function batchOptimize(params) {
103
+ const { items, processFn, batchSize = 10, delayMs = 100 } = params;
104
+ const results = [];
105
+ for (let i = 0; i < items.length; i += batchSize) {
106
+ const batch = items.slice(i, i + batchSize);
107
+ const batchResults = await Promise.all(batch.map(processFn));
108
+ results.push(...batchResults);
109
+ if (i + batchSize < items.length) {
110
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
111
+ }
112
+ }
113
+ return results;
114
+ }
115
+ var costRecords = [];
116
+ function trackCost(record) {
117
+ costRecords.push({
118
+ ...record,
119
+ timestamp: /* @__PURE__ */ new Date()
120
+ });
121
+ }
122
+ async function getCostSummary(params) {
123
+ const { startDate, endDate } = params;
124
+ let filtered = [...costRecords];
125
+ if (startDate) {
126
+ filtered = filtered.filter((r) => r.timestamp >= startDate);
127
+ }
128
+ if (endDate) {
129
+ filtered = filtered.filter((r) => r.timestamp <= endDate);
130
+ }
131
+ const period = {
132
+ start: filtered.length > 0 ? filtered[0].timestamp : /* @__PURE__ */ new Date(),
133
+ end: filtered.length > 0 ? filtered[filtered.length - 1].timestamp : /* @__PURE__ */ new Date()
134
+ };
135
+ const totalCost = filtered.reduce((sum, r) => sum + r.cost, 0);
136
+ const totalRequests = filtered.length;
137
+ const costByModel = {};
138
+ const costByTask = {};
139
+ for (const record of filtered) {
140
+ costByModel[record.model] = (costByModel[record.model] || 0) + record.cost;
141
+ costByTask[record.taskType] = (costByTask[record.taskType] || 0) + record.cost;
142
+ }
143
+ const avgCostPerRequest = totalRequests > 0 ? totalCost / totalRequests : 0;
144
+ const daysDiff = period.end.getTime() - period.start.getTime();
145
+ const days = daysDiff > 0 ? daysDiff / (1e3 * 60 * 60 * 24) : 1;
146
+ const estimatedMonthlyCost = totalCost / days * 30;
147
+ return {
148
+ period,
149
+ totalCost,
150
+ totalRequests,
151
+ costByModel,
152
+ costByTask,
153
+ avgCostPerRequest,
154
+ estimatedMonthlyCost
155
+ };
156
+ }
157
+ function calculateSavings(params) {
158
+ const { since } = params;
159
+ const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
160
+ const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
161
+ const opusCost = filtered.reduce((sum, r) => {
162
+ const cost = estimateCost({
163
+ taskType: r.taskType,
164
+ inputTokens: r.inputTokens,
165
+ outputTokens: r.outputTokens,
166
+ model: "opus"
167
+ });
168
+ return sum + cost.totalCost;
169
+ }, 0);
170
+ const savings = opusCost - actualCost;
171
+ const savingsPercent = opusCost > 0 ? savings / opusCost * 100 : 0;
172
+ return {
173
+ actualCost,
174
+ opusCost,
175
+ savings,
176
+ savingsPercent
177
+ };
178
+ }
179
+ function recommendModelUpgrades(params) {
180
+ const { errorRates, threshold = 0.05 } = params;
181
+ const recommendations = [];
182
+ for (const [taskType, errorRate] of Object.entries(errorRates)) {
183
+ if (errorRate > threshold) {
184
+ const currentModel = TASK_MODEL_MAP[taskType];
185
+ let recommendedModel;
186
+ if (currentModel === "haiku") {
187
+ recommendedModel = "sonnet";
188
+ } else if (currentModel === "sonnet") {
189
+ recommendedModel = "opus";
190
+ } else {
191
+ continue;
192
+ }
193
+ recommendations.push({
194
+ taskType,
195
+ currentModel,
196
+ recommendedModel
197
+ });
198
+ }
199
+ }
200
+ return recommendations;
201
+ }
202
+ async function getCostBreakdown(params) {
203
+ const { groupBy, startDate, endDate } = params;
204
+ let filtered = [...costRecords];
205
+ if (startDate) {
206
+ filtered = filtered.filter((r) => r.timestamp >= startDate);
207
+ }
208
+ if (endDate) {
209
+ filtered = filtered.filter((r) => r.timestamp <= endDate);
210
+ }
211
+ const groups = {};
212
+ for (const record of filtered) {
213
+ let key;
214
+ switch (groupBy) {
215
+ case "model":
216
+ key = record.model;
217
+ break;
218
+ case "task":
219
+ key = record.taskType;
220
+ break;
221
+ case "day":
222
+ key = record.timestamp.toISOString().split("T")[0];
223
+ break;
224
+ case "hour":
225
+ key = record.timestamp.toISOString().slice(0, 13) + ":00";
226
+ break;
227
+ default:
228
+ key = record.taskType;
229
+ }
230
+ if (!groups[key]) {
231
+ groups[key] = { cost: 0, requests: 0 };
232
+ }
233
+ groups[key].cost += record.cost;
234
+ groups[key].requests += 1;
235
+ }
236
+ const totalCost = filtered.reduce((sum, r) => sum + r.cost, 0);
237
+ const totalRequests = filtered.length;
238
+ return { groups, totalCost, totalRequests };
239
+ }
240
+ async function getSavingsReport(params) {
241
+ const { startDate, endDate } = params;
242
+ let filtered = [...costRecords];
243
+ if (startDate) {
244
+ filtered = filtered.filter((r) => r.timestamp >= startDate);
245
+ }
246
+ if (endDate) {
247
+ filtered = filtered.filter((r) => r.timestamp <= endDate);
248
+ }
249
+ const period = {
250
+ start: filtered.length > 0 ? filtered[0].timestamp : /* @__PURE__ */ new Date(),
251
+ end: filtered.length > 0 ? filtered[filtered.length - 1].timestamp : /* @__PURE__ */ new Date()
252
+ };
253
+ const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
254
+ let opusOnlyCost = 0;
255
+ const requests = { total: filtered.length, haiku: 0, sonnet: 0, opus: 0 };
256
+ for (const record of filtered) {
257
+ opusOnlyCost += estimateCost({
258
+ taskType: record.taskType,
259
+ inputTokens: record.inputTokens,
260
+ outputTokens: record.outputTokens,
261
+ model: "opus"
262
+ }).totalCost;
263
+ if (record.model.includes("haiku")) {
264
+ requests.haiku++;
265
+ } else if (record.model.includes("sonnet")) {
266
+ requests.sonnet++;
267
+ } else if (record.model.includes("opus")) {
268
+ requests.opus++;
269
+ }
270
+ }
271
+ const savings = opusOnlyCost - actualCost;
272
+ const savingsPercentage = opusOnlyCost > 0 ? savings / opusOnlyCost * 100 : 0;
273
+ let recommendation = "";
274
+ if (savingsPercentage > 50) {
275
+ recommendation = "Excellent! Your model selection is highly optimized.";
276
+ } else if (savingsPercentage > 30) {
277
+ recommendation = "Good savings. Consider using Haiku for simpler tasks.";
278
+ } else {
279
+ recommendation = "Consider reviewing task complexity to better match models.";
280
+ }
281
+ return {
282
+ period,
283
+ actualCost,
284
+ opusOnlyCost,
285
+ savings,
286
+ savingsPercentage,
287
+ requests,
288
+ recommendation
289
+ };
290
+ }
291
+ export {
292
+ MODELS,
293
+ batchOptimize,
294
+ calculateSavings,
295
+ estimateCost,
296
+ getCostBreakdown,
297
+ getCostSummary,
298
+ getOptimalModel,
299
+ getSavingsReport,
300
+ recommendModelUpgrades,
301
+ smartLLMCall,
302
+ trackCost
303
+ };
@@ -1,16 +1,16 @@
1
- import {
2
- ingestChunk,
3
- ingestChunksBatch,
4
- ingestSession,
5
- updateMemory
6
- } from "./chunk-C57DHKTL.js";
7
- import "./chunk-5KIJNY6Z.js";
8
- import "./chunk-3WGYBAYR.js";
9
- import "./chunk-H3HSKH2P.js";
10
- import "./chunk-QGM4M3NI.js";
11
- export {
12
- ingestChunk,
13
- ingestChunksBatch,
14
- ingestSession,
15
- updateMemory
16
- };
1
+ import {
2
+ ingestChunk,
3
+ ingestChunksBatch,
4
+ ingestSession,
5
+ updateMemory
6
+ } from "./chunk-C57DHKTL.js";
7
+ import "./chunk-5KIJNY6Z.js";
8
+ import "./chunk-3WGYBAYR.js";
9
+ import "./chunk-H3HSKH2P.js";
10
+ import "./chunk-QGM4M3NI.js";
11
+ export {
12
+ ingestChunk,
13
+ ingestChunksBatch,
14
+ ingestSession,
15
+ updateMemory
16
+ };
@@ -1,15 +1,15 @@
1
- import {
2
- ingestChunk,
3
- ingestChunksBatch,
4
- ingestSession,
5
- updateMemory
6
- } from "./chunk-EI5CE3EY.js";
7
- import "./chunk-5KBZQHDL.js";
8
- import "./chunk-3WGYBAYR.js";
9
- import "./chunk-QGM4M3NI.js";
10
- export {
11
- ingestChunk,
12
- ingestChunksBatch,
13
- ingestSession,
14
- updateMemory
15
- };
1
+ import {
2
+ ingestChunk,
3
+ ingestChunksBatch,
4
+ ingestSession,
5
+ updateMemory
6
+ } from "./chunk-EI5CE3EY.js";
7
+ import "./chunk-5KBZQHDL.js";
8
+ import "./chunk-3WGYBAYR.js";
9
+ import "./chunk-QGM4M3NI.js";
10
+ export {
11
+ ingestChunk,
12
+ ingestChunksBatch,
13
+ ingestSession,
14
+ updateMemory
15
+ };