@peasant-labs/fairtrade 0.0.59 → 0.0.61

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.
@@ -527,7 +527,10 @@ function _e(e, t, n) {
527
527
  return a > 0 && o.push(`${a} ${a === 1 ? "file" : "files"}`), (e.insertions > 0 || e.deletions > 0) && o.push(`+${e.insertions} −${e.deletions}`), o.length && (i.stat = o.join(", ")), i;
528
528
  }
529
529
  function W(e) {
530
- return y(e).map((t, n) => _e(t, n, e));
530
+ return y(e).map((e, t) => ({
531
+ tg: e,
532
+ i: t
533
+ })).filter(({ tg: t }) => e[t.startIndex]?.role !== "system").map(({ tg: t, i: n }) => _e(t, n, e));
531
534
  }
532
535
  function G(e, t = {}) {
533
536
  let n = A(e), r = T(e).map((t) => ge(t, e)), i = W(e), a = H(t.scorecard, t.medians), o = {};
@@ -762,21 +765,15 @@ function Ue(e) {
762
765
  }
763
766
  });
764
767
  }
765
- var We = /^(custom-title|agent name|session title): \S/, Ge = /* @__PURE__ */ new Set(["agent renamed", "session title set"]);
766
- function Ke(e, t) {
767
- if (t !== "claude-code" || e.role !== "system" || (e.depth ?? 0) !== 0 || (e.toolCalls?.length ?? 0) > 0) return !1;
768
- let n = (e.content ?? "").trim();
769
- return n === "" || n.includes("\n") ? !1 : We.test(n) || Ge.has(n);
770
- }
771
- function qe(t) {
768
+ function We(t) {
772
769
  if (t.timestamp === void 0 || t.timestamp === null || e(t.timestamp)) return t;
773
770
  let { timestamp: n, ...r } = t;
774
771
  return r;
775
772
  }
776
- function Je(e) {
773
+ function Ge(e) {
777
774
  Ue(e);
778
775
  let t = e.filter((e) => {
779
- if (Z(e)) return !0;
776
+ if (Z(e) || e.controlKind) return !0;
780
777
  let t = !!e.content?.trim(), n = (e.toolCalls?.length ?? 0) > 0;
781
778
  return !(!t && !n || e.role === "system" && !n && (!e.content || e.content.trim().length < 8));
782
779
  }), n = [];
@@ -791,15 +788,15 @@ function Je(e) {
791
788
  }
792
789
  return n;
793
790
  }
794
- function Ye(e) {
791
+ function Ke(e) {
795
792
  if (e.role !== "assistant") return;
796
793
  let t = i.safeParse(e.observedModel);
797
794
  return t.success ? t.data : void 0;
798
795
  }
799
- function Xe(e, t) {
796
+ function qe(e, t) {
800
797
  let n = /* @__PURE__ */ new Map(), r = typeof t == "string" && t.length > 0 ? t : void 0;
801
798
  for (let t of e) {
802
- let e = t.depth ?? 0, i = Ye(t);
799
+ let e = t.depth ?? 0, i = Ke(t);
803
800
  if (t.role !== "assistant") {
804
801
  n.set(t.index, {});
805
802
  continue;
@@ -815,12 +812,12 @@ function Xe(e, t) {
815
812
  }
816
813
  return n;
817
814
  }
818
- function Ze(e) {
815
+ function Je(e) {
819
816
  if (e.toolKind) return e.toolKind;
820
817
  let t = e.name.toLowerCase();
821
818
  return t === "read" || t === "notebookread" ? "read" : t === "edit" || t === "multiedit" || t === "notebookedit" || t === "write" ? "edit" : t === "bash" || t === "runcommand" || t === "run_command" || t === "shell" ? "execute" : t === "grep" || t === "glob" || t === "globsearch" || t === "websearch" || t === "web_search" ? "search" : t === "webfetch" || t === "web_fetch" || t === "fetch" || t === "readwebsite" ? "fetch" : t === "delete" || t === "remove" ? "delete" : t === "move" || t === "rename" ? "move" : "other";
822
819
  }
823
- function Qe(e) {
820
+ function Ye(e) {
824
821
  let t = e.name.toLowerCase();
825
822
  if (t === "read" || t === "notebookread") return "read";
826
823
  if (t === "edit" || t === "multiedit" || t === "notebookedit" || t === "write") return "edits";
@@ -837,7 +834,7 @@ function Qe(e) {
837
834
  default: return "other";
838
835
  }
839
836
  }
840
- function $e(e) {
837
+ function Xe(e) {
841
838
  let t = ze(c(e.arguments)), n = e.filePath ?? (t && typeof t.file_path == "string" ? t.file_path : void 0);
842
839
  if (n) return n;
843
840
  if (!t) return Y(e.arguments, 80);
@@ -855,7 +852,7 @@ function $e(e) {
855
852
  let r = typeof t.subagent_type == "string" ? t.subagent_type : typeof t.subagent == "string" ? t.subagent : typeof t.agent == "string" ? t.agent : void 0;
856
853
  return r && typeof t.description == "string" ? `${r}, ${t.description}` : typeof t.description == "string" ? Y(t.description, 100) : typeof t.subject == "string" ? Y(t.subject, 100) : typeof t.prompt == "string" ? Y(t.prompt, 100) : Y(e.arguments, 80);
857
854
  }
858
- function et(e) {
855
+ function Ze(e) {
859
856
  let t = _(e);
860
857
  if (t) return {
861
858
  hunks: t.spans.map((e) => ({ lines: e })),
@@ -863,13 +860,13 @@ function et(e) {
863
860
  dels: t.dels
864
861
  };
865
862
  }
866
- function tt(e) {
863
+ function Qe(e) {
867
864
  let t = {
868
865
  id: e.id,
869
866
  name: e.name,
870
- kind: Ze(e),
871
- group: Qe(e),
872
- preview: $e(e)
867
+ kind: Je(e),
868
+ group: Ye(e),
869
+ preview: Xe(e)
873
870
  };
874
871
  e.namespace !== void 0 && (t.namespace = e.namespace);
875
872
  let n = c(e.arguments);
@@ -878,10 +875,10 @@ function tt(e) {
878
875
  i !== void 0 && (t.output = i);
879
876
  let a = f(e);
880
877
  a && (t.filePath = a), e.durationMs != null && (t.durationMs = e.durationMs), e.exitCode != null && (t.exitCode = e.exitCode), e.isError && (t.isError = !0), e.usage && (t.usage = e.usage), e.callEntryRef && (t.callEntryRef = e.callEntryRef), e.resultEntryRef && (t.resultEntryRef = e.resultEntryRef), e.callProvenance && (t.callProvenance = e.callProvenance), e.resultProvenance && (t.resultProvenance = e.resultProvenance), e.callEntryRef && !e.resultEntryRef && (t.pending = !0);
881
- let o = et(e);
878
+ let o = Ze(e);
882
879
  return o && (t.diff = o.hunks, t.adds = o.adds, t.dels = o.dels), t;
883
880
  }
884
- function nt(e) {
881
+ function $e(e) {
885
882
  let t = e.hash, n = e.message.split("\n")[0], r = {
886
883
  hash: t,
887
884
  shortHash: t.slice(0, 7),
@@ -891,7 +888,7 @@ function nt(e) {
891
888
  let i = "commitTime" in e ? Number(e.commitTime) : Date.parse(e.timestamp);
892
889
  return Number.isFinite(i) && (r.commitTime = i), "session" in e && e.session === !0 && (r.session = !0), "insertions" in e && (r.adds = e.insertions), "deletions" in e && (r.dels = e.deletions), "filesChanged" in e && (r.files = e.filesChanged), r;
893
890
  }
894
- function rt(e, t) {
891
+ function et(e, t) {
895
892
  let n = t.map((e) => ({
896
893
  index: e.index,
897
894
  ms: e.timestamp ? Date.parse(e.timestamp) : NaN
@@ -904,13 +901,13 @@ function rt(e, t) {
904
901
  t.turn = e;
905
902
  }
906
903
  }
907
- function it(e) {
904
+ function tt(e) {
908
905
  let t = e.gitContext, n = e.gitBranch ?? t?.branch ?? void 0, r = e.gitRemote ?? t?.remote ?? void 0, i = t?.user, a = Array.isArray(t?.commits) ? t.commits : [], o = [], s = 0, c = 0, l = 0;
909
- for (let e of a) o.push(nt(e)), "filesChanged" in e && (s += e.filesChanged), "insertions" in e && (c += e.insertions), "deletions" in e && (l += e.deletions);
906
+ for (let e of a) o.push($e(e)), "filesChanged" in e && (s += e.filesChanged), "insertions" in e && (c += e.insertions), "deletions" in e && (l += e.deletions);
910
907
  let u = {};
911
908
  return n && (u.branch = n), r && (u.remote = r), i && (u.author = i), o.length && (u.commits = o), s > 0 && (u.filesChanged = s), c > 0 && (u.insertions = c), l > 0 && (u.deletions = l), Object.keys(u).length > 0 ? u : void 0;
912
909
  }
913
- function at(t, n) {
910
+ function nt(t, n) {
914
911
  let r = {
915
912
  id: t.id,
916
913
  harness: t.harness,
@@ -923,11 +920,11 @@ function at(t, n) {
923
920
  turnCount: t.turnCount,
924
921
  toolCallCount: t.toolCallCount
925
922
  };
926
- t.project && (r.project = t.project), t.model && (r.model = t.model), t.inputSubmissionCount !== void 0 && (r.inputSubmissionCount = t.inputSubmissionCount), t.purpose && (r.purpose = t.purpose), t.rootSessionId && (r.rootSessionId = t.rootSessionId), mt(t) && (r.hasNormalizedEvidence = !0);
923
+ t.project && (r.project = t.project), t.model && (r.model = t.model), t.inputSubmissionCount !== void 0 && (r.inputSubmissionCount = t.inputSubmissionCount), t.purpose && (r.purpose = t.purpose), t.rootSessionId && (r.rootSessionId = t.rootSessionId), dt(t) && (r.hasNormalizedEvidence = !0);
927
924
  let i = t.workingDirectory ?? t.gitContext?.workingDirectory;
928
925
  return i && (r.workingDirectory = i), t.outcome && (r.outcome = t.outcome), t.scorecard !== void 0 && (r.scorecard = t.scorecard), n && (r.git = n), r;
929
926
  }
930
- function ot(e) {
927
+ function rt(e) {
931
928
  let t = [];
932
929
  for (let n of e) {
933
930
  if (n.targetEntryIndex == null) continue;
@@ -941,7 +938,7 @@ function ot(e) {
941
938
  }
942
939
  return t;
943
940
  }
944
- function st(e, t) {
941
+ function it(e, t) {
945
942
  let n = {};
946
943
  for (let t of e) {
947
944
  let e = n[t.turn] ?? [];
@@ -953,7 +950,7 @@ function st(e, t) {
953
950
  }
954
951
  return n;
955
952
  }
956
- function ct(e) {
953
+ function at(e) {
957
954
  let t = [];
958
955
  for (let n of e) for (let e of n.toolCalls) {
959
956
  if (!e.diff) continue;
@@ -970,7 +967,7 @@ function ct(e) {
970
967
  }
971
968
  return t;
972
969
  }
973
- function lt(e) {
970
+ function ot(e) {
974
971
  let t = /* @__PURE__ */ new Map();
975
972
  for (let n of e) for (let e of n.toolCalls) {
976
973
  let r = e.filePath;
@@ -995,7 +992,7 @@ function lt(e) {
995
992
  for (let e of n) e.edited = e.writes + e.edits > 0;
996
993
  return n;
997
994
  }
998
- function ut(e, t, n) {
995
+ function st(e, t, n) {
999
996
  let r = [], i = e.find((e) => e.role === "user" && e.content.trim() !== "");
1000
997
  i && r.push({
1001
998
  id: "hl-request",
@@ -1053,13 +1050,13 @@ function ut(e, t, n) {
1053
1050
  }
1054
1051
  return r;
1055
1052
  }
1056
- function dt(e) {
1053
+ function ct(e) {
1057
1054
  if (e === "error") return "errors";
1058
1055
  if (e === "retry") return "retries";
1059
1056
  if (e === "revert") return "re-edit";
1060
1057
  if (e === "subagent") return "subagent";
1061
1058
  }
1062
- function ft(e, t) {
1059
+ function lt(e, t) {
1063
1060
  let n = {
1064
1061
  edits: 0,
1065
1062
  bash: 0,
@@ -1074,7 +1071,7 @@ function ft(e, t) {
1074
1071
  for (let e of Object.keys(t)) {
1075
1072
  let n = t[e] ?? [], i = /* @__PURE__ */ new Set();
1076
1073
  for (let e of n) {
1077
- let t = dt(e.kind);
1074
+ let t = ct(e.kind);
1078
1075
  t && i.add(t);
1079
1076
  }
1080
1077
  for (let e of i) r[e] = (r[e] ?? 0) + 1;
@@ -1087,8 +1084,8 @@ function ft(e, t) {
1087
1084
  totalTurns: e.length
1088
1085
  };
1089
1086
  }
1090
- function pt(e, t, r, i) {
1091
- let a = mt(e);
1087
+ function ut(e, t, r, i) {
1088
+ let a = dt(e);
1092
1089
  if (a) try {
1093
1090
  e = {
1094
1091
  ...n(e),
@@ -1097,20 +1094,20 @@ function pt(e, t, r, i) {
1097
1094
  } catch (e) {
1098
1095
  throw Object.assign(/* @__PURE__ */ TypeError(`Fairtrade adaptTranscript refused the durable payload during main/earlier evidence validation: ${e instanceof Error ? e.message : "canonical validation failed"}. No transcript was cooked. Correct the producer using the canonical schema and retry.`), { cause: e });
1099
1096
  }
1100
- let o = e.turns ?? [], { turns: s, toolCallsById: c, analytics: l, annotationsByTurn: u, filteredTurns: d } = $(e, o, e.nativeMetadata, "main", t, r, i?.visibleTurnIndices), f = it(e);
1101
- f?.commits && rt(f.commits, s);
1097
+ let o = e.turns ?? [], { turns: s, toolCallsById: c, analytics: l, annotationsByTurn: u, filteredTurns: d } = $(e, o, e.nativeMetadata, "main", t, r, i?.visibleTurnIndices), f = tt(e);
1098
+ f?.commits && et(f.commits, s);
1102
1099
  let p = l.phases ?? [], m = {
1103
- session: at(e, f),
1100
+ session: nt(e, f),
1104
1101
  turns: s,
1105
1102
  toolCallsById: c,
1106
- diffs: ct(s),
1107
- files: lt(s),
1103
+ diffs: at(s),
1104
+ files: ot(s),
1108
1105
  tasks: Ve(l.taskGroups ?? W(d), s),
1109
- highlights: ut(s, p, f),
1110
- filterIndex: ft(s, u),
1106
+ highlights: st(s, p, f),
1107
+ filterIndex: lt(s, u),
1111
1108
  analytics: l
1112
1109
  };
1113
- return e.nativeMetadata && (m.nativeMetadata = e.nativeMetadata), a && (m.usageScopes = be(o)), m.relationships = ht(e.relationships ?? [], i?.relationshipNavigation), m.earlierHistory = (e.earlierHistory ?? []).map((t, n) => {
1110
+ return e.nativeMetadata && (m.nativeMetadata = e.nativeMetadata), a && (m.usageScopes = be(o)), m.relationships = ft(e.relationships ?? [], i?.relationshipNavigation), m.earlierHistory = (e.earlierHistory ?? []).map((t, n) => {
1114
1111
  let r = `earlier-${n}`, i = $(e, t.turns, t.nativeMetadata, r);
1115
1112
  return {
1116
1113
  id: r,
@@ -1122,7 +1119,7 @@ function pt(e, t, r, i) {
1122
1119
  };
1123
1120
  }), m;
1124
1121
  }
1125
- function mt(e) {
1122
+ function dt(e) {
1126
1123
  return e.harness === "pi" || [
1127
1124
  "nativeMetadata",
1128
1125
  "inputSubmissionCount",
@@ -1132,7 +1129,7 @@ function mt(e) {
1132
1129
  "earlierHistory"
1133
1130
  ].some((t) => X(e, t)) || !!e.turns?.some(He);
1134
1131
  }
1135
- function ht(e, t) {
1132
+ function ft(e, t) {
1136
1133
  let n;
1137
1134
  try {
1138
1135
  n = a.array().parse(t === void 0 ? [] : t);
@@ -1166,12 +1163,12 @@ function $(e, t, n, r, i, a, o) {
1166
1163
  s.set(e.index, (s.get(e.index) ?? 0) + 1);
1167
1164
  for (let t of e.toolCalls ?? []) t.id && c.set(t.id, (c.get(t.id) ?? 0) + 1);
1168
1165
  }
1169
- let l = Xe(t, e.model), u = /* @__PURE__ */ new Map();
1166
+ let l = qe(t, e.model), u = /* @__PURE__ */ new Map();
1170
1167
  r === "main" && t.forEach((e, t) => u.set(e, t));
1171
- let d = (e.harness === "pi" ? t : Je(t)).filter((t) => !Ke(t, e.harness)).map((e) => {
1172
- let t = qe(e), n = u.get(e);
1168
+ let d = (e.harness === "pi" ? t : Ge(t)).map((e) => {
1169
+ let t = We(e), n = u.get(e);
1173
1170
  return t !== e && n !== void 0 && u.set(t, n), t;
1174
- }), f = o === void 0 ? null : new Set(o), p = f === null ? d : d.filter((e) => f.has(e.index)), m = x(p), h = e.harness, g = a ?? G(p, { scorecard: e.scorecard ?? void 0 }), _ = st(g.patternAnnotations ?? [], ot(i ?? [])), v = -1;
1171
+ }), f = o === void 0 ? null : new Set(o), p = f === null ? d : d.filter((e) => f.has(e.index)), m = x(p), h = e.harness, g = a ?? G(p, { scorecard: e.scorecard ?? void 0 }), _ = it(g.patternAnnotations ?? [], rt(i ?? [])), v = -1;
1175
1172
  for (let e = 0; e < p.length; e++) {
1176
1173
  let t = p[e];
1177
1174
  t.role === "assistant" && (t.depth ?? 0) === 0 && t.content?.trim() && (v = e);
@@ -1179,7 +1176,7 @@ function $(e, t, n, r, i, a, o) {
1179
1176
  let y = /* @__PURE__ */ new Map(), b = [], S = new Map(d.map((e, t) => [e, t]));
1180
1177
  for (let e = 0; e < p.length; e++) {
1181
1178
  let t = p[e], i = (t.toolCalls ?? []).map((e, t) => ({
1182
- ...tt(e),
1179
+ ...Qe(e),
1183
1180
  sourceIndex: t,
1184
1181
  sourceIdUnique: !e.id || c.get(e.id) === 1
1185
1182
  }));
@@ -1221,7 +1218,7 @@ function $(e, t, n, r, i, a, o) {
1221
1218
  toolCalls: i,
1222
1219
  annotations: _[t.index] ?? []
1223
1220
  };
1224
- u.has(t) && (x.sourcePosition = u.get(t)), f === 0 && t.role === "assistant" && (x.provider = h), t.agentName && (x.agentName = t.agentName), o && (x.thinking = o);
1221
+ u.has(t) && (x.sourcePosition = u.get(t)), f === 0 && t.role === "assistant" && (x.provider = h), t.agentName && (x.agentName = t.agentName), t.controlKind && (x.controlKind = t.controlKind, x.isControl = !0), o && (x.thinking = o);
1225
1222
  let C = Be(t.role, a, h);
1226
1223
  C !== void 0 && (x.displayContent = C), t.usage && (x.usage = t.usage), t.sourceEntryRef && (x.sourceEntryRef = t.sourceEntryRef), t.provenance && (x.provenance = t.provenance), t.entryType && (x.entryType = t.entryType), t.stopReason !== void 0 && t.stopReason !== null && (x.stopReason = t.stopReason), g && (x.isError = !0), e === v && (x.isFinal = !0), !t.usage && (t.tokensIn != null || t.tokensOut != null) && (x.tokens = {
1227
1224
  in: t.tokensIn ?? 0,
@@ -1239,4 +1236,4 @@ function $(e, t, n, r, i, a, o) {
1239
1236
  };
1240
1237
  }
1241
1238
  //#endregion
1242
- export { h as S, W as _, ke as a, A as b, Ee as c, K as d, T as f, he as g, G as h, Te as i, q as l, C as m, Ke as n, Oe as o, H as p, Je as r, De as s, pt as t, ve as u, y as v, E as x, x as y };
1239
+ export { y as _, Oe as a, E as b, q as c, T as d, H as f, W as g, he as h, ke as i, ve as l, G as m, Ge as n, De as o, C as p, Te as r, Ee as s, ut as t, K as u, x as v, h as x, A as y };
@@ -0,0 +1,23 @@
1
+ //#region src/ui/closed-value.js
2
+ function e(e, r) {
3
+ t(e), n(r);
4
+ let i = String(e);
5
+ return Object.freeze({
6
+ wire: e,
7
+ label: r,
8
+ String: () => i,
9
+ toString: () => i,
10
+ toJSON: () => e
11
+ });
12
+ }
13
+ function t(e) {
14
+ if (!(typeof e == "string" && e.length > 0) && !(typeof e == "number" && Number.isFinite(e))) throw TypeError(`closed(wire, label) failed in src/ui/closed-value.js: wire must be a non-empty string or a finite number, received ${r(e)}. A closed value's wire is the exact value persisted and compared, so it must be a primitive with a stable value (for example 'project' or 25). Pass the primitive at the member definition.`);
15
+ }
16
+ function n(e) {
17
+ if (!(typeof e == "string" && e.length > 0)) throw TypeError(`closed(wire, label) failed in src/ui/closed-value.js: label must be a non-empty string, received ${r(e)}. The label is the human-readable text shown for the member, so every member needs its own (for example '25' for the numeric wire 25). Pass the label at the member definition.`);
18
+ }
19
+ function r(e) {
20
+ return typeof e == "string" ? JSON.stringify(e) : typeof e == "number" ? String(e) : e === null ? "null" : Array.isArray(e) ? "an array" : `a ${typeof e}`;
21
+ }
22
+ //#endregion
23
+ export { e as closed };