@dtlabs/ai-toolkit 0.15.0 → 0.15.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/CHANGELOG.md +8 -0
- package/lib/workflow-control.js +13 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
## 0.1.4 (2026-07-21)
|
|
2
|
+
## [0.15.1](https://github.com/dtlab-tech/ai-toolkit/compare/v0.15.0...v0.15.1) (2026-10-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **workflows:** recover ```json structured output wrapped around a ne… ([a96add9](https://github.com/dtlab-tech/ai-toolkit/commit/a96add902195ea0a125e0fbbc9be06126dfbd602))
|
|
8
|
+
* **workflows:** recover ```json structured output wrapped around a nested untagged fence ([6e92dd2](https://github.com/dtlab-tech/ai-toolkit/commit/6e92dd28bf96f6e96947b45bcc7c8e54d7cb9c38))
|
|
9
|
+
|
|
2
10
|
## [0.15.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.14.3...v0.15.0) (2026-10-01)
|
|
3
11
|
|
|
4
12
|
|
package/lib/workflow-control.js
CHANGED
|
@@ -307,6 +307,19 @@ function extractDelimitedStructuredOutput(text, schema) {
|
|
|
307
307
|
if (tagMatch) candidates.push(tagMatch[1]);
|
|
308
308
|
const fenceMatches = [...text.matchAll(/```json\s*([\s\S]*?)```/gi)];
|
|
309
309
|
if (fenceMatches.length) candidates.push(fenceMatches[fenceMatches.length - 1][1]);
|
|
310
|
+
// The non-greedy fence match above stops at the FIRST ``` following ```json, which is
|
|
311
|
+
// wrong when a schema string field (e.g. a "report") legitimately embeds its own
|
|
312
|
+
// untagged ``` ... ``` example (a markdown table, say) before the real closing fence —
|
|
313
|
+
// observed empirically with gaia-validate-feature-docs. Recover with a brace-balance
|
|
314
|
+
// span instead of a fence-delimiter match, anchored after the last ```json marker so it
|
|
315
|
+
// is immune to backtick nesting inside string values.
|
|
316
|
+
const lastJsonFence = text.lastIndexOf('```json');
|
|
317
|
+
if (lastJsonFence !== -1) {
|
|
318
|
+
const tail = text.slice(lastJsonFence + '```json'.length);
|
|
319
|
+
const first = tail.indexOf('{');
|
|
320
|
+
const last = tail.lastIndexOf('}');
|
|
321
|
+
if (first !== -1 && last > first) candidates.push(tail.slice(first, last + 1));
|
|
322
|
+
}
|
|
310
323
|
for (const raw of candidates) {
|
|
311
324
|
try {
|
|
312
325
|
const parsed = JSON.parse(raw.trim());
|