@tangle-network/agent-eval 0.173.3 → 0.175.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 (149) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +1 -1
  3. package/dist/{proposal-findings-bko3GGy-.js → abort-signal-CtzAM_sJ.js} +11 -11
  4. package/dist/abort-signal-CtzAM_sJ.js.map +1 -0
  5. package/dist/adapters/http.d.ts +2 -2
  6. package/dist/agent-profile-_xPxqVJt.d.ts +488 -0
  7. package/dist/agent-profile-_xPxqVJt.d.ts.map +1 -0
  8. package/dist/analyst/index.d.ts +7 -9
  9. package/dist/analyst/index.d.ts.map +1 -1
  10. package/dist/analyst/index.js +8 -8
  11. package/dist/{benchmark-C4wk_Sjr.js → benchmark-DQKzykkO.js} +2 -2
  12. package/dist/{benchmark-C4wk_Sjr.js.map → benchmark-DQKzykkO.js.map} +1 -1
  13. package/dist/{benchmark-command-BY9oscke.js → benchmark-command-D_5xG9LG.js} +13 -13
  14. package/dist/{benchmark-command-BY9oscke.js.map → benchmark-command-D_5xG9LG.js.map} +1 -1
  15. package/dist/benchmarks/index.d.ts +3 -4
  16. package/dist/benchmarks/index.d.ts.map +1 -1
  17. package/dist/benchmarks/index.js +3 -3
  18. package/dist/campaign/index.d.ts +5 -9
  19. package/dist/campaign/index.js +7 -7
  20. package/dist/{campaign-B3kPMU8S.js → campaign-BzMSCejE.js} +8 -8
  21. package/dist/{campaign-B3kPMU8S.js.map → campaign-BzMSCejE.js.map} +1 -1
  22. package/dist/{opencode-sqlite-eK6HW6dr.js → claude-jsonl-CxZZrDJ3.js} +9 -149
  23. package/dist/claude-jsonl-CxZZrDJ3.js.map +1 -0
  24. package/dist/cli.js +9 -2
  25. package/dist/cli.js.map +1 -1
  26. package/dist/{client-DlqdbM7n.d.ts → client-vyYQg3bm.d.ts} +2 -2
  27. package/dist/{client-DlqdbM7n.d.ts.map → client-vyYQg3bm.d.ts.map} +1 -1
  28. package/dist/contract/index.d.ts +9 -10
  29. package/dist/contract/index.js +8 -8
  30. package/dist/{default-registry-B0bKikCb.js → default-registry-DBqVI4pq.js} +5 -5
  31. package/dist/{default-registry-B0bKikCb.js.map → default-registry-DBqVI4pq.js.map} +1 -1
  32. package/dist/{default-registry-BKwc8bN5.d.ts → default-registry-FfNzaUHV.d.ts} +3 -3
  33. package/dist/{default-registry-BKwc8bN5.d.ts.map → default-registry-FfNzaUHV.d.ts.map} +1 -1
  34. package/dist/{define-agent-eval-CY6qdlGV.d.ts → define-agent-eval-V1jQyCDR.d.ts} +102 -11
  35. package/dist/define-agent-eval-V1jQyCDR.d.ts.map +1 -0
  36. package/dist/{define-agent-eval-8h3lXXee.js → define-agent-eval-ox5McL6e.js} +331 -144
  37. package/dist/define-agent-eval-ox5McL6e.js.map +1 -0
  38. package/dist/{dspy-rlm-engine-CF0t2ITD.js → dspy-rlm-engine-Caz2pl4L.js} +3 -3
  39. package/dist/{dspy-rlm-engine-CF0t2ITD.js.map → dspy-rlm-engine-Caz2pl4L.js.map} +1 -1
  40. package/dist/{engine-DhFir3Ys.d.ts → engine-CvW_I72-.d.ts} +2 -2
  41. package/dist/{engine-DhFir3Ys.d.ts.map → engine-CvW_I72-.d.ts.map} +1 -1
  42. package/dist/experiment/index.d.ts +1 -4
  43. package/dist/experiment/index.d.ts.map +1 -1
  44. package/dist/{external-optimizer-process-BwITA9Jp.js → external-optimizer-process-CxnFL1hd.js} +2 -2
  45. package/dist/{external-optimizer-process-BwITA9Jp.js.map → external-optimizer-process-CxnFL1hd.js.map} +1 -1
  46. package/dist/{external-optimizer-subprocess-wBWeoG6A.js → external-optimizer-subprocess-CQi27uEI.js} +2 -2
  47. package/dist/{external-optimizer-subprocess-wBWeoG6A.js.map → external-optimizer-subprocess-CQi27uEI.js.map} +1 -1
  48. package/dist/fuzz.js +1 -1
  49. package/dist/fuzz.js.map +1 -1
  50. package/dist/hosted/index.d.ts +1 -1
  51. package/dist/{index-D0Db5X-4.d.ts → index-BAAiSF3_.d.ts} +5 -5
  52. package/dist/{index-D0Db5X-4.d.ts.map → index-BAAiSF3_.d.ts.map} +1 -1
  53. package/dist/{index-BQqOjerE.d.ts → index-BTrx5s8m.d.ts} +8 -9
  54. package/dist/index-BTrx5s8m.d.ts.map +1 -0
  55. package/dist/index-DKXuBPXf.d.ts +3840 -0
  56. package/dist/index-DKXuBPXf.d.ts.map +1 -0
  57. package/dist/index.d.ts +11 -13
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +11 -11
  60. package/dist/{integrity-BWywb34E.js → integrity-DsHWCebQ.js} +11 -435
  61. package/dist/integrity-DsHWCebQ.js.map +1 -0
  62. package/dist/{kind-factory-gP6lDySe.js → kind-factory-BLvL-E44.js} +2 -2
  63. package/dist/{kind-factory-gP6lDySe.js.map → kind-factory-BLvL-E44.js.map} +1 -1
  64. package/dist/{llm-judge-BfqMFo4h.js → llm-judge-DmNaBrXB.js} +2541 -2435
  65. package/dist/llm-judge-DmNaBrXB.js.map +1 -0
  66. package/dist/{matrix-DGu8KhSs.d.ts → matrix-CJtXz1ky.d.ts} +2 -2
  67. package/dist/{matrix-DGu8KhSs.d.ts.map → matrix-CJtXz1ky.d.ts.map} +1 -1
  68. package/dist/multishot/golden/index.d.ts +1 -1
  69. package/dist/multishot/index.d.ts +2 -2
  70. package/dist/openapi.json +1 -1
  71. package/dist/opencode-sqlite-CNw3vubS.js +145 -0
  72. package/dist/opencode-sqlite-CNw3vubS.js.map +1 -0
  73. package/dist/{produced-state-D91uDvQw.js → produced-state-B8mw6zj9.js} +2 -2
  74. package/dist/{produced-state-D91uDvQw.js.map → produced-state-B8mw6zj9.js.map} +1 -1
  75. package/dist/report-command-DKlXfU5r.js +1528 -0
  76. package/dist/report-command-DKlXfU5r.js.map +1 -0
  77. package/dist/rl.d.ts +1 -1
  78. package/dist/rl.d.ts.map +1 -1
  79. package/dist/rl.js.map +1 -1
  80. package/dist/rollout/index.js +3 -2
  81. package/dist/{rollout-C-znbbYg.js → rollout-CGlDq1GI.js} +3 -2
  82. package/dist/{rollout-C-znbbYg.js.map → rollout-CGlDq1GI.js.map} +1 -1
  83. package/dist/{semantic-concept-judge-Dok7_35a.js → semantic-concept-judge-E3s_fEjB.js} +3 -3
  84. package/dist/{semantic-concept-judge-Dok7_35a.js.map → semantic-concept-judge-E3s_fEjB.js.map} +1 -1
  85. package/dist/{skillopt-optimization-method-DDw3v3gA.js → skillopt-optimization-method-f7399oGb.js} +5 -5
  86. package/dist/{skillopt-optimization-method-DDw3v3gA.js.map → skillopt-optimization-method-f7399oGb.js.map} +1 -1
  87. package/dist/statistical-heldout-Cqb73yE9.d.ts +1127 -0
  88. package/dist/statistical-heldout-Cqb73yE9.d.ts.map +1 -0
  89. package/dist/{store-otlp-Dow0pk_5.js → store-otlp-DV_H2HDu.js} +2 -2
  90. package/dist/{store-otlp-Dow0pk_5.js.map → store-otlp-DV_H2HDu.js.map} +1 -1
  91. package/dist/{store-tool-spans-CCZNsihA.d.ts → store-tool-spans-4o55ABER.d.ts} +3 -3
  92. package/dist/{store-tool-spans-CCZNsihA.d.ts.map → store-tool-spans-4o55ABER.d.ts.map} +1 -1
  93. package/dist/{store-tool-spans-CeNj_m2L.js → store-tool-spans-B9tjys_h.js} +3 -3
  94. package/dist/{store-tool-spans-CeNj_m2L.js.map → store-tool-spans-B9tjys_h.js.map} +1 -1
  95. package/dist/supervisor-run/index.d.ts +71 -6
  96. package/dist/supervisor-run/index.d.ts.map +1 -1
  97. package/dist/supervisor-run/index.js +6 -1357
  98. package/dist/supervisor-run/index.js.map +1 -1
  99. package/dist/{task-failure-attributes-CZjZeBsY.js → task-failure-attributes-CUy9mkIY.js} +2 -2
  100. package/dist/{task-failure-attributes-CZjZeBsY.js.map → task-failure-attributes-CUy9mkIY.js.map} +1 -1
  101. package/dist/terminal-record-Ce9_UjRz.js +539 -0
  102. package/dist/terminal-record-Ce9_UjRz.js.map +1 -0
  103. package/dist/{tool-groups-Cp4Xdzrp.d.ts → tool-groups-DAe1t6zb.d.ts} +2 -2
  104. package/dist/tool-groups-DAe1t6zb.d.ts.map +1 -0
  105. package/dist/trace-repair/index.d.ts +1 -1
  106. package/dist/traces.d.ts +2 -2
  107. package/dist/traces.js +4 -4
  108. package/dist/{types-Ba5UQyVD.d.ts → types-BJz2CPTM.d.ts} +2 -2
  109. package/dist/{types-Ba5UQyVD.d.ts.map → types-BJz2CPTM.d.ts.map} +1 -1
  110. package/dist/{types-CiWITkGo.js → types-DQ0e2E7y.js} +2 -2
  111. package/dist/types-DQ0e2E7y.js.map +1 -0
  112. package/dist/{types-BDV4PiMR.d.ts → types-Dd1ejaeI.d.ts} +2 -2
  113. package/dist/{types-BDV4PiMR.d.ts.map → types-Dd1ejaeI.d.ts.map} +1 -1
  114. package/dist/{types-CoPUTiXb.d.ts → types-vUdAx2Cj.d.ts} +65 -3
  115. package/dist/types-vUdAx2Cj.d.ts.map +1 -0
  116. package/docs/campaign-proposers.md +42 -0
  117. package/package.json +1 -1
  118. package/dist/agent-profile-B9_GGsG8.d.ts +0 -84
  119. package/dist/agent-profile-B9_GGsG8.d.ts.map +0 -1
  120. package/dist/backend-integrity-CeuTgqsd.d.ts +0 -280
  121. package/dist/backend-integrity-CeuTgqsd.d.ts.map +0 -1
  122. package/dist/benchmark-BjLGkfnN.d.ts +0 -236
  123. package/dist/benchmark-BjLGkfnN.d.ts.map +0 -1
  124. package/dist/define-agent-eval-8h3lXXee.js.map +0 -1
  125. package/dist/define-agent-eval-CY6qdlGV.d.ts.map +0 -1
  126. package/dist/external-optimizer-contracts-CQCpyrIL.d.ts +0 -172
  127. package/dist/external-optimizer-contracts-CQCpyrIL.d.ts.map +0 -1
  128. package/dist/heldout-gate-Df5hsqmm.d.ts +0 -453
  129. package/dist/heldout-gate-Df5hsqmm.d.ts.map +0 -1
  130. package/dist/index-BQqOjerE.d.ts.map +0 -1
  131. package/dist/index-CFDffsKz.d.ts +0 -1135
  132. package/dist/index-CFDffsKz.d.ts.map +0 -1
  133. package/dist/integrity-BWywb34E.js.map +0 -1
  134. package/dist/llm-judge-BfqMFo4h.js.map +0 -1
  135. package/dist/opencode-sqlite-eK6HW6dr.js.map +0 -1
  136. package/dist/power-preflight-Ptse_Kq7.d.ts +0 -117
  137. package/dist/power-preflight-Ptse_Kq7.d.ts.map +0 -1
  138. package/dist/pre-registration-BoI4ucR3.d.ts +0 -592
  139. package/dist/pre-registration-BoI4ucR3.d.ts.map +0 -1
  140. package/dist/promotion-policy-CvMda3kU.d.ts +0 -134
  141. package/dist/promotion-policy-CvMda3kU.d.ts.map +0 -1
  142. package/dist/proposal-findings-bko3GGy-.js.map +0 -1
  143. package/dist/provenance-CRY67X50.d.ts +0 -1995
  144. package/dist/provenance-CRY67X50.d.ts.map +0 -1
  145. package/dist/statistical-heldout-DTyB_6-1.d.ts +0 -295
  146. package/dist/statistical-heldout-DTyB_6-1.d.ts.map +0 -1
  147. package/dist/tool-groups-Cp4Xdzrp.d.ts.map +0 -1
  148. package/dist/types-CiWITkGo.js.map +0 -1
  149. package/dist/types-CoPUTiXb.d.ts.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { c as unscreenedRewardFields } from "./reward-nw2xZGZG.js";
