@peasant-labs/fairtrade 0.0.2 → 0.0.3

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 (34) hide show
  1. package/dist/lib/base.css +7 -1
  2. package/dist/lib/components.css +1 -1
  3. package/dist/lib/types/Intensity.d.ts +3 -3
  4. package/dist/lib/types/index.d.ts +2 -0
  5. package/dist/lib/types/transcript/CheckRow.d.ts +15 -0
  6. package/dist/lib/types/transcript/DiffEntryCard.d.ts +27 -0
  7. package/dist/lib/types/transcript/FilterSection.d.ts +11 -0
  8. package/dist/lib/types/transcript/FiltersRail.d.ts +41 -0
  9. package/dist/lib/types/transcript/LabelPopover.d.ts +14 -0
  10. package/dist/lib/types/transcript/Markdown.d.ts +7 -0
  11. package/dist/lib/types/transcript/OutlineRail.d.ts +13 -0
  12. package/dist/lib/types/transcript/Scorecard.d.ts +8 -0
  13. package/dist/lib/types/transcript/Scrubber.d.ts +17 -0
  14. package/dist/lib/types/transcript/TaskBody.d.ts +8 -0
  15. package/dist/lib/types/transcript/Thinking.d.ts +9 -0
  16. package/dist/lib/types/transcript/ToolBody.d.ts +8 -0
  17. package/dist/lib/types/transcript/ToolCall.d.ts +12 -0
  18. package/dist/lib/types/transcript/TranscriptViewer.d.ts +6 -0
  19. package/dist/lib/types/transcript/TurnCard.d.ts +31 -0
  20. package/dist/lib/types/transcript/ViewSwitch.d.ts +11 -0
  21. package/dist/lib/types/transcript/adapter.d.ts +90 -0
  22. package/dist/lib/types/transcript/adapter.parse.d.ts +75 -0
  23. package/dist/lib/types/transcript/analytics.d.ts +216 -0
  24. package/dist/lib/types/transcript/graph/GraphLegend.d.ts +49 -0
  25. package/dist/lib/types/transcript/graph/GraphSubagentBranch.d.ts +24 -0
  26. package/dist/lib/types/transcript/graph/GraphToolNode.d.ts +56 -0
  27. package/dist/lib/types/transcript/graph/GraphTurnNode.d.ts +76 -0
  28. package/dist/lib/types/transcript/graph/index.d.ts +10 -0
  29. package/dist/lib/types/transcript/index.d.ts +69 -0
  30. package/dist/lib/types/transcript/state-capabilities.d.ts +161 -0
  31. package/dist/lib/types/transcript/view-model.d.ts +563 -0
  32. package/dist/lib/types/transcript/wire-types.d.ts +325 -0
  33. package/dist/lib/ui.js +4976 -1019
  34. package/package.json +7 -2
