@peasant-labs/fairtrade 0.0.1 → 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.
- package/dist/lib/base.css +54 -0
- package/dist/lib/components.css +2 -0
- package/dist/lib/fonts.css +28 -0
- package/dist/lib/icons.js +1 -0
- package/dist/lib/tokens.css +184 -0
- package/dist/lib/tokens.json +768 -0
- package/dist/lib/types/Accordion.d.ts +47 -0
- package/dist/lib/types/Avatar.d.ts +94 -0
- package/dist/lib/types/BrandMark.d.ts +25 -0
- package/dist/lib/types/Breadcrumb.d.ts +66 -0
- package/dist/lib/types/Button.d.ts +86 -0
- package/dist/lib/types/Card.d.ts +145 -0
- package/dist/lib/types/ChartBar.d.ts +51 -0
- package/dist/lib/types/ChartLine.d.ts +54 -0
- package/dist/lib/types/Checkbox.d.ts +132 -0
- package/dist/lib/types/Chip.d.ts +85 -0
- package/dist/lib/types/CliOnboard.d.ts +68 -0
- package/dist/lib/types/CommandPalette.d.ts +6 -0
- package/dist/lib/types/CommitGraph.d.ts +71 -0
- package/dist/lib/types/ConnectionState.d.ts +82 -0
- package/dist/lib/types/ConsentDialog.d.ts +97 -0
- package/dist/lib/types/DataTable.d.ts +116 -0
- package/dist/lib/types/DateRange.d.ts +242 -0
- package/dist/lib/types/Dialog.d.ts +9 -0
- package/dist/lib/types/DiffView.d.ts +39 -0
- package/dist/lib/types/EmptyState.d.ts +28 -0
- package/dist/lib/types/EvidenceCaption.d.ts +39 -0
- package/dist/lib/types/Explainer.d.ts +82 -0
- package/dist/lib/types/FacetRail.d.ts +13 -0
- package/dist/lib/types/Feedback.d.ts +222 -0
- package/dist/lib/types/GroupedMultiSelect.d.ts +67 -0
- package/dist/lib/types/Input.d.ts +158 -0
- package/dist/lib/types/Intensity.d.ts +55 -0
- package/dist/lib/types/MapCanvas.d.ts +89 -0
- package/dist/lib/types/Menu.d.ts +62 -0
- package/dist/lib/types/ModerationQueue.d.ts +135 -0
- package/dist/lib/types/Pager.d.ts +47 -0
- package/dist/lib/types/Pagination.d.ts +50 -0
- package/dist/lib/types/PolicySelect.d.ts +80 -0
- package/dist/lib/types/ProviderIcon.d.ts +84 -0
- package/dist/lib/types/RailShell.d.ts +199 -0
- package/dist/lib/types/Redaction.d.ts +53 -0
- package/dist/lib/types/RoleRoster.d.ts +97 -0
- package/dist/lib/types/SignIn.d.ts +78 -0
- package/dist/lib/types/Sparkline.d.ts +19 -0
- package/dist/lib/types/StatTiles.d.ts +118 -0
- package/dist/lib/types/StepWizard.d.ts +92 -0
- package/dist/lib/types/StepsWaterfall.d.ts +67 -0
- package/dist/lib/types/Switch.d.ts +63 -0
- package/dist/lib/types/Tabs.d.ts +48 -0
- package/dist/lib/types/TimeStrip.d.ts +12 -0
- package/dist/lib/types/Timeline.d.ts +192 -0
- package/dist/lib/types/ToastHost.d.ts +70 -0
- package/dist/lib/types/ToolRenderers.d.ts +24 -0
- package/dist/lib/types/Tooltip.d.ts +80 -0
- package/dist/lib/types/Tour.d.ts +37 -0
- package/dist/lib/types/TranscriptMarkers.d.ts +50 -0
- package/dist/lib/types/Treemap.d.ts +77 -0
- package/dist/lib/types/VisibilityControl.d.ts +54 -0
- package/dist/lib/types/chart-shared.d.ts +63 -0
- package/dist/lib/types/icons.d.ts +1 -0
- package/dist/lib/types/index.d.ts +55 -0
- package/dist/lib/types/transcript/CheckRow.d.ts +15 -0
- package/dist/lib/types/transcript/DiffEntryCard.d.ts +27 -0
- package/dist/lib/types/transcript/FilterSection.d.ts +11 -0
- package/dist/lib/types/transcript/FiltersRail.d.ts +41 -0
- package/dist/lib/types/transcript/LabelPopover.d.ts +14 -0
- package/dist/lib/types/transcript/Markdown.d.ts +7 -0
- package/dist/lib/types/transcript/OutlineRail.d.ts +13 -0
- package/dist/lib/types/transcript/Scorecard.d.ts +8 -0
- package/dist/lib/types/transcript/Scrubber.d.ts +17 -0
- package/dist/lib/types/transcript/TaskBody.d.ts +8 -0
- package/dist/lib/types/transcript/Thinking.d.ts +9 -0
- package/dist/lib/types/transcript/ToolBody.d.ts +8 -0
- package/dist/lib/types/transcript/ToolCall.d.ts +12 -0
- package/dist/lib/types/transcript/TranscriptViewer.d.ts +6 -0
- package/dist/lib/types/transcript/TurnCard.d.ts +31 -0
- package/dist/lib/types/transcript/ViewSwitch.d.ts +11 -0
- package/dist/lib/types/transcript/adapter.d.ts +90 -0
- package/dist/lib/types/transcript/adapter.parse.d.ts +75 -0
- package/dist/lib/types/transcript/analytics.d.ts +216 -0
- package/dist/lib/types/transcript/graph/GraphLegend.d.ts +49 -0
- package/dist/lib/types/transcript/graph/GraphSubagentBranch.d.ts +24 -0
- package/dist/lib/types/transcript/graph/GraphToolNode.d.ts +56 -0
- package/dist/lib/types/transcript/graph/GraphTurnNode.d.ts +76 -0
- package/dist/lib/types/transcript/graph/index.d.ts +10 -0
- package/dist/lib/types/transcript/index.d.ts +69 -0
- package/dist/lib/types/transcript/state-capabilities.d.ts +161 -0
- package/dist/lib/types/transcript/view-model.d.ts +563 -0
- package/dist/lib/types/transcript/wire-types.d.ts +325 -0
- package/dist/lib/ui.js +12693 -0
- package/package.json +11 -5
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trajectory-graph tool-cluster pill visual.
|
|
3
|
+
* @param {GraphToolNodeProps} props
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
|
+
*/
|
|
6
|
+
export function GraphToolNode({ tools, totalDurationMs, hasError, isFilteredOut, max, className, }: GraphToolNodeProps): JSX.Element;
|
|
7
|
+
export default GraphToolNode;
|
|
8
|
+
/**
|
|
9
|
+
* One cooked tool entry for the cluster. A strict presentational subset of
|
|
10
|
+
* ToolCallVM — note the absence of any raw wire `arguments`/`result` string, by
|
|
11
|
+
* design, so the visual cannot parse wire JSON.
|
|
12
|
+
*/
|
|
13
|
+
export type GraphToolItem = {
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* display name (e.g. "Read", "Bash")
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* tool kind (decorative grouping hint)
|
|
21
|
+
*/
|
|
22
|
+
kind?: string;
|
|
23
|
+
/**
|
|
24
|
+
* cooked path; basename is the preview fallback
|
|
25
|
+
*/
|
|
26
|
+
filePath?: string;
|
|
27
|
+
/**
|
|
28
|
+
* cooked one-line arg summary (NEVER parsed here)
|
|
29
|
+
*/
|
|
30
|
+
preview?: string;
|
|
31
|
+
isError?: boolean;
|
|
32
|
+
exitCode?: number;
|
|
33
|
+
};
|
|
34
|
+
export type GraphToolNodeProps = {
|
|
35
|
+
/**
|
|
36
|
+
* the cooked tool calls for this turn
|
|
37
|
+
*/
|
|
38
|
+
tools: GraphToolItem[];
|
|
39
|
+
/**
|
|
40
|
+
* summed duration → header badge
|
|
41
|
+
*/
|
|
42
|
+
totalDurationMs?: number;
|
|
43
|
+
/**
|
|
44
|
+
* cluster carries a failed call
|
|
45
|
+
*/
|
|
46
|
+
hasError?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* engine: dimmed by an active filter
|
|
49
|
+
*/
|
|
50
|
+
isFilteredOut?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* rows before collapsing to "+ N more" (default 4)
|
|
53
|
+
*/
|
|
54
|
+
max?: number;
|
|
55
|
+
className?: string;
|
|
56
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trajectory-graph turn card visual.
|
|
3
|
+
* @param {GraphTurnNodeProps} props
|
|
4
|
+
* @returns {JSX.Element}
|
|
5
|
+
*/
|
|
6
|
+
export function GraphTurnNode({ role, agentName, turnNumber, contentPreview, toolCount, totalTokens, tokensIn, tokensOut, hasError, hasRetry, hasRevert, isSearchMatch, isFilteredOut, isSelected, provider, className, }: GraphTurnNodeProps): JSX.Element;
|
|
7
|
+
export default GraphTurnNode;
|
|
8
|
+
export type Role = import("../wire-types.js").Role;
|
|
9
|
+
/**
|
|
10
|
+
* Cooked, engine-agnostic props for one trajectory-graph turn card. Every field
|
|
11
|
+
* is a finished display value — the component does no parsing, truncation, or
|
|
12
|
+
* data derivation beyond choosing the accent token and chrome label.
|
|
13
|
+
*/
|
|
14
|
+
export type GraphTurnNodeProps = {
|
|
15
|
+
/**
|
|
16
|
+
* canonical role; selects the chrome label + base accent
|
|
17
|
+
*/
|
|
18
|
+
role: Role;
|
|
19
|
+
/**
|
|
20
|
+
* subagent name; PRESENT ⇒ render as a subagent (mauve)
|
|
21
|
+
*/
|
|
22
|
+
agentName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* the display number shown as "#…"
|
|
25
|
+
*/
|
|
26
|
+
turnNumber: string | number;
|
|
27
|
+
/**
|
|
28
|
+
* one-line, already-truncated preview (may be empty)
|
|
29
|
+
*/
|
|
30
|
+
contentPreview: string;
|
|
31
|
+
/**
|
|
32
|
+
* tool-call count for the footer ("N tools")
|
|
33
|
+
*/
|
|
34
|
+
toolCount: number;
|
|
35
|
+
/**
|
|
36
|
+
* total tokens for the footer badge
|
|
37
|
+
*/
|
|
38
|
+
totalTokens: number;
|
|
39
|
+
/**
|
|
40
|
+
* optional split, surfaced via title for hover detail
|
|
41
|
+
*/
|
|
42
|
+
tokensIn?: number;
|
|
43
|
+
tokensOut?: number;
|
|
44
|
+
/**
|
|
45
|
+
* clay accent + error flag (highest-priority flag)
|
|
46
|
+
*/
|
|
47
|
+
hasError?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* "retry" flag (when not an error)
|
|
50
|
+
*/
|
|
51
|
+
hasRetry?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* "re-edit" flag (when not an error or retry)
|
|
54
|
+
*/
|
|
55
|
+
hasRevert?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* engine: highlighted as a search hit
|
|
58
|
+
*/
|
|
59
|
+
isSearchMatch?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* engine: dimmed because a filter excludes it
|
|
62
|
+
*/
|
|
63
|
+
isFilteredOut?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* engine: the active/selected node
|
|
66
|
+
*/
|
|
67
|
+
isSelected?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* harness key (e.g. "claude-code") → assistant accent
|
|
70
|
+
*/
|
|
71
|
+
provider?: string;
|
|
72
|
+
/**
|
|
73
|
+
* extra classes appended after the base
|
|
74
|
+
*/
|
|
75
|
+
className?: string;
|
|
76
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { GraphTurnNode } from "./GraphTurnNode.jsx";
|
|
2
|
+
export { GraphToolNode } from "./GraphToolNode.jsx";
|
|
3
|
+
export { GraphSubagentBranch } from "./GraphSubagentBranch.jsx";
|
|
4
|
+
export type GraphTurnNodeProps = import("./GraphTurnNode.jsx").GraphTurnNodeProps;
|
|
5
|
+
export type GraphToolNodeProps = import("./GraphToolNode.jsx").GraphToolNodeProps;
|
|
6
|
+
export type GraphToolItem = import("./GraphToolNode.jsx").GraphToolItem;
|
|
7
|
+
export type GraphSubagentBranchProps = import("./GraphSubagentBranch.jsx").GraphSubagentBranchProps;
|
|
8
|
+
export type GraphLegendProps = import("./GraphLegend.jsx").GraphLegendProps;
|
|
9
|
+
export type GraphLegendItem = import("./GraphLegend.jsx").GraphLegendItem;
|
|
10
|
+
export { GraphLegend, GRAPH_LEGEND_ITEMS } from "./GraphLegend.jsx";
|