@seclai/react 0.0.15 → 0.0.16

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 CHANGED
@@ -32,6 +32,7 @@ export function App() {
32
32
  - **`AgentRunForm`** builds a text input and file inputs from the agent's accepted attachments, uploads the files, then runs with text and files together.
33
33
  - **`AgentChat`** sends each message as a run with a shared session id and streams the reply.
34
34
  - **`SeclaiAgent`** renders one of the two based on `mode`.
35
+ - **`RunProgress`** shows a running run's steps and elapsed time. See [below](#runprogress).
35
36
 
36
37
  ### Files in `AgentChat`
37
38
 
@@ -133,28 +134,35 @@ await start({ input: "Hello", uploadIds: ["..."], sessionId: "..." });
133
134
 
134
135
  Options also take `basePath` and `agentId`, as the components do.
135
136
 
136
- Runs that generate images can take a minute or two, so show the time elapsed:
137
+ ### `RunProgress`
138
+
139
+ Runs that generate images can take a minute or two. `RunProgress` shows a running run's steps and the time elapsed, and renders nothing otherwise:
137
140
 
138
141
  ```tsx
139
- function Elapsed({ startedAt }: { startedAt: number }) {
140
- const [now, setNow] = useState(Date.now());
141
- useEffect(() => {
142
- const timer = setInterval(() => setNow(Date.now()), 1000);
143
- return () => clearInterval(timer);
144
- }, []);
145
- const seconds = Math.max(0, Math.floor((now - startedAt) / 1000));
146
- return <>{Math.floor(seconds / 60)}:{String(seconds % 60).padStart(2, "0")}</>;
147
- }
142
+ import { RunProgress, useAgentRun } from "@seclai/react";
148
143
 
149
144
  const run = useAgentRun();
150
145
 
151
- {run.status === "running" && run.startedAt !== null && (
152
- <p>
153
- Usually takes a minute or two · <Elapsed startedAt={run.startedAt} />
154
- </p>
155
- )}
146
+ <RunProgress
147
+ run={run}
148
+ message={(seconds) => (seconds < 150 ? "Generating images usually takes a minute or two." : "Still working…")}
149
+ />
156
150
  ```
157
151
 
152
+ - It shows "Starting the run…" until the first step, then each step's name and message, with ✓ for finished steps and ● for the current one.
153
+ - The clock reads `m:ss`, and screen readers get "42 seconds elapsed". Steps and the message are announced as they change, but the clock isn't, so keep the seconds out of `message`.
154
+ - `run` needs only `status`, `steps` and `startedAt`, so a plain object works too.
155
+ - `AgentChat` shows it until the reply starts streaming.
156
+
157
+ | Prop | |
158
+ |---|---|
159
+ | `run` | Required. `{ status, steps, startedAt }`, such as a `useAgentRun` result |
160
+ | `showSteps` | Show the step list. Defaults to `true` |
161
+ | `message` | A note next to the clock: a node, or `(seconds) => ReactNode` |
162
+ | `className` | Added to the outer element |
163
+
164
+ For just the clock, `useElapsed(startedAt, running)` returns whole seconds since `startedAt`, ticking while `running`. It's 0 on the first render, so server and client markup match.
165
+
158
166
  ### Building your own UI
159
167
 
160
168
  To upload files and run the agent from your own UI, use the helpers the components are built on:
package/dist/index.cjs CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  MediaPreview: () => MediaPreview,
30
30
  MediaSkeleton: () => MediaSkeleton,
31
31
  MediaViewer: () => MediaViewer,
32
+ RunProgress: () => RunProgress,
32
33
  SeclaiAgent: () => SeclaiAgent,
33
34
  attachmentFileName: () => attachmentFileName,
34
35
  createEndpoints: () => createEndpoints,
@@ -36,12 +37,13 @@ __export(index_exports, {
36
37
  saveFile: () => saveFile,
37
38
  saveFiles: () => saveFiles,
38
39
  uploadFile: () => uploadFile,
39
- useAgentRun: () => useAgentRun
40
+ useAgentRun: () => useAgentRun,
41
+ useElapsed: () => useElapsed
40
42
  });
41
43
  module.exports = __toCommonJS(index_exports);
42
44
 
43
45
  // src/AgentChat.tsx
44
- var import_react7 = require("react");
46
+ var import_react8 = require("react");
45
47
 
46
48
  // src/attachments.ts
47
49
  var import_react = require("react");
@@ -634,8 +636,80 @@ function MediaGallery({
634
636
  ] });
635
637
  }
636
638
 
637
- // src/useAgentRun.ts
639
+ // src/RunProgress.tsx
638
640
  var import_react6 = require("react");
641
+ var import_jsx_runtime6 = require("react/jsx-runtime");
642
+ function useElapsed(startedAt, running) {
643
+ const [now, setNow] = (0, import_react6.useState)(null);
644
+ (0, import_react6.useEffect)(() => {
645
+ if (!running || startedAt === null) return;
646
+ let timer;
647
+ const tick = () => {
648
+ const time = Date.now();
649
+ setNow(time);
650
+ const into = ((time - startedAt) % 1e3 + 1e3) % 1e3;
651
+ timer = setTimeout(tick, 1e3 - into);
652
+ };
653
+ tick();
654
+ return () => clearTimeout(timer);
655
+ }, [running, startedAt]);
656
+ if (startedAt === null || now === null) return 0;
657
+ return Math.max(0, Math.floor((now - startedAt) / 1e3));
658
+ }
659
+ function formatClock(seconds) {
660
+ return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
661
+ }
662
+ function spokenDuration(seconds) {
663
+ const minutes = Math.floor(seconds / 60);
664
+ const rest = seconds % 60;
665
+ const unit = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
666
+ if (minutes === 0) return unit(rest, "second");
667
+ return rest === 0 ? unit(minutes, "minute") : `${unit(minutes, "minute")} ${unit(rest, "second")}`;
668
+ }
669
+ function RunProgress({ run, showSteps = true, message, className }) {
670
+ const running = run.status === "running";
671
+ const seconds = useElapsed(run.startedAt, running);
672
+ if (!running) return null;
673
+ const note = typeof message === "function" ? message(seconds) : message;
674
+ const last = run.steps.length - 1;
675
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
676
+ "div",
677
+ {
678
+ className: className ? `seclai-run-progress ${className}` : "seclai-run-progress",
679
+ "aria-live": "polite",
680
+ children: [
681
+ showSteps && (run.steps.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "seclai-notice", children: "Starting the run\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ol", { className: "seclai-steps", children: run.steps.map((step, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { children: [
682
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-step-marker", "aria-hidden": "true", children: i === last ? "\u25CF" : "\u2713" }),
683
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-sr-only", children: i === last ? "In progress: " : "Done: " }),
684
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
685
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-step-name", children: step.name }),
686
+ step.message && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "seclai-step-message", children: [
687
+ " \xB7 ",
688
+ step.message
689
+ ] })
690
+ ] })
691
+ ] }, step.id)) })),
692
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "seclai-run-progress-note", children: [
693
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-run-progress-pulse", "aria-hidden": "true" }),
694
+ note != null && note !== false && note !== "" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-run-progress-message", children: note }),
695
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
696
+ "span",
697
+ {
698
+ className: "seclai-run-progress-clock",
699
+ role: "timer",
700
+ "aria-live": "off",
701
+ "aria-label": `${spokenDuration(seconds)} elapsed`,
702
+ children: formatClock(seconds)
703
+ }
704
+ )
705
+ ] })
706
+ ]
707
+ }
708
+ );
709
+ }
710
+
711
+ // src/useAgentRun.ts
712
+ var import_react7 = require("react");
639
713
 
