@tyvm/knowhow 0.0.69 → 0.0.71
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.
- package/docs/shell-commands.md +174 -0
- package/package.json +1 -1
- package/src/agents/base/base.ts +4 -5
- package/src/agents/developer/developer.ts +21 -13
- package/src/agents/tools/agentCall.ts +4 -2
- package/src/agents/tools/fileSearch.ts +5 -1
- package/src/agents/tools/startAgentTask.ts +131 -22
- package/src/agents/tools/stringReplace.ts +42 -12
- package/src/chat/CliChatService.ts +57 -11
- package/src/chat/modules/AgentModule.ts +72 -12
- package/src/chat/modules/CustomCommandsModule.ts +79 -0
- package/src/chat/modules/InternalChatModule.ts +11 -1
- package/src/chat/modules/ShellCommandModule.ts +96 -0
- package/src/chat/modules/index.ts +1 -0
- package/src/chat/types.ts +14 -2
- package/src/chat.ts +16 -13
- package/src/cli.ts +16 -6
- package/src/clients/anthropic.ts +82 -112
- package/src/clients/gemini.ts +445 -87
- package/src/clients/index.ts +125 -0
- package/src/clients/knowhow.ts +81 -0
- package/src/clients/openai.ts +256 -145
- package/src/clients/pricing/anthropic.ts +90 -0
- package/src/clients/pricing/google.ts +65 -0
- package/src/clients/pricing/index.ts +4 -0
- package/src/clients/pricing/openai.ts +134 -0
- package/src/clients/pricing/xai.ts +62 -0
- package/src/clients/types.ts +170 -1
- package/src/clients/xai.ts +275 -46
- package/src/config.ts +61 -15
- package/src/embeddings.ts +9 -1
- package/src/microphone.ts +15 -16
- package/src/migrations.ts +151 -0
- package/src/plugins/AgentsMdPlugin.ts +118 -0
- package/src/plugins/PluginBase.ts +8 -0
- package/src/plugins/downloader/downloader.ts +5 -6
- package/src/plugins/embedding.ts +10 -8
- package/src/plugins/exec.ts +70 -0
- package/src/plugins/github.ts +120 -74
- package/src/plugins/language.ts +11 -13
- package/src/plugins/plugins.ts +25 -4
- package/src/plugins/tmux.ts +132 -0
- package/src/plugins/types.ts +1 -0
- package/src/plugins/vim.ts +14 -1
- package/src/services/AgentSyncFs.ts +417 -0
- package/src/services/{AgentSynchronization.ts → AgentSyncKnowhowWeb.ts} +2 -2
- package/src/services/EventService.ts +0 -1
- package/src/services/KnowhowClient.ts +106 -0
- package/src/services/index.ts +4 -2
- package/src/types.ts +57 -4
- package/src/worker.ts +11 -6
- package/tests/manual/modalities/README.md +157 -0
- package/tests/manual/modalities/google.modalities.test.ts +335 -0
- package/tests/manual/modalities/openai.modalities.test.ts +329 -0
- package/tests/manual/modalities/streaming.test.ts +260 -0
- package/tests/manual/modalities/xai.modalities.test.ts +307 -0
- package/tests/plugins/language/languagePlugin-content-triggers.test.ts +5 -5
- package/tests/plugins/language/languagePlugin-integration.test.ts +1 -1
- package/tests/plugins/language/languagePlugin.test.ts +17 -8
- package/ts_build/package.json +1 -1
- package/ts_build/src/agents/base/base.d.ts +3 -3
- package/ts_build/src/agents/base/base.js +1 -1
- package/ts_build/src/agents/base/base.js.map +1 -1
- package/ts_build/src/agents/developer/developer.js +21 -12
- package/ts_build/src/agents/developer/developer.js.map +1 -1
- package/ts_build/src/agents/tools/agentCall.js +4 -2
- package/ts_build/src/agents/tools/agentCall.js.map +1 -1
- package/ts_build/src/agents/tools/executeScript/index.d.ts +1 -1
- package/ts_build/src/agents/tools/fileSearch.js +2 -1
- package/ts_build/src/agents/tools/fileSearch.js.map +1 -1
- package/ts_build/src/agents/tools/github/index.d.ts +1 -1
- package/ts_build/src/agents/tools/startAgentTask.d.ts +2 -1
- package/ts_build/src/agents/tools/startAgentTask.js +118 -17
- package/ts_build/src/agents/tools/startAgentTask.js.map +1 -1
- package/ts_build/src/agents/tools/stringReplace.js +29 -12
- package/ts_build/src/agents/tools/stringReplace.js.map +1 -1
- package/ts_build/src/chat/CliChatService.d.ts +4 -0
- package/ts_build/src/chat/CliChatService.js +39 -5
- package/ts_build/src/chat/CliChatService.js.map +1 -1
- package/ts_build/src/chat/modules/AgentModule.d.ts +4 -1
- package/ts_build/src/chat/modules/AgentModule.js +49 -11
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
- package/ts_build/src/chat/modules/CustomCommandsModule.d.ts +9 -0
- package/ts_build/src/chat/modules/CustomCommandsModule.js +58 -0
- package/ts_build/src/chat/modules/CustomCommandsModule.js.map +1 -0
- package/ts_build/src/chat/modules/InternalChatModule.d.ts +2 -0
- package/ts_build/src/chat/modules/InternalChatModule.js +10 -0
- package/ts_build/src/chat/modules/InternalChatModule.js.map +1 -1
- package/ts_build/src/chat/modules/ShellCommandModule.d.ts +8 -0
- package/ts_build/src/chat/modules/ShellCommandModule.js +83 -0
- package/ts_build/src/chat/modules/ShellCommandModule.js.map +1 -0
- package/ts_build/src/chat/modules/index.d.ts +1 -0
- package/ts_build/src/chat/modules/index.js +3 -1
- package/ts_build/src/chat/modules/index.js.map +1 -1
- package/ts_build/src/chat/types.d.ts +11 -1
- package/ts_build/src/chat.js +16 -13
- package/ts_build/src/chat.js.map +1 -1
- package/ts_build/src/cli.js +10 -3
- package/ts_build/src/cli.js.map +1 -1
- package/ts_build/src/clients/anthropic.d.ts +5 -1
- package/ts_build/src/clients/anthropic.js +61 -112
- package/ts_build/src/clients/anthropic.js.map +1 -1
- package/ts_build/src/clients/gemini.d.ts +80 -2
- package/ts_build/src/clients/gemini.js +336 -74
- package/ts_build/src/clients/gemini.js.map +1 -1
- package/ts_build/src/clients/index.d.ts +9 -1
- package/ts_build/src/clients/index.js +65 -0
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/knowhow.d.ts +9 -1
- package/ts_build/src/clients/knowhow.js +43 -0
- package/ts_build/src/clients/knowhow.js.map +1 -1
- package/ts_build/src/clients/openai.d.ts +9 -1
- package/ts_build/src/clients/openai.js +201 -133
- package/ts_build/src/clients/openai.js.map +1 -1
- package/ts_build/src/clients/pricing/anthropic.d.ts +17 -0
- package/ts_build/src/clients/pricing/anthropic.js +93 -0
- package/ts_build/src/clients/pricing/anthropic.js.map +1 -0
- package/ts_build/src/clients/pricing/google.d.ts +73 -0
- package/ts_build/src/clients/pricing/google.js +68 -0
- package/ts_build/src/clients/pricing/google.js.map +1 -0
- package/ts_build/src/clients/pricing/index.d.ts +4 -0
- package/ts_build/src/clients/pricing/index.js +14 -0
- package/ts_build/src/clients/pricing/index.js.map +1 -0
- package/ts_build/src/clients/pricing/openai.d.ts +7 -0
- package/ts_build/src/clients/pricing/openai.js +137 -0
- package/ts_build/src/clients/pricing/openai.js.map +1 -0
- package/ts_build/src/clients/pricing/xai.d.ts +26 -0
- package/ts_build/src/clients/pricing/xai.js +59 -0
- package/ts_build/src/clients/pricing/xai.js.map +1 -0
- package/ts_build/src/clients/types.d.ts +135 -0
- package/ts_build/src/clients/xai.d.ts +9 -1
- package/ts_build/src/clients/xai.js +178 -46
- package/ts_build/src/clients/xai.js.map +1 -1
- package/ts_build/src/config.d.ts +1 -0
- package/ts_build/src/config.js +45 -16
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/embeddings.js +8 -1
- package/ts_build/src/embeddings.js.map +1 -1
- package/ts_build/src/microphone.js +7 -9
- package/ts_build/src/microphone.js.map +1 -1
- package/ts_build/src/migrations.d.ts +17 -0
- package/ts_build/src/migrations.js +86 -0
- package/ts_build/src/migrations.js.map +1 -0
- package/ts_build/src/plugins/AgentsMdPlugin.d.ts +13 -0
- package/ts_build/src/plugins/AgentsMdPlugin.js +118 -0
- package/ts_build/src/plugins/AgentsMdPlugin.js.map +1 -0
- package/ts_build/src/plugins/PluginBase.d.ts +1 -0
- package/ts_build/src/plugins/PluginBase.js +3 -0
- package/ts_build/src/plugins/PluginBase.js.map +1 -1
- package/ts_build/src/plugins/downloader/downloader.js +5 -5
- package/ts_build/src/plugins/downloader/downloader.js.map +1 -1
- package/ts_build/src/plugins/embedding.js +9 -8
- package/ts_build/src/plugins/embedding.js.map +1 -1
- package/ts_build/src/plugins/exec.d.ts +10 -0
- package/ts_build/src/plugins/exec.js +56 -0
- package/ts_build/src/plugins/exec.js.map +1 -0
- package/ts_build/src/plugins/github.js +93 -51
- package/ts_build/src/plugins/github.js.map +1 -1
- package/ts_build/src/plugins/language.js +14 -11
- package/ts_build/src/plugins/language.js.map +1 -1
- package/ts_build/src/plugins/plugins.d.ts +1 -0
- package/ts_build/src/plugins/plugins.js +19 -1
- package/ts_build/src/plugins/plugins.js.map +1 -1
- package/ts_build/src/plugins/tmux.d.ts +14 -0
- package/ts_build/src/plugins/tmux.js +108 -0
- package/ts_build/src/plugins/tmux.js.map +1 -0
- package/ts_build/src/plugins/types.d.ts +1 -0
- package/ts_build/src/plugins/vim.js +11 -1
- package/ts_build/src/plugins/vim.js.map +1 -1
- package/ts_build/src/services/AgentSyncFs.d.ts +34 -0
- package/ts_build/src/services/AgentSyncFs.js +325 -0
- package/ts_build/src/services/AgentSyncFs.js.map +1 -0
- package/ts_build/src/services/AgentSyncKnowhowWeb.d.ts +29 -0
- package/ts_build/src/services/AgentSyncKnowhowWeb.js +178 -0
- package/ts_build/src/services/AgentSyncKnowhowWeb.js.map +1 -0
- package/ts_build/src/services/AgentSynchronization.d.ts +1 -1
- package/ts_build/src/services/AgentSynchronization.js +3 -3
- package/ts_build/src/services/AgentSynchronization.js.map +1 -1
- package/ts_build/src/services/EventService.js.map +1 -1
- package/ts_build/src/services/KnowhowClient.d.ts +9 -1
- package/ts_build/src/services/KnowhowClient.js +58 -0
- package/ts_build/src/services/KnowhowClient.js.map +1 -1
- package/ts_build/src/services/index.d.ts +2 -1
- package/ts_build/src/services/index.js +2 -1
- package/ts_build/src/services/index.js.map +1 -1
- package/ts_build/src/types.d.ts +26 -1
- package/ts_build/src/types.js +45 -4
- package/ts_build/src/types.js.map +1 -1
- package/ts_build/src/utils/PersistentInputManager.d.ts +28 -0
- package/ts_build/src/utils/PersistentInputManager.js +293 -0
- package/ts_build/src/utils/PersistentInputManager.js.map +1 -0
- package/ts_build/src/worker.js +2 -2
- package/ts_build/src/worker.js.map +1 -1
- package/ts_build/tests/manual/modalities/google.modalities.test.d.ts +1 -0
- package/ts_build/tests/manual/modalities/google.modalities.test.js +252 -0
- package/ts_build/tests/manual/modalities/google.modalities.test.js.map +1 -0
- package/ts_build/tests/manual/modalities/openai.modalities.test.d.ts +1 -0
- package/ts_build/tests/manual/modalities/openai.modalities.test.js +252 -0
- package/ts_build/tests/manual/modalities/openai.modalities.test.js.map +1 -0
- package/ts_build/tests/manual/modalities/streaming.test.d.ts +1 -0
- package/ts_build/tests/manual/modalities/streaming.test.js +206 -0
- package/ts_build/tests/manual/modalities/streaming.test.js.map +1 -0
- package/ts_build/tests/manual/modalities/xai.modalities.test.d.ts +1 -0
- package/ts_build/tests/manual/modalities/xai.modalities.test.js +226 -0
- package/ts_build/tests/manual/modalities/xai.modalities.test.js.map +1 -0
- package/ts_build/tests/manual/persistent-input-test.d.ts +1 -0
- package/ts_build/tests/manual/persistent-input-test.js +35 -0
- package/ts_build/tests/manual/persistent-input-test.js.map +1 -0
- package/ts_build/tests/plugins/language/languagePlugin-content-triggers.test.js +5 -5
- package/ts_build/tests/plugins/language/languagePlugin-content-triggers.test.js.map +1 -1
- package/ts_build/tests/plugins/language/languagePlugin-integration.test.js +1 -1
- package/ts_build/tests/plugins/language/languagePlugin-integration.test.js.map +1 -1
- package/ts_build/tests/plugins/language/languagePlugin.test.js +17 -7
- package/ts_build/tests/plugins/language/languagePlugin.test.js.map +1 -1
package/src/cli.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Command } from "commander";
|
|
|
7
7
|
import { execSync } from "child_process";
|
|
8
8
|
import { version } from "../package.json";
|
|
9
9
|
import { generate, embed, upload } from "./index";
|
|
10
|
-
import { init } from "./config";
|
|
10
|
+
import { init, migrateConfig } from "./config";
|
|
11
11
|
|
|
12
12
|
import { download, purge } from ".";
|
|
13
13
|
import { includedTools } from "./agents/tools/list";
|
|
@@ -26,6 +26,7 @@ import { startChat } from "./chat";
|
|
|
26
26
|
import { askAI } from "./chat-old";
|
|
27
27
|
import { getConfiguredEmbeddingMap, queryEmbedding } from "./embeddings";
|
|
28
28
|
import { getConfig } from "./config";
|
|
29
|
+
import { getEnabledPlugins } from "./types";
|
|
29
30
|
import { marked } from "marked";
|
|
30
31
|
import { BaseAgent } from "./agents/base/base";
|
|
31
32
|
import { AskModule } from "./chat/modules/AskModule";
|
|
@@ -36,9 +37,16 @@ import { SetupModule } from "./chat/modules/SetupModule";
|
|
|
36
37
|
import { CliChatService } from "./chat/CliChatService";
|
|
37
38
|
|
|
38
39
|
async function setupServices() {
|
|
39
|
-
|
|
40
|
+
await migrateConfig();
|
|
41
|
+
|
|
42
|
+
const { Agents, Mcp, Clients, Tools: OldTools } = services();
|
|
40
43
|
const Tools = new LazyToolsService();
|
|
41
44
|
|
|
45
|
+
// We need to wireup the LazyTools to be connected to the same singletons that are in services()
|
|
46
|
+
Tools.setContext({
|
|
47
|
+
...OldTools.getContext(),
|
|
48
|
+
});
|
|
49
|
+
|
|
42
50
|
const { Researcher, Developer, Patcher, Setup } = agents({
|
|
43
51
|
...services(),
|
|
44
52
|
Tools,
|
|
@@ -85,7 +93,7 @@ async function readStdin(): Promise<string> {
|
|
|
85
93
|
async function main() {
|
|
86
94
|
const program = new Command();
|
|
87
95
|
const config = await getConfig();
|
|
88
|
-
const chatService = new CliChatService(config.plugins);
|
|
96
|
+
const chatService = new CliChatService(getEnabledPlugins(config.plugins));
|
|
89
97
|
|
|
90
98
|
program
|
|
91
99
|
.name("knowhow")
|
|
@@ -114,13 +122,13 @@ async function main() {
|
|
|
114
122
|
try {
|
|
115
123
|
console.log("🔄 Checking for knowhow updates...");
|
|
116
124
|
console.log(`Current version: ${version}`);
|
|
117
|
-
|
|
125
|
+
|
|
118
126
|
console.log("📦 Installing latest version from npm...");
|
|
119
127
|
execSync("npm install -g knowhow@latest", {
|
|
120
128
|
stdio: "inherit",
|
|
121
129
|
encoding: "utf-8",
|
|
122
130
|
});
|
|
123
|
-
|
|
131
|
+
|
|
124
132
|
console.log("✓ knowhow has been updated successfully!");
|
|
125
133
|
console.log("Run 'knowhow --version' to see the new version.");
|
|
126
134
|
} catch (error) {
|
|
@@ -195,6 +203,8 @@ async function main() {
|
|
|
195
203
|
"10"
|
|
196
204
|
)
|
|
197
205
|
.option("--message-id <messageId>", "Knowhow message ID for task tracking")
|
|
206
|
+
.option("--sync-fs", "Enable filesystem-based synchronization")
|
|
207
|
+
.option("--task-id <taskId>", "Pre-generated task ID (used with --sync-fs for predictable agent directory path)")
|
|
198
208
|
.option("--prompt-file <path>", "Custom prompt template file with {text}")
|
|
199
209
|
.option("--input <text>", "Task input (fallback to stdin if not provided)")
|
|
200
210
|
.action(async (options) => {
|
|
@@ -255,7 +265,7 @@ async function main() {
|
|
|
255
265
|
const askModule = new AskModule();
|
|
256
266
|
await askModule.initialize(chatService);
|
|
257
267
|
await askModule.processAIQuery(input, {
|
|
258
|
-
plugins: config.plugins,
|
|
268
|
+
plugins: config.plugins.enabled,
|
|
259
269
|
currentModel: options.model,
|
|
260
270
|
currentProvider: options.provider,
|
|
261
271
|
});
|
package/src/clients/anthropic.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Anthropic from "@anthropic-ai/sdk";
|
|
2
2
|
import { wait } from "../utils";
|
|
3
|
+
import { AnthropicTextPricing } from "./pricing";
|
|
3
4
|
import { Models } from "../types";
|
|
4
5
|
import {
|
|
5
6
|
GenericClient,
|
|
@@ -9,6 +10,14 @@ import {
|
|
|
9
10
|
Message,
|
|
10
11
|
EmbeddingOptions,
|
|
11
12
|
EmbeddingResponse,
|
|
13
|
+
AudioTranscriptionOptions,
|
|
14
|
+
AudioTranscriptionResponse,
|
|
15
|
+
AudioGenerationOptions,
|
|
16
|
+
AudioGenerationResponse,
|
|
17
|
+
ImageGenerationOptions,
|
|
18
|
+
ImageGenerationResponse,
|
|
19
|
+
VideoGenerationOptions,
|
|
20
|
+
VideoGenerationResponse,
|
|
12
21
|
} from "./types";
|
|
13
22
|
|
|
14
23
|
type MessageParam = Anthropic.MessageParam;
|
|
@@ -234,19 +243,29 @@ export class GenericAnthropicClient implements GenericClient {
|
|
|
234
243
|
if (item.type === "image_url") {
|
|
235
244
|
const url = item.image_url.url;
|
|
236
245
|
const isDataUrl = url.startsWith("data:");
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
const isHttpUrl = url.startsWith("http");
|
|
247
|
+
if (isHttpUrl) {
|
|
248
|
+
return {
|
|
249
|
+
type: "image" as const,
|
|
250
|
+
source: {
|
|
251
|
+
type: "url" as const,
|
|
252
|
+
url,
|
|
253
|
+
},
|
|
254
|
+
} as Anthropic.ImageBlockParam;
|
|
255
|
+
} else {
|
|
256
|
+
const base64Data = isDataUrl ? url.split(",")[1] : url;
|
|
257
|
+
const mediaType = isDataUrl
|
|
258
|
+
? url.match(/data:([^;]+);/)?.[1] || "image/jpeg"
|
|
259
|
+
: "image/jpeg";
|
|
260
|
+
return {
|
|
261
|
+
type: "image" as const,
|
|
262
|
+
source: {
|
|
263
|
+
type: "base64" as const,
|
|
264
|
+
media_type: mediaType as any,
|
|
265
|
+
data: base64Data,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
250
269
|
} else if (item.type === "text") {
|
|
251
270
|
return { type: "text" as const, text: item.text };
|
|
252
271
|
}
|
|
@@ -299,15 +318,24 @@ export class GenericAnthropicClient implements GenericClient {
|
|
|
299
318
|
}
|
|
300
319
|
if (typeof e === "object" && e.type === "image_url") {
|
|
301
320
|
const isUrl = e.image_url.url.startsWith("http");
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
}
|
|
321
|
+
if (isUrl) {
|
|
322
|
+
return {
|
|
323
|
+
type: "image",
|
|
324
|
+
source: {
|
|
325
|
+
type: "url" as const,
|
|
326
|
+
url: e.image_url.url,
|
|
327
|
+
},
|
|
328
|
+
} as Anthropic.ContentBlockParam;
|
|
329
|
+
} else {
|
|
330
|
+
return {
|
|
331
|
+
type: "image",
|
|
332
|
+
source: {
|
|
333
|
+
type: "base64" as const,
|
|
334
|
+
media_type: "image/jpeg",
|
|
335
|
+
data: e.image_url.url,
|
|
336
|
+
},
|
|
337
|
+
} as Anthropic.ContentBlockParam;
|
|
338
|
+
}
|
|
311
339
|
}
|
|
312
340
|
};
|
|
313
341
|
|
|
@@ -340,7 +368,7 @@ export class GenericAnthropicClient implements GenericClient {
|
|
|
340
368
|
},
|
|
341
369
|
]
|
|
342
370
|
: undefined,
|
|
343
|
-
max_tokens: options.max_tokens ||
|
|
371
|
+
max_tokens: options.max_tokens || 8000,
|
|
344
372
|
...(tools.length && {
|
|
345
373
|
tool_choice: { type: "auto" },
|
|
346
374
|
tools,
|
|
@@ -398,98 +426,14 @@ export class GenericAnthropicClient implements GenericClient {
|
|
|
398
426
|
}
|
|
399
427
|
|
|
400
428
|
pricesPerMillion() {
|
|
401
|
-
return
|
|
402
|
-
[Models.anthropic.Opus4_6]: {
|
|
403
|
-
input: 5.0,
|
|
404
|
-
input_gt_200k: 10.0,
|
|
405
|
-
cache_write: 6.25,
|
|
406
|
-
cache_hit: 0.5,
|
|
407
|
-
output: 25.0,
|
|
408
|
-
output_gt_200k: 37.5,
|
|
409
|
-
},
|
|
410
|
-
[Models.anthropic.Sonnet4_6]: {
|
|
411
|
-
input: 3.0,
|
|
412
|
-
input_gt_200k: 6.0,
|
|
413
|
-
cache_write: 3.75,
|
|
414
|
-
cache_hit: 0.3,
|
|
415
|
-
output: 15.0,
|
|
416
|
-
output_gt_200k: 22.5,
|
|
417
|
-
},
|
|
418
|
-
[Models.anthropic.Opus4_5]: {
|
|
419
|
-
input: 5.0,
|
|
420
|
-
cache_write: 6.25,
|
|
421
|
-
cache_hit: 0.5,
|
|
422
|
-
output: 25.0,
|
|
423
|
-
},
|
|
424
|
-
[Models.anthropic.Opus4_1]: {
|
|
425
|
-
input: 15.0,
|
|
426
|
-
cache_write: 18.75,
|
|
427
|
-
cache_hit: 1.5,
|
|
428
|
-
output: 75.0,
|
|
429
|
-
},
|
|
430
|
-
[Models.anthropic.Opus4]: {
|
|
431
|
-
input: 15.0,
|
|
432
|
-
cache_write: 18.75,
|
|
433
|
-
cache_hit: 1.5,
|
|
434
|
-
output: 75.0,
|
|
435
|
-
},
|
|
436
|
-
[Models.anthropic.Sonnet4]: {
|
|
437
|
-
input: 3.0,
|
|
438
|
-
input_gt_200k: 6.0,
|
|
439
|
-
cache_write: 3.75,
|
|
440
|
-
cache_hit: 0.3,
|
|
441
|
-
output: 15.0,
|
|
442
|
-
output_gt_200k: 22.5,
|
|
443
|
-
},
|
|
444
|
-
[Models.anthropic.Sonnet4_5]: {
|
|
445
|
-
input: 3.0,
|
|
446
|
-
input_gt_200k: 6.0,
|
|
447
|
-
cache_write: 3.75,
|
|
448
|
-
cache_hit: 0.3,
|
|
449
|
-
output: 15.0,
|
|
450
|
-
output_gt_200k: 22.5,
|
|
451
|
-
},
|
|
452
|
-
[Models.anthropic.Haiku4_5]: {
|
|
453
|
-
input: 1,
|
|
454
|
-
cache_write: 1.25,
|
|
455
|
-
cache_hit: 0.1,
|
|
456
|
-
output: 5,
|
|
457
|
-
},
|
|
458
|
-
[Models.anthropic.Sonnet3_7]: {
|
|
459
|
-
input: 3.0,
|
|
460
|
-
cache_write: 3.75,
|
|
461
|
-
cache_hit: 0.3,
|
|
462
|
-
output: 15.0,
|
|
463
|
-
},
|
|
464
|
-
[Models.anthropic.Sonnet3_5]: {
|
|
465
|
-
input: 3.0,
|
|
466
|
-
cache_write: 3.75,
|
|
467
|
-
cache_hit: 0.3,
|
|
468
|
-
output: 15.0,
|
|
469
|
-
},
|
|
470
|
-
[Models.anthropic.Haiku3_5]: {
|
|
471
|
-
input: 0.8,
|
|
472
|
-
cache_write: 1.0,
|
|
473
|
-
cache_hit: 0.08,
|
|
474
|
-
output: 4.0,
|
|
475
|
-
},
|
|
476
|
-
[Models.anthropic.Opus3]: {
|
|
477
|
-
input: 15.0,
|
|
478
|
-
cache_write: 18.75,
|
|
479
|
-
cache_hit: 1.5,
|
|
480
|
-
output: 75.0,
|
|
481
|
-
},
|
|
482
|
-
[Models.anthropic.Haiku3]: {
|
|
483
|
-
input: 0.25,
|
|
484
|
-
cache_write: 0.3125,
|
|
485
|
-
cache_hit: 0.025,
|
|
486
|
-
output: 1.25,
|
|
487
|
-
},
|
|
488
|
-
};
|
|
429
|
+
return AnthropicTextPricing;
|
|
489
430
|
}
|
|
490
431
|
|
|
491
432
|
calculateCost(model: string, usage: Usage): number | undefined {
|
|
492
|
-
const
|
|
433
|
+
const rawP = this.pricesPerMillion()[model];
|
|
434
|
+
// Fall back to pricing file for unknown/newer models
|
|
435
|
+
const fallback = AnthropicTextPricing[model as keyof typeof AnthropicTextPricing];
|
|
436
|
+
const p: any = rawP || fallback || undefined;
|
|
493
437
|
if (!p) return undefined;
|
|
494
438
|
|
|
495
439
|
const inputTokens = usage.input_tokens ?? 0;
|
|
@@ -532,4 +476,30 @@ export class GenericAnthropicClient implements GenericClient {
|
|
|
532
476
|
async createEmbedding(options: EmbeddingOptions): Promise<EmbeddingResponse> {
|
|
533
477
|
throw new Error("Provider does not support embeddings");
|
|
534
478
|
}
|
|
479
|
+
|
|
480
|
+
async createAudioTranscription(
|
|
481
|
+
options: AudioTranscriptionOptions
|
|
482
|
+
): Promise<AudioTranscriptionResponse> {
|
|
483
|
+
throw new Error("Anthropic does not support audio transcription");
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async createAudioGeneration(
|
|
487
|
+
options: AudioGenerationOptions
|
|
488
|
+
): Promise<AudioGenerationResponse> {
|
|
489
|
+
throw new Error("Anthropic does not support audio generation");
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async createImageGeneration(
|
|
493
|
+
options: ImageGenerationOptions
|
|
494
|
+
): Promise<ImageGenerationResponse> {
|
|
495
|
+
throw new Error("Anthropic does not support image generation");
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
async createVideoGeneration(
|
|
499
|
+
options: VideoGenerationOptions
|
|
500
|
+
): Promise<VideoGenerationResponse> {
|
|
501
|
+
throw new Error(
|
|
502
|
+
"Video generation is not supported by the Anthropic provider."
|
|
503
|
+
);
|
|
504
|
+
}
|
|
535
505
|
}
|