claude-sdk-proxy 3.1.0 → 3.1.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/README.md +4 -0
- package/package.json +1 -1
- package/src/proxy/server.ts +17 -1
package/README.md
CHANGED
|
@@ -300,6 +300,10 @@ Use your endpoint in any Anthropic-compatible chat app:
|
|
|
300
300
|
| **API Key** | Your `CLAUDE_PROXY_API_KEY` value |
|
|
301
301
|
| **Model** | `claude-opus-4-6`, `claude-sonnet-4-6`, or `claude-haiku-4-5-20251001` |
|
|
302
302
|
|
|
303
|
+
## Attribution
|
|
304
|
+
|
|
305
|
+
**Built on** [rynfar/opencode-claude-max-proxy](https://github.com/rynfar/opencode-claude-max-proxy) — the original concept and foundation for this proxy implementation. This fork expands the idea into a full mock API endpoint with Anthropic and OpenAI compatibility.
|
|
306
|
+
|
|
303
307
|
## License
|
|
304
308
|
|
|
305
309
|
MIT
|
package/package.json
CHANGED
package/src/proxy/server.ts
CHANGED
|
@@ -221,7 +221,23 @@ function parseToolUse(text: string): { toolCalls: ToolCall[]; textBefore: string
|
|
|
221
221
|
while ((m = xmlRegex.exec(text)) !== null) {
|
|
222
222
|
if (firstIdx < 0) firstIdx = m.index
|
|
223
223
|
try {
|
|
224
|
-
const
|
|
224
|
+
const raw = m[1]!.trim()
|
|
225
|
+
let p: any
|
|
226
|
+
try { p = JSON.parse(raw) } catch {
|
|
227
|
+
// Repair: models often emit raw newlines in heredocs/multiline commands
|
|
228
|
+
// which are invalid inside JSON strings. Escape them only inside quoted values.
|
|
229
|
+
let fixed = "", inStr = false, esc = false
|
|
230
|
+
for (const ch of raw) {
|
|
231
|
+
if (esc) { fixed += ch; esc = false; continue }
|
|
232
|
+
if (ch === "\\") { esc = true; fixed += ch; continue }
|
|
233
|
+
if (ch === '"') { inStr = !inStr; fixed += ch; continue }
|
|
234
|
+
if (inStr && ch === "\n") { fixed += "\\n"; continue }
|
|
235
|
+
if (inStr && ch === "\r") { fixed += "\\r"; continue }
|
|
236
|
+
if (inStr && ch === "\t") { fixed += "\\t"; continue }
|
|
237
|
+
fixed += ch
|
|
238
|
+
}
|
|
239
|
+
p = JSON.parse(fixed)
|
|
240
|
+
}
|
|
225
241
|
calls.push({
|
|
226
242
|
id: generateId("toolu_"),
|
|
227
243
|
name: String(p.name ?? ""),
|