640
714
  // src/sse.ts
641
715
  function parseData(data) {
@@ -781,15 +855,15 @@ function applyEvent(state, { event, data }, endpoints) {
781
855
  }
782
856
  function useAgentRun(options = {}) {
783
857
  const { basePath, agentId, onEvent } = options;
784
- const endpoints = (0, import_react6.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
785
- const [state, setState] = (0, import_react6.useState)(IDLE);
786
- const active = (0, import_react6.useRef)(null);
787
- const onEventRef = (0, import_react6.useRef)(onEvent);
788
- (0, import_react6.useEffect)(() => {
858
+ const endpoints = (0, import_react7.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
859
+ const [state, setState] = (0, import_react7.useState)(IDLE);
860
+ const active = (0, import_react7.useRef)(null);
861
+ const onEventRef = (0, import_react7.useRef)(onEvent);
862
+ (0, import_react7.useEffect)(() => {
789
863
  onEventRef.current = onEvent;
790
864
  });
791
- (0, import_react6.useEffect)(() => () => active.current?.abort(), []);
792
- const start = (0, import_react6.useCallback)(
865
+ (0, import_react7.useEffect)(() => () => active.current?.abort(), []);
866
+ const start = (0, import_react7.useCallback)(
793
867
  async ({ input, uploadIds, sessionId }) => {
794
868
  active.current?.abort();
795
869
  const controller = new AbortController();
@@ -849,8 +923,8 @@ function useAgentRun(options = {}) {
849
923
  },
850
924
  [endpoints]
851
925
  );
852
- const cancel = (0, import_react6.useCallback)(() => active.current?.abort(), []);
853
- const reset = (0, import_react6.useCallback)(() => {
926
+ const cancel = (0, import_react7.useCallback)(() => active.current?.abort(), []);
927
+ const reset = (0, import_react7.useCallback)(() => {
854
928
  const controller = active.current;
855
929
  active.current = null;
856
930
  controller?.abort();
@@ -860,7 +934,7 @@ function useAgentRun(options = {}) {
860
934
  }
861
935
 
862
936
  // src/AgentChat.tsx
863
- var import_jsx_runtime6 = require("react/jsx-runtime");
937
+ var import_jsx_runtime7 = require("react/jsx-runtime");
864
938
  function createSessionId() {
865
939
  if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
866
940
  return Array.from(
@@ -884,13 +958,13 @@ function plural(count, word) {
884
958
  }
885
959
  function FileChip({ name, tag, preview, status, error, onRemove }) {
886
960
  const meta = status === "uploading" ? "Uploading\u2026" : status === "error" ? error : tag;
887
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "seclai-file", "data-status": status, children: [
888
- preview && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "seclai-file-thumb", src: preview, alt: "" }),
889
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "seclai-file-text", children: [
890
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-file-name", title: name, children: name }),
891
- meta && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "seclai-file-meta", children: meta })
961
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "seclai-file", "data-status": status, children: [
962
+ preview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { className: "seclai-file-thumb", src: preview, alt: "" }),
963
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "seclai-file-text", children: [
964
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "seclai-file-name", title: name, children: name }),
965
+ meta && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "seclai-file-meta", children: meta })
892
966
  ] }),
893
- onRemove && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
967
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
894
968
  "button",
895
969
  {
896
970
  type: "button",
@@ -903,8 +977,8 @@ function FileChip({ name, tag, preview, status, error, onRemove }) {
903
977
  ] });
904
978
  }
905
979
  function UserTurn({ message, previews }) {
906
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "seclai-turn seclai-turn-user", children: [
907
- message.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "seclai-files", "aria-label": "Attached files", children: message.files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
980
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "seclai-turn seclai-turn-user", children: [
981
+ message.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "seclai-files", "aria-label": "Attached files", children: message.files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
908
982
  FileChip,
909
983
  {
910
984
  name: file.name,
@@ -913,14 +987,14 @@ function UserTurn({ message, previews }) {
913
987
  },
914
988
  file.uploadId
915
989
  )) }),
916
- message.input && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MarkdownContent, { content: message.input })
990
+ message.input && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownContent, { content: message.input })
917
991
  ] });
918
992
  }
919
993
  function AssistantTurn({ turn, endpoints }) {
920
994
  const { runId } = turn;
921
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "seclai-turn seclai-turn-assistant", children: [
922
- turn.output && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MarkdownContent, { content: turn.output }),
923
- runId && turn.attachments && turn.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
995
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "seclai-turn seclai-turn-assistant", children: [
996
+ turn.output && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownContent, { content: turn.output }),
997
+ runId && turn.attachments && turn.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
924
998
  MediaGallery,
925
999
  {
926
1000
  attachments: turn.attachments.map(({ id, name, mime, bytes }) => ({
@@ -932,8 +1006,8 @@ function AssistantTurn({ turn, endpoints }) {
932
1006
  }))
933
1007
  }
934
1008
  ),
935
- turn.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "seclai-error", role: "alert", children: turn.error }),
936
- turn.status === "cancelled" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "seclai-notice", children: "Stopped." })
1009
+ turn.error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-error", role: "alert", children: turn.error }),
1010
+ turn.status === "cancelled" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-notice", children: "Stopped." })
937
1011
  ] });
938
1012
  }
