@mistriwork/agent-ui 1.4.1 → 1.5.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.
- package/dist/agentIde.d.ts +43 -2
- package/dist/agentIde.js +163 -27
- package/dist/fileTree.d.ts +29 -3
- package/dist/fileTree.js +82 -13
- package/dist/index.d.ts +3 -3
- package/dist/orchestrator.d.ts +25 -1
- package/dist/orchestrator.js +102 -33
- package/dist/pierre.d.ts +1 -1
- package/dist/pierreAdapter.d.ts +62 -32
- package/dist/pierreAdapter.js +299 -65
- package/dist/surfaces.d.ts +18 -1
- package/dist/surfaces.js +13 -2
- package/dist/tools.d.ts +14 -2
- package/dist/tools.js +97 -11
- package/dist/workbench.css +122 -0
- package/package.json +2 -2
package/dist/tools.js
CHANGED
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* - `<ModeSwitcher>`: compact agent mode selector (`Ask` / `Plan` / `Agent` / `Review`)
|
|
7
7
|
* - `<ModelPicker>`: compact model / ACP provider selector
|
|
8
8
|
*/
|
|
9
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { Badge, Button, EmptyState, SegmentedControl, Select, StatusDot, TextField } from '@mistriwork/mistri/ui';
|
|
11
11
|
import './workbench.css';
|
|
12
12
|
function callTone(status) {
|
|
@@ -16,22 +16,49 @@ function callTone(status) {
|
|
|
16
16
|
return 'critical';
|
|
17
17
|
return 'info';
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const ToolCallCard = memo(function ToolCallCard({ call, defaultOpen, maxOutputChars, onSelect }) {
|
|
20
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
21
|
+
const [showFullOutput, setShowFullOutput] = useState(false);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (defaultOpen)
|
|
24
|
+
setOpen(true);
|
|
25
|
+
}, [defaultOpen]);
|
|
26
|
+
const inputJson = useMemo(() => (open && call.input ? JSON.stringify(call.input, null, 2) : undefined), [open, call.input]);
|
|
27
|
+
const outputInfo = useMemo(() => {
|
|
28
|
+
if (!open || !call.output)
|
|
29
|
+
return undefined;
|
|
30
|
+
const total = call.output.length;
|
|
31
|
+
if (showFullOutput || !Number.isFinite(maxOutputChars) || total <= maxOutputChars) {
|
|
32
|
+
return { text: call.output, truncated: false, total };
|
|
33
|
+
}
|
|
34
|
+
return { text: call.output.slice(0, maxOutputChars), truncated: true, total };
|
|
35
|
+
}, [open, call.output, showFullOutput, maxOutputChars]);
|
|
36
|
+
return (_jsxs("details", { className: "aui-tool-card", open: open, onToggle: (e) => {
|
|
37
|
+
const nextOpen = e.currentTarget.open;
|
|
38
|
+
setOpen(nextOpen);
|
|
39
|
+
if (nextOpen)
|
|
40
|
+
onSelect?.(call.id);
|
|
41
|
+
}, children: [_jsxs("summary", { className: "aui-tool-card-summary", children: [_jsx(StatusDot, { tone: callTone(call.status), pulse: call.status === 'running' }), _jsx("span", { children: call.label ?? call.name }), _jsx(Badge, { tone: callTone(call.status), children: call.status }), call.durationMs !== undefined ? _jsx("span", { className: "kit-agent-msg-meta", children: `${call.durationMs}ms` }) : null] }), open ? (_jsxs("div", { className: "aui-tool-card-body", children: [inputJson ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Input" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: inputJson }) })] })) : null, call.error ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Error" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.error }) })] })) : null, outputInfo ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Output" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: outputInfo.text }) }), outputInfo.truncated ? (_jsxs("div", { className: "aui-truncate-bar", children: [_jsx("span", { children: `Showing ${maxOutputChars.toLocaleString()} of ${outputInfo.total.toLocaleString()} chars` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setShowFullOutput(true), children: "Show full output" })] })) : null] })) : null] })) : null] }));
|
|
42
|
+
});
|
|
43
|
+
export function ToolCallInspector({ calls, selectedId, onSelect, title = 'Tool calls', initialVisibleCount = 50, loadMoreStep = 50, maxOutputChars = 8_000, empty, className, }) {
|
|
20
44
|
const [filter, setFilter] = useState('all');
|
|
45
|
+
const [visibleLimit, setVisibleLimit] = useState(initialVisibleCount);
|
|
21
46
|
const visible = useMemo(() => {
|
|
22
47
|
if (filter === 'all')
|
|
23
48
|
return calls;
|
|
24
49
|
return calls.filter((c) => c.status === filter);
|
|
25
50
|
}, [calls, filter]);
|
|
26
|
-
|
|
51
|
+
const hiddenCount = Number.isFinite(visibleLimit) ? Math.max(0, visible.length - visibleLimit) : 0;
|
|
52
|
+
const windowed = useMemo(() => (hiddenCount > 0 ? visible.slice(visible.length - visibleLimit) : visible), [visible, hiddenCount, visibleLimit]);
|
|
53
|
+
return (_jsxs("section", { className: className ? `aui-tool-inspector ${className}` : 'aui-tool-inspector', "aria-label": title, children: [_jsxs("header", { className: "aui-tool-inspector-head", children: [_jsxs("span", { className: "aui-approval-queue-title", children: [_jsx("span", { children: title }), _jsx(Badge, { tone: "neutral", children: String(calls.length) })] }), _jsx(SegmentedControl, { ariaLabel: "Filter tool calls", size: "sm", value: filter, onValueChange: (next) => {
|
|
54
|
+
setFilter(next);
|
|
55
|
+
setVisibleLimit(initialVisibleCount);
|
|
56
|
+
}, options: [
|
|
27
57
|
{ value: 'all', label: 'All' },
|
|
28
58
|
{ value: 'running', label: 'Running' },
|
|
29
59
|
{ value: 'completed', label: 'Done' },
|
|
30
60
|
{ value: 'failed', label: 'Failed' },
|
|
31
|
-
] })] }), visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No tool calls" }))) : (
|
|
32
|
-
if (e.currentTarget.open)
|
|
33
|
-
onSelect?.(call.id);
|
|
34
|
-
}, children: [_jsxs("summary", { className: "aui-tool-card-summary", children: [_jsx(StatusDot, { tone: callTone(call.status), pulse: call.status === 'running' }), _jsx("span", { children: call.label ?? call.name }), _jsx(Badge, { tone: callTone(call.status), children: call.status }), call.durationMs !== undefined ? _jsx("span", { className: "kit-agent-msg-meta", children: `${call.durationMs}ms` }) : null] }), _jsxs("div", { className: "aui-tool-card-body", children: [call.input ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Input" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: JSON.stringify(call.input, null, 2) }) })] })) : null, call.error ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Error" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.error }) })] })) : null, call.output ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Output" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.output }) })] })) : null] })] }, call.id))) }))] }));
|
|
61
|
+
] })] }), visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No tool calls" }))) : (_jsxs("div", { className: "aui-tool-inspector-list", children: [hiddenCount > 0 ? (_jsxs("div", { className: "aui-thread-window-bar", children: [_jsx("span", { children: `Showing latest ${windowed.length} of ${visible.length} calls` }), _jsxs("div", { className: "aui-session-actions", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit((n) => n + loadMoreStep), children: `Show ${Math.min(loadMoreStep, hiddenCount)} earlier` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit(Number.POSITIVE_INFINITY), children: "Show all" })] })] })) : null, windowed.map((call) => (_jsx(ToolCallCard, { call: call, defaultOpen: selectedId === call.id || call.status === 'failed', maxOutputChars: maxOutputChars, onSelect: onSelect }, call.id)))] }))] }));
|
|
35
62
|
}
|
|
36
63
|
const ANSI_FG_CLASS = {
|
|
37
64
|
30: 'aui-ansi-muted',
|
|
@@ -125,10 +152,20 @@ export function parseAnsiLine(line) {
|
|
|
125
152
|
}
|
|
126
153
|
return segments;
|
|
127
154
|
}
|
|
128
|
-
|
|
155
|
+
const DEFAULT_VIEWPORT_HEIGHT = 384;
|
|
156
|
+
function renderAnsiLine(line, key) {
|
|
157
|
+
return (_jsx("div", { className: "aui-terminal-line", children: parseAnsiLine(line).map((seg, segIdx) => seg.className ? (_jsx("span", { className: seg.className, children: seg.text }, segIdx)) : (_jsx("span", { children: seg.text }, segIdx))) }, key));
|
|
158
|
+
}
|
|
159
|
+
export function TerminalOutput({ text, lines, title = 'Terminal', running = false, searchable = false, autoFollow = true, defaultWrap = true, virtualizeThreshold = 200, rowHeight = 20, overscan = 25, onClear, className, }) {
|
|
129
160
|
const [wrap, setWrap] = useState(defaultWrap);
|
|
130
161
|
const [query, setQuery] = useState('');
|
|
162
|
+
const [following, setFollowing] = useState(autoFollow);
|
|
163
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
164
|
+
const [viewportHeight, setViewportHeight] = useState(DEFAULT_VIEWPORT_HEIGHT);
|
|
131
165
|
const bodyRef = useRef(null);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
setFollowing(autoFollow);
|
|
168
|
+
}, [autoFollow]);
|
|
132
169
|
const allLines = useMemo(() => {
|
|
133
170
|
if (lines)
|
|
134
171
|
return lines;
|
|
@@ -142,12 +179,61 @@ export function TerminalOutput({ text, lines, title = 'Terminal', running = fals
|
|
|
142
179
|
return allLines;
|
|
143
180
|
return allLines.filter((line) => line.replace(ANSI_SGR_RE, '').toLowerCase().includes(q));
|
|
144
181
|
}, [allLines, query]);
|
|
182
|
+
const virtualized = filteredLines.length > virtualizeThreshold;
|
|
183
|
+
const { startIndex, endIndex, topPad, bottomPad } = useMemo(() => {
|
|
184
|
+
if (!virtualized) {
|
|
185
|
+
return { startIndex: 0, endIndex: filteredLines.length, topPad: 0, bottomPad: 0 };
|
|
186
|
+
}
|
|
187
|
+
const visibleRows = Math.max(1, Math.ceil(viewportHeight / rowHeight));
|
|
188
|
+
if (following) {
|
|
189
|
+
const end = filteredLines.length;
|
|
190
|
+
const start = Math.max(0, end - visibleRows - overscan * 2);
|
|
191
|
+
return {
|
|
192
|
+
startIndex: start,
|
|
193
|
+
endIndex: end,
|
|
194
|
+
topPad: start * rowHeight,
|
|
195
|
+
bottomPad: 0,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const rawStart = Math.floor(scrollTop / rowHeight);
|
|
199
|
+
const start = Math.max(0, rawStart - overscan);
|
|
200
|
+
const end = Math.min(filteredLines.length, rawStart + visibleRows + overscan);
|
|
201
|
+
return {
|
|
202
|
+
startIndex: start,
|
|
203
|
+
endIndex: end,
|
|
204
|
+
topPad: start * rowHeight,
|
|
205
|
+
bottomPad: Math.max(0, (filteredLines.length - end) * rowHeight),
|
|
206
|
+
};
|
|
207
|
+
}, [virtualized, filteredLines.length, viewportHeight, rowHeight, following, scrollTop, overscan]);
|
|
145
208
|
useEffect(() => {
|
|
146
|
-
if (!
|
|
209
|
+
if (!following || !bodyRef.current)
|
|
147
210
|
return;
|
|
148
211
|
bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
|
|
149
|
-
}, [
|
|
150
|
-
|
|
212
|
+
}, [following, filteredLines.length]);
|
|
213
|
+
const handleScroll = useCallback(() => {
|
|
214
|
+
const el = bodyRef.current;
|
|
215
|
+
if (!el)
|
|
216
|
+
return;
|
|
217
|
+
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
218
|
+
if (el.clientHeight > 0)
|
|
219
|
+
setViewportHeight(el.clientHeight);
|
|
220
|
+
setScrollTop(el.scrollTop);
|
|
221
|
+
if (distanceFromBottom > rowHeight * 2) {
|
|
222
|
+
setFollowing(false);
|
|
223
|
+
}
|
|
224
|
+
else if (autoFollow) {
|
|
225
|
+
setFollowing(true);
|
|
226
|
+
}
|
|
227
|
+
}, [autoFollow, rowHeight]);
|
|
228
|
+
const jumpToTail = useCallback(() => {
|
|
229
|
+
setFollowing(true);
|
|
230
|
+
if (bodyRef.current) {
|
|
231
|
+
bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
|
|
232
|
+
setScrollTop(bodyRef.current.scrollTop);
|
|
233
|
+
}
|
|
234
|
+
}, []);
|
|
235
|
+
const visibleSlice = useMemo(() => (virtualized ? filteredLines.slice(startIndex, endIndex) : filteredLines), [virtualized, filteredLines, startIndex, endIndex]);
|
|
236
|
+
return (_jsxs("section", { className: className ? `aui-terminal ${className}` : 'aui-terminal', "aria-label": title, children: [_jsxs("header", { className: "aui-terminal-head", children: [_jsxs("span", { className: "aui-terminal-title", children: [_jsx(StatusDot, { tone: running ? 'info' : 'neutral', pulse: running }), _jsx("span", { children: title }), running ? _jsx(Badge, { tone: "info", children: "Running" }) : null, virtualized ? _jsx(Badge, { tone: "neutral", children: `${filteredLines.length.toLocaleString()} lines` }) : null] }), _jsxs("div", { className: "aui-terminal-controls", children: [searchable ? (_jsx(TextField, { label: "Filter output", labelHidden: true, reserve: false, value: query, onValueChange: (next) => setQuery(next), placeholder: "Filter logs\u2026" })) : null, !following && filteredLines.length > 0 ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: jumpToTail, children: "Follow tail" })) : null, _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setWrap((w) => !w), children: wrap ? 'No wrap' : 'Wrap' }), onClear ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onClear, children: "Clear" })) : null] })] }), _jsxs("pre", { ref: bodyRef, className: "aui-terminal-body", "data-wrap": wrap ? 'true' : 'false', "data-virtualized": virtualized ? 'true' : undefined, onScroll: handleScroll, children: [topPad > 0 ? _jsx("div", { "aria-hidden": "true", style: { height: `${topPad}px` } }) : null, visibleSlice.map((line, offset) => renderAnsiLine(line, startIndex + offset)), bottomPad > 0 ? _jsx("div", { "aria-hidden": "true", style: { height: `${bottomPad}px` } }) : null] })] }));
|
|
151
237
|
}
|
|
152
238
|
const DEFAULT_MODES = [
|
|
153
239
|
{ value: 'ask', label: 'Ask' },
|
package/dist/workbench.css
CHANGED
|
@@ -791,4 +791,126 @@
|
|
|
791
791
|
flex: 0 0 auto;
|
|
792
792
|
text-align: center;
|
|
793
793
|
}
|
|
794
|
+
|
|
795
|
+
/* ==========================================================================
|
|
796
|
+
* SessionTree Actions/Repos, Multi-Root Headers & Long-Session Controls
|
|
797
|
+
* ======================================================================== */
|
|
798
|
+
.aui-session-repos {
|
|
799
|
+
display: flex;
|
|
800
|
+
flex-wrap: wrap;
|
|
801
|
+
align-items: center;
|
|
802
|
+
gap: var(--space-1);
|
|
803
|
+
}
|
|
804
|
+
.aui-session-actions {
|
|
805
|
+
display: inline-flex;
|
|
806
|
+
flex-wrap: wrap;
|
|
807
|
+
align-items: center;
|
|
808
|
+
gap: var(--space-1);
|
|
809
|
+
margin-inline-start: auto;
|
|
810
|
+
}
|
|
811
|
+
.aui-session-rename {
|
|
812
|
+
flex: 1 1 auto;
|
|
813
|
+
min-width: 0;
|
|
814
|
+
}
|
|
815
|
+
.aui-session-row[data-archived='true'] {
|
|
816
|
+
opacity: 0.72;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
.aui-file-tree-roots,
|
|
820
|
+
.aui-diff-roots {
|
|
821
|
+
display: flex;
|
|
822
|
+
flex-direction: column;
|
|
823
|
+
gap: var(--space-2);
|
|
824
|
+
min-width: 0;
|
|
825
|
+
}
|
|
826
|
+
.aui-file-tree-root,
|
|
827
|
+
.aui-diff-root {
|
|
828
|
+
display: flex;
|
|
829
|
+
flex-direction: column;
|
|
830
|
+
gap: var(--space-1h);
|
|
831
|
+
min-width: 0;
|
|
832
|
+
}
|
|
833
|
+
.aui-file-tree-root-head,
|
|
834
|
+
.aui-diff-root-head {
|
|
835
|
+
display: flex;
|
|
836
|
+
align-items: center;
|
|
837
|
+
gap: var(--space-2);
|
|
838
|
+
width: 100%;
|
|
839
|
+
padding: var(--space-1h) var(--space-2);
|
|
840
|
+
border: 1px solid var(--line);
|
|
841
|
+
border-radius: var(--radius);
|
|
842
|
+
background: var(--raised);
|
|
843
|
+
color: var(--ink);
|
|
844
|
+
font-family: var(--mono);
|
|
845
|
+
font-size: var(--text-xs);
|
|
846
|
+
font-weight: 600;
|
|
847
|
+
text-align: start;
|
|
848
|
+
cursor: pointer;
|
|
849
|
+
}
|
|
850
|
+
@media (hover: hover) {
|
|
851
|
+
.aui-file-tree-root-head:hover,
|
|
852
|
+
.aui-diff-root-head:hover {
|
|
853
|
+
background: color-mix(in srgb, var(--surface) 60%, var(--raised));
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
.aui-file-tree-root-label,
|
|
857
|
+
.aui-diff-root-label {
|
|
858
|
+
flex: 1 1 auto;
|
|
859
|
+
min-width: 0;
|
|
860
|
+
overflow: hidden;
|
|
861
|
+
text-overflow: ellipsis;
|
|
862
|
+
white-space: nowrap;
|
|
863
|
+
}
|
|
864
|
+
.aui-diff-root-body {
|
|
865
|
+
display: flex;
|
|
866
|
+
flex-direction: column;
|
|
867
|
+
gap: var(--space-2);
|
|
868
|
+
min-width: 0;
|
|
869
|
+
}
|
|
870
|
+
.aui-diff-file-toggle {
|
|
871
|
+
display: inline-flex;
|
|
872
|
+
align-items: center;
|
|
873
|
+
justify-content: center;
|
|
874
|
+
padding: 0 var(--space-1);
|
|
875
|
+
border: none;
|
|
876
|
+
background: transparent;
|
|
877
|
+
color: var(--ink-muted);
|
|
878
|
+
font-family: var(--mono);
|
|
879
|
+
font-size: var(--text-xs);
|
|
880
|
+
cursor: pointer;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
.aui-thread-sticky {
|
|
884
|
+
position: relative;
|
|
885
|
+
overflow-y: auto;
|
|
886
|
+
min-height: 0;
|
|
887
|
+
}
|
|
888
|
+
.aui-thread-window-bar,
|
|
889
|
+
.aui-truncate-bar {
|
|
890
|
+
display: flex;
|
|
891
|
+
flex-wrap: wrap;
|
|
892
|
+
align-items: center;
|
|
893
|
+
justify-content: space-between;
|
|
894
|
+
gap: var(--space-2);
|
|
895
|
+
padding: var(--space-1h) var(--space-2h);
|
|
896
|
+
border: 1px solid var(--line);
|
|
897
|
+
border-radius: var(--radius);
|
|
898
|
+
background: var(--raised);
|
|
899
|
+
color: var(--ink-muted);
|
|
900
|
+
font-size: var(--text-xs);
|
|
901
|
+
font-family: var(--mono);
|
|
902
|
+
}
|
|
903
|
+
.aui-thread-jump {
|
|
904
|
+
position: sticky;
|
|
905
|
+
bottom: var(--space-2);
|
|
906
|
+
display: flex;
|
|
907
|
+
justify-content: center;
|
|
908
|
+
pointer-events: none;
|
|
909
|
+
}
|
|
910
|
+
.aui-thread-jump > * {
|
|
911
|
+
pointer-events: auto;
|
|
912
|
+
}
|
|
913
|
+
.aui-terminal-line {
|
|
914
|
+
min-height: 1.25em;
|
|
915
|
+
}
|
|
794
916
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/agent-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Opt-in React workbench, orchestrator, and AI IDE primitives for Mistri Apps, with an optional @pierre/diffs & @pierre/trees adapter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mistri",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@mistriwork/mistri": "1.
|
|
43
|
+
"@mistriwork/mistri": "1.5.0",
|
|
44
44
|
"@pierre/diffs": ">=1.0.0",
|
|
45
45
|
"@pierre/trees": ">=1.0.0",
|
|
46
46
|
"react": ">=19"
|