@riddledc/riddle-proof 0.5.47 → 0.5.49

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
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-ODORKNSO.js";
18
18
  import {
19
19
  runRiddleProof
20
- } from "./chunk-N3ZNBRIG.js";
20
+ } from "./chunk-YJPQOAZG.js";
21
21
  import {
22
22
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
23
23
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -32,14 +32,14 @@ import {
32
32
  createDisabledRiddleProofAgentAdapter,
33
33
  readRiddleProofRunStatus,
34
34
  runRiddleProofEngineHarness
35
- } from "./chunk-ALP5KOS2.js";
35
+ } from "./chunk-722PW3X3.js";
36
36
  import "./chunk-4ASMX4R6.js";
37
37
  import "./chunk-JFQXAJH2.js";
38
38
  import {
39
39
  createCodexExecAgentAdapter,
40
40
  createCodexExecJsonRunner,
41
41
  runCodexExecAgentDoctor
42
- } from "./chunk-NOBFZDZG.js";
42
+ } from "./chunk-YW77WDTR.js";
43
43
  import {
44
44
  RIDDLE_PROOF_RUN_STATE_VERSION,
45
45
  appendRunEvent,
@@ -51,11 +51,11 @@ import {
51
51
  normalizePrLifecycleState,
52
52
  normalizeRunParams,
53
53
  setRunStatus
54
- } from "./chunk-JOXTKWX6.js";
54
+ } from "./chunk-U7Q3RB5D.js";
55
55
  import {
56
56
  RIDDLE_PROOF_RUN_CARD_VERSION,
57
57
  createRiddleProofRunCard
58
- } from "./chunk-PLSGW2GI.js";
58
+ } from "./chunk-CI2F66EE.js";
59
59
  import {
60
60
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
61
61
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -41,6 +41,13 @@ var import_node_child_process = require("child_process");
41
41
  var import_node_fs = require("fs");
42
42
  var import_node_os = __toESM(require("os"), 1);
43
43
  var import_node_path = __toESM(require("path"), 1);
44
+
45
+ // src/result.ts
46
+ function compactRecord(input) {
47
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
48
+ }
49
+
50
+ // src/codex-exec-agent.ts
44
51
  var REFINED_INPUTS_SCHEMA = {
45
52
  type: "object",
46
53
  additionalProperties: false,
@@ -166,10 +173,10 @@ var PROOF_SCHEMA = {
166
173
  source: { type: "string", enum: ["supervising_agent"] }
167
174
  }
168
175
  };
169
- var PROMPT_STRING_LIMIT = 2e3;
170
- var PROMPT_ARRAY_LIMIT = 12;
171
- var PROMPT_OBJECT_KEY_LIMIT = 70;
172
- var PROMPT_BLOCK_LIMIT = 12e4;
176
+ var PROMPT_STRING_LIMIT = 1400;
177
+ var PROMPT_ARRAY_LIMIT = 8;
178
+ var PROMPT_OBJECT_KEY_LIMIT = 50;
179
+ var PROMPT_BLOCK_LIMIT = 7e4;
173
180
  var PROMPT_KEY_PRIORITY = [
174
181
  "ok",
175
182
  "status",
@@ -191,6 +198,16 @@ var PROMPT_KEY_PRIORITY = [
191
198
  "after_cdn",
192
199
  "before_baseline",
193
200
  "prod_baseline",
201
+ "route_hints",
202
+ "route_candidates",
203
+ "keyword_hits",
204
+ "observations",
205
+ "latest_attempt",
206
+ "attempt_history",
207
+ "current_plan",
208
+ "plan_history",
209
+ "decision_history",
210
+ "refined_inputs",
194
211
  "recon_assessment",
195
212
  "baseline_understanding",
196
213
  "supervisor_author_packet",
@@ -214,6 +231,7 @@ var PROMPT_KEY_PRIORITY = [
214
231
  "shipGate",
215
232
  "last_error",
216
233
  "errors",
234
+ "runtime_events",
217
235
  "events"
218
236
  ];
219
237
  var PROMPT_PRIORITY_INDEX = new Map(PROMPT_KEY_PRIORITY.map((key, index) => [key, index]));
@@ -230,7 +248,7 @@ function compactPromptValue(value, depth = 0, key = "") {
230
248
  if (!looksLikeUrl && (lowerKey.includes("base64") || lowerKey.includes("data_url") || lowerKey.includes("screenshot_blob"))) {
231
249
  return `[omitted ${value.length} chars from ${key || "large artifact"}]`;
232
250
  }
233
- const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 1200;
251
+ const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 900;
234
252
  return truncatePromptString(value, limit);
235
253
  }
236
254
  if (Array.isArray(value)) {
@@ -361,11 +379,39 @@ function isHarnessVerificationOnlyBlocker(blocker) {
361
379
  const text = blocker.toLowerCase();
362
380
  return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
363
381
  }
382
+ function runnerMetrics(input) {
383
+ const schemaText = JSON.stringify(input.request.schema);
384
+ const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
385
+ return compactRecord({
386
+ purpose: input.request.purpose,
387
+ workdir: input.request.workdir,
388
+ started_at: input.startedAt,
389
+ finished_at: finishedAt,
390
+ duration_ms: Date.now() - input.startedMs,
391
+ prompt_chars: input.request.prompt.length,
392
+ prompt_lines: input.request.prompt.split(/\r?\n/).length,
393
+ schema_chars: schemaText.length,
394
+ stdout_chars: (input.stdout || "").length,
395
+ stderr_chars: (input.stderr || "").length,
396
+ final_message_chars: (input.finalText || "").length,
397
+ exit_status: input.status ?? null,
398
+ timed_out: input.timedOut || false,
399
+ error_code: input.errorCode,
400
+ codex_command: input.config.codexCommand || "codex",
401
+ codex_model: input.config.codexModel,
402
+ codex_sandbox: input.config.codexSandbox || "workspace-write",
403
+ codex_full_auto: input.config.codexFullAuto !== false,
404
+ timeout_ms: Number(input.config.codexTimeoutMs || 6e5)
405
+ });
406
+ }
364
407
  function createCodexExecJsonRunner(config = {}) {
365
408
  return (request) => {
409
+ const startedAt = (/* @__PURE__ */ new Date()).toISOString();
410
+ const startedMs = Date.now();
366
411
  if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
367
412
  return {
368
413
  ok: false,
414
+ metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
369
415
  blocker: {
370
416
  code: "codex_workdir_missing",
371
417
  message: `Codex workdir does not exist for ${request.purpose}.`,
@@ -410,6 +456,17 @@ function createCodexExecJsonRunner(config = {}) {
410
456
  ok: false,
411
457
  stdout: proc.stdout || "",
412
458
  stderr: proc.stderr || "",
459
+ metrics: runnerMetrics({
460
+ request,
461
+ config,
462
+ startedAt,
463
+ startedMs,
464
+ stdout: proc.stdout || "",
465
+ stderr: proc.stderr || "",
466
+ status: proc.status,
467
+ timedOut,
468
+ errorCode: proc.error.code || "spawn_error"
469
+ }),
413
470
  blocker: {
414
471
  code: timedOut ? "codex_timeout" : "codex_exec_error",
415
472
  message: timedOut ? `Codex timed out during ${request.purpose}.` : `Codex failed to start or complete ${request.purpose}.`,
@@ -422,6 +479,16 @@ function createCodexExecJsonRunner(config = {}) {
422
479
  ok: false,
423
480
  stdout: proc.stdout || "",
424
481
  stderr: proc.stderr || "",
482
+ metrics: runnerMetrics({
483
+ request,
484
+ config,
485
+ startedAt,
486
+ startedMs,
487
+ stdout: proc.stdout || "",
488
+ stderr: proc.stderr || "",
489
+ status: proc.status,
490
+ errorCode: "nonzero_exit"
491
+ }),
425
492
  blocker: {
426
493
  code: "codex_nonzero_exit",
427
494
  message: `Codex exited with status ${proc.status} during ${request.purpose}.`,
@@ -436,6 +503,17 @@ function createCodexExecJsonRunner(config = {}) {
436
503
  ok: false,
437
504
  stdout: proc.stdout || "",
438
505
  stderr: proc.stderr || "",
506
+ metrics: runnerMetrics({
507
+ request,
508
+ config,
509
+ startedAt,
510
+ startedMs,
511
+ stdout: proc.stdout || "",
512
+ stderr: proc.stderr || "",
513
+ finalText,
514
+ status: proc.status,
515
+ errorCode: "invalid_json"
516
+ }),
439
517
  blocker: {
440
518
  code: "codex_invalid_json",
441
519
  message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
@@ -447,7 +525,17 @@ function createCodexExecJsonRunner(config = {}) {
447
525
  ok: true,
448
526
  json: parsed,
449
527
  stdout: proc.stdout || "",
450
- stderr: proc.stderr || ""
528
+ stderr: proc.stderr || "",
529
+ metrics: runnerMetrics({
530
+ request,
531
+ config,
532
+ startedAt,
533
+ startedMs,
534
+ stdout: proc.stdout || "",
535
+ stderr: proc.stderr || "",
536
+ finalText,
537
+ status: proc.status
538
+ })
451
539
  };
452
540
  } finally {
453
541
  (0, import_node_fs.rmSync)(tmpDir, { recursive: true, force: true });
@@ -468,14 +556,21 @@ function payloadOrBlocker(raw, checkpoint) {
468
556
  ok: false,
469
557
  blocker: {
470
558
  ...blocker,
471
- checkpoint
559
+ checkpoint,
560
+ details: {
561
+ ...blocker.details || {},
562
+ runner_metrics: raw.metrics || null
563
+ }
472
564
  }
473
565
  };
474
566
  }
475
567
  return {
476
568
  ok: true,
477
569
  payload: raw.json,
478
- summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0
570
+ summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0,
571
+ details: compactRecord({
572
+ runner_metrics: raw.metrics || null
573
+ })
479
574
  };
480
575
  }
481
576
  function stringArray(value) {
@@ -611,14 +706,16 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
611
706
  agent_summary: summary,
612
707
  agent_changed_files: changedFiles,
613
708
  agent_tests_run: testsRun,
614
- agent_blockers: blockers
709
+ agent_blockers: blockers,
710
+ runner_metrics: raw.metrics || null
615
711
  };
616
712
  attemptSummaries.push({
617
713
  purpose,
618
714
  summary,
619
715
  changed_files: changedFiles,
620
716
  tests_run: testsRun,
621
- blockers
717
+ blockers,
718
+ runner_metrics: raw.metrics || null
622
719
  });
623
720
  if (hardBlockers.length) {
624
721
  return {
@@ -3,7 +3,8 @@ import {
3
3
  createCodexExecAgentAdapter,
4
4
  createCodexExecJsonRunner,
5
5
  runCodexExecAgentDoctor
6
- } from "./chunk-NOBFZDZG.js";
6
+ } from "./chunk-YW77WDTR.js";
7
+ import "./chunk-DUFDZJOF.js";
7
8
  export {
8
9
  createCodexExecAgentAdapter as createLocalAgentAdapter,
9
10
  createCodexExecJsonRunner as createLocalAgentJsonRunner,
package/dist/openclaw.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-JOXTKWX6.js";
5
- import "./chunk-PLSGW2GI.js";
4
+ } from "./chunk-U7Q3RB5D.js";
5
+ import "./chunk-CI2F66EE.js";
6
6
  import "./chunk-R6SCWJCI.js";
7
7
  import {
8
8
  compactRecord
@@ -115,7 +115,7 @@ declare function buildSetupArgs(params: WorkflowParams, config: ReturnType<typeo
115
115
  target_image_hash: string;
116
116
  viewport_matrix_json: string;
117
117
  deterministic_setup_json: string;
118
- reference: "prod" | "before" | "both";
118
+ reference: "before" | "prod" | "both";
119
119
  base_branch: string;
120
120
  before_ref: string;
121
121
  allow_static_preview_fallback: string;
@@ -115,7 +115,7 @@ declare function buildSetupArgs(params: WorkflowParams, config: ReturnType<typeo
115
115
  target_image_hash: string;
116
116
  viewport_matrix_json: string;
117
117
  deterministic_setup_json: string;
118
- reference: "prod" | "before" | "both";
118
+ reference: "before" | "prod" | "both";
119
119
  base_branch: string;
120
120
  before_ref: string;
121
121
  allow_static_preview_fallback: string;
@@ -1745,9 +1745,27 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1745
1745
  }
1746
1746
  return "inspect the ship gate details, repair the missing invariant, then resume the run";
1747
1747
  };
1748
+ const shipGateRecoveryStage = (shipGate) => {
1749
+ const reasons = shipGate.reasons || [];
1750
+ if (reasons.some((reason) => reason.includes("before_cdn") || reason.includes("prod_cdn") || reason.includes("prod_url"))) {
1751
+ return "recon";
1752
+ }
1753
+ if (reasons.some((reason) => reason.includes("implementation"))) {
1754
+ return "implement";
1755
+ }
1756
+ if (reasons.some((reason) => reason.includes("after_cdn") || reason.includes("verify_status") || reason.includes("visual_delta"))) {
1757
+ return "verify";
1758
+ }
1759
+ if (reasons.some((reason) => reason.includes("proof_assessment"))) {
1760
+ return "verify";
1761
+ }
1762
+ return "verify";
1763
+ };
1748
1764
  const shipGateBlocked = (state, executed, details = {}) => {
1749
1765
  const shipGate = validateShipGate(state);
1750
1766
  const nextAction = primaryShipGateNextAction(shipGate);
1767
+ const recoveryStage = shipGateRecoveryStage(shipGate);
1768
+ const advanceOptions = Array.from(/* @__PURE__ */ new Set([recoveryStage, "verify", "author", "implement", "recon", "ship"]));
1751
1769
  return checkpoint(
1752
1770
  "verify",
1753
1771
  "ship_gate_blocked",
@@ -1755,12 +1773,13 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1755
1773
  {
1756
1774
  ok: false,
1757
1775
  nextActions: ["inspect_ship_gate", "advance_run_to_verify", "supply_proof_assessment_json", "return_to_recon_if_baseline_is_missing"],
1758
- advanceOptions: ["verify", "author", "implement", "recon"],
1759
- recommendedAdvanceStage: "verify",
1760
- continueWithStage: "verify",
1776
+ advanceOptions,
1777
+ recommendedAdvanceStage: recoveryStage,
1778
+ continueWithStage: recoveryStage,
1761
1779
  blocking: true,
1762
- details: { ...details, shipGate, next_action: nextAction, executed },
1780
+ details: { ...details, shipGate, next_action: nextAction, recovery_stage: recoveryStage, executed },
1763
1781
  nextAction,
1782
+ recoveryStage,
1764
1783
  shipGate,
1765
1784
  verifyStatus: state?.verify_status || null,
1766
1785
  mergeRecommendation: state?.merge_recommendation || null,
@@ -277,7 +277,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
277
277
  blocking?: boolean;
278
278
  details?: Record<string, unknown>;
279
279
  ok: boolean;
280
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
280
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
281
281
  state_path: string;
282
282
  stage: any;
283
283
  summary: string;
@@ -362,7 +362,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
362
362
  continueWithStage?: WorkflowStage | null;
363
363
  blocking?: boolean;
364
364
  details?: Record<string, unknown>;
365
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
365
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
366
366
  state_path: string;
367
367
  stage: any;
368
368
  checkpoint: string;
@@ -624,7 +624,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
624
624
  error?: undefined;
625
625
  } | {
626
626
  ok: boolean;
627
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
627
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
628
628
  state_path: string;
629
629
  stage: any;
630
630
  summary: string;
@@ -277,7 +277,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
277
277
  blocking?: boolean;
278
278
  details?: Record<string, unknown>;
279
279
  ok: boolean;
280
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
280
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
281
281
  state_path: string;
282
282
  stage: any;
283
283
  summary: string;
@@ -362,7 +362,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
362
362
  continueWithStage?: WorkflowStage | null;
363
363
  blocking?: boolean;
364
364
  details?: Record<string, unknown>;
365
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
365
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
366
366
  state_path: string;
367
367
  stage: any;
368
368
  checkpoint: string;
@@ -624,7 +624,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
624
624
  error?: undefined;
625
625
  } | {
626
626
  ok: boolean;
627
- action: "run" | "ship" | "setup" | "recon" | "author" | "implement" | "verify";
627
+ action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
628
628
  state_path: string;
629
629
  stage: any;
630
630
  summary: string;
@@ -781,9 +781,27 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
781
781
  }
782
782
  return "inspect the ship gate details, repair the missing invariant, then resume the run";
783
783
  };
784
+ const shipGateRecoveryStage = (shipGate) => {
785
+ const reasons = shipGate.reasons || [];
786
+ if (reasons.some((reason) => reason.includes("before_cdn") || reason.includes("prod_cdn") || reason.includes("prod_url"))) {
787
+ return "recon";
788
+ }
789
+ if (reasons.some((reason) => reason.includes("implementation"))) {
790
+ return "implement";
791
+ }
792
+ if (reasons.some((reason) => reason.includes("after_cdn") || reason.includes("verify_status") || reason.includes("visual_delta"))) {
793
+ return "verify";
794
+ }
795
+ if (reasons.some((reason) => reason.includes("proof_assessment"))) {
796
+ return "verify";
797
+ }
798
+ return "verify";
799
+ };
784
800
  const shipGateBlocked = (state, executed, details = {}) => {
785
801
  const shipGate = validateShipGate(state);
786
802
  const nextAction = primaryShipGateNextAction(shipGate);
803
+ const recoveryStage = shipGateRecoveryStage(shipGate);
804
+ const advanceOptions = Array.from(/* @__PURE__ */ new Set([recoveryStage, "verify", "author", "implement", "recon", "ship"]));
787
805
  return checkpoint(
788
806
  "verify",
789
807
  "ship_gate_blocked",
@@ -791,12 +809,13 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
791
809
  {
792
810
  ok: false,
793
811
  nextActions: ["inspect_ship_gate", "advance_run_to_verify", "supply_proof_assessment_json", "return_to_recon_if_baseline_is_missing"],
794
- advanceOptions: ["verify", "author", "implement", "recon"],
795
- recommendedAdvanceStage: "verify",
796
- continueWithStage: "verify",
812
+ advanceOptions,
813
+ recommendedAdvanceStage: recoveryStage,
814
+ continueWithStage: recoveryStage,
797
815
  blocking: true,
798
- details: { ...details, shipGate, next_action: nextAction, executed },
816
+ details: { ...details, shipGate, next_action: nextAction, recovery_stage: recoveryStage, executed },
799
817
  nextAction,
818
+ recoveryStage,
800
819
  shipGate,
801
820
  verifyStatus: state?.verify_status || null,
802
821
  mergeRecommendation: state?.merge_recommendation || null,
package/dist/run-card.cjs CHANGED
@@ -81,6 +81,68 @@ function compactText(value, limit = 600) {
81
81
  if (!text) return void 0;
82
82
  return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
83
83
  }
84
+ function numericValue(value) {
85
+ const number = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
86
+ return Number.isFinite(number) ? number : void 0;
87
+ }
88
+ function eventDetails(event) {
89
+ return recordValue(recordValue(event)?.details) || {};
90
+ }
91
+ function collectRunnerMetrics(details) {
92
+ const metrics = [];
93
+ const adapterDetails = recordValue(details.adapter_details);
94
+ const direct = recordValue(adapterDetails?.runner_metrics);
95
+ if (direct) metrics.push(direct);
96
+ const attempts = Array.isArray(adapterDetails?.attempt_summaries) ? adapterDetails.attempt_summaries : [];
97
+ for (const attempt of attempts) {
98
+ const attemptMetrics = recordValue(recordValue(attempt)?.runner_metrics);
99
+ if (attemptMetrics) metrics.push(attemptMetrics);
100
+ }
101
+ return metrics;
102
+ }
103
+ function observabilityFrom(state) {
104
+ const engineEvents = state.events.filter((event) => event.kind === "engine.result").map((event) => ({ event, details: eventDetails(event) }));
105
+ const agentEvents = state.events.filter((event) => event.kind.startsWith("agent.")).map((event) => ({ event, details: eventDetails(event) })).filter(({ details }) => numericValue(details.duration_ms) !== void 0);
106
+ const retryEvents = state.events.filter((event) => /retry|recovery/i.test(event.kind) || /retry|recovery/i.test(event.summary || "")).slice(-8);
107
+ const runnerMetrics = agentEvents.flatMap(({ details }) => collectRunnerMetrics(details));
108
+ const promptChars = runnerMetrics.map((metrics) => numericValue(metrics.prompt_chars)).filter((value) => value !== void 0);
109
+ const sum = (values) => values.reduce((total, value) => total + (value ?? 0), 0);
110
+ const recentEngineTimings = engineEvents.slice(-8).map(({ event, details }) => compactRecord({
111
+ checkpoint: event.checkpoint || null,
112
+ stage: event.stage || null,
113
+ duration_ms: numericValue(details.duration_ms),
114
+ ok: details.ok ?? null
115
+ }));
116
+ const recentAgentTimings = agentEvents.slice(-8).map(({ event, details }) => {
117
+ const metrics = collectRunnerMetrics(details);
118
+ const localPromptChars = metrics.map((item) => numericValue(item.prompt_chars)).filter((value) => value !== void 0);
119
+ return compactRecord({
120
+ kind: event.kind,
121
+ checkpoint: event.checkpoint || null,
122
+ stage: event.stage || null,
123
+ duration_ms: numericValue(details.duration_ms),
124
+ prompt_chars: localPromptChars.length ? Math.max(...localPromptChars) : void 0,
125
+ attempt_count: numericValue(recordValue(details.adapter_details)?.attempt_count)
126
+ });
127
+ });
128
+ return compactRecord({
129
+ engine_call_count: engineEvents.length,
130
+ agent_call_count: agentEvents.length,
131
+ engine_total_ms: sum(engineEvents.map(({ details }) => numericValue(details.duration_ms))),
132
+ agent_total_ms: sum(agentEvents.map(({ details }) => numericValue(details.duration_ms))),
133
+ max_agent_prompt_chars: promptChars.length ? Math.max(...promptChars) : void 0,
134
+ total_agent_prompt_chars: promptChars.length ? sum(promptChars) : void 0,
135
+ recent_engine_timings: recentEngineTimings.length ? recentEngineTimings : void 0,
136
+ recent_agent_timings: recentAgentTimings.length ? recentAgentTimings : void 0,
137
+ retry_event_count: retryEvents.length,
138
+ recent_retry_reasons: retryEvents.length ? retryEvents.map((event) => compactRecord({
139
+ kind: event.kind,
140
+ checkpoint: event.checkpoint || null,
141
+ stage: event.stage || null,
142
+ summary: compactText(event.summary, 240)
143
+ })) : void 0
144
+ });
145
+ }
84
146
  function visualDeltaFrom(input) {
85
147
  const fullState = input.fullRiddleState || {};
86
148
  const bundle = recordValue(fullState.evidence_bundle);
@@ -193,6 +255,7 @@ function createRiddleProofRunCard(state, input = {}) {
193
255
  proof_evidence_present: fullState.proof_evidence_present === true || Boolean(bundle?.proof_evidence || bundle?.proof_evidence_sample),
194
256
  artifacts
195
257
  }),
258
+ observability: observabilityFrom(state),
196
259
  stop_condition: compactRecord({
197
260
  status: state.status,
198
261
  terminal: isTerminalStatus(state.status),
package/dist/run-card.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RIDDLE_PROOF_RUN_CARD_VERSION,
3
3
  createRiddleProofRunCard
4
- } from "./chunk-PLSGW2GI.js";
4
+ } from "./chunk-CI2F66EE.js";
5
5
  import "./chunk-R6SCWJCI.js";
6
6
  import "./chunk-DUFDZJOF.js";
7
7
  export {
package/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-N3ZNBRIG.js";
4
- import "./chunk-JOXTKWX6.js";
5
- import "./chunk-PLSGW2GI.js";
3
+ } from "./chunk-YJPQOAZG.js";
4
+ import "./chunk-U7Q3RB5D.js";
5
+ import "./chunk-CI2F66EE.js";
6
6
  import "./chunk-R6SCWJCI.js";
7
7
  import "./chunk-DUFDZJOF.js";
8
8
  export {
package/dist/state.cjs CHANGED
@@ -89,6 +89,68 @@ function compactText(value, limit = 600) {
89
89
  if (!text) return void 0;
90
90
  return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
91
91
  }
92
+ function numericValue(value) {
93
+ const number = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
94
+ return Number.isFinite(number) ? number : void 0;
95
+ }
96
+ function eventDetails(event) {
97
+ return recordValue(recordValue(event)?.details) || {};
98
+ }
99
+ function collectRunnerMetrics(details) {
100
+ const metrics = [];
101
+ const adapterDetails = recordValue(details.adapter_details);
102
+ const direct = recordValue(adapterDetails?.runner_metrics);
103
+ if (direct) metrics.push(direct);
104
+ const attempts = Array.isArray(adapterDetails?.attempt_summaries) ? adapterDetails.attempt_summaries : [];
105
+ for (const attempt of attempts) {
106
+ const attemptMetrics = recordValue(recordValue(attempt)?.runner_metrics);
107
+ if (attemptMetrics) metrics.push(attemptMetrics);
108
+ }
109
+ return metrics;
110
+ }
111
+ function observabilityFrom(state) {
112
+ const engineEvents = state.events.filter((event) => event.kind === "engine.result").map((event) => ({ event, details: eventDetails(event) }));
113
+ const agentEvents = state.events.filter((event) => event.kind.startsWith("agent.")).map((event) => ({ event, details: eventDetails(event) })).filter(({ details }) => numericValue(details.duration_ms) !== void 0);
114
+ const retryEvents = state.events.filter((event) => /retry|recovery/i.test(event.kind) || /retry|recovery/i.test(event.summary || "")).slice(-8);
115
+ const runnerMetrics = agentEvents.flatMap(({ details }) => collectRunnerMetrics(details));
116
+ const promptChars = runnerMetrics.map((metrics) => numericValue(metrics.prompt_chars)).filter((value) => value !== void 0);
117
+ const sum = (values) => values.reduce((total, value) => total + (value ?? 0), 0);
118
+ const recentEngineTimings = engineEvents.slice(-8).map(({ event, details }) => compactRecord({
119
+ checkpoint: event.checkpoint || null,
120
+ stage: event.stage || null,
121
+ duration_ms: numericValue(details.duration_ms),
122
+ ok: details.ok ?? null
123
+ }));
124
+ const recentAgentTimings = agentEvents.slice(-8).map(({ event, details }) => {
125
+ const metrics = collectRunnerMetrics(details);
126
+ const localPromptChars = metrics.map((item) => numericValue(item.prompt_chars)).filter((value) => value !== void 0);
127
+ return compactRecord({
128
+ kind: event.kind,
129
+ checkpoint: event.checkpoint || null,
130
+ stage: event.stage || null,
131
+ duration_ms: numericValue(details.duration_ms),
132
+ prompt_chars: localPromptChars.length ? Math.max(...localPromptChars) : void 0,
133
+ attempt_count: numericValue(recordValue(details.adapter_details)?.attempt_count)
134
+ });
135
+ });
136
+ return compactRecord({
137
+ engine_call_count: engineEvents.length,
138
+ agent_call_count: agentEvents.length,
139
+ engine_total_ms: sum(engineEvents.map(({ details }) => numericValue(details.duration_ms))),
140
+ agent_total_ms: sum(agentEvents.map(({ details }) => numericValue(details.duration_ms))),
141
+ max_agent_prompt_chars: promptChars.length ? Math.max(...promptChars) : void 0,
142
+ total_agent_prompt_chars: promptChars.length ? sum(promptChars) : void 0,
143
+ recent_engine_timings: recentEngineTimings.length ? recentEngineTimings : void 0,
144
+ recent_agent_timings: recentAgentTimings.length ? recentAgentTimings : void 0,
145
+ retry_event_count: retryEvents.length,
146
+ recent_retry_reasons: retryEvents.length ? retryEvents.map((event) => compactRecord({
147
+ kind: event.kind,
148
+ checkpoint: event.checkpoint || null,
149
+ stage: event.stage || null,
150
+ summary: compactText(event.summary, 240)
151
+ })) : void 0
152
+ });
153
+ }
92
154
  function visualDeltaFrom(input) {
93
155
  const fullState = input.fullRiddleState || {};
94
156
  const bundle = recordValue(fullState.evidence_bundle);
@@ -201,6 +263,7 @@ function createRiddleProofRunCard(state, input = {}) {
201
263
  proof_evidence_present: fullState.proof_evidence_present === true || Boolean(bundle?.proof_evidence || bundle?.proof_evidence_sample),
202
264
  artifacts
203
265
  }),
266
+ observability: observabilityFrom(state),
204
267
  stop_condition: compactRecord({
205
268
  status: state.status,
206
269
  terminal: isTerminalStatus(state.status),
package/dist/state.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  normalizePrLifecycleState,
10
10
  normalizeRunParams,
11
11
  setRunStatus
12
- } from "./chunk-JOXTKWX6.js";
13
- import "./chunk-PLSGW2GI.js";
12
+ } from "./chunk-U7Q3RB5D.js";
13
+ import "./chunk-CI2F66EE.js";
14
14
  import "./chunk-R6SCWJCI.js";
15
15
  import "./chunk-DUFDZJOF.js";
16
16
  export {
package/dist/types.d.cts CHANGED
@@ -199,6 +199,18 @@ interface RiddleProofRunCard {
199
199
  proof_evidence_present?: boolean;
200
200
  artifacts?: RiddleProofCheckpointArtifact[];
201
201
  };
202
+ observability?: {
203
+ engine_call_count?: number;
204
+ agent_call_count?: number;
205
+ engine_total_ms?: number;
206
+ agent_total_ms?: number;
207
+ max_agent_prompt_chars?: number;
208
+ total_agent_prompt_chars?: number;
209
+ recent_engine_timings?: Array<Record<string, unknown>>;
210
+ recent_agent_timings?: Array<Record<string, unknown>>;
211
+ retry_event_count?: number;
212
+ recent_retry_reasons?: Array<Record<string, unknown>>;
213
+ };
202
214
  stop_condition: {
203
215
  status: RiddleProofStatus;
204
216
  terminal?: boolean;