@emqo/claudebridge 0.1.4 → 0.1.6
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/config.yaml.example +7 -5
- package/dist/core/agent.js +11 -5
- package/dist/core/intent.js +5 -2
- package/dist/core/keys.js +0 -2
- package/package.json +1 -1
package/config.yaml.example
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
endpoints
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
# Leave endpoints empty to use claude CLI's own authentication
|
|
2
|
+
# 留空则直接使用 claude CLI 自身的认证配置
|
|
3
|
+
endpoints: []
|
|
4
|
+
# - name: "default"
|
|
5
|
+
# base_url: ""
|
|
6
|
+
# api_key: "sk-your-api-key"
|
|
7
|
+
# model: "claude-sonnet-4-20250514"
|
|
6
8
|
|
|
7
9
|
locale: en # "zh" for Chinese
|
|
8
10
|
|
package/dist/core/agent.js
CHANGED
|
@@ -63,10 +63,12 @@ export class AgentEngine {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
async _executeWithRetry(userId, prompt, platform, onChunk, memoryPrompt) {
|
|
66
|
-
const maxRetries = Math.min(this.rotator.count, 3);
|
|
66
|
+
const maxRetries = Math.max(Math.min(this.rotator.count, 3), 1);
|
|
67
67
|
let lastErr;
|
|
68
68
|
for (let i = 0; i < maxRetries; i++) {
|
|
69
|
-
const ep = this.rotator.
|
|
69
|
+
const ep = this.rotator.count
|
|
70
|
+
? this.rotator.next()
|
|
71
|
+
: { name: "cli-default", api_key: "", base_url: "", model: "" };
|
|
70
72
|
try {
|
|
71
73
|
return await this._execute(userId, prompt, platform, ep, onChunk, memoryPrompt);
|
|
72
74
|
}
|
|
@@ -103,7 +105,8 @@ export class AgentEngine {
|
|
|
103
105
|
if (this.config.agent.max_budget_usd)
|
|
104
106
|
args.push("--max-budget-usd", String(this.config.agent.max_budget_usd));
|
|
105
107
|
const env = { ...process.env };
|
|
106
|
-
|
|
108
|
+
if (ep.api_key)
|
|
109
|
+
env.ANTHROPIC_API_KEY = ep.api_key;
|
|
107
110
|
if (ep.base_url)
|
|
108
111
|
env.ANTHROPIC_BASE_URL = ep.base_url;
|
|
109
112
|
const child = spawn("claude", args, { cwd, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
@@ -179,9 +182,12 @@ export class AgentEngine {
|
|
|
179
182
|
});
|
|
180
183
|
}
|
|
181
184
|
_autoSummarize(userId, prompt, response) {
|
|
182
|
-
const ep = this.rotator.
|
|
185
|
+
const ep = this.rotator.count
|
|
186
|
+
? this.rotator.next()
|
|
187
|
+
: { name: "cli-default", api_key: "", base_url: "", model: "" };
|
|
183
188
|
const env = { ...process.env };
|
|
184
|
-
|
|
189
|
+
if (ep.api_key)
|
|
190
|
+
env.ANTHROPIC_API_KEY = ep.api_key;
|
|
185
191
|
if (ep.base_url)
|
|
186
192
|
env.ANTHROPIC_BASE_URL = ep.base_url;
|
|
187
193
|
const summaryPrompt = `Extract 1-3 key facts worth remembering about the user from this exchange. Output only bullet points, no preamble. If nothing worth remembering, output "NONE".\n\nUser: ${prompt.slice(0, 500)}\nAssistant: ${response.slice(0, 1000)}`;
|
package/dist/core/intent.js
CHANGED
|
@@ -22,9 +22,12 @@ export function regexDetect(text) {
|
|
|
22
22
|
export function claudeDetect(text, rotator) {
|
|
23
23
|
return new Promise(resolve => {
|
|
24
24
|
const timeout = setTimeout(() => resolve({ type: "none" }), 15000);
|
|
25
|
-
const ep = rotator.
|
|
25
|
+
const ep = rotator.count
|
|
26
|
+
? rotator.next()
|
|
27
|
+
: { name: "cli-default", api_key: "", base_url: "", model: "" };
|
|
26
28
|
const env = { ...process.env };
|
|
27
|
-
|
|
29
|
+
if (ep.api_key)
|
|
30
|
+
env.ANTHROPIC_API_KEY = ep.api_key;
|
|
28
31
|
if (ep.base_url)
|
|
29
32
|
env.ANTHROPIC_BASE_URL = ep.base_url;
|
|
30
33
|
const prompt = `Classify the user's intent. Output ONLY one JSON line, no other text:
|
package/dist/core/keys.js
CHANGED