caveat-cli 0.19.3 → 0.19.5

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.js CHANGED
@@ -74,7 +74,7 @@ import {
74
74
  userPromptSubmitReminderText,
75
75
  writeDigestMarker,
76
76
  writeUserConfigPatch
77
- } from "./chunk-RO2ZVJMX.js";
77
+ } from "./chunk-EMGYSGFX.js";
78
78
 
79
79
  // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
80
80
  var require_code = __commonJS({
@@ -8390,7 +8390,7 @@ function runStats(ctx) {
8390
8390
 
8391
8391
  // src/commands/serve.ts
8392
8392
  async function runServe(opts) {
8393
- const { startServer } = await import("./server-INQI6ANK.js");
8393
+ const { startServer } = await import("./server-RSDQNLWE.js");
8394
8394
  const { port, host } = startServer({ port: opts.port });
8395
8395
  process.stdout.write(`[caveat] web portal: http://${host}:${port}/
8396
8396
  `);
@@ -33275,17 +33275,21 @@ async function rankKnowledge(key, turns, candidates, ask = callJev) {
33275
33275
  const state = {
33276
33276
  turns,
33277
33277
  currentHostOs: fingerprint().os,
33278
- candidates: candidates.map(({ hit, entry }) => ({
33279
- title: hit.title,
33280
- symptom: hit.symptomExcerpt,
33281
- cause: entry.sections.Cause?.slice(0, 300) ?? "",
33282
- resolution: entry.sections.Resolution?.slice(0, 600) ?? "",
33283
- environment: hit.environment
33284
- }))
33278
+ candidates: candidates.map(({ hit, entry }) => {
33279
+ const { applies_to_os: appliesToOs = null, ...recordedEnvironment } = hit.environment;
33280
+ return {
33281
+ title: hit.title,
33282
+ symptom: hit.symptomExcerpt,
33283
+ cause: entry.sections.Cause?.slice(0, 300) ?? "",
33284
+ resolution: entry.sections.Resolution?.slice(0, 600) ?? "",
33285
+ recordedEnvironment,
33286
+ appliesToOs
33287
+ };
33288
+ })
33285
33289
  };
33286
33290
  const questions = Object.fromEntries(candidates.map((_, index) => [`candidate_${index}`, {
33287
33291
  type: "noul",
33288
- instructions: `Does candidates[${index}] directly apply to the unresolved problem shown in the turns and offer a useful resolution? Check the described environment against the task's target environment; currentHostOs is the host OS, which may differ from the target OS.`
33292
+ instructions: `Does candidates[${index}] directly apply to the unresolved problem shown in the turns and offer a useful resolution? A recordedEnvironment value is where the entry was observed, not a restriction. Only appliesToOs restricts the target OS; null means any OS. currentHostOs may differ from the task's target OS.`
33289
33293
  }]));
33290
33294
  const response = await ask(key, state, questions);
33291
33295
  let best = null;
@@ -33906,26 +33910,28 @@ function toolInputText(input) {
33906
33910
  const command = r.command ?? r.cmd;
33907
33911
  return typeof command === "string" ? command : "";
33908
33912
  }
33909
- function isCodexToolError(payload) {
33910
- if (payload.is_error === true) return true;
33911
- const topExit = numericExitCode(payload.exit_code ?? payload.exitCode);
33912
- if (topExit !== null) return topExit !== 0;
33913
+ function codexToolStatus(payload) {
33914
+ if (payload.is_error === true) return "failed";
33913
33915
  const resp = payload.tool_response ?? payload.toolResponse;
33916
+ if (resp !== null && typeof resp === "object" && !Array.isArray(resp) && resp.is_error === true) return "failed";
33917
+ const topExit = numericExitCode(payload.exit_code ?? payload.exitCode);
33918
+ if (topExit !== null) return topExit === 0 ? "succeeded" : "failed";
33914
33919
  if (resp !== null && typeof resp === "object" && !Array.isArray(resp)) {
33915
33920
  const r = resp;
33916
- if (r.is_error === true) return true;
33917
33921
  const exit = numericExitCode(r.exit_code ?? r.exitCode);
33918
- if (exit !== null) return exit !== 0;
33922
+ if (exit !== null) return exit === 0 ? "succeeded" : "failed";
33919
33923
  }
33920
33924
  const responseExit = processExitCodeFromText(extractToolResponseText(resp));
33921
- if (responseExit !== null) return responseExit !== 0;
33925
+ if (responseExit !== null) return responseExit === 0 ? "succeeded" : "failed";
33922
33926
  const transcriptExit = transcriptExitCode(payload);
33923
- if (transcriptExit !== null) return transcriptExit !== 0;
33924
- return false;
33927
+ if (transcriptExit !== null) return transcriptExit === 0 ? "succeeded" : "failed";
33928
+ return "unknown";
33925
33929
  }
33926
33930
  function buildCodexPostToolUseWorkerJob(payload) {
33927
33931
  const sessionId = codexSessionId(payload);
33928
33932
  if (!sessionId) return null;
33933
+ const status2 = codexToolStatus(payload);
33934
+ if (status2 === "succeeded") return null;
33929
33935
  const transcriptPath = typeof payload.transcript_path === "string" ? payload.transcript_path : void 0;
33930
33936
  const toolUseId = typeof payload.tool_use_id === "string" ? payload.tool_use_id : void 0;
33931
33937
  const responseText = extractToolResponseText(payload.tool_response ?? payload.toolResponse);
@@ -33933,8 +33939,7 @@ function buildCodexPostToolUseWorkerJob(payload) {
33933
33939
  const transcriptOutput = transcriptPath && toolUseId ? transcriptToolOutput(transcriptPath, toolUseId) : null;
33934
33940
  const topicText = inputText.trim();
33935
33941
  const failureText = [responseText, transcriptOutput ?? ""].map((s) => s.trim()).filter(Boolean).join("\n");
33936
- const knownError = isCodexToolError(payload);
33937
- if (knownError) {
33942
+ if (status2 === "failed") {
33938
33943
  return { sessionId, topicText, failureText, knownError: true, transcriptPath, toolUseId };
33939
33944
  }
33940
33945
  if (transcriptPath && toolUseId && isShellLikeTool(payload) && (topicText || failureText)) {