reifyui 0.5.0 → 0.6.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 +40 -3
- package/dist/{chunk-2LYV4PIX.js → chunk-NTIWFHR4.js} +26 -2
- package/dist/chunk-NTIWFHR4.js.map +1 -0
- package/dist/harness.cjs +72 -21
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.d.ts +23 -0
- package/dist/harness.js +52 -23
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +1166 -326
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +263 -1
- package/dist/index.js +1141 -323
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Card.jsx +49 -0
- package/src/components/Carousel.jsx +73 -0
- package/src/components/ChatPanel.jsx +461 -0
- package/src/components/Chip.jsx +61 -0
- package/src/components/Composer.jsx +20 -1
- package/src/components/Dialog.jsx +5 -10
- package/src/components/Modal.jsx +75 -0
- package/src/components/Popover.jsx +86 -0
- package/src/components/SearchField.jsx +30 -0
- package/src/components/icons.jsx +9 -0
- package/src/components/overlay.js +63 -0
- package/src/format.js +10 -0
- package/src/harness/attach.js +63 -0
- package/src/harness/index.d.ts +23 -0
- package/src/harness/index.js +6 -18
- package/src/hooks/useTypewriter.js +53 -0
- package/src/index.d.ts +263 -1
- package/src/index.js +27 -1
- package/src/input/dictate.js +60 -0
- package/src/sheet/SheetGrid.jsx +5 -1
- package/src/state/turns.js +30 -0
- package/styles/chat.css +127 -1
- package/styles/chip.css +53 -0
- package/styles/dialog.css +42 -37
- package/styles/library.css +205 -0
- package/styles/preview.css +73 -0
- package/styles/sheet.css +16 -14
- package/styles/themes/dark.css +20 -0
- package/styles/themes/light.css +23 -0
- package/dist/chunk-2LYV4PIX.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,26 @@ export function createConversationStore(
|
|
|
90
90
|
makeInitial?: (key: string) => unknown,
|
|
91
91
|
): ConversationStore;
|
|
92
92
|
|
|
93
|
+
// ── history replay ──────────────────────────────────────────────────────────
|
|
94
|
+
/** One turn as the gateway records it: the person's text, the assistant's, and the tools between. */
|
|
95
|
+
export interface Turn {
|
|
96
|
+
user?: string;
|
|
97
|
+
assistant?: string;
|
|
98
|
+
status?: string;
|
|
99
|
+
tools?: Array<{ name: string; arguments?: string; result?: unknown }>;
|
|
100
|
+
}
|
|
101
|
+
/** A rendered message: a user line, or an assistant turn as its ordered blocks. */
|
|
102
|
+
export interface ChatMessage {
|
|
103
|
+
role: 'user' | 'assistant';
|
|
104
|
+
text?: string;
|
|
105
|
+
blocks?: Block[];
|
|
106
|
+
status?: 'running' | 'done' | 'failed' | 'cancelled' | 'incomplete';
|
|
107
|
+
/** Names of the files sent WITH this message. ChatPanel sets it on send; history never has it. */
|
|
108
|
+
files?: string[];
|
|
109
|
+
}
|
|
110
|
+
/** Gateway turns -> the message shape ChatMessages and ChatPanel render. */
|
|
111
|
+
export function turnsToMessages(turns: Turn[]): ChatMessage[];
|
|
112
|
+
|
|
93
113
|
// ── icons ───────────────────────────────────────────────────────────────────
|
|
94
114
|
export const Svg: ComponentType<{ s?: number; children?: ReactNode }>;
|
|
95
115
|
export const Chevron: ComponentType<{ dir?: 'left' | 'right' | 'down'; size?: number }>;
|
|
@@ -106,6 +126,10 @@ export const IcSpawn: ComponentType;
|
|
|
106
126
|
export const IcCheck: ComponentType;
|
|
107
127
|
export const IcThink: ComponentType;
|
|
108
128
|
export const IcSend: ComponentType;
|
|
129
|
+
export const IcX: ComponentType<{ size?: number }>;
|
|
130
|
+
export const IcMic: ComponentType<{ size?: number }>;
|
|
131
|
+
export const IcPaperclip: ComponentType<{ size?: number }>;
|
|
132
|
+
export const IcPanelRight: ComponentType<{ size?: number }>;
|
|
109
133
|
|
|
110
134
|
// ── tool metadata helpers ─────────────────────────────────────────────────────
|
|
111
135
|
export function humanize(name: string): string;
|
|
@@ -141,9 +165,244 @@ export const ChatMessagesSkeleton: ComponentType<Record<string, unknown>>;
|
|
|
141
165
|
export const UserTurn: ComponentType<Record<string, unknown>>;
|
|
142
166
|
export const AssistantTurn: ComponentType<Record<string, unknown>>;
|
|
143
167
|
export const DEFAULT_STATUS_LABELS: Record<string, string>;
|
|
144
|
-
|
|
168
|
+
|
|
169
|
+
export interface ComposerProps {
|
|
170
|
+
value: string;
|
|
171
|
+
onChange: (value: string) => void;
|
|
172
|
+
onSend: () => void;
|
|
173
|
+
/** Disables the textarea itself. */
|
|
174
|
+
disabled?: boolean;
|
|
175
|
+
/** Disables the send button — and, since 0.6.0, the Enter key with it. */
|
|
176
|
+
sendDisabled?: boolean;
|
|
177
|
+
placeholder?: string;
|
|
178
|
+
rows?: number;
|
|
179
|
+
/** Grow to fit the text, up to maxRows, then scroll. Exclusive with a CSS min-height. */
|
|
180
|
+
autoGrow?: boolean;
|
|
181
|
+
maxRows?: number;
|
|
182
|
+
autoFocus?: boolean;
|
|
183
|
+
/** The accessible name. Give one whenever the placeholder animates — it is otherwise the only
|
|
184
|
+
* name the field has, and it changes every few seconds. */
|
|
185
|
+
inputAriaLabel?: string;
|
|
186
|
+
/** Node rendered ABOVE the textarea, e.g. a row of staged attachments. */
|
|
187
|
+
attachments?: ReactNode;
|
|
188
|
+
accessoriesLeft?: ReactNode;
|
|
189
|
+
accessoriesRight?: ReactNode;
|
|
190
|
+
/** Replaces the default send button entirely. */
|
|
191
|
+
renderSend?: () => ReactNode;
|
|
192
|
+
/** Each REPLACES the default class, so a product restyles wholesale instead of fighting it. */
|
|
193
|
+
classNames?: { root?: string; input?: string; row?: string };
|
|
194
|
+
inputRef?: { current: HTMLTextAreaElement | null };
|
|
195
|
+
}
|
|
196
|
+
export const Composer: ComponentType<ComposerProps>;
|
|
145
197
|
export const CodeBlock: ComponentType<{ code?: string; lang?: string; [k: string]: unknown }>;
|
|
146
198
|
|
|
199
|
+
// ── ChatPanel: the whole conversation column ─────────────────────────────────
|
|
200
|
+
/** A file picked but not yet sent. `payload` is whatever the caller's prepare() produced and the
|
|
201
|
+
* panel never looks inside it — it hands the list straight back to runTurn. */
|
|
202
|
+
export interface StagedFile {
|
|
203
|
+
name: string;
|
|
204
|
+
size?: number;
|
|
205
|
+
payload?: unknown;
|
|
206
|
+
/** True between the pick and prepare() resolving. The panel sets it; prepare() never returns it. */
|
|
207
|
+
pending?: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The dispatcher's callbacks, plus the session id a brand-new document learns mid-stream. */
|
|
211
|
+
export type TurnHandlers = ResponseHandlers;
|
|
212
|
+
|
|
213
|
+
/** Run one turn. The panel does not know whether that is one stream, a stream with a fallback, or
|
|
214
|
+
* three requests — only that progress arrives through `handlers`.
|
|
215
|
+
* Resolve `{ connecting: true }` when the backend is not up yet: the panel then holds the
|
|
216
|
+
* message (with its files) and retries, instead of showing a failed turn. */
|
|
217
|
+
export type RunTurn = (args: {
|
|
218
|
+
sessionId: string;
|
|
219
|
+
text: string;
|
|
220
|
+
attachments: StagedFile[];
|
|
221
|
+
handlers: TurnHandlers;
|
|
222
|
+
}) => Promise<{ connecting?: boolean } | void>;
|
|
223
|
+
|
|
224
|
+
/** The conversation so far, already as messages — callers write `.then(turnsToMessages)`. A
|
|
225
|
+
* caller whose brand-new document has no session yet resolves [] here without a request. */
|
|
226
|
+
export type LoadHistory = (sessionId: string) => Promise<ChatMessage[]>;
|
|
227
|
+
|
|
228
|
+
export interface ChatPanelProps {
|
|
229
|
+
/** Opaque to the panel: it is never parsed, so a placeholder id for an unsaved document is
|
|
230
|
+
* fine. When it changes mid-stream to the real id, the panel recognises its own adoption and
|
|
231
|
+
* does not reload over the turn arriving live. */
|
|
232
|
+
sessionId: string;
|
|
233
|
+
runTurn: RunTurn;
|
|
234
|
+
loadHistory: LoadHistory;
|
|
235
|
+
/** The turn opened a session. Adopt the id — the panel will not treat that as a new document. */
|
|
236
|
+
onSessionStarted?: (sessionId: string) => void;
|
|
237
|
+
/** A turn finished (here, or elsewhere): the document may have changed underneath. */
|
|
238
|
+
onChanged?: () => void;
|
|
239
|
+
|
|
240
|
+
/** A first message carried in from somewhere else (a landing prompt). Sent once, and only when
|
|
241
|
+
* there is no history. */
|
|
242
|
+
seed?: string;
|
|
243
|
+
/** Fires before the history request whenever a seed was supplied — strip it from the URL here,
|
|
244
|
+
* so a refresh or a back-button cannot resend it. */
|
|
245
|
+
onSeedConsumed?: () => void;
|
|
246
|
+
|
|
247
|
+
/** A turn is running that this panel did not start (another tab, or the first turn before the
|
|
248
|
+
* session is queryable). The panel polls history while it is true and reloads once when it
|
|
249
|
+
* goes false. */
|
|
250
|
+
externalBusy?: boolean;
|
|
251
|
+
|
|
252
|
+
/** Enables the attach control. prepare() turns a File into the entry runTurn will receive; it
|
|
253
|
+
* rejects with the message the person sees. Null (default) renders no control at all. */
|
|
254
|
+
attachments?: {
|
|
255
|
+
prepare: (file: File) => Promise<StagedFile>;
|
|
256
|
+
accept?: string;
|
|
257
|
+
/** Default true. */
|
|
258
|
+
multiple?: boolean;
|
|
259
|
+
} | null;
|
|
260
|
+
/** From createDictation(), built ONCE (useState(() => createDictation())) — a new object every
|
|
261
|
+
* render stops the recogniser every render. Null (default) renders no microphone, never a
|
|
262
|
+
* disabled one. */
|
|
263
|
+
dictation?: {
|
|
264
|
+
start(handlers: { onText?: (text: string) => void; onEnd?: () => void; onError?: (message: string) => void }): void;
|
|
265
|
+
stop(): void;
|
|
266
|
+
} | null;
|
|
267
|
+
|
|
268
|
+
title?: string;
|
|
269
|
+
/** Header content after the title, e.g. a "the agent is working" mark. */
|
|
270
|
+
headerRight?: ReactNode;
|
|
271
|
+
collapsed?: boolean;
|
|
272
|
+
/** Absent → the collapse toggle is not rendered. */
|
|
273
|
+
onToggleCollapse?: () => void;
|
|
274
|
+
/** Panel width in px, from your own drag handle. Ignored while collapsed. */
|
|
275
|
+
width?: number;
|
|
276
|
+
|
|
277
|
+
placeholder?: string;
|
|
278
|
+
/** Shown when there is no conversation. */
|
|
279
|
+
emptyState?: ReactNode;
|
|
280
|
+
/** Shown INSTEAD of emptyState while externalBusy and empty — never falls back to it: a blank
|
|
281
|
+
* "describe what you want" prompt is a dead end while the agent is visibly working. */
|
|
282
|
+
busyState?: ReactNode;
|
|
283
|
+
connectingLabel?: string;
|
|
284
|
+
connectingNote?: ReactNode;
|
|
285
|
+
workingLabel?: string;
|
|
286
|
+
statusLabels?: { failed?: string; cancelled?: string; incomplete?: string };
|
|
287
|
+
renderMarkdown?: (text: string) => ReactNode;
|
|
288
|
+
/** Extra content inside a user bubble. Return undefined to fall through to the built-in file
|
|
289
|
+
* chips, the same contract ChatMessages uses. */
|
|
290
|
+
userExtras?: (message: ChatMessage, index: number) => ReactNode | undefined;
|
|
291
|
+
toolLabels?: Record<string, string>;
|
|
292
|
+
/** The panel's placement in YOUR layout. Everything it paints inside is the package's. */
|
|
293
|
+
classNames?: { root?: string };
|
|
294
|
+
}
|
|
295
|
+
export const ChatPanel: ComponentType<ChatPanelProps>;
|
|
296
|
+
|
|
297
|
+
// ── voice input ─────────────────────────────────────────────────────────────
|
|
298
|
+
export interface Dictation {
|
|
299
|
+
/** onText fires once per finished phrase, so a draft grows as you speak. */
|
|
300
|
+
start(handlers: {
|
|
301
|
+
onText?: (text: string) => void;
|
|
302
|
+
onEnd?: () => void;
|
|
303
|
+
onError?: (message: string) => void;
|
|
304
|
+
}): void;
|
|
305
|
+
stop(): void;
|
|
306
|
+
}
|
|
307
|
+
/** Null where the browser has no recogniser — render nothing, not a disabled button. */
|
|
308
|
+
export function createDictation(options?: { lang?: string }): Dictation | null;
|
|
309
|
+
|
|
310
|
+
/** A byte count as a person reads it. null/undefined -> '' (unknown is not zero). */
|
|
311
|
+
export function bytesLabel(bytes: number | null | undefined): string;
|
|
312
|
+
|
|
313
|
+
// ── library page pieces ─────────────────────────────────────────────────────
|
|
314
|
+
export interface CarouselProps {
|
|
315
|
+
/** Names the scroll region and its buttons ("Scroll templates left"). */
|
|
316
|
+
label: string;
|
|
317
|
+
/** px per press. Defaults to 90% of the visible width. */
|
|
318
|
+
step?: number;
|
|
319
|
+
children?: ReactNode;
|
|
320
|
+
classNames?: { root?: string; viewport?: string; button?: string };
|
|
321
|
+
}
|
|
322
|
+
/** Buttons disable at each edge and are not rendered at all when the content already fits.
|
|
323
|
+
* Item width comes from --uic-car-item (default 236px). */
|
|
324
|
+
export const Carousel: ComponentType<CarouselProps>;
|
|
325
|
+
|
|
326
|
+
export interface CardProps {
|
|
327
|
+
/** The thumbnail node; this component supplies the box around it. */
|
|
328
|
+
art?: ReactNode;
|
|
329
|
+
title: ReactNode;
|
|
330
|
+
subtitle?: ReactNode;
|
|
331
|
+
/** Makes art + title one button. Omit while an inline rename field is in `title`. */
|
|
332
|
+
onClick?: () => void;
|
|
333
|
+
selected?: boolean;
|
|
334
|
+
/** Floats over the art on hover; always visible where there is no hover. */
|
|
335
|
+
overlay?: ReactNode;
|
|
336
|
+
/** Sits in the title row — a sibling of the main button, never inside it. */
|
|
337
|
+
actions?: ReactNode;
|
|
338
|
+
classNames?: { root?: string };
|
|
339
|
+
}
|
|
340
|
+
export const Card: ComponentType<CardProps>;
|
|
341
|
+
|
|
342
|
+
export interface ChipProps {
|
|
343
|
+
label: ReactNode;
|
|
344
|
+
icon?: ReactNode;
|
|
345
|
+
title?: string;
|
|
346
|
+
selected?: boolean;
|
|
347
|
+
onClick?: () => void;
|
|
348
|
+
onRemove?: () => void;
|
|
349
|
+
/** Required with onRemove: "✕" alone does not say which of five chips it removes. */
|
|
350
|
+
removeLabel?: string;
|
|
351
|
+
className?: string;
|
|
352
|
+
}
|
|
353
|
+
export const Chip: ComponentType<ChipProps>;
|
|
354
|
+
|
|
355
|
+
export interface SearchFieldProps {
|
|
356
|
+
value: string;
|
|
357
|
+
onChange: (value: string) => void;
|
|
358
|
+
/** Also the accessible name. */
|
|
359
|
+
placeholder?: string;
|
|
360
|
+
clearLabel?: string;
|
|
361
|
+
className?: string;
|
|
362
|
+
}
|
|
363
|
+
export const SearchField: ComponentType<SearchFieldProps>;
|
|
364
|
+
|
|
365
|
+
export interface PopoverProps {
|
|
366
|
+
open: boolean;
|
|
367
|
+
/** The control it belongs to; the panel positions against its box and a press on it is not
|
|
368
|
+
* treated as an outside press. */
|
|
369
|
+
anchorRef: { current: HTMLElement | null };
|
|
370
|
+
onClose?: () => void;
|
|
371
|
+
/** Preferred width, clamped to the viewport. */
|
|
372
|
+
width?: number;
|
|
373
|
+
/** Flip to the other side rather than squeeze below this. */
|
|
374
|
+
minHeight?: number;
|
|
375
|
+
placement?: 'auto' | 'below' | 'above';
|
|
376
|
+
label?: string;
|
|
377
|
+
className?: string;
|
|
378
|
+
children?: ReactNode;
|
|
379
|
+
}
|
|
380
|
+
/** Portals to the body and positions itself fixed — never clipped by an ancestor's overflow. */
|
|
381
|
+
export const Popover: ComponentType<PopoverProps>;
|
|
382
|
+
|
|
383
|
+
export interface ModalProps {
|
|
384
|
+
open: boolean;
|
|
385
|
+
onClose?: () => void;
|
|
386
|
+
title?: ReactNode;
|
|
387
|
+
description?: ReactNode;
|
|
388
|
+
/** Header buttons, before the close ✕. */
|
|
389
|
+
actions?: ReactNode;
|
|
390
|
+
size?: 'sm' | 'md' | 'lg' | 'full';
|
|
391
|
+
/** An exact width, overriding `size`. */
|
|
392
|
+
width?: number | string;
|
|
393
|
+
/** id of your own heading, when the name does not live in `title`. */
|
|
394
|
+
labelledBy?: string;
|
|
395
|
+
children?: ReactNode;
|
|
396
|
+
classNames?: { backdrop?: string; root?: string; body?: string };
|
|
397
|
+
}
|
|
398
|
+
/** Shares the dialog host's Escape ordering: the last overlay opened answers the key. */
|
|
399
|
+
export const Modal: ComponentType<ModalProps>;
|
|
400
|
+
|
|
401
|
+
/** Types `phrases` out one at a time. Honours prefers-reduced-motion (shows the first phrase and
|
|
402
|
+
* stops). Speed and order are not configurable — they were the only differences between the
|
|
403
|
+
* three implementations this replaces. */
|
|
404
|
+
export function useTypewriter(phrases: string[], options?: { active?: boolean }): string;
|
|
405
|
+
|
|
147
406
|
// ── resizable pane ──────────────────────────────────────────────────────────
|
|
148
407
|
export function useResizablePane(options?: Record<string, unknown>): {
|
|
149
408
|
size: number;
|
|
@@ -260,6 +519,9 @@ export interface SheetColumnType {
|
|
|
260
519
|
configKey?: string;
|
|
261
520
|
/** An extra header sub-label, e.g. which kind of compute this is. */
|
|
262
521
|
badge?: (column: SheetColumn) => string | undefined;
|
|
522
|
+
/** How much room this type's config popover needs. Defaults to 250 x 340. */
|
|
523
|
+
configWidth?: number;
|
|
524
|
+
configHeight?: number;
|
|
263
525
|
}
|
|
264
526
|
|
|
265
527
|
export interface SheetCellRenderContext {
|