@peasant-labs/fairtrade 0.0.47 → 0.0.48
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/lib/{adapter-Dulh38C2.js → adapter-DnCl_ddK.js} +187 -174
- package/dist/lib/commons.js +1 -1
- package/dist/lib/components.css +1 -1
- package/dist/lib/share.js +1 -1
- package/dist/lib/types/transcript/Collapsible.d.ts +10 -0
- package/dist/lib/types/transcript/FiltersRail.d.ts +1 -0
- package/dist/lib/types/transcript/Thinking.d.ts +1 -1
- package/dist/lib/types/transcript/ToolCall.d.ts +1 -1
- package/dist/lib/types/transcript/TranscriptViewer.d.ts +1 -1
- package/dist/lib/types/transcript/TurnCard.d.ts +3 -1
- package/dist/lib/types/transcript/WorkGroup.d.ts +9 -0
- package/dist/lib/types/transcript/action-groups.d.ts +9 -0
- package/dist/lib/types/transcript/adapter.d.ts +12 -0
- package/dist/lib/types/transcript/filters.d.ts +5 -5
- package/dist/lib/types/transcript/index.d.ts +1 -1
- package/dist/lib/types/transcript/state-capabilities.d.ts +10 -3
- package/dist/lib/types/transcript/view-model.d.ts +5 -0
- package/dist/lib/types/transcript/work-summary.d.ts +8 -0
- package/dist/lib/types/ui/transcript/adapter.d.ts +12 -0
- package/dist/lib/types/ui/transcript/view-model.d.ts +5 -0
- package/dist/lib/{ui-CrH0SVd_.js → ui-BLiaBlAK.js} +1722 -1354
- package/dist/lib/ui.js +3 -3
- package/package.json +1 -1
|
@@ -126,11 +126,11 @@ function y(e) {
|
|
|
126
126
|
let n = [];
|
|
127
127
|
for (let r = 0; r < t.length; r++) {
|
|
128
128
|
let i = t[r], a = (r + 1 < t.length ? t[r + 1] : e.length) - 1;
|
|
129
|
-
n.push(
|
|
129
|
+
n.push(b(e, i, a));
|
|
130
130
|
}
|
|
131
131
|
return n;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function b(e, t, n) {
|
|
134
134
|
let r = e[t], i = 0, a = /* @__PURE__ */ new Set(), o = 0, s = 0, c = !1, l = 0, u;
|
|
135
135
|
for (let r = t; r <= n; r++) {
|
|
136
136
|
let t = e[r];
|
|
@@ -158,23 +158,23 @@ function ee(e, t, n) {
|
|
|
158
158
|
};
|
|
159
159
|
return u !== void 0 && (h.finalEntryIndex = u), h;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function x(e) {
|
|
162
162
|
if (e.length === 0) return [];
|
|
163
163
|
let t = y(e), n = /* @__PURE__ */ new Map();
|
|
164
164
|
for (let e = 0; e < t.length; e++) n.set(t[e].startIndex, e + 1);
|
|
165
165
|
let r = Array(e.length), i = 0, a = 0;
|
|
166
166
|
for (let t = 0; t < e.length; t++) {
|
|
167
167
|
let e = n.get(t);
|
|
168
|
-
e === void 0 ? i === 0 ? r[t] = `${t + 1}` : (a += 1, r[t] = `${i}${
|
|
168
|
+
e === void 0 ? i === 0 ? r[t] = `${t + 1}` : (a += 1, r[t] = `${i}${ee(a)}`) : (i = e, a = 0, r[t] = `${i}`);
|
|
169
169
|
}
|
|
170
170
|
return r;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function ee(e) {
|
|
173
173
|
let t = "", n = e;
|
|
174
174
|
for (; n > 0;) t = String.fromCharCode(97 + (n - 1) % 26) + t, n = Math.floor((n - 1) / 26);
|
|
175
175
|
return t;
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function te(e) {
|
|
178
178
|
let t = e.reduce((e, t) => e + Math.max(0, t.durationMs), 0), n = 0;
|
|
179
179
|
return e.map((e) => {
|
|
180
180
|
let r = Math.max(0, e.durationMs), i = t > 0 ? n / t * 100 : 0, a = t > 0 ? r / t * 100 : 0;
|
|
@@ -186,17 +186,17 @@ function ne(e) {
|
|
|
186
186
|
};
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
var
|
|
189
|
+
var ne = /* @__PURE__ */ new Set([
|
|
190
190
|
"Task",
|
|
191
191
|
"EnterWorktree",
|
|
192
192
|
"SendMessage",
|
|
193
193
|
"TeamCreate"
|
|
194
|
-
]),
|
|
194
|
+
]), re = /* @__PURE__ */ new Set([
|
|
195
195
|
"Write",
|
|
196
196
|
"Edit",
|
|
197
197
|
"NotebookEdit"
|
|
198
198
|
]);
|
|
199
|
-
function
|
|
199
|
+
function S(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 x(e) {
|
|
|
206
206
|
type: "error",
|
|
207
207
|
label: `${e.name} failed`,
|
|
208
208
|
severity: "error"
|
|
209
|
-
}),
|
|
209
|
+
}), ne.has(e.name) && t.push({
|
|
210
210
|
turnIndex: i,
|
|
211
211
|
type: "subagent",
|
|
212
212
|
label: `Subagent: ${e.name}`,
|
|
213
213
|
severity: "info"
|
|
214
|
-
}),
|
|
214
|
+
}), re.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 x(e) {
|
|
|
240
240
|
}
|
|
241
241
|
return t.sort((e, t) => e.turnIndex - t.turnIndex);
|
|
242
242
|
}
|
|
243
|
-
var
|
|
243
|
+
var ie = {
|
|
244
244
|
planning: "Planning",
|
|
245
245
|
exploration: "Exploration",
|
|
246
246
|
implementation: "Implementation",
|
|
@@ -252,20 +252,20 @@ var ae = {
|
|
|
252
252
|
recovery: "Recovery",
|
|
253
253
|
abandonment: "Abandonment"
|
|
254
254
|
};
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function C(e) {
|
|
256
|
+
return ie[e] ?? String(e);
|
|
257
257
|
}
|
|
258
|
-
var
|
|
258
|
+
var w = /* @__PURE__ */ new Set([
|
|
259
259
|
"Read",
|
|
260
260
|
"Glob",
|
|
261
261
|
"Grep",
|
|
262
262
|
"WebSearch",
|
|
263
263
|
"WebFetch"
|
|
264
|
-
]),
|
|
264
|
+
]), T = /* @__PURE__ */ new Set([
|
|
265
265
|
"Write",
|
|
266
266
|
"Edit",
|
|
267
267
|
"NotebookEdit"
|
|
268
|
-
]),
|
|
268
|
+
]), ae = [
|
|
269
269
|
/\btest\b/i,
|
|
270
270
|
/\bjest\b/i,
|
|
271
271
|
/\bpytest\b/i,
|
|
@@ -278,21 +278,21 @@ var C = /* @__PURE__ */ new Set([
|
|
|
278
278
|
/\bmocha\b/i,
|
|
279
279
|
/\brspec\b/i
|
|
280
280
|
];
|
|
281
|
-
function
|
|
281
|
+
function oe(e, t) {
|
|
282
282
|
return e.toolCalls?.some((e) => t.has(e.name)) ?? !1;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function se(e, t) {
|
|
285
285
|
return e.toolCalls?.length ? e.toolCalls.every((e) => t.has(e.name)) : !1;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function E(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
|
|
292
|
-
for (let t of e.toolCalls ?? []) if (t.name === "Bash" &&
|
|
291
|
+
function ce(e) {
|
|
292
|
+
for (let t of e.toolCalls ?? []) if (t.name === "Bash" && ae.some((e) => e.test(t.arguments))) return !0;
|
|
293
293
|
return !1;
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function le(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 ue(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) =>
|
|
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) => T.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 ue(e) {
|
|
|
310
310
|
}
|
|
311
311
|
return t;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function ue(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
|
|
318
|
-
let t =
|
|
317
|
+
function de(e) {
|
|
318
|
+
let t = le(e), n = [], r = 0;
|
|
319
319
|
for (; r < t.length;) {
|
|
320
320
|
let e = r + 1;
|
|
321
|
-
for (; e < t.length &&
|
|
321
|
+
for (; e < t.length && ue(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
|
|
326
|
+
var fe = [
|
|
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 pe = [
|
|
|
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
|
-
],
|
|
335
|
-
function
|
|
334
|
+
], pe = /\b(let'?s move on|forget it|different approach|never mind)\b/i;
|
|
335
|
+
function me(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" ?
|
|
337
|
+
return e.role === "user" ? fe.some((t) => t.test(e.content)) ? "user-correction" : n ?? "planning" : E(e) ? "error" : ce(e) ? "testing" : r > 0 && se(e, w) ? "debug" : oe(e, T) ? n === "retry-loop" || n === "user-correction" ? "recovery" : "implementation" : se(e, w) && r === 0 ? "exploration" : e.role === "assistant" && !e.toolCalls?.length && e.content.length > 100 ? "planning" : n ?? "planning";
|
|
338
338
|
}
|
|
339
|
-
var
|
|
339
|
+
var he = /* @__PURE__ */ new Set([
|
|
340
340
|
"error",
|
|
341
341
|
"user-correction",
|
|
342
342
|
"retry-loop",
|
|
343
343
|
"abandonment"
|
|
344
344
|
]);
|
|
345
|
-
function
|
|
345
|
+
function ge(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 _e(e) {
|
|
|
351
351
|
a.endTurn = r.endTurn;
|
|
352
352
|
continue;
|
|
353
353
|
}
|
|
354
|
-
if (i < 3 && !
|
|
354
|
+
if (i < 3 && !he.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 _e(e) {
|
|
|
379
379
|
}
|
|
380
380
|
return t;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function _e(e) {
|
|
383
383
|
if (e.length === 0) return [];
|
|
384
|
-
let t =
|
|
384
|
+
let t = de(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++)
|
|
387
|
+
for (let t = Math.max(0, r - 3); t < r; t++) E(e[t]) && i++;
|
|
388
388
|
let a = n.length > 0 ? n[n.length - 1].type : null;
|
|
389
389
|
n.push({
|
|
390
|
-
type:
|
|
390
|
+
type: me(e[r], r, a, i, t),
|
|
391
391
|
turn: r
|
|
392
392
|
});
|
|
393
393
|
}
|
|
@@ -399,8 +399,8 @@ function ve(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 =
|
|
403
|
-
if ((i || a || o && n.type !== "planning") && (e.filter(
|
|
402
|
+
let t = e[e.length - 1], n = r[r.length - 1], i = E(t) && t.role === "assistant", a = t.role === "user" && pe.test(t.content), o = !e.slice(Math.floor(e.length * .8)).some((e) => oe(e, T));
|
|
403
|
+
if ((i || a || o && n.type !== "planning") && (e.filter(E).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 ve(e) {
|
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
return
|
|
413
|
+
return ge(r);
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
return
|
|
415
|
+
function D(e) {
|
|
416
|
+
return _e(e).map((t, n) => {
|
|
417
417
|
let r = 0;
|
|
418
|
-
for (let n = t.startTurn; n <= t.endTurn; n++) e[n] &&
|
|
418
|
+
for (let n = t.startTurn; n <= t.endTurn; n++) e[n] && E(e[n]) && r++;
|
|
419
419
|
let i = {
|
|
420
420
|
id: `phase-${n + 1}`,
|
|
421
|
-
label:
|
|
421
|
+
label: C(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 E(e) {
|
|
|
426
426
|
return r > 0 && (i.errors = r), i;
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function O(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
|
|
435
|
+
function ve(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 =
|
|
439
|
+
let i = {}, a = O(t), o = O(n), s = O(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
|
|
443
|
-
function
|
|
442
|
+
var k = .2, A = 70, j = 50, M = 40, N = 30, P = 4, F = 3;
|
|
443
|
+
function I(e) {
|
|
444
444
|
return e != null;
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function L(e) {
|
|
447
447
|
return e === "bad" ? 2 : +(e === "watch");
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return e.reduce((e, t) =>
|
|
449
|
+
function R(e) {
|
|
450
|
+
return e.reduce((e, t) => L(t) > L(e) ? t : e, "good");
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function z(e, t = {}) {
|
|
453
453
|
if (!e) return [];
|
|
454
454
|
let n = [];
|
|
455
455
|
{
|
|
456
|
-
let r = [], i = [], a =
|
|
457
|
-
if (a !== void 0 && (r.push(a >
|
|
456
|
+
let r = [], i = [], a = I(e.totalTokens) && (e.totalTokens ?? 0) > 0 && I(e.retryTokensWasted) ? (e.retryTokensWasted ?? 0) / (e.totalTokens ?? 1) : void 0;
|
|
457
|
+
if (a !== void 0 && (r.push(a > k ? "bad" : "good"), a > k && i.push(`${Math.round(a * 100)}% of tokens spent on retries`)), I(e.m5ContextUtilizationPct)) {
|
|
458
458
|
let t = e.m5ContextUtilizationPct ?? 0;
|
|
459
|
-
r.push(t >
|
|
459
|
+
r.push(t > A ? "watch" : "good"), t > A && i.push(`Context ${Math.round(t)}% full`);
|
|
460
460
|
}
|
|
461
|
-
if (
|
|
461
|
+
if (I(e.m6OutputSurvivalPct)) {
|
|
462
462
|
let t = e.m6OutputSurvivalPct ?? 0;
|
|
463
|
-
r.push(t <
|
|
463
|
+
r.push(t < j ? "watch" : "good"), t < j && i.push(`Only ${Math.round(t)}% of output survived`);
|
|
464
464
|
}
|
|
465
|
-
e.outcome === "failed" &&
|
|
465
|
+
e.outcome === "failed" && I(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 || I(e.m5ContextUtilizationPct) || I(e.m6OutputSurvivalPct)) && n.push(B("token", "Token efficiency", a === void 0 ? I(e.m5ContextUtilizationPct) ? `${Math.round(e.m5ContextUtilizationPct ?? 0)}% context used` : "—" : `${Math.round(a * 100)}% retry tokens`, R(r), i));
|
|
466
466
|
}
|
|
467
467
|
{
|
|
468
468
|
let t = [], r = [];
|
|
469
|
-
if (
|
|
469
|
+
if (I(e.specQualityScore)) {
|
|
470
470
|
let n = e.specQualityScore ?? 0;
|
|
471
|
-
t.push(n <
|
|
471
|
+
t.push(n < M ? "bad" : "good"), n < M && r.push(`Spec quality low (${Math.round(n)}/100)`);
|
|
472
472
|
}
|
|
473
|
-
if (
|
|
473
|
+
if (I(e.signalDensity)) {
|
|
474
474
|
let n = e.signalDensity ?? 0;
|
|
475
|
-
t.push(n <
|
|
475
|
+
t.push(n < N ? "watch" : "good"), n < N && 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")), (
|
|
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")), (I(e.specQualityScore) || I(e.signalDensity) || I(e.m7SpecHasExamples) || I(e.m7SpecHasConstraints)) && n.push(B("prompt", "Prompt quality", I(e.specQualityScore) ? `Spec ${Math.round(e.specQualityScore ?? 0)}/100` : I(e.signalDensity) ? `${Math.round(e.signalDensity ?? 0)}% signal` : "—", R(t), r));
|
|
478
478
|
}
|
|
479
479
|
{
|
|
480
480
|
let t = [], r = [];
|
|
481
|
-
if (
|
|
481
|
+
if (I(e.m4ConsecutiveErrorMax)) {
|
|
482
482
|
let n = e.m4ConsecutiveErrorMax ?? 0;
|
|
483
|
-
t.push(n >=
|
|
483
|
+
t.push(n >= P ? "bad" : "good"), n >= P && r.push(`${n} errors in a row`);
|
|
484
484
|
}
|
|
485
|
-
if (
|
|
485
|
+
if (I(e.withinSessionReverts)) {
|
|
486
486
|
let n = e.withinSessionReverts ?? 0;
|
|
487
|
-
t.push(n >=
|
|
487
|
+
t.push(n >= F ? "bad" : "good"), n >= F && r.push(`${n} reverts mid-session`);
|
|
488
488
|
}
|
|
489
|
-
(
|
|
489
|
+
(I(e.m4ConsecutiveErrorMax) || I(e.withinSessionReverts)) && n.push(B("loop", "Loop efficiency", I(e.m4ConsecutiveErrorMax) ? `${e.m4ConsecutiveErrorMax ?? 0} max error streak` : I(e.withinSessionReverts) ? `${e.withinSessionReverts ?? 0} reverts` : "—", R(t), r));
|
|
490
490
|
}
|
|
491
491
|
return n;
|
|
492
492
|
}
|
|
493
|
-
function
|
|
493
|
+
function B(e, t, n, r, i) {
|
|
494
494
|
let a = {
|
|
495
495
|
id: e,
|
|
496
496
|
label: t,
|
|
@@ -500,7 +500,7 @@ function z(e, t, n, r, i) {
|
|
|
500
500
|
};
|
|
501
501
|
return i.length && (a.flags = i, a.detail = i.join(", ")), a;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function ye(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 be(e, t) {
|
|
|
509
509
|
label: e.label
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function be(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 xe(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
|
|
530
|
-
return y(e).map((t, n) =>
|
|
529
|
+
function V(e) {
|
|
530
|
+
return y(e).map((t, n) => be(t, n, e));
|
|
531
531
|
}
|
|
532
|
-
function
|
|
533
|
-
let n =
|
|
532
|
+
function H(e, t = {}) {
|
|
533
|
+
let n = D(e), r = S(e).map((t) => ye(t, e)), i = V(e), a = z(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
|
|
538
|
+
var U = Object.freeze({
|
|
539
539
|
input: "input",
|
|
540
540
|
output: "output",
|
|
541
541
|
cacheRead: "cache read",
|
|
@@ -543,14 +543,14 @@ var H = Object.freeze({
|
|
|
543
543
|
cacheWrite1h: "cache write 1h (subset)",
|
|
544
544
|
reasoning: "reasoning (subset)",
|
|
545
545
|
totalTokens: "total tokens"
|
|
546
|
-
}),
|
|
546
|
+
}), W = Object.freeze({
|
|
547
547
|
input: "input",
|
|
548
548
|
output: "output",
|
|
549
549
|
cacheRead: "cache read",
|
|
550
550
|
cacheWrite: "cache write",
|
|
551
551
|
total: "total"
|
|
552
552
|
});
|
|
553
|
-
function
|
|
553
|
+
function xe(e) {
|
|
554
554
|
if (e.length === 1) return e[0];
|
|
555
555
|
let t = e.map((e) => {
|
|
556
556
|
let [t, n = "0"] = e.toLowerCase().split("e"), [r, i = ""] = t.split(".");
|
|
@@ -561,14 +561,14 @@ function Se(e) {
|
|
|
561
561
|
}), n = Math.max(0, ...t.map((e) => e.scale)), r = t.reduce((e, t) => e + t.coefficient * 10n ** BigInt(n - t.scale), 0n).toString().padStart(n + 1, "0");
|
|
562
562
|
return n ? (r.slice(0, -n) + "." + r.slice(-n)).replace(/\.?0+$/, "") || "0" : r;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function G(e) {
|
|
565
565
|
let n = e.flatMap((e) => [e.usage, ...(e.toolCalls ?? []).map((e) => e.usage)]).filter((e) => e != null);
|
|
566
566
|
return Object.values(t).flatMap((e) => {
|
|
567
567
|
let t = n.filter((t) => t.scope === e);
|
|
568
568
|
if (!t.length) return [];
|
|
569
569
|
let r = (n, r) => Object.entries(r).map(([r, i]) => {
|
|
570
570
|
let a = t.map((e) => e[n]?.[r]).filter((e) => e != null), o = "unknown";
|
|
571
|
-
if (a.length && n === "cost" && (o =
|
|
571
|
+
if (a.length && n === "cost" && (o = xe(a.map(String))), a.length && n === "tokens") {
|
|
572
572
|
let t = a.reduce((e, t) => e + BigInt(t), 0n);
|
|
573
573
|
if (t > BigInt(2 ** 53 - 1)) throw RangeError(`Detailed usage aggregate failed in Fairtrade adaptTranscript during ${e} ${r} summation: the known token sum exceeds the JS-safe contract bound; no trustworthy total can be displayed. Reduce the session scope or repair the producer accounting and retry.`);
|
|
574
574
|
o = String(t);
|
|
@@ -582,41 +582,41 @@ function W(e) {
|
|
|
582
582
|
return [{
|
|
583
583
|
scope: e,
|
|
584
584
|
ownerCount: t.length,
|
|
585
|
-
tokens: r("tokens",
|
|
586
|
-
cost: r("cost",
|
|
585
|
+
tokens: r("tokens", U),
|
|
586
|
+
cost: r("cost", W)
|
|
587
587
|
}];
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/ui/transcript/title.js
|
|
592
|
-
var
|
|
593
|
-
function
|
|
592
|
+
var Se = 80, Ce = "<user_query>", we = "</user_query>", Te = /^\s*(?:<([a-z][a-z0-9_-]*)>[\s\S]*?<\/\1>\s*)*<user_query>/;
|
|
593
|
+
function K(e) {
|
|
594
594
|
if (!e) return "";
|
|
595
|
-
let t =
|
|
595
|
+
let t = Te.exec(e);
|
|
596
596
|
if (!t) return e;
|
|
597
|
-
let n = t[0].length, r = e.indexOf(
|
|
597
|
+
let n = t[0].length, r = e.indexOf(we, n);
|
|
598
598
|
if (r === -1) return e.slice(n).trim();
|
|
599
599
|
let i = e.slice(n, r).trim(), a = e.slice(r + 13).trim();
|
|
600
|
-
return a && !a.startsWith(
|
|
600
|
+
return a && !a.startsWith(Ce) ? `${i}\n\n${a}` : i;
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
return
|
|
602
|
+
function Ee(e) {
|
|
603
|
+
return K(e).replace(/\s+/g, " ").trim();
|
|
604
604
|
}
|
|
605
|
-
var
|
|
606
|
-
function
|
|
605
|
+
var q = 160;
|
|
606
|
+
function De({ title: e, hasNormalizedEvidence: t, firstTaskPrompt: n, firstUserContent: r, id: i }) {
|
|
607
607
|
let a = String(e ?? (t ? void 0 : n ?? r) ?? i ?? "transcript");
|
|
608
|
-
if (a.length <=
|
|
609
|
-
let o = (a.codePointAt(
|
|
608
|
+
if (a.length <= q) return a;
|
|
609
|
+
let o = (a.codePointAt(q - 2) ?? 0) > 65535 ? q - 2 : q - 1;
|
|
610
610
|
return a.slice(0, o).trimEnd() + "…";
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function J(e, t = Se) {
|
|
613
613
|
if (!e) return "";
|
|
614
|
-
let n = Ae(
|
|
614
|
+
let n = Ae(K(e)), { slashCommand: r, rest: i } = je(n);
|
|
615
615
|
n = i;
|
|
616
616
|
let a = n.replace(/<\/?[a-zA-Z][a-zA-Z0-9-]*[^>]*>/g, " ").replace(/[ \t\r\f\v]+/g, " ").trim();
|
|
617
617
|
return a ? Pe(Ne(Me(a).replace(/\s+/g, " ").trim()), t) : r ? Pe(r, t) : "";
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function Oe(e) {
|
|
620
620
|
if (!e) return "";
|
|
621
621
|
let t = e.trim().replace(/[\\/]+$/, "");
|
|
622
622
|
if (!t) return "";
|
|
@@ -624,7 +624,7 @@ function J(e) {
|
|
|
624
624
|
return n.length > 0 ? n[n.length - 1] : t;
|
|
625
625
|
}
|
|
626
626
|
function ke(e) {
|
|
627
|
-
let t = e.id.slice(0, 8), n =
|
|
627
|
+
let t = e.id.slice(0, 8), n = Oe(e.project), r = J(e.promptContent, e.limit), i;
|
|
628
628
|
i = n && r ? `${n}: ${r}` : n ? `${n}, ${t}` : r ? `${t} — ${r}` : `Session ${t}`;
|
|
629
629
|
let a = (e.promptContent ?? i).trim() || i;
|
|
630
630
|
return {
|
|
@@ -701,25 +701,33 @@ function Ie(e) {
|
|
|
701
701
|
let t = e.trim().match(/\S+/g);
|
|
702
702
|
return t ? t.length : 0;
|
|
703
703
|
}
|
|
704
|
-
function Le(
|
|
704
|
+
function Le(t, n) {
|
|
705
|
+
if (!t || !e(t.timestamp) || !e(n.timestamp)) return;
|
|
706
|
+
let r = (t.toolCalls ?? []).reduce((e, t) => {
|
|
707
|
+
let n = t?.durationMs;
|
|
708
|
+
return e + (typeof n == "number" && Number.isFinite(n) && n > 0 ? n : 0);
|
|
709
|
+
}, 0), i = Date.parse(n.timestamp) - (Date.parse(t.timestamp) + r);
|
|
710
|
+
return i > 0 ? i : void 0;
|
|
711
|
+
}
|
|
712
|
+
function Re(e) {
|
|
705
713
|
if (!e || e <= 0) return "0";
|
|
706
714
|
if (e < 1e3) return String(e);
|
|
707
715
|
let t = e / 1e3;
|
|
708
716
|
return (t >= 10 ? Math.round(t) : Math.round(t * 10) / 10) + "k";
|
|
709
717
|
}
|
|
710
|
-
function
|
|
718
|
+
function ze(e) {
|
|
711
719
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
712
720
|
}
|
|
713
721
|
var X = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
|
|
714
722
|
function Z(e) {
|
|
715
723
|
return !!e.sourceEntryRef || X(e, "provenance") || !!e.usage || !!e.toolCalls?.some((e) => e.callEntryRef || e.resultEntryRef || e.usage || X(e, "callProvenance") || X(e, "resultProvenance"));
|
|
716
724
|
}
|
|
717
|
-
function
|
|
725
|
+
function Be(e, t, n) {
|
|
718
726
|
if (n !== "cursor" || e !== "user") return;
|
|
719
|
-
let r =
|
|
727
|
+
let r = K(t);
|
|
720
728
|
return r === t ? void 0 : r;
|
|
721
729
|
}
|
|
722
|
-
function
|
|
730
|
+
function Ve(e, t) {
|
|
723
731
|
let n = new Map(t.filter((e) => e.displayContent !== void 0).map((e) => [e.index, e.displayContent]));
|
|
724
732
|
return n.size === 0 ? e : e.map((e) => {
|
|
725
733
|
let t = n.get(e.turnIndices?.[0]);
|
|
@@ -729,7 +737,7 @@ function Be(e, t) {
|
|
|
729
737
|
};
|
|
730
738
|
});
|
|
731
739
|
}
|
|
732
|
-
function
|
|
740
|
+
function He(e) {
|
|
733
741
|
return X(e, "sourceEntryRef") && e.sourceEntryRef !== "" || X(e, "provenance") || X(e, "usage") || !!e.toolCalls?.some((e) => X(e, "callEntryRef") && e.callEntryRef !== "" || X(e, "resultEntryRef") && e.resultEntryRef !== "" || [
|
|
734
742
|
"callProvenance",
|
|
735
743
|
"resultProvenance",
|
|
@@ -738,13 +746,13 @@ function Ve(e) {
|
|
|
738
746
|
].some((t) => X(e, t)));
|
|
739
747
|
}
|
|
740
748
|
function Q(e) {
|
|
741
|
-
let t =
|
|
749
|
+
let t = ze(e);
|
|
742
750
|
if (t?.submissionRef === "") {
|
|
743
751
|
let { submissionRef: e, ...n } = t;
|
|
744
752
|
r.parse(n);
|
|
745
753
|
} else r.parse(e);
|
|
746
754
|
}
|
|
747
|
-
function
|
|
755
|
+
function Ue(e) {
|
|
748
756
|
e.forEach((e, t) => {
|
|
749
757
|
try {
|
|
750
758
|
X(e, "sourceEntryRef") && e.sourceEntryRef !== "" && o.parse(e.sourceEntryRef), X(e, "provenance") && Q(e.provenance);
|
|
@@ -754,19 +762,19 @@ function He(e) {
|
|
|
754
762
|
}
|
|
755
763
|
});
|
|
756
764
|
}
|
|
757
|
-
var
|
|
758
|
-
function
|
|
765
|
+
var We = /^(custom-title|agent name|session title): \S/, Ge = /* @__PURE__ */ new Set(["agent renamed", "session title set"]);
|
|
766
|
+
function Ke(e, t) {
|
|
759
767
|
if (t !== "claude-code" || e.role !== "system" || (e.depth ?? 0) !== 0 || (e.toolCalls?.length ?? 0) > 0) return !1;
|
|
760
768
|
let n = (e.content ?? "").trim();
|
|
761
|
-
return n === "" || n.includes("\n") ? !1 :
|
|
769
|
+
return n === "" || n.includes("\n") ? !1 : We.test(n) || Ge.has(n);
|
|
762
770
|
}
|
|
763
|
-
function
|
|
771
|
+
function qe(t) {
|
|
764
772
|
if (t.timestamp === void 0 || t.timestamp === null || e(t.timestamp)) return t;
|
|
765
773
|
let { timestamp: n, ...r } = t;
|
|
766
774
|
return r;
|
|
767
775
|
}
|
|
768
|
-
function
|
|
769
|
-
|
|
776
|
+
function Je(e) {
|
|
777
|
+
Ue(e);
|
|
770
778
|
let t = e.filter((e) => {
|
|
771
779
|
if (Z(e)) return !0;
|
|
772
780
|
let t = !!e.content?.trim(), n = (e.toolCalls?.length ?? 0) > 0;
|
|
@@ -783,15 +791,15 @@ function qe(e) {
|
|
|
783
791
|
}
|
|
784
792
|
return n;
|
|
785
793
|
}
|
|
786
|
-
function
|
|
794
|
+
function Ye(e) {
|
|
787
795
|
if (e.role !== "assistant") return;
|
|
788
796
|
let t = i.safeParse(e.observedModel);
|
|
789
797
|
return t.success ? t.data : void 0;
|
|
790
798
|
}
|
|
791
|
-
function
|
|
799
|
+
function Xe(e, t) {
|
|
792
800
|
let n = /* @__PURE__ */ new Map(), r = typeof t == "string" && t.length > 0 ? t : void 0;
|
|
793
801
|
for (let t of e) {
|
|
794
|
-
let e = t.depth ?? 0, i =
|
|
802
|
+
let e = t.depth ?? 0, i = Ye(t);
|
|
795
803
|
if (t.role !== "assistant") {
|
|
796
804
|
n.set(t.index, {});
|
|
797
805
|
continue;
|
|
@@ -807,12 +815,12 @@ function Ye(e, t) {
|
|
|
807
815
|
}
|
|
808
816
|
return n;
|
|
809
817
|
}
|
|
810
|
-
function
|
|
818
|
+
function Ze(e) {
|
|
811
819
|
if (e.toolKind) return e.toolKind;
|
|
812
820
|
let t = e.name.toLowerCase();
|
|
813
821
|
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";
|
|
814
822
|
}
|
|
815
|
-
function
|
|
823
|
+
function Qe(e) {
|
|
816
824
|
let t = e.name.toLowerCase();
|
|
817
825
|
if (t === "read" || t === "notebookread") return "read";
|
|
818
826
|
if (t === "edit" || t === "multiedit" || t === "notebookedit" || t === "write") return "edits";
|
|
@@ -829,8 +837,8 @@ function Ze(e) {
|
|
|
829
837
|
default: return "other";
|
|
830
838
|
}
|
|
831
839
|
}
|
|
832
|
-
function
|
|
833
|
-
let t =
|
|
840
|
+
function $e(e) {
|
|
841
|
+
let t = ze(c(e.arguments)), n = e.filePath ?? (t && typeof t.file_path == "string" ? t.file_path : void 0);
|
|
834
842
|
if (n) return n;
|
|
835
843
|
if (!t) return Y(e.arguments, 80);
|
|
836
844
|
if (typeof t.command == "string") return Y(t.command, 100);
|
|
@@ -847,7 +855,7 @@ function Qe(e) {
|
|
|
847
855
|
let r = typeof t.subagent_type == "string" ? t.subagent_type : typeof t.subagent == "string" ? t.subagent : typeof t.agent == "string" ? t.agent : void 0;
|
|
848
856
|
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);
|
|
849
857
|
}
|
|
850
|
-
function
|
|
858
|
+
function et(e) {
|
|
851
859
|
let t = _(e);
|
|
852
860
|
if (t) return {
|
|
853
861
|
hunks: t.spans.map((e) => ({ lines: e })),
|
|
@@ -855,13 +863,13 @@ function $e(e) {
|
|
|
855
863
|
dels: t.dels
|
|
856
864
|
};
|
|
857
865
|
}
|
|
858
|
-
function
|
|
866
|
+
function tt(e) {
|
|
859
867
|
let t = {
|
|
860
868
|
id: e.id,
|
|
861
869
|
name: e.name,
|
|
862
|
-
kind:
|
|
863
|
-
group:
|
|
864
|
-
preview:
|
|
870
|
+
kind: Ze(e),
|
|
871
|
+
group: Qe(e),
|
|
872
|
+
preview: $e(e)
|
|
865
873
|
};
|
|
866
874
|
e.namespace !== void 0 && (t.namespace = e.namespace);
|
|
867
875
|
let n = c(e.arguments);
|
|
@@ -870,10 +878,10 @@ function et(e) {
|
|
|
870
878
|
i !== void 0 && (t.output = i);
|
|
871
879
|
let a = f(e);
|
|
872
880
|
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);
|
|
873
|
-
let o =
|
|
881
|
+
let o = et(e);
|
|
874
882
|
return o && (t.diff = o.hunks, t.adds = o.adds, t.dels = o.dels), t;
|
|
875
883
|
}
|
|
876
|
-
function
|
|
884
|
+
function nt(e) {
|
|
877
885
|
let t = e.hash, n = e.message.split("\n")[0], r = {
|
|
878
886
|
hash: t,
|
|
879
887
|
shortHash: t.slice(0, 7),
|
|
@@ -883,7 +891,7 @@ function tt(e) {
|
|
|
883
891
|
let i = "commitTime" in e ? Number(e.commitTime) : Date.parse(e.timestamp);
|
|
884
892
|
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;
|
|
885
893
|
}
|
|
886
|
-
function
|
|
894
|
+
function rt(e, t) {
|
|
887
895
|
let n = t.map((e) => ({
|
|
888
896
|
index: e.index,
|
|
889
897
|
ms: e.timestamp ? Date.parse(e.timestamp) : NaN
|
|
@@ -896,13 +904,13 @@ function nt(e, t) {
|
|
|
896
904
|
t.turn = e;
|
|
897
905
|
}
|
|
898
906
|
}
|
|
899
|
-
function
|
|
907
|
+
function it(e) {
|
|
900
908
|
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;
|
|
901
|
-
for (let e of a) o.push(
|
|
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);
|
|
902
910
|
let u = {};
|
|
903
911
|
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;
|
|
904
912
|
}
|
|
905
|
-
function
|
|
913
|
+
function at(t, n) {
|
|
906
914
|
let r = {
|
|
907
915
|
id: t.id,
|
|
908
916
|
harness: t.harness,
|
|
@@ -915,11 +923,11 @@ function it(t, n) {
|
|
|
915
923
|
turnCount: t.turnCount,
|
|
916
924
|
toolCallCount: t.toolCallCount
|
|
917
925
|
};
|
|
918
|
-
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),
|
|
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);
|
|
919
927
|
let i = t.workingDirectory ?? t.gitContext?.workingDirectory;
|
|
920
928
|
return i && (r.workingDirectory = i), t.outcome && (r.outcome = t.outcome), t.scorecard !== void 0 && (r.scorecard = t.scorecard), n && (r.git = n), r;
|
|
921
929
|
}
|
|
922
|
-
function
|
|
930
|
+
function ot(e) {
|
|
923
931
|
let t = [];
|
|
924
932
|
for (let n of e) {
|
|
925
933
|
if (n.targetEntryIndex == null) continue;
|
|
@@ -933,7 +941,7 @@ function at(e) {
|
|
|
933
941
|
}
|
|
934
942
|
return t;
|
|
935
943
|
}
|
|
936
|
-
function
|
|
944
|
+
function st(e, t) {
|
|
937
945
|
let n = {};
|
|
938
946
|
for (let t of e) {
|
|
939
947
|
let e = n[t.turn] ?? [];
|
|
@@ -945,7 +953,7 @@ function ot(e, t) {
|
|
|
945
953
|
}
|
|
946
954
|
return n;
|
|
947
955
|
}
|
|
948
|
-
function
|
|
956
|
+
function ct(e) {
|
|
949
957
|
let t = [];
|
|
950
958
|
for (let n of e) for (let e of n.toolCalls) {
|
|
951
959
|
if (!e.diff) continue;
|
|
@@ -962,7 +970,7 @@ function st(e) {
|
|
|
962
970
|
}
|
|
963
971
|
return t;
|
|
964
972
|
}
|
|
965
|
-
function
|
|
973
|
+
function lt(e) {
|
|
966
974
|
let t = /* @__PURE__ */ new Map();
|
|
967
975
|
for (let n of e) for (let e of n.toolCalls) {
|
|
968
976
|
let r = e.filePath;
|
|
@@ -987,7 +995,7 @@ function ct(e) {
|
|
|
987
995
|
for (let e of n) e.edited = e.writes + e.edits > 0;
|
|
988
996
|
return n;
|
|
989
997
|
}
|
|
990
|
-
function
|
|
998
|
+
function ut(e, t, n) {
|
|
991
999
|
let r = [], i = e.find((e) => e.role === "user" && e.content.trim() !== "");
|
|
992
1000
|
i && r.push({
|
|
993
1001
|
id: "hl-request",
|
|
@@ -1041,17 +1049,17 @@ function lt(e, t, n) {
|
|
|
1041
1049
|
title: "final response",
|
|
1042
1050
|
sub: Y(c.content, 200)
|
|
1043
1051
|
};
|
|
1044
|
-
c.tokens && (e.tokens =
|
|
1052
|
+
c.tokens && (e.tokens = Re(c.tokens.in + c.tokens.out)), r.push(e);
|
|
1045
1053
|
}
|
|
1046
1054
|
return r;
|
|
1047
1055
|
}
|
|
1048
|
-
function
|
|
1056
|
+
function dt(e) {
|
|
1049
1057
|
if (e === "error") return "errors";
|
|
1050
1058
|
if (e === "retry") return "retries";
|
|
1051
1059
|
if (e === "revert") return "re-edit";
|
|
1052
1060
|
if (e === "subagent") return "subagent";
|
|
1053
1061
|
}
|
|
1054
|
-
function
|
|
1062
|
+
function ft(e, t) {
|
|
1055
1063
|
let n = {
|
|
1056
1064
|
edits: 0,
|
|
1057
1065
|
bash: 0,
|
|
@@ -1066,7 +1074,7 @@ function dt(e, t) {
|
|
|
1066
1074
|
for (let e of Object.keys(t)) {
|
|
1067
1075
|
let n = t[e] ?? [], i = /* @__PURE__ */ new Set();
|
|
1068
1076
|
for (let e of n) {
|
|
1069
|
-
let t =
|
|
1077
|
+
let t = dt(e.kind);
|
|
1070
1078
|
t && i.add(t);
|
|
1071
1079
|
}
|
|
1072
1080
|
for (let e of i) r[e] = (r[e] ?? 0) + 1;
|
|
@@ -1079,8 +1087,8 @@ function dt(e, t) {
|
|
|
1079
1087
|
totalTurns: e.length
|
|
1080
1088
|
};
|
|
1081
1089
|
}
|
|
1082
|
-
function
|
|
1083
|
-
let a =
|
|
1090
|
+
function pt(e, t, r, i) {
|
|
1091
|
+
let a = mt(e);
|
|
1084
1092
|
if (a) try {
|
|
1085
1093
|
e = {
|
|
1086
1094
|
...n(e),
|
|
@@ -1089,20 +1097,20 @@ function ft(e, t, r, i) {
|
|
|
1089
1097
|
} catch (e) {
|
|
1090
1098
|
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 });
|
|
1091
1099
|
}
|
|
1092
|
-
let o = e.turns ?? [], { turns: s, toolCallsById: c, analytics: l, annotationsByTurn: u, filteredTurns: d } = $(e, o, e.nativeMetadata, "main", t, r, i?.visibleTurnIndices), f =
|
|
1093
|
-
f?.commits &&
|
|
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);
|
|
1094
1102
|
let p = l.phases ?? [], m = {
|
|
1095
|
-
session:
|
|
1103
|
+
session: at(e, f),
|
|
1096
1104
|
turns: s,
|
|
1097
1105
|
toolCallsById: c,
|
|
1098
|
-
diffs:
|
|
1099
|
-
files:
|
|
1100
|
-
tasks:
|
|
1101
|
-
highlights:
|
|
1102
|
-
filterIndex:
|
|
1106
|
+
diffs: ct(s),
|
|
1107
|
+
files: lt(s),
|
|
1108
|
+
tasks: Ve(l.taskGroups ?? V(d), s),
|
|
1109
|
+
highlights: ut(s, p, f),
|
|
1110
|
+
filterIndex: ft(s, u),
|
|
1103
1111
|
analytics: l
|
|
1104
1112
|
};
|
|
1105
|
-
return e.nativeMetadata && (m.nativeMetadata = e.nativeMetadata), a && (m.usageScopes =
|
|
1113
|
+
return e.nativeMetadata && (m.nativeMetadata = e.nativeMetadata), a && (m.usageScopes = G(o)), m.relationships = ht(e.relationships ?? [], i?.relationshipNavigation), m.earlierHistory = (e.earlierHistory ?? []).map((t, n) => {
|
|
1106
1114
|
let r = `earlier-${n}`, i = $(e, t.turns, t.nativeMetadata, r);
|
|
1107
1115
|
return {
|
|
1108
1116
|
id: r,
|
|
@@ -1110,11 +1118,11 @@ function ft(e, t, r, i) {
|
|
|
1110
1118
|
explanation: "ownership of this earlier history is uncertain. it is retained here, separate from current turns and input submissions.",
|
|
1111
1119
|
turns: i.turns,
|
|
1112
1120
|
nativeMetadata: t.nativeMetadata,
|
|
1113
|
-
usageScopes:
|
|
1121
|
+
usageScopes: G(t.turns)
|
|
1114
1122
|
};
|
|
1115
1123
|
}), m;
|
|
1116
1124
|
}
|
|
1117
|
-
function
|
|
1125
|
+
function mt(e) {
|
|
1118
1126
|
return e.harness === "pi" || [
|
|
1119
1127
|
"nativeMetadata",
|
|
1120
1128
|
"inputSubmissionCount",
|
|
@@ -1122,9 +1130,9 @@ function pt(e) {
|
|
|
1122
1130
|
"purpose",
|
|
1123
1131
|
"relationships",
|
|
1124
1132
|
"earlierHistory"
|
|
1125
|
-
].some((t) => X(e, t)) || !!e.turns?.some(
|
|
1133
|
+
].some((t) => X(e, t)) || !!e.turns?.some(He);
|
|
1126
1134
|
}
|
|
1127
|
-
function
|
|
1135
|
+
function ht(e, t) {
|
|
1128
1136
|
let n;
|
|
1129
1137
|
try {
|
|
1130
1138
|
n = a.array().parse(t === void 0 ? [] : t);
|
|
@@ -1153,14 +1161,14 @@ function mt(e, t) {
|
|
|
1153
1161
|
return r?.targetLocalId && r.targetLocalId === i?.targetLocalId && o.length === 2 && o[0].statusLabel === o[1].statusLabel && o[0].navigation?.localId === o[1].navigation?.localId && o[0].navigation?.transcriptId === o[1].navigation?.transcriptId ? (o[0].label = "context inherited from and started by", [o[0]]) : o;
|
|
1154
1162
|
}
|
|
1155
1163
|
function $(e, t, n, r, i, a, o) {
|
|
1156
|
-
let s =
|
|
1164
|
+
let s = Xe(t, e.model), c = (e.harness === "pi" ? t : Je(t)).filter((t) => !Ke(t, e.harness)).map(qe), l = o === void 0 ? null : new Set(o), u = l === null ? c : c.filter((e) => l.has(e.index)), d = x(u), f = e.harness, p = a ?? H(u, { scorecard: e.scorecard ?? void 0 }), m = st(p.patternAnnotations ?? [], ot(i ?? [])), h = -1;
|
|
1157
1165
|
for (let e = 0; e < u.length; e++) {
|
|
1158
1166
|
let t = u[e];
|
|
1159
1167
|
t.role === "assistant" && (t.depth ?? 0) === 0 && t.content?.trim() && (h = e);
|
|
1160
1168
|
}
|
|
1161
|
-
let g = /* @__PURE__ */ new Map(), _ = [];
|
|
1169
|
+
let g = /* @__PURE__ */ new Map(), _ = [], v = new Map(c.map((e, t) => [e, t]));
|
|
1162
1170
|
for (let e = 0; e < u.length; e++) {
|
|
1163
|
-
let t = u[e], i = (t.toolCalls ?? []).map(
|
|
1171
|
+
let t = u[e], i = (t.toolCalls ?? []).map(tt);
|
|
1164
1172
|
for (let e of i) {
|
|
1165
1173
|
e.partition = r;
|
|
1166
1174
|
let i = n?.filter((n) => n.attachment?.turnIndex === t.index && n.attachment?.toolCallId === e.id);
|
|
@@ -1168,11 +1176,16 @@ function $(e, t, n, r, i, a, o) {
|
|
|
1168
1176
|
}
|
|
1169
1177
|
for (let e of i) g.set(e.id, e);
|
|
1170
1178
|
let a = t.content ?? "", o;
|
|
1171
|
-
if (t.entryType === "thinking" && (Z(t) || a.trim() !== ""))
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1179
|
+
if (t.entryType === "thinking" && (Z(t) || a.trim() !== "")) {
|
|
1180
|
+
o = {
|
|
1181
|
+
text: a,
|
|
1182
|
+
words: Ie(a)
|
|
1183
|
+
};
|
|
1184
|
+
let e = v.get(t) ?? -1, n;
|
|
1185
|
+
for (let r = e - 1; r >= 0 && !n; r--) (c[r].depth ?? 0) === (t.depth ?? 0) && (n = c[r]);
|
|
1186
|
+
let r = Le(n, t);
|
|
1187
|
+
r !== void 0 && (o.durationMs = r), a = "";
|
|
1188
|
+
} else if (!Z(t)) {
|
|
1176
1189
|
let e = a.match(/^\s*<thinking>([\s\S]*?)<\/thinking>\s*/);
|
|
1177
1190
|
if (e) {
|
|
1178
1191
|
let t = e[1].trim();
|
|
@@ -1182,25 +1195,25 @@ function $(e, t, n, r, i, a, o) {
|
|
|
1182
1195
|
}, a = a.slice(e[0].length));
|
|
1183
1196
|
}
|
|
1184
1197
|
}
|
|
1185
|
-
let
|
|
1198
|
+
let l = t.depth ?? 0, p = t.entryType === "error" || i.some((e) => e.isError), y = {
|
|
1186
1199
|
index: t.index,
|
|
1187
1200
|
identity: `${r}:${t.sourceEntryRef || t.index}`,
|
|
1188
1201
|
partition: r,
|
|
1189
1202
|
role: t.role,
|
|
1190
1203
|
label: d[e] ?? String(e + 1),
|
|
1191
1204
|
content: a,
|
|
1192
|
-
depth:
|
|
1205
|
+
depth: l,
|
|
1193
1206
|
toolCalls: i,
|
|
1194
1207
|
annotations: m[t.index] ?? []
|
|
1195
1208
|
};
|
|
1196
|
-
|
|
1197
|
-
let
|
|
1198
|
-
|
|
1209
|
+
l === 0 && t.role === "assistant" && (y.provider = f), t.agentName && (y.agentName = t.agentName), o && (y.thinking = o);
|
|
1210
|
+
let b = Be(t.role, a, f);
|
|
1211
|
+
b !== void 0 && (y.displayContent = b), t.usage && (y.usage = t.usage), t.sourceEntryRef && (y.sourceEntryRef = t.sourceEntryRef), t.provenance && (y.provenance = t.provenance), t.entryType && (y.entryType = t.entryType), t.stopReason !== void 0 && t.stopReason !== null && (y.stopReason = t.stopReason), p && (y.isError = !0), e === h && (y.isFinal = !0), !t.usage && (t.tokensIn != null || t.tokensOut != null) && (y.tokens = {
|
|
1199
1212
|
in: t.tokensIn ?? 0,
|
|
1200
1213
|
out: t.tokensOut ?? 0
|
|
1201
|
-
}), t.timestamp && (
|
|
1202
|
-
let
|
|
1203
|
-
|
|
1214
|
+
}), t.timestamp && (y.timestamp = t.timestamp);
|
|
1215
|
+
let x = s.get(t.index);
|
|
1216
|
+
x?.effectiveModel !== void 0 && (y.effectiveModel = x.effectiveModel), x?.modelChangedFrom !== void 0 && (y.modelChangedFrom = x.modelChangedFrom), _.push(y);
|
|
1204
1217
|
}
|
|
1205
1218
|
return {
|
|
1206
1219
|
turns: _,
|
|
@@ -1211,4 +1224,4 @@ function $(e, t, n, r, i, a, o) {
|
|
|
1211
1224
|
};
|
|
1212
1225
|
}
|
|
1213
1226
|
//#endregion
|
|
1214
|
-
export { h as S,
|
|
1227
|
+
export { h as S, V as _, ke as a, D as b, De as c, U as d, S as f, ve as g, H as h, Ee as i, K as l, te as m, Ke as n, Oe as o, z as p, Je as r, J as s, pt as t, W as u, y as v, C as x, x as y };
|