@volter-ai-dev/supercode-ui 0.1.70 → 0.1.72
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/README.md +61 -1
- package/activity.mjs +5 -1235
- package/chunks/chunk-2FG7VKIW.mjs +201 -0
- package/chunks/chunk-4XUMCWPC.mjs +29 -0
- package/chunks/chunk-E65I2I2L.mjs +120 -0
- package/chunks/chunk-IL5T2AST.mjs +842 -0
- package/chunks/chunk-LOP6XOON.mjs +671 -0
- package/chunks/chunk-LS6JBXNT.mjs +1237 -0
- package/chunks/chunk-SJ3YTA6Z.mjs +316 -0
- package/chunks/chunk-TKTOVDXB.mjs +139 -0
- package/chunks/chunk-V3UM7H7W.mjs +328 -0
- package/chunks/chunk-WRK5TBX3.mjs +224 -0
- package/chunks/chunk-ZLYHUYE2.mjs +62 -0
- package/components.d.ts +3 -0
- package/components.mjs +59 -3766
- package/composer.mjs +8 -580
- package/conversation.mjs +16 -1373
- package/embed.mjs +15 -3681
- package/icon.mjs +3 -58
- package/index.d.ts +25 -0
- package/logo.mjs +5 -87
- package/messenger.d.ts +3 -0
- package/messenger.mjs +21 -3677
- package/package.json +22 -3
- package/react/activity.mjs +5 -1235
- package/react/chunks/chunk-7ES5FSLG.mjs +316 -0
- package/react/chunks/chunk-LS6JBXNT.mjs +1237 -0
- package/react/chunks/chunk-LYRIQE5M.mjs +29 -0
- package/react/chunks/chunk-NJC6S2AW.mjs +201 -0
- package/react/chunks/chunk-OINC7LV7.mjs +62 -0
- package/react/chunks/chunk-QL6QEYPK.mjs +842 -0
- package/react/chunks/chunk-UGL6AB2K.mjs +120 -0
- package/react/chunks/chunk-UKHDCPME.mjs +328 -0
- package/react/chunks/chunk-UKMTRNJN.mjs +671 -0
- package/react/chunks/chunk-VFOVJ4S3.mjs +139 -0
- package/react/chunks/chunk-YK7SJ6EH.mjs +224 -0
- package/react/components.mjs +59 -3766
- package/react/composer.mjs +8 -580
- package/react/conversation.mjs +16 -1373
- package/react/icon.mjs +3 -58
- package/react/index.d.ts +25 -0
- package/react/logo.mjs +5 -87
- package/react/messenger.d.ts +3 -0
- package/react/messenger.mjs +21 -3677
- package/react/sessions.mjs +9 -519
- package/react/settings.mjs +9 -425
- package/react/subagents.mjs +8 -1546
- package/react/supervision-components.mjs +1354 -0
- package/react/supervision.d.ts +36 -0
- package/sessions.mjs +9 -519
- package/settings.mjs +9 -425
- package/source-inventory.d.ts +240 -0
- package/source-inventory.mjs +367 -0
- package/styles.css +104 -0
- package/subagents.mjs +8 -1546
- package/supervision-components.d.ts +36 -0
- package/supervision-components.mjs +1354 -0
- package/supervision.d.ts +242 -0
- package/supervision.mjs +349 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MessageImages,
|
|
3
|
+
boundedSet,
|
|
4
|
+
uiMemory
|
|
5
|
+
} from "./chunk-V3UM7H7W.mjs";
|
|
6
|
+
import {
|
|
7
|
+
activitySummary,
|
|
8
|
+
compactToolTarget,
|
|
9
|
+
createToolPresentation,
|
|
10
|
+
groupConversation,
|
|
11
|
+
harnessDisplayName,
|
|
12
|
+
toolCategory
|
|
13
|
+
} from "./chunk-LS6JBXNT.mjs";
|
|
14
|
+
import {
|
|
15
|
+
UiIcon
|
|
16
|
+
} from "./chunk-ZLYHUYE2.mjs";
|
|
17
|
+
|
|
18
|
+
// src/conversation.jsx
|
|
19
|
+
import { Fragment } from "preact";
|
|
20
|
+
import { useEffect as useEffect2, useId, useLayoutEffect, useRef as useRef2, useState } from "preact/hooks";
|
|
21
|
+
|
|
22
|
+
// src/markdown.jsx
|
|
23
|
+
import MarkdownIt from "markdown-it";
|
|
24
|
+
import { useEffect, useMemo, useRef } from "preact/hooks";
|
|
25
|
+
import { jsx } from "preact/jsx-runtime";
|
|
26
|
+
var markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
|
|
27
|
+
var LANGUAGE_LABELS = {
|
|
28
|
+
bash: "Shell",
|
|
29
|
+
css: "CSS",
|
|
30
|
+
html: "HTML",
|
|
31
|
+
js: "JavaScript",
|
|
32
|
+
javascript: "JavaScript",
|
|
33
|
+
jsx: "JSX",
|
|
34
|
+
md: "Markdown",
|
|
35
|
+
markdown: "Markdown",
|
|
36
|
+
py: "Python",
|
|
37
|
+
python: "Python",
|
|
38
|
+
rs: "Rust",
|
|
39
|
+
rust: "Rust",
|
|
40
|
+
sh: "Shell",
|
|
41
|
+
shell: "Shell",
|
|
42
|
+
ts: "TypeScript",
|
|
43
|
+
tsx: "TSX",
|
|
44
|
+
yaml: "YAML",
|
|
45
|
+
yml: "YAML",
|
|
46
|
+
json: "JSON",
|
|
47
|
+
jsonc: "JSONC",
|
|
48
|
+
sql: "SQL",
|
|
49
|
+
xml: "XML"
|
|
50
|
+
};
|
|
51
|
+
var COPY_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="5" width="8" height="8" rx="1.5"></rect><path d="M3 10.5V4.25C3 3.56 3.56 3 4.25 3h6.25"></path></svg>';
|
|
52
|
+
function languageLabel(info) {
|
|
53
|
+
const language = info.trim().split(/\s+/, 1)[0]?.toLocaleLowerCase() ?? "";
|
|
54
|
+
if (!language) return "Code";
|
|
55
|
+
return LANGUAGE_LABELS[language] ?? language.toLocaleUpperCase();
|
|
56
|
+
}
|
|
57
|
+
function frameCode(render, tokens, index, options, env, self) {
|
|
58
|
+
const label = markdown.utils.escapeHtml(languageLabel(tokens[index]?.info ?? ""));
|
|
59
|
+
const body = render(tokens, index, options, env, self).replace(
|
|
60
|
+
"<pre>",
|
|
61
|
+
`<pre tabindex="0" role="region" aria-label="${label} code">`
|
|
62
|
+
);
|
|
63
|
+
return `<div class="scui-code-block"><div class="scui-code-head"><span>${label}</span><button class="scui-code-copy" type="button" aria-label="Copy code" title="Copy code">${COPY_ICON}<span>Copy</span></button></div>${body}</div>`;
|
|
64
|
+
}
|
|
65
|
+
for (const kind of ["fence", "code_block"]) {
|
|
66
|
+
const render = markdown.renderer.rules[kind];
|
|
67
|
+
markdown.renderer.rules[kind] = (tokens, index, options, env, self) => frameCode(render, tokens, index, options, env, self);
|
|
68
|
+
}
|
|
69
|
+
var defaultLinkOpen = markdown.renderer.rules.link_open;
|
|
70
|
+
markdown.renderer.rules.link_open = (tokens, index, options, env, self) => {
|
|
71
|
+
tokens[index]?.attrSet("target", "_blank");
|
|
72
|
+
tokens[index]?.attrSet("rel", "noreferrer noopener");
|
|
73
|
+
return defaultLinkOpen ? defaultLinkOpen(tokens, index, options, env, self) : self.renderToken(tokens, index, options);
|
|
74
|
+
};
|
|
75
|
+
function setCopyState(button, status) {
|
|
76
|
+
const labels = {
|
|
77
|
+
idle: ["Copy code", "Copy"],
|
|
78
|
+
copied: ["Code copied", "Copied"],
|
|
79
|
+
failed: ["Copy failed \xB7 retry", "Retry"]
|
|
80
|
+
};
|
|
81
|
+
const [label, visible] = labels[status];
|
|
82
|
+
button.dataset.status = status;
|
|
83
|
+
button.setAttribute("aria-label", label);
|
|
84
|
+
button.setAttribute("title", label);
|
|
85
|
+
const text = button.querySelector("span");
|
|
86
|
+
if (text) text.textContent = visible;
|
|
87
|
+
}
|
|
88
|
+
function Markdown({ value, copyText }) {
|
|
89
|
+
const html = useMemo(() => markdown.render(value), [value]);
|
|
90
|
+
const resets = useRef(/* @__PURE__ */ new Map());
|
|
91
|
+
useEffect(() => () => {
|
|
92
|
+
for (const timer of resets.current.values()) clearTimeout(timer);
|
|
93
|
+
resets.current.clear();
|
|
94
|
+
}, []);
|
|
95
|
+
const copyCode = async (event) => {
|
|
96
|
+
const button = event.target.closest?.(".scui-code-copy");
|
|
97
|
+
if (!button || !event.currentTarget.contains(button) || !copyText) return;
|
|
98
|
+
const code = button.closest(".scui-code-block")?.querySelector("pre code");
|
|
99
|
+
if (!code) return;
|
|
100
|
+
button.disabled = true;
|
|
101
|
+
try {
|
|
102
|
+
await copyText(code.textContent ?? "");
|
|
103
|
+
setCopyState(button, "copied");
|
|
104
|
+
} catch {
|
|
105
|
+
setCopyState(button, "failed");
|
|
106
|
+
} finally {
|
|
107
|
+
button.disabled = false;
|
|
108
|
+
}
|
|
109
|
+
clearTimeout(resets.current.get(button));
|
|
110
|
+
const timer = setTimeout(() => {
|
|
111
|
+
if (button.isConnected) setCopyState(button, "idle");
|
|
112
|
+
resets.current.delete(button);
|
|
113
|
+
}, 1500);
|
|
114
|
+
resets.current.set(button, timer);
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: "scui-markdown", "data-copyable": Boolean(copyText), onClick: copyCode, dangerouslySetInnerHTML: { __html: html } });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/conversation.jsx
|
|
120
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs } from "preact/jsx-runtime";
|
|
121
|
+
function LoadingStatus({ state, compact = false }) {
|
|
122
|
+
const copy = {
|
|
123
|
+
connecting: ["Connecting to coding agents", "Checking installed harnesses and capabilities.", 0],
|
|
124
|
+
starting: [`Starting ${harnessDisplayName(state.harness) || "coding agent"}`, "Opening a controlled session in this workspace.", 1],
|
|
125
|
+
discovering: ["Loading recent sessions", "Scanning native session stores without loading full transcripts.", 2],
|
|
126
|
+
ready: ["Ready", "Coding sessions are up to date.", 3]
|
|
127
|
+
}[state.startup];
|
|
128
|
+
return /* @__PURE__ */ jsxs("div", { className: `scui-loading${compact ? " scui-loading-compact" : ""}`, role: "status", "aria-busy": state.startup !== "ready", children: [
|
|
129
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-orbit", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("i", {}) }),
|
|
130
|
+
/* @__PURE__ */ jsxs("span", { className: "scui-loading-copy", children: [
|
|
131
|
+
/* @__PURE__ */ jsx2("strong", { children: copy[0] }),
|
|
132
|
+
/* @__PURE__ */ jsx2("small", { children: copy[1] })
|
|
133
|
+
] }),
|
|
134
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-progress", "aria-hidden": "true", children: [1, 2, 3].map((step) => /* @__PURE__ */ jsx2("i", { "data-progress": step <= copy[2] ? "done" : step === copy[2] + 1 ? "current" : "waiting" }, step)) })
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
function RequestCard({ entry, adapter, canRespond }) {
|
|
138
|
+
const request = entry.request;
|
|
139
|
+
if (!request) return null;
|
|
140
|
+
if (request.status === "responded") {
|
|
141
|
+
return /* @__PURE__ */ jsxs("div", { className: "scui-request-done", children: [
|
|
142
|
+
"\u2713 Request answered \xB7 ",
|
|
143
|
+
request.resolution?.name ?? request.requestKind
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
return /* @__PURE__ */ jsxs("section", { className: "scui-request", role: "alert", "aria-label": `${request.requestKind} needs input`, children: [
|
|
147
|
+
/* @__PURE__ */ jsx2("strong", { children: "Agent needs input" }),
|
|
148
|
+
/* @__PURE__ */ jsx2(Markdown, { value: request.payloadText || entry.text, copyText: adapter?.copyText }),
|
|
149
|
+
/* @__PURE__ */ jsxs("div", { className: "scui-request-actions", children: [
|
|
150
|
+
request.options.map((option) => /* @__PURE__ */ jsx2("button", { type: "button", disabled: !canRespond, onClick: () => adapter.onIntent({ action: "respond", requestId: request.requestId, optionId: option.optionId }), children: option.name }, option.optionId)),
|
|
151
|
+
request.cancellable ? /* @__PURE__ */ jsx2("button", { type: "button", disabled: !canRespond, onClick: () => adapter.onIntent({ action: "respond", requestId: request.requestId, optionId: null }), children: "Cancel" }) : null
|
|
152
|
+
] })
|
|
153
|
+
] });
|
|
154
|
+
}
|
|
155
|
+
function ContextDisclosure({ context }) {
|
|
156
|
+
if (!context?.length) return null;
|
|
157
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-context", children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("summary", { children: [
|
|
159
|
+
"Context \xB7 ",
|
|
160
|
+
context.length
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ jsx2("div", { children: context.map((item, index) => /* @__PURE__ */ jsxs("p", { children: [
|
|
163
|
+
/* @__PURE__ */ jsx2("strong", { children: item.label }),
|
|
164
|
+
/* @__PURE__ */ jsx2("span", { children: item.detail })
|
|
165
|
+
] }, item.id ?? index)) })
|
|
166
|
+
] });
|
|
167
|
+
}
|
|
168
|
+
function MessageMeta({ entry, adapter }) {
|
|
169
|
+
const [copyState, setCopyState2] = useState("idle");
|
|
170
|
+
const reset = useRef2(null);
|
|
171
|
+
useEffect2(() => () => clearTimeout(reset.current), []);
|
|
172
|
+
const date = entry.ts === null ? null : new Date(entry.ts);
|
|
173
|
+
const validDate = date && Number.isFinite(date.valueOf()) ? date : null;
|
|
174
|
+
if (!validDate && (!adapter?.copyText || !entry.text)) return null;
|
|
175
|
+
const copy = async () => {
|
|
176
|
+
try {
|
|
177
|
+
await adapter.copyText(entry.text);
|
|
178
|
+
setCopyState2("copied");
|
|
179
|
+
} catch {
|
|
180
|
+
setCopyState2("failed");
|
|
181
|
+
}
|
|
182
|
+
clearTimeout(reset.current);
|
|
183
|
+
reset.current = setTimeout(() => setCopyState2("idle"), 1500);
|
|
184
|
+
};
|
|
185
|
+
const copyLabel = copyState === "copied" ? "Message copied" : copyState === "failed" ? "Copy failed \xB7 retry" : "Copy message";
|
|
186
|
+
return /* @__PURE__ */ jsxs("footer", { className: "scui-message-meta", children: [
|
|
187
|
+
validDate ? /* @__PURE__ */ jsx2("time", { dateTime: validDate.toISOString(), title: validDate.toLocaleString(), children: validDate.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) }) : null,
|
|
188
|
+
adapter?.copyText && entry.text ? /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": copyLabel, title: copyLabel, onClick: copy, "data-status": copyState, children: /* @__PURE__ */ jsx2(UiIcon, { name: "copy", size: 13 }) }) : null
|
|
189
|
+
] });
|
|
190
|
+
}
|
|
191
|
+
var TOOL_ICONS = {
|
|
192
|
+
read: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
193
|
+
/* @__PURE__ */ jsx2("path", { d: "M5 2.75h7.25L15 5.5v7.75A1.75 1.75 0 0 1 13.25 15h-8.5A1.75 1.75 0 0 1 3 13.25v-8.5A2 2 0 0 1 5 2.75Z" }),
|
|
194
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 2.9v3h2.85M6 9h6M6 12h4" })
|
|
195
|
+
] }),
|
|
196
|
+
search: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
197
|
+
/* @__PURE__ */ jsx2("circle", { cx: "8", cy: "8", r: "4.5" }),
|
|
198
|
+
/* @__PURE__ */ jsx2("path", { d: "m11.5 11.5 3 3" })
|
|
199
|
+
] }),
|
|
200
|
+
edit: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
201
|
+
/* @__PURE__ */ jsx2("path", { d: "m11.75 3.25 3 3-8.5 8.5-3.75.75.75-3.75 8.5-8.5Z" }),
|
|
202
|
+
/* @__PURE__ */ jsx2("path", { d: "m10 5 3 3" })
|
|
203
|
+
] }),
|
|
204
|
+
command: () => /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2("path", { d: "m3 5 3 3-3 3M8 12h6" }) }),
|
|
205
|
+
test: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
206
|
+
/* @__PURE__ */ jsx2("path", { d: "M6 2.5v3L3 12a2 2 0 0 0 1.8 3h8.4a2 2 0 0 0 1.8-3l-3-6.5v-3M5 9h8" }),
|
|
207
|
+
/* @__PURE__ */ jsx2("path", { d: "M5 2.5h8" })
|
|
208
|
+
] }),
|
|
209
|
+
web: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
210
|
+
/* @__PURE__ */ jsx2("circle", { cx: "9", cy: "9", r: "6.5" }),
|
|
211
|
+
/* @__PURE__ */ jsx2("path", { d: "M2.75 9h12.5M9 2.5c2 1.8 3 4 3 6.5s-1 4.7-3 6.5c-2-1.8-3-4-3-6.5s1-4.7 3-6.5Z" })
|
|
212
|
+
] }),
|
|
213
|
+
agent: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
214
|
+
/* @__PURE__ */ jsx2("circle", { cx: "9", cy: "6", r: "2.5" }),
|
|
215
|
+
/* @__PURE__ */ jsx2("path", { d: "M4 15c.4-3 2-4.5 5-4.5s4.6 1.5 5 4.5" })
|
|
216
|
+
] }),
|
|
217
|
+
plan: () => /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2("path", { d: "m3 5 1 1 2-2M3 9l1 1 2-2M3 13l1 1 2-2M8 5h7M8 9h7M8 13h7" }) }),
|
|
218
|
+
other: () => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
219
|
+
/* @__PURE__ */ jsx2("path", { d: "M9 2.5v3M9 12.5v3M2.5 9h3M12.5 9h3" }),
|
|
220
|
+
/* @__PURE__ */ jsx2("circle", { cx: "9", cy: "9", r: "3.5" })
|
|
221
|
+
] })
|
|
222
|
+
};
|
|
223
|
+
function ToolIcon({ category }) {
|
|
224
|
+
const Glyph = TOOL_ICONS[category] ?? TOOL_ICONS.other;
|
|
225
|
+
return /* @__PURE__ */ jsx2("svg", { className: "scui-tool-icon", viewBox: "0 0 18 18", fill: "none", stroke: "currentColor", strokeWidth: "1.35", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(Glyph, {}) });
|
|
226
|
+
}
|
|
227
|
+
function toolAction(entry, category, presentation) {
|
|
228
|
+
if (presentation?.action) return presentation.action;
|
|
229
|
+
const status = entry.status ?? "completed";
|
|
230
|
+
const actions = {
|
|
231
|
+
read: ["Reading", "Read", "Read failed"],
|
|
232
|
+
search: ["Searching", "Searched", "Search failed"],
|
|
233
|
+
edit: ["Editing", "Edited", "Edit failed"],
|
|
234
|
+
command: ["Running command", "Ran command", "Command failed"],
|
|
235
|
+
test: ["Running tests", "Ran tests", "Tests failed"],
|
|
236
|
+
web: ["Browsing", "Browsed", "Browser action failed"],
|
|
237
|
+
agent: ["Starting agent", "Started agent", "Agent failed"],
|
|
238
|
+
plan: ["Updating plan", "Updated plan", "Plan update failed"]
|
|
239
|
+
};
|
|
240
|
+
const position = status === "pending" ? 0 : status === "error" ? 2 : 1;
|
|
241
|
+
if (actions[category]) return actions[category][position];
|
|
242
|
+
const label = entry.label?.split(/__|\//).at(-1)?.replaceAll(/[_-]+/g, " ") || "Tool";
|
|
243
|
+
return status === "error" ? `${label} failed` : label;
|
|
244
|
+
}
|
|
245
|
+
function argumentLabel(key) {
|
|
246
|
+
const labels = { cmd: "Command", command: "Command", cwd: "Working directory", file_path: "File", target_file: "File", path: "Path", query: "Query", pattern: "Pattern", url: "URL" };
|
|
247
|
+
return labels[key] ?? key.replaceAll(/[_-]+/g, " ").replace(/^./, (letter) => letter.toLocaleUpperCase());
|
|
248
|
+
}
|
|
249
|
+
function argumentRows(argumentsText) {
|
|
250
|
+
if (!argumentsText) return [];
|
|
251
|
+
try {
|
|
252
|
+
const value = JSON.parse(argumentsText);
|
|
253
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
254
|
+
return Object.entries(value).map(([key, item]) => ({
|
|
255
|
+
key,
|
|
256
|
+
label: argumentLabel(key),
|
|
257
|
+
value: typeof item === "string" ? item : JSON.stringify(item, null, 2)
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
return [{ key: "arguments", label: "Details", value: argumentsText }];
|
|
263
|
+
}
|
|
264
|
+
function stripAnsi(value) {
|
|
265
|
+
return value?.replaceAll(/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*)?\u0007)|(?:(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g, "") ?? "";
|
|
266
|
+
}
|
|
267
|
+
function formatDuration(value) {
|
|
268
|
+
if (value === null) return "";
|
|
269
|
+
if (value < 1e3) return `${Math.round(value)}ms`;
|
|
270
|
+
return `${(value / 1e3).toFixed(value < 1e4 ? 1 : 0)}s`;
|
|
271
|
+
}
|
|
272
|
+
function ToolMetrics({ presentation }) {
|
|
273
|
+
const metrics = [
|
|
274
|
+
presentation.matches === null ? "" : `${presentation.matches} ${presentation.matches === 1 ? "match" : "matches"}`,
|
|
275
|
+
presentation.additions === null ? "" : `+${presentation.additions}`,
|
|
276
|
+
presentation.deletions === null ? "" : `\u2212${presentation.deletions}`,
|
|
277
|
+
presentation.exitCode === null ? "" : `exit ${presentation.exitCode}`,
|
|
278
|
+
formatDuration(presentation.durationMs)
|
|
279
|
+
].filter(Boolean);
|
|
280
|
+
return metrics.length ? /* @__PURE__ */ jsx2("div", { className: "scui-tool-metrics", children: metrics.map((metric) => /* @__PURE__ */ jsx2("span", { children: metric }, metric)) }) : null;
|
|
281
|
+
}
|
|
282
|
+
function PendingElapsed({ now }) {
|
|
283
|
+
const clock = now ?? Date.now;
|
|
284
|
+
const started = useRef2(clock());
|
|
285
|
+
const [elapsed, setElapsed] = useState(0);
|
|
286
|
+
useEffect2(() => {
|
|
287
|
+
const timer = setInterval(() => setElapsed(Math.max(0, clock() - started.current)), 1e3);
|
|
288
|
+
return () => clearInterval(timer);
|
|
289
|
+
}, [clock]);
|
|
290
|
+
return /* @__PURE__ */ jsx2("small", { className: "scui-tool-elapsed", children: elapsed < 1e3 ? "now" : formatDuration(elapsed) });
|
|
291
|
+
}
|
|
292
|
+
function LinePreview({ value, kind }) {
|
|
293
|
+
if (!value) return null;
|
|
294
|
+
return /* @__PURE__ */ jsx2("ol", { className: "scui-code-preview", "data-kind": kind, children: stripAnsi(value).split("\n").map((line, index) => {
|
|
295
|
+
const tone = kind === "diff" ? line.startsWith("+") && !line.startsWith("+++") ? "add" : line.startsWith("-") && !line.startsWith("---") ? "remove" : line.startsWith("@@") ? "hunk" : "plain" : "plain";
|
|
296
|
+
return /* @__PURE__ */ jsxs("li", { "data-tone": tone, children: [
|
|
297
|
+
/* @__PURE__ */ jsx2("span", { children: index + 1 }),
|
|
298
|
+
/* @__PURE__ */ jsx2("code", { children: line || " " })
|
|
299
|
+
] }, index);
|
|
300
|
+
}) });
|
|
301
|
+
}
|
|
302
|
+
function TerminalPreview({ presentation, pending, failed }) {
|
|
303
|
+
return /* @__PURE__ */ jsxs("section", { className: "scui-terminal", children: [
|
|
304
|
+
/* @__PURE__ */ jsxs("header", { children: [
|
|
305
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", children: [
|
|
306
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
307
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
308
|
+
/* @__PURE__ */ jsx2("i", {})
|
|
309
|
+
] }),
|
|
310
|
+
/* @__PURE__ */ jsx2("code", { children: presentation.command ? `$ ${presentation.command}` : "Terminal" })
|
|
311
|
+
] }),
|
|
312
|
+
presentation.preview ? /* @__PURE__ */ jsx2("pre", { "data-error": failed, children: stripAnsi(presentation.preview) }) : pending ? /* @__PURE__ */ jsxs("div", { className: "scui-terminal-wait", children: [
|
|
313
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
314
|
+
" Waiting for output"
|
|
315
|
+
] }) : /* @__PURE__ */ jsx2("div", { className: "scui-terminal-empty", children: "No output" })
|
|
316
|
+
] });
|
|
317
|
+
}
|
|
318
|
+
function SearchPreview({ presentation }) {
|
|
319
|
+
const lines = stripAnsi(presentation.preview).split("\n").filter(Boolean);
|
|
320
|
+
return /* @__PURE__ */ jsxs("section", { className: "scui-search-preview", children: [
|
|
321
|
+
presentation.query ? /* @__PURE__ */ jsxs("header", { children: [
|
|
322
|
+
/* @__PURE__ */ jsx2("span", { children: "Search" }),
|
|
323
|
+
/* @__PURE__ */ jsx2("code", { children: presentation.query })
|
|
324
|
+
] }) : null,
|
|
325
|
+
lines.length ? /* @__PURE__ */ jsx2("ol", { children: lines.map((line, index) => {
|
|
326
|
+
const match = /^(.*?):(\d+)(?::(\d+))?:(.*)$/.exec(line);
|
|
327
|
+
return /* @__PURE__ */ jsx2("li", { children: match ? /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
328
|
+
/* @__PURE__ */ jsx2("code", { children: match[1] }),
|
|
329
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
330
|
+
match[2],
|
|
331
|
+
match[3] ? `:${match[3]}` : ""
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ jsx2("span", { children: match[4] })
|
|
334
|
+
] }) : /* @__PURE__ */ jsx2("span", { children: line }) }, index);
|
|
335
|
+
}) }) : /* @__PURE__ */ jsx2("p", { children: "No textual results" })
|
|
336
|
+
] });
|
|
337
|
+
}
|
|
338
|
+
function ToolPreview({ presentation, entry }) {
|
|
339
|
+
const pending = entry.status === "pending";
|
|
340
|
+
const failed = entry.status === "error";
|
|
341
|
+
if (presentation.detail === "terminal") return /* @__PURE__ */ jsx2(TerminalPreview, { presentation, pending, failed });
|
|
342
|
+
if (presentation.detail === "diff") return presentation.preview ? /* @__PURE__ */ jsx2(LinePreview, { value: presentation.preview, kind: "diff" }) : /* @__PURE__ */ jsx2("div", { className: "scui-tool-empty", children: "Edit completed without a textual diff" });
|
|
343
|
+
if (presentation.detail === "file") return presentation.preview ? /* @__PURE__ */ jsx2(LinePreview, { value: presentation.preview, kind: "file" }) : /* @__PURE__ */ jsx2("div", { className: "scui-tool-empty", children: "File contents were not included in this event" });
|
|
344
|
+
if (presentation.detail === "matches") return /* @__PURE__ */ jsx2(SearchPreview, { presentation });
|
|
345
|
+
if (presentation.detail === "web") return /* @__PURE__ */ jsxs("section", { className: "scui-web-preview", children: [
|
|
346
|
+
presentation.url ? /* @__PURE__ */ jsx2("code", { children: presentation.url }) : null,
|
|
347
|
+
presentation.preview ? /* @__PURE__ */ jsx2("p", { children: stripAnsi(presentation.preview) }) : /* @__PURE__ */ jsx2("small", { children: pending ? "Waiting for the page" : "No page summary returned" })
|
|
348
|
+
] });
|
|
349
|
+
if (presentation.detail === "agent") return /* @__PURE__ */ jsx2("section", { className: "scui-agent-preview", children: presentation.items?.length ? /* @__PURE__ */ jsx2("ol", { className: "scui-agent-roster", children: presentation.items.map((item, index) => /* @__PURE__ */ jsxs("li", { children: [
|
|
350
|
+
/* @__PURE__ */ jsx2("strong", { children: item.label }),
|
|
351
|
+
/* @__PURE__ */ jsx2("small", { children: item.status })
|
|
352
|
+
] }, `${item.label}:${index}`)) }) : presentation.preview ? /* @__PURE__ */ jsx2("pre", { children: stripAnsi(presentation.preview) }) : /* @__PURE__ */ jsx2("small", { children: pending ? "Agent is working" : "No textual handoff returned" }) });
|
|
353
|
+
if (presentation.detail === "plan") return /* @__PURE__ */ jsx2("ol", { className: "scui-plan-preview", children: presentation.items?.map((item, index) => /* @__PURE__ */ jsxs("li", { "data-status": item.status, children: [
|
|
354
|
+
/* @__PURE__ */ jsx2("i", { "aria-hidden": "true" }),
|
|
355
|
+
/* @__PURE__ */ jsx2("span", { children: item.label })
|
|
356
|
+
] }, `${item.label}:${index}`)) });
|
|
357
|
+
return presentation.preview ? /* @__PURE__ */ jsx2("pre", { className: "scui-tool-output", "data-error": failed, children: stripAnsi(presentation.preview) }) : null;
|
|
358
|
+
}
|
|
359
|
+
function ToolActions({ presentation, adapter }) {
|
|
360
|
+
const [copied, setCopied] = useState(false);
|
|
361
|
+
const reset = useRef2(null);
|
|
362
|
+
useEffect2(() => () => clearTimeout(reset.current), []);
|
|
363
|
+
if (!adapter?.copyText) return null;
|
|
364
|
+
const action = presentation.command ? ["Copy command", presentation.command] : presentation.path ? ["Copy path", presentation.path] : presentation.url ? ["Copy URL", presentation.url] : presentation.query ? ["Copy query", presentation.query] : null;
|
|
365
|
+
const copy = async () => {
|
|
366
|
+
await adapter.copyText(action[1]);
|
|
367
|
+
setCopied(true);
|
|
368
|
+
clearTimeout(reset.current);
|
|
369
|
+
reset.current = setTimeout(() => setCopied(false), 1500);
|
|
370
|
+
};
|
|
371
|
+
return action ? /* @__PURE__ */ jsx2("div", { className: "scui-tool-actions", children: /* @__PURE__ */ jsx2("button", { type: "button", onClick: copy, children: copied ? "Copied" : action[0] }) }) : null;
|
|
372
|
+
}
|
|
373
|
+
function ToolStack({ tools }) {
|
|
374
|
+
if (tools.length < 2) return null;
|
|
375
|
+
return /* @__PURE__ */ jsx2("div", { className: "scui-tool-stack", "aria-label": "Coordinated tools", children: tools.map((tool) => /* @__PURE__ */ jsx2("span", { children: tool.replaceAll("__", " \xB7 ").replaceAll("_", " ") }, tool)) });
|
|
376
|
+
}
|
|
377
|
+
function TechnicalDetails({ entry }) {
|
|
378
|
+
if (!entry.arguments && !entry.resultText) return null;
|
|
379
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-tool-technical", children: [
|
|
380
|
+
/* @__PURE__ */ jsx2("summary", { children: "Technical details" }),
|
|
381
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
382
|
+
entry.arguments ? /* @__PURE__ */ jsxs("section", { children: [
|
|
383
|
+
/* @__PURE__ */ jsx2("strong", { children: "Native arguments" }),
|
|
384
|
+
/* @__PURE__ */ jsx2("dl", { children: argumentRows(entry.arguments).map((row) => /* @__PURE__ */ jsxs("div", { children: [
|
|
385
|
+
/* @__PURE__ */ jsx2("dt", { children: row.label }),
|
|
386
|
+
/* @__PURE__ */ jsx2("dd", { children: /* @__PURE__ */ jsx2("pre", { children: row.value }) })
|
|
387
|
+
] }, row.key)) })
|
|
388
|
+
] }) : null,
|
|
389
|
+
entry.resultText ? /* @__PURE__ */ jsxs("section", { children: [
|
|
390
|
+
/* @__PURE__ */ jsx2("strong", { children: "Native result" }),
|
|
391
|
+
/* @__PURE__ */ jsxs("pre", { "data-error": entry.status === "error", children: [
|
|
392
|
+
entry.resultText,
|
|
393
|
+
entry.truncated ? "\n[truncated]" : ""
|
|
394
|
+
] })
|
|
395
|
+
] }) : null
|
|
396
|
+
] })
|
|
397
|
+
] });
|
|
398
|
+
}
|
|
399
|
+
function TranscriptEntry({ entry, state, adapter }) {
|
|
400
|
+
if (entry.role === "opaque") {
|
|
401
|
+
return /* @__PURE__ */ jsxs("article", { className: "scui-message scui-opaque", "data-role": "opaque", "data-kind": entry.kind, "aria-label": "Unrecognized entry", children: [
|
|
402
|
+
/* @__PURE__ */ jsxs("div", { className: "scui-notice", "data-code": "opaque-entry", children: [
|
|
403
|
+
"Unrecognized entry kind ",
|
|
404
|
+
/* @__PURE__ */ jsx2("code", { children: entry.kind }),
|
|
405
|
+
" \u2014 kept as-is, nothing dropped"
|
|
406
|
+
] }),
|
|
407
|
+
entry.text ? /* @__PURE__ */ jsx2(Markdown, { value: entry.text, copyText: adapter?.copyText }) : null,
|
|
408
|
+
entry.raw ? /* @__PURE__ */ jsxs("details", { className: "scui-tool-technical", children: [
|
|
409
|
+
/* @__PURE__ */ jsx2("summary", { children: "Technical details" }),
|
|
410
|
+
/* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsxs("section", { children: [
|
|
411
|
+
/* @__PURE__ */ jsx2("strong", { children: "Raw entry" }),
|
|
412
|
+
/* @__PURE__ */ jsxs("pre", { children: [
|
|
413
|
+
entry.raw,
|
|
414
|
+
entry.truncated ? "\n[truncated]" : ""
|
|
415
|
+
] })
|
|
416
|
+
] }) })
|
|
417
|
+
] }) : null
|
|
418
|
+
] });
|
|
419
|
+
}
|
|
420
|
+
if (entry.role === "request") return /* @__PURE__ */ jsx2(RequestCard, { entry, adapter, canRespond: state.canRespond });
|
|
421
|
+
if (entry.role === "reasoning") {
|
|
422
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-reasoning", open: entry.streaming, children: [
|
|
423
|
+
/* @__PURE__ */ jsx2("summary", { children: entry.streaming ? "Reasoning\u2026" : "Reasoning" }),
|
|
424
|
+
/* @__PURE__ */ jsx2(Markdown, { value: entry.text, copyText: adapter?.copyText })
|
|
425
|
+
] });
|
|
426
|
+
}
|
|
427
|
+
if (entry.role === "notice" || entry.role === "system") return /* @__PURE__ */ jsx2("div", { className: "scui-notice", "data-code": entry.code, children: entry.text });
|
|
428
|
+
return /* @__PURE__ */ jsxs("article", { className: "scui-message", "data-role": entry.role, "aria-label": `${entry.role === "user" ? "Your" : "Assistant"} message`, children: [
|
|
429
|
+
/* @__PURE__ */ jsx2(MessageImages, { items: entry.images, adapter }),
|
|
430
|
+
/* @__PURE__ */ jsx2(Markdown, { value: entry.text, copyText: adapter?.copyText }),
|
|
431
|
+
/* @__PURE__ */ jsx2(ContextDisclosure, { context: entry.context }),
|
|
432
|
+
entry.truncated ? /* @__PURE__ */ jsx2("small", { className: "scui-truncated", children: "Entry truncated by host \xB7 load native session for the complete value" }) : null,
|
|
433
|
+
/* @__PURE__ */ jsx2(MessageMeta, { entry, adapter })
|
|
434
|
+
] });
|
|
435
|
+
}
|
|
436
|
+
function ToolRow({ entry, workspace, open = false, adapter }) {
|
|
437
|
+
const presentation = entry.presentation ?? createToolPresentation(entry);
|
|
438
|
+
const [expanded, setExpanded] = useState(open || entry.status === "pending");
|
|
439
|
+
useEffect2(() => {
|
|
440
|
+
if (entry.status === "pending") setExpanded(true);
|
|
441
|
+
}, [entry.status]);
|
|
442
|
+
const target = compactToolTarget(presentation.target, workspace);
|
|
443
|
+
const hasDetail = Boolean(entry.arguments || entry.resultText || presentation.preview || presentation.fields.length);
|
|
444
|
+
const category = presentation.category ?? toolCategory(entry);
|
|
445
|
+
const summary = /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
446
|
+
/* @__PURE__ */ jsx2(ToolIcon, { category }),
|
|
447
|
+
/* @__PURE__ */ jsx2("strong", { children: toolAction(entry, category, presentation) }),
|
|
448
|
+
target ? /* @__PURE__ */ jsx2("code", { className: "scui-tool-target", title: presentation.target, children: target }) : null,
|
|
449
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-spacer" }),
|
|
450
|
+
entry.status === "pending" ? /* @__PURE__ */ jsx2(PendingElapsed, { now: adapter?.now }) : null,
|
|
451
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-tool-status", role: "status", "data-status": entry.status ?? "completed", "aria-label": entry.status ?? "completed", children: entry.status === "pending" ? /* @__PURE__ */ jsx2("i", {}) : /* @__PURE__ */ jsx2(UiIcon, { name: entry.status === "error" ? "close" : "check", size: 12 }) }),
|
|
452
|
+
hasDetail ? /* @__PURE__ */ jsx2(UiIcon, { name: "chevron", size: 14, className: "scui-tool-chevron" }) : null
|
|
453
|
+
] });
|
|
454
|
+
if (!hasDetail) return /* @__PURE__ */ jsx2("div", { className: "scui-tool", "data-status": entry.status ?? "completed", "data-category": category, children: /* @__PURE__ */ jsx2("div", { className: "scui-tool-head", children: summary }) });
|
|
455
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-tool", "data-status": entry.status ?? "completed", "data-category": category, open: expanded, onToggle: (event) => setExpanded(event.currentTarget.open), children: [
|
|
456
|
+
/* @__PURE__ */ jsx2("summary", { className: "scui-tool-head", children: summary }),
|
|
457
|
+
/* @__PURE__ */ jsxs("div", { className: "scui-tool-detail", children: [
|
|
458
|
+
/* @__PURE__ */ jsx2(ToolMetrics, { presentation }),
|
|
459
|
+
/* @__PURE__ */ jsx2(ToolStack, { tools: presentation.tools ?? [] }),
|
|
460
|
+
/* @__PURE__ */ jsx2(ToolPreview, { presentation, entry }),
|
|
461
|
+
presentation.fields.length ? /* @__PURE__ */ jsx2("dl", { className: "scui-tool-fields", children: presentation.fields.map((field) => /* @__PURE__ */ jsxs("div", { children: [
|
|
462
|
+
/* @__PURE__ */ jsx2("dt", { children: field.label }),
|
|
463
|
+
/* @__PURE__ */ jsx2("dd", { children: field.value })
|
|
464
|
+
] }, field.label)) }) : null,
|
|
465
|
+
/* @__PURE__ */ jsx2(ToolActions, { presentation, adapter }),
|
|
466
|
+
/* @__PURE__ */ jsx2(TechnicalDetails, { entry })
|
|
467
|
+
] })
|
|
468
|
+
] });
|
|
469
|
+
}
|
|
470
|
+
function ActivityGroup({ entries, state, adapter }) {
|
|
471
|
+
const active = entries.some((entry) => entry.status === "pending");
|
|
472
|
+
const [open, setOpen] = useState(active);
|
|
473
|
+
const id = useId();
|
|
474
|
+
useEffect2(() => {
|
|
475
|
+
if (active) setOpen(true);
|
|
476
|
+
}, [active]);
|
|
477
|
+
if (entries.length === 1) return /* @__PURE__ */ jsx2("section", { className: "scui-activity", "data-single": "true", children: /* @__PURE__ */ jsx2(ToolRow, { entry: entries[0], workspace: state.workspace, adapter }) });
|
|
478
|
+
return /* @__PURE__ */ jsxs("section", { className: "scui-activity", children: [
|
|
479
|
+
/* @__PURE__ */ jsxs("button", { className: "scui-activity-head", type: "button", "aria-expanded": open, "aria-controls": id, onClick: () => setOpen((value) => !value), children: [
|
|
480
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-fold", "data-open": open, children: /* @__PURE__ */ jsx2(UiIcon, { name: "chevron", size: 14 }) }),
|
|
481
|
+
/* @__PURE__ */ jsx2("strong", { children: activitySummary(entries) }),
|
|
482
|
+
/* @__PURE__ */ jsx2("span", { className: "scui-spacer" }),
|
|
483
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
484
|
+
entries.filter((entry) => entry.status !== "pending").length,
|
|
485
|
+
"/",
|
|
486
|
+
entries.length
|
|
487
|
+
] })
|
|
488
|
+
] }),
|
|
489
|
+
open ? /* @__PURE__ */ jsx2("div", { id, children: entries.map((entry) => /* @__PURE__ */ jsx2(ToolRow, { entry, workspace: state.workspace, adapter }, entry.id)) }) : null
|
|
490
|
+
] });
|
|
491
|
+
}
|
|
492
|
+
function TaskPlan({ plan }) {
|
|
493
|
+
if (!plan.items.length) return null;
|
|
494
|
+
const complete = plan.items.filter((item) => item.status === "completed" || item.status === "cancelled").length;
|
|
495
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-plan", children: [
|
|
496
|
+
/* @__PURE__ */ jsxs("summary", { children: [
|
|
497
|
+
/* @__PURE__ */ jsx2("span", { children: "Plan" }),
|
|
498
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
499
|
+
complete,
|
|
500
|
+
"/",
|
|
501
|
+
plan.items.length
|
|
502
|
+
] })
|
|
503
|
+
] }),
|
|
504
|
+
/* @__PURE__ */ jsx2("ol", { tabIndex: 0, "aria-label": "Task plan steps", children: plan.items.map((item) => /* @__PURE__ */ jsxs("li", { "data-status": item.status, children: [
|
|
505
|
+
/* @__PURE__ */ jsx2("i", { "aria-hidden": "true" }),
|
|
506
|
+
" ",
|
|
507
|
+
/* @__PURE__ */ jsx2("span", { children: item.title })
|
|
508
|
+
] }, item.id)) })
|
|
509
|
+
] });
|
|
510
|
+
}
|
|
511
|
+
function SessionDetails({ semantics }) {
|
|
512
|
+
if (!semantics.fidelity && !semantics.residueCount && !semantics.parseErrors && !semantics.subagents.length) return null;
|
|
513
|
+
return /* @__PURE__ */ jsxs("details", { className: "scui-details", children: [
|
|
514
|
+
/* @__PURE__ */ jsx2("summary", { children: "Session details" }),
|
|
515
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
516
|
+
semantics.fidelity ? /* @__PURE__ */ jsxs("p", { children: [
|
|
517
|
+
/* @__PURE__ */ jsx2("strong", { children: "Fidelity" }),
|
|
518
|
+
/* @__PURE__ */ jsx2("span", { children: semantics.fidelity.replaceAll("_", " ") })
|
|
519
|
+
] }) : null,
|
|
520
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
521
|
+
/* @__PURE__ */ jsx2("strong", { children: "Native records" }),
|
|
522
|
+
/* @__PURE__ */ jsx2("span", { children: semantics.rawRecords })
|
|
523
|
+
] }),
|
|
524
|
+
semantics.residueCount ? /* @__PURE__ */ jsxs("p", { children: [
|
|
525
|
+
/* @__PURE__ */ jsx2("strong", { children: "Residue" }),
|
|
526
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
527
|
+
semantics.residueCount,
|
|
528
|
+
" retained"
|
|
529
|
+
] })
|
|
530
|
+
] }) : null,
|
|
531
|
+
semantics.parseErrors ? /* @__PURE__ */ jsxs("p", { children: [
|
|
532
|
+
/* @__PURE__ */ jsx2("strong", { children: "Parse diagnostics" }),
|
|
533
|
+
/* @__PURE__ */ jsx2("span", { children: semantics.parseErrors })
|
|
534
|
+
] }) : null,
|
|
535
|
+
semantics.subagents.map((agent) => /* @__PURE__ */ jsxs("p", { children: [
|
|
536
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
537
|
+
agent.source,
|
|
538
|
+
" subagent"
|
|
539
|
+
] }),
|
|
540
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
541
|
+
agent.messages,
|
|
542
|
+
" messages \xB7 ",
|
|
543
|
+
agent.fidelity.replaceAll("_", " ")
|
|
544
|
+
] })
|
|
545
|
+
] }, agent.id))
|
|
546
|
+
] })
|
|
547
|
+
] });
|
|
548
|
+
}
|
|
549
|
+
var conversationMemory = uiMemory();
|
|
550
|
+
function ConversationAnnouncements({ state }) {
|
|
551
|
+
const previousBusy = useRef2(state.busy);
|
|
552
|
+
const [announcement, setAnnouncement] = useState("");
|
|
553
|
+
useEffect2(() => {
|
|
554
|
+
if (previousBusy.current && !state.busy && !state.error) {
|
|
555
|
+
setAnnouncement(`${harnessDisplayName(state.harness) || "Coding agent"} finished working`);
|
|
556
|
+
}
|
|
557
|
+
previousBusy.current = state.busy;
|
|
558
|
+
}, [state.busy, state.error, state.harness]);
|
|
559
|
+
return /* @__PURE__ */ jsx2("span", { className: "scui-sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement });
|
|
560
|
+
}
|
|
561
|
+
function Conversation({ state, adapter, components = {}, slots = {}, memoryKey = state.attached?.key || `${state.harness}:${state.workspace}`, pending = null, unreadAfterMessages = null }) {
|
|
562
|
+
const scroller = useRef2(null);
|
|
563
|
+
const remembered = conversationMemory.get(memoryKey) ?? { top: null, atBottom: true };
|
|
564
|
+
const [atBottom, setAtBottom] = useState(remembered.atBottom);
|
|
565
|
+
const earlierAnchor = useRef2(null);
|
|
566
|
+
const restored = useRef2(false);
|
|
567
|
+
const blocks = groupConversation(state.transcript);
|
|
568
|
+
const unreadBoundary = useRef2(Number.isSafeInteger(unreadAfterMessages) && unreadAfterMessages >= 0 ? unreadAfterMessages : null);
|
|
569
|
+
const unreadBlock = unreadBoundary.current === null ? -1 : blocks.findIndex((block) => {
|
|
570
|
+
const entries = block.kind === "activity" ? block.entries : [block.entry];
|
|
571
|
+
return entries.some((entry) => Number.isSafeInteger(entry.messageIndex) && entry.messageIndex > unreadBoundary.current);
|
|
572
|
+
});
|
|
573
|
+
const Entry = components.TranscriptEntry ?? TranscriptEntry;
|
|
574
|
+
const Group = components.ActivityGroup ?? ActivityGroup;
|
|
575
|
+
const Plan = components.TaskPlan ?? TaskPlan;
|
|
576
|
+
const Before = slots.beforeConversation;
|
|
577
|
+
const After = slots.afterConversation;
|
|
578
|
+
const Empty = slots.emptyConversation;
|
|
579
|
+
const remember = (value) => boundedSet(conversationMemory, memoryKey, value);
|
|
580
|
+
const pendingMessage = typeof pending === "string" ? { text: pending, status: "sending" } : pending;
|
|
581
|
+
const pin = () => {
|
|
582
|
+
if (!scroller.current) return;
|
|
583
|
+
scroller.current.scrollTop = scroller.current.scrollHeight;
|
|
584
|
+
setAtBottom(true);
|
|
585
|
+
remember({ top: scroller.current.scrollTop, atBottom: true });
|
|
586
|
+
};
|
|
587
|
+
useLayoutEffect(() => {
|
|
588
|
+
const element = scroller.current;
|
|
589
|
+
if (!element) return;
|
|
590
|
+
const anchor = earlierAnchor.current;
|
|
591
|
+
if (anchor) {
|
|
592
|
+
if (state.operation === "loadEarlier") anchor.seenOperation = true;
|
|
593
|
+
const prepended = state.transcript.length > anchor.entries && state.transcript[0]?.id !== anchor.firstId;
|
|
594
|
+
if (prepended) {
|
|
595
|
+
element.scrollTop = anchor.top + (element.scrollHeight - anchor.height);
|
|
596
|
+
earlierAnchor.current = null;
|
|
597
|
+
remember({ top: element.scrollTop, atBottom: false });
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (state.error || anchor.seenOperation && state.operation !== "loadEarlier") earlierAnchor.current = null;
|
|
601
|
+
}
|
|
602
|
+
if (!restored.current) {
|
|
603
|
+
restored.current = true;
|
|
604
|
+
if (remembered.top !== null && !remembered.atBottom) element.scrollTop = remembered.top;
|
|
605
|
+
else pin();
|
|
606
|
+
} else if (atBottom) pin();
|
|
607
|
+
}, [memoryKey, state.transcript, state.busy, state.operation, state.error, pendingMessage?.text, pendingMessage?.status]);
|
|
608
|
+
return /* @__PURE__ */ jsxs("div", { className: "scui-conversation-wrap", children: [
|
|
609
|
+
/* @__PURE__ */ jsx2(ConversationAnnouncements, { state }),
|
|
610
|
+
/* @__PURE__ */ jsx2("div", { className: "scui-conversation", ref: scroller, tabIndex: 0, "aria-label": "Conversation", onScroll: (event) => {
|
|
611
|
+
const element = event.currentTarget;
|
|
612
|
+
const bottom = element.scrollHeight - element.scrollTop - element.clientHeight <= 64;
|
|
613
|
+
setAtBottom(bottom);
|
|
614
|
+
remember({ top: element.scrollTop, atBottom: bottom });
|
|
615
|
+
}, children: /* @__PURE__ */ jsxs("div", { children: [
|
|
616
|
+
Before ? /* @__PURE__ */ jsx2(Before, { state, adapter, value: null }) : null,
|
|
617
|
+
/* @__PURE__ */ jsx2(Plan, { plan: state.taskPlan, value: state.taskPlan, state, adapter }),
|
|
618
|
+
/* @__PURE__ */ jsx2(SessionDetails, { semantics: state.semantics }),
|
|
619
|
+
state.history.hasEarlier ? /* @__PURE__ */ jsx2("button", { className: "scui-load", type: "button", disabled: Boolean(state.operation), onClick: () => {
|
|
620
|
+
const element = scroller.current;
|
|
621
|
+
if (element) earlierAnchor.current = { height: element.scrollHeight, top: element.scrollTop, entries: state.transcript.length, firstId: state.transcript[0]?.id, seenOperation: false };
|
|
622
|
+
setAtBottom(false);
|
|
623
|
+
adapter.onIntent({ action: "loadEarlier" });
|
|
624
|
+
}, children: "Load earlier messages" }) : null,
|
|
625
|
+
!blocks.length && state.startup !== "ready" ? /* @__PURE__ */ jsx2(LoadingStatus, { state }) : null,
|
|
626
|
+
!blocks.length && state.startup === "ready" ? Empty ? /* @__PURE__ */ jsx2(Empty, { state, adapter, value: null }) : /* @__PURE__ */ jsx2("div", { className: "scui-empty", children: state.error ?? (state.harness ? `${harnessDisplayName(state.harness)} is listening. Say something.` : "No transcript yet.") }) : null,
|
|
627
|
+
blocks.map((block, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
628
|
+
index === unreadBlock ? /* @__PURE__ */ jsx2("div", { className: "scui-unread-divider", role: "separator", "aria-label": "New messages", children: /* @__PURE__ */ jsx2("span", { children: "New" }) }) : null,
|
|
629
|
+
block.kind === "activity" ? /* @__PURE__ */ jsx2(Group, { value: block.entries, entries: block.entries, state, adapter }) : /* @__PURE__ */ jsx2(Entry, { value: block.entry, entry: block.entry, state, adapter })
|
|
630
|
+
] }, block.id)),
|
|
631
|
+
pendingMessage ? /* @__PURE__ */ jsxs("article", { className: "scui-message scui-pending", "data-role": "user", "data-status": pendingMessage.status, "aria-label": "Your pending message", children: [
|
|
632
|
+
/* @__PURE__ */ jsx2(MessageImages, { items: pendingMessage.images, adapter }),
|
|
633
|
+
/* @__PURE__ */ jsx2(Markdown, { value: pendingMessage.text, copyText: adapter?.copyText }),
|
|
634
|
+
/* @__PURE__ */ jsx2(ContextDisclosure, { context: pendingMessage.context }),
|
|
635
|
+
/* @__PURE__ */ jsxs("footer", { children: [
|
|
636
|
+
/* @__PURE__ */ jsx2("small", { children: pendingMessage.status === "failed" ? "Not sent" : "Sending\u2026" }),
|
|
637
|
+
pendingMessage.status === "failed" ? /* @__PURE__ */ jsxs("span", { children: [
|
|
638
|
+
/* @__PURE__ */ jsx2("button", { type: "button", onClick: pendingMessage.onRetry, children: "Retry" }),
|
|
639
|
+
/* @__PURE__ */ jsx2("button", { type: "button", onClick: pendingMessage.onEdit, children: "Edit" })
|
|
640
|
+
] }) : null
|
|
641
|
+
] })
|
|
642
|
+
] }) : null,
|
|
643
|
+
state.busy ? /* @__PURE__ */ jsxs("div", { className: "scui-working", role: "status", children: [
|
|
644
|
+
/* @__PURE__ */ jsx2("span", { "aria-hidden": "true", children: "\u2726" }),
|
|
645
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
646
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
647
|
+
/* @__PURE__ */ jsx2("i", {}),
|
|
648
|
+
/* @__PURE__ */ jsxs("small", { children: [
|
|
649
|
+
harnessDisplayName(state.harness),
|
|
650
|
+
" is working"
|
|
651
|
+
] })
|
|
652
|
+
] }) : null,
|
|
653
|
+
After ? /* @__PURE__ */ jsx2(After, { state, adapter, value: null }) : null
|
|
654
|
+
] }) }),
|
|
655
|
+
!atBottom ? /* @__PURE__ */ jsxs("button", { className: "scui-latest", type: "button", onClick: pin, children: [
|
|
656
|
+
/* @__PURE__ */ jsx2(UiIcon, { name: "down", size: 13 }),
|
|
657
|
+
" Latest"
|
|
658
|
+
] }) : null
|
|
659
|
+
] });
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export {
|
|
663
|
+
LoadingStatus,
|
|
664
|
+
RequestCard,
|
|
665
|
+
TranscriptEntry,
|
|
666
|
+
ToolRow,
|
|
667
|
+
ActivityGroup,
|
|
668
|
+
TaskPlan,
|
|
669
|
+
SessionDetails,
|
|
670
|
+
Conversation
|
|
671
|
+
};
|