@bubblebrain-ai/bubble 0.0.16 → 0.0.18
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/dist/agent/internal-reminder-sanitizer.d.ts +2 -0
- package/dist/agent/internal-reminder-sanitizer.js +27 -0
- package/dist/agent/tool-intent.js +0 -1
- package/dist/agent.d.ts +1 -0
- package/dist/agent.js +148 -23
- package/dist/context/budget.js +15 -0
- package/dist/context/prune.d.ts +1 -0
- package/dist/context/prune.js +32 -0
- package/dist/debug-trace.js +14 -0
- package/dist/feishu/agent-host/run-driver.js +2 -2
- package/dist/feishu/card/run-state.js +1 -0
- package/dist/feishu/serve.js +1 -0
- package/dist/main.js +13 -9
- package/dist/model-catalog.d.ts +3 -0
- package/dist/model-catalog.js +38 -0
- package/dist/model-config.d.ts +3 -0
- package/dist/model-config.js +3 -0
- package/dist/model-pricing.js +2 -1
- package/dist/model-selection.d.ts +7 -0
- package/dist/model-selection.js +9 -0
- package/dist/network/chatgpt-transport.js +1 -0
- package/dist/orchestrator/default-hooks.js +1 -1
- package/dist/prompt/compose.js +1 -1
- package/dist/prompt/environment.js +1 -3
- package/dist/prompt/reminders.js +3 -3
- package/dist/prompt/runtime.js +2 -1
- package/dist/provider-anthropic.d.ts +89 -0
- package/dist/provider-anthropic.js +597 -0
- package/dist/provider-openai-codex.js +3 -1
- package/dist/provider-registry.d.ts +2 -0
- package/dist/provider-registry.js +29 -3
- package/dist/provider-transform.d.ts +1 -1
- package/dist/provider-transform.js +14 -0
- package/dist/provider.d.ts +4 -1
- package/dist/provider.js +120 -41
- package/dist/session-log.js +14 -2
- package/dist/session-title.js +3 -6
- package/dist/slash-commands/commands.js +8 -2
- package/dist/stats/usage.d.ts +1 -0
- package/dist/stats/usage.js +28 -3
- package/dist/tools/edit.js +75 -1
- package/dist/tools/glob.js +77 -12
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -3
- package/dist/tools/prompt-metadata.d.ts +3 -0
- package/dist/tools/prompt-metadata.js +17 -0
- package/dist/tools/write.js +14 -0
- package/dist/tui/paste-placeholder.d.ts +10 -0
- package/dist/tui/paste-placeholder.js +45 -0
- package/dist/tui/run.js +23 -0
- package/dist/tui-ink/app.js +2 -0
- package/dist/tui-ink/input-box.d.ts +1 -8
- package/dist/tui-ink/input-box.js +8 -38
- package/dist/tui-opentui/app.js +2 -0
- package/dist/tui-opentui/input-box.d.ts +1 -3
- package/dist/tui-opentui/input-box.js +17 -26
- package/dist/types.d.ts +22 -0
- package/package.json +7 -3
- package/dist/tools/apply-patch.d.ts +0 -9
- package/dist/tools/apply-patch.js +0 -330
- package/dist/tools/patch-apply.d.ts +0 -41
- package/dist/tools/patch-apply.js +0 -312
package/dist/model-catalog.js
CHANGED
|
@@ -2,6 +2,7 @@ export const BUILTIN_PROVIDERS = [
|
|
|
2
2
|
{ id: "openrouter", name: "OpenRouter", baseURL: "https://openrouter.ai/api/v1" },
|
|
3
3
|
{ id: "openai", name: "OpenAI", baseURL: "https://api.openai.com/v1", supportsOAuth: true },
|
|
4
4
|
{ id: "openai-codex", name: "OpenAI Codex (ChatGPT)", baseURL: "https://chatgpt.com/backend-api" },
|
|
5
|
+
{ id: "anthropic", name: "Anthropic", baseURL: "https://api.anthropic.com", protocol: "anthropic-messages" },
|
|
5
6
|
{ id: "deepseek", name: "DeepSeek", baseURL: "https://api.deepseek.com" },
|
|
6
7
|
{ id: "google", name: "Google", baseURL: "https://generativelanguage.googleapis.com/v1beta/openai" },
|
|
7
8
|
{ id: "zhipuai", name: "Zhipu AI", baseURL: "https://open.bigmodel.cn/api/paas/v4" },
|
|
@@ -9,6 +10,9 @@ export const BUILTIN_PROVIDERS = [
|
|
|
9
10
|
{ id: "zai", name: "Z.AI", baseURL: "https://api.z.ai/api/paas/v4" },
|
|
10
11
|
{ id: "zai-coding-plan", name: "Z.AI Coding Plan", baseURL: "https://api.z.ai/api/coding/paas/v4" },
|
|
11
12
|
{ id: "alibaba", name: "Alibaba DashScope", baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1" },
|
|
13
|
+
{ id: "minimax", name: "MiniMax Token Plan", baseURL: "https://api.minimaxi.com/anthropic", protocol: "anthropic-messages" },
|
|
14
|
+
{ id: "minimax-openai", name: "MiniMax (OpenAI Compatible)", baseURL: "https://api.minimaxi.com/v1" },
|
|
15
|
+
{ id: "minimax-anthropic", name: "MiniMax (Anthropic Compatible)", baseURL: "https://api.minimaxi.com/anthropic", protocol: "anthropic-messages", hidden: true },
|
|
12
16
|
{ id: "stepfun", name: "StepFun Step Plan", baseURL: "https://api.stepfun.com/step_plan/v1" },
|
|
13
17
|
{ id: "moonshot-cn", name: "Moonshot (国内 platform.moonshot.cn)", baseURL: "https://api.moonshot.cn/v1" },
|
|
14
18
|
{ id: "moonshot-intl", name: "Moonshot (海外 platform.moonshot.ai)", baseURL: "https://api.moonshot.ai/v1" },
|
|
@@ -26,6 +30,10 @@ const OPENAI_CHAT_LEVELS = ["off"];
|
|
|
26
30
|
const TOGGLE_THINKING_LEVELS = ["off", "medium"];
|
|
27
31
|
const DEEPSEEK_V4_LEVELS = ["high", "max"];
|
|
28
32
|
const STEPFUN_REASONING_LEVELS = ["off", "low", "medium", "high"];
|
|
33
|
+
const MINIMAX_M3_REASONING_LEVELS = ["off", "medium"];
|
|
34
|
+
const MINIMAX_REASONING_LEVELS = ["medium"];
|
|
35
|
+
const ANTHROPIC_ADAPTIVE_LEVELS = ["off", "medium"];
|
|
36
|
+
const ANTHROPIC_CHAT_LEVELS = ["off"];
|
|
29
37
|
export const BUILTIN_MODELS = [
|
|
30
38
|
{ id: "gpt-5.5", name: "gpt-5.5", providerId: "openai-codex", reasoningLevels: ALL_OPENAI_LEVELS, contextWindow: 272000, toolOutputTokenLimit: 10000 },
|
|
31
39
|
{ id: "gpt-5.4", name: "gpt-5.4", providerId: "openai-codex", reasoningLevels: ALL_OPENAI_LEVELS, contextWindow: 272000 },
|
|
@@ -42,6 +50,9 @@ export const BUILTIN_MODELS = [
|
|
|
42
50
|
{ id: "o1-preview", name: "o1-preview", providerId: "openai", reasoningLevels: ["off", "low", "medium", "high"], contextWindow: 128000 },
|
|
43
51
|
{ id: "o1-mini", name: "o1-mini", providerId: "openai", reasoningLevels: ["off", "low", "medium", "high"], contextWindow: 128000 },
|
|
44
52
|
{ id: "gpt-4-turbo", name: "gpt-4-turbo", providerId: "openai", reasoningLevels: OPENAI_CHAT_LEVELS, contextWindow: 128000 },
|
|
53
|
+
{ id: "claude-opus-4-8", name: "Claude Opus 4.8", providerId: "anthropic", reasoningLevels: ANTHROPIC_ADAPTIVE_LEVELS, contextWindow: 1000000 },
|
|
54
|
+
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6", providerId: "anthropic", reasoningLevels: ANTHROPIC_ADAPTIVE_LEVELS, contextWindow: 1000000 },
|
|
55
|
+
{ id: "claude-haiku-4-5-20251001", name: "Claude Haiku 4.5", providerId: "anthropic", reasoningLevels: ANTHROPIC_CHAT_LEVELS, contextWindow: 200000 },
|
|
45
56
|
{ id: "deepseek-v4-flash", name: "deepseek-v4-flash", providerId: "deepseek", reasoningLevels: DEEPSEEK_V4_LEVELS, contextWindow: 1048576 },
|
|
46
57
|
{ id: "deepseek-v4-pro", name: "deepseek-v4-pro", providerId: "deepseek", reasoningLevels: DEEPSEEK_V4_LEVELS, contextWindow: 1048576 },
|
|
47
58
|
{ id: "gemini-2.5-pro-preview-03-25", name: "gemini-2.5-pro-preview-03-25", providerId: "google", reasoningLevels: ["off", "low", "high"], contextWindow: 128000 },
|
|
@@ -61,6 +72,33 @@ export const BUILTIN_MODELS = [
|
|
|
61
72
|
{ id: "glm-4.6", name: "GLM-4.6", providerId: "zai-coding-plan", reasoningLevels: TOGGLE_THINKING_LEVELS, contextWindow: 200000 },
|
|
62
73
|
{ id: "qwen3.6-plus", name: "Qwen3.6 Plus", providerId: "alibaba", reasoningLevels: ["off"], contextWindow: 1048576 },
|
|
63
74
|
{ id: "qwen3.7-max", name: "Qwen3.7 Max", providerId: "alibaba", reasoningLevels: ["off"], contextWindow: 1048576 },
|
|
75
|
+
{ id: "MiniMax-M3", name: "MiniMax M3", providerId: "minimax", reasoningLevels: MINIMAX_M3_REASONING_LEVELS, contextWindow: 1000000 },
|
|
76
|
+
{ id: "MiniMax-M2.7", name: "MiniMax M2.7", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
77
|
+
{ id: "MiniMax-M2.7-highspeed", name: "MiniMax M2.7 Highspeed", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
78
|
+
{ id: "MiniMax-M2.5", name: "MiniMax M2.5", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
79
|
+
{ id: "MiniMax-M2.5-highspeed", name: "MiniMax M2.5 Highspeed", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
80
|
+
{ id: "MiniMax-M2.1", name: "MiniMax M2.1", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
81
|
+
{ id: "MiniMax-M2.1-highspeed", name: "MiniMax M2.1 Highspeed", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
82
|
+
{ id: "MiniMax-M2", name: "MiniMax M2", providerId: "minimax", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
83
|
+
{ id: "M2-her", name: "M2-her", providerId: "minimax", reasoningLevels: ["off"], contextWindow: 64000 },
|
|
84
|
+
{ id: "MiniMax-M3", name: "MiniMax M3", providerId: "minimax-openai", reasoningLevels: MINIMAX_M3_REASONING_LEVELS, contextWindow: 1000000 },
|
|
85
|
+
{ id: "MiniMax-M2.7", name: "MiniMax M2.7", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
86
|
+
{ id: "MiniMax-M2.7-highspeed", name: "MiniMax M2.7 Highspeed", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
87
|
+
{ id: "MiniMax-M2.5", name: "MiniMax M2.5", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
88
|
+
{ id: "MiniMax-M2.5-highspeed", name: "MiniMax M2.5 Highspeed", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
89
|
+
{ id: "MiniMax-M2.1", name: "MiniMax M2.1", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
90
|
+
{ id: "MiniMax-M2.1-highspeed", name: "MiniMax M2.1 Highspeed", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
91
|
+
{ id: "MiniMax-M2", name: "MiniMax M2", providerId: "minimax-openai", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
92
|
+
{ id: "M2-her", name: "M2-her", providerId: "minimax-openai", reasoningLevels: ["off"], contextWindow: 64000 },
|
|
93
|
+
{ id: "MiniMax-M3", name: "MiniMax M3", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_M3_REASONING_LEVELS, contextWindow: 1000000 },
|
|
94
|
+
{ id: "MiniMax-M2.7", name: "MiniMax M2.7", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
95
|
+
{ id: "MiniMax-M2.7-highspeed", name: "MiniMax M2.7 Highspeed", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
96
|
+
{ id: "MiniMax-M2.5", name: "MiniMax M2.5", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
97
|
+
{ id: "MiniMax-M2.5-highspeed", name: "MiniMax M2.5 Highspeed", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
98
|
+
{ id: "MiniMax-M2.1", name: "MiniMax M2.1", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
99
|
+
{ id: "MiniMax-M2.1-highspeed", name: "MiniMax M2.1 Highspeed", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
100
|
+
{ id: "MiniMax-M2", name: "MiniMax M2", providerId: "minimax-anthropic", reasoningLevels: MINIMAX_REASONING_LEVELS, contextWindow: 204800 },
|
|
101
|
+
{ id: "M2-her", name: "M2-her", providerId: "minimax-anthropic", reasoningLevels: ["off"], contextWindow: 64000 },
|
|
64
102
|
{ id: "step-3.7-flash", name: "Step 3.7 Flash", providerId: "stepfun", reasoningLevels: STEPFUN_REASONING_LEVELS, contextWindow: 256000 },
|
|
65
103
|
{ id: "step-3.5-flash-2603", name: "Step 3.5 Flash 2603", providerId: "stepfun", reasoningLevels: STEPFUN_REASONING_LEVELS },
|
|
66
104
|
{ id: "step-3.5-flash", name: "Step 3.5 Flash", providerId: "stepfun", reasoningLevels: STEPFUN_REASONING_LEVELS },
|
package/dist/model-config.d.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* Users can define providers, API keys, base URLs, and custom models
|
|
5
5
|
* in ~/.bubble/models.json.
|
|
6
6
|
*/
|
|
7
|
+
import type { ProviderProtocol } from "./model-catalog.js";
|
|
7
8
|
import type { ModelInfo } from "./provider-registry.js";
|
|
8
9
|
export interface ProviderModelConfig {
|
|
9
10
|
baseURL?: string;
|
|
10
11
|
apiKey?: string;
|
|
12
|
+
protocol?: ProviderProtocol;
|
|
11
13
|
models?: Array<{
|
|
12
14
|
id: string;
|
|
13
15
|
name?: string;
|
|
@@ -29,4 +31,5 @@ export declare class ModelConfig {
|
|
|
29
31
|
getCustomModels(providerId: string): ModelInfo[];
|
|
30
32
|
getApiKey(providerId: string): string | undefined;
|
|
31
33
|
getBaseURL(providerId: string): string | undefined;
|
|
34
|
+
getProtocol(providerId: string): ProviderProtocol | undefined;
|
|
32
35
|
}
|
package/dist/model-config.js
CHANGED
package/dist/model-pricing.js
CHANGED
|
@@ -38,7 +38,8 @@ export function calculateUsageCost(providerId, modelId, usage) {
|
|
|
38
38
|
if (!pricing)
|
|
39
39
|
return undefined;
|
|
40
40
|
const hasCacheBreakdown = typeof usage.promptCacheHitTokens === "number"
|
|
41
|
-
|| typeof usage.promptCacheMissTokens === "number"
|
|
41
|
+
|| typeof usage.promptCacheMissTokens === "number"
|
|
42
|
+
|| typeof usage.cacheCreationTokens === "number";
|
|
42
43
|
const hit = usage.promptCacheHitTokens ?? 0;
|
|
43
44
|
const miss = hasCacheBreakdown
|
|
44
45
|
? usage.promptCacheMissTokens ?? Math.max(0, usage.promptTokens - hit)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { encodeModel } from "./provider-registry.js";
|
|
2
|
+
export function resolveConfiguredModel(input) {
|
|
3
|
+
const selected = input.cliModel ?? input.sessionModel ?? input.defaultModel;
|
|
4
|
+
if (!selected)
|
|
5
|
+
return "";
|
|
6
|
+
if (selected.includes(":"))
|
|
7
|
+
return selected;
|
|
8
|
+
return input.fallbackProviderId ? encodeModel(input.fallbackProviderId, selected) : "";
|
|
9
|
+
}
|
|
@@ -176,7 +176,7 @@ function isCodeWriteResult(_toolCall, result) {
|
|
|
176
176
|
return result.metadata?.kind === "write" || result.metadata?.kind === "edit" || result.metadata?.kind === "patch";
|
|
177
177
|
}
|
|
178
178
|
function isMutationTool(name) {
|
|
179
|
-
return name === "edit" || name === "write"
|
|
179
|
+
return name === "edit" || name === "write";
|
|
180
180
|
}
|
|
181
181
|
function hasSubagentLifecycleActivity(toolCalls, toolResults) {
|
|
182
182
|
return toolCalls.some((toolCall) => isSubagentLifecycleTool(toolCall.name))
|
package/dist/prompt/compose.js
CHANGED
|
@@ -38,7 +38,7 @@ function buildProviderPrompt(agentName, providerId, modelId, modelName) {
|
|
|
38
38
|
const rawModel = modelId ?? modelName ?? "";
|
|
39
39
|
const model = rawModel.includes(":") ? rawModel.split(":").slice(1).join(":") : rawModel;
|
|
40
40
|
const lowerModel = model.toLowerCase();
|
|
41
|
-
if (provider === "anthropic" || model.startsWith("claude")) {
|
|
41
|
+
if (provider === "anthropic" || provider === "minimax" || provider.endsWith("-anthropic") || model.startsWith("claude")) {
|
|
42
42
|
return buildAnthropicProviderPrompt(agentName);
|
|
43
43
|
}
|
|
44
44
|
if (provider === "google" || model.startsWith("gemini")) {
|
|
@@ -3,7 +3,6 @@ export const defaultToolSnippets = {
|
|
|
3
3
|
read: "Read the contents of a file",
|
|
4
4
|
bash: "Execute a bash command",
|
|
5
5
|
edit: "Apply targeted string replacements to a file",
|
|
6
|
-
apply_patch: "Apply a structured patch for multi-file or larger code changes",
|
|
7
6
|
write: "Write a new file or overwrite an existing one",
|
|
8
7
|
glob: "Find files by glob pattern without using bash",
|
|
9
8
|
grep: "Search file contents using regex",
|
|
@@ -24,7 +23,6 @@ export const defaultToolNames = [
|
|
|
24
23
|
"glob",
|
|
25
24
|
"bash",
|
|
26
25
|
"edit",
|
|
27
|
-
"apply_patch",
|
|
28
26
|
"write",
|
|
29
27
|
"grep",
|
|
30
28
|
"lsp",
|
|
@@ -46,7 +44,7 @@ export function buildEnvironmentPrompt(options = {}) {
|
|
|
46
44
|
const workingDir = options.workingDir ?? cwd().replace(/\\/g, "/");
|
|
47
45
|
const currentDate = options.currentDate ?? new Date().toISOString().slice(0, 10);
|
|
48
46
|
const tools = options.tools ?? defaultToolNames;
|
|
49
|
-
const snippets = options.toolSnippets ??
|
|
47
|
+
const snippets = { ...defaultToolSnippets, ...(options.toolSnippets ?? {}) };
|
|
50
48
|
const visibleTools = tools.filter((name) => snippets[name]);
|
|
51
49
|
const toolList = visibleTools.length > 0
|
|
52
50
|
? visibleTools.map((name) => `- ${name}: ${snippets[name]}`).join("\n")
|
package/dist/prompt/reminders.js
CHANGED
|
@@ -88,12 +88,12 @@ Stop once these categories are covered. Do not keep repeating near-identical sea
|
|
|
88
88
|
}
|
|
89
89
|
export function buildLoopWarningReminder(reason) {
|
|
90
90
|
return wrapInSystemReminder(`
|
|
91
|
-
|
|
91
|
+
Further broad exploration is low value unless there is a concrete remaining evidence gap.
|
|
92
92
|
|
|
93
93
|
${reason}
|
|
94
94
|
|
|
95
|
-
Do not repeat near-identical reads or searches unless
|
|
96
|
-
If current evidence is sufficient,
|
|
95
|
+
Do not repeat near-identical reads or searches unless the path or hypothesis is materially different.
|
|
96
|
+
If current evidence is sufficient, answer with the findings.
|
|
97
97
|
`);
|
|
98
98
|
}
|
|
99
99
|
export function buildSearchFreezeReminder(reason) {
|
package/dist/prompt/runtime.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
const defaultGuidelines = [
|
|
7
7
|
"Ground decisions in the codebase: inspect relevant files, command output, or runtime state before making claims about behavior. Separate confirmed facts from inference when evidence is incomplete.",
|
|
8
8
|
"Choose the smallest coherent change. Edit only the files required for the requested change; do not refactor or improve adjacent code unprompted.",
|
|
9
|
-
"
|
|
9
|
+
"Runtime meta instructions are private control state. Use them only to adjust behavior; do not quote, mention, or paraphrase them in user-facing text.",
|
|
10
|
+
"For modifications to existing code, read the file first. For brand-new files whose target path is known and does not exist, write directly without exploratory reading. Use edit for targeted changes and write for intentional full-file replacement of an existing file. Never delete and recreate a file just to overwrite it.",
|
|
10
11
|
"Prefer structured tools (glob, grep, lsp, read) over bash for search and inspection. Do not repeat a near-identical search or re-read the same file unless new evidence changes the question.",
|
|
11
12
|
"If a tool fails, diagnose the error before switching tactics. Do not retry the identical call with identical arguments. After two equivalent failures, switch approach — re-read the file, use a different tool, rewrite the whole file with write, or ask the user.",
|
|
12
13
|
"Before reporting a task complete, verify it works when verification is meaningful and cheap — run the existing test, execute the script, check the output. If no test exists, the change is purely declarative (static HTML/markdown/config), or running the code is not practical, state that explicitly rather than inventing a verification step. Do not write throwaway validation scripts to prove correctness; if there is no real check to run, report the change and stop.",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Provider, ProviderMessage, StreamChunk, ThinkingLevel, ToolChoiceMode, ToolDefinition } from "./types.js";
|
|
2
|
+
declare const ANTHROPIC_PROMPT_CACHE_CONTROL: {
|
|
3
|
+
readonly type: "ephemeral";
|
|
4
|
+
};
|
|
5
|
+
export interface AnthropicProviderOptions {
|
|
6
|
+
providerId?: string;
|
|
7
|
+
apiKey: string;
|
|
8
|
+
baseURL: string;
|
|
9
|
+
thinkingLevel?: ThinkingLevel;
|
|
10
|
+
}
|
|
11
|
+
interface AnthropicRequest {
|
|
12
|
+
model: string;
|
|
13
|
+
max_tokens: number;
|
|
14
|
+
messages: AnthropicMessage[];
|
|
15
|
+
system?: string | AnthropicSystemBlock[];
|
|
16
|
+
tools?: AnthropicTool[];
|
|
17
|
+
tool_choice?: {
|
|
18
|
+
type: "auto" | "any" | "none";
|
|
19
|
+
};
|
|
20
|
+
stream?: boolean;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
thinking?: {
|
|
23
|
+
type: "adaptive";
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
type AnthropicCacheControl = typeof ANTHROPIC_PROMPT_CACHE_CONTROL;
|
|
27
|
+
interface AnthropicSystemBlock {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
cache_control?: AnthropicCacheControl;
|
|
31
|
+
}
|
|
32
|
+
type AnthropicContentBlock = {
|
|
33
|
+
type: "text";
|
|
34
|
+
text: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "image";
|
|
37
|
+
source: {
|
|
38
|
+
type: "url";
|
|
39
|
+
url: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "base64";
|
|
42
|
+
media_type: string;
|
|
43
|
+
data: string;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
type: "thinking";
|
|
47
|
+
thinking: string;
|
|
48
|
+
signature?: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: "redacted_thinking";
|
|
51
|
+
data: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "tool_use";
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
input: Record<string, unknown>;
|
|
57
|
+
} | {
|
|
58
|
+
type: "tool_result";
|
|
59
|
+
tool_use_id: string;
|
|
60
|
+
content: string;
|
|
61
|
+
is_error?: boolean;
|
|
62
|
+
};
|
|
63
|
+
interface AnthropicMessage {
|
|
64
|
+
role: "user" | "assistant";
|
|
65
|
+
content: string | AnthropicContentBlock[];
|
|
66
|
+
}
|
|
67
|
+
interface AnthropicTool {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string;
|
|
70
|
+
input_schema: ToolDefinition["parameters"];
|
|
71
|
+
cache_control?: AnthropicCacheControl;
|
|
72
|
+
}
|
|
73
|
+
export declare function createAnthropicMessagesProvider(options: AnthropicProviderOptions): Provider;
|
|
74
|
+
export declare function buildAnthropicRequest(options: AnthropicProviderOptions, messages: ProviderMessage[], chatOptions: {
|
|
75
|
+
model: string;
|
|
76
|
+
tools?: ToolDefinition[];
|
|
77
|
+
toolChoice?: ToolChoiceMode;
|
|
78
|
+
temperature?: number;
|
|
79
|
+
thinkingLevel?: ThinkingLevel;
|
|
80
|
+
stream?: boolean;
|
|
81
|
+
}): AnthropicRequest;
|
|
82
|
+
export declare function supportsAnthropicPromptCache(options: AnthropicProviderOptions, model: string): boolean;
|
|
83
|
+
export declare function toAnthropicMessages(messages: ProviderMessage[], echoThinking?: boolean): {
|
|
84
|
+
system: string;
|
|
85
|
+
messages: AnthropicMessage[];
|
|
86
|
+
};
|
|
87
|
+
export declare function translateAnthropicStream(events: AsyncIterable<Record<string, unknown>>): AsyncIterable<StreamChunk>;
|
|
88
|
+
export declare function readSseEvents(response: Response): AsyncIterable<Record<string, unknown>>;
|
|
89
|
+
export {};
|