claude-sdk-proxy 2.3.0 → 2.3.2
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/package.json +1 -1
- package/src/mcpTools.ts +0 -30
- package/src/proxy/server.ts +5 -5
package/package.json
CHANGED
package/src/mcpTools.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { z } from "zod"
|
|
|
3
3
|
import { createPrivateKey, createPublicKey, sign, randomBytes } from "node:crypto"
|
|
4
4
|
import { readFileSync } from "node:fs"
|
|
5
5
|
import { homedir } from "node:os"
|
|
6
|
-
import { execSync } from "node:child_process"
|
|
7
6
|
|
|
8
7
|
// ── Gateway helpers ──────────────────────────────────────────────────────────
|
|
9
8
|
|
|
@@ -158,35 +157,6 @@ export function createMcpServer(state: McpServerState = { messageSent: false })
|
|
|
158
157
|
name: "opencode",
|
|
159
158
|
version: "1.0.0",
|
|
160
159
|
tools: [
|
|
161
|
-
// exec: fallback for callers whose system prompt references "exec" instead of
|
|
162
|
-
// Claude Code's built-in "Bash" tool. Maps to child_process.execSync.
|
|
163
|
-
tool(
|
|
164
|
-
"exec",
|
|
165
|
-
"Execute a shell command and return its output. Use this for running scripts, system commands, and file operations.",
|
|
166
|
-
{
|
|
167
|
-
command: z.string().describe("The shell command to execute"),
|
|
168
|
-
timeout: z.number().optional().describe("Timeout in milliseconds (default 120000)"),
|
|
169
|
-
},
|
|
170
|
-
async (args) => {
|
|
171
|
-
try {
|
|
172
|
-
const output = execSync(args.command, {
|
|
173
|
-
encoding: "utf-8",
|
|
174
|
-
timeout: args.timeout ?? 120_000,
|
|
175
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
176
|
-
cwd: "/tmp",
|
|
177
|
-
})
|
|
178
|
-
return { content: [{ type: "text", text: output || "(no output)" }] }
|
|
179
|
-
} catch (error: any) {
|
|
180
|
-
const stderr = error.stderr ? String(error.stderr) : ""
|
|
181
|
-
const stdout = error.stdout ? String(error.stdout) : ""
|
|
182
|
-
const msg = error.message ?? "Command failed"
|
|
183
|
-
return {
|
|
184
|
-
content: [{ type: "text", text: `Error: ${msg}\n${stderr}\n${stdout}`.trim() }],
|
|
185
|
-
isError: true
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
),
|
|
190
160
|
tool(
|
|
191
161
|
"message",
|
|
192
162
|
"Send a message or file to a chat. Provide `to` (chat ID from conversation_label, e.g. '-1001426819337'), and either `message` (text) or `filePath`/`path`/`media` (absolute path to a file). Write files to /tmp/ before sending.",
|
package/src/proxy/server.ts
CHANGED
|
@@ -435,8 +435,8 @@ export function createProxyServer(config: Partial<ProxyConfig> = {}) {
|
|
|
435
435
|
// Client tool mode: serialize all messages as context, inject tools
|
|
436
436
|
const conversationParts = messages
|
|
437
437
|
.map((m) => {
|
|
438
|
-
const
|
|
439
|
-
return
|
|
438
|
+
const tag = m.role === "assistant" ? "assistant_message" : "user_message"
|
|
439
|
+
return `<${tag}>\n${serializeContent(m.content, tempFiles)}\n</${tag}>`
|
|
440
440
|
})
|
|
441
441
|
.join("\n\n")
|
|
442
442
|
const toolsSection = buildClientToolsPrompt(body.tools)
|
|
@@ -449,15 +449,15 @@ export function createProxyServer(config: Partial<ProxyConfig> = {}) {
|
|
|
449
449
|
systemPrompt = systemContext || undefined
|
|
450
450
|
prompt = serializeContent(messages[0]!.content, tempFiles)
|
|
451
451
|
} else {
|
|
452
|
-
// Multi-turn: build conversation context with
|
|
452
|
+
// Multi-turn: build conversation context with XML-delimited turns.
|
|
453
453
|
// Put prior turns in system prompt as context, last user message as prompt.
|
|
454
454
|
const lastMsg = messages[messages.length - 1]!
|
|
455
455
|
const priorMsgs = messages.slice(0, -1)
|
|
456
456
|
|
|
457
457
|
const contextParts = priorMsgs
|
|
458
458
|
.map((m) => {
|
|
459
|
-
const
|
|
460
|
-
return
|
|
459
|
+
const tag = m.role === "assistant" ? "assistant_message" : "user_message"
|
|
460
|
+
return `<${tag}>\n${serializeContent(m.content, tempFiles)}\n</${tag}>`
|
|
461
461
|
})
|
|
462
462
|
.join("\n\n")
|
|
463
463
|
|