@whittlelabs/sifter 0.11.0 → 0.12.0

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 (3) hide show
  1. package/bin.js +24 -4
  2. package/bin.js.map +2 -2
  3. package/package.json +1 -1
package/bin.js CHANGED
@@ -19360,6 +19360,9 @@ var require_claude_code = __commonJS({
19360
19360
  const model = modelOverride ?? this.config.model;
19361
19361
  return new Promise((resolve, reject) => {
19362
19362
  const args = ["--print", "--output-format", "stream-json", "--verbose"];
19363
+ if (spec.outputSchema && typeof spec.outputSchema === "object" && Object.keys(spec.outputSchema).length > 0) {
19364
+ args.push("--json-schema", JSON.stringify(spec.outputSchema));
19365
+ }
19363
19366
  if (model)
19364
19367
  args.push("--model", model);
19365
19368
  if (this.config.maxTurns !== void 0)
@@ -19419,8 +19422,14 @@ var require_claude_code = __commonJS({
19419
19422
  if (code === 0) {
19420
19423
  try {
19421
19424
  const stream = parseStreamJson(stdout);
19425
+ if (stream.resultMeta?.isError) {
19426
+ throw new Error(`Claude Code reported ${stream.resultMeta.subtype ?? "an error"} on its terminal event`);
19427
+ }
19422
19428
  const answerText = stream.finalText ?? stdout;
19423
- const parsed = extractJsonObject(answerText);
19429
+ const parsed = stream.structuredOutput ?? extractJsonObject(answerText);
19430
+ if (parsed === void 0 && stream.resultMeta) {
19431
+ throw new Error(`claude's final message contained no JSON object (result subtype=${stream.resultMeta.subtype ?? "unknown"}; message head: ${JSON.stringify(answerText.slice(0, 160))})`);
19432
+ }
19424
19433
  (0, validate_output_1.assertOutputValid)(spec, parsed);
19425
19434
  settle(() => resolve({
19426
19435
  response: {
@@ -19527,6 +19536,8 @@ var require_claude_code = __commonJS({
19527
19536
  let finalText = null;
19528
19537
  const readPaths = [];
19529
19538
  let usage = null;
19539
+ let resultMeta = null;
19540
+ let structuredOutput = null;
19530
19541
  for (const line of stdout.split("\n")) {
19531
19542
  const trimmed = line.trim();
19532
19543
  if (!trimmed.startsWith("{"))
@@ -19548,8 +19559,17 @@ var require_claude_code = __commonJS({
19548
19559
  }
19549
19560
  }
19550
19561
  } else if (event.type === "result") {
19551
- if (typeof event.result === "string")
19562
+ if (typeof event.result === "string" && event.result.trim().length > 0) {
19552
19563
  finalText = event.result;
19564
+ }
19565
+ resultMeta = {
19566
+ subtype: typeof event.subtype === "string" ? event.subtype : null,
19567
+ isError: event.is_error === true
19568
+ };
19569
+ const so = event.structured_output;
19570
+ if (so && typeof so === "object" && !Array.isArray(so)) {
19571
+ structuredOutput = so;
19572
+ }
19553
19573
  const u = event.usage;
19554
19574
  const cost = event.total_cost_usd;
19555
19575
  usage = {
@@ -19559,7 +19579,7 @@ var require_claude_code = __commonJS({
19559
19579
  };
19560
19580
  }
19561
19581
  }
19562
- return { finalText, readPaths, usage };
19582
+ return { finalText, readPaths, usage, resultMeta, structuredOutput };
19563
19583
  }
19564
19584
  var MAX_REPORTED_READS = 2e3;
19565
19585
  function relativeWorkspaceReads(readPaths, cwd) {
@@ -21484,7 +21504,7 @@ var import_shuttle = __toESM(require_dist5());
21484
21504
  // package.json
21485
21505
  var package_default = {
21486
21506
  name: "@whittlelabs/sifter",
21487
- version: "0.11.0",
21507
+ version: "0.12.0",
21488
21508
  description: "Whittle Sifter: paired AI reviewer for Whittle Sift job pools.",
21489
21509
  bin: {
21490
21510
  "whittle-sifter": "./dist/bin.js"