@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,196 +1,196 @@
1
- // src/engine/cost-optimization.ts
2
- import Anthropic from "@anthropic-ai/sdk";
3
- var MODELS = {
4
- haiku: {
5
- model: "claude-haiku-4.5",
6
- maxTokens: 4096,
7
- temperature: 0,
8
- costPerMillion: 0.25
9
- // $0.25 per million input tokens
10
- },
11
- sonnet: {
12
- model: "claude-sonnet-4.5",
13
- maxTokens: 8192,
14
- temperature: 0,
15
- costPerMillion: 3
16
- // $3.00 per million input tokens
17
- },
18
- opus: {
19
- model: "claude-opus-4.5",
20
- maxTokens: 16384,
21
- temperature: 0,
22
- costPerMillion: 15
23
- // $15.00 per million input tokens
24
- }
25
- };
26
- var TASK_MODEL_MAP = {
27
- temporal_parsing: "haiku",
28
- // Fast, simple parsing
29
- simple_classification: "haiku",
30
- // Fast classification
31
- memory_extraction: "sonnet",
32
- // Needs accuracy for disambiguation
33
- relation_detection: "sonnet",
34
- // Needs reasoning
35
- consolidation: "sonnet",
36
- // Needs to merge intelligently
37
- summarization: "haiku",
38
- // Fast summarization
39
- complex_reasoning: "opus"
40
- // Deep reasoning tasks
41
- };
42
- function getOptimalModel(taskType, options = {}) {
43
- if (options.forceModel) {
44
- return MODELS[options.forceModel];
45
- }
46
- let tier = TASK_MODEL_MAP[taskType];
47
- if (options.minQuality && tier === "haiku") {
48
- tier = "sonnet";
49
- }
50
- return MODELS[tier];
51
- }
52
- function estimateCost(params) {
53
- const modelConfig = getOptimalModel(params.taskType, { forceModel: params.model });
54
- const inputCost = params.inputTokens / 1e6 * modelConfig.costPerMillion;
55
- const outputCostPerMillion = modelConfig.costPerMillion * 5;
56
- const outputCost = params.outputTokens / 1e6 * outputCostPerMillion;
57
- return {
58
- model: modelConfig.model,
59
- inputCost,
60
- outputCost,
61
- totalCost: inputCost + outputCost
62
- };
63
- }
64
- async function smartLLMCall(params) {
65
- const { taskType, prompt, systemPrompt, maxTokens, temperature, forceModel } = params;
66
- const modelConfig = getOptimalModel(taskType, { forceModel });
67
- const anthropic = new Anthropic({
68
- apiKey: process.env.ANTHROPIC_API_KEY || ""
69
- });
70
- const messages = [{ role: "user", content: prompt }];
71
- if (systemPrompt) {
72
- }
73
- const response = await anthropic.messages.create({
74
- model: modelConfig.model,
75
- max_tokens: maxTokens || modelConfig.maxTokens,
76
- temperature: temperature !== void 0 ? temperature : modelConfig.temperature,
77
- messages
78
- });
79
- const textContent = response.content.find((c) => c.type === "text");
80
- const responseText = textContent && textContent.type === "text" ? textContent.text : "";
81
- const tokensUsed = {
82
- input: response.usage.input_tokens,
83
- output: response.usage.output_tokens
84
- };
85
- const cost = estimateCost({
86
- taskType,
87
- inputTokens: tokensUsed.input,
88
- outputTokens: tokensUsed.output,
89
- model: forceModel
90
- });
91
- return {
92
- response: responseText,
93
- model: modelConfig.model,
94
- tokensUsed,
95
- cost: cost.totalCost
96
- };
97
- }
98
- async function batchOptimize(params) {
99
- const { items, processFn, batchSize = 10, delayMs = 100 } = params;
100
- const results = [];
101
- for (let i = 0; i < items.length; i += batchSize) {
102
- const batch = items.slice(i, i + batchSize);
103
- const batchResults = await Promise.all(batch.map(processFn));
104
- results.push(...batchResults);
105
- if (i + batchSize < items.length) {
106
- await new Promise((resolve) => setTimeout(resolve, delayMs));
107
- }
108
- }
109
- return results;
110
- }
111
- var costRecords = [];
112
- function trackCost(record) {
113
- costRecords.push({
114
- ...record,
115
- timestamp: /* @__PURE__ */ new Date()
116
- });
117
- }
118
- function getCostSummary(params) {
119
- const { since, groupBy = "taskType" } = params;
120
- const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
121
- const grouped = {};
122
- for (const record of filtered) {
123
- const key = record[groupBy];
124
- if (!grouped[key]) {
125
- grouped[key] = [];
126
- }
127
- grouped[key].push(record);
128
- }
129
- const summary = {};
130
- for (const [key, records] of Object.entries(grouped)) {
131
- const totalCost = records.reduce((sum, r) => sum + r.cost, 0);
132
- summary[key] = {
133
- calls: records.length,
134
- totalCost,
135
- avgCost: totalCost / records.length
136
- };
137
- }
138
- return summary;
139
- }
140
- function calculateSavings(params) {
141
- const { since } = params;
142
- const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
143
- const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
144
- const opusCost = filtered.reduce((sum, r) => {
145
- const cost = estimateCost({
146
- taskType: r.taskType,
147
- inputTokens: r.inputTokens,
148
- outputTokens: r.outputTokens,
149
- model: "opus"
150
- });
151
- return sum + cost.totalCost;
152
- }, 0);
153
- const savings = opusCost - actualCost;
154
- const savingsPercent = opusCost > 0 ? savings / opusCost * 100 : 0;
155
- return {
156
- actualCost,
157
- opusCost,
158
- savings,
159
- savingsPercent
160
- };
161
- }
162
- function recommendModelUpgrades(params) {
163
- const { errorRates, threshold = 0.05 } = params;
164
- const recommendations = [];
165
- for (const [taskType, errorRate] of Object.entries(errorRates)) {
166
- if (errorRate > threshold) {
167
- const currentModel = TASK_MODEL_MAP[taskType];
168
- let recommendedModel;
169
- if (currentModel === "haiku") {
170
- recommendedModel = "sonnet";
171
- } else if (currentModel === "sonnet") {
172
- recommendedModel = "opus";
173
- } else {
174
- continue;
175
- }
176
- recommendations.push({
177
- taskType,
178
- currentModel,
179
- recommendedModel
180
- });
181
- }
182
- }
183
- return recommendations;
184
- }
185
- export {
186
- MODELS,
187
- batchOptimize,
188
- calculateSavings,
189
- estimateCost,
190
- getCostSummary,
191
- getOptimalModel,
192
- recommendModelUpgrades,
193
- smartLLMCall,
194
- trackCost
195
- };
1
+ // src/engine/cost-optimization.ts
2
+ import Anthropic from "@anthropic-ai/sdk";
3
+ var MODELS = {
4
+ haiku: {
5
+ model: "claude-haiku-4.5",
6
+ maxTokens: 4096,
7
+ temperature: 0,
8
+ costPerMillion: 0.25
9
+ // $0.25 per million input tokens
10
+ },
11
+ sonnet: {
12
+ model: "claude-sonnet-4.5",
13
+ maxTokens: 8192,
14
+ temperature: 0,
15
+ costPerMillion: 3
16
+ // $3.00 per million input tokens
17
+ },
18
+ opus: {
19
+ model: "claude-opus-4.5",
20
+ maxTokens: 16384,
21
+ temperature: 0,
22
+ costPerMillion: 15
23
+ // $15.00 per million input tokens
24
+ }
25
+ };
26
+ var TASK_MODEL_MAP = {
27
+ temporal_parsing: "haiku",
28
+ // Fast, simple parsing
29
+ simple_classification: "haiku",
30
+ // Fast classification
31
+ memory_extraction: "sonnet",
32
+ // Needs accuracy for disambiguation
33
+ relation_detection: "sonnet",
34
+ // Needs reasoning
35
+ consolidation: "sonnet",
36
+ // Needs to merge intelligently
37
+ summarization: "haiku",
38
+ // Fast summarization
39
+ complex_reasoning: "opus"
40
+ // Deep reasoning tasks
41
+ };
42
+ function getOptimalModel(taskType, options = {}) {
43
+ if (options.forceModel) {
44
+ return MODELS[options.forceModel];
45
+ }
46
+ let tier = TASK_MODEL_MAP[taskType];
47
+ if (options.minQuality && tier === "haiku") {
48
+ tier = "sonnet";
49
+ }
50
+ return MODELS[tier];
51
+ }
52
+ function estimateCost(params) {
53
+ const modelConfig = getOptimalModel(params.taskType, { forceModel: params.model });
54
+ const inputCost = params.inputTokens / 1e6 * modelConfig.costPerMillion;
55
+ const outputCostPerMillion = modelConfig.costPerMillion * 5;
56
+ const outputCost = params.outputTokens / 1e6 * outputCostPerMillion;
57
+ return {
58
+ model: modelConfig.model,
59
+ inputCost,
60
+ outputCost,
61
+ totalCost: inputCost + outputCost
62
+ };
63
+ }
64
+ async function smartLLMCall(params) {
65
+ const { taskType, prompt, systemPrompt, maxTokens, temperature, forceModel } = params;
66
+ const modelConfig = getOptimalModel(taskType, { forceModel });
67
+ const anthropic = new Anthropic({
68
+ apiKey: process.env.ANTHROPIC_API_KEY || ""
69
+ });
70
+ const messages = [{ role: "user", content: prompt }];
71
+ if (systemPrompt) {
72
+ }
73
+ const response = await anthropic.messages.create({
74
+ model: modelConfig.model,
75
+ max_tokens: maxTokens || modelConfig.maxTokens,
76
+ temperature: temperature !== void 0 ? temperature : modelConfig.temperature,
77
+ messages
78
+ });
79
+ const textContent = response.content.find((c) => c.type === "text");
80
+ const responseText = textContent && textContent.type === "text" ? textContent.text : "";
81
+ const tokensUsed = {
82
+ input: response.usage.input_tokens,
83
+ output: response.usage.output_tokens
84
+ };
85
+ const cost = estimateCost({
86
+ taskType,
87
+ inputTokens: tokensUsed.input,
88
+ outputTokens: tokensUsed.output,
89
+ model: forceModel
90
+ });
91
+ return {
92
+ response: responseText,
93
+ model: modelConfig.model,
94
+ tokensUsed,
95
+ cost: cost.totalCost
96
+ };
97
+ }
98
+ async function batchOptimize(params) {
99
+ const { items, processFn, batchSize = 10, delayMs = 100 } = params;
100
+ const results = [];
101
+ for (let i = 0; i < items.length; i += batchSize) {
102
+ const batch = items.slice(i, i + batchSize);
103
+ const batchResults = await Promise.all(batch.map(processFn));
104
+ results.push(...batchResults);
105
+ if (i + batchSize < items.length) {
106
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
107
+ }
108
+ }
109
+ return results;
110
+ }
111
+ var costRecords = [];
112
+ function trackCost(record) {
113
+ costRecords.push({
114
+ ...record,
115
+ timestamp: /* @__PURE__ */ new Date()
116
+ });
117
+ }
118
+ function getCostSummary(params) {
119
+ const { since, groupBy = "taskType" } = params;
120
+ const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
121
+ const grouped = {};
122
+ for (const record of filtered) {
123
+ const key = record[groupBy];
124
+ if (!grouped[key]) {
125
+ grouped[key] = [];
126
+ }
127
+ grouped[key].push(record);
128
+ }
129
+ const summary = {};
130
+ for (const [key, records] of Object.entries(grouped)) {
131
+ const totalCost = records.reduce((sum, r) => sum + r.cost, 0);
132
+ summary[key] = {
133
+ calls: records.length,
134
+ totalCost,
135
+ avgCost: totalCost / records.length
136
+ };
137
+ }
138
+ return summary;
139
+ }
140
+ function calculateSavings(params) {
141
+ const { since } = params;
142
+ const filtered = since ? costRecords.filter((r) => r.timestamp >= since) : costRecords;
143
+ const actualCost = filtered.reduce((sum, r) => sum + r.cost, 0);
144
+ const opusCost = filtered.reduce((sum, r) => {
145
+ const cost = estimateCost({
146
+ taskType: r.taskType,
147
+ inputTokens: r.inputTokens,
148
+ outputTokens: r.outputTokens,
149
+ model: "opus"
150
+ });
151
+ return sum + cost.totalCost;
152
+ }, 0);
153
+ const savings = opusCost - actualCost;
154
+ const savingsPercent = opusCost > 0 ? savings / opusCost * 100 : 0;
155
+ return {
156
+ actualCost,
157
+ opusCost,
158
+ savings,
159
+ savingsPercent
160
+ };
161
+ }
162
+ function recommendModelUpgrades(params) {
163
+ const { errorRates, threshold = 0.05 } = params;
164
+ const recommendations = [];
165
+ for (const [taskType, errorRate] of Object.entries(errorRates)) {
166
+ if (errorRate > threshold) {
167
+ const currentModel = TASK_MODEL_MAP[taskType];
168
+ let recommendedModel;
169
+ if (currentModel === "haiku") {
170
+ recommendedModel = "sonnet";
171
+ } else if (currentModel === "sonnet") {
172
+ recommendedModel = "opus";
173
+ } else {
174
+ continue;
175
+ }
176
+ recommendations.push({
177
+ taskType,
178
+ currentModel,
179
+ recommendedModel
180
+ });
181
+ }
182
+ }
183
+ return recommendations;
184
+ }
185
+ export {
186
+ MODELS,
187
+ batchOptimize,
188
+ calculateSavings,
189
+ estimateCost,
190
+ getCostSummary,
191
+ getOptimalModel,
192
+ recommendModelUpgrades,
193
+ smartLLMCall,
194
+ trackCost
195
+ };
196
196
  //# sourceMappingURL=cost-optimization-6OIKRSBV.js.map