939
1013
  function toTurnAttachment({ id, name, mime, bytes }) {
@@ -946,9 +1020,9 @@ function AttachControl({
946
1020
  disabled,
947
1021
  onFiles
948
1022
  }) {
949
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "seclai-button seclai-attach", "aria-disabled": disabled || void 0, children: [
1023
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "seclai-button seclai-attach", "aria-disabled": disabled || void 0, children: [
950
1024
  label,
951
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1025
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
952
1026
  "input",
953
1027
  {
954
1028
  type: "file",
@@ -975,10 +1049,10 @@ function AgentChat({
975
1049
  initialTurns,
976
1050
  onTurnComplete
977
1051
  }) {
978
- const endpoints = (0, import_react7.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
1052
+ const endpoints = (0, import_react8.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
979
1053
  const run = useAgentRun({ basePath, agentId });
980
1054
  const { slots } = useAcceptedAttachments(endpoints);
981
- const [transcript, setTranscript] = (0, import_react7.useState)(() => ({
1055
+ const [transcript, setTranscript] = (0, import_react8.useState)(() => ({
982
1056
  sessionId,
983
1057
  epoch: 0,
984
1058
  turns: initialTurns ?? [],
@@ -986,15 +1060,15 @@ function AgentChat({
986
1060
  generatedSessionId: null,
987
1061
  runEpoch: null
988
1062
  }));
989
- const [message, setMessage] = (0, import_react7.useState)("");
990
- const [files, setFiles] = (0, import_react7.useState)([]);
991
- const [notice, setNotice] = (0, import_react7.useState)(null);
992
- const [dragging, setDragging] = (0, import_react7.useState)(false);
993
- const generatedSessionId = (0, import_react7.useRef)(null);
994
- const shownEpoch = (0, import_react7.useRef)(transcript.epoch);
995
- const turnComplete = (0, import_react7.useRef)(onTurnComplete);
996
- const sentPreviews = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
997
- const pendingPreviews = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
1063
+ const [message, setMessage] = (0, import_react8.useState)("");
1064
+ const [files, setFiles] = (0, import_react8.useState)([]);
1065
+ const [notice, setNotice] = (0, import_react8.useState)(null);
1066
+ const [dragging, setDragging] = (0, import_react8.useState)(false);
1067
+ const generatedSessionId = (0, import_react8.useRef)(null);
1068
+ const shownEpoch = (0, import_react8.useRef)(transcript.epoch);
1069
+ const turnComplete = (0, import_react8.useRef)(onTurnComplete);
1070
+ const sentPreviews = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
1071
+ const pendingPreviews = (0, import_react8.useRef)(/* @__PURE__ */ new Set());
998
1072
  if (transcript.sessionId !== sessionId) {
999
1073
  const adopting = transcript.sessionId === void 0 && sessionId !== void 0 && sessionId === transcript.generatedSessionId;
1000
1074
  setTranscript(
@@ -1008,10 +1082,10 @@ function AgentChat({
1008
1082
  }
1009
1083
  );
1010
1084
  }
1011
- (0, import_react7.useEffect)(() => {
1085
+ (0, import_react8.useEffect)(() => {
1012
1086
  turnComplete.current = onTurnComplete;
1013
1087
  });
1014
- (0, import_react7.useEffect)(() => {
1088
+ (0, import_react8.useEffect)(() => {
1015
1089
  if (shownEpoch.current === transcript.epoch) return;
1016
1090
  shownEpoch.current = transcript.epoch;
1017
1091
  run.cancel();
@@ -1024,7 +1098,7 @@ function AgentChat({
1024
1098
  setFiles([]);
1025
1099
  setNotice(null);
1026
1100
  }, [transcript.epoch, run.cancel]);
1027
- (0, import_react7.useEffect)(
1101
+ (0, import_react8.useEffect)(
1028
1102
  () => () => {
1029
1103
  pendingPreviews.current.forEach(revoke);
1030
1104
  sentPreviews.current.forEach(revoke);
@@ -1180,29 +1254,29 @@ function AgentChat({
1180
1254
  }
1181
1255
  } : {};
1182
1256
  const buttons = attachButtons?.length ? attachButtons : [{ label: "Attach" }];
1183
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "seclai-agent seclai-chat", children: [
1184
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
1185
- transcript.turns.map((turn, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react7.Fragment, { children: [
1186
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1257
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-agent seclai-chat", children: [
1258
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
1259
+ transcript.turns.map((turn, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react8.Fragment, { children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1187
1261
  UserTurn,
1188
1262
  {
1189
1263
  message: { input: turn.input, files: turn.files ?? [] },
1190
1264
  previews: sentPreviews.current
1191
1265
  }
1192
1266
  ),
1193
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AssistantTurn, { turn, endpoints })
1267
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AssistantTurn, { turn, endpoints })
1194
1268
  ] }, `${transcript.epoch}:${i}`)),
1195
- transcript.pending && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UserTurn, { message: transcript.pending, previews: sentPreviews.current }),
1196
- streaming && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { className: "seclai-turn seclai-turn-assistant", children: run.text ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MarkdownContent, { content: run.text }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "seclai-notice", children: "Thinking\u2026" }) })
1269
+ transcript.pending && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UserTurn, { message: transcript.pending, previews: sentPreviews.current }),
1270
+ streaming && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { className: "seclai-turn seclai-turn-assistant", children: run.text ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownContent, { content: run.text }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RunProgress, { run }) })
1197
1271
  ] }),
1198
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1272
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1199
1273
  "form",
1200
1274
  {
1201
1275
  className: dragging ? "seclai-form seclai-dropping" : "seclai-form",
1202
1276
  onSubmit,
1203
1277
  ...dropHandlers,
1204
1278
  children: [
1205
- files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "seclai-files", "aria-label": "Files to send", children: files.map((f) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1279
+ files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "seclai-files", "aria-label": "Files to send", children: files.map((f) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1206
1280
  FileChip,
1207
1281
  {
1208
1282
  name: f.name,
@@ -1214,7 +1288,7 @@ function AgentChat({
1214
1288
  },
1215
1289
  f.localId
1216
1290
  )) }),
1217
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1291
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1218
1292
  "textarea",
1219
1293
  {
1220
1294
  rows: 2,
@@ -1226,9 +1300,9 @@ function AgentChat({
1226
1300
  onPaste: acceptsFiles ? onPaste : void 0
1227
1301
  }
1228
1302
  ),
1229
- notice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "seclai-error", role: "alert", children: notice }),
1230
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "seclai-actions", children: [
1231
- acceptsFiles && buttons.map((button) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1303
+ notice && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-error", role: "alert", children: notice }),
1304
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-actions", children: [
1305
+ acceptsFiles && buttons.map((button) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1232
1306
  AttachControl,
1233
1307
  {
1234
1308
  label: button.label,
@@ -1239,8 +1313,8 @@ function AgentChat({
1239
1313
  },
1240
1314
  `${button.label}\0${button.tag ?? ""}`
1241
1315
  )),
1242
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: !canSend, children: "Send" }),
1243
- running && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1316
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: !canSend, children: "Send" }),
1317
+ running && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1244
1318
  ] })
1245
1319
  ]
1246
1320
  }
@@ -1249,8 +1323,8 @@ function AgentChat({
1249
1323
  }
1250
1324
 
1251
1325
  // src/AgentRunForm.tsx
1252
- var import_react8 = require("react");
1253
- var import_jsx_runtime7 = require("react/jsx-runtime");
1326
+ var import_react9 = require("react");
1327
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1254
1328
  function slotProblem(slot, count) {
1255
1329
  const label = slot.label ?? slot.name;
1256
1330
  const min = slot.min ?? 0;
@@ -1261,13 +1335,13 @@ function slotProblem(slot, count) {
1261
1335
  return null;
1262
1336
  }
1263
1337
  function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1264
- const endpoints = (0, import_react8.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
1338
+ const endpoints = (0, import_react9.useMemo)(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
1265
1339
  const run = useAgentRun({ basePath, agentId });
1266
1340
  const { slots, error: loadError } = useAcceptedAttachments(endpoints);
1267
- const [input, setInput] = (0, import_react8.useState)("");
1268
- const [files, setFiles] = (0, import_react8.useState)({});
1269
- const [uploading, setUploading] = (0, import_react8.useState)(false);
1270
- const [formError, setFormError] = (0, import_react8.useState)(null);
1341
+ const [input, setInput] = (0, import_react9.useState)("");
1342
+ const [files, setFiles] = (0, import_react9.useState)({});
1343
+ const [uploading, setUploading] = (0, import_react9.useState)(false);
1344
+ const [formError, setFormError] = (0, import_react9.useState)(null);
1271
1345
  const selected = Object.values(files).flat();
1272
1346
  const busy = uploading || run.status === "running";
1273
1347
  async function submit(event) {
@@ -1301,30 +1375,30 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1301
1375
  onFinish?.(result);
1302
1376
  }
1303
1377
  if (loadError) {
1304
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "seclai-agent", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-error", role: "alert", children: loadError }) });
1378
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "seclai-agent", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "seclai-error", role: "alert", children: loadError }) });
1305
1379
  }
1306
1380
  if (!slots) {
1307
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-agent", children: [
1308
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-notice", children: "Loading\u2026" }),
1309
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-skeleton", "aria-hidden": "true", children: [
1310
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", {}),
1311
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", {})
1381
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "seclai-agent", children: [
1382
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "seclai-notice", children: "Loading\u2026" }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "seclai-skeleton", "aria-hidden": "true", children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", {}),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", {})
1312
1386
  ] })
1313
1387
  ] });
1314
1388
  }
1315
1389
  const error = formError ?? run.error;
1316
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-agent", children: [
1317
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { className: "seclai-form", onSubmit: submit, children: [
1318
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "seclai-field", children: [
1319
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: inputLabel }),
1320
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("textarea", { rows: 4, value: input, onChange: (e) => setInput(e.target.value) })
1390
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "seclai-agent", children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { className: "seclai-form", onSubmit: submit, children: [
1392
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "seclai-field", children: [
1393
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: inputLabel }),
1394
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("textarea", { rows: 4, value: input, onChange: (e) => setInput(e.target.value) })
1321
1395
  ] }),
1322
- slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "seclai-field", children: [
1323
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1396
+ slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "seclai-field", children: [
1397
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
1324
1398
  slot.label ?? slot.name,
1325
1399
  (slot.min ?? 0) > 0 ? " (required)" : ""
1326
1400
  ] }),