2
2
  import { f as validateRolloutLine, r as ROLLOUT_SCHEMA, u as isRolloutLine } from "./schema-C1aaAxTf.js";
3
+ import { d as parseJson, p as parseSupervisorTree, r as readTerminalRecord, s as isUnavailable, u as asRecord } from "./terminal-record-Ce9_UjRz.js";
3
4
  //#region src/supervisor-run/integrity-issues.ts
4
5
  function evidence(path, value) {
5
6
  return {
@@ -762,436 +763,6 @@ function treeIssues(tree, uncertainty = {}) {
762
763
  //#region src/supervisor-run/integrity-types.ts
763
764
  const SUPERVISOR_RUN_INTEGRITY_SCHEMA = "tangle.supervisor-run-integrity@1";
764
765
  //#endregion
765
- //#region src/supervisor-run/source-facts.ts
766
- function asRecord(v) {
767
- return typeof v === "object" && v !== null ? v : {};
768
- }
769
- function num(v) {
770
- return typeof v === "number" && Number.isFinite(v) ? v : 0;
771
- }
772
- function readSpend(v) {
773
- const rec = asRecord(v);
774
- const tok = asRecord(rec.tokens);
775
- const cacheRead = tok.cacheRead ?? tok.cache_read;
776
- const cacheWrite = tok.cacheWrite ?? tok.cache_write;
777
- return {
778
- tokens: {
779
- input: num(tok.input),
780
- output: num(tok.output),
781
- cacheRead: num(cacheRead),
782
- cacheWrite: num(cacheWrite),
783
- hasCache: cacheRead !== void 0 || cacheWrite !== void 0,
784
- breakdownKnown: tok.cacheBreakdownKnown !== false
785
- },
786
- tokensKnown: rec.tokensKnown !== false,
787
- usd: num(rec.usd),
788
- usdKnown: rec.usdKnown !== false
789
- };
790
- }
791
- function parseJsonl(text) {
792
- return parseJsonlWithDiagnostics(text).rows;
793
- }
794
- function parseJsonlWithDiagnostics(text) {
795
- if (text === null) return {
796
- rows: [],
797
- invalidRows: 0
798
- };
799
- const out = [];
800
- let invalidRows = 0;
801
- for (const line of text.split("\n")) {
802
- const trimmed = line.trim();
803
- if (!trimmed) continue;
804
- try {
805
- const parsed = JSON.parse(trimmed);
806
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) out.push(parsed);
807
- else invalidRows += 1;
808
- } catch {
809
- invalidRows += 1;
810
- }
811
- }
812
- return {
813
- rows: out,
814
- invalidRows
815
- };
816
- }
817
- function parseJson(text) {
818
- if (text === null) return null;
819
- try {
820
- const parsed = JSON.parse(text);
821
- return typeof parsed === "object" && parsed !== null ? parsed : null;
822
- } catch {
823
- return null;
824
- }
825
- }
826
- function ms(at) {
827
- if (typeof at !== "string") return null;
828
- const t = Date.parse(at);
829
- return Number.isFinite(t) ? t : null;
830
- }
831
- function readVerdict(v) {
832
- if (typeof v === "string") return {
833
- label: v,
834
- valid: null,
835
- score: null,
836
- raw: v
837
- };
838
- if (typeof v !== "object" || v === null) return {
839
- label: null,
840
- valid: null,
841
- score: null,
842
- raw: null
843
- };
844
- const rec = v;
845
- const valid = typeof rec.valid === "boolean" ? rec.valid : null;
846
- return {
847
- label: valid === null ? null : valid ? "valid" : "invalid",
848
- valid,
849
- score: typeof rec.score === "number" && Number.isFinite(rec.score) ? rec.score : null,
850
- raw: v
851
- };
852
- }
853
- function workerSourceKey(worker) {
854
- return worker.workerId ?? worker.label;
855
- }
856
- /** Event kinds this parser folds into the tree. */
857
- const TREE_EVENT_KINDS = [
858
- "spawned",
859
- "settled",
860
- "cancelled",
861
- "metered"
862
- ];
863
- /**
864
- * Event kinds `agent-runtime` journals that this parser recognizes but does not model as
865
- * tree nodes: `waiting` arms a wait node and `woken` settles it. They are counted by kind
866
- * rather than dropped, so "understood, not modeled" can never be mistaken for "absent".
867
- */
868
- const UNMODELLED_EVENT_KINDS = ["waiting", "woken"];
869
- function treeEventKind(value) {
870
- return TREE_EVENT_KINDS.includes(value) ? value : null;
871
- }
872
- /**
873
- * Classify one parsed journal row. Every row lands in exactly one outcome — interpreted,
874
- * recognized-but-not-modeled, or unreadable — because a row that falls through silently is
875
- * how a run with events reads as a run with none.
876
- */
877
- function readJournalRow(row) {
878
- const kind = row.kind;
879
- if (typeof kind !== "string") return { outcome: "unreadable" };
880
- if (kind === "begin" && typeof row.root === "string") return {
881
- outcome: "ignored",
882
- dialect: "runtime-envelope",
883
- kind: "begin"
884
- };
885
- if (kind === "event") {
886
- const inner = row.event;
887
- if (typeof inner !== "object" || inner === null || Array.isArray(inner)) return { outcome: "unreadable" };
888
- const innerKind = inner.kind;
889
- if (typeof innerKind !== "string") return { outcome: "unreadable" };
890
- const tree = treeEventKind(innerKind);
891
- if (tree !== null) return {
892
- outcome: "event",
893
- dialect: "runtime-envelope",
894
- kind: tree,
895
- event: inner
896
- };
897
- return {
898
- outcome: "ignored",
899
- dialect: "runtime-envelope",
900
- kind: innerKind
901
- };
902
- }
903
- const tree = treeEventKind(kind);
904
- if (tree !== null) return {
905
- outcome: "event",
906
- dialect: "flat",
907
- kind: tree,
908
- event: row
909
- };
910
- if (UNMODELLED_EVENT_KINDS.includes(kind)) return {
911
- outcome: "ignored",
912
- dialect: "flat",
913
- kind
914
- };
915
- return { outcome: "unreadable" };
916
- }
917
- function summarizeDialect(seen) {
918
- if (seen.size === 0) return "none";
919
- if (seen.size > 1) return "mixed";
920
- return seen.has("runtime-envelope") ? "runtime-envelope" : "flat";
921
- }
922
- function parseSupervisorTree(src) {
923
- const parsedJournal = parseJsonlWithDiagnostics(src.journal);
924
- const events = parsedJournal.rows;
925
- const state = parseJson(src.state);
926
- const spawns = [];
927
- const closes = [];
928
- let brainIn = 0;
929
- let brainOut = 0;
930
- let brainCacheRead = 0;
931
- let brainCacheWrite = 0;
932
- let brainHasCache = false;
933
- let brainCacheBreakdownKnown = true;
934
- let brainTokensKnownCount = 0;
935
- let brainTokensUnknownCount = 0;
936
- let brainUsd = 0;
937
- let brainUsdKnownCount = 0;
938
- let brainUsdUnknownCount = 0;
939
- let meteredCount = 0;
940
- let rootId = null;
941
- let unreadableRows = 0;
942
- const ignoredByKind = /* @__PURE__ */ new Map();
943
- const dialectsSeen = /* @__PURE__ */ new Set();
944
- const meteredRows = [];
945
- for (const [sourceRow, row] of events.entries()) {
946
- const reading = readJournalRow(row);
947
- if (reading.outcome === "unreadable") {
948
- unreadableRows += 1;
949
- continue;
950
- }
951
- dialectsSeen.add(reading.dialect);
952
- if (reading.outcome === "ignored") {
953
- ignoredByKind.set(reading.kind, (ignoredByKind.get(reading.kind) ?? 0) + 1);
954
- continue;
955
- }
956
- const { kind, event: ev } = reading;
957
- const id = typeof ev.id === "string" ? ev.id : "";
958
- if (kind === "spawned") {
959
- const parent = typeof ev.parent === "string" && ev.parent.length > 0 ? ev.parent : null;
960
- const label = typeof ev.label === "string" ? ev.label : "";
961
- const invalidFields = [];
962
- if (id.length === 0) invalidFields.push("id");
963
- const parentOmittedForFirstRoot = ev.parent === void 0 && rootId === null;
964
- if (ev.parent !== null && !parentOmittedForFirstRoot && !(typeof ev.parent === "string" && ev.parent.length > 0)) invalidFields.push("parent");
965
- if (label.length === 0) invalidFields.push("label");
966
- if (ev.role !== void 0 && ev.role !== "supervisor" && ev.role !== "worker") invalidFields.push("role");
967
- if (ev.profileDigest !== void 0 && !(typeof ev.profileDigest === "string" && ev.profileDigest.length > 0)) invalidFields.push("profileDigest");
968
- if (ev.runtime !== void 0 && !(typeof ev.runtime === "string" && ev.runtime.length > 0)) invalidFields.push("runtime");
969
- const role = ev.role === "supervisor" || ev.role === "worker" ? ev.role : null;
970
- const valid = invalidFields.length === 0;
971
- if (valid && parent === null && rootId === null) rootId = id;
972
- spawns.push({
973
- sourceRow,
974
- id,
975
- parent,
976
- label,
977
- role,
978
- profileDigest: typeof ev.profileDigest === "string" && ev.profileDigest.length > 0 ? ev.profileDigest : null,
979
- runtime: typeof ev.runtime === "string" && ev.runtime.length > 0 ? ev.runtime : null,
980
- at: ms(ev.at),
981
- valid,
982
- invalidFields
983
- });
984
- } else if (kind === "settled") {
985
- const verdict = readVerdict(ev.verdict);
986
- closes.push({
987
- id,
988
- kind: "settled",
989
- status: typeof ev.status === "string" ? ev.status : null,
990
- verdict: verdict.label,
991
- valid: verdict.valid,
992
- score: verdict.score,
993
- rawVerdict: verdict.raw,
994
- reason: typeof ev.reason === "string" ? ev.reason : null,
995
- infra: typeof ev.infra === "boolean" ? ev.infra : null,
996
- at: ms(ev.at),
997
- spend: readSpend(ev.spent),
998
- hasSpend: asRecord(ev.spent).tokens !== void 0
999
- });
1000
- } else if (kind === "cancelled") closes.push({
1001
- id,
1002
- kind: "cancelled",
1003
- status: "cancelled",
1004
- verdict: typeof ev.reason === "string" ? ev.reason : null,
1005
- valid: null,
1006
- score: null,
1007
- rawVerdict: typeof ev.reason === "string" ? ev.reason : null,
1008
- reason: typeof ev.reason === "string" ? ev.reason : null,
1009
- infra: null,
1010
- at: ms(ev.at),
1011
- spend: {
1012
- tokens: {
1013
- input: 0,
1014
- output: 0,
1015
- cacheRead: 0,
1016
- cacheWrite: 0,
1017
- hasCache: false,
1018
- breakdownKnown: true
1019
- },
1020
- tokensKnown: true,
1021
- usd: 0,
1022
- usdKnown: true
1023
- },
1024
- hasSpend: false
1025
- });
1026
- else if (kind === "metered") meteredRows.push({
1027
- id,
1028
- spend: readSpend(ev.spend),
1029
- at: ms(ev.at)
1030
- });
1031
- else throw new Error(`unhandled journal event kind ${JSON.stringify(kind)}`);
1032
- }
1033
- for (const row of meteredRows) {
1034
- if (rootId === null || row.id !== rootId) continue;
1035
- if (row.spend.tokensKnown) {
1036
- brainIn += row.spend.tokens.input;
1037
- brainOut += row.spend.tokens.output;
1038
- brainCacheRead += row.spend.tokens.cacheRead;
1039
- brainCacheWrite += row.spend.tokens.cacheWrite;
1040
- brainHasCache = brainHasCache || row.spend.tokens.hasCache;
1041
- brainCacheBreakdownKnown = brainCacheBreakdownKnown && row.spend.tokens.breakdownKnown;
1042
- brainTokensKnownCount += 1;
1043
- } else brainTokensUnknownCount += 1;
1044
- if (row.spend.usdKnown) {
1045
- brainUsd += row.spend.usd;
1046
- brainUsdKnownCount += 1;
1047
- } else brainUsdUnknownCount += 1;
1048
- meteredCount += 1;
1049
- }
1050
- const workerSpawns = spawns.filter((s) => s.valid && s.id !== rootId);
1051
- const workerIds = new Set(workerSpawns.map((s) => s.id));
1052
- const workerCloses = closes.filter((c) => workerIds.has(c.id));
1053
- const workerLogs = /* @__PURE__ */ new Map();
1054
- const workerLogRows = [];
1055
- for (const [sourceIndex, w] of (src.workers ?? []).entries()) {
1056
- const facts = {
1057
- sourceIndex,
1058
- workerId: w.workerId ?? null,
1059
- label: w.label,
1060
- inboxCaptured: w.inbox !== null,
1061
- eventsCaptured: w.events !== null,
1062
- inboxInvalidRows: 0,
1063
- eventsInvalidRows: 0,
1064
- started: null,
1065
- finished: false,
1066
- finishedAt: null,
1067
- passed: null,
1068
- score: null,
1069
- finishedPatchBytes: null,
1070
- evidenceBytes: 0,
1071
- steersQueued: null,
1072
- steersDelivered: null,
1073
- steersQueuedUnavailable: null,
1074
- steersDeliveredUnavailable: null,
1075
- questions: 0,
1076
- steerRequests: [],
1077
- steerAcknowledgements: []
1078
- };
1079
- const parsedInbox = parseJsonlWithDiagnostics(w.inbox);
1080
- const parsedEvents = parseJsonlWithDiagnostics(w.events);
1081
- facts.inboxInvalidRows = parsedInbox.invalidRows;
1082
- facts.eventsInvalidRows = parsedEvents.invalidRows;
1083
- for (const [row, req] of parsedInbox.rows.entries()) {
1084
- if (typeof req.message !== "string" || req.message.trim().length === 0) continue;
1085
- facts.steerRequests.push({
1086
- requestId: typeof req.id === "string" && req.id.length > 0 ? req.id : null,
1087
- row
1088
- });
1089
- }
1090
- for (const [row, ev] of parsedEvents.rows.entries()) {
1091
- const kind = ev.kind;
1092
- if (kind === "message") {
1093
- if (ev.direction === "up") {
1094
- facts.questions += 1;
1095
- continue;
1096
- }
1097
- facts.steerAcknowledgements.push({
1098
- requestId: typeof ev.requestId === "string" && ev.requestId.length > 0 ? ev.requestId : null,
1099
- delivered: typeof ev.delivered === "boolean" ? ev.delivered : null,
1100
- row
1101
- });
1102
- } else if (kind === "started") facts.started = ms(ev.at);
1103
- else if (kind === "finished") {
1104
- facts.finished = true;
1105
- facts.finishedAt = ms(ev.at);
1106
- facts.passed = typeof ev.passed === "boolean" ? ev.passed : null;
1107
- facts.score = typeof ev.score === "number" && Number.isFinite(ev.score) ? ev.score : null;
1108
- facts.finishedPatchBytes = typeof ev.patchBytes === "number" ? ev.patchBytes : null;
1109
- facts.evidenceBytes = typeof ev.evidence === "string" ? ev.evidence.length : 0;
1110
- }
1111
- }
1112
- const requestsById = /* @__PURE__ */ new Map();
1113
- for (const request of facts.steerRequests) {
1114
- if (request.requestId === null) continue;
1115
- requestsById.set(request.requestId, (requestsById.get(request.requestId) ?? 0) + 1);
1116
- }
1117
- const acknowledgementsById = /* @__PURE__ */ new Map();
1118
- for (const acknowledgement of facts.steerAcknowledgements) {
1119
- if (acknowledgement.requestId === null) continue;
1120
- const matches = acknowledgementsById.get(acknowledgement.requestId) ?? [];
1121
- matches.push(acknowledgement);
1122
- acknowledgementsById.set(acknowledgement.requestId, matches);
1123
- }
1124
- const queueProblems = [];
1125
- if (!facts.inboxCaptured) queueProblems.push("inbox absent");
1126
- if (!facts.eventsCaptured) queueProblems.push("events absent");
1127
- if (facts.inboxInvalidRows > 0) queueProblems.push("inbox contains malformed rows");
1128
- if (facts.eventsInvalidRows > 0) queueProblems.push("events contain malformed rows");
1129
- if (facts.steerRequests.some((request) => request.requestId === null)) queueProblems.push("queued request id missing");
1130
- if ([...requestsById.values()].some((count) => count > 1)) queueProblems.push("queued request id duplicated");
1131
- if (facts.steerAcknowledgements.some((acknowledgement) => acknowledgement.requestId === null)) queueProblems.push("acknowledgement request id missing");
1132
- if ([...acknowledgementsById.keys()].some((id) => !requestsById.has(id))) queueProblems.push("acknowledgement has no queued request");
1133
- if (queueProblems.length === 0) facts.steersQueued = requestsById.size;
1134
- else facts.steersQueuedUnavailable = [...new Set(queueProblems)].join("; ");
1135
- const deliveryProblems = [...queueProblems];
1136
- if ([...acknowledgementsById.values()].some((rows) => rows.length > 1)) deliveryProblems.push("acknowledgement request id duplicated");
1137
- if (facts.steerAcknowledgements.some((acknowledgement) => acknowledgement.delivered === null)) deliveryProblems.push("acknowledgement delivery status missing");
1138
- if (deliveryProblems.length === 0) facts.steersDelivered = [...requestsById.keys()].filter((id) => {
1139
- const acknowledgement = acknowledgementsById.get(id);
1140
- return acknowledgement?.length === 1 && acknowledgement[0]?.delivered === true;
1141
- }).length;
1142
- else facts.steersDeliveredUnavailable = [...new Set(deliveryProblems)].join("; ");
1143
- workerLogRows.push(facts);
1144
- workerLogs.set(workerSourceKey(w), facts);
1145
- }
1146
- const startedAt = ms(state?.startedAt) ?? spawns[0]?.at ?? null;
1147
- const rootClose = rootId === null ? null : closes.find((close) => close.id === rootId);
1148
- const completedAt = ms(state?.completedAt) ?? rootClose?.at ?? null;
1149
- let firstEventAt = null;
1150
- let lastEventAt = null;
1151
- const widenEventSpan = (at) => {
1152
- if (at === null) return;
1153
- if (firstEventAt === null || at < firstEventAt) firstEventAt = at;
1154
- if (lastEventAt === null || at > lastEventAt) lastEventAt = at;
1155
- };
1156
- for (const spawn of spawns) widenEventSpan(spawn.at);
1157
- for (const close of closes) widenEventSpan(close.at);
1158
- for (const metered of meteredRows) widenEventSpan(metered.at);
1159
- return {
1160
- rootId,
1161
- spawns,
1162
- closes,
1163
- workerSpawns,
1164
- workerCloses,
1165
- brain: {
1166
- tokensIn: brainIn,
1167
- tokensOut: brainOut,
1168
- cacheRead: brainCacheRead,
1169
- cacheWrite: brainCacheWrite,
1170
- hasCache: brainHasCache,
1171
- cacheBreakdownKnown: brainCacheBreakdownKnown,
1172
- tokensKnownCount: brainTokensKnownCount,
1173
- tokensUnknownCount: brainTokensUnknownCount,
1174
- usd: brainUsd,
1175
- usdKnownCount: brainUsdKnownCount,
1176
- usdUnknownCount: brainUsdUnknownCount,
1177
- meteredCount
1178
- },
1179
- workerLogs,
1180
- workerLogRows,
1181
- journalRows: events.length + parsedJournal.invalidRows,
1182
- journalInvalidRows: parsedJournal.invalidRows + unreadableRows,
1183
- journalMalformedJsonRows: parsedJournal.invalidRows,
1184
- journalIgnoredRowsByKind: Object.fromEntries(ignoredByKind),
1185
- journalMeteredRows: meteredRows.length,
1186
- journalDialect: summarizeDialect(dialectsSeen),
1187
- state,
1188
- startedAt,
1189
- completedAt,
1190
- firstEventAt,
1191
- lastEventAt
1192
- };
1193
- }
1194
- //#endregion
1195
766
  //#region src/supervisor-run/rollout-nodes.ts
1196
767
  /**
1197
768
  * The supervision tree as `tangle.rollout.v1` rows.
@@ -1260,6 +831,11 @@ function supervisorRunRolloutLinesFromFacts(src, tree, opts = {}) {
1260
831
  const result = parseJson(src.result);
1261
832
  const judge = parseJson(src.judge);
1262
833
  const stateResult = asRecord(state?.result);
834
+ const terminal = readTerminalRecord({
835
+ state,
836
+ result,
837
+ failure: src.failure === void 0 ? void 0 : parseJson(src.failure)
838
+ });
1263
839
  const rootId = tree.rootId;
1264
840
  const runId = opts.runId ?? rootId ?? src.runRef;
1265
841
  const suite = opts.suite ?? "supervisor-run";
@@ -1314,7 +890,7 @@ function supervisorRunRolloutLinesFromFacts(src, tree, opts = {}) {
1314
890
  verdict: judge ?? null,
1315
891
  metrics: {
1316
892
  arm: src.arm,
1317
- sup_status: typeof state?.status === "string" ? state.status : null,
893
+ sup_status: isUnavailable(terminal.supStatus) ? null : terminal.supStatus,
1318
894
  sup_verdict: typeof state?.verdict === "string" ? state.verdict : null,
1319
895
  delivered: typeof stateResult.delivered === "boolean" ? stateResult.delivered : null,
1320
896
  verify_pass: typeof result?.verify_pass === "boolean" ? result.verify_pass : null,
@@ -1325,9 +901,9 @@ function supervisorRunRolloutLinesFromFacts(src, tree, opts = {}) {
1325
901
  runtime: rootSpawn?.runtime ?? null,
1326
902
  profile_digest: rootSpawn?.profileDigest ?? null
1327
903
  },
1328
- is_completed: state?.status === "completed",
904
+ is_completed: terminal.completed === true,
1329
905
  is_truncated: false,
1330
- error: result?.kind === "interrupted" && typeof result.reason === "string" ? result.reason : null,
906
+ error: terminal.completed !== false ? null : !isUnavailable(terminal.supReason) && terminal.supReason !== null ? terminal.supReason : !isUnavailable(terminal.failure) && terminal.failure !== null ? terminal.failure.message ?? terminal.failure.name : null,
1331
907
  realness_gated: false
1332
908
  },
1333
909
  cost: {
@@ -1513,6 +1089,6 @@ function analyzeSupervisorRunIntegrity(input, options = {}) {
1513
1089
  };
1514
1090
  }
1515
1091
  //#endregion
1516
- export { parseJsonl as a, SUPERVISOR_RUN_INTEGRITY_SCHEMA as c, parseJson as i, supervisorRunRolloutLines as n, parseSupervisorTree as o, asRecord as r, workerSourceKey as s, analyzeSupervisorRunIntegrity as t };
1092
+ export { supervisorRunRolloutLines as n, SUPERVISOR_RUN_INTEGRITY_SCHEMA as r, analyzeSupervisorRunIntegrity as t };
1517
1093
 
1518
- //# sourceMappingURL=integrity-BWywb34E.js.map
1094
+ //# sourceMappingURL=integrity-DsHWCebQ.js.map