@seclai/react 0.0.11 → 0.0.13
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 +12 -1
- package/dist/index.cjs +174 -51
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +164 -41
- package/dist/styles.css +81 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -250,9 +250,20 @@ These are exported so the API is in place, but they're minimal until they're por
|
|
|
250
250
|
|
|
251
251
|
| Export | For now | Coming |
|
|
252
252
|
|---|---|---|
|
|
253
|
-
| `MarkdownContent` |
|
|
253
|
+
| `MarkdownContent` | Paragraphs, lists, rules and bold (see below) | GFM tables, KaTeX, mermaid, sanitized SVG |
|
|
254
254
|
| `MediaPreview` | Image cards (see [Media](#media)), a download link for everything else | Audio, video and PDF previews |
|
|
255
255
|
|
|
256
|
+
`MarkdownContent` shows the agent's text in `AgentRunForm` and `AgentChat`. It renders:
|
|
257
|
+
|
|
258
|
+
- paragraphs, split by blank lines, with a single newline as a line break;
|
|
259
|
+
- numbered lists (`1.` or `1)`), keeping the agent's own numbers. Each number is a badge like the one on `MediaPreview`, so "2." in the text matches image 2;
|
|
260
|
+
- bulleted lists (`-`, `*` or `•`);
|
|
261
|
+
- nested lists: an item indented at least 2 spaces more than the item above it (a tab counts as 4) is nested in that item, numbered or bulleted, at any depth;
|
|
262
|
+
- horizontal rules: a line of three or more `-`, `*` or `_`, optionally spaced (`---`, `* * *`);
|
|
263
|
+
- `**bold**`.
|
|
264
|
+
|
|
265
|
+
Anything else, such as headings, links, code and tables, shows as the text it is. It never renders HTML. While the text streams in, a list item with nothing after its marker, a rule that's only partly there, or a `**` that isn't closed yet, shows as plain text until it's complete. The root element is a `div.seclai-markdown`, and the list numbers are `.seclai-markdown-number`.
|
|
266
|
+
|
|
256
267
|
## License
|
|
257
268
|
|
|
258
269
|
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(index_exports);
|
|
40
40
|
|
|
41
41
|
// src/AgentChat.tsx
|
|
42
|
-
var
|
|
42
|
+
var import_react7 = require("react");
|
|
43
43
|
|
|
44
44
|
// src/attachments.ts
|
|
45
45
|
var import_react = require("react");
|
|
@@ -127,16 +127,139 @@ function messageFileLimits(slots) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// src/placeholders/MarkdownContent.tsx
|
|
130
|
+
var import_react2 = require("react");
|
|
130
131
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
132
|
+
var ORDERED = /^(\s*)(\d{1,9})[.)]\s+(\S.*)$/;
|
|
133
|
+
var BULLET = /^(\s*)[-*•]\s+(\S.*)$/;
|
|
134
|
+
var BARE_MARKER = /^\s*(?:\d{1,9}[.)]?\s*|[-*•_][-*_\s]*)$/;
|
|
135
|
+
var THEMATIC_BREAK = /^\s*([-*_])(?:[ \t]*\1){2,}[ \t]*$/;
|
|
136
|
+
var NEST = 2;
|
|
137
|
+
var FENCE = /^\s*(`{3,}(?!.*`)|~{3,})/;
|
|
138
|
+
var CLOSING_FENCE = /^\s*(`{3,}|~{3,})\s*$/;
|
|
139
|
+
function indentOf(space) {
|
|
140
|
+
let width = 0;
|
|
141
|
+
for (const char of space) width += char === " " ? 4 : 1;
|
|
142
|
+
return width;
|
|
143
|
+
}
|
|
144
|
+
function parse(content) {
|
|
145
|
+
const blocks = [];
|
|
146
|
+
const open = [];
|
|
147
|
+
let blank = true;
|
|
148
|
+
let fence = null;
|
|
149
|
+
const push = (block) => {
|
|
150
|
+
blocks.push(block);
|
|
151
|
+
open.length = 0;
|
|
152
|
+
};
|
|
153
|
+
for (const line of content.replace(/\r\n?/g, "\n").split("\n")) {
|
|
154
|
+
const last = blocks.at(-1);
|
|
155
|
+
if (fence && last?.type === "p") {
|
|
156
|
+
last.lines.push(line);
|
|
157
|
+
const closing = CLOSING_FENCE.exec(line)?.[1];
|
|
158
|
+
if (closing && closing[0] === fence[0] && closing.length >= fence.length) fence = null;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const opening = FENCE.exec(line);
|
|
162
|
+
if (opening) {
|
|
163
|
+
fence = opening[1];
|
|
164
|
+
push({ type: "p", lines: [line], verbatim: true });
|
|
165
|
+
blank = false;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (!line.trim()) {
|
|
169
|
+
blank = true;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (THEMATIC_BREAK.test(line)) {
|
|
173
|
+
push({ type: "hr" });
|
|
174
|
+
blank = false;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const ordered = ORDERED.exec(line);
|
|
178
|
+
const bullet = ordered || BARE_MARKER.test(line) ? null : BULLET.exec(line);
|
|
179
|
+
if (ordered || bullet) {
|
|
180
|
+
const type = ordered ? "ol" : "ul";
|
|
181
|
+
const item = ordered ? { n: Number(ordered[2]), indent: indentOf(ordered[1]), lines: [ordered[3]], lists: [] } : { indent: indentOf(bullet[1]), lines: [bullet[2]], lists: [] };
|
|
182
|
+
let level = 0;
|
|
183
|
+
while (level < open.length && item.indent >= open[level].items.at(-1).indent + NEST) level++;
|
|
184
|
+
const list = open[level];
|
|
185
|
+
if (list?.type === type) {
|
|
186
|
+
list.items.push(item);
|
|
187
|
+
open.length = level + 1;
|
|
188
|
+
} else {
|
|
189
|
+
const next = { type, items: [item] };
|
|
190
|
+
(level > 0 ? open[level - 1].items.at(-1).lists : blocks).push(next);
|
|
191
|
+
open.length = level;
|
|
192
|
+
open.push(next);
|
|
193
|
+
}
|
|
194
|
+
} else if (!blank && open.length > 0 && !BARE_MARKER.test(line)) {
|
|
195
|
+
open.at(-1).items.at(-1).lines.push(line.trim());
|
|
196
|
+
} else if (!blank && last?.type === "p" && !last.verbatim) {
|
|
197
|
+
last.lines.push(line);
|
|
198
|
+
} else {
|
|
199
|
+
push({ type: "p", lines: [line] });
|
|
200
|
+
}
|
|
201
|
+
blank = false;
|
|
202
|
+
}
|
|
203
|
+
return blocks;
|
|
204
|
+
}
|
|
205
|
+
var INLINE = /(`[^`\n]+`)|\*\*(?!\s)((?:[^*`\n]|`[^`\n]*`)*?(?:[^\s*`]|`[^`\n]*`))\*\*/g;
|
|
206
|
+
function inline(text) {
|
|
207
|
+
const nodes = [];
|
|
208
|
+
let at = 0;
|
|
209
|
+
for (const match of text.matchAll(INLINE)) {
|
|
210
|
+
if (match[2] === void 0) continue;
|
|
211
|
+
const index = match.index;
|
|
212
|
+
if (index > at) nodes.push(text.slice(at, index));
|
|
213
|
+
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: match[2] }, index));
|
|
214
|
+
at = index + match[0].length;
|
|
215
|
+
}
|
|
216
|
+
if (at < text.length) nodes.push(text.slice(at));
|
|
217
|
+
return nodes;
|
|
218
|
+
}
|
|
219
|
+
function withBreaks(lines, format) {
|
|
220
|
+
return lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react2.Fragment, { children: [
|
|
221
|
+
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
222
|
+
format(line)
|
|
223
|
+
] }, i));
|
|
224
|
+
}
|
|
225
|
+
function renderList(list, key) {
|
|
226
|
+
if (list.type === "ul") {
|
|
227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { children: list.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
228
|
+
withBreaks(item.lines, inline),
|
|
229
|
+
item.lists.map(renderList)
|
|
230
|
+
] }, i)) }, key);
|
|
231
|
+
}
|
|
232
|
+
return (
|
|
233
|
+
// `role="list"`: Safari drops the list role from a list styled with
|
|
234
|
+
// `list-style: none`, which this one is, for its number badges.
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { start: list.items[0].n, role: "list", children: list.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { value: item.n, children: [
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "seclai-markdown-number", children: item.n }),
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
238
|
+
withBreaks(item.lines, inline),
|
|
239
|
+
item.lists.map(renderList)
|
|
240
|
+
] })
|
|
241
|
+
] }, i)) }, key)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
131
244
|
function MarkdownContent({ content }) {
|
|
132
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "seclai-markdown", children: content
|
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "seclai-markdown", children: parse(content).map((block, i) => {
|
|
246
|
+
switch (block.type) {
|
|
247
|
+
case "ol":
|
|
248
|
+
case "ul":
|
|
249
|
+
return renderList(block, i);
|
|
250
|
+
case "hr":
|
|
251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", {}, i);
|
|
252
|
+
default:
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: withBreaks(block.lines, block.verbatim ? (line) => line : inline) }, i);
|
|
254
|
+
}
|
|
255
|
+
}) });
|
|
133
256
|
}
|
|
134
257
|
|
|
135
258
|
// src/media/MediaGallery.tsx
|
|
136
|
-
var
|
|
259
|
+
var import_react5 = require("react");
|
|
137
260
|
|
|
138
261
|
// src/placeholders/MediaPreview.tsx
|
|
139
|
-
var
|
|
262
|
+
var import_react3 = require("react");
|
|
140
263
|
|
|
141
264
|
// src/media/files.ts
|
|
142
265
|
var EXTENSIONS = {
|
|
@@ -230,9 +353,9 @@ function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }) {
|
|
|
230
353
|
);
|
|
231
354
|
}
|
|
232
355
|
function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen }) {
|
|
233
|
-
const img = (0,
|
|
234
|
-
const [natural, setNatural] = (0,
|
|
235
|
-
const [failed, setFailed] = (0,
|
|
356
|
+
const img = (0, import_react3.useRef)(null);
|
|
357
|
+
const [natural, setNatural] = (0, import_react3.useState)(null);
|
|
358
|
+
const [failed, setFailed] = (0, import_react3.useState)(false);
|
|
236
359
|
const label = imageLabel(attachment, number);
|
|
237
360
|
function measure() {
|
|
238
361
|
const el = img.current;
|
|
@@ -240,7 +363,7 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
240
363
|
setNatural(`${el.naturalWidth} / ${el.naturalHeight}`);
|
|
241
364
|
}
|
|
242
365
|
}
|
|
243
|
-
(0,
|
|
366
|
+
(0, import_react3.useEffect)(() => {
|
|
244
367
|
setNatural(null);
|
|
245
368
|
setFailed(false);
|
|
246
369
|
const el = img.current;
|
|
@@ -296,18 +419,18 @@ function MediaSkeleton({ aspectRatio, number, label }) {
|
|
|
296
419
|
}
|
|
297
420
|
|
|
298
421
|
// src/media/MediaViewer.tsx
|
|
299
|
-
var
|
|
422
|
+
var import_react4 = require("react");
|
|
300
423
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
301
424
|
function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
302
|
-
const dialog = (0,
|
|
303
|
-
const closeButton = (0,
|
|
304
|
-
const returnFocus = (0,
|
|
305
|
-
const isOpen = (0,
|
|
306
|
-
const titleId = (0,
|
|
425
|
+
const dialog = (0, import_react4.useRef)(null);
|
|
426
|
+
const closeButton = (0, import_react4.useRef)(null);
|
|
427
|
+
const returnFocus = (0, import_react4.useRef)(null);
|
|
428
|
+
const isOpen = (0, import_react4.useRef)(false);
|
|
429
|
+
const titleId = (0, import_react4.useId)();
|
|
307
430
|
const current = index != null ? attachments[index] : void 0;
|
|
308
431
|
const open = current != null;
|
|
309
432
|
isOpen.current = open;
|
|
310
|
-
(0,
|
|
433
|
+
(0, import_react4.useEffect)(() => {
|
|
311
434
|
const el = dialog.current;
|
|
312
435
|
if (!el) return;
|
|
313
436
|
if (open && !el.open) {
|
|
@@ -319,7 +442,7 @@ function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
|
319
442
|
restoreFocus();
|
|
320
443
|
}
|
|
321
444
|
}, [open]);
|
|
322
|
-
(0,
|
|
445
|
+
(0, import_react4.useEffect)(
|
|
323
446
|
() => () => {
|
|
324
447
|
if (isOpen.current) restoreFocus();
|
|
325
448
|
},
|
|
@@ -419,10 +542,10 @@ function MediaGallery({
|
|
|
419
542
|
}) {
|
|
420
543
|
const images = attachments.filter(isImage);
|
|
421
544
|
const files = attachments.filter((attachment) => !isImage(attachment));
|
|
422
|
-
const [viewing, setViewing] = (0,
|
|
423
|
-
const [downloading, setDownloading] = (0,
|
|
424
|
-
const abort = (0,
|
|
425
|
-
(0,
|
|
545
|
+
const [viewing, setViewing] = (0, import_react5.useState)(null);
|
|
546
|
+
const [downloading, setDownloading] = (0, import_react5.useState)(false);
|
|
547
|
+
const abort = (0, import_react5.useRef)(null);
|
|
548
|
+
(0, import_react5.useEffect)(() => () => abort.current?.abort(), []);
|
|
426
549
|
if (viewing != null && viewing >= images.length) setViewing(null);
|
|
427
550
|
async function downloadAll() {
|
|
428
551
|
if (downloading) return;
|
|
@@ -478,7 +601,7 @@ function MediaGallery({
|
|
|
478
601
|
}
|
|
479
602
|
|
|
480
603
|
// src/useAgentRun.ts
|
|
481
|
-
var
|
|
604
|
+
var import_react6 = require("react");
|
|
482
605
|
|
|
483
606
|
// src/sse.ts
|
|
484
607
|
function parseData(data) {
|
|
@@ -624,15 +747,15 @@ function applyEvent(state, { event, data }, endpoints) {
|
|
|
624
747
|
}
|
|
625
748
|
function useAgentRun(options = {}) {
|
|
626
749
|
const { basePath, agentId, onEvent } = options;
|
|
627
|
-
const endpoints = (0,
|
|
628
|
-
const [state, setState] = (0,
|
|
629
|
-
const active = (0,
|
|
630
|
-
const onEventRef = (0,
|
|
631
|
-
(0,
|
|
750
|
+
const endpoints = (0, import_react6.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
|
|
751
|
+
const [state, setState] = (0, import_react6.useState)(IDLE);
|
|
752
|
+
const active = (0, import_react6.useRef)(null);
|
|
753
|
+
const onEventRef = (0, import_react6.useRef)(onEvent);
|
|
754
|
+
(0, import_react6.useEffect)(() => {
|
|
632
755
|
onEventRef.current = onEvent;
|
|
633
756
|
});
|
|
634
|
-
(0,
|
|
635
|
-
const start = (0,
|
|
757
|
+
(0, import_react6.useEffect)(() => () => active.current?.abort(), []);
|
|
758
|
+
const start = (0, import_react6.useCallback)(
|
|
636
759
|
async ({ input, uploadIds, sessionId }) => {
|
|
637
760
|
active.current?.abort();
|
|
638
761
|
const controller = new AbortController();
|
|
@@ -692,8 +815,8 @@ function useAgentRun(options = {}) {
|
|
|
692
815
|
},
|
|
693
816
|
[endpoints]
|
|
694
817
|
);
|
|
695
|
-
const cancel = (0,
|
|
696
|
-
const reset = (0,
|
|
818
|
+
const cancel = (0, import_react6.useCallback)(() => active.current?.abort(), []);
|
|
819
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
697
820
|
const controller = active.current;
|
|
698
821
|
active.current = null;
|
|
699
822
|
controller?.abort();
|
|
@@ -818,10 +941,10 @@ function AgentChat({
|
|
|
818
941
|
initialTurns,
|
|
819
942
|
onTurnComplete
|
|
820
943
|
}) {
|
|
821
|
-
const endpoints = (0,
|
|
944
|
+
const endpoints = (0, import_react7.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
|
|
822
945
|
const run = useAgentRun({ basePath, agentId });
|
|
823
946
|
const { slots } = useAcceptedAttachments(endpoints);
|
|
824
|
-
const [transcript, setTranscript] = (0,
|
|
947
|
+
const [transcript, setTranscript] = (0, import_react7.useState)(() => ({
|
|
825
948
|
sessionId,
|
|
826
949
|
epoch: 0,
|
|
827
950
|
turns: initialTurns ?? [],
|
|
@@ -829,15 +952,15 @@ function AgentChat({
|
|
|
829
952
|
generatedSessionId: null,
|
|
830
953
|
runEpoch: null
|
|
831
954
|
}));
|
|
832
|
-
const [message, setMessage] = (0,
|
|
833
|
-
const [files, setFiles] = (0,
|
|
834
|
-
const [notice, setNotice] = (0,
|
|
835
|
-
const [dragging, setDragging] = (0,
|
|
836
|
-
const generatedSessionId = (0,
|
|
837
|
-
const shownEpoch = (0,
|
|
838
|
-
const turnComplete = (0,
|
|
839
|
-
const sentPreviews = (0,
|
|
840
|
-
const pendingPreviews = (0,
|
|
955
|
+
const [message, setMessage] = (0, import_react7.useState)("");
|
|
956
|
+
const [files, setFiles] = (0, import_react7.useState)([]);
|
|
957
|
+
const [notice, setNotice] = (0, import_react7.useState)(null);
|
|
958
|
+
const [dragging, setDragging] = (0, import_react7.useState)(false);
|
|
959
|
+
const generatedSessionId = (0, import_react7.useRef)(null);
|
|
960
|
+
const shownEpoch = (0, import_react7.useRef)(transcript.epoch);
|
|
961
|
+
const turnComplete = (0, import_react7.useRef)(onTurnComplete);
|
|
962
|
+
const sentPreviews = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
963
|
+
const pendingPreviews = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
|
|
841
964
|
if (transcript.sessionId !== sessionId) {
|
|
842
965
|
const adopting = transcript.sessionId === void 0 && sessionId !== void 0 && sessionId === transcript.generatedSessionId;
|
|
843
966
|
setTranscript(
|
|
@@ -851,10 +974,10 @@ function AgentChat({
|
|
|
851
974
|
}
|
|
852
975
|
);
|
|
853
976
|
}
|
|
854
|
-
(0,
|
|
977
|
+
(0, import_react7.useEffect)(() => {
|
|
855
978
|
turnComplete.current = onTurnComplete;
|
|
856
979
|
});
|
|
857
|
-
(0,
|
|
980
|
+
(0, import_react7.useEffect)(() => {
|
|
858
981
|
if (shownEpoch.current === transcript.epoch) return;
|
|
859
982
|
shownEpoch.current = transcript.epoch;
|
|
860
983
|
run.cancel();
|
|
@@ -867,7 +990,7 @@ function AgentChat({
|
|
|
867
990
|
setFiles([]);
|
|
868
991
|
setNotice(null);
|
|
869
992
|
}, [transcript.epoch, run.cancel]);
|
|
870
|
-
(0,
|
|
993
|
+
(0, import_react7.useEffect)(
|
|
871
994
|
() => () => {
|
|
872
995
|
pendingPreviews.current.forEach(revoke);
|
|
873
996
|
sentPreviews.current.forEach(revoke);
|
|
@@ -1025,7 +1148,7 @@ function AgentChat({
|
|
|
1025
1148
|
const buttons = attachButtons?.length ? attachButtons : [{ label: "Attach" }];
|
|
1026
1149
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "seclai-agent seclai-chat", children: [
|
|
1027
1150
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
|
|
1028
|
-
transcript.turns.map((turn, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1151
|
+
transcript.turns.map((turn, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react7.Fragment, { children: [
|
|
1029
1152
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1030
1153
|
UserTurn,
|
|
1031
1154
|
{
|
|
@@ -1092,7 +1215,7 @@ function AgentChat({
|
|
|
1092
1215
|
}
|
|
1093
1216
|
|
|
1094
1217
|
// src/AgentRunForm.tsx
|
|
1095
|
-
var
|
|
1218
|
+
var import_react8 = require("react");
|
|
1096
1219
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1097
1220
|
function slotProblem(slot, count) {
|
|
1098
1221
|
const label = slot.label ?? slot.name;
|
|
@@ -1104,13 +1227,13 @@ function slotProblem(slot, count) {
|
|
|
1104
1227
|
return null;
|
|
1105
1228
|
}
|
|
1106
1229
|
function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
|
|
1107
|
-
const endpoints = (0,
|
|
1230
|
+
const endpoints = (0, import_react8.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
|
|
1108
1231
|
const run = useAgentRun({ basePath, agentId });
|
|
1109
1232
|
const { slots, error: loadError } = useAcceptedAttachments(endpoints);
|
|
1110
|
-
const [input, setInput] = (0,
|
|
1111
|
-
const [files, setFiles] = (0,
|
|
1112
|
-
const [uploading, setUploading] = (0,
|
|
1113
|
-
const [formError, setFormError] = (0,
|
|
1233
|
+
const [input, setInput] = (0, import_react8.useState)("");
|
|
1234
|
+
const [files, setFiles] = (0, import_react8.useState)({});
|
|
1235
|
+
const [uploading, setUploading] = (0, import_react8.useState)(false);
|
|
1236
|
+
const [formError, setFormError] = (0, import_react8.useState)(null);
|
|
1114
1237
|
const selected = Object.values(files).flat();
|
|
1115
1238
|
const busy = uploading || run.status === "running";
|
|
1116
1239
|
async function submit(event) {
|
package/dist/index.d.cts
CHANGED
|
@@ -381,8 +381,14 @@ interface MarkdownContentProps {
|
|
|
381
381
|
content: string;
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
|
-
* Shows agent output.
|
|
385
|
-
*
|
|
384
|
+
* Shows agent output. It renders paragraphs (a single newline is a line
|
|
385
|
+
* break), numbered lists that keep the agent's own numbers, bulleted lists,
|
|
386
|
+
* lists nested under an item by indenting them, horizontal rules (`---`,
|
|
387
|
+
* `***`, `___`) and `**bold**`. Everything else, such as headings, code, links
|
|
388
|
+
* and tables, shows as the text it is. It never renders HTML. It also works on
|
|
389
|
+
* text that's still streaming: a half-written list item, rule or `**` shows as
|
|
390
|
+
* text until it's complete. Tables, maths and diagrams are coming in a later
|
|
391
|
+
* version.
|
|
386
392
|
*/
|
|
387
393
|
declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
|
|
388
394
|
|
package/dist/index.d.ts
CHANGED
|
@@ -381,8 +381,14 @@ interface MarkdownContentProps {
|
|
|
381
381
|
content: string;
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
|
-
* Shows agent output.
|
|
385
|
-
*
|
|
384
|
+
* Shows agent output. It renders paragraphs (a single newline is a line
|
|
385
|
+
* break), numbered lists that keep the agent's own numbers, bulleted lists,
|
|
386
|
+
* lists nested under an item by indenting them, horizontal rules (`---`,
|
|
387
|
+
* `***`, `___`) and `**bold**`. Everything else, such as headings, code, links
|
|
388
|
+
* and tables, shows as the text it is. It never renders HTML. It also works on
|
|
389
|
+
* text that's still streaming: a half-written list item, rule or `**` shows as
|
|
390
|
+
* text until it's complete. Tables, maths and diagrams are coming in a later
|
|
391
|
+
* version.
|
|
386
392
|
*/
|
|
387
393
|
declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
|
|
388
394
|
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/AgentChat.tsx
|
|
4
4
|
import {
|
|
5
|
-
Fragment as
|
|
5
|
+
Fragment as Fragment4,
|
|
6
6
|
useEffect as useEffect6,
|
|
7
7
|
useMemo as useMemo2,
|
|
8
8
|
useRef as useRef5,
|
|
@@ -95,9 +95,132 @@ function messageFileLimits(slots) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// src/placeholders/MarkdownContent.tsx
|
|
98
|
-
import {
|
|
98
|
+
import { Fragment } from "react";
|
|
99
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
100
|
+
var ORDERED = /^(\s*)(\d{1,9})[.)]\s+(\S.*)$/;
|
|
101
|
+
var BULLET = /^(\s*)[-*•]\s+(\S.*)$/;
|
|
102
|
+
var BARE_MARKER = /^\s*(?:\d{1,9}[.)]?\s*|[-*•_][-*_\s]*)$/;
|
|
103
|
+
var THEMATIC_BREAK = /^\s*([-*_])(?:[ \t]*\1){2,}[ \t]*$/;
|
|
104
|
+
var NEST = 2;
|
|
105
|
+
var FENCE = /^\s*(`{3,}(?!.*`)|~{3,})/;
|
|
106
|
+
var CLOSING_FENCE = /^\s*(`{3,}|~{3,})\s*$/;
|
|
107
|
+
function indentOf(space) {
|
|
108
|
+
let width = 0;
|
|
109
|
+
for (const char of space) width += char === " " ? 4 : 1;
|
|
110
|
+
return width;
|
|
111
|
+
}
|
|
112
|
+
function parse(content) {
|
|
113
|
+
const blocks = [];
|
|
114
|
+
const open = [];
|
|
115
|
+
let blank = true;
|
|
116
|
+
let fence = null;
|
|
117
|
+
const push = (block) => {
|
|
118
|
+
blocks.push(block);
|
|
119
|
+
open.length = 0;
|
|
120
|
+
};
|
|
121
|
+
for (const line of content.replace(/\r\n?/g, "\n").split("\n")) {
|
|
122
|
+
const last = blocks.at(-1);
|
|
123
|
+
if (fence && last?.type === "p") {
|
|
124
|
+
last.lines.push(line);
|
|
125
|
+
const closing = CLOSING_FENCE.exec(line)?.[1];
|
|
126
|
+
if (closing && closing[0] === fence[0] && closing.length >= fence.length) fence = null;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const opening = FENCE.exec(line);
|
|
130
|
+
if (opening) {
|
|
131
|
+
fence = opening[1];
|
|
132
|
+
push({ type: "p", lines: [line], verbatim: true });
|
|
133
|
+
blank = false;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!line.trim()) {
|
|
137
|
+
blank = true;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (THEMATIC_BREAK.test(line)) {
|
|
141
|
+
push({ type: "hr" });
|
|
142
|
+
blank = false;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const ordered = ORDERED.exec(line);
|
|
146
|
+
const bullet = ordered || BARE_MARKER.test(line) ? null : BULLET.exec(line);
|
|
147
|
+
if (ordered || bullet) {
|
|
148
|
+
const type = ordered ? "ol" : "ul";
|
|
149
|
+
const item = ordered ? { n: Number(ordered[2]), indent: indentOf(ordered[1]), lines: [ordered[3]], lists: [] } : { indent: indentOf(bullet[1]), lines: [bullet[2]], lists: [] };
|
|
150
|
+
let level = 0;
|
|
151
|
+
while (level < open.length && item.indent >= open[level].items.at(-1).indent + NEST) level++;
|
|
152
|
+
const list = open[level];
|
|
153
|
+
if (list?.type === type) {
|
|
154
|
+
list.items.push(item);
|
|
155
|
+
open.length = level + 1;
|
|
156
|
+
} else {
|
|
157
|
+
const next = { type, items: [item] };
|
|
158
|
+
(level > 0 ? open[level - 1].items.at(-1).lists : blocks).push(next);
|
|
159
|
+
open.length = level;
|
|
160
|
+
open.push(next);
|
|
161
|
+
}
|
|
162
|
+
} else if (!blank && open.length > 0 && !BARE_MARKER.test(line)) {
|
|
163
|
+
open.at(-1).items.at(-1).lines.push(line.trim());
|
|
164
|
+
} else if (!blank && last?.type === "p" && !last.verbatim) {
|
|
165
|
+
last.lines.push(line);
|
|
166
|
+
} else {
|
|
167
|
+
push({ type: "p", lines: [line] });
|
|
168
|
+
}
|
|
169
|
+
blank = false;
|
|
170
|
+
}
|
|
171
|
+
return blocks;
|
|
172
|
+
}
|
|
173
|
+
var INLINE = /(`[^`\n]+`)|\*\*(?!\s)((?:[^*`\n]|`[^`\n]*`)*?(?:[^\s*`]|`[^`\n]*`))\*\*/g;
|
|
174
|
+
function inline(text) {
|
|
175
|
+
const nodes = [];
|
|
176
|
+
let at = 0;
|
|
177
|
+
for (const match of text.matchAll(INLINE)) {
|
|
178
|
+
if (match[2] === void 0) continue;
|
|
179
|
+
const index = match.index;
|
|
180
|
+
if (index > at) nodes.push(text.slice(at, index));
|
|
181
|
+
nodes.push(/* @__PURE__ */ jsx("strong", { children: match[2] }, index));
|
|
182
|
+
at = index + match[0].length;
|
|
183
|
+
}
|
|
184
|
+
if (at < text.length) nodes.push(text.slice(at));
|
|
185
|
+
return nodes;
|
|
186
|
+
}
|
|
187
|
+
function withBreaks(lines, format) {
|
|
188
|
+
return lines.map((line, i) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
189
|
+
i > 0 && /* @__PURE__ */ jsx("br", {}),
|
|
190
|
+
format(line)
|
|
191
|
+
] }, i));
|
|
192
|
+
}
|
|
193
|
+
function renderList(list, key) {
|
|
194
|
+
if (list.type === "ul") {
|
|
195
|
+
return /* @__PURE__ */ jsx("ul", { children: list.items.map((item, i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
196
|
+
withBreaks(item.lines, inline),
|
|
197
|
+
item.lists.map(renderList)
|
|
198
|
+
] }, i)) }, key);
|
|
199
|
+
}
|
|
200
|
+
return (
|
|
201
|
+
// `role="list"`: Safari drops the list role from a list styled with
|
|
202
|
+
// `list-style: none`, which this one is, for its number badges.
|
|
203
|
+
/* @__PURE__ */ jsx("ol", { start: list.items[0].n, role: "list", children: list.items.map((item, i) => /* @__PURE__ */ jsxs("li", { value: item.n, children: [
|
|
204
|
+
/* @__PURE__ */ jsx("span", { className: "seclai-markdown-number", children: item.n }),
|
|
205
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
206
|
+
withBreaks(item.lines, inline),
|
|
207
|
+
item.lists.map(renderList)
|
|
208
|
+
] })
|
|
209
|
+
] }, i)) }, key)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
99
212
|
function MarkdownContent({ content }) {
|
|
100
|
-
return /* @__PURE__ */ jsx("div", { className: "seclai-markdown", children: content
|
|
213
|
+
return /* @__PURE__ */ jsx("div", { className: "seclai-markdown", children: parse(content).map((block, i) => {
|
|
214
|
+
switch (block.type) {
|
|
215
|
+
case "ol":
|
|
216
|
+
case "ul":
|
|
217
|
+
return renderList(block, i);
|
|
218
|
+
case "hr":
|
|
219
|
+
return /* @__PURE__ */ jsx("hr", {}, i);
|
|
220
|
+
default:
|
|
221
|
+
return /* @__PURE__ */ jsx("p", { children: withBreaks(block.lines, block.verbatim ? (line) => line : inline) }, i);
|
|
222
|
+
}
|
|
223
|
+
}) });
|
|
101
224
|
}
|
|
102
225
|
|
|
103
226
|
// src/media/MediaGallery.tsx
|
|
@@ -166,7 +289,7 @@ async function downloadSequentially(files, delayMs, signal) {
|
|
|
166
289
|
}
|
|
167
290
|
|
|
168
291
|
// src/placeholders/MediaPreview.tsx
|
|
169
|
-
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
292
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
170
293
|
function hasContent(node) {
|
|
171
294
|
return node != null && node !== false && node !== "";
|
|
172
295
|
}
|
|
@@ -180,7 +303,7 @@ function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }) {
|
|
|
180
303
|
const filename = attachmentFileName(attachment, number);
|
|
181
304
|
const extra = typeof actions === "function" ? actions(attachment) : actions;
|
|
182
305
|
if (!isImage(attachment)) {
|
|
183
|
-
return /* @__PURE__ */ jsx2("figure", { className: "seclai-media", children: /* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ jsx2("figure", { className: "seclai-media", children: /* @__PURE__ */ jsxs2("figcaption", { children: [
|
|
184
307
|
/* @__PURE__ */ jsx2("a", { href: attachment.url, download: filename, children: attachment.name ?? filename }),
|
|
185
308
|
hasContent(extra) && /* @__PURE__ */ jsx2("span", { className: "seclai-media-actions", children: extra })
|
|
186
309
|
] }) });
|
|
@@ -217,7 +340,7 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
217
340
|
else measure();
|
|
218
341
|
}
|
|
219
342
|
}, [attachment.url]);
|
|
220
|
-
const frameContent = /* @__PURE__ */
|
|
343
|
+
const frameContent = /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
221
344
|
failed ? /* @__PURE__ */ jsx2("span", { className: "seclai-media-error", children: "Couldn't load the image." }) : /* @__PURE__ */ jsx2(
|
|
222
345
|
"img",
|
|
223
346
|
{
|
|
@@ -233,7 +356,7 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
233
356
|
number != null && /* @__PURE__ */ jsx2("span", { className: "seclai-media-badge", children: number })
|
|
234
357
|
] });
|
|
235
358
|
const frameStyle = aspectRatioStyle(aspectRatio ?? natural ?? void 0);
|
|
236
|
-
return /* @__PURE__ */
|
|
359
|
+
return /* @__PURE__ */ jsxs2("figure", { className: "seclai-media seclai-media-image", children: [
|
|
237
360
|
onOpen ? /* @__PURE__ */ jsx2(
|
|
238
361
|
"button",
|
|
239
362
|
{
|
|
@@ -246,7 +369,7 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
246
369
|
children: frameContent
|
|
247
370
|
}
|
|
248
371
|
) : /* @__PURE__ */ jsx2("div", { className: "seclai-media-frame", style: frameStyle, children: frameContent }),
|
|
249
|
-
/* @__PURE__ */
|
|
372
|
+
/* @__PURE__ */ jsxs2("figcaption", { className: "seclai-media-bar", children: [
|
|
250
373
|
/* @__PURE__ */ jsx2("a", { href: attachment.url, download: filename, "aria-label": `Download ${label}`, children: "Download" }),
|
|
251
374
|
hasContent(extra) && /* @__PURE__ */ jsx2("span", { className: "seclai-media-actions", children: extra })
|
|
252
375
|
] })
|
|
@@ -254,10 +377,10 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
254
377
|
}
|
|
255
378
|
|
|
256
379
|
// src/media/MediaSkeleton.tsx
|
|
257
|
-
import { jsx as jsx3, jsxs as
|
|
380
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
258
381
|
function MediaSkeleton({ aspectRatio, number, label }) {
|
|
259
382
|
const name = label ?? (number != null ? `Image ${number} is being generated` : "Image is being generated");
|
|
260
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ jsxs3("div", { className: "seclai-media seclai-media-image seclai-media-skeleton", role: "img", "aria-label": name, children: [
|
|
261
384
|
/* @__PURE__ */ jsx3("div", { className: "seclai-media-frame", style: aspectRatioStyle(aspectRatio), children: number != null && /* @__PURE__ */ jsx3("span", { className: "seclai-media-badge", children: number }) }),
|
|
262
385
|
/* @__PURE__ */ jsx3("div", { className: "seclai-media-bar", children: /* @__PURE__ */ jsx3("span", { className: "seclai-media-skeleton-line" }) })
|
|
263
386
|
] });
|
|
@@ -265,7 +388,7 @@ function MediaSkeleton({ aspectRatio, number, label }) {
|
|
|
265
388
|
|
|
266
389
|
// src/media/MediaViewer.tsx
|
|
267
390
|
import { useEffect as useEffect3, useId, useRef as useRef2 } from "react";
|
|
268
|
-
import { Fragment as
|
|
391
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
269
392
|
function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
270
393
|
const dialog = useRef2(null);
|
|
271
394
|
const closeButton = useRef2(null);
|
|
@@ -336,18 +459,18 @@ function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
|
336
459
|
onCancel,
|
|
337
460
|
onClose: onDialogClose,
|
|
338
461
|
onClick,
|
|
339
|
-
children: current && /* @__PURE__ */
|
|
462
|
+
children: current && /* @__PURE__ */ jsxs4("div", { className: "seclai-viewer-body", children: [
|
|
340
463
|
/* @__PURE__ */ jsx4("img", { className: "seclai-viewer-image", src: current.url, alt: label }),
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
/* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ jsxs4("div", { className: "seclai-viewer-bar", children: [
|
|
465
|
+
/* @__PURE__ */ jsxs4("p", { className: "seclai-viewer-title", id: titleId, children: [
|
|
343
466
|
label,
|
|
344
|
-
attachments.length > 1 && /* @__PURE__ */
|
|
467
|
+
attachments.length > 1 && /* @__PURE__ */ jsxs4("span", { className: "seclai-viewer-count", children: [
|
|
345
468
|
number,
|
|
346
469
|
" of ",
|
|
347
470
|
attachments.length
|
|
348
471
|
] })
|
|
349
472
|
] }),
|
|
350
|
-
attachments.length > 1 && /* @__PURE__ */
|
|
473
|
+
attachments.length > 1 && /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
351
474
|
/* @__PURE__ */ jsx4(
|
|
352
475
|
"button",
|
|
353
476
|
{
|
|
@@ -377,7 +500,7 @@ function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
|
377
500
|
}
|
|
378
501
|
|
|
379
502
|
// src/media/MediaGallery.tsx
|
|
380
|
-
import { jsx as jsx5, jsxs as
|
|
503
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
381
504
|
var DOWNLOAD_ALL_DELAY_MS = 400;
|
|
382
505
|
function MediaGallery({
|
|
383
506
|
attachments,
|
|
@@ -408,8 +531,8 @@ function MediaGallery({
|
|
|
408
531
|
}
|
|
409
532
|
}
|
|
410
533
|
const skeletons = Math.max(0, Math.floor(pending));
|
|
411
|
-
return /* @__PURE__ */
|
|
412
|
-
images.length + skeletons > 0 && /* @__PURE__ */
|
|
534
|
+
return /* @__PURE__ */ jsxs5("div", { className: "seclai-gallery", children: [
|
|
535
|
+
images.length + skeletons > 0 && /* @__PURE__ */ jsxs5("ul", { className: "seclai-gallery-grid", children: [
|
|
413
536
|
images.map((image, i) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(
|
|
414
537
|
MediaPreview,
|
|
415
538
|
{
|
|
@@ -671,7 +794,7 @@ function useAgentRun(options = {}) {
|
|
|
671
794
|
}
|
|
672
795
|
|
|
673
796
|
// src/AgentChat.tsx
|
|
674
|
-
import { jsx as jsx6, jsxs as
|
|
797
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
675
798
|
function createSessionId() {
|
|
676
799
|
if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
677
800
|
return Array.from(
|
|
@@ -695,9 +818,9 @@ function plural(count, word) {
|
|
|
695
818
|
}
|
|
696
819
|
function FileChip({ name, tag, preview, status, error, onRemove }) {
|
|
697
820
|
const meta = status === "uploading" ? "Uploading\u2026" : status === "error" ? error : tag;
|
|
698
|
-
return /* @__PURE__ */
|
|
821
|
+
return /* @__PURE__ */ jsxs6("li", { className: "seclai-file", "data-status": status, children: [
|
|
699
822
|
preview && /* @__PURE__ */ jsx6("img", { className: "seclai-file-thumb", src: preview, alt: "" }),
|
|
700
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ jsxs6("span", { className: "seclai-file-text", children: [
|
|
701
824
|
/* @__PURE__ */ jsx6("span", { className: "seclai-file-name", title: name, children: name }),
|
|
702
825
|
meta && /* @__PURE__ */ jsx6("span", { className: "seclai-file-meta", children: meta })
|
|
703
826
|
] }),
|
|
@@ -714,7 +837,7 @@ function FileChip({ name, tag, preview, status, error, onRemove }) {
|
|
|
714
837
|
] });
|
|
715
838
|
}
|
|
716
839
|
function UserTurn({ message, previews }) {
|
|
717
|
-
return /* @__PURE__ */
|
|
840
|
+
return /* @__PURE__ */ jsxs6("li", { className: "seclai-turn seclai-turn-user", children: [
|
|
718
841
|
message.files.length > 0 && /* @__PURE__ */ jsx6("ul", { className: "seclai-files", "aria-label": "Attached files", children: message.files.map((file) => /* @__PURE__ */ jsx6(
|
|
719
842
|
FileChip,
|
|
720
843
|
{
|
|
@@ -729,7 +852,7 @@ function UserTurn({ message, previews }) {
|
|
|
729
852
|
}
|
|
730
853
|
function AssistantTurn({ turn, endpoints }) {
|
|
731
854
|
const { runId } = turn;
|
|
732
|
-
return /* @__PURE__ */
|
|
855
|
+
return /* @__PURE__ */ jsxs6("li", { className: "seclai-turn seclai-turn-assistant", children: [
|
|
733
856
|
turn.output && /* @__PURE__ */ jsx6(MarkdownContent, { content: turn.output }),
|
|
734
857
|
runId && turn.attachments && turn.attachments.length > 0 && /* @__PURE__ */ jsx6(
|
|
735
858
|
MediaGallery,
|
|
@@ -757,7 +880,7 @@ function AttachControl({
|
|
|
757
880
|
disabled,
|
|
758
881
|
onFiles
|
|
759
882
|
}) {
|
|
760
|
-
return /* @__PURE__ */
|
|
883
|
+
return /* @__PURE__ */ jsxs6("label", { className: "seclai-button seclai-attach", "aria-disabled": disabled || void 0, children: [
|
|
761
884
|
label,
|
|
762
885
|
/* @__PURE__ */ jsx6(
|
|
763
886
|
"input",
|
|
@@ -991,9 +1114,9 @@ function AgentChat({
|
|
|
991
1114
|
}
|
|
992
1115
|
} : {};
|
|
993
1116
|
const buttons = attachButtons?.length ? attachButtons : [{ label: "Attach" }];
|
|
994
|
-
return /* @__PURE__ */
|
|
995
|
-
/* @__PURE__ */
|
|
996
|
-
transcript.turns.map((turn, i) => /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ jsxs6("div", { className: "seclai-agent seclai-chat", children: [
|
|
1118
|
+
/* @__PURE__ */ jsxs6("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
|
|
1119
|
+
transcript.turns.map((turn, i) => /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
997
1120
|
/* @__PURE__ */ jsx6(
|
|
998
1121
|
UserTurn,
|
|
999
1122
|
{
|
|
@@ -1006,7 +1129,7 @@ function AgentChat({
|
|
|
1006
1129
|
transcript.pending && /* @__PURE__ */ jsx6(UserTurn, { message: transcript.pending, previews: sentPreviews.current }),
|
|
1007
1130
|
streaming && /* @__PURE__ */ jsx6("li", { className: "seclai-turn seclai-turn-assistant", children: run.text ? /* @__PURE__ */ jsx6(MarkdownContent, { content: run.text }) : /* @__PURE__ */ jsx6("p", { className: "seclai-notice", children: "Thinking\u2026" }) })
|
|
1008
1131
|
] }),
|
|
1009
|
-
/* @__PURE__ */
|
|
1132
|
+
/* @__PURE__ */ jsxs6(
|
|
1010
1133
|
"form",
|
|
1011
1134
|
{
|
|
1012
1135
|
className: dragging ? "seclai-form seclai-dropping" : "seclai-form",
|
|
@@ -1038,7 +1161,7 @@ function AgentChat({
|
|
|
1038
1161
|
}
|
|
1039
1162
|
),
|
|
1040
1163
|
notice && /* @__PURE__ */ jsx6("p", { className: "seclai-error", role: "alert", children: notice }),
|
|
1041
|
-
/* @__PURE__ */
|
|
1164
|
+
/* @__PURE__ */ jsxs6("div", { className: "seclai-actions", children: [
|
|
1042
1165
|
acceptsFiles && buttons.map((button) => /* @__PURE__ */ jsx6(
|
|
1043
1166
|
AttachControl,
|
|
1044
1167
|
{
|
|
@@ -1061,7 +1184,7 @@ function AgentChat({
|
|
|
1061
1184
|
|
|
1062
1185
|
// src/AgentRunForm.tsx
|
|
1063
1186
|
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
1064
|
-
import { jsx as jsx7, jsxs as
|
|
1187
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1065
1188
|
function slotProblem(slot, count) {
|
|
1066
1189
|
const label = slot.label ?? slot.name;
|
|
1067
1190
|
const min = slot.min ?? 0;
|
|
@@ -1115,23 +1238,23 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
|
|
|
1115
1238
|
return /* @__PURE__ */ jsx7("div", { className: "seclai-agent", children: /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: loadError }) });
|
|
1116
1239
|
}
|
|
1117
1240
|
if (!slots) {
|
|
1118
|
-
return /* @__PURE__ */
|
|
1241
|
+
return /* @__PURE__ */ jsxs7("div", { className: "seclai-agent", children: [
|
|
1119
1242
|
/* @__PURE__ */ jsx7("p", { className: "seclai-notice", children: "Loading\u2026" }),
|
|
1120
|
-
/* @__PURE__ */
|
|
1243
|
+
/* @__PURE__ */ jsxs7("div", { className: "seclai-skeleton", "aria-hidden": "true", children: [
|
|
1121
1244
|
/* @__PURE__ */ jsx7("span", {}),
|
|
1122
1245
|
/* @__PURE__ */ jsx7("span", {})
|
|
1123
1246
|
] })
|
|
1124
1247
|
] });
|
|
1125
1248
|
}
|
|
1126
1249
|
const error = formError ?? run.error;
|
|
1127
|
-
return /* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */
|
|
1129
|
-
/* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ jsxs7("div", { className: "seclai-agent", children: [
|
|
1251
|
+
/* @__PURE__ */ jsxs7("form", { className: "seclai-form", onSubmit: submit, children: [
|
|
1252
|
+
/* @__PURE__ */ jsxs7("label", { className: "seclai-field", children: [
|
|
1130
1253
|
/* @__PURE__ */ jsx7("span", { children: inputLabel }),
|
|
1131
1254
|
/* @__PURE__ */ jsx7("textarea", { rows: 4, value: input, onChange: (e) => setInput(e.target.value) })
|
|
1132
1255
|
] }),
|
|
1133
|
-
slots.map((slot) => /* @__PURE__ */
|
|
1134
|
-
/* @__PURE__ */
|
|
1256
|
+
slots.map((slot) => /* @__PURE__ */ jsxs7("label", { className: "seclai-field", children: [
|
|
1257
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
1135
1258
|
slot.label ?? slot.name,
|
|
1136
1259
|
(slot.min ?? 0) > 0 ? " (required)" : ""
|
|
1137
1260
|
] }),
|
|
@@ -1146,19 +1269,19 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
|
|
|
1146
1269
|
}
|
|
1147
1270
|
)
|
|
1148
1271
|
] }, slot.name)),
|
|
1149
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ jsxs7("div", { className: "seclai-actions", children: [
|
|
1150
1273
|
/* @__PURE__ */ jsx7("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: busy, children: uploading ? "Uploading\u2026" : "Run" }),
|
|
1151
1274
|
run.status === "running" && /* @__PURE__ */ jsx7("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
|
|
1152
1275
|
] })
|
|
1153
1276
|
] }),
|
|
1154
|
-
run.steps.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */
|
|
1277
|
+
run.steps.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */ jsxs7("li", { children: [
|
|
1155
1278
|
step.name,
|
|
1156
1279
|
": ",
|
|
1157
1280
|
step.message
|
|
1158
1281
|
] }, step.id)) }),
|
|
1159
1282
|
error && /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: error }),
|
|
1160
1283
|
run.status === "cancelled" && /* @__PURE__ */ jsx7("p", { className: "seclai-notice", children: "Stopped." }),
|
|
1161
|
-
(run.text || run.attachments.length > 0) && /* @__PURE__ */
|
|
1284
|
+
(run.text || run.attachments.length > 0) && /* @__PURE__ */ jsxs7("div", { className: "seclai-output", "aria-live": "polite", "aria-busy": run.status === "running", children: [
|
|
1162
1285
|
run.text && /* @__PURE__ */ jsx7(MarkdownContent, { content: run.text }),
|
|
1163
1286
|
run.attachments.length > 0 && /* @__PURE__ */ jsx7(MediaGallery, { attachments: run.attachments })
|
|
1164
1287
|
] })
|
package/dist/styles.css
CHANGED
|
@@ -370,11 +370,72 @@
|
|
|
370
370
|
inset: -8px;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
/* Agent output: paragraphs, lists, rules and bold. The list numbers are badges, below. */
|
|
373
374
|
.seclai-markdown {
|
|
374
|
-
white-space: pre-wrap;
|
|
375
375
|
overflow-wrap: anywhere;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
.seclai-markdown > * {
|
|
379
|
+
margin: 0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.seclai-markdown > * + * {
|
|
383
|
+
margin-block-start: 0.75em;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/* Keeps the text's own spacing, such as indented code. */
|
|
387
|
+
.seclai-markdown p {
|
|
388
|
+
white-space: pre-wrap;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.seclai-markdown ul {
|
|
392
|
+
padding-inline-start: 1.25em;
|
|
393
|
+
list-style: disc;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.seclai-markdown ul > li + li {
|
|
397
|
+
margin-block-start: 4px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.seclai-markdown ol {
|
|
401
|
+
display: flex;
|
|
402
|
+
flex-direction: column;
|
|
403
|
+
gap: 6px;
|
|
404
|
+
padding: 0;
|
|
405
|
+
list-style: none;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.seclai-markdown ol > li {
|
|
409
|
+
display: flex;
|
|
410
|
+
align-items: baseline;
|
|
411
|
+
gap: 8px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.seclai-markdown ol > li > :last-child {
|
|
415
|
+
min-width: 0;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/* A list nested in an item sits under the item's text, inset by the parent's
|
|
419
|
+
badge or bullet. A nested numbered list keeps its badges. */
|
|
420
|
+
.seclai-markdown li ul,
|
|
421
|
+
.seclai-markdown li ol {
|
|
422
|
+
margin: 6px 0 0;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.seclai-markdown ul ul {
|
|
426
|
+
list-style: circle;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.seclai-markdown ul ul ul {
|
|
430
|
+
list-style: square;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.seclai-markdown hr {
|
|
434
|
+
height: 0;
|
|
435
|
+
border: 0;
|
|
436
|
+
border-block-start: 1px solid var(--seclai-border);
|
|
437
|
+
}
|
|
438
|
+
|
|
378
439
|
.seclai-media {
|
|
379
440
|
display: flex;
|
|
380
441
|
flex-direction: column;
|
|
@@ -486,11 +547,12 @@ button.seclai-media-frame:focus-visible {
|
|
|
486
547
|
}
|
|
487
548
|
}
|
|
488
549
|
|
|
489
|
-
/*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
550
|
+
/*
|
|
551
|
+
* A number badge, on an image and on the matching item of a numbered list in
|
|
552
|
+
* the agent's text. Fixed colours: the badge sits on the image, not on the page.
|
|
553
|
+
*/
|
|
554
|
+
.seclai-media-badge,
|
|
555
|
+
.seclai-markdown-number {
|
|
494
556
|
display: inline-flex;
|
|
495
557
|
align-items: center;
|
|
496
558
|
justify-content: center;
|
|
@@ -506,6 +568,19 @@ button.seclai-media-frame:focus-visible {
|
|
|
506
568
|
border-radius: 999px;
|
|
507
569
|
}
|
|
508
570
|
|
|
571
|
+
.seclai-media-badge {
|
|
572
|
+
position: absolute;
|
|
573
|
+
top: 8px;
|
|
574
|
+
inset-inline-start: 8px;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* On the page, the same badge inverts in a dark colour scheme, so it still stands out. */
|
|
578
|
+
.seclai-markdown-number {
|
|
579
|
+
flex: none;
|
|
580
|
+
color: light-dark(#ffffff, #000000);
|
|
581
|
+
background: light-dark(rgb(0 0 0 / 0.72), rgb(255 255 255 / 0.85));
|
|
582
|
+
}
|
|
583
|
+
|
|
509
584
|
.seclai-media-error {
|
|
510
585
|
position: absolute;
|
|
511
586
|
inset: 0;
|