@hilbras/sdk 3.8.0 → 3.8.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/output/structured.js +12 -3
- package/package.json +7 -7
|
@@ -52,9 +52,18 @@ export function extractJson(raw) {
|
|
|
52
52
|
return text;
|
|
53
53
|
}
|
|
54
54
|
// Strip markdown code fences: ```json ... ``` or ``` ... ```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
//
|
|
56
|
+
// String operations rather than a regex. The equivalent pattern
|
|
57
|
+
// (`^```(?:json)?\s*\n?([\s\S]*?)\n?\s*```$`) partitions the leading
|
|
58
|
+
// whitespace ambiguously, so a response that opens a fence and then runs on
|
|
59
|
+
// in spaces without ever closing it makes the engine backtrack
|
|
60
|
+
// quadratically — tens of thousands of spaces is enough to hang the process.
|
|
61
|
+
// `extractJson` runs on model output, so an upstream response could trigger
|
|
62
|
+
// it.
|
|
63
|
+
if (text.length >= 6 && text.startsWith("```") && text.endsWith("```")) {
|
|
64
|
+
// Drop the opening fence and its optional language token (```json).
|
|
65
|
+
const body = text.slice(3, -3).replace(/^(?:json)?[ \t]*\r?\n?/, "");
|
|
66
|
+
return body.trim();
|
|
58
67
|
}
|
|
59
68
|
// Try to find a JSON object or array in the text by bracket matching
|
|
60
69
|
const objStart = text.indexOf("{");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hilbras/sdk",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "Provider-agnostic LLM client SDK — streaming, tool calling, embeddings, image generation, speech synthesis, transcription, reranking, circuit breaker, retry, reasoning normalization, cost enforcement, structured output with schema validation, type-safe tool builder, and SSRF-safe provider registration. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
"dev": "tsc --watch",
|
|
241
241
|
"pretest": "npx tsc --noEmit",
|
|
242
242
|
"typecheck:examples": "tsc -p tsconfig.examples-check.json",
|
|
243
|
-
|
|
243
|
+
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
|
244
244
|
"test": "npm run test:root",
|
|
245
245
|
"test:watch": "vitest",
|
|
246
246
|
"test:coverage": "vitest run --coverage",
|
|
@@ -312,17 +312,17 @@
|
|
|
312
312
|
}
|
|
313
313
|
},
|
|
314
314
|
"devDependencies": {
|
|
315
|
-
"@types/node": "^26.6.
|
|
315
|
+
"@types/node": "^26.6.6",
|
|
316
316
|
"@types/react": "^19.3.0",
|
|
317
317
|
"@types/react-dom": "^19.3.0",
|
|
318
|
-
"@vitest/coverage-v8": "^
|
|
318
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
319
319
|
"jsdom": "^31.0.0",
|
|
320
|
-
"oxlint": "^1.
|
|
320
|
+
"oxlint": "^1.92.0",
|
|
321
321
|
"react": "^19.3.1",
|
|
322
322
|
"react-dom": "^19.3.1",
|
|
323
323
|
"typescript": "^7.0.2",
|
|
324
|
-
"vitest": "^
|
|
325
|
-
"vue": "^3.5.
|
|
324
|
+
"vitest": "^5.1.0",
|
|
325
|
+
"vue": "^3.5.45"
|
|
326
326
|
},
|
|
327
327
|
"packageManager": "npm@11.19.0",
|
|
328
328
|
"workspaces": [
|