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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-sdk-proxy",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Anthropic Messages API proxy backed by Claude Agent SDK — use Claude Max with any API client",
5
5
  "type": "module",
6
6
  "main": "./src/proxy/server.ts",
@@ -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 p = JSON.parse(m[1]!.trim())
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 ?? ""),