1327
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1401
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1328
1402
  "input",
1329
1403
  {
1330
1404
  type: "file",
@@ -1335,29 +1409,29 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1335
1409
  }
1336
1410
  )
1337
1411
  ] }, slot.name)),
1338
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-actions", children: [
1339
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: busy, children: uploading ? "Uploading\u2026" : "Run" }),
1340
- run.status === "running" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1412
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "seclai-actions", children: [
1413
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: busy, children: uploading ? "Uploading\u2026" : "Run" }),
1414
+ run.status === "running" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1341
1415
  ] })
1342
1416
  ] }),
1343
- run.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { children: [
1417
+ run.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { children: [
1344
1418
  step.name,
1345
1419
  ": ",
1346
1420
  step.message
1347
1421
  ] }, step.id)) }),
1348
- error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-error", role: "alert", children: error }),
1349
- run.status === "cancelled" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "seclai-notice", children: "Stopped." }),
1350
- (run.text || run.attachments.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "seclai-output", "aria-live": "polite", "aria-busy": run.status === "running", children: [
1351
- run.text && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MarkdownContent, { content: run.text }),
1352
- run.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MediaGallery, { attachments: run.attachments })
1422
+ error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "seclai-error", role: "alert", children: error }),
1423
+ run.status === "cancelled" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "seclai-notice", children: "Stopped." }),
1424
+ (run.text || run.attachments.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "seclai-output", "aria-live": "polite", "aria-busy": run.status === "running", children: [
1425
+ run.text && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MarkdownContent, { content: run.text }),
1426
+ run.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MediaGallery, { attachments: run.attachments })
1353
1427
  ] })
1354
1428
  ] });
1355
1429
  }
1356
1430
 
1357
1431
  // src/SeclaiAgent.tsx
1358
- var import_jsx_runtime8 = require("react/jsx-runtime");
1432
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1359
1433
  function SeclaiAgent({ mode, basePath, agentId }) {
1360
- return mode === "chat" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AgentChat, { basePath, agentId }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AgentRunForm, { basePath, agentId });
1434
+ return mode === "chat" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AgentChat, { basePath, agentId }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AgentRunForm, { basePath, agentId });
1361
1435
  }
1362
1436
  // Annotate the CommonJS export names for ESM import in node:
1363
1437
  0 && (module.exports = {
@@ -1369,6 +1443,7 @@ function SeclaiAgent({ mode, basePath, agentId }) {
1369
1443
  MediaPreview,
1370
1444
  MediaSkeleton,
1371
1445
  MediaViewer,
1446
+ RunProgress,
1372
1447
  SeclaiAgent,
1373
1448
  attachmentFileName,
1374
1449
  createEndpoints,
@@ -1376,5 +1451,6 @@ function SeclaiAgent({ mode, basePath, agentId }) {
1376
1451
  saveFile,
1377
1452
  saveFiles,
1378
1453
  uploadFile,
1379
- useAgentRun
1454
+ useAgentRun,
1455
+ useElapsed
1380
1456
  });
package/dist/index.d.cts CHANGED
@@ -236,6 +236,34 @@ interface SeclaiAgentProps extends AgentEndpointOptions {
236
236
  /** Boots the agent UI from its mode, and its agent id when the server hosts several. */
237
237
  declare function SeclaiAgent({ mode, basePath, agentId }: SeclaiAgentProps): react.JSX.Element;
238
238
 
239
+ /**
240
+ * Whole seconds since `startedAt` (a `Date.now()` value, such as `useAgentRun`'s
241
+ * `startedAt`), updated every second while `running`. It's 0 when `startedAt` is
242
+ * `null`, and on the first render, so server and client render the same markup;
243
+ * the real value follows in an effect. When `running` turns false it keeps its
244
+ * last value and stops the timer.
245
+ */
246
+ declare function useElapsed(startedAt: number | null, running: boolean): number;
247
+ /** The fields `RunProgress` reads. A `useAgentRun` result fits, as does a plain object. */
248
+ type RunProgressRun = Pick<AgentRunState, "status" | "steps" | "startedAt">;
249
+ interface RunProgressProps {
250
+ run: RunProgressRun;
251
+ /** Show the step list. Defaults to true. */
252
+ showSteps?: boolean;
253
+ /**
254
+ * A note shown next to the clock, or a function of the seconds elapsed, for a
255
+ * note that changes as the run goes on. It's read out when it changes, so
256
+ * don't put the seconds in it.
257
+ */
258
+ message?: ReactNode | ((seconds: number) => ReactNode);
259
+ className?: string;
260
+ }
261
+ /**
262
+ * A running run's steps and elapsed time. Renders nothing unless
263
+ * `run.status` is `"running"`.
264
+ */
265
+ declare function RunProgress({ run, showSteps, message, className }: RunProgressProps): react.JSX.Element | null;
266
+
239
267
  declare const DEFAULT_BASE_PATH = "/api/seclai";
240
268
  /**
241
269
  * The URLs of the `@seclai/handlers` routes. Build it with
@@ -443,4 +471,4 @@ interface MarkdownContentProps {
443
471
  */
444
472
  declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
445
473
 
446
- export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun };
474
+ export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, RunProgress, type RunProgressProps, type RunProgressRun, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun, useElapsed };
package/dist/index.d.ts CHANGED
@@ -236,6 +236,34 @@ interface SeclaiAgentProps extends AgentEndpointOptions {
236
236
  /** Boots the agent UI from its mode, and its agent id when the server hosts several. */
237
237
  declare function SeclaiAgent({ mode, basePath, agentId }: SeclaiAgentProps): react.JSX.Element;
238
238
 
239
+ /**
240
+ * Whole seconds since `startedAt` (a `Date.now()` value, such as `useAgentRun`'s
241
+ * `startedAt`), updated every second while `running`. It's 0 when `startedAt` is
242
+ * `null`, and on the first render, so server and client render the same markup;
243
+ * the real value follows in an effect. When `running` turns false it keeps its
244
+ * last value and stops the timer.
245
+ */
246
+ declare function useElapsed(startedAt: number | null, running: boolean): number;
247
+ /** The fields `RunProgress` reads. A `useAgentRun` result fits, as does a plain object. */
248
+ type RunProgressRun = Pick<AgentRunState, "status" | "steps" | "startedAt">;
249
+ interface RunProgressProps {
250
+ run: RunProgressRun;
251
+ /** Show the step list. Defaults to true. */
252
+ showSteps?: boolean;
253
+ /**
254
+ * A note shown next to the clock, or a function of the seconds elapsed, for a
255
+ * note that changes as the run goes on. It's read out when it changes, so
256
+ * don't put the seconds in it.
257
+ */
258
+ message?: ReactNode | ((seconds: number) => ReactNode);
259
+ className?: string;
260
+ }
261
+ /**
262
+ * A running run's steps and elapsed time. Renders nothing unless
263
+ * `run.status` is `"running"`.
264
+ */
265
+ declare function RunProgress({ run, showSteps, message, className }: RunProgressProps): react.JSX.Element | null;
266
+
239
267
  declare const DEFAULT_BASE_PATH = "/api/seclai";
240
268
  /**
241
269
  * The URLs of the `@seclai/handlers` routes. Build it with
@@ -443,4 +471,4 @@ interface MarkdownContentProps {
443
471
  */
444
472
  declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
445
473
 
446
- export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun };
474
+ export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, RunProgress, type RunProgressProps, type RunProgressRun, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun, useElapsed };
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@
3
3
  // src/AgentChat.tsx
