reifyui 0.14.0 → 0.15.1
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/agent-chat.cjs +6 -2
- package/dist/agent-chat.cjs.map +1 -1
- package/dist/agent-chat.js +47 -1842
- package/dist/agent-chat.js.map +1 -1
- package/dist/{chunk-NTIWFHR4.js → chunk-KJY3FVGZ.js} +8 -3
- package/dist/chunk-KJY3FVGZ.js.map +1 -0
- package/dist/chunk-S46J7CLH.js +1896 -0
- package/dist/chunk-S46J7CLH.js.map +1 -0
- package/dist/harness.cjs +11 -2
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.js +5 -1
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +2286 -748
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +52 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agent-chat/tools.js +5 -1
- package/src/agent-chat/turn.js +2 -1
- package/src/components/ChatPanel.jsx +38 -2
- package/src/components/ToolSteps.jsx +3 -2
- package/src/harness/index.js +3 -1
- package/src/index.d.ts +13 -1
- package/src/state/blocks.js +4 -3
- package/src/state/turns.js +3 -1
- package/src/stream/responses.js +3 -2
- package/styles/chat.css +8 -0
- package/dist/chunk-NTIWFHR4.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,14 @@ 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;
|
|
21
|
-
|
|
24
|
+
/** isError: the result item said the tool failed (`is_error: true`). */
|
|
25
|
+
onToolResult?(callId: string, output: string, isError?: boolean): void;
|
|
22
26
|
onFile?(file: { container_id: string; file_id: string; filename: string }): void;
|
|
23
27
|
/** Terminal event. `status` distinguishes completed / incomplete / failed (incl. cancels). */
|
|
24
28
|
onDone?(status: string, response: unknown): void;
|
|
@@ -300,6 +304,14 @@ export interface ChatPanelProps {
|
|
|
300
304
|
toolLabels?: Record<string, string>;
|
|
301
305
|
/** The panel's placement in YOUR layout. Everything it paints inside is the package's. */
|
|
302
306
|
classNames?: { root?: string };
|
|
307
|
+
/** 'agent' draws each turn with reifyui/agent-chat's AgentTurnView (needs styles/agent-chat.css). */
|
|
308
|
+
view?: 'messages' | 'agent';
|
|
309
|
+
/** The agent view's live-line mark: the harness's logo, as a node. */
|
|
310
|
+
mark?: ReactNode;
|
|
311
|
+
/** The mark's motion (reifyui/agent-chat motionFor(base)). */
|
|
312
|
+
motion?: string;
|
|
313
|
+
/** Overrides for the agent view's words (reifyui/agent-chat DEFAULT_AGENT_LABELS). */
|
|
314
|
+
agentLabels?: Record<string, unknown>;
|
|
303
315
|
}
|
|
304
316
|
export const ChatPanel: ComponentType<ChatPanelProps>;
|
|
305
317
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentTurnView,
|
|
3
|
+
newTurn,
|
|
4
|
+
reduceTurn,
|
|
5
|
+
turnFromMessage
|
|
6
|
+
} from "./chunk-S46J7CLH.js";
|
|
1
7
|
import {
|
|
2
8
|
createResponsesDispatcher,
|
|
3
9
|
pumpResponsesStream,
|
|
4
10
|
readSSEStream,
|
|
5
11
|
turnsToMessages
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KJY3FVGZ.js";
|
|
7
13
|
import {
|
|
8
14
|
MentionInput,
|
|
9
15
|
MentionText,
|
|
@@ -68,8 +74,8 @@ function withStep(blocks, step) {
|
|
|
68
74
|
else out.push({ kind: "tools", reasoning: "", steps: [step] });
|
|
69
75
|
return out;
|
|
70
76
|
}
|
|
71
|
-
function withResult(blocks, callId, output) {
|
|
72
|
-
return blocks.map((b) => b.kind !== "tools" ? b : { ...b, steps: b.steps.map((t) => t.callId && t.callId === callId && t.result === void 0 ? { ...t, result: output } : t) });
|
|
77
|
+
function withResult(blocks, callId, output, isError = false) {
|
|
78
|
+
return blocks.map((b) => b.kind !== "tools" ? b : { ...b, steps: b.steps.map((t) => t.callId && t.callId === callId && t.result === void 0 ? { ...t, result: output, ...isError ? { isError: true } : {} } : t) });
|
|
73
79
|
}
|
|
74
80
|
function asstText(a) {
|
|
75
81
|
return a.blocks.filter((b) => b.kind === "text").map((b) => b.text).join("\n\n");
|
|
@@ -320,17 +326,18 @@ function ToolGroup(props) {
|
|
|
320
326
|
] });
|
|
321
327
|
}
|
|
322
328
|
function ToolRow(props) {
|
|
323
|
-
const { step, requestLabel = "Request", resultLabel = "Result" } = props;
|
|
329
|
+
const { step, requestLabel = "Request", resultLabel = "Result", failedLabel = "Failed" } = props;
|
|
324
330
|
const [open, setOpen] = useState(false);
|
|
325
331
|
const meta = toolMeta(step.name, step.args);
|
|
326
332
|
const Icon = meta.Icon;
|
|
327
333
|
const hasDetail = !!(step.args && step.args !== "{}") || step.result !== void 0;
|
|
328
|
-
return /* @__PURE__ */ jsxs("div", { className: "wbx-act", children: [
|
|
334
|
+
return /* @__PURE__ */ jsxs("div", { className: "wbx-act" + (step.isError ? " is-failed" : ""), children: [
|
|
329
335
|
/* @__PURE__ */ jsx("span", { className: "wbx-act-ic-t", children: /* @__PURE__ */ jsx(Icon, {}) }),
|
|
330
336
|
/* @__PURE__ */ jsxs("div", { className: "wbx-act-main", children: [
|
|
331
337
|
/* @__PURE__ */ jsxs("button", { className: "wbx-act-row" + (open ? " open" : ""), disabled: !hasDetail, onClick: () => setOpen((v) => !v), children: [
|
|
332
338
|
/* @__PURE__ */ jsx("span", { className: "wbx-act-k", children: meta.label }),
|
|
333
339
|
meta.chip && /* @__PURE__ */ jsx("span", { className: "wbx-act-chip", children: meta.chip }),
|
|
340
|
+
step.isError && /* @__PURE__ */ jsx("span", { className: "wbx-act-failed", children: failedLabel }),
|
|
334
341
|
hasDetail && /* @__PURE__ */ jsx("span", { className: "wbx-act-exp", children: /* @__PURE__ */ jsx(Chevron, { dir: open ? "down" : "right", size: 12 }) })
|
|
335
342
|
] }),
|
|
336
343
|
open && /* @__PURE__ */ jsxs("div", { className: "wbx-act-detail", children: [
|
|
@@ -723,6 +730,21 @@ var PANEL_STATUS_LABELS = {
|
|
|
723
730
|
cancelled: "Stopped",
|
|
724
731
|
incomplete: "The turn hit its limit. Send a follow up to continue."
|
|
725
732
|
};
|
|
733
|
+
function pairTurns(messages) {
|
|
734
|
+
const out = [];
|
|
735
|
+
let user = null;
|
|
736
|
+
for (const m of messages) {
|
|
737
|
+
if (m.role === "user") {
|
|
738
|
+
if (user) out.push({ user, asst: null });
|
|
739
|
+
user = m;
|
|
740
|
+
} else {
|
|
741
|
+
out.push({ user, asst: m });
|
|
742
|
+
user = null;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (user) out.push({ user, asst: null });
|
|
746
|
+
return out;
|
|
747
|
+
}
|
|
726
748
|
function ChatPanel(props) {
|
|
727
749
|
const {
|
|
728
750
|
sessionId,
|
|
@@ -750,8 +772,17 @@ function ChatPanel(props) {
|
|
|
750
772
|
renderMarkdown,
|
|
751
773
|
userExtras,
|
|
752
774
|
toolLabels,
|
|
753
|
-
classNames = {}
|
|
775
|
+
classNames = {},
|
|
776
|
+
// view="agent" draws each turn with reifyui/agent-chat's AgentTurnView (the live line with the
|
|
777
|
+
// harness's mark, work folded per run of calls, every call openable) instead of ChatMessages.
|
|
778
|
+
// Needs styles/agent-chat.css too. `mark` (a node: the harness's logo) and `motion` (see
|
|
779
|
+
// motionFor) dress the live line; `agentLabels` overrides its words.
|
|
780
|
+
view = "messages",
|
|
781
|
+
mark,
|
|
782
|
+
motion,
|
|
783
|
+
agentLabels
|
|
754
784
|
} = props;
|
|
785
|
+
const agentView = view === "agent";
|
|
755
786
|
const [messages, setMessages] = useState3([]);
|
|
756
787
|
const [draft, setDraft] = useState3("");
|
|
757
788
|
const [busy, setBusy] = useState3(false);
|
|
@@ -797,20 +828,21 @@ function ChatPanel(props) {
|
|
|
797
828
|
}, [messages, connecting, histLoading]);
|
|
798
829
|
const deliver = useCallback(async (text, files = []) => {
|
|
799
830
|
setBusy(true);
|
|
800
|
-
setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running" }]);
|
|
831
|
+
setMessages((m) => [...m, { role: "assistant", blocks: [], status: "running", clock: newTurn({ startedAt: Date.now() }) }]);
|
|
801
832
|
try {
|
|
802
833
|
const out = await api.current.runTurn({
|
|
803
834
|
sessionId,
|
|
804
835
|
text,
|
|
805
836
|
attachments: files,
|
|
806
837
|
handlers: {
|
|
838
|
+
onEvent: (ev) => updateLastAsst((a) => ({ ...a, clock: reduceTurn(a.clock || newTurn(), ev, Date.now()) })),
|
|
807
839
|
onSession: (sid) => {
|
|
808
840
|
if (sid && sid !== sessionId) adoptedRef.current = sid;
|
|
809
841
|
api.current.onSessionStarted?.(sid);
|
|
810
842
|
},
|
|
811
843
|
onReasoningDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withReasoning(a.blocks, d) })),
|
|
812
844
|
onToolCall: (name, args, callId) => updateLastAsst((a) => ({ ...a, blocks: withStep(a.blocks, { name, args, callId }) })),
|
|
813
|
-
onToolResult: (callId, output) => updateLastAsst((a) => ({ ...a, blocks: withResult(a.blocks, callId, output) })),
|
|
845
|
+
onToolResult: (callId, output, isError) => updateLastAsst((a) => ({ ...a, blocks: withResult(a.blocks, callId, output, isError) })),
|
|
814
846
|
onTextDelta: (d) => updateLastAsst((a) => ({ ...a, blocks: withText(a.blocks, d) })),
|
|
815
847
|
onDone: (status) => updateLastAsst((a) => ({ ...a, status: status === "completed" ? "done" : status })),
|
|
816
848
|
onError: () => updateLastAsst((a) => ({
|
|
@@ -1036,7 +1068,18 @@ function ChatPanel(props) {
|
|
|
1036
1068
|
dropped ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: workingLabel }) : null
|
|
1037
1069
|
] }),
|
|
1038
1070
|
/* @__PURE__ */ jsxs5("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
|
|
1039
|
-
histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx5(
|
|
1071
|
+
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(
|
|
1072
|
+
AgentTurnView,
|
|
1073
|
+
{
|
|
1074
|
+
mark,
|
|
1075
|
+
motion,
|
|
1076
|
+
labels: agentLabels,
|
|
1077
|
+
renderMarkdown,
|
|
1078
|
+
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),
|
|
1079
|
+
userExtra: user ? userExtras?.(user, i) : void 0
|
|
1080
|
+
},
|
|
1081
|
+
i
|
|
1082
|
+
)) }) : /* @__PURE__ */ jsx5(
|
|
1040
1083
|
ChatMessages,
|
|
1041
1084
|
{
|
|
1042
1085
|
messages,
|