reifyui 0.14.0 → 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/agent-chat.js +47 -1842
- package/dist/agent-chat.js.map +1 -1
- package/dist/chunk-6CJPYMR2.js +1892 -0
- package/dist/chunk-6CJPYMR2.js.map +1 -0
- package/dist/harness.cjs +4 -0
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.js +4 -0
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +2269 -741
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +45 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatPanel.jsx +37 -1
- package/src/harness/index.js +3 -1
- package/src/index.d.ts +11 -0
- package/styles/chat.css +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reifyui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -36,6 +36,8 @@ import { Chip } from './Chip.jsx';
|
|
|
36
36
|
import { IcMic, IcPanelRight, IcPaperclip, IcSend } from './icons.jsx';
|
|
37
37
|
import { withReasoning, withResult, withStep, withText } from '../state/blocks.js';
|
|
38
38
|
import { bytesLabel } from '../format.js';
|
|
39
|
+
import { newTurn, reduceTurn, turnFromMessage } from '../agent-chat/turn.js';
|
|
40
|
+
import { AgentTurnView } from '../agent-chat/components.jsx';
|
|
39
41
|
|
|
40
42
|
// Not props. Every one of the four copies used these exact numbers, so there is nothing to
|
|
41
43
|
// configure — a knob nobody turns is a knob that only makes the call sites longer.
|
|
@@ -52,6 +54,18 @@ const PANEL_STATUS_LABELS = {
|
|
|
52
54
|
incomplete: 'The turn hit its limit. Send a follow up to continue.',
|
|
53
55
|
};
|
|
54
56
|
|
|
57
|
+
/** Messages as turns: each answer with the message it answers. */
|
|
58
|
+
function pairTurns(messages) {
|
|
59
|
+
const out = [];
|
|
60
|
+
let user = null;
|
|
61
|
+
for (const m of messages) {
|
|
62
|
+
if (m.role === 'user') { if (user) out.push({ user, asst: null }); user = m; }
|
|
63
|
+
else { out.push({ user, asst: m }); user = null; }
|
|
64
|
+
}
|
|
65
|
+
if (user) out.push({ user, asst: null });
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
55
69
|
export function ChatPanel(props) {
|
|
56
70
|
const {
|
|
57
71
|
sessionId,
|
|
@@ -85,7 +99,16 @@ export function ChatPanel(props) {
|
|
|
85
99
|
userExtras,
|
|
86
100
|
toolLabels,
|
|
87
101
|
classNames = {},
|
|
102
|
+
// view="agent" draws each turn with reifyui/agent-chat's AgentTurnView (the live line with the
|
|
103
|
+
// harness's mark, work folded per run of calls, every call openable) instead of ChatMessages.
|
|
104
|
+
// Needs styles/agent-chat.css too. `mark` (a node: the harness's logo) and `motion` (see
|
|
105
|
+
// motionFor) dress the live line; `agentLabels` overrides its words.
|
|
106
|
+
view = 'messages',
|
|
107
|
+
mark,
|
|
108
|
+
motion,
|
|
109
|
+
agentLabels,
|
|
88
110
|
} = props;
|
|
111
|
+
const agentView = view === 'agent';
|
|
89
112
|
|
|
90
113
|
const [messages, setMessages] = useState([]);
|
|
91
114
|
const [draft, setDraft] = useState('');
|
|
@@ -150,13 +173,16 @@ export function ChatPanel(props) {
|
|
|
150
173
|
// ── running a turn ────────────────────────────────────────────────────────
|
|
151
174
|
const deliver = useCallback(async (text, files = []) => {
|
|
152
175
|
setBusy(true);
|
|
153
|
-
|
|
176
|
+
// the turn's clock: every event folded in as it arrives (transports that pass onEvent), so the
|
|
177
|
+
// agent view can say when each call started and answered; never set for a replayed history
|
|
178
|
+
setMessages((m) => [...m, { role: 'assistant', blocks: [], status: 'running', clock: newTurn({ startedAt: Date.now() }) }]);
|
|
154
179
|
try {
|
|
155
180
|
const out = await api.current.runTurn({
|
|
156
181
|
sessionId,
|
|
157
182
|
text,
|
|
158
183
|
attachments: files,
|
|
159
184
|
handlers: {
|
|
185
|
+
onEvent: (ev) => updateLastAsst((a) => ({ ...a, clock: reduceTurn(a.clock || newTurn(), ev, Date.now()) })),
|
|
160
186
|
onSession: (sid) => {
|
|
161
187
|
// Arm the adopt guard only when the id is genuinely CHANGING: a session reporting
|
|
162
188
|
// the id it already has is not a rename and must not suppress a later reload.
|
|
@@ -421,6 +447,16 @@ export function ChatPanel(props) {
|
|
|
421
447
|
{histLoading ? <ChatMessagesSkeleton />
|
|
422
448
|
: empty && externalBusy ? (busyState === undefined ? defaultBusyState : busyState)
|
|
423
449
|
: empty ? emptyState
|
|
450
|
+
: agentView ? (
|
|
451
|
+
<div className="uic-chat-turns">
|
|
452
|
+
{pairTurns(messages).map(({ user, asst }, i) => (
|
|
453
|
+
<AgentTurnView key={i} mark={mark} motion={motion} labels={agentLabels} renderMarkdown={renderMarkdown}
|
|
454
|
+
turn={asst ? turnFromMessage(asst, asst.clock || null, user ? { text: user.text, files: (user.files || []).map((n) => ({ name: n })) } : null)
|
|
455
|
+
: turnFromMessage({ status: 'done', blocks: [] }, null, user ? { text: user.text, files: (user.files || []).map((n) => ({ name: n })) } : null)}
|
|
456
|
+
userExtra={user ? userExtras?.(user, i) : undefined} />
|
|
457
|
+
))}
|
|
458
|
+
</div>
|
|
459
|
+
)
|
|
424
460
|
: (
|
|
425
461
|
<ChatMessages
|
|
426
462
|
messages={messages}
|
package/src/harness/index.js
CHANGED
|
@@ -190,7 +190,7 @@ function sessionIdOf(evt) {
|
|
|
190
190
|
* person's own sentence instead of our scaffolding.
|
|
191
191
|
*
|
|
192
192
|
* handlers: the ReifyUI dispatcher's (onTextDelta, onReasoningDelta, onToolCall, onToolResult,
|
|
193
|
-
* onDone, onError) plus onSession(sessionId).
|
|
193
|
+
* onDone, onError) plus onSession(sessionId) and onEvent(event), every event whole as it arrives.
|
|
194
194
|
*
|
|
195
195
|
* Returns {ok, sessionId}, or {connecting:true} when the gateway is still coming up (503).
|
|
196
196
|
*/
|
|
@@ -236,6 +236,8 @@ export async function streamTurn({ sessionId, harnessId, input, instructions, ha
|
|
|
236
236
|
try { evt = JSON.parse(data); } catch { return; } // malformed frame
|
|
237
237
|
const found = sessionIdOf(evt);
|
|
238
238
|
if (found && found !== sid) { sid = found; handlers.onSession?.(found); }
|
|
239
|
+
// every event, whole, as it arrives (reifyui/agent-chat folds these into the turn's clock)
|
|
240
|
+
try { handlers.onEvent?.(evt); } catch { /* a view's clock must never break the stream */ }
|
|
239
241
|
d.dispatch(evt);
|
|
240
242
|
});
|
|
241
243
|
} catch {
|
package/src/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/styles/chat.css
CHANGED
|
@@ -362,3 +362,8 @@ body.uic-resizing iframe { pointer-events: none; }
|
|
|
362
362
|
buttons centered on the grown box, which is the common chat-input behavior. */
|
|
363
363
|
.uic-composer-line { display: flex; align-items: center; gap: 8px; }
|
|
364
364
|
.uic-composer-line textarea { flex: 1; min-width: 0; }
|
|
365
|
+
|
|
366
|
+
/* ChatPanel view="agent": the turns of reifyui/agent-chat (its own styles: agent-chat.css) */
|
|
367
|
+
.uic-chat-turns { display: flex; flex-direction: column; gap: 22px; }
|
|
368
|
+
.uic-chat .uac-user-b { font-size: 13.5px; }
|
|
369
|
+
.uic-chat .uac-md { font-size: 13.5px; }
|