4
4
  import {
5
5
  Fragment as Fragment4,
6
- useEffect as useEffect6,
6
+ useEffect as useEffect7,
7
7
  useMemo as useMemo2,
8
8
  useRef as useRef5,
9
- useState as useState5
9
+ useState as useState6
10
10
  } from "react";
11
11
 
12
12
  // src/attachments.ts
@@ -600,8 +600,80 @@ function MediaGallery({
600
600
  ] });
601
601
  }
602
602
 
603
+ // src/RunProgress.tsx
604
+ import { useEffect as useEffect5, useState as useState4 } from "react";
605
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
606
+ function useElapsed(startedAt, running) {
607
+ const [now, setNow] = useState4(null);
608
+ useEffect5(() => {
609
+ if (!running || startedAt === null) return;
610
+ let timer;
611
+ const tick = () => {
612
+ const time = Date.now();
613
+ setNow(time);
614
+ const into = ((time - startedAt) % 1e3 + 1e3) % 1e3;
615
+ timer = setTimeout(tick, 1e3 - into);
616
+ };
617
+ tick();
618
+ return () => clearTimeout(timer);
619
+ }, [running, startedAt]);
620
+ if (startedAt === null || now === null) return 0;
621
+ return Math.max(0, Math.floor((now - startedAt) / 1e3));
622
+ }
623
+ function formatClock(seconds) {
624
+ return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
625
+ }
626
+ function spokenDuration(seconds) {
627
+ const minutes = Math.floor(seconds / 60);
628
+ const rest = seconds % 60;
629
+ const unit = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
630
+ if (minutes === 0) return unit(rest, "second");
631
+ return rest === 0 ? unit(minutes, "minute") : `${unit(minutes, "minute")} ${unit(rest, "second")}`;
632
+ }
633
+ function RunProgress({ run, showSteps = true, message, className }) {
634
+ const running = run.status === "running";
635
+ const seconds = useElapsed(run.startedAt, running);
636
+ if (!running) return null;
637
+ const note = typeof message === "function" ? message(seconds) : message;
638
+ const last = run.steps.length - 1;
639
+ return /* @__PURE__ */ jsxs6(
640
+ "div",
641
+ {
642
+ className: className ? `seclai-run-progress ${className}` : "seclai-run-progress",
643
+ "aria-live": "polite",
644
+ children: [
645
+ showSteps && (run.steps.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "seclai-notice", children: "Starting the run\u2026" }) : /* @__PURE__ */ jsx6("ol", { className: "seclai-steps", children: run.steps.map((step, i) => /* @__PURE__ */ jsxs6("li", { children: [
646
+ /* @__PURE__ */ jsx6("span", { className: "seclai-step-marker", "aria-hidden": "true", children: i === last ? "\u25CF" : "\u2713" }),
647
+ /* @__PURE__ */ jsx6("span", { className: "seclai-sr-only", children: i === last ? "In progress: " : "Done: " }),
648
+ /* @__PURE__ */ jsxs6("span", { children: [
649
+ /* @__PURE__ */ jsx6("span", { className: "seclai-step-name", children: step.name }),
650
+ step.message && /* @__PURE__ */ jsxs6("span", { className: "seclai-step-message", children: [
651
+ " \xB7 ",
652
+ step.message
653
+ ] })
654
+ ] })
655
+ ] }, step.id)) })),
656
+ /* @__PURE__ */ jsxs6("div", { className: "seclai-run-progress-note", children: [
657
+ /* @__PURE__ */ jsx6("span", { className: "seclai-run-progress-pulse", "aria-hidden": "true" }),
658
+ note != null && note !== false && note !== "" && /* @__PURE__ */ jsx6("span", { className: "seclai-run-progress-message", children: note }),
659
+ /* @__PURE__ */ jsx6(
660
+ "span",
661
+ {
662
+ className: "seclai-run-progress-clock",
663
+ role: "timer",
664
+ "aria-live": "off",
665
+ "aria-label": `${spokenDuration(seconds)} elapsed`,
666
+ children: formatClock(seconds)
667
+ }
668
+ )
669
+ ] })
670
+ ]
671
+ }
672
+ );
673
+ }
674
+
603
675
  // src/useAgentRun.ts
604
- import { useCallback, useEffect as useEffect5, useMemo, useRef as useRef4, useState as useState4 } from "react";
676
+ import { useCallback, useEffect as useEffect6, useMemo, useRef as useRef4, useState as useState5 } from "react";
605
677
 
606
678
  // src/sse.ts
