@emqo/claudebridge 0.2.0 → 0.2.1
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/adapters/discord.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, GatewayIntentBits } from "discord.js";
|
|
2
|
-
import { writeFileSync
|
|
2
|
+
import { writeFileSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { chunkText } from "./base.js";
|
|
5
5
|
import { reloadConfig } from "../core/config.js";
|
|
@@ -98,8 +98,7 @@ export class DiscordAdapter {
|
|
|
98
98
|
}
|
|
99
99
|
// File upload handling
|
|
100
100
|
if (msg.attachments.size > 0) {
|
|
101
|
-
const ws =
|
|
102
|
-
mkdirSync(ws, { recursive: true });
|
|
101
|
+
const ws = this.engine.getWorkDir(msg.author.id);
|
|
103
102
|
for (const [, att] of msg.attachments) {
|
|
104
103
|
try {
|
|
105
104
|
const resp = await fetch(att.url);
|
|
@@ -146,10 +146,9 @@ export class TelegramAdapter {
|
|
|
146
146
|
const url = `https://api.telegram.org/file/bot${this.config.token}/${file.file_path}`;
|
|
147
147
|
const resp = await fetch(url);
|
|
148
148
|
const buf = Buffer.from(await resp.arrayBuffer());
|
|
149
|
-
const {
|
|
149
|
+
const { writeFileSync } = await import("fs");
|
|
150
150
|
const { join } = await import("path");
|
|
151
|
-
const ws =
|
|
152
|
-
mkdirSync(ws, { recursive: true });
|
|
151
|
+
const ws = this.engine.getWorkDir(String(uid));
|
|
153
152
|
writeFileSync(join(ws, fileName), buf);
|
|
154
153
|
const prompt = msg.caption || `Analyze the uploaded file: ${fileName}`;
|
|
155
154
|
await this.handlePrompt(chatId, String(uid), prompt);
|
package/dist/core/agent.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class AgentEngine {
|
|
|
22
22
|
}[];
|
|
23
23
|
getRotator(): EndpointRotator;
|
|
24
24
|
getEndpointCount(): number;
|
|
25
|
-
|
|
25
|
+
getWorkDir(userId: string): string;
|
|
26
26
|
isLocked(userId: string): boolean;
|
|
27
27
|
runStream(userId: string, prompt: string, platform: string, chatId: string, onChunk?: StreamCallback): Promise<AgentResponse>;
|
|
28
28
|
private _executeWithRetry;
|
package/dist/core/agent.js
CHANGED
|
@@ -197,7 +197,7 @@ export class AgentEngine {
|
|
|
197
197
|
if (ep.base_url)
|
|
198
198
|
env.ANTHROPIC_BASE_URL = ep.base_url;
|
|
199
199
|
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)}`;
|
|
200
|
-
const args = ["-p", summaryPrompt, "--output-format", "stream-json", "--max-turns", "1", "--max-budget-usd", "0.05"];
|
|
200
|
+
const args = ["-p", summaryPrompt, "--verbose", "--output-format", "stream-json", "--max-turns", "1", "--max-budget-usd", "0.05"];
|
|
201
201
|
if (ep.model)
|
|
202
202
|
args.push("--model", ep.model);
|
|
203
203
|
const child = spawn("claude", args, { env, stdio: ["pipe", "pipe", "pipe"] });
|