@@ -0,0 +1,563 @@
1
+ /**
2
+ * Cooked git chrome for the session header. Produced by the adapter from
3
+ * whichever wire shape is present — flat `gitBranch`/`gitRemote` OR nested
4
+ * `gitContext` (see TranscriptWireInput in wire-types.js). Absent on the model
5
+ * ⇒ the git chips are omitted entirely (clean degrade). Every field is optional
6
+ * because the real Go wire carries only branch + remote today; the rest arrive
7
+ * only via metadata.json fixtures.
8
+ *
9
+ * @typedef {object} SessionGitVM
10
+ * @property {string} [branch]
11
+ * @property {string} [remote]
12
+ * @property {string} [author] cooked from the drifted gitContext.user (TS shape); absent on the Go-flat wire (render-when-present)
13
+ * @property {CommitVM[]} [commits]
14
+ * @property {number} [filesChanged]
15
+ * @property {number} [insertions]
16
+ * @property {number} [deletions]
17
+ */
18
+ /**
19
+ * A cooked commit for the git chrome / commit chips. Mirrors CommitInfo
20
+ * (wire-types.js) with display-ready fields. The churn (`adds`/`dels`/`files`)
21
+ * and `turn` anchor are render-when-present: the canonical Go CommitInfo carries
22
+ * no churn and commits are not on the session_detail payload (the deferred
23
+ * backend follow-up), so these light up from fixtures / the drifted TS shape now
24
+ * and from the wire when that follow-up lands.
25
+ *
26
+ * @typedef {object} CommitVM
27
+ * @property {string} hash
28
+ * @property {string} shortHash abbreviated hash for the chip label
29
+ * @property {string} message first line
30
+ * @property {string} [author]
31
+ * @property {number} [commitTime] Unix millis
32
+ * @property {boolean} [session] true if produced during this session
33
+ * @property {number} [adds] insertions for the checkpoint stat (render-when-present)
34
+ * @property {number} [dels] deletions for the checkpoint stat (render-when-present)
35
+ * @property {number} [files] files changed for the checkpoint stat (render-when-present)
36
+ * @property {number} [turn] turn index this checkpoint attaches to (adapter joins commitTime→nearest turn)
37
+ */
38
+ /**
39
+ * The cooked session header / meta / outcome / scorecard, plus optional git.
40
+ * The scorecard is passed through largely as-is (the wire scorecard is already
41
+ * flat numeric signals); the analytics util derives display BANDS from it
42
+ * separately (see `scorecardBands` on the analytics block).
43
+ *
44
+ * @typedef {object} SessionVM
45
+ * @property {string} id
46
+ * @property {import('./wire-types.js').Harness} harness
47
+ * @property {string} startTime
48
+ * @property {string} endTime
49
+ * @property {number} durationMins
50
+ * @property {number} totalTokens
51
+ * @property {number} tokensIn
52
+ * @property {number} tokensOut
53
+ * @property {number} turnCount
54
+ * @property {number} toolCallCount
55
+ * @property {string} [title] editorial session title/summary (render-when-present; else the consumer derives one from the first prompt). Not a wire field — supplied by a curated consumer.
56
+ * @property {string} [project]
57
+ * @property {string} [model]
58
+ * @property {string} [workingDirectory]
59
+ * @property {import('./wire-types.js').SessionOutcome} [outcome]
60
+ * @property {import('./wire-types.js').SessionScorecard | null} [scorecard]
61
+ * @property {SessionGitVM} [git] render-when-present; never a wire field
62
+ */
63
+ /**
64
+ * A logical grouping for the filters rail, derived from `ToolCallKind`. The
65
+ * adapter classifies every tool call into exactly one group; counts roll up in
66
+ * `FilterIndexVM.toolGroupCounts`.
67
+ * @typedef {'edits' | 'bash' | 'read' | 'search' | 'fetch' | 'tasks' | 'other'} ToolGroup
68
+ */
69
+ /** Canonical ToolGroup ids, in the filters-rail display order. @type {readonly ToolGroup[]} */
70
+ export const TOOL_GROUPS: readonly ToolGroup[];
71
+ /**
72
+ * Cooked git chrome for the session header. Produced by the adapter from
73
+ * whichever wire shape is present — flat `gitBranch`/`gitRemote` OR nested
74
+ * `gitContext` (see TranscriptWireInput in wire-types.js). Absent on the model
75
+ * ⇒ the git chips are omitted entirely (clean degrade). Every field is optional
76
+ * because the real Go wire carries only branch + remote today; the rest arrive
77
+ * only via metadata.json fixtures.
78
+ */
79
+ export type SessionGitVM = {
80
+ branch?: string;
81
+ remote?: string;
82
+ /**
83
+ * cooked from the drifted gitContext.user (TS shape); absent on the Go-flat wire (render-when-present)
84
+ */
85
+ author?: string;
86
+ commits?: CommitVM[];
87
+ filesChanged?: number;
88
+ insertions?: number;
89
+ deletions?: number;
90
+ };
91
+ /**
92
+ * A cooked commit for the git chrome / commit chips. Mirrors CommitInfo
93
+ * (wire-types.js) with display-ready fields. The churn (`adds`/`dels`/`files`)
94
+ * and `turn` anchor are render-when-present: the canonical Go CommitInfo carries
95
+ * no churn and commits are not on the session_detail payload (the deferred
96
+ * backend follow-up), so these light up from fixtures / the drifted TS shape now
97
+ * and from the wire when that follow-up lands.
98
+ */
99
+ export type CommitVM = {
100
+ hash: string;
101
+ /**
102
+ * abbreviated hash for the chip label
103
+ */
104
+ shortHash: string;
105
+ /**
106
+ * first line
107
+ */
108
+ message: string;
109
+ author?: string;
110
+ /**
111
+ * Unix millis
112
+ */
113
+ commitTime?: number;
114
+ /**
115
+ * true if produced during this session
116
+ */
117
+ session?: boolean;
118
+ /**
119
+ * insertions for the checkpoint stat (render-when-present)
120
+ */
121
+ adds?: number;
122
+ /**
123
+ * deletions for the checkpoint stat (render-when-present)
124
+ */
125
+ dels?: number;
126
+ /**
127
+ * files changed for the checkpoint stat (render-when-present)
128
+ */
129
+ files?: number;
130
+ /**
131
+ * turn index this checkpoint attaches to (adapter joins commitTime→nearest turn)
132
+ */
133
+ turn?: number;
134
+ };
135
+ /**
136
+ * The cooked session header / meta / outcome / scorecard, plus optional git.
137
+ * The scorecard is passed through largely as-is (the wire scorecard is already
138
+ * flat numeric signals); the analytics util derives display BANDS from it
139
+ * separately (see `scorecardBands` on the analytics block).
140
+ */
141
+ export type SessionVM = {
142
+ id: string;
143
+ harness: import("./wire-types.js").Harness;
144
+ startTime: string;
145
+ endTime: string;
146
+ durationMins: number;
147
+ totalTokens: number;
148
+ tokensIn: number;
149
+ tokensOut: number;
150
+ turnCount: number;
151
+ toolCallCount: number;
152
+ /**
153
+ * editorial session title/summary (render-when-present; else the consumer derives one from the first prompt). Not a wire field — supplied by a curated consumer.
154
+ */
155
+ title?: string;
156
+ project?: string;
157
+ model?: string;
158
+ workingDirectory?: string;
159
+ outcome?: import("./wire-types.js").SessionOutcome;
160
+ scorecard?: import("./wire-types.js").SessionScorecard | null;
161
+ /**
162
+ * render-when-present; never a wire field
163
+ */
164
+ git?: SessionGitVM;
165
+ };
166
+ /**
167
+ * A logical grouping for the filters rail, derived from `ToolCallKind`. The
168
+ * adapter classifies every tool call into exactly one group; counts roll up in
169
+ * `FilterIndexVM.toolGroupCounts`.
170
+ */
171
+ export type ToolGroup = "edits" | "bash" | "read" | "search" | "fetch" | "tasks" | "other";
172
+ /**
173
+ * One line of a rendered diff hunk (cooked from a parsed edit/write result).
174
+ */
175
+ export type DiffLineVM = {
176
+ sign: "add" | "del" | "ctx";
177
+ /**
178
+ * old-file line number (gutter); absent for adds
179
+ */
180
+ oldNo?: string;
181
+ /**
182
+ * new-file line number (gutter); absent for dels
183
+ */
184
+ newNo?: string;
185
+ text: string;
186
+ };
187
+ /**
188
+ * A contiguous diff hunk for one file change.
189
+ */
190
+ export type DiffHunkVM = {
191
+ /**
192
+ * the hunk range header line, when present
193
+ */
194
+ header?: string;
195
+ lines: DiffLineVM[];
196
+ };
197
+ /**
198
+ * A fully cooked tool call. The adapter has ALREADY parsed the wire
199
+ * `arguments`/`result` JSON strings into `args`/`output`, derived a one-line
200
+ * `preview`, classified the `kind`/`group`, and (for edit/write) computed
201
+ * `diff`. Components render these fields directly — they NEVER JSON.parse.
202
+ */
203
+ export type ToolCallVM = {
204
+ id: string;
205
+ /**
206
+ * display name (e.g. "Read", "Bash")
207
+ */
208
+ name: string;
209
+ kind: import("./wire-types.js").ToolCallKind;
210
+ /**
211
+ * filters-rail grouping
212
+ */
213
+ group: ToolGroup;
214
+ /**
215
+ * the one-line summary shown collapsed
216
+ */
217
+ preview: string;
218
+ /**
219
+ * parsed `arguments` (shape varies by tool)
220
+ */
221
+ args?: unknown;
222
+ /**
223
+ * parsed `result` (shape varies by tool)
224
+ */
225
+ output?: unknown;
226
+ filePath?: string;
227
+ durationMs?: number;
228
+ exitCode?: number;
229
+ isError?: boolean;
230
+ /**
231
+ * present for edit/write kinds
232
+ */
233
+ diff?: DiffHunkVM[];
234
+ /**
235
+ * churn for edit/write
236
+ */
237
+ adds?: number;
238
+ dels?: number;
239
+ };
240
+ /**
241
+ * Cooked thinking content for a turn. The adapter extracts thinking from the
242
+ * folded `turn.content` (render-when-present); absent ⇒ no thinking block.
243
+ */
244
+ export type ThinkingVM = {
245
+ text: string;
246
+ /**
247
+ * precomputed word count for the toggle badge
248
+ */
249
+ words?: number;
250
+ };
251
+ /**
252
+ * One cooked turn. `toolCalls` here are the same `ToolCallVM` objects indexed in
253
+ * `toolCallsById` (shared identity — index once, reference everywhere).
254
+ */
255
+ export type TurnVM = {
256
+ index: number;
257
+ role: import("./wire-types.js").Role;
258
+ /**
259
+ * display label, e.g. "1a" / "2"
260
+ */
261
+ label: string;
262
+ /**
263
+ * markdown body (thinking already extracted)
264
+ */
265
+ content: string;
266
+ /**
267
+ * subagent nesting depth (0 = top level)
268
+ */
269
+ depth: number;
270
+ /**
271
+ * provider/role accent token name (decoration)
272
+ */
273
+ accent?: string;
274
+ /**
275
+ * subagent name when depth > 0
276
+ */
277
+ agentName?: string;
278
+ thinking?: ThinkingVM;
279
+ toolCalls: ToolCallVM[];
280
+ entryType?: import("./wire-types.js").EntryType;
281
+ stopReason?: import("./wire-types.js").StopReason | null;
282
+ isError?: boolean;
283
+ isFinal?: boolean;
284
+ tokens?: {
285
+ in: number;
286
+ out: number;
287
+ };
288
+ /**
289
+ * RFC3339 absolute time (drives commit anchoring); the visible label prefers `time`
290
+ */
291
+ timestamp?: string;
292
+ /**
293
+ * editorial display time, e.g. "8m ago" (render-when-present; else `timestamp`). Not derivable from the wire (relative to now) — a curated consumer supplies it.
294
+ */
295
+ time?: string;
296
+ /**
297
+ * editorial absolute time for the hover title (render-when-present; else `timestamp`)
298
+ */
299
+ timeTitle?: string;
300
+ /**
301
+ * annotations targeting this turn (may be empty)
302
+ */
303
+ annotations: AnnotationVM[];
304
+ };
305
+ /**
306
+ * A cooked annotation, already resolved to the turn it targets. The adapter maps
307
+ * the wire `AnnotationSummary` half-open entry range onto turn indices.
308
+ */
309
+ export type AnnotationVM = {
310
+ id: string;
311
+ /**
312
+ * e.g. "error" / "retry" / "revert" / "subagent"
313
+ */
314
+ kind: string;
315
+ /**
316
+ * target turn index
317
+ */
318
+ turn: number;
319
+ label: string;
320
+ preview?: string;
321
+ isPrimary?: boolean;
322
+ };
323
+ /**
324
+ * One file in the Files tab, with cooked churn. The adapter aggregates per-file
325
+ * reads/writes/edits/deletes across all tool calls.
326
+ */
327
+ export type FileEntryVM = {
328
+ path: string;
329
+ /**
330
+ * basename for compact display
331
+ */
332
+ leaf: string;
333
+ reads: number;
334
+ writes: number;
335
+ edits: number;
336
+ deletes: number;
337
+ /**
338
+ * total insertions
339
+ */
340
+ adds: number;
341
+ /**
342
+ * total deletions
343
+ */
344
+ dels: number;
345
+ /**
346
+ * true if writes + edits > 0
347
+ */
348
+ edited: boolean;
349
+ /**
350
+ * first turn that touched the file
351
+ */
352
+ turn?: number;
353
+ };
354
+ /**
355
+ * One diff entry in the Diffs tab — a file change with its rendered hunks.
356
+ */
357
+ export type DiffEntryVM = {
358
+ path: string;
359
+ leaf: string;
360
+ adds: number;
361
+ dels: number;
362
+ hunks: DiffHunkVM[];
363
+ /**
364
+ * turn the edit happened on
365
+ */
366
+ turn?: number;
367
+ /**
368
+ * back-reference into toolCallsById
369
+ */
370
+ toolCallId?: string;
371
+ };
372
+ /**
373
+ * One task group for the trace outline / waterfall — a user-prompt boundary plus
374
+ * its derived per-task summary. The adapter computes boundaries off the turn
375
+ * stream; the optional analytics util can enrich this further.
376
+ */
377
+ export type TaskGroupVM = {
378
+ id: string;
379
+ /**
380
+ * 1-based task number
381
+ */
382
+ index: number;
383
+ /**
384
+ * user content for the task (case preserved)
385
+ */
386
+ prompt: string;
387
+ /**
388
+ * turns belonging to this task
389
+ */
390
+ turnIndices: number[];
391
+ durationMs?: number;
392
+ /**
393
+ * tool-call count in the task
394
+ */
395
+ tools?: number;
396
+ outcome?: "ok" | "error";
397
+ /**
398
+ * short error label when outcome === 'error'
399
+ */
400
+ error?: string;
401
+ /**
402
+ * cooked churn/files summary, e.g. "2 files · +316 −25" (render-when-present)
403
+ */
404
+ stat?: string;
405
+ };
406
+ /**
407
+ * One curated key-moment for the HIGHLIGHTS tab. `vm.highlights` BACKS this tab
408
+ * directly; the tab must render non-empty from it.
409
+ */
410
+ export type HighlightVM = {
411
+ id: string;
412
+ kind: "request" | "phase" | "error" | "checkpoint" | "final" | (string & {});
413
+ /**
414
+ * turn index this highlight points at
415
+ */
416
+ turn: number;
417
+ title: string;
418
+ sub?: string;
419
+ /**
420
+ * semantic icon key (consumer maps to a glyph)
421
+ */
422
+ icon?: string;
423
+ /**
424
+ * e.g. "+312 −24 · 7 files"
425
+ */
426
+ stat?: string;
427
+ time?: string;
428
+ tokens?: string;
429
+ /**
430
+ * error styling
431
+ */
432
+ err?: boolean;
433
+ /**
434
+ * e.g. a phase id
435
+ */
436
+ tag?: string;
437
+ };
438
+ /**
439
+ * Precomputed indices the filters rail + search read, so no component recomputes
440
+ * counts or scans turns. Keyed maps are plain records (turn index / group id →
441
+ * value) for cheap, stable lookup.
442
+ */
443
+ export type FilterIndexVM = {
444
+ /**
445
+ * tool-group id → count
446
+ */
447
+ toolGroupCounts: Record<ToolGroup, number>;
448
+ /**
449
+ * turn index → annotations
450
+ */
451
+ annotationsByTurn: Record<number, AnnotationVM[]>;
452
+ /**
453
+ * semantic-tag ids present
454
+ */
455
+ tags: string[];
456
+ /**
457
+ * tag id → count
458
+ */
459
+ tagCounts: Record<string, number>;
460
+ totalTurns: number;
461
+ };
462
+ /**
463
+ * One scorecard axis band — the display verdict the analytics util derives from
464
+ * the raw `SessionScorecard` numeric signals.
465
+ */
466
+ export type ScorecardBandVM = {
467
+ /**
468
+ * axis id (e.g. token-efficiency)
469
+ */
470
+ id: string;
471
+ label: string;
472
+ band: "good" | "ok" | "watch" | "bad" | (string & {});
473
+ /**
474
+ * formatted headline value
475
+ */
476
+ value?: string;
477
+ /**
478
+ * single cooked sub-line (the lean analytics shape)
479
+ */
480
+ detail?: string;
481
+ /**
482
+ * semantic axis-icon key the consumer maps to a glyph (render-when-present)
483
+ */
484
+ icon?: string;
485
+ /**
486
+ * the per-axis flag LIST (render-when-present; richer than `detail` — a curated/backend nicety)
487
+ */
488
+ flags?: string[];
489
+ /**
490
+ * trend-vs-median delta (render-when-present)
491
+ */
492
+ delta?: {
493
+ dir: "up" | "down";
494
+ text: string;
495
+ };
496
+ };
497
+ /**
498
+ * One phase spanning a turn range, drawn as a divider in the trace.
499
+ */
500
+ export type PhaseVM = {
501
+ id: string;
502
+ label: string;
503
+ /**
504
+ * first turn index (inclusive)
505
+ */
506
+ from: number;
507
+ /**
508
+ * last turn index (inclusive)
509
+ */
510
+ to: number;
511
+ /**
512
+ * semantic icon key
513
+ */
514
+ icon?: string;
515
+ /**
516
+ * error count attributed to the phase
517
+ */
518
+ errors?: number;
519
+ };
520
+ /**
521
+ * The optional analytics block. The adapter accepts a precomputed
522
+ * `TranscriptAnalytics` (produced separately) OR derives it; when no
523
+ * analytics are available the WHOLE block is absent and every analytics-fed
524
+ * surface degrades cleanly. Each field is independently optional.
525
+ */
526
+ export type TranscriptAnalyticsVM = {
527
+ phases?: PhaseVM[];
528
+ scorecardBands?: ScorecardBandVM[];
529
+ /**
530
+ * detected patterns (errors/retries/reverts/subagents)
531
+ */
532
+ patternAnnotations?: AnnotationVM[];
533
+ /**
534
+ * analytics-enriched task grouping
535
+ */
536
+ taskGroups?: TaskGroupVM[];
537
+ };
538
+ /**
539
+ * The cooked transcript view model — the adapter's sole output and every
540
+ * component's prop contract. `analytics` and the git cluster are the only
541
+ * render-when-present pieces; everything else is always populated (possibly with
542
+ * empty arrays) so components never branch on existence for the core surfaces.
543
+ */
544
+ export type TranscriptViewModel = {
545
+ session: SessionVM;
546
+ turns: TurnVM[];
547
+ /**
548
+ * parsed once; turns reference the same objects
549
+ */
550
+ toolCallsById: Map<string, ToolCallVM>;
551
+ diffs: DiffEntryVM[];
552
+ files: FileEntryVM[];
553
+ tasks: TaskGroupVM[];
554
+ /**
555
+ * BACKS the HIGHLIGHTS tab (non-empty when present)
556
+ */
557
+ highlights: HighlightVM[];
558
+ filterIndex: FilterIndexVM;
559
+ /**
560
+ * render-when-present
561
+ */
562
+ analytics?: TranscriptAnalyticsVM;
563
+ };