reifyui 0.13.9 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -15,6 +15,9 @@ export interface ResponseHandlers {
15
15
  onCreated?(responseId: string): void;
16
16
  /** The server-side session id, for continuing this conversation on the next turn. */
17
17
  onSession?(sessionId: string): void;
18
+ /** Every event whole, as it arrives (streamTurn passes it; ChatPanel's agent view folds it into
19
+ * the turn's clock). */
20
+ onEvent?(event: { type: string; [k: string]: unknown }): void;
18
21
  onReasoningDelta?(text: string): void;
19
22
  onTextDelta?(text: string): void;
20
23
  onToolCall?(name: string, args: string, callId: string): void;
@@ -300,6 +303,14 @@ export interface ChatPanelProps {
300
303
  toolLabels?: Record<string, string>;
301
304
  /** The panel's placement in YOUR layout. Everything it paints inside is the package's. */
302
305
  classNames?: { root?: string };
306
+ /** 'agent' draws each turn with reifyui/agent-chat's AgentTurnView (needs styles/agent-chat.css). */
307
+ view?: 'messages' | 'agent';
308
+ /** The agent view's live-line mark: the harness's logo, as a node. */
309
+ mark?: ReactNode;
310
+ /** The mark's motion (reifyui/agent-chat motionFor(base)). */
311
+ motion?: string;
312
+ /** Overrides for the agent view's words (reifyui/agent-chat DEFAULT_AGENT_LABELS). */
313
+ agentLabels?: Record<string, unknown>;
303
314
  }
304
315
  export const ChatPanel: ComponentType<ChatPanelProps>;
305
316
 
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ import {
2
+ AgentTurnView,
3
+ newTurn,
4
+ reduceTurn,
5
+ turnFromMessage
6
+ } from "./chunk-6CJPYMR2.js";
1
7
  import {
2
8
  createResponsesDispatcher,
3
9
  pumpResponsesStream,
@@ -14,8 +20,11 @@ import {
14
20
  sheetToDelimited
15
21
  } from "./chunk-G34T6ZLN.js";
16
22
  import {
17
- Chevron,
18
23
  CodeBlock,
24
+ Modal
25
+ } from "./chunk-AGSX5YKH.js";
26
+ import {
27
+ Chevron,
19
28
  IcCheck,
20
29
  IcDoc,
21
30
  IcDownload,
@@ -35,9 +44,8 @@ import {
35
44
  IcThink,
36
45
  IcTool,
37
46
  IcX,
38
- Modal,
39
47
  Svg
40
- } from "./chunk-J7SECRIG.js";
48
+ } from "./chunk-WAND7AYD.js";
41
49
  import {
42
50
  useOverlayEscape
43
51
  } from "./chunk-J633KV57.js";
@@ -721,6 +729,21 @@ var PANEL_STATUS_LABELS = {
721
729
  cancelled: "Stopped",
722
730
  incomplete: "The turn hit its limit. Send a follow up to continue."
723
731
  };
732
+ function pairTurns(messages) {
733
+ const out = [];
734
+ let user = null;
735
+ for (const m of messages) {
736
+ if (m.role === "user") {
737
+ if (user) out.push({ user, asst: null });
738
+ user = m;
739
+ } else {
740
+ out.push({ user, asst: m });
741
+ user = null;
742
+ }
743
+ }
744
+ if (user) out.push({ user, asst: null });
745
+ return out;
746
+ }
724
747
  function ChatPanel(props) {
725
748
  const {
726
749
  sessionId,
@@ -748,8 +771,17 @@ function ChatPanel(props) {
748
771
  renderMarkdown,
749
772
  userExtras,
750
773
  toolLabels,
751
- classNames = {}
774
+ classNames = {},
775
+ // view="agent" draws each turn with reifyui/agent-chat's AgentTurnView (the live line with the
776
+ // harness's mark, work folded per run of calls, every call openable) instead of ChatMessages.
777
+ // Needs styles/agent-chat.css too. `mark` (a node: the harness's logo) and `motion` (see
778
+ // motionFor) dress the live line; `agentLabels` overrides its words.
779
+ view = "messages",
780
+ mark,
781
+ motion,
782
+ agentLabels
752
783
  } = props;
784
+ const agentView = view === "agent";
753
785
  const [messages, setMessages] = useState3([]);
754
786
  const [draft, setDraft] = useState3("");
755
787
  const [busy, setBusy] = useState3(false);
@@ -795,13 +827,14 @@ function ChatPanel(props) {
795
827
  }, [messages, connecting, histLoading]);
796
828
  const deliver = useCallback(async (text, files = []) => {
797
829
  setBusy(true);
798
- setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running" }]);
830
+ setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running", clock: newTurn({ startedAt: Date.now() }) }]);
799
831
  try {
800
832
  const out = await api.current.runTurn({
801
833
  sessionId,
802
834
  text,
803
835
  attachments: files,
804
836
  handlers: {
837
+ onEvent: (ev) => updateLastAsst((a) => ({ ...a, clock: reduceTurn(a.clock || newTurn(), ev, Date.now()) })),
805
838
  onSession: (sid) => {
806
839
  if (sid && sid !== sessionId) adoptedRef.current = sid;
807
840
  api.current.onSessionStarted?.(sid);
@@ -1034,7 +1067,18 @@ function ChatPanel(props) {
1034
1067
  dropped ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: workingLabel }) : null
1035
1068
  ] }),
1036
1069
  /* @__PURE__ */ jsxs5("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
1037
- histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx5(
1070
+ histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : agentView ? /* @__PURE__ */ jsx5("div", { className: "uic-chat-turns", children: pairTurns(messages).map(({ user, asst }, i) => /* @__PURE__ */ jsx5(
1071
+ AgentTurnView,
1072
+ {
1073
+ mark,
1074
+ motion,
1075
+ labels: agentLabels,
1076
+ renderMarkdown,
1077
+ turn: asst ? turnFromMessage(asst, asst.clock || null, user ? { text: user.text, files: (user.files || []).map((n) => ({ name: n })) } : null) : turnFromMessage({ status: "done", blocks: [] }, null, user ? { text: user.text, files: (user.files || []).map((n) => ({ name: n })) } : null),
1078
+ userExtra: user ? userExtras?.(user, i) : void 0
1079
+ },
1080
+ i
1081
+ )) }) : /* @__PURE__ */ jsx5(
1038
1082
  ChatMessages,
1039
1083
  {
1040
1084
  messages,