claude-sdk-proxy 3.1.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-sdk-proxy",
3
- "version": "3.1.1",
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 ?? ""),