@mistriwork/agent-ui 0.0.0-stage → 1.4.0

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.
@@ -0,0 +1,133 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Multi-agent & orchestrator primitives for `@mistriwork/agent-ui`:
4
+ * - `<SessionTree>`: hierarchical tree of agent runs, sub-agents, and worktrees
5
+ * - `<RaceCompare>`: side-by-side comparison of parallel agent / model runs
6
+ * - `<ApprovalQueue>`: cross-agent permission & checkpoint approval inbox
7
+ * - `<PlanView>`: structured agent execution plan with progress meter
8
+ */
9
+ import { useMemo, useState } from 'react';
10
+ import { Badge, Button, EmptyState, Meter, SegmentedControl, StatusDot } from '@mistriwork/mistri/ui';
11
+ import './workbench.css';
12
+ function sessionTone(status) {
13
+ if (status === 'completed')
14
+ return 'good';
15
+ if (status === 'failed')
16
+ return 'critical';
17
+ if (status === 'waiting_approval' || status === 'paused')
18
+ return 'warning';
19
+ if (status === 'running')
20
+ return 'info';
21
+ return 'neutral';
22
+ }
23
+ function sessionLabel(status) {
24
+ if (status === 'waiting_approval')
25
+ return 'Needs approval';
26
+ if (status === 'running')
27
+ return 'Running';
28
+ if (status === 'paused')
29
+ return 'Paused';
30
+ if (status === 'completed')
31
+ return 'Done';
32
+ if (status === 'failed')
33
+ return 'Failed';
34
+ return 'Idle';
35
+ }
36
+ function matchesFilter(node, filter) {
37
+ if (filter === 'all')
38
+ return true;
39
+ if (filter === 'active')
40
+ return node.status === 'running' || node.status === 'waiting_approval' || node.status === 'paused';
41
+ if (filter === 'waiting')
42
+ return node.status === 'waiting_approval' || (node.pendingApprovals ?? 0) > 0;
43
+ return node.status === 'failed';
44
+ }
45
+ function filterTree(nodes, filter) {
46
+ if (filter === 'all')
47
+ return [...nodes];
48
+ const out = [];
49
+ for (const node of nodes) {
50
+ const kids = node.children ? filterTree(node.children, filter) : [];
51
+ if (matchesFilter(node, filter) || kids.length > 0) {
52
+ out.push({ ...node, ...(kids.length > 0 ? { children: kids } : {}) });
53
+ }
54
+ }
55
+ return out;
56
+ }
57
+ export function SessionTree({ sessions, selectedId, onSelect, onCancel, onFork, filterable = false, empty, className }) {
58
+ const [filter, setFilter] = useState('all');
59
+ const [collapsed, setCollapsed] = useState(() => new Set());
60
+ const visible = useMemo(() => filterTree(sessions, filter), [sessions, filter]);
61
+ const toggleCollapse = (id) => {
62
+ setCollapsed((prev) => {
63
+ const next = new Set(prev);
64
+ if (next.has(id))
65
+ next.delete(id);
66
+ else
67
+ next.add(id);
68
+ return next;
69
+ });
70
+ };
71
+ const renderNode = (node) => {
72
+ const hasKids = Boolean(node.children && node.children.length > 0);
73
+ const isCollapsed = collapsed.has(node.id);
74
+ const selected = node.id === selectedId;
75
+ return (_jsxs("li", { children: [_jsxs("div", { className: "aui-session-row", "data-selected": selected ? 'true' : undefined, children: [_jsxs("div", { className: "aui-session-row-head", children: [hasKids ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: isCollapsed ? `Expand ${node.title}` : `Collapse ${node.title}`, onClick: () => toggleCollapse(node.id), children: isCollapsed ? '▸' : '▾' })) : null, _jsx(StatusDot, { tone: sessionTone(node.status), pulse: node.status === 'running' }), _jsx("button", { type: "button", className: "aui-session-title", onClick: () => onSelect(node.id), children: node.title }), _jsx(Badge, { tone: sessionTone(node.status), children: sessionLabel(node.status) })] }), _jsxs("div", { className: "aui-session-meta", children: [node.model ? _jsx("span", { children: node.model }) : null, node.branch ? _jsx("span", { children: node.branch }) : null, node.durationLabel ? _jsx("span", { children: node.durationLabel }) : null, node.tokensLabel ? _jsx("span", { children: node.tokensLabel }) : null, node.pendingApprovals && node.pendingApprovals > 0 ? (_jsx(Badge, { tone: "warning", children: `${node.pendingApprovals} approval${node.pendingApprovals === 1 ? '' : 's'}` })) : null, onFork ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onFork(node.id), children: "Fork" })) : null, onCancel && (node.status === 'running' || node.status === 'paused') ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onCancel(node.id), children: "Stop" })) : null] })] }), hasKids && !isCollapsed ? _jsx("ul", { className: "aui-session-list aui-session-children", children: node.children.map(renderNode) }) : null] }, node.id));
76
+ };
77
+ return (_jsxs("div", { className: className ? `aui-session-tree ${className}` : 'aui-session-tree', children: [filterable ? (_jsx("div", { className: "aui-session-filters", children: _jsx(SegmentedControl, { ariaLabel: "Filter agent sessions", size: "sm", value: filter, onValueChange: (next) => setFilter(next), options: [
78
+ { value: 'all', label: 'All' },
79
+ { value: 'active', label: 'Active' },
80
+ { value: 'waiting', label: 'Approvals' },
81
+ { value: 'failed', label: 'Failed' },
82
+ ] }) })) : null, visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No agent sessions" }))) : (_jsx("ul", { className: "aui-session-list", role: "tree", "aria-label": "Agent sessions", children: visible.map(renderNode) }))] }));
83
+ }
84
+ export function RaceCompare({ candidates, winnerId, onPickWinner, onInspect, renderDiff, empty, className }) {
85
+ if (candidates.length === 0) {
86
+ return empty ? _jsx("div", { className: className, children: empty }) : _jsx(EmptyState, { compact: true, title: "No race candidates" });
87
+ }
88
+ return (_jsx("div", { className: className ? `aui-race-grid ${className}` : 'aui-race-grid', role: "region", "aria-label": "Agent race comparison", children: candidates.map((candidate) => {
89
+ const isWinner = winnerId === candidate.id;
90
+ return (_jsxs("article", { className: "aui-race-card", "data-winner": isWinner ? 'true' : undefined, children: [_jsxs("header", { className: "aui-race-head", children: [_jsxs("span", { className: "aui-race-title", children: [_jsx(StatusDot, { tone: sessionTone(candidate.status), pulse: candidate.status === 'running' }), _jsx("span", { children: candidate.label })] }), _jsx(Badge, { tone: isWinner ? 'good' : 'neutral', children: isWinner ? 'Winner' : candidate.model })] }), _jsxs("div", { className: "aui-race-metrics", children: [candidate.durationLabel ? _jsx("span", { children: candidate.durationLabel }) : null, candidate.costLabel ? _jsx("span", { children: candidate.costLabel }) : null, candidate.filesChanged !== undefined ? (_jsx("span", { children: `${candidate.filesChanged} file${candidate.filesChanged === 1 ? '' : 's'}` })) : null, candidate.additions !== undefined ? _jsx("span", { className: "kit-diff-stat-add", children: `+${candidate.additions}` }) : null, candidate.deletions !== undefined ? _jsx("span", { className: "kit-diff-stat-del", children: `-${candidate.deletions}` }) : null] }), candidate.checks && candidate.checks.length > 0 ? (_jsx("div", { className: "aui-race-checks", children: candidate.checks.map((check) => (_jsx(Badge, { tone: check.passed ? 'good' : 'critical', children: `${check.passed ? '✓' : '✗'} ${check.label}` }, check.label))) })) : null, candidate.summary ? _jsx("p", { className: "aui-race-summary", children: candidate.summary }) : null, renderDiff && candidate.diff ? renderDiff(candidate) : null, _jsxs("div", { className: "aui-race-actions", children: [onPickWinner ? (_jsx(Button, { size: "sm", variant: isWinner ? 'secondary' : 'primary', disabled: candidate.status === 'running' || candidate.status === 'failed', onClick: () => onPickWinner(candidate.id), children: isWinner ? 'Selected winner' : 'Pick winner' })) : null, onInspect ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: () => onInspect(candidate.id), children: "Inspect diff" })) : null] })] }, candidate.id));
91
+ }) }));
92
+ }
93
+ function approvalRiskTone(risk) {
94
+ if (risk === 'high')
95
+ return 'critical';
96
+ if (risk === 'low')
97
+ return 'neutral';
98
+ return 'warning';
99
+ }
100
+ export function ApprovalQueue({ approvals, onApprove, onDeny, onAlwaysAllow, onApproveAllLowRisk, title = 'Pending approvals', empty, className, }) {
101
+ const lowRiskIds = useMemo(() => approvals.filter((a) => a.risk === 'low').map((a) => a.id), [approvals]);
102
+ if (approvals.length === 0) {
103
+ return empty ? _jsx("div", { className: className, children: empty }) : _jsx(EmptyState, { compact: true, title: "No pending approvals" });
104
+ }
105
+ return (_jsxs("section", { className: className ? `aui-approval-queue ${className}` : 'aui-approval-queue', "aria-label": title, children: [_jsxs("header", { className: "aui-approval-queue-head", children: [_jsxs("span", { className: "aui-approval-queue-title", children: [_jsx("span", { children: title }), _jsx(Badge, { tone: "warning", children: String(approvals.length) })] }), onApproveAllLowRisk && lowRiskIds.length > 0 ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: () => onApproveAllLowRisk(lowRiskIds), children: `Approve all low-risk (${lowRiskIds.length})` })) : null] }), approvals.map((approval) => (_jsxs("article", { className: "kit-agent-approval", children: [_jsxs("div", { className: "kit-agent-approval-head", children: [_jsx(Badge, { tone: approvalRiskTone(approval.risk), children: approval.risk ?? 'medium' }), _jsx("code", { children: approval.tool }), approval.agentLabel ? _jsx(Badge, { tone: "neutral", children: approval.agentLabel }) : null, approval.createdAt ? _jsx("span", { className: "kit-agent-msg-meta", children: approval.createdAt }) : null] }), _jsx("p", { className: "kit-agent-approval-summary", children: approval.summary }), approval.input ? (_jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: JSON.stringify(approval.input, null, 2) }) })) : null, _jsxs("div", { className: "kit-agent-approval-actions", children: [_jsx(Button, { size: "sm", variant: "primary", onClick: () => onApprove(approval.id), children: "Approve" }), _jsx(Button, { size: "sm", variant: "secondary", onClick: () => onDeny(approval.id), children: "Deny" }), onAlwaysAllow ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onAlwaysAllow(approval), children: "Always allow" })) : null] })] }, approval.id)))] }));
106
+ }
107
+ function stepTone(status) {
108
+ if (status === 'completed')
109
+ return 'good';
110
+ if (status === 'in_progress')
111
+ return 'info';
112
+ if (status === 'blocked')
113
+ return 'critical';
114
+ return 'neutral';
115
+ }
116
+ function stepLabel(status) {
117
+ if (status === 'in_progress')
118
+ return 'In progress';
119
+ if (status === 'completed')
120
+ return 'Done';
121
+ if (status === 'blocked')
122
+ return 'Blocked';
123
+ if (status === 'skipped')
124
+ return 'Skipped';
125
+ return 'Pending';
126
+ }
127
+ export function PlanView({ steps, title = 'Execution plan', summary, empty, className }) {
128
+ if (steps.length === 0) {
129
+ return empty ? _jsx("div", { className: className, children: empty }) : _jsx(EmptyState, { compact: true, title: "No plan steps" });
130
+ }
131
+ const doneCount = steps.filter((step) => step.status === 'completed' || step.status === 'skipped').length;
132
+ return (_jsxs("section", { className: className ? `aui-plan ${className}` : 'aui-plan', "aria-label": title, children: [_jsxs("header", { className: "aui-plan-head", children: [_jsx("span", { className: "aui-plan-title", children: title }), _jsx(Badge, { tone: doneCount === steps.length ? 'good' : 'info', children: `${doneCount}/${steps.length}` })] }), summary ? _jsx("p", { className: "aui-plan-step-detail", children: summary }) : null, _jsx(Meter, { value: doneCount, min: 0, max: steps.length, ariaLabel: `${title} progress`, tone: doneCount === steps.length ? 'good' : 'info', size: "sm", fluid: true }), _jsx("ol", { className: "aui-plan-steps", children: steps.map((step) => (_jsxs("li", { className: "aui-plan-step", "data-status": step.status, children: [_jsxs("div", { className: "aui-plan-step-head", children: [_jsx(StatusDot, { tone: stepTone(step.status), pulse: step.status === 'in_progress' }), _jsx("span", { className: "aui-plan-step-title", children: step.title }), _jsx(Badge, { tone: stepTone(step.status), children: stepLabel(step.status) })] }), step.detail ? _jsx("p", { className: "aui-plan-step-detail", children: step.detail }) : null] }, step.id))) })] }));
133
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `@mistriwork/agent-ui/pierre`: Optional adapter connecting `@pierre/diffs`
3
+ * (and lazy `@pierre/diffs/edit`) and `@pierre/trees` into `@mistriwork/agent-ui`.
4
+ */
5
+ export { PierreCodeSurface, PierreDiffSurface, PierreFileTree, createPierreSurfaces } from './pierreAdapter.js';
6
+ export type { PierreAdapterOptions, PierreCodeSurfaceProps, PierreCommonOptions, PierreDiffLineAnnotation, PierreDiffSurfaceProps, PierreDiffsReactModule, PierreEditProviderProps, PierreFileContents, PierreFileProps, PierreFileTreeProps, PierreLineAnnotation, PierreMultiFileDiffProps, PierrePatchDiffProps, PierreSelectionRange, PierreThemeConfig, PierreTreesReactModule, } from './pierreAdapter.js';
package/dist/pierre.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `@mistriwork/agent-ui/pierre`: Optional adapter connecting `@pierre/diffs`
3
+ * (and lazy `@pierre/diffs/edit`) and `@pierre/trees` into `@mistriwork/agent-ui`.
4
+ */
5
+ export { PierreCodeSurface, PierreDiffSurface, PierreFileTree, createPierreSurfaces } from './pierreAdapter.js';
@@ -0,0 +1,140 @@
1
+ /**
2
+ * `@mistriwork/agent-ui/pierre`: Optional adapter connecting `@pierre/diffs`
3
+ * (Shiki code/diff viewer, virtualized split/unified diffs, inline annotations,
4
+ * `renderSelectionAction` -> "Add to chat", and lazy `@pierre/diffs/edit`) and
5
+ * `@pierre/trees` (virtualized file tree) into `@mistriwork/agent-ui`'s
6
+ * `<AgentUiProvider>` surface seam.
7
+ *
8
+ * Uses structural module contracts so `@mistriwork/agent-ui` carries zero hard
9
+ * runtime dependencies on `@pierre/diffs` or `@pierre/trees` — apps pass their
10
+ * imported Pierre modules so Vite/Rolldown tree-shakes cleanly, and surfaces
11
+ * fall back gracefully to built-in zero-dep primitives if omitted.
12
+ */
13
+ import { type ComponentType, type ReactNode } from 'react';
14
+ import { type FileTreeProps } from './fileTree.js';
15
+ import { type AgentUiSurfaces, type CodeSurfaceProps, type DiffSurfaceProps } from './surfaces.js';
16
+ export interface PierreThemeConfig {
17
+ readonly dark: string;
18
+ readonly light: string;
19
+ }
20
+ export interface PierreFileContents {
21
+ readonly name: string;
22
+ readonly contents: string;
23
+ readonly lang?: string;
24
+ }
25
+ export interface PierreLineAnnotation<T = unknown> {
26
+ readonly lineNumber: number;
27
+ readonly metadata?: T;
28
+ }
29
+ export interface PierreDiffLineAnnotation<T = unknown> {
30
+ readonly side: 'additions' | 'deletions';
31
+ readonly lineNumber: number;
32
+ readonly metadata?: T;
33
+ }
34
+ export interface PierreSelectionRange {
35
+ readonly start: number;
36
+ readonly end: number;
37
+ readonly text?: string;
38
+ }
39
+ export interface PierreCommonOptions {
40
+ readonly theme?: string | PierreThemeConfig;
41
+ readonly themeType?: 'light' | 'dark' | 'system';
42
+ readonly diffStyle?: 'split' | 'unified';
43
+ readonly overflow?: 'scroll' | 'wrap';
44
+ readonly disableLineNumbers?: boolean;
45
+ readonly unsafeCSS?: string;
46
+ readonly edit?: boolean;
47
+ readonly onChange?: (value: string) => void;
48
+ }
49
+ export interface PierreFileProps {
50
+ readonly file: PierreFileContents;
51
+ readonly options?: PierreCommonOptions;
52
+ readonly lineAnnotations?: readonly PierreLineAnnotation[];
53
+ readonly renderAnnotation?: (annotation: PierreLineAnnotation) => ReactNode;
54
+ readonly renderSelectionAction?: (selection: PierreSelectionRange) => ReactNode;
55
+ readonly className?: string;
56
+ }
57
+ export interface PierreMultiFileDiffProps {
58
+ readonly oldFile: PierreFileContents;
59
+ readonly newFile: PierreFileContents;
60
+ readonly options?: PierreCommonOptions;
61
+ readonly lineAnnotations?: readonly PierreDiffLineAnnotation[];
62
+ readonly renderAnnotation?: (annotation: PierreDiffLineAnnotation) => ReactNode;
63
+ readonly renderSelectionAction?: (selection: PierreSelectionRange) => ReactNode;
64
+ readonly className?: string;
65
+ }
66
+ export interface PierrePatchDiffProps {
67
+ readonly patch: string;
68
+ readonly options?: PierreCommonOptions;
69
+ readonly lineAnnotations?: readonly PierreDiffLineAnnotation[];
70
+ readonly renderAnnotation?: (annotation: PierreDiffLineAnnotation) => ReactNode;
71
+ readonly renderSelectionAction?: (selection: PierreSelectionRange) => ReactNode;
72
+ readonly className?: string;
73
+ }
74
+ export interface PierreEditProviderProps {
75
+ readonly children: ReactNode;
76
+ readonly createEditor?: unknown;
77
+ }
78
+ /** Structural subset of `@pierre/diffs/react`. */
79
+ export interface PierreDiffsReactModule {
80
+ readonly File: ComponentType<PierreFileProps>;
81
+ readonly MultiFileDiff?: ComponentType<PierreMultiFileDiffProps>;
82
+ readonly PatchDiff?: ComponentType<PierrePatchDiffProps>;
83
+ readonly EditProvider?: ComponentType<PierreEditProviderProps>;
84
+ }
85
+ /** Structural subset of `@pierre/trees/react`. */
86
+ export interface PierreTreesReactModule {
87
+ readonly FileTree: ComponentType<{
88
+ readonly model: unknown;
89
+ readonly className?: string;
90
+ }>;
91
+ readonly useFileTree: (options: {
92
+ readonly paths: readonly string[];
93
+ readonly search?: boolean;
94
+ readonly initialExpandedPaths?: readonly string[];
95
+ readonly onSelect?: (path: string) => void;
96
+ }) => {
97
+ readonly model: unknown;
98
+ };
99
+ }
100
+ export interface PierreAdapterOptions {
101
+ /** Imported `@pierre/diffs/react` module (`import * as pierreDiffs from '@pierre/diffs/react'`). */
102
+ readonly diffs?: PierreDiffsReactModule;
103
+ /** Optional imported `@pierre/trees/react` module (`import * as pierreTrees from '@pierre/trees/react'`). */
104
+ readonly trees?: PierreTreesReactModule;
105
+ /** Optional Shiki theme pair or single theme name (defaults to `{ dark: 'pierre-dark', light: 'pierre-light' }`). */
106
+ readonly theme?: string | PierreThemeConfig;
107
+ /** Sync with Mistri's `useLook().mode` (`'light' | 'dark'`) or `'system'`. */
108
+ readonly themeMode?: 'light' | 'dark' | 'system';
109
+ /** Default diff layout (`'split' | 'unified'`). */
110
+ readonly diffStyle?: 'split' | 'unified';
111
+ /** Optional custom CSS injected into Pierre's Shadow DOM. */
112
+ readonly unsafeCSS?: string;
113
+ /** Optional custom `@pierre/diffs/edit` editor factory passed to `EditProvider`. */
114
+ readonly createEditor?: unknown;
115
+ }
116
+ export interface PierreCodeSurfaceProps extends CodeSurfaceProps {
117
+ readonly diffs?: PierreDiffsReactModule;
118
+ readonly theme?: string | PierreThemeConfig;
119
+ readonly themeMode?: 'light' | 'dark' | 'system';
120
+ readonly unsafeCSS?: string;
121
+ readonly createEditor?: unknown;
122
+ }
123
+ export declare function PierreCodeSurface({ diffs, theme, themeMode, unsafeCSS, createEditor, ...props }: PierreCodeSurfaceProps): import("react").JSX.Element;
124
+ export interface PierreDiffSurfaceProps extends DiffSurfaceProps {
125
+ readonly diffs?: PierreDiffsReactModule;
126
+ readonly theme?: string | PierreThemeConfig;
127
+ readonly themeMode?: 'light' | 'dark' | 'system';
128
+ readonly unsafeCSS?: string;
129
+ readonly createEditor?: unknown;
130
+ }
131
+ export declare function PierreDiffSurface({ diffs, theme, themeMode, unsafeCSS, createEditor, ...props }: PierreDiffSurfaceProps): import("react").JSX.Element;
132
+ export interface PierreFileTreeProps extends FileTreeProps {
133
+ readonly trees?: PierreTreesReactModule;
134
+ }
135
+ export declare function PierreFileTree({ trees, ...props }: PierreFileTreeProps): import("react").JSX.Element;
136
+ /**
137
+ * Create an `AgentUiSurfaces` bundle wired to `@pierre/diffs/react` (and
138
+ * optionally `@pierre/trees/react`) to pass straight into `<AgentUiProvider>`.
139
+ */
140
+ export declare function createPierreSurfaces(options: PierreAdapterOptions): AgentUiSurfaces;
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * `@mistriwork/agent-ui/pierre`: Optional adapter connecting `@pierre/diffs`
4
+ * (Shiki code/diff viewer, virtualized split/unified diffs, inline annotations,
5
+ * `renderSelectionAction` -> "Add to chat", and lazy `@pierre/diffs/edit`) and
6
+ * `@pierre/trees` (virtualized file tree) into `@mistriwork/agent-ui`'s
7
+ * `<AgentUiProvider>` surface seam.
8
+ *
9
+ * Uses structural module contracts so `@mistriwork/agent-ui` carries zero hard
10
+ * runtime dependencies on `@pierre/diffs` or `@pierre/trees` — apps pass their
11
+ * imported Pierre modules so Vite/Rolldown tree-shakes cleanly, and surfaces
12
+ * fall back gracefully to built-in zero-dep primitives if omitted.
13
+ */
14
+ import { useMemo } from 'react';
15
+ import { Button } from '@mistriwork/mistri/ui';
16
+ import { DefaultFileTree } from './fileTree.js';
17
+ import { DefaultCodeSurface, DefaultDiffSurface, } from './surfaces.js';
18
+ const DEFAULT_THEME = { dark: 'pierre-dark', light: 'pierre-light' };
19
+ function renderChatSelectionButton(path, content, selection, onAddToChat) {
20
+ const startLine = Math.min(selection.start, selection.end);
21
+ const endLine = Math.max(selection.start, selection.end);
22
+ const text = selection.text ??
23
+ content
24
+ .split('\n')
25
+ .slice(Math.max(0, startLine - 1), endLine)
26
+ .join('\n');
27
+ return (_jsx(Button, { size: "sm", variant: "primary", onClick: () => onAddToChat({ path, startLine, endLine, text }), children: "Add to chat" }));
28
+ }
29
+ export function PierreCodeSurface({ diffs, theme = DEFAULT_THEME, themeMode = 'system', unsafeCSS, createEditor, ...props }) {
30
+ if (!diffs?.File)
31
+ return _jsx(DefaultCodeSurface, { ...props });
32
+ const PierreFile = diffs.File;
33
+ const EditProvider = diffs.EditProvider;
34
+ const file = {
35
+ name: props.path,
36
+ contents: props.content,
37
+ ...(props.language ? { lang: props.language } : {}),
38
+ };
39
+ const lineAnnotations = [
40
+ ...(props.markers ?? []).map((m) => ({
41
+ lineNumber: m.line,
42
+ metadata: `${m.severity.toUpperCase()}: ${m.message}`,
43
+ })),
44
+ ...(props.annotations ?? []).map((a) => ({
45
+ lineNumber: a.line,
46
+ metadata: a.body,
47
+ })),
48
+ ];
49
+ const options = {
50
+ theme,
51
+ themeType: themeMode,
52
+ ...(unsafeCSS ? { unsafeCSS } : {}),
53
+ ...(props.editable ? { edit: true, onChange: props.onChange } : {}),
54
+ };
55
+ const rendered = (_jsx(PierreFile, { file: file, options: options, lineAnnotations: lineAnnotations.length > 0 ? lineAnnotations : undefined, renderAnnotation: lineAnnotations.length > 0 ? (ann) => ann.metadata : undefined, renderSelectionAction: props.onAddToChat ? (sel) => renderChatSelectionButton(props.path, props.content, sel, props.onAddToChat) : undefined, className: props.className }));
56
+ if (props.editable && EditProvider) {
57
+ return _jsx(EditProvider, { createEditor: createEditor, children: rendered });
58
+ }
59
+ return rendered;
60
+ }
61
+ export function PierreDiffSurface({ diffs, theme = DEFAULT_THEME, themeMode = 'system', unsafeCSS, createEditor, ...props }) {
62
+ if (!diffs)
63
+ return _jsx(DefaultDiffSurface, { ...props });
64
+ const EditProvider = diffs.EditProvider;
65
+ const lineAnnotations = props.annotations?.map((ann) => ({
66
+ side: ann.side,
67
+ lineNumber: ann.line,
68
+ metadata: ann.body,
69
+ }));
70
+ const options = {
71
+ theme,
72
+ themeType: themeMode,
73
+ diffStyle: props.diffStyle ?? 'split',
74
+ ...(unsafeCSS ? { unsafeCSS } : {}),
75
+ ...(props.editable ? { edit: true, onChange: props.onChange } : {}),
76
+ };
77
+ let rendered = null;
78
+ if (props.oldFile && props.newFile && diffs.MultiFileDiff) {
79
+ const MultiFileDiff = diffs.MultiFileDiff;
80
+ rendered = (_jsx(MultiFileDiff, { oldFile: props.oldFile, newFile: props.newFile, options: options, lineAnnotations: lineAnnotations, renderAnnotation: lineAnnotations ? (ann) => ann.metadata : undefined, renderSelectionAction: props.onAddToChat
81
+ ? (sel) => renderChatSelectionButton(props.newFile.name, props.newFile.contents, sel, props.onAddToChat)
82
+ : undefined, className: props.className }));
83
+ }
84
+ else if (props.patch && diffs.PatchDiff) {
85
+ const PatchDiff = diffs.PatchDiff;
86
+ rendered = (_jsx(PatchDiff, { patch: props.patch, options: options, lineAnnotations: lineAnnotations, renderAnnotation: lineAnnotations ? (ann) => ann.metadata : undefined, renderSelectionAction: props.onAddToChat
87
+ ? (sel) => renderChatSelectionButton(props.selectedFile ?? 'diff', props.patch, sel, props.onAddToChat)
88
+ : undefined, className: props.className }));
89
+ }
90
+ else {
91
+ return _jsx(DefaultDiffSurface, { ...props });
92
+ }
93
+ if (props.editable && EditProvider) {
94
+ return _jsx(EditProvider, { createEditor: createEditor, children: rendered });
95
+ }
96
+ return rendered;
97
+ }
98
+ function PierreFileTreeMounted({ trees, ...props }) {
99
+ const flatPaths = useMemo(() => {
100
+ if (props.paths)
101
+ return props.paths;
102
+ if (props.entries)
103
+ return props.entries.map((entry) => entry.path);
104
+ return [];
105
+ }, [props.paths, props.entries]);
106
+ const { model } = trees.useFileTree({
107
+ paths: flatPaths,
108
+ search: props.searchable,
109
+ initialExpandedPaths: props.defaultExpandedPaths,
110
+ onSelect: props.onSelect,
111
+ });
112
+ const TreeComponent = trees.FileTree;
113
+ return _jsx(TreeComponent, { model: model, className: props.className });
114
+ }
115
+ export function PierreFileTree({ trees, ...props }) {
116
+ if (!trees?.FileTree || !trees?.useFileTree) {
117
+ return _jsx(DefaultFileTree, { ...props });
118
+ }
119
+ return _jsx(PierreFileTreeMounted, { trees: trees, ...props });
120
+ }
121
+ /* ============================================================================
122
+ * 3. Surface Bundle Factory for `<AgentUiProvider surfaces={...}>`
123
+ * ========================================================================== */
124
+ /**
125
+ * Create an `AgentUiSurfaces` bundle wired to `@pierre/diffs/react` (and
126
+ * optionally `@pierre/trees/react`) to pass straight into `<AgentUiProvider>`.
127
+ */
128
+ export function createPierreSurfaces(options) {
129
+ const { diffs, trees, theme = DEFAULT_THEME, themeMode = 'system', diffStyle = 'split', unsafeCSS, createEditor } = options;
130
+ const CodeAdapter = (props) => (_jsx(PierreCodeSurface, { ...props, diffs: diffs, theme: theme, themeMode: themeMode, unsafeCSS: unsafeCSS, createEditor: createEditor }));
131
+ const DiffAdapter = (props) => (_jsx(PierreDiffSurface, { ...props, diffStyle: props.diffStyle ?? diffStyle, diffs: diffs, theme: theme, themeMode: themeMode, unsafeCSS: unsafeCSS, createEditor: createEditor }));
132
+ const TreeAdapter = trees ? (props) => _jsx(PierreFileTree, { ...props, trees: trees }) : undefined;
133
+ return {
134
+ ...(diffs ? { code: CodeAdapter, diff: DiffAdapter } : {}),
135
+ ...(TreeAdapter ? { fileTree: TreeAdapter } : {}),
136
+ };
137
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Workbench shell & navigation primitives for `@mistriwork/agent-ui`:
3
+ * - `<WorkbenchLayout>`: resizable multi-pane IDE/orchestrator frame
4
+ * - `<TabStrip>`: open-file / session / diff tab bar
5
+ * - `<StatusBar>`: compact bottom IDE status strip
6
+ * - `<CommandPalette>`: keyboard-first filterable command / file / session launcher
7
+ */
8
+ import { type ReactNode } from 'react';
9
+ import { type Tone } from '@mistriwork/mistri/ui';
10
+ import './workbench.css';
11
+ export interface WorkbenchLayoutSizes {
12
+ readonly sidebarWidth: number;
13
+ readonly inspectorWidth: number;
14
+ readonly bottomHeight: number;
15
+ }
16
+ export interface WorkbenchLayoutProps {
17
+ /** Optional top toolbar / breadcrumb bar. */
18
+ readonly header?: ReactNode;
19
+ /** Optional left rail (e.g. `<FileTree>` or `<SessionTree>`). */
20
+ readonly sidebar?: ReactNode;
21
+ /** Primary center stage (e.g. `<CodeSurface>`, `<DiffSurface>`, `<RaceCompare>`, or `<AgentThread>`). */
22
+ readonly main: ReactNode;
23
+ /** Optional right rail (e.g. `<AgentThread>` + `<AgentComposer>` or `<ToolCallInspector>`). */
24
+ readonly inspector?: ReactNode;
25
+ /** Optional bottom drawer (e.g. `<TerminalOutput>` or `<ApprovalQueue>`). */
26
+ readonly bottom?: ReactNode;
27
+ /** Optional footer strip (e.g. `<StatusBar>`). */
28
+ readonly statusBar?: ReactNode;
29
+ readonly defaultSidebarWidth?: number;
30
+ readonly defaultInspectorWidth?: number;
31
+ readonly defaultBottomHeight?: number;
32
+ readonly minSidebarWidth?: number;
33
+ readonly maxSidebarWidth?: number;
34
+ readonly minInspectorWidth?: number;
35
+ readonly maxInspectorWidth?: number;
36
+ readonly minBottomHeight?: number;
37
+ readonly maxBottomHeight?: number;
38
+ readonly sidebarCollapsed?: boolean;
39
+ readonly inspectorCollapsed?: boolean;
40
+ readonly bottomCollapsed?: boolean;
41
+ /** Called whenever a pane is resized via pointer drag or keyboard arrows. */
42
+ readonly onLayoutChange?: (sizes: WorkbenchLayoutSizes) => void;
43
+ readonly className?: string;
44
+ }
45
+ export declare function WorkbenchLayout({ header, sidebar, main, inspector, bottom, statusBar, defaultSidebarWidth, defaultInspectorWidth, defaultBottomHeight, minSidebarWidth, maxSidebarWidth, minInspectorWidth, maxInspectorWidth, minBottomHeight, maxBottomHeight, sidebarCollapsed, inspectorCollapsed, bottomCollapsed, onLayoutChange, className, }: WorkbenchLayoutProps): import("react").JSX.Element;
46
+ export interface TabStripItem {
47
+ readonly id: string;
48
+ readonly label: string;
49
+ readonly title?: string;
50
+ readonly dirty?: boolean;
51
+ readonly badge?: string;
52
+ readonly tone?: Tone;
53
+ readonly closable?: boolean;
54
+ }
55
+ export interface TabStripProps {
56
+ readonly tabs: readonly TabStripItem[];
57
+ readonly activeId?: string;
58
+ readonly onSelect: (id: string) => void;
59
+ readonly onClose?: (id: string) => void;
60
+ readonly actions?: ReactNode;
61
+ readonly ariaLabel?: string;
62
+ readonly className?: string;
63
+ }
64
+ export declare function TabStrip({ tabs, activeId, onSelect, onClose, actions, ariaLabel, className }: TabStripProps): import("react").JSX.Element;
65
+ export interface StatusBarItem {
66
+ readonly id: string;
67
+ readonly label: string;
68
+ readonly value?: string;
69
+ readonly tone?: Tone;
70
+ readonly pulse?: boolean;
71
+ readonly align?: 'left' | 'right';
72
+ readonly onClick?: () => void;
73
+ }
74
+ export interface StatusBarProps {
75
+ readonly items?: readonly StatusBarItem[];
76
+ readonly left?: ReactNode;
77
+ readonly right?: ReactNode;
78
+ readonly className?: string;
79
+ }
80
+ export declare function StatusBar({ items, left, right, className }: StatusBarProps): import("react").JSX.Element;
81
+ export interface CommandPaletteItem {
82
+ readonly id: string;
83
+ readonly label: string;
84
+ readonly description?: string;
85
+ readonly group?: string;
86
+ readonly shortcut?: string;
87
+ readonly keywords?: readonly string[];
88
+ readonly disabled?: boolean;
89
+ }
90
+ export interface CommandPaletteProps {
91
+ readonly open: boolean;
92
+ readonly onOpenChange: (open: boolean) => void;
93
+ readonly items: readonly CommandPaletteItem[];
94
+ readonly onSelect: (item: CommandPaletteItem) => void;
95
+ readonly placeholder?: string;
96
+ readonly emptyTitle?: string;
97
+ /** Bind global `Cmd/Ctrl+K` shortcut to toggle the palette. Default `false`. */
98
+ readonly bindHotkey?: boolean;
99
+ readonly className?: string;
100
+ }
101
+ export declare function CommandPalette({ open, onOpenChange, items, onSelect, placeholder, emptyTitle, bindHotkey, className, }: CommandPaletteProps): import("react").JSX.Element | null;