@flue/client 0.0.7 → 0.0.8
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/index.mjs +18 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -248,18 +248,30 @@ function extractResult(parts, schema, sessionId) {
|
|
|
248
248
|
rawOutput: allText
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
251
|
+
let result = resultBlock;
|
|
252
|
+
if (schema.type === "object" || schema.type === "array") try {
|
|
253
|
+
result = JSON.parse(result);
|
|
254
|
+
} catch {
|
|
255
|
+
console.error("[flue] extractResult: schema validation failed", schema);
|
|
254
256
|
console.error("[flue] extractResult: parsed value was:", JSON.stringify(resultBlock));
|
|
255
257
|
throw new SkillOutputError("Result does not match the expected schema.", {
|
|
256
258
|
sessionId,
|
|
257
259
|
rawOutput: resultBlock,
|
|
258
|
-
validationErrors:
|
|
260
|
+
validationErrors: ["JSON.parse(result) failed"]
|
|
259
261
|
});
|
|
260
262
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
const parsedResult = v.safeParse(schema, result);
|
|
264
|
+
if (!parsedResult.success) {
|
|
265
|
+
console.error("[flue] extractResult: schema validation failed", parsedResult.issues);
|
|
266
|
+
console.error("[flue] extractResult: parsed value was:", JSON.stringify(result));
|
|
267
|
+
throw new SkillOutputError("Result does not match the expected schema.", {
|
|
268
|
+
sessionId,
|
|
269
|
+
rawOutput: result,
|
|
270
|
+
validationErrors: parsedResult.issues
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
console.log("[flue] extractResult: validated result:", JSON.stringify(parsedResult.output));
|
|
274
|
+
return parsedResult.output;
|
|
263
275
|
}
|
|
264
276
|
/**
|
|
265
277
|
* Extracts the content of the last ---RESULT_START--- / ---RESULT_END--- block from text.
|