@emqo/claudebridge 0.1.4 → 0.1.5

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.
@@ -1,8 +1,10 @@
1
- endpoints:
2
- - name: "default"
3
- base_url: ""
4
- api_key: "sk-your-api-key"
5
- model: "claude-sonnet-4-20250514"
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
 
@@ -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.next();
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
- env.ANTHROPIC_API_KEY = ep.api_key;
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.next();
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
- env.ANTHROPIC_API_KEY = ep.api_key;
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/keys.js CHANGED
@@ -6,8 +6,6 @@ export class EndpointRotator {
6
6
  cooldownMs = 60_000;
7
7
  constructor(endpoints) {
8
8
  this.endpoints = endpoints.filter(e => e.api_key);
9
- if (!this.endpoints.length)
10
- throw new Error("No endpoints configured");
11
9
  }
12
10
  next() {
13
11
  const now = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emqo/claudebridge",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Bridge Claude Code Agent SDK to chat platforms (Telegram, Discord, etc.)",
5
5
  "main": "dist/index.js",
6
6
  "bin": {