reifyui 0.2.0 → 0.4.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/README.md CHANGED
@@ -14,7 +14,7 @@ _Reify_ — to make the abstract concrete. ReifyUI reifies an agent's intent int
14
14
  npm install reifyui
15
15
  ```
16
16
 
17
- > **Status: v0.2, early.** ReifyUI is an open foundation, not a finished platform. This first
17
+ > **Status: v0.4, early.** ReifyUI is an open foundation, not a finished platform. This first
18
18
  > release line ships the rendering-and-interaction core described under **Today** below. The larger
19
19
  > vision — a component registry, agent-driven composition, and protocol interop — is on the
20
20
  > **Roadmap**, stated plainly so you can tell what runs now from what's coming. We don't ship
@@ -54,7 +54,8 @@ A production-grade surface for rendering and interacting with a live agent turn:
54
54
  | **Chat surface** | `ChatMessages`, `UserTurn`, `AssistantTurn`, `ToolGroup`, `ToolRow`, `Composer` — message list + a collapsible "ran 5 commands, wrote a file" tool-step timeline |
55
55
  | **Rich blocks** | `CodeBlock` (highlight.js + mermaid + charts), `useResizablePane`, `PaneResizer` |
56
56
  | **Task list** | `TaskList`, `taskStatusGroup` — the master list beside a conversation: live status, filtering, cursor pagination. Transport-agnostic: you supply `fetchPage(cursor)` |
57
- | **Slides** | a slide renderer/editor + `reifyui/styles/slides.css` |
57
+ | **Dialogs** | `DialogHost`, `useDialog` — awaited in-app `alert` / `confirm` / `prompt`, so a destructive tool call or a "name this" step never falls back to a browser popup |
58
+ | **Slides** (`reifyui/slides`) | `SlideView`, `SlideStage`, `EditorCanvas`, `Presentation`, `ElementView`, `themeVars` — render a JSON deck, edit it by direct manipulation, present it |
58
59
  | **Spreadsheet** | `SheetGrid`, `sheetToDelimited`, `sheetToAoA` — an AI-editable grid |
59
60
  | **Icons / tool meta** | `Ic*` icon set, `toolMeta`, `humanize`, `summarizeSteps` |
60
61
  | **Auth (optional)** | `configureAuth`, `login`, `AuthForm`, `GoogleButton` — a thin JWT client for products with a `/v1/auth`-style backend; wired to nothing by default |
@@ -87,29 +88,43 @@ Render a live agent turn from a Server-Sent-Events response:
87
88
 
88
89
  ```jsx
89
90
  import { useState } from 'react';
90
- import { ChatMessages, Composer, createConversationStore, pumpResponsesStream } from 'reifyui';
91
+ import { ChatMessages, Composer, pumpResponsesStream } from 'reifyui';
91
92
  import 'reifyui/styles/chat.css';
92
93
  import 'reifyui/styles/themes/light.css'; // or themes/dark.css
93
94
 
94
- const store = createConversationStore();
95
-
95
+ // You own the conversation array. ReifyUI renders it — text, reasoning, and a collapsible
96
+ // tool-step timeline — and never decides how you fetch or where your state lives.
96
97
  export function Chat({ endpoint }) {
97
- const [, force] = useState(0);
98
- store.subscribe(() => force((n) => n + 1));
98
+ const [messages, setMessages] = useState([]);
99
+ const [busy, setBusy] = useState(false);
100
+
101
+ const amendLast = (patch) =>
102
+ setMessages((m) => m.map((x, i) => (i === m.length - 1 ? { ...x, ...patch(x) } : x)));
99
103
 
100
104
  async function send(text) {
105
+ setMessages((m) => [...m, { role: 'user', text }, { role: 'assistant', text: '', steps: [] }]);
106
+ setBusy(true);
101
107
  const res = await fetch(endpoint, {
102
108
  method: 'POST',
103
109
  headers: { 'content-type': 'application/json' },
104
110
  body: JSON.stringify({ input: text, stream: true }),
105
111
  });
106
- await pumpResponsesStream({ response: res, store });
112
+ await pumpResponsesStream(res.body, {
113
+ onTextDelta: (d) => amendLast((x) => ({ text: x.text + d })),
114
+ onReasoningDelta: (d) => amendLast((x) => ({ reasoning: (x.reasoning || '') + d })),
115
+ onToolCall: (name, args, callId) =>
116
+ amendLast((x) => ({ steps: [...x.steps, { name, args, callId }] })),
117
+ onToolResult: (callId, output) =>
118
+ amendLast((x) => ({ steps: x.steps.map((s) => (s.callId === callId ? { ...s, output } : s)) })),
119
+ onDone: () => setBusy(false),
120
+ onError: () => setBusy(false),
121
+ });
107
122
  }
108
123
 
109
124
  return (
110
125
  <>
111
- <ChatMessages store={store} />
112
- <Composer onSend={send} placeholder="Ask anything…" />
126
+ <ChatMessages messages={messages} workingLabel={busy ? 'Working…' : undefined} />
127
+ <Composer onSend={send} disabled={busy} />
113
128
  </>
114
129
  );
115
130
  }
@@ -130,11 +145,47 @@ import 'reifyui/styles/themes/dark.css'; // dark theme variables
130
145
  import 'reifyui/styles/slides.css'; // slides
131
146
  import 'reifyui/styles/sheet.css'; // spreadsheet grid
132
147
  import 'reifyui/styles/tasks.css'; // task list
148
+ import 'reifyui/styles/dialog.css'; // alert / confirm / prompt dialogs
133
149
  ```
134
150
 
135
151
  Themes are CSS-variable files — load one, or switch at runtime by toggling which you apply. Override
136
152
  the variables to match your design system.
137
153
 
154
+ ## Slides
155
+
156
+ A deck is JSON — a fixed 1920×1080 stage, and elements with absolute frames and stable ids. That
157
+ makes it something an agent can author and patch precisely, and something you can render, edit and
158
+ present from the same components.
159
+
160
+ Imported from **`reifyui/slides`**, not the root: chart, diagram and code elements lazy-load
161
+ echarts, mermaid and highlight.js, and a root re-export would put all three in the dependency graph
162
+ of every app that imports a `Button`.
163
+
164
+ ```jsx
165
+ import { SlideView, EditorCanvas, Presentation } from 'reifyui/slides';
166
+ import 'reifyui/styles/slides.css';
167
+
168
+ // Read-only: thumbnails, previews, print pages.
169
+ <SlideView slide={deck.slides[0]} theme={deck.theme} bare />
170
+
171
+ // Editable: drag to move, corner handles to resize, double-click to edit text,
172
+ // Delete to remove, arrows to nudge. The canvas never mutates the deck — you do.
173
+ <EditorCanvas
174
+ slide={deck.slides[i]}
175
+ theme={deck.theme}
176
+ selectedId={selected}
177
+ onSelect={setSelected}
178
+ onPatchElement={(id, patch) => setDeck((d) => patchElement(d, i, id, patch))}
179
+ onDeleteElement={(id) => setDeck((d) => removeElement(d, i, id))}
180
+ readOnly={agentIsWriting}
181
+ />
182
+ ```
183
+
184
+ Because every commit leaves as a typed patch, undo, autosave and collaboration stay where they
185
+ belong — with the host. Pass `peers` to draw other people's selections and live drags, and
186
+ `onDragState` to broadcast your own. `resolveSrc` rewrites element `src` values on the way out, so
187
+ workspace-relative image paths can point at your own file API.
188
+
138
189
  ## Optional: auth client
139
190
 
140
191
  ReifyUI includes a small, framework-agnostic auth client for products whose backend exposes a JSON