607
679
  function parseData(data) {
@@ -748,13 +820,13 @@ function applyEvent(state, { event, data }, endpoints) {
748
820
  function useAgentRun(options = {}) {
749
821
  const { basePath, agentId, onEvent } = options;
750
822
  const endpoints = useMemo(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
751
- const [state, setState] = useState4(IDLE);
823
+ const [state, setState] = useState5(IDLE);
752
824
  const active = useRef4(null);
753
825
  const onEventRef = useRef4(onEvent);
754
- useEffect5(() => {
826
+ useEffect6(() => {
755
827
  onEventRef.current = onEvent;
756
828
  });
757
- useEffect5(() => () => active.current?.abort(), []);
829
+ useEffect6(() => () => active.current?.abort(), []);
758
830
  const start = useCallback(
759
831
  async ({ input, uploadIds, sessionId }) => {
760
832
  active.current?.abort();
@@ -826,7 +898,7 @@ function useAgentRun(options = {}) {
826
898
  }
827
899
 
828
900
  // src/AgentChat.tsx
829
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
901
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
830
902
  function createSessionId() {
831
903
  if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
832
904
  return Array.from(
@@ -850,13 +922,13 @@ function plural(count, word) {
850
922
  }
851
923
  function FileChip({ name, tag, preview, status, error, onRemove }) {
852
924
  const meta = status === "uploading" ? "Uploading\u2026" : status === "error" ? error : tag;
853
- return /* @__PURE__ */ jsxs6("li", { className: "seclai-file", "data-status": status, children: [
854
- preview && /* @__PURE__ */ jsx6("img", { className: "seclai-file-thumb", src: preview, alt: "" }),
855
- /* @__PURE__ */ jsxs6("span", { className: "seclai-file-text", children: [
856
- /* @__PURE__ */ jsx6("span", { className: "seclai-file-name", title: name, children: name }),
857
- meta && /* @__PURE__ */ jsx6("span", { className: "seclai-file-meta", children: meta })
925
+ return /* @__PURE__ */ jsxs7("li", { className: "seclai-file", "data-status": status, children: [
926
+ preview && /* @__PURE__ */ jsx7("img", { className: "seclai-file-thumb", src: preview, alt: "" }),
927
+ /* @__PURE__ */ jsxs7("span", { className: "seclai-file-text", children: [
928
+ /* @__PURE__ */ jsx7("span", { className: "seclai-file-name", title: name, children: name }),
929
+ meta && /* @__PURE__ */ jsx7("span", { className: "seclai-file-meta", children: meta })
858
930
  ] }),
859
- onRemove && /* @__PURE__ */ jsx6(
931
+ onRemove && /* @__PURE__ */ jsx7(
860
932
  "button",
861
933
  {
862
934
  type: "button",
@@ -869,8 +941,8 @@ function FileChip({ name, tag, preview, status, error, onRemove }) {
869
941
  ] });
870
942
  }
871
943
  function UserTurn({ message, previews }) {
872
- return /* @__PURE__ */ jsxs6("li", { className: "seclai-turn seclai-turn-user", children: [
873
- message.files.length > 0 && /* @__PURE__ */ jsx6("ul", { className: "seclai-files", "aria-label": "Attached files", children: message.files.map((file) => /* @__PURE__ */ jsx6(
944
+ return /* @__PURE__ */ jsxs7("li", { className: "seclai-turn seclai-turn-user", children: [
945
+ message.files.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "seclai-files", "aria-label": "Attached files", children: message.files.map((file) => /* @__PURE__ */ jsx7(
874
946
  FileChip,
875
947
  {
876
948
  name: file.name,
@@ -879,14 +951,14 @@ function UserTurn({ message, previews }) {
879
951
  },
880
952
  file.uploadId
881
953
  )) }),
882
- message.input && /* @__PURE__ */ jsx6(MarkdownContent, { content: message.input })
954
+ message.input && /* @__PURE__ */ jsx7(MarkdownContent, { content: message.input })
883
955
  ] });
884
956
  }
885
957
  function AssistantTurn({ turn, endpoints }) {
886
958
  const { runId } = turn;
887
- return /* @__PURE__ */ jsxs6("li", { className: "seclai-turn seclai-turn-assistant", children: [
888
- turn.output && /* @__PURE__ */ jsx6(MarkdownContent, { content: turn.output }),
889
- runId && turn.attachments && turn.attachments.length > 0 && /* @__PURE__ */ jsx6(
959
+ return /* @__PURE__ */ jsxs7("li", { className: "seclai-turn seclai-turn-assistant", children: [
960
+ turn.output && /* @__PURE__ */ jsx7(MarkdownContent, { content: turn.output }),
961
+ runId && turn.attachments && turn.attachments.length > 0 && /* @__PURE__ */ jsx7(
890
962
  MediaGallery,
891
963
  {
892
964
  attachments: turn.attachments.map(({ id, name, mime, bytes }) => ({
@@ -898,8 +970,8 @@ function AssistantTurn({ turn, endpoints }) {
898
970
  }))
899
971
  }
900
972
  ),
901
- turn.error && /* @__PURE__ */ jsx6("p", { className: "seclai-error", role: "alert", children: turn.error }),
902
- turn.status === "cancelled" && /* @__PURE__ */ jsx6("p", { className: "seclai-notice", children: "Stopped." })
973
+ turn.error && /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: turn.error }),
974
+ turn.status === "cancelled" && /* @__PURE__ */ jsx7("p", { className: "seclai-notice", children: "Stopped." })
903
975
  ] });
904
976
  }
905
977
  function toTurnAttachment({ id, name, mime, bytes }) {
@@ -912,9 +984,9 @@ function AttachControl({
912
984
  disabled,
913
985
  onFiles
914
986
  }) {
915
- return /* @__PURE__ */ jsxs6("label", { className: "seclai-button seclai-attach", "aria-disabled": disabled || void 0, children: [
987
+ return /* @__PURE__ */ jsxs7("label", { className: "seclai-button seclai-attach", "aria-disabled": disabled || void 0, children: [
916
988
  label,
917
- /* @__PURE__ */ jsx6(
989
+ /* @__PURE__ */ jsx7(
918
990
  "input",
919
991
  {
920
992
  type: "file",
@@ -944,7 +1016,7 @@ function AgentChat({
944
1016
  const endpoints = useMemo2(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
945
1017
  const run = useAgentRun({ basePath, agentId });
946
1018
  const { slots } = useAcceptedAttachments(endpoints);
947
- const [transcript, setTranscript] = useState5(() => ({
1019
+ const [transcript, setTranscript] = useState6(() => ({
948
1020
  sessionId,
949
1021
  epoch: 0,
950
1022
  turns: initialTurns ?? [],
@@ -952,10 +1024,10 @@ function AgentChat({
952
1024
  generatedSessionId: null,
953
1025
  runEpoch: null
954
1026
  }));
955
- const [message, setMessage] = useState5("");
956
- const [files, setFiles] = useState5([]);
957
- const [notice, setNotice] = useState5(null);
958
- const [dragging, setDragging] = useState5(false);
1027
+ const [message, setMessage] = useState6("");
1028
+ const [files, setFiles] = useState6([]);
1029
+ const [notice, setNotice] = useState6(null);
1030
+ const [dragging, setDragging] = useState6(false);
959
1031
  const generatedSessionId = useRef5(null);
960
1032
  const shownEpoch = useRef5(transcript.epoch);
961
1033
  const turnComplete = useRef5(onTurnComplete);
@@ -974,10 +1046,10 @@ function AgentChat({
974
1046
  }
975
1047
  );
976
1048
  }
977
- useEffect6(() => {
1049
+ useEffect7(() => {
978
1050
  turnComplete.current = onTurnComplete;
979
1051
  });
980
- useEffect6(() => {
1052
+ useEffect7(() => {
981
1053
  if (shownEpoch.current === transcript.epoch) return;
982
1054
  shownEpoch.current = transcript.epoch;
983
1055
  run.cancel();
@@ -990,7 +1062,7 @@ function AgentChat({
990
1062
  setFiles([]);
991
1063
  setNotice(null);
992
1064
  }, [transcript.epoch, run.cancel]);
993
- useEffect6(
1065
+ useEffect7(
994
1066
  () => () => {
995
1067
  pendingPreviews.current.forEach(revoke);
996
1068
  sentPreviews.current.forEach(revoke);
@@ -1146,29 +1218,29 @@ function AgentChat({
1146
1218
  }
1147
1219
  } : {};
1148
1220
  const buttons = attachButtons?.length ? attachButtons : [{ label: "Attach" }];
1149
- return /* @__PURE__ */ jsxs6("div", { className: "seclai-agent seclai-chat", children: [
1150
- /* @__PURE__ */ jsxs6("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
1151
- transcript.turns.map((turn, i) => /* @__PURE__ */ jsxs6(Fragment4, { children: [
1152
- /* @__PURE__ */ jsx6(
1221
+ return /* @__PURE__ */ jsxs7("div", { className: "seclai-agent seclai-chat", children: [
1222
+ /* @__PURE__ */ jsxs7("ul", { className: "seclai-turns", "aria-live": "polite", "aria-busy": streaming, children: [
1223
+ transcript.turns.map((turn, i) => /* @__PURE__ */ jsxs7(Fragment4, { children: [
1224
+ /* @__PURE__ */ jsx7(
1153
1225
  UserTurn,
1154
1226
  {
1155
1227
  message: { input: turn.input, files: turn.files ?? [] },
1156
1228
  previews: sentPreviews.current
1157
1229
  }
1158
1230
  ),
1159
- /* @__PURE__ */ jsx6(AssistantTurn, { turn, endpoints })
1231
+ /* @__PURE__ */ jsx7(AssistantTurn, { turn, endpoints })
1160
1232
  ] }, `${transcript.epoch}:${i}`)),
1161
- transcript.pending && /* @__PURE__ */ jsx6(UserTurn, { message: transcript.pending, previews: sentPreviews.current }),
1162
- 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" }) })
1233
+ transcript.pending && /* @__PURE__ */ jsx7(UserTurn, { message: transcript.pending, previews: sentPreviews.current }),
1234
+ streaming && /* @__PURE__ */ jsx7("li", { className: "seclai-turn seclai-turn-assistant", children: run.text ? /* @__PURE__ */ jsx7(MarkdownContent, { content: run.text }) : /* @__PURE__ */ jsx7(RunProgress, { run }) })
1163
1235
  ] }),
1164
- /* @__PURE__ */ jsxs6(
1236
+ /* @__PURE__ */ jsxs7(
1165
1237
  "form",
1166
1238
  {
1167
1239
  className: dragging ? "seclai-form seclai-dropping" : "seclai-form",
1168
1240
  onSubmit,
1169
1241
  ...dropHandlers,
1170
1242
  children: [
1171
- files.length > 0 && /* @__PURE__ */ jsx6("ul", { className: "seclai-files", "aria-label": "Files to send", children: files.map((f) => /* @__PURE__ */ jsx6(
1243
+ files.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "seclai-files", "aria-label": "Files to send", children: files.map((f) => /* @__PURE__ */ jsx7(
1172
1244
  FileChip,
1173
1245
  {
1174
1246
  name: f.name,
@@ -1180,7 +1252,7 @@ function AgentChat({
1180
1252
  },
1181
1253
  f.localId
1182
1254
  )) }),
1183
- /* @__PURE__ */ jsx6(
1255
+ /* @__PURE__ */ jsx7(
1184
1256
  "textarea",
1185
1257
  {
1186
1258
  rows: 2,
@@ -1192,9 +1264,9 @@ function AgentChat({
1192
1264
  onPaste: acceptsFiles ? onPaste : void 0
1193
1265
  }
1194
1266
  ),
1195
- notice && /* @__PURE__ */ jsx6("p", { className: "seclai-error", role: "alert", children: notice }),
1196
- /* @__PURE__ */ jsxs6("div", { className: "seclai-actions", children: [
1197
- acceptsFiles && buttons.map((button) => /* @__PURE__ */ jsx6(
1267
+ notice && /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: notice }),
1268
+ /* @__PURE__ */ jsxs7("div", { className: "seclai-actions", children: [
1269
+ acceptsFiles && buttons.map((button) => /* @__PURE__ */ jsx7(
1198
1270
  AttachControl,
1199
1271
  {
1200
1272
  label: button.label,
@@ -1205,8 +1277,8 @@ function AgentChat({
1205
1277
  },
1206
1278
  `${button.label}\0${button.tag ?? ""}`
1207
1279
  )),
1208
- /* @__PURE__ */ jsx6("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: !canSend, children: "Send" }),
1209
- running && /* @__PURE__ */ jsx6("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1280
+ /* @__PURE__ */ jsx7("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: !canSend, children: "Send" }),
1281
+ running && /* @__PURE__ */ jsx7("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1210
1282
  ] })
1211
1283
  ]
1212
1284
  }
@@ -1215,8 +1287,8 @@ function AgentChat({
1215
1287
  }
1216
1288
 
1217
1289
  // src/AgentRunForm.tsx
1218
- import { useMemo as useMemo3, useState as useState6 } from "react";
1219
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1290
+ import { useMemo as useMemo3, useState as useState7 } from "react";
1291
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1220
1292
  function slotProblem(slot, count) {
1221
1293
  const label = slot.label ?? slot.name;
1222
1294
  const min = slot.min ?? 0;
@@ -1230,10 +1302,10 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1230
1302
  const endpoints = useMemo3(() => createEndpoints({ basePath, agentId }), [basePath, agentId]);
1231
1303
  const run = useAgentRun({ basePath, agentId });
1232
1304
  const { slots, error: loadError } = useAcceptedAttachments(endpoints);
1233
- const [input, setInput] = useState6("");
1234
- const [files, setFiles] = useState6({});
1235
- const [uploading, setUploading] = useState6(false);
1236
- const [formError, setFormError] = useState6(null);
1305
+ const [input, setInput] = useState7("");
1306
+ const [files, setFiles] = useState7({});
1307
+ const [uploading, setUploading] = useState7(false);
1308
+ const [formError, setFormError] = useState7(null);
1237
1309
  const selected = Object.values(files).flat();
1238
1310
  const busy = uploading || run.status === "running";
1239
1311
  async function submit(event) {
@@ -1267,30 +1339,30 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1267
1339
  onFinish?.(result);
1268
1340
  }
1269
1341
  if (loadError) {
1270
- return /* @__PURE__ */ jsx7("div", { className: "seclai-agent", children: /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: loadError }) });
1342
+ return /* @__PURE__ */ jsx8("div", { className: "seclai-agent", children: /* @__PURE__ */ jsx8("p", { className: "seclai-error", role: "alert", children: loadError }) });
1271
1343
  }
1272
1344
  if (!slots) {
1273
- return /* @__PURE__ */ jsxs7("div", { className: "seclai-agent", children: [
1274
- /* @__PURE__ */ jsx7("p", { className: "seclai-notice", children: "Loading\u2026" }),
1275
- /* @__PURE__ */ jsxs7("div", { className: "seclai-skeleton", "aria-hidden": "true", children: [
1276
- /* @__PURE__ */ jsx7("span", {}),
1277
- /* @__PURE__ */ jsx7("span", {})
1345
+ return /* @__PURE__ */ jsxs8("div", { className: "seclai-agent", children: [
1346
+ /* @__PURE__ */ jsx8("p", { className: "seclai-notice", children: "Loading\u2026" }),
1347
+ /* @__PURE__ */ jsxs8("div", { className: "seclai-skeleton", "aria-hidden": "true", children: [
1348
+ /* @__PURE__ */ jsx8("span", {}),
1349
+ /* @__PURE__ */ jsx8("span", {})
1278
1350
  ] })
1279
1351
  ] });
1280
1352
  }
1281
1353
  const error = formError ?? run.error;
1282
- return /* @__PURE__ */ jsxs7("div", { className: "seclai-agent", children: [
1283
- /* @__PURE__ */ jsxs7("form", { className: "seclai-form", onSubmit: submit, children: [
1284
- /* @__PURE__ */ jsxs7("label", { className: "seclai-field", children: [
1285
- /* @__PURE__ */ jsx7("span", { children: inputLabel }),
1286
- /* @__PURE__ */ jsx7("textarea", { rows: 4, value: input, onChange: (e) => setInput(e.target.value) })
1354
+ return /* @__PURE__ */ jsxs8("div", { className: "seclai-agent", children: [
1355
+ /* @__PURE__ */ jsxs8("form", { className: "seclai-form", onSubmit: submit, children: [
1356
+ /* @__PURE__ */ jsxs8("label", { className: "seclai-field", children: [
1357
+ /* @__PURE__ */ jsx8("span", { children: inputLabel }),
1358
+ /* @__PURE__ */ jsx8("textarea", { rows: 4, value: input, onChange: (e) => setInput(e.target.value) })
1287
1359
  ] }),
1288
- slots.map((slot) => /* @__PURE__ */ jsxs7("label", { className: "seclai-field", children: [
1289
- /* @__PURE__ */ jsxs7("span", { children: [
1360
+ slots.map((slot) => /* @__PURE__ */ jsxs8("label", { className: "seclai-field", children: [
1361
+ /* @__PURE__ */ jsxs8("span", { children: [
1290
1362
  slot.label ?? slot.name,
1291
1363
  (slot.min ?? 0) > 0 ? " (required)" : ""
1292
1364
  ] }),
1293
- /* @__PURE__ */ jsx7(
1365
+ /* @__PURE__ */ jsx8(
1294
1366
  "input",
1295
1367
  {
1296
1368
  type: "file",
@@ -1301,29 +1373,29 @@ function AgentRunForm({ basePath, agentId, inputLabel = "Input", onFinish }) {
1301
1373
  }
1302
1374
  )
1303
1375
  ] }, slot.name)),
1304
- /* @__PURE__ */ jsxs7("div", { className: "seclai-actions", children: [
1305
- /* @__PURE__ */ jsx7("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: busy, children: uploading ? "Uploading\u2026" : "Run" }),
1306
- run.status === "running" && /* @__PURE__ */ jsx7("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1376
+ /* @__PURE__ */ jsxs8("div", { className: "seclai-actions", children: [
1377
+ /* @__PURE__ */ jsx8("button", { type: "submit", className: "seclai-button seclai-button-primary", disabled: busy, children: uploading ? "Uploading\u2026" : "Run" }),
1378
+ run.status === "running" && /* @__PURE__ */ jsx8("button", { type: "button", className: "seclai-button", onClick: run.cancel, children: "Stop" })
1307
1379
  ] })
1308
1380
  ] }),
1309
- run.steps.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */ jsxs7("li", { children: [
1381
+ run.steps.length > 0 && /* @__PURE__ */ jsx8("ul", { className: "seclai-steps", children: run.steps.map((step) => /* @__PURE__ */ jsxs8("li", { children: [
1310
1382
  step.name,
1311
1383
  ": ",
1312
1384
  step.message
1313
1385
  ] }, step.id)) }),
1314
- error && /* @__PURE__ */ jsx7("p", { className: "seclai-error", role: "alert", children: error }),
1315
- run.status === "cancelled" && /* @__PURE__ */ jsx7("p", { className: "seclai-notice", children: "Stopped." }),
1316
- (run.text || run.attachments.length > 0) && /* @__PURE__ */ jsxs7("div", { className: "seclai-output", "aria-live": "polite", "aria-busy": run.status === "running", children: [
1317
- run.text && /* @__PURE__ */ jsx7(MarkdownContent, { content: run.text }),
1318
- run.attachments.length > 0 && /* @__PURE__ */ jsx7(MediaGallery, { attachments: run.attachments })
1386
+ error && /* @__PURE__ */ jsx8("p", { className: "seclai-error", role: "alert", children: error }),
1387
+ run.status === "cancelled" && /* @__PURE__ */ jsx8("p", { className: "seclai-notice", children: "Stopped." }),
1388
+ (run.text || run.attachments.length > 0) && /* @__PURE__ */ jsxs8("div", { className: "seclai-output", "aria-live": "polite", "aria-busy": run.status === "running", children: [
1389
+ run.text && /* @__PURE__ */ jsx8(MarkdownContent, { content: run.text }),
1390
+ run.attachments.length > 0 && /* @__PURE__ */ jsx8(MediaGallery, { attachments: run.attachments })
1319
1391
  ] })
1320
1392
  ] });
1321
1393
  }
1322
1394
 
1323
1395
  // src/SeclaiAgent.tsx
1324
- import { jsx as jsx8 } from "react/jsx-runtime";
1396
+ import { jsx as jsx9 } from "react/jsx-runtime";
1325
1397
  function SeclaiAgent({ mode, basePath, agentId }) {
1326
- return mode === "chat" ? /* @__PURE__ */ jsx8(AgentChat, { basePath, agentId }) : /* @__PURE__ */ jsx8(AgentRunForm, { basePath, agentId });
1398
+ return mode === "chat" ? /* @__PURE__ */ jsx9(AgentChat, { basePath, agentId }) : /* @__PURE__ */ jsx9(AgentRunForm, { basePath, agentId });
1327
1399
  }
1328
1400
  export {
1329
1401
  AgentChat,
@@ -1334,6 +1406,7 @@ export {
1334
1406
  MediaPreview,
1335
1407
  MediaSkeleton,
1336
1408
  MediaViewer,
1409
+ RunProgress,
1337
1410
  SeclaiAgent,
1338
1411
  attachmentFileName,
1339
1412
  createEndpoints,
@@ -1341,5 +1414,6 @@ export {
1341
1414
  saveFile,
1342
1415
  saveFiles,
1343
1416
  uploadFile,
1344
- useAgentRun
1417
+ useAgentRun,
1418
+ useElapsed
1345
1419
  };
package/dist/styles.css CHANGED
@@ -209,6 +209,59 @@
209
209
  color: var(--seclai-muted);
210
210
  }
211
211
 
212
+ .seclai-run-progress {
213
+ display: flex;
214
+ flex-direction: column;
215
+ gap: calc(var(--seclai-gap) / 2);
216
+ }
217
+
218
+ .seclai-run-progress .seclai-steps li {
219
+ display: flex;
220
+ gap: 8px;
221
+ }
222
+
223
+ .seclai-step-marker {
224
+ flex-shrink: 0;
225
+ color: var(--seclai-muted);
226
+ }
227
+
228
+ .seclai-steps li:last-child .seclai-step-marker {
229
+ color: var(--seclai-accent);
230
+ }
231
+
232
+ .seclai-step-name {
233
+ font-weight: 500;
234
+ }
235
+
236
+ .seclai-run-progress-note {
237
+ display: flex;
238
+ align-items: center;
239
+ gap: 8px;
240
+ padding: 8px 12px;
241
+ font-size: 0.875em;
242
+ color: var(--seclai-muted);
243
+ background: var(--seclai-surface);
244
+ border-radius: var(--seclai-radius);
245
+ }
246
+
247
+ .seclai-run-progress-pulse {
248
+ flex-shrink: 0;
249
+ width: 8px;
250
+ height: 8px;
251
+ background: var(--seclai-accent);
252
+ border-radius: 50%;
253
+ animation: seclai-pulse 1.6s ease-in-out infinite;
254
+ }
255
+
256
+ .seclai-run-progress-message {
257
+ flex: 1;
258
+ }
259
+
260
+ .seclai-run-progress-clock {
261
+ margin-inline-start: auto;
262
+ font-variant-numeric: tabular-nums;
263
+ }
264
+
212
265
  /* Output */
213
266
  .seclai-output,
214
267
  .seclai-turn {
@@ -252,8 +305,12 @@
252
305
  border-radius: var(--seclai-radius);
253
306
  }
254
307
 
255
- /* Hidden from view but not from the browser, so a wrapping label opens the picker. */
256
- .seclai-agent .seclai-sr-only {
308
+ /*
309
+ * Hidden from view but not from the browser or screen readers: a wrapping label
310
+ * still opens the picker, and step states are still read out.
311
+ */
312
+ .seclai-agent .seclai-sr-only,
313
+ .seclai-run-progress .seclai-sr-only {
257
314
  position: absolute;
258
315
  width: 1px;
259
316
  height: 1px;
@@ -800,7 +857,8 @@ button.seclai-media-frame:focus-visible {
800
857
  transform: none;
801
858
  }
802
859
 
803
- .seclai-skeleton > span {
860
+ .seclai-skeleton > span,
861
+ .seclai-run-progress-pulse {
804
862
  animation: none;
805
863
  }
806
864
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seclai/react",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "React components and hooks for running Seclai agents: run form, chat, and streaming output.",
5
5
  "license": "MIT",
6
6
  "type": "module",