@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.
Files changed (2) hide show
  1. package/dist/index.mjs +18 -6
  2. 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
- const parseResult = v.safeParse(schema, resultBlock);
252
- if (!parseResult.success) {
253
- console.error("[flue] extractResult: schema validation failed", parseResult.issues);
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: parseResult.issues
260
+ validationErrors: ["JSON.parse(result) failed"]
259
261
  });
260
262
  }
261
- console.log("[flue] extractResult: validated result:", JSON.stringify(parseResult.output));
262
- return parseResult.output;
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flue/client",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {