@peasant-labs/fairtrade 0.0.2 → 0.0.4

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 (67) hide show
  1. package/dist/lib/ChartLine-Dlp6-CLL.js +264 -0
  2. package/dist/lib/InUseShell-DZvmRdj-.js +1532 -0
  3. package/dist/lib/analytics.css +1 -0
  4. package/dist/lib/analytics.js +1052 -0
  5. package/dist/lib/base.css +7 -1
  6. package/dist/lib/commons.css +1 -0
  7. package/dist/lib/commons.js +3275 -0
  8. package/dist/lib/components.css +1 -1
  9. package/dist/lib/graph.css +1 -0
  10. package/dist/lib/graph.js +823 -0
  11. package/dist/lib/types/Intensity.d.ts +3 -3
  12. package/dist/lib/types/MapCanvas.d.ts +37 -5
  13. package/dist/lib/types/RoleRoster.d.ts +12 -1
  14. package/dist/lib/types/analytics/ChartCard.d.ts +18 -0
  15. package/dist/lib/types/analytics/ContributorTable.d.ts +16 -0
  16. package/dist/lib/types/analytics/ProjectOverview.d.ts +40 -0
  17. package/dist/lib/types/analytics/format.d.ts +48 -0
  18. package/dist/lib/types/analytics/index.d.ts +24 -0
  19. package/dist/lib/types/analytics/metrics.d.ts +130 -0
  20. package/dist/lib/types/analytics/stats.d.ts +23 -0
  21. package/dist/lib/types/analytics/time.d.ts +32 -0
  22. package/dist/lib/types/analytics/types.d.ts +453 -0
  23. package/dist/lib/types/commons/Explore.d.ts +6 -0
  24. package/dist/lib/types/commons/Manage.d.ts +34 -0
  25. package/dist/lib/types/commons/index.d.ts +24 -0
  26. package/dist/lib/types/commons/providers.d.ts +8 -0
  27. package/dist/lib/types/commons/types.d.ts +356 -0
  28. package/dist/lib/types/graph/ChangeDetail.d.ts +28 -0
  29. package/dist/lib/types/graph/Changes.d.ts +21 -0
  30. package/dist/lib/types/graph/CodeMap.d.ts +49 -0
  31. package/dist/lib/types/graph/CodeMapComposition.d.ts +85 -0
  32. package/dist/lib/types/graph/changeGraph.d.ts +106 -0
  33. package/dist/lib/types/graph/index.d.ts +30 -0
  34. package/dist/lib/types/graph/types.d.ts +579 -0
  35. package/dist/lib/types/index.d.ts +3 -0
  36. package/dist/lib/types/inuse/InUseShell.d.ts +50 -0
  37. package/dist/lib/types/transcript/CheckRow.d.ts +15 -0
  38. package/dist/lib/types/transcript/DiffEntryCard.d.ts +27 -0
  39. package/dist/lib/types/transcript/FilterSection.d.ts +11 -0
  40. package/dist/lib/types/transcript/FiltersRail.d.ts +41 -0
  41. package/dist/lib/types/transcript/LabelPopover.d.ts +14 -0
  42. package/dist/lib/types/transcript/Markdown.d.ts +7 -0
  43. package/dist/lib/types/transcript/OutlineRail.d.ts +13 -0
  44. package/dist/lib/types/transcript/Scorecard.d.ts +8 -0
  45. package/dist/lib/types/transcript/Scrubber.d.ts +17 -0
  46. package/dist/lib/types/transcript/TaskBody.d.ts +8 -0
  47. package/dist/lib/types/transcript/Thinking.d.ts +9 -0
  48. package/dist/lib/types/transcript/ToolBody.d.ts +8 -0
  49. package/dist/lib/types/transcript/ToolCall.d.ts +12 -0
  50. package/dist/lib/types/transcript/TranscriptViewer.d.ts +6 -0
  51. package/dist/lib/types/transcript/TurnCard.d.ts +31 -0
  52. package/dist/lib/types/transcript/ViewSwitch.d.ts +11 -0
  53. package/dist/lib/types/transcript/adapter.d.ts +90 -0
  54. package/dist/lib/types/transcript/adapter.parse.d.ts +75 -0
  55. package/dist/lib/types/transcript/analytics.d.ts +216 -0
  56. package/dist/lib/types/transcript/graph/GraphLegend.d.ts +49 -0
  57. package/dist/lib/types/transcript/graph/GraphSubagentBranch.d.ts +24 -0
  58. package/dist/lib/types/transcript/graph/GraphToolNode.d.ts +56 -0
  59. package/dist/lib/types/transcript/graph/GraphTurnNode.d.ts +76 -0
  60. package/dist/lib/types/transcript/graph/index.d.ts +10 -0
  61. package/dist/lib/types/transcript/index.d.ts +69 -0
  62. package/dist/lib/types/transcript/state-capabilities.d.ts +161 -0
  63. package/dist/lib/types/transcript/view-model.d.ts +563 -0
  64. package/dist/lib/types/transcript/wire-types.d.ts +325 -0
  65. package/dist/lib/ui-oBFnHPFe.js +11146 -0
  66. package/dist/lib/ui.js +4 -8736
  67. package/package.json +42 -6
@@ -0,0 +1,41 @@
1
+ export default function FiltersRail({ tab, filters, onFiltersChange, counts, checkpoints, filtersActive, onClear, onJumpStart, onJumpLatest, }: {
2
+ tab: any;
3
+ filters?: {
4
+ categories: {
5
+ prompts: boolean;
6
+ responses: boolean;
7
+ thinking: boolean;
8
+ toolcalls: boolean;
9
+ };
10
+ toolGroups: {};
11
+ tags: {
12
+ errors: boolean;
13
+ retries: boolean;
14
+ revert: boolean;
15
+ };
16
+ views: {
17
+ hidden: boolean;
18
+ expandAll: boolean;
19
+ compact: boolean;
20
+ };
21
+ checkpoint: string;
22
+ };
23
+ onFiltersChange?: () => void;
24
+ counts?: {
25
+ categories: {
26
+ prompts: number;
27
+ responses: number;
28
+ thinking: number;
29
+ toolcalls: number;
30
+ };
31
+ toolGroups: {};
32
+ };
33
+ checkpoints?: any[];
34
+ filtersActive?: number;
35
+ onClear?: () => void;
36
+ onJumpStart?: () => void;
37
+ onJumpLatest?: () => void;
38
+ }): any;
39
+ export type TranscriptFilters = import("./state-capabilities.js").TranscriptFilters;
40
+ export type ToolGroup = import("./view-model.js").ToolGroup;
41
+ export type CommitVM = import("./view-model.js").CommitVM;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {number} [props.turnId] the turn index being labelled
4
+ * @param {SavedLabel} [props.current] the existing label, if any
5
+ * @param {(outcome: SavedLabel['outcome'], flag: string) => void} [props.onSave]
6
+ * @param {Function} [props.onClose]
7
+ */
8
+ export default function LabelPopover({ turnId, current, onSave, onClose }: {
9
+ turnId?: number;
10
+ current?: SavedLabel;
11
+ onSave?: (outcome: SavedLabel["outcome"], flag: string) => void;
12
+ onClose?: Function;
13
+ }): any;
14
+ export type SavedLabel = import("./state-capabilities.js").SavedLabel;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {string} [props.text] the cooked markdown body (e.g. `TurnVM.content`)
4
+ */
5
+ export default function Markdown({ text }: {
6
+ text?: string;
7
+ }): any;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {TranscriptViewModel} props.viewModel
4
+ * @param {import('./state-capabilities.js').TranscriptTab} props.tab
5
+ * @param {(turnIndex: number) => void} [props.onJump]
6
+ */
7
+ export default function OutlineRail({ viewModel, tab, onJump }: {
8
+ viewModel: TranscriptViewModel;
9
+ tab: import("./state-capabilities.js").TranscriptTab;
10
+ onJump?: (turnIndex: number) => void;
11
+ }): any;
12
+ export type TranscriptViewModel = import("./view-model.js").TranscriptViewModel;
13
+ export type AnnotationVM = import("./view-model.js").AnnotationVM;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {ScorecardBandVM[]} [props.bands] the cooked scorecard bands (vm.analytics.scorecardBands)
4
+ */
5
+ export default function Scorecard({ bands }: {
6
+ bands?: ScorecardBandVM[];
7
+ }): any;
8
+ export type ScorecardBandVM = import("./view-model.js").ScorecardBandVM;
@@ -0,0 +1,17 @@
1
+ /** @typedef {import('./view-model.js').TurnVM} TurnVM */
2
+ /**
3
+ * @param {object} props
4
+ * @param {TurnVM[]} [props.turns]
5
+ * @param {number} [props.active] the active TURN INDEX (TurnVM.index)
6
+ * @param {(clientX: number, track: HTMLElement) => void} [props.onSeek]
7
+ * @param {{ current: boolean }} [props.draggingRef] shared drag latch; defaults to an internal ref
8
+ */
9
+ export default function Scrubber({ turns, active, onSeek, draggingRef }: {
10
+ turns?: TurnVM[];
11
+ active?: number;
12
+ onSeek?: (clientX: number, track: HTMLElement) => void;
13
+ draggingRef?: {
14
+ current: boolean;
15
+ };
16
+ }): any;
17
+ export type TurnVM = import("./view-model.js").TurnVM;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {ToolCallVM} [props.tool]
4
+ */
5
+ export default function TaskBody({ tool }: {
6
+ tool?: ToolCallVM;
7
+ }): any;
8
+ export type ToolCallVM = import("./view-model.js").ToolCallVM;
@@ -0,0 +1,9 @@
1
+ /** @typedef {import('./view-model.js').ThinkingVM} ThinkingVM */
2
+ /**
3
+ * @param {object} props
4
+ * @param {ThinkingVM} [props.block] cooked thinking (e.g. `TurnVM.thinking`)
5
+ */
6
+ export default function Thinking({ block }: {
7
+ block?: ThinkingVM;
8
+ }): any;
9
+ export type ThinkingVM = import("./view-model.js").ThinkingVM;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {ToolCallVM} [props.tool]
4
+ */
5
+ export default function ToolBody({ tool }: {
6
+ tool?: ToolCallVM;
7
+ }): any;
8
+ export type ToolCallVM = import("./view-model.js").ToolCallVM;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {ToolCallVM} [props.tool]
4
+ * @param {boolean} [props.open]
5
+ * @param {() => void} [props.onToggle]
6
+ */
7
+ export default function ToolCall({ tool, open, onToggle }: {
8
+ tool?: ToolCallVM;
9
+ open?: boolean;
10
+ onToggle?: () => void;
11
+ }): any;
12
+ export type ToolCallVM = import("./view-model.js").ToolCallVM;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {TranscriptViewerProps} props
3
+ */
4
+ export default function TranscriptViewer({ viewModel, capabilities, callbacks, theme: themeProp, onThemeChange, graphSlot, activeTab: activeTabProp, onTabChange, viewMode: viewModeProp, onViewModeChange, leftRailOpen: leftRailOpenProp, onLeftRailOpenChange, rightRailOpen: rightRailOpenProp, onRightRailOpenChange, openTools: openToolsProp, onOpenToolsChange, activeTurn: activeTurnProp, onActiveTurnChange, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, savedLabels: savedLabelsProp, onSavedLabelsChange, shareOpen: shareOpenProp, onShareOpenChange, moreOpen: moreOpenProp, onMoreOpenChange, }: TranscriptViewerProps): any;
5
+ export type TranscriptViewerProps = import("./state-capabilities.js").TranscriptViewerProps;
6
+ export type TranscriptFilters = import("./state-capabilities.js").TranscriptFilters;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {TurnVM} [props.turn]
4
+ * @param {boolean} [props.active]
5
+ * @param {Record<string, boolean>} [props.openTools] tool id → open?
6
+ * @param {(id: string) => void} [props.toggleTool]
7
+ * @param {(turnIndex: number) => void} [props.onCopyAnchor]
8
+ * @param {boolean} [props.copied]
9
+ * @param {(turnIndex: number, el: HTMLElement | null) => void} [props.registerRef]
10
+ * @param {(turnIndex: number) => void} [props.onLabel] omit to hide the "label" affordance
11
+ * @param {{ outcome: string, flag?: string }} [props.savedLabel]
12
+ * @param {boolean} [props.compact]
13
+ * @param {boolean} [props.expandAll]
14
+ */
15
+ export default function TurnCard({ turn, active, openTools, toggleTool, onCopyAnchor, copied, registerRef, onLabel, savedLabel, compact, expandAll, }: {
16
+ turn?: TurnVM;
17
+ active?: boolean;
18
+ openTools?: Record<string, boolean>;
19
+ toggleTool?: (id: string) => void;
20
+ onCopyAnchor?: (turnIndex: number) => void;
21
+ copied?: boolean;
22
+ registerRef?: (turnIndex: number, el: HTMLElement | null) => void;
23
+ onLabel?: (turnIndex: number) => void;
24
+ savedLabel?: {
25
+ outcome: string;
26
+ flag?: string;
27
+ };
28
+ compact?: boolean;
29
+ expandAll?: boolean;
30
+ }): any;
31
+ export type TurnVM = import("./view-model.js").TurnVM;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @param {object} props
3
+ * @param {string} [props.label] the switch label + its accessible name
4
+ * @param {boolean} [props.on]
5
+ * @param {Function} [props.onToggle]
6
+ */
7
+ export default function ViewSwitch({ label, on, onToggle }: {
8
+ label?: string;
9
+ on?: boolean;
10
+ onToggle?: Function;
11
+ }): any;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Default turn prefilter the adapter applies to `payload.turns`: drop turns with
3
+ * neither content nor tool calls (and short tool-less system banners), then
4
+ * collapse adjacent same-role turns with identical content (a streaming
5
+ * artifact), preferring the tool-bearing copy. Pure, order-preserving. Exported
6
+ * so a host that pre-scopes turns can run the SAME filter.
7
+ * @param {TurnDetail[]} turns
8
+ * @returns {TurnDetail[]}
9
+ */
10
+ export function prefilterTurns(turns: TurnDetail[]): TurnDetail[];
11
+ /**
12
+ * Dependency-free line diff (LCS) → cooked `DiffLineVM[]`. fairtrade ships no
13
+ * `diff` package, so the adapter computes hunks itself. Line numbers are 1-based
14
+ * within the supplied snippet (the wire carries the edit snippet, not the file
15
+ * offset). Deterministic — no clock/randomness — so it is screenshot-stable.
16
+ * @param {string} oldText
17
+ * @param {string} newText
18
+ * @returns {DiffLineVM[]}
19
+ */
20
+ export function diffLines(oldText: string, newText: string): DiffLineVM[];
21
+ /**
22
+ * Project the canonical wire payload (folded turns) into the cooked
23
+ * `TranscriptViewModel` every dumb transcript component renders. The SOLE
24
+ * wire-parse + git-drift normalisation site.
25
+ *
26
+ * @param {TranscriptWireInput} payload canonical wire; tolerates both git shapes
27
+ * @param {AnnotationSummary[]} [annotations] separately-fetched entry annotations
28
+ * @param {TranscriptAnalyticsVM} [analytics] precomputed analytics; else derived on demand
29
+ * @returns {TranscriptViewModel}
30
+ */
31
+ export function adaptTranscript(payload: TranscriptWireInput, annotations?: AnnotationSummary[], analytics?: TranscriptAnalyticsVM): TranscriptViewModel;
32
+ export type TranscriptWireInput = import("./wire-types.js").TranscriptWireInput;
33
+ export type SessionDetailPayload = import("./wire-types.js").SessionDetailPayload;
34
+ export type TurnDetail = import("./wire-types.js").TurnDetail;
35
+ export type ToolCallDetail = import("./wire-types.js").ToolCallDetail;
36
+ export type AnnotationSummary = import("./wire-types.js").AnnotationSummary;
37
+ export type TranscriptViewModel = import("./view-model.js").TranscriptViewModel;
38
+ export type TranscriptAnalyticsVM = import("./view-model.js").TranscriptAnalyticsVM;
39
+ export type SessionVM = import("./view-model.js").SessionVM;
40
+ export type SessionGitVM = import("./view-model.js").SessionGitVM;
41
+ export type CommitVM = import("./view-model.js").CommitVM;
42
+ export type TurnVM = import("./view-model.js").TurnVM;
43
+ export type ToolCallVM = import("./view-model.js").ToolCallVM;
44
+ export type ToolGroup = import("./view-model.js").ToolGroup;
45
+ export type DiffLineVM = import("./view-model.js").DiffLineVM;
46
+ export type DiffHunkVM = import("./view-model.js").DiffHunkVM;
47
+ export type DiffEntryVM = import("./view-model.js").DiffEntryVM;
48
+ export type FileEntryVM = import("./view-model.js").FileEntryVM;
49
+ export type AnnotationVM = import("./view-model.js").AnnotationVM;
50
+ export type HighlightVM = import("./view-model.js").HighlightVM;
51
+ export type FilterIndexVM = import("./view-model.js").FilterIndexVM;
52
+ export type PhaseVM = import("./view-model.js").PhaseVM;
53
+ export type WireGitLike = {
54
+ branch?: string | null;
55
+ remote?: string | null;
56
+ /**
57
+ * TS-drift author (transcript.ts)
58
+ */
59
+ user?: string;
60
+ commits?: unknown[];
61
+ };
62
+ export type WireCommitLike = {
63
+ hash?: string;
64
+ message?: string;
65
+ /**
66
+ * Go shape (metadata.go)
67
+ */
68
+ authorName?: string;
69
+ /**
70
+ * Go shape, Unix millis
71
+ */
72
+ commitTime?: number;
73
+ /**
74
+ * TS-drift shape (transcript.ts)
75
+ */
76
+ timestamp?: string;
77
+ /**
78
+ * TS-drift per-commit churn
79
+ */
80
+ filesChanged?: number;
81
+ /**
82
+ * TS-drift per-commit churn
83
+ */
84
+ insertions?: number;
85
+ /**
86
+ * TS-drift per-commit churn
87
+ */
88
+ deletions?: number;
89
+ session?: boolean;
90
+ };
@@ -0,0 +1,75 @@
1
+ /** @typedef {import('./wire-types.js').ToolCallDetail} ToolCallDetail */
2
+ /**
3
+ * The SOLE `JSON.parse` of a wire-encoded tool string in the lifted code. Every
4
+ * other parse helper here, the adapter, and the analytics util route through it,
5
+ * so a grep for `JSON.parse` of tool args/result yields exactly one hit. Returns
6
+ * `undefined` for empty or malformed input — callers degrade rather than throw.
7
+ *
8
+ * @param {string | undefined | null} raw
9
+ * @returns {unknown}
10
+ */
11
+ export function parseJson(raw: string | undefined | null): unknown;
12
+ /**
13
+ * Parse a tool call's `arguments` JSON string. Thin named entry point over the
14
+ * one `parseJson` site; the cooked `ToolCallVM.args` is this value (shape varies
15
+ * by tool, hence `unknown`).
16
+ * @param {string | undefined | null} raw
17
+ * @returns {unknown}
18
+ */
19
+ export function parseArgs(raw: string | undefined | null): unknown;
20
+ /**
21
+ * Parse a tool call's `result` JSON string. Thin named entry point over the one
22
+ * `parseJson` site; the cooked `ToolCallVM.output` is this value.
23
+ * @param {string | undefined | null} raw
24
+ * @returns {unknown}
25
+ */
26
+ export function parseResult(raw: string | undefined | null): unknown;
27
+ /**
28
+ * Extract the file path a tool call targets, preferring the wire `filePath`
29
+ * field and falling back to the common `file_path` / `path` / `notebook_path`
30
+ * argument keys. Consolidates the THREE duplicate `extractPath` definitions
31
+ * (tasks.ts, FilesView.tsx, file-rollup.ts) into one.
32
+ * @param {ToolCallDetail} call
33
+ * @returns {string | undefined}
34
+ */
35
+ export function extractPath(call: ToolCallDetail): string | undefined;
36
+ /**
37
+ * One old→new replacement inside an Edit / MultiEdit / NotebookEdit call.
38
+ * @typedef {object} EditPair
39
+ * @property {string} old_string
40
+ * @property {string} new_string
41
+ */
42
+ /**
43
+ * The list of old→new replacements for an edit-family tool call: the `edits[]`
44
+ * array for MultiEdit, else the single `old_string` / `new_string` pair. Used by
45
+ * BOTH the diff-hunk builder (adapter) and the churn counter (`countDiff`), so
46
+ * the argument shape is parsed in exactly one place.
47
+ * @param {ToolCallDetail} call
48
+ * @returns {EditPair[]}
49
+ */
50
+ export function editPairs(call: ToolCallDetail): EditPair[];
51
+ /**
52
+ * The full-file body a Write tool call lays down (its `content` argument).
53
+ * @param {ToolCallDetail} call
54
+ * @returns {string}
55
+ */
56
+ export function writeContent(call: ToolCallDetail): string;
57
+ /**
58
+ * Lines inserted / removed for an edit-family or write tool call. Consolidates
59
+ * the THREE duplicate `countDiff` definitions. Pure: depends only on the parsed
60
+ * arguments, never a clock or the file system.
61
+ * @param {ToolCallDetail} call
62
+ * @returns {{ adds: number, dels: number }}
63
+ */
64
+ export function countDiff(call: ToolCallDetail): {
65
+ adds: number;
66
+ dels: number;
67
+ };
68
+ export type ToolCallDetail = import("./wire-types.js").ToolCallDetail;
69
+ /**
70
+ * One old→new replacement inside an Edit / MultiEdit / NotebookEdit call.
71
+ */
72
+ export type EditPair = {
73
+ old_string: string;
74
+ new_string: string;
75
+ };
@@ -0,0 +1,216 @@
1
+ /** @typedef {import('./wire-types.js').TurnDetail} TurnDetail */
2
+ /** @typedef {import('./wire-types.js').ToolCallDetail} ToolCallDetail */
3
+ /** @typedef {import('./wire-types.js').SessionScorecard} SessionScorecard */
4
+ /** @typedef {import('./view-model.js').PhaseVM} PhaseVM */
5
+ /** @typedef {import('./view-model.js').ScorecardBandVM} ScorecardBandVM */
6
+ /** @typedef {import('./view-model.js').AnnotationVM} AnnotationVM */
7
+ /** @typedef {import('./view-model.js').TaskGroupVM} TaskGroupVM */
8
+ /** @typedef {import('./view-model.js').TranscriptAnalyticsVM} TranscriptAnalyticsVM */
9
+ /**
10
+ * A "task" is the span from a top-level user prompt up to (but not including)
11
+ * the next one — one turn of human↔agent collaboration. The shape is the
12
+ * canonical `TaskGroup` the transcript-browser already exports, kept stable for
13
+ * back-compat re-export.
14
+ * @typedef {object} TaskGroup
15
+ * @property {number} startIndex display position of the starting prompt
16
+ * @property {number} endIndex display position of the last turn (inclusive)
17
+ * @property {number} promptEntryIndex wire entry index of the prompt (anchor)
18
+ * @property {number} [finalEntryIndex] wire entry index of the final assistant turn
19
+ * @property {string} prompt untruncated user prompt
20
+ * @property {number} toolCallCount
21
+ * @property {string[]} filesTouched
22
+ * @property {number} insertions
23
+ * @property {number} deletions
24
+ * @property {number} durationMs
25
+ * @property {boolean} hasErrors
26
+ * @property {number} tokens
27
+ */
28
+ /**
29
+ * Split a turn list into task groups. Each top-level (depth-0) user turn starts
30
+ * a new task; depth-1+ user turns are content blocks, NOT boundaries. A session
31
+ * that starts without a user prompt is a single task spanning everything.
32
+ * @param {TurnDetail[]} turns
33
+ * @returns {TaskGroup[]}
34
+ */
35
+ export function computeTasks(turns: TurnDetail[]): TaskGroup[];
36
+ /**
37
+ * Per-turn display labels: `"1"`, `"2"` for the prompts that open a task, and
38
+ * `"2a"`, `"2b"` for the follow-ups within it.
39
+ * @param {TurnDetail[]} turns
40
+ * @returns {string[]}
41
+ */
42
+ export function computeTurnLabels(turns: TurnDetail[]): string[];
43
+ /**
44
+ * One segment of the proportional task waterfall: a task's share of the total
45
+ * work time and the cumulative share before it (segments tile back-to-back).
46
+ * @typedef {object} WaterfallSegment
47
+ * @property {number} promptEntryIndex
48
+ * @property {number} offsetPct
49
+ * @property {number} widthPct
50
+ * @property {number} durationMs
51
+ */
52
+ /**
53
+ * Turn task groups into a relative-duration lane. When the total duration is 0
54
+ * (untimed transcript) every segment is zero-width at offset 0 — the caller
55
+ * renders the task list without bars rather than dividing by zero.
56
+ * @param {TaskGroup[]} tasks
57
+ * @returns {WaterfallSegment[]}
58
+ */
59
+ export function buildTaskWaterfall(tasks: TaskGroup[]): WaterfallSegment[];
60
+ /**
61
+ * Walk a transcript and surface error / retry / revert / subagent moments,
62
+ * sorted by display position.
63
+ * @param {TurnDetail[]} turns
64
+ * @returns {TranscriptAnnotation[]}
65
+ */
66
+ export function annotateTranscript(turns: TurnDetail[]): TranscriptAnnotation[];
67
+ /** Display label for a phase type, falling back to the raw value. @param {string} type @returns {string} */
68
+ export function phaseLabel(type: string): string;
69
+ /**
70
+ * Segment a transcript into rendered phases. `from` / `to` are WIRE turn indices
71
+ * (matching `TurnVM.index`), so a divider component can anchor by them directly.
72
+ * @param {TurnDetail[]} turns
73
+ * @returns {PhaseVM[]}
74
+ */
75
+ export function detectPhases(turns: TurnDetail[]): PhaseVM[];
76
+ /**
77
+ * Per-metric medians across the user's sessions, each field undefined when the
78
+ * sample yields no value (so the comparison line degrades rather than fabricate
79
+ * a baseline). The host supplies the sessions; the viewer never fetches them.
80
+ * @param {PersonalMedianSession[] | undefined} sessions
81
+ * @returns {PersonalMedians}
82
+ */
83
+ export function computePersonalMedians(sessions: PersonalMedianSession[] | undefined): PersonalMedians;
84
+ /**
85
+ * Derive the three scorecard axis verdict bands (token / prompt / loop
86
+ * efficiency) from the raw numeric signals. Returns `[]` when the scorecard
87
+ * carries no usable signal, so the card is omitted cleanly.
88
+ * @param {SessionScorecard | null | undefined} sc
89
+ * @param {PersonalMedians} [medians]
90
+ * @returns {ScorecardBandVM[]}
91
+ */
92
+ export function assessScorecard(sc: SessionScorecard | null | undefined, medians?: PersonalMedians): ScorecardBandVM[];
93
+ /**
94
+ * The cooked task groups for a turn list (`computeTasks` mapped onto
95
+ * `TaskGroupVM`). Exported so the adapter can populate the always-present
96
+ * `vm.tasks` from the same single computation `computeAnalytics` uses.
97
+ * @param {TurnDetail[]} turns
98
+ * @returns {TaskGroupVM[]}
99
+ */
100
+ export function computeTaskGroups(turns: TurnDetail[]): TaskGroupVM[];
101
+ /**
102
+ * Compute the cooked single-session analytics block from a (prefiltered) turn
103
+ * list. Each field is omitted when empty so the block is genuinely
104
+ * render-when-present. The adapter calls this on demand when no precomputed
105
+ * analytics is supplied, and reuses the returned `patternAnnotations` /
106
+ * `taskGroups` so nothing is derived twice.
107
+ * @param {TurnDetail[]} turns
108
+ * @param {{ scorecard?: SessionScorecard | null, medians?: PersonalMedians }} [opts]
109
+ * @returns {TranscriptAnalyticsVM}
110
+ */
111
+ export function computeAnalytics(turns: TurnDetail[], opts?: {
112
+ scorecard?: SessionScorecard | null;
113
+ medians?: PersonalMedians;
114
+ }): TranscriptAnalyticsVM;
115
+ export type TurnDetail = import("./wire-types.js").TurnDetail;
116
+ export type ToolCallDetail = import("./wire-types.js").ToolCallDetail;
117
+ export type SessionScorecard = import("./wire-types.js").SessionScorecard;
118
+ export type PhaseVM = import("./view-model.js").PhaseVM;
119
+ export type ScorecardBandVM = import("./view-model.js").ScorecardBandVM;
120
+ export type AnnotationVM = import("./view-model.js").AnnotationVM;
121
+ export type TaskGroupVM = import("./view-model.js").TaskGroupVM;
122
+ export type TranscriptAnalyticsVM = import("./view-model.js").TranscriptAnalyticsVM;
123
+ /**
124
+ * A "task" is the span from a top-level user prompt up to (but not including)
125
+ * the next one — one turn of human↔agent collaboration. The shape is the
126
+ * canonical `TaskGroup` the transcript-browser already exports, kept stable for
127
+ * back-compat re-export.
128
+ */
129
+ export type TaskGroup = {
130
+ /**
131
+ * display position of the starting prompt
132
+ */
133
+ startIndex: number;
134
+ /**
135
+ * display position of the last turn (inclusive)
136
+ */
137
+ endIndex: number;
138
+ /**
139
+ * wire entry index of the prompt (anchor)
140
+ */
141
+ promptEntryIndex: number;
142
+ /**
143
+ * wire entry index of the final assistant turn
144
+ */
145
+ finalEntryIndex?: number;
146
+ /**
147
+ * untruncated user prompt
148
+ */
149
+ prompt: string;
150
+ toolCallCount: number;
151
+ filesTouched: string[];
152
+ insertions: number;
153
+ deletions: number;
154
+ durationMs: number;
155
+ hasErrors: boolean;
156
+ tokens: number;
157
+ };
158
+ /**
159
+ * One segment of the proportional task waterfall: a task's share of the total
160
+ * work time and the cumulative share before it (segments tile back-to-back).
161
+ */
162
+ export type WaterfallSegment = {
163
+ promptEntryIndex: number;
164
+ offsetPct: number;
165
+ widthPct: number;
166
+ durationMs: number;
167
+ };
168
+ export type FailedAttempt = {
169
+ tools: string[];
170
+ turnRange: [number, number];
171
+ };
172
+ export type PersonalMedians = {
173
+ retryShare?: number;
174
+ specQualityScore?: number;
175
+ withinSessionReverts?: number;
176
+ };
177
+ /**
178
+ * A session sample for personal-median computation — the QualitySession subset
179
+ * the medians read. Kept structural so the transcript-browser `QualitySession`
180
+ * is assignable for back-compat.
181
+ */
182
+ export type PersonalMedianSession = {
183
+ totalTokens: number;
184
+ retryTokensWasted: number;
185
+ specQualityScore: number;
186
+ withinSessionReverts: number;
187
+ };
188
+ /**
189
+ * A client-side detected pattern moment. Canonical `TranscriptAnnotation` shape
190
+ * kept stable for back-compat re-export.
191
+ */
192
+ export type TranscriptAnnotation = {
193
+ /**
194
+ * display position
195
+ */
196
+ turnIndex: number;
197
+ type: "retry" | "error" | "revert" | "subagent";
198
+ label: string;
199
+ severity: "info" | "warning" | "error";
200
+ };
201
+ export type PhaseType = "planning" | "exploration" | "implementation" | "testing" | "error" | "debug" | "retry-loop" | "user-correction" | "recovery" | "abandonment";
202
+ export type PhaseSegment = {
203
+ type: PhaseType;
204
+ /**
205
+ * display position (inclusive)
206
+ */
207
+ startTurn: number;
208
+ /**
209
+ * display position (inclusive)
210
+ */
211
+ endTurn: number;
212
+ badges: {
213
+ type: PhaseType;
214
+ count: number;
215
+ }[];
216
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The trajectory-graph legend visual.
3
+ * @param {GraphLegendProps} props
4
+ * @returns {JSX.Element}
5
+ */
6
+ export function GraphLegend({ items, className }: GraphLegendProps): JSX.Element;
7
+ /**
8
+ * One legend entry.
9
+ * @typedef {object} GraphLegendItem
10
+ * @property {'user' | 'assistant' | 'subagent' | 'tool' | 'error' | (string & {})} kind
11
+ * the node kind this swatch stands for; selects the accent
12
+ * @property {string} label the lowercase word shown beside the swatch
13
+ * @property {string} [provider] harness key → assistant swatch accent
14
+ */
15
+ /**
16
+ * @typedef {object} GraphLegendProps
17
+ * @property {GraphLegendItem[]} [items] legend entries (defaults to GRAPH_LEGEND_ITEMS)
18
+ * @property {string} [className]
19
+ */
20
+ /** The canonical legend set, in display order — mirrors the mockup's legend. */
21
+ export const GRAPH_LEGEND_ITEMS: readonly {
22
+ kind: string;
23
+ label: string;
24
+ }[];
25
+ export default GraphLegend;
26
+ /**
27
+ * One legend entry.
28
+ */
29
+ export type GraphLegendItem = {
30
+ /**
31
+ * the node kind this swatch stands for; selects the accent
32
+ */
33
+ kind: "user" | "assistant" | "subagent" | "tool" | "error" | (string & {});
34
+ /**
35
+ * the lowercase word shown beside the swatch
36
+ */
37
+ label: string;
38
+ /**
39
+ * harness key → assistant swatch accent
40
+ */
41
+ provider?: string;
42
+ };
43
+ export type GraphLegendProps = {
44
+ /**
45
+ * legend entries (defaults to GRAPH_LEGEND_ITEMS)
46
+ */
47
+ items?: GraphLegendItem[];
48
+ className?: string;
49
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @typedef {object} GraphSubagentBranchProps
3
+ * @property {string} agentName the nested agent's name (user content)
4
+ * @property {number} depth nesting depth (1 = first level under the main lane)
5
+ * @property {string} [className]
6
+ */
7
+ /**
8
+ * The subagent swimlane header visual.
9
+ * @param {GraphSubagentBranchProps} props
10
+ * @returns {JSX.Element}
11
+ */
12
+ export function GraphSubagentBranch({ agentName, depth, className }: GraphSubagentBranchProps): JSX.Element;
13
+ export default GraphSubagentBranch;
14
+ export type GraphSubagentBranchProps = {
15
+ /**
16
+ * the nested agent's name (user content)
17
+ */
18
+ agentName: string;
19
+ /**
20
+ * nesting depth (1 = first level under the main lane)
21
+ */
22
+ depth: number;
23
+ className?: string;
24
+ };