@peasant-labs/fairtrade 0.0.50 → 0.0.51

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.
@@ -186,17 +186,17 @@ function C(e) {
186
186
  };
187
187
  });
188
188
  }
189
- var ee = /* @__PURE__ */ new Set([
189
+ var w = /* @__PURE__ */ new Set([
190
190
  "Task",
191
191
  "EnterWorktree",
192
192
  "SendMessage",
193
193
  "TeamCreate"
194
- ]), te = /* @__PURE__ */ new Set([
194
+ ]), ee = /* @__PURE__ */ new Set([
195
195
  "Write",
196
196
  "Edit",
197
197
  "NotebookEdit"
198
198
  ]);
199
- function w(e) {
199
+ function T(e) {
200
200
  let t = [], n = [], r = /* @__PURE__ */ new Map();
201
201
  for (let i = 0; i < e.length; i++) {
202
202
  let a = e[i];
@@ -206,12 +206,12 @@ function w(e) {
206
206
  type: "error",
207
207
  label: `${e.name} failed`,
208
208
  severity: "error"
209
- }), ee.has(e.name) && t.push({
209
+ }), w.has(e.name) && t.push({
210
210
  turnIndex: i,
211
211
  type: "subagent",
212
212
  label: `Subagent: ${e.name}`,
213
213
  severity: "info"
214
- }), te.has(e.name)) {
214
+ }), ee.has(e.name)) {
215
215
  let t = f(e);
216
216
  if (t) {
217
217
  let e = r.get(t) ?? [];
@@ -240,7 +240,7 @@ function w(e) {
240
240
  }
241
241
  return t.sort((e, t) => e.turnIndex - t.turnIndex);
242
242
  }
243
- var ne = {
243
+ var te = {
244
244
  planning: "Planning",
245
245
  exploration: "Exploration",
246
246
  implementation: "Implementation",
@@ -252,20 +252,20 @@ var ne = {
252
252
  recovery: "Recovery",
253
253
  abandonment: "Abandonment"
254
254
  };
255
- function T(e) {
256
- return ne[e] ?? String(e);
255
+ function E(e) {
256
+ return te[e] ?? String(e);
257
257
  }
258
- var E = /* @__PURE__ */ new Set([
258
+ var D = /* @__PURE__ */ new Set([
259
259
  "Read",
260
260
  "Glob",
261
261
  "Grep",
262
262
  "WebSearch",
263
263
  "WebFetch"
264
- ]), D = /* @__PURE__ */ new Set([
264
+ ]), O = /* @__PURE__ */ new Set([
265
265
  "Write",
266
266
  "Edit",
267
267
  "NotebookEdit"
268
- ]), re = [
268
+ ]), ne = [
269
269
  /\btest\b/i,
270
270
  /\bjest\b/i,
271
271
  /\bpytest\b/i,
@@ -278,21 +278,21 @@ var E = /* @__PURE__ */ new Set([
278
278
  /\bmocha\b/i,
279
279
  /\brspec\b/i
280
280
  ];
281
- function ie(e, t) {
281
+ function re(e, t) {
282
282
  return e.toolCalls?.some((e) => t.has(e.name)) ?? !1;
283
283
  }
284
- function ae(e, t) {
284
+ function ie(e, t) {
285
285
  return e.toolCalls?.length ? e.toolCalls.every((e) => t.has(e.name)) : !1;
286
286
  }
287
- function O(e) {
287
+ function k(e) {
288
288
  for (let t of e.toolCalls ?? []) if (t.isError || t.exitCode !== void 0 && t.exitCode !== null && t.exitCode !== 0) return !0;
289
289
  return !1;
290
290
  }
291
- function oe(e) {
292
- for (let t of e.toolCalls ?? []) if (t.name === "Bash" && re.some((e) => e.test(t.arguments))) return !0;
291
+ function ae(e) {
292
+ for (let t of e.toolCalls ?? []) if (t.name === "Bash" && ne.some((e) => e.test(t.arguments))) return !0;
293
293
  return !1;
294
294
  }
295
- function se(e) {
295
+ function oe(e) {
296
296
  let t = [], n = [], r = -1;
297
297
  for (let i = 0; i < e.length; i++) {
298
298
  let a = e[i];
@@ -302,7 +302,7 @@ function se(e) {
302
302
  }
303
303
  if (a.toolCalls?.length) {
304
304
  r < 0 && (r = i);
305
- for (let e of a.toolCalls) n.push(e.name), (e.isError || e.exitCode !== void 0 && e.exitCode !== null && e.exitCode !== 0) && n.length > 0 && (n.some((e) => D.has(e) || e === "Bash") && t.push({
305
+ for (let e of a.toolCalls) n.push(e.name), (e.isError || e.exitCode !== void 0 && e.exitCode !== null && e.exitCode !== 0) && n.length > 0 && (n.some((e) => O.has(e) || e === "Bash") && t.push({
306
306
  tools: [...n],
307
307
  turnRange: [r, i]
308
308
  }), n = [], r = -1);
@@ -310,20 +310,20 @@ function se(e) {
310
310
  }
311
311
  return t;
312
312
  }
313
- function ce(e, t) {
313
+ function se(e, t) {
314
314
  let n = new Set(e), r = new Set(t), i = [...n].filter((e) => r.has(e)).length, a = (/* @__PURE__ */ new Set([...n, ...r])).size;
315
315
  return a > 0 ? i / a : 0;
316
316
  }
317
- function le(e) {
318
- let t = se(e), n = [], r = 0;
317
+ function ce(e) {
318
+ let t = oe(e), n = [], r = 0;
319
319
  for (; r < t.length;) {
320
320
  let e = r + 1;
321
- for (; e < t.length && ce(t[r].tools, t[e].tools) >= .5;) e++;
321
+ for (; e < t.length && se(t[r].tools, t[e].tools) >= .5;) e++;
322
322
  e - r >= 2 && n.push([t[r].turnRange[0], t[e - 1].turnRange[1]]), r = e;
323
323
  }
324
324
  return n;
325
325
  }
326
- var ue = [
326
+ var le = [
327
327
  /\bi already said\b/i,
328
328
  /\bi told you\b/i,
329
329
  /\bno,?\s+not that\b/i,
@@ -331,18 +331,18 @@ var ue = [
331
331
  /\bnot what i asked\b/i,
332
332
  /\bwrong,?\s+i\b/i,
333
333
  /\bplease (re-?read|read again)\b/i
334
- ], de = /\b(let'?s move on|forget it|different approach|never mind)\b/i;
335
- function fe(e, t, n, r, i) {
334
+ ], ue = /\b(let'?s move on|forget it|different approach|never mind)\b/i;
335
+ function de(e, t, n, r, i) {
336
336
  for (let [e, n] of i) if (t >= e && t <= n) return "retry-loop";
337
- return e.role === "user" ? ue.some((t) => t.test(e.content)) ? "user-correction" : n ?? "planning" : O(e) ? "error" : oe(e) ? "testing" : r > 0 && ae(e, E) ? "debug" : ie(e, D) ? n === "retry-loop" || n === "user-correction" ? "recovery" : "implementation" : ae(e, E) && r === 0 ? "exploration" : e.role === "assistant" && !e.toolCalls?.length && e.content.length > 100 ? "planning" : n ?? "planning";
337
+ return e.role === "user" ? le.some((t) => t.test(e.content)) ? "user-correction" : n ?? "planning" : k(e) ? "error" : ae(e) ? "testing" : r > 0 && ie(e, D) ? "debug" : re(e, O) ? n === "retry-loop" || n === "user-correction" ? "recovery" : "implementation" : ie(e, D) && r === 0 ? "exploration" : e.role === "assistant" && !e.toolCalls?.length && e.content.length > 100 ? "planning" : n ?? "planning";
338
338
  }
339
- var pe = /* @__PURE__ */ new Set([
339
+ var fe = /* @__PURE__ */ new Set([
340
340
  "error",
341
341
  "user-correction",
342
342
  "retry-loop",
343
343
  "abandonment"
344
344
  ]);
345
- function me(e) {
345
+ function pe(e) {
346
346
  if (e.length <= 1) return e;
347
347
  let t = [];
348
348
  for (let n = 0; n < e.length; n++) {
@@ -351,7 +351,7 @@ function me(e) {
351
351
  a.endTurn = r.endTurn;
352
352
  continue;
353
353
  }
354
- if (i < 3 && !pe.has(r.type) && a) {
354
+ if (i < 3 && !fe.has(r.type) && a) {
355
355
  a.endTurn = r.endTurn;
356
356
  let e = a.badges.find((e) => e.type === r.type);
357
357
  e ? e.count += i : a.badges.push({
@@ -379,15 +379,15 @@ function me(e) {
379
379
  }
380
380
  return t;
381
381
  }
382
- function he(e) {
382
+ function me(e) {
383
383
  if (e.length === 0) return [];
384
- let t = le(e), n = [];
384
+ let t = ce(e), n = [];
385
385
  for (let r = 0; r < e.length; r++) {
386
386
  let i = 0;
387
- for (let t = Math.max(0, r - 3); t < r; t++) O(e[t]) && i++;
387
+ for (let t = Math.max(0, r - 3); t < r; t++) k(e[t]) && i++;
388
388
  let a = n.length > 0 ? n[n.length - 1].type : null;
389
389
  n.push({
390
- type: fe(e[r], r, a, i, t),
390
+ type: de(e[r], r, a, i, t),
391
391
  turn: r
392
392
  });
393
393
  }
@@ -399,8 +399,8 @@ function he(e) {
399
399
  badges: []
400
400
  });
401
401
  if (i && r.push(i), r.length > 0) {
402
- let t = e[e.length - 1], n = r[r.length - 1], i = O(t) && t.role === "assistant", a = t.role === "user" && de.test(t.content), o = !e.slice(Math.floor(e.length * .8)).some((e) => ie(e, D));
403
- if ((i || a || o && n.type !== "planning") && (e.filter(O).length > 0 || a) && n.type !== "abandonment") {
402
+ let t = e[e.length - 1], n = r[r.length - 1], i = k(t) && t.role === "assistant", a = t.role === "user" && ue.test(t.content), o = !e.slice(Math.floor(e.length * .8)).some((e) => re(e, O));
403
+ if ((i || a || o && n.type !== "planning") && (e.filter(k).length > 0 || a) && n.type !== "abandonment") {
404
404
  let t = e.length - 1;
405
405
  r.push({
406
406
  type: "abandonment",
@@ -410,15 +410,15 @@ function he(e) {
410
410
  });
411
411
  }
412
412
  }
413
- return me(r);
413
+ return pe(r);
414
414
  }
415
- function k(e) {
416
- return he(e).map((t, n) => {
415
+ function A(e) {
416
+ return me(e).map((t, n) => {
417
417
  let r = 0;
418
- for (let n = t.startTurn; n <= t.endTurn; n++) e[n] && O(e[n]) && r++;
418
+ for (let n = t.startTurn; n <= t.endTurn; n++) e[n] && k(e[n]) && r++;
419
419
  let i = {
420
420
  id: `phase-${n + 1}`,
421
- label: T(t.type),
421
+ label: E(t.type),
422
422
  from: e[t.startTurn]?.index ?? t.startTurn,
423
423
  to: e[t.endTurn]?.index ?? t.endTurn,
424
424
  icon: t.type
@@ -426,71 +426,71 @@ function k(e) {
426
426
  return r > 0 && (i.errors = r), i;
427
427
  });
428
428
  }
429
- function A(e) {
429
+ function j(e) {
430
430
  let t = e.filter((e) => Number.isFinite(e)).sort((e, t) => e - t);
431
431
  if (t.length === 0) return;
432
432
  let n = Math.floor(t.length / 2);
433
433
  return t.length % 2 == 0 ? (t[n - 1] + t[n]) / 2 : t[n];
434
434
  }
435
- function ge(e) {
435
+ function he(e) {
436
436
  if (!e || e.length === 0) return {};
437
437
  let t = [], n = [], r = [];
438
438
  for (let i of e) i.totalTokens > 0 && Number.isFinite(i.retryTokensWasted) && t.push(i.retryTokensWasted / i.totalTokens), Number.isFinite(i.specQualityScore) && i.specQualityScore > 0 && n.push(i.specQualityScore), Number.isFinite(i.withinSessionReverts) && r.push(i.withinSessionReverts);
439
- let i = {}, a = A(t), o = A(n), s = A(r);
439
+ let i = {}, a = j(t), o = j(n), s = j(r);
440
440
  return a !== void 0 && (i.retryShare = a), o !== void 0 && (i.specQualityScore = o), s !== void 0 && (i.withinSessionReverts = s), i;
441
441
  }
442
- var j = .2, M = 70, N = 50, P = 40, F = 30, I = 4, L = 3;
443
- function R(e) {
442
+ var M = .2, N = 70, P = 50, F = 40, I = 30, L = 4, R = 3;
443
+ function z(e) {
444
444
  return e != null;
445
445
  }
446
- function z(e) {
446
+ function B(e) {
447
447
  return e === "bad" ? 2 : +(e === "watch");
448
448
  }
449
- function B(e) {
450
- return e.reduce((e, t) => z(t) > z(e) ? t : e, "good");
449
+ function V(e) {
450
+ return e.reduce((e, t) => B(t) > B(e) ? t : e, "good");
451
451
  }
452
- function V(e, t = {}) {
452
+ function H(e, t = {}) {
453
453
  if (!e) return [];
454
454
  let n = [];
455
455
  {
456
- let r = [], i = [], a = R(e.totalTokens) && (e.totalTokens ?? 0) > 0 && R(e.retryTokensWasted) ? (e.retryTokensWasted ?? 0) / (e.totalTokens ?? 1) : void 0;
457
- if (a !== void 0 && (r.push(a > j ? "bad" : "good"), a > j && i.push(`${Math.round(a * 100)}% of tokens spent on retries`)), R(e.m5ContextUtilizationPct)) {
456
+ let r = [], i = [], a = z(e.totalTokens) && (e.totalTokens ?? 0) > 0 && z(e.retryTokensWasted) ? (e.retryTokensWasted ?? 0) / (e.totalTokens ?? 1) : void 0;
457
+ if (a !== void 0 && (r.push(a > M ? "bad" : "good"), a > M && i.push(`${Math.round(a * 100)}% of tokens spent on retries`)), z(e.m5ContextUtilizationPct)) {
458
458
  let t = e.m5ContextUtilizationPct ?? 0;
459
- r.push(t > M ? "watch" : "good"), t > M && i.push(`Context ${Math.round(t)}% full`);
459
+ r.push(t > N ? "watch" : "good"), t > N && i.push(`Context ${Math.round(t)}% full`);
460
460
  }
461
- if (R(e.m6OutputSurvivalPct)) {
461
+ if (z(e.m6OutputSurvivalPct)) {
462
462
  let t = e.m6OutputSurvivalPct ?? 0;
463
- r.push(t < N ? "watch" : "good"), t < N && i.push(`Only ${Math.round(t)}% of output survived`);
463
+ r.push(t < P ? "watch" : "good"), t < P && i.push(`Only ${Math.round(t)}% of output survived`);
464
464
  }
465
- e.outcome === "failed" && R(e.costTotalUsd) && a !== void 0 && t.retryShare !== void 0 && a > t.retryShare && (r.push("bad"), i.push("Failed outcome with above-median spend")), (a !== void 0 || R(e.m5ContextUtilizationPct) || R(e.m6OutputSurvivalPct)) && n.push(H("token", "Token efficiency", a === void 0 ? R(e.m5ContextUtilizationPct) ? `${Math.round(e.m5ContextUtilizationPct ?? 0)}% context used` : "—" : `${Math.round(a * 100)}% retry tokens`, B(r), i));
465
+ e.outcome === "failed" && z(e.costTotalUsd) && a !== void 0 && t.retryShare !== void 0 && a > t.retryShare && (r.push("bad"), i.push("Failed outcome with above-median spend")), (a !== void 0 || z(e.m5ContextUtilizationPct) || z(e.m6OutputSurvivalPct)) && n.push(U("token", "Token efficiency", a === void 0 ? z(e.m5ContextUtilizationPct) ? `${Math.round(e.m5ContextUtilizationPct ?? 0)}% context used` : "—" : `${Math.round(a * 100)}% retry tokens`, V(r), i));
466
466
  }
467
467
  {
468
468
  let t = [], r = [];
469
- if (R(e.specQualityScore)) {
469
+ if (z(e.specQualityScore)) {
470
470
  let n = e.specQualityScore ?? 0;
471
- t.push(n < P ? "bad" : "good"), n < P && r.push(`Spec quality low (${Math.round(n)}/100)`);
471
+ t.push(n < F ? "bad" : "good"), n < F && r.push(`Spec quality low (${Math.round(n)}/100)`);
472
472
  }
473
- if (R(e.signalDensity)) {
473
+ if (z(e.signalDensity)) {
474
474
  let n = e.signalDensity ?? 0;
475
- t.push(n < F ? "watch" : "good"), n < F && r.push(`Sparse direction (${Math.round(n)}% signal)`);
475
+ t.push(n < I ? "watch" : "good"), n < I && r.push(`Sparse direction (${Math.round(n)}% signal)`);
476
476
  }
477
- e.m7SpecHasExamples === !1 && (t.push("watch"), r.push("No examples in the prompt")), e.m7SpecHasConstraints === !1 && (t.push("watch"), r.push("No constraints in the prompt")), (R(e.specQualityScore) || R(e.signalDensity) || R(e.m7SpecHasExamples) || R(e.m7SpecHasConstraints)) && n.push(H("prompt", "Prompt quality", R(e.specQualityScore) ? `Spec ${Math.round(e.specQualityScore ?? 0)}/100` : R(e.signalDensity) ? `${Math.round(e.signalDensity ?? 0)}% signal` : "—", B(t), r));
477
+ e.m7SpecHasExamples === !1 && (t.push("watch"), r.push("No examples in the prompt")), e.m7SpecHasConstraints === !1 && (t.push("watch"), r.push("No constraints in the prompt")), (z(e.specQualityScore) || z(e.signalDensity) || z(e.m7SpecHasExamples) || z(e.m7SpecHasConstraints)) && n.push(U("prompt", "Prompt quality", z(e.specQualityScore) ? `Spec ${Math.round(e.specQualityScore ?? 0)}/100` : z(e.signalDensity) ? `${Math.round(e.signalDensity ?? 0)}% signal` : "—", V(t), r));
478
478
  }
479
479
  {
480
480
  let t = [], r = [];
481
- if (R(e.m4ConsecutiveErrorMax)) {
481
+ if (z(e.m4ConsecutiveErrorMax)) {
482
482
  let n = e.m4ConsecutiveErrorMax ?? 0;
483
- t.push(n >= I ? "bad" : "good"), n >= I && r.push(`${n} errors in a row`);
483
+ t.push(n >= L ? "bad" : "good"), n >= L && r.push(`${n} errors in a row`);
484
484
  }
485
- if (R(e.withinSessionReverts)) {
485
+ if (z(e.withinSessionReverts)) {
486
486
  let n = e.withinSessionReverts ?? 0;
487
- t.push(n >= L ? "bad" : "good"), n >= L && r.push(`${n} reverts mid-session`);
487
+ t.push(n >= R ? "bad" : "good"), n >= R && r.push(`${n} reverts mid-session`);
488
488
  }
489
- (R(e.m4ConsecutiveErrorMax) || R(e.withinSessionReverts)) && n.push(H("loop", "Loop efficiency", R(e.m4ConsecutiveErrorMax) ? `${e.m4ConsecutiveErrorMax ?? 0} max error streak` : R(e.withinSessionReverts) ? `${e.withinSessionReverts ?? 0} reverts` : "—", B(t), r));
489
+ (z(e.m4ConsecutiveErrorMax) || z(e.withinSessionReverts)) && n.push(U("loop", "Loop efficiency", z(e.m4ConsecutiveErrorMax) ? `${e.m4ConsecutiveErrorMax ?? 0} max error streak` : z(e.withinSessionReverts) ? `${e.withinSessionReverts ?? 0} reverts` : "—", V(t), r));
490
490
  }
491
491
  return n;
492
492
  }
493
- function H(e, t, n, r, i) {
493
+ function U(e, t, n, r, i) {
494
494
  let a = {
495
495
  id: e,
496
496
  label: t,
@@ -500,7 +500,7 @@ function H(e, t, n, r, i) {
500
500
  };
501
501
  return i.length && (a.flags = i, a.detail = i.join(", ")), a;
502
502
  }
503
- function _e(e, t) {
503
+ function ge(e, t) {
504
504
  let n = t[e.turnIndex]?.index ?? e.turnIndex;
505
505
  return {
506
506
  id: `pattern-${e.type}-${e.turnIndex}`,
@@ -509,7 +509,7 @@ function _e(e, t) {
509
509
  label: e.label
510
510
  };
511
511
  }
512
- function ve(e, t, n) {
512
+ function _e(e, t, n) {
513
513
  let r = [];
514
514
  for (let t = e.startIndex; t <= e.endIndex; t++) {
515
515
  let e = n[t];
@@ -526,16 +526,16 @@ function ve(e, t, n) {
526
526
  let a = e.filesTouched.length, o = [];
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
- function U(e) {
530
- return y(e).map((t, n) => ve(t, n, e));
529
+ function W(e) {
530
+ return y(e).map((t, n) => _e(t, n, e));
531
531
  }
532
- function W(e, t = {}) {
533
- let n = k(e), r = w(e).map((t) => _e(t, e)), i = U(e), a = V(t.scorecard, t.medians), o = {};
532
+ function G(e, t = {}) {
533
+ let n = A(e), r = T(e).map((t) => ge(t, e)), i = W(e), a = H(t.scorecard, t.medians), o = {};
534
534
  return n.length && (o.phases = n), a.length && (o.scorecardBands = a), r.length && (o.patternAnnotations = r), i.length && (o.taskGroups = i), o;
535
535
  }
536
536
  //#endregion
537
537
  //#region src/ui/transcript/usage.js
538
- var G = Object.freeze({
538
+ var K = Object.freeze({
539
539
  input: "input",
540
540
  output: "output",
541
541
  cacheRead: "cache read",
@@ -543,7 +543,7 @@ var G = Object.freeze({
543
543
  cacheWrite1h: "cache write 1h (subset)",
544
544
  reasoning: "reasoning (subset)",
545
545
  totalTokens: "total tokens"
546
- }), K = Object.freeze({
546
+ }), ve = Object.freeze({
547
547
  input: "input",
548
548
  output: "output",
549
549
  cacheRead: "cache read",
@@ -582,8 +582,8 @@ function be(e) {
582
582
  return [{
583
583
  scope: e,
584
584
  ownerCount: t.length,
585
- tokens: r("tokens", G),
586
- cost: r("cost", K)
585
+ tokens: r("tokens", K),
586
+ cost: r("cost", ve)
587
587
  }];
588
588
  });
589
589
  }
@@ -1105,7 +1105,7 @@ function pt(e, t, r, i) {
1105
1105
  toolCallsById: c,
1106
1106
  diffs: ct(s),
1107
1107
  files: lt(s),
1108
- tasks: Ve(l.taskGroups ?? U(d), s),
1108
+ tasks: Ve(l.taskGroups ?? W(d), s),
1109
1109
  highlights: ut(s, p, f),
1110
1110
  filterIndex: ft(s, u),
1111
1111
  analytics: l
@@ -1166,14 +1166,19 @@ function $(e, t, n, r, i, a, o) {
1166
1166
  s.set(e.index, (s.get(e.index) ?? 0) + 1);
1167
1167
  for (let t of e.toolCalls ?? []) t.id && c.set(t.id, (c.get(t.id) ?? 0) + 1);
1168
1168
  }
1169
- let l = Xe(t, e.model), u = (e.harness === "pi" ? t : Je(t)).filter((t) => !Ke(t, e.harness)).map(qe), d = o === void 0 ? null : new Set(o), f = d === null ? u : u.filter((e) => d.has(e.index)), p = x(f), m = e.harness, h = a ?? W(f, { scorecard: e.scorecard ?? void 0 }), g = st(h.patternAnnotations ?? [], ot(i ?? [])), _ = -1;
1170
- for (let e = 0; e < f.length; e++) {
1171
- let t = f[e];
1172
- t.role === "assistant" && (t.depth ?? 0) === 0 && t.content?.trim() && (_ = e);
1169
+ let l = Xe(t, e.model), u = /* @__PURE__ */ new Map();
1170
+ 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);
1173
+ 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;
1175
+ for (let e = 0; e < p.length; e++) {
1176
+ let t = p[e];
1177
+ t.role === "assistant" && (t.depth ?? 0) === 0 && t.content?.trim() && (v = e);
1173
1178
  }
1174
- let v = /* @__PURE__ */ new Map(), y = [], b = new Map(u.map((e, t) => [e, t]));
1175
- for (let e = 0; e < f.length; e++) {
1176
- let t = f[e], i = (t.toolCalls ?? []).map((e, t) => ({
1179
+ let y = /* @__PURE__ */ new Map(), b = [], S = new Map(d.map((e, t) => [e, t]));
1180
+ for (let e = 0; e < p.length; e++) {
1181
+ let t = p[e], i = (t.toolCalls ?? []).map((e, t) => ({
1177
1182
  ...tt(e),
1178
1183
  sourceIndex: t,
1179
1184
  sourceIdUnique: !e.id || c.get(e.id) === 1
@@ -1183,15 +1188,15 @@ function $(e, t, n, r, i, a, o) {
1183
1188
  let i = n?.filter((n) => n.attachment?.turnIndex === t.index && n.attachment?.toolCallId === e.id);
1184
1189
  i?.length && (e.nativeMetadata = i);
1185
1190
  }
1186
- for (let e of i) v.set(e.id, e);
1191
+ for (let e of i) y.set(e.id, e);
1187
1192
  let a = t.content ?? "", o;
1188
1193
  if (t.entryType === "thinking" && (Z(t) || a.trim() !== "")) {
1189
1194
  o = {
1190
1195
  text: a,
1191
1196
  words: Ie(a)
1192
1197
  };
1193
- let e = b.get(t) ?? -1, n;
1194
- for (let r = e - 1; r >= 0 && !n; r--) (u[r].depth ?? 0) === (t.depth ?? 0) && (n = u[r]);
1198
+ let e = S.get(t) ?? -1, n;
1199
+ for (let r = e - 1; r >= 0 && !n; r--) (d[r].depth ?? 0) === (t.depth ?? 0) && (n = d[r]);
1195
1200
  let r = Le(n, t);
1196
1201
  r !== void 0 && (o.durationMs = r), a = "";
1197
1202
  } else if (!Z(t)) {
@@ -1204,34 +1209,34 @@ function $(e, t, n, r, i, a, o) {
1204
1209
  }, a = a.slice(e[0].length));
1205
1210
  }
1206
1211
  }
1207
- let d = t.depth ?? 0, h = t.entryType === "error" || i.some((e) => e.isError), x = {
1212
+ let f = t.depth ?? 0, g = t.entryType === "error" || i.some((e) => e.isError), x = {
1208
1213
  index: t.index,
1209
1214
  sourceIndexUnique: s.get(t.index) === 1,
1210
1215
  identity: `${r}:${t.sourceEntryRef || t.index}`,
1211
1216
  partition: r,
1212
1217
  role: t.role,
1213
- label: p[e] ?? String(e + 1),
1218
+ label: m[e] ?? String(e + 1),
1214
1219
  content: a,
1215
- depth: d,
1220
+ depth: f,
1216
1221
  toolCalls: i,
1217
- annotations: g[t.index] ?? []
1222
+ annotations: _[t.index] ?? []
1218
1223
  };
1219
- d === 0 && t.role === "assistant" && (x.provider = m), t.agentName && (x.agentName = t.agentName), o && (x.thinking = o);
1220
- let S = Be(t.role, a, m);
1221
- S !== void 0 && (x.displayContent = S), 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), h && (x.isError = !0), e === _ && (x.isFinal = !0), !t.usage && (t.tokensIn != null || t.tokensOut != null) && (x.tokens = {
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);
1225
+ let C = Be(t.role, a, h);
1226
+ 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 = {
1222
1227
  in: t.tokensIn ?? 0,
1223
1228
  out: t.tokensOut ?? 0
1224
1229
  }), t.timestamp && (x.timestamp = t.timestamp);
1225
- let C = l.get(t.index);
1226
- C?.effectiveModel !== void 0 && (x.effectiveModel = C.effectiveModel), C?.modelChangedFrom !== void 0 && (x.modelChangedFrom = C.modelChangedFrom), y.push(x);
1230
+ let w = l.get(t.index);
1231
+ w?.effectiveModel !== void 0 && (x.effectiveModel = w.effectiveModel), w?.modelChangedFrom !== void 0 && (x.modelChangedFrom = w.modelChangedFrom), b.push(x);
1227
1232
  }
1228
1233
  return {
1229
- turns: y,
1230
- toolCallsById: v,
1231
- analytics: h,
1232
- annotationsByTurn: g,
1233
- filteredTurns: f
1234
+ turns: b,
1235
+ toolCallsById: y,
1236
+ analytics: g,
1237
+ annotationsByTurn: _,
1238
+ filteredTurns: p
1234
1239
  };
1235
1240
  }
1236
1241
  //#endregion
1237
- export { h as S, U as _, ke as a, k as b, Ee as c, G as d, w as f, ge as g, W as h, Te as i, q as l, C as m, Ke as n, Oe as o, V as p, Je as r, De as s, pt as t, K as u, y as v, T as x, x as y };
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 };
@@ -1,5 +1,5 @@
1
1
  import { Dt as e, Tt as t, ft as n, mt as r } from "./GraphLegend-e9x79JtU.js";
2
- import { $ as i, $t as a, Gn as o, In as s, O as c, Qn as l, St as u, Xn as d, Yn as f, Zt as p, _t as m, at as h, bt as g, en as _, ht as v, k as y, nt as b, ot as x, pr as S, tn as C, tt as w, vt as T, yt as E } from "./ui-BOGaFxV-.js";
2
+ import { $ as i, $t as a, Gn as o, In as s, O as c, Qn as l, St as u, Xn as d, Yn as f, Zt as p, _t as m, at as h, bt as g, en as _, ht as v, k as y, nt as b, ot as x, pr as S, tn as C, tt as w, vt as T, yt as E } from "./ui-Do7A_I-0.js";
3
3
  import { p as D } from "./time-CpVBzcqQ.js";
4
4
  import { i as O, o as k, r as A } from "./format-B3uT2wzU.js";
5
5
  import { useEffect as j, useId as M, useMemo as N, useRef as ee, useState as P } from "react";