reifyui 0.3.0 → 0.4.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/README.md +59 -10
- package/dist/index.d.ts +93 -22
- package/dist/slides.cjs +737 -0
- package/dist/slides.cjs.map +1 -0
- package/dist/slides.d.ts +128 -0
- package/dist/slides.js +705 -0
- package/dist/slides.js.map +1 -0
- package/package.json +10 -3
- package/src/auth/AuthForm.jsx +187 -0
- package/src/auth/GoogleButton.jsx +80 -0
- package/src/auth/client.js +177 -0
- package/src/components/ChatMessages.jsx +194 -0
- package/src/components/CodeBlock.jsx +120 -0
- package/src/components/Composer.jsx +75 -0
- package/src/components/Dialog.jsx +312 -0
- package/src/components/TaskList.jsx +193 -0
- package/src/components/ToolSteps.jsx +84 -0
- package/src/components/icons.jsx +33 -0
- package/src/components/resizable.jsx +84 -0
- package/src/components/toolMeta.js +91 -0
- package/src/index.d.ts +234 -0
- package/src/index.js +35 -0
- package/src/sheet/SheetGrid.jsx +633 -0
- package/src/slides/Editor.jsx +246 -0
- package/src/slides/Presentation.jsx +79 -0
- package/src/slides/SlideView.jsx +97 -0
- package/src/slides/elements.jsx +178 -0
- package/src/slides/index.d.ts +128 -0
- package/src/slides/index.js +10 -0
- package/src/state/blocks.js +37 -0
- package/src/state/conversationStore.js +55 -0
- package/src/stream/responses.js +122 -0
- package/styles/slides.css +38 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Drag-to-resize pane primitive — drag mechanics lifted from HarnessRouter's workbench
|
|
2
|
+
// useHResize (iframe/text-selection neutralization included), extended with:
|
|
3
|
+
// - min/max clamps (absolute px and/or a viewport fraction, e.g. 60vw)
|
|
4
|
+
// - per-user width persistence (localStorage, storageKey)
|
|
5
|
+
// - double-click the divider to reset to the default width
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// const pane = useResizablePane({ initial: 340, min: 320, maxFraction: 0.6,
|
|
9
|
+
// fromRight: true, storageKey: 'cg.chat.w' });
|
|
10
|
+
// <PaneResizer pane={pane} />
|
|
11
|
+
// <aside style={{ flex: `0 0 ${pane.width}px` }}>…</aside>
|
|
12
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
13
|
+
|
|
14
|
+
export function useResizablePane(opts = {}) {
|
|
15
|
+
const {
|
|
16
|
+
initial = 380,
|
|
17
|
+
min = 240,
|
|
18
|
+
max = null, // absolute px cap (null = none)
|
|
19
|
+
maxFraction = null, // viewport-width fraction cap, e.g. 0.6 for 60vw (null = none)
|
|
20
|
+
fromRight = false, // divider sits on the pane's LEFT edge (dragging right shrinks)
|
|
21
|
+
storageKey = null, // persist the chosen width per user (localStorage)
|
|
22
|
+
} = opts;
|
|
23
|
+
|
|
24
|
+
const clamp = useCallback((x) => {
|
|
25
|
+
let hi = max ?? Infinity;
|
|
26
|
+
if (maxFraction && typeof window !== 'undefined') hi = Math.min(hi, Math.round(window.innerWidth * maxFraction));
|
|
27
|
+
return Math.min(hi, Math.max(min, x));
|
|
28
|
+
}, [min, max, maxFraction]);
|
|
29
|
+
|
|
30
|
+
const [width, setWidth] = useState(() => {
|
|
31
|
+
if (storageKey && typeof window !== 'undefined') {
|
|
32
|
+
try {
|
|
33
|
+
const n = parseInt(window.localStorage.getItem(storageKey) || '', 10);
|
|
34
|
+
if (Number.isFinite(n)) return clamp(n);
|
|
35
|
+
} catch { /* private mode */ }
|
|
36
|
+
}
|
|
37
|
+
return initial;
|
|
38
|
+
});
|
|
39
|
+
const widthRef = useRef(width);
|
|
40
|
+
widthRef.current = width;
|
|
41
|
+
|
|
42
|
+
const persist = useCallback((w) => {
|
|
43
|
+
if (!storageKey) return;
|
|
44
|
+
try { window.localStorage.setItem(storageKey, String(w)); } catch { /* private mode */ }
|
|
45
|
+
}, [storageKey]);
|
|
46
|
+
|
|
47
|
+
const onMouseDown = useCallback((e) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
const sx = e.clientX, base = widthRef.current, dir = fromRight ? -1 : 1;
|
|
50
|
+
// While dragging, neutralize iframes/text-selection so an embedded preview can't swallow
|
|
51
|
+
// mousemove/mouseup (which would strand the drag).
|
|
52
|
+
document.body.classList.add('uic-resizing');
|
|
53
|
+
const move = (ev) => setWidth(clamp(base + dir * (ev.clientX - sx)));
|
|
54
|
+
const up = () => {
|
|
55
|
+
window.removeEventListener('mousemove', move); window.removeEventListener('mouseup', up);
|
|
56
|
+
document.body.style.cursor = ''; document.body.classList.remove('uic-resizing');
|
|
57
|
+
persist(widthRef.current);
|
|
58
|
+
};
|
|
59
|
+
window.addEventListener('mousemove', move); window.addEventListener('mouseup', up);
|
|
60
|
+
document.body.style.cursor = 'col-resize';
|
|
61
|
+
}, [clamp, fromRight, persist]);
|
|
62
|
+
|
|
63
|
+
const reset = useCallback(() => {
|
|
64
|
+
setWidth(initial);
|
|
65
|
+
if (storageKey) { try { window.localStorage.removeItem(storageKey); } catch { /* private mode */ } }
|
|
66
|
+
}, [initial, storageKey]);
|
|
67
|
+
|
|
68
|
+
return { width, onMouseDown, reset };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The grabbable divider (comfortable 7px hit area, col-resize cursor, dblclick = reset). */
|
|
72
|
+
export function PaneResizer(props) {
|
|
73
|
+
const { pane, className, title = 'Drag to resize (double-click to reset)' } = props;
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
className={className ?? 'uic-vresize'}
|
|
77
|
+
role="separator"
|
|
78
|
+
aria-orientation="vertical"
|
|
79
|
+
title={title}
|
|
80
|
+
onMouseDown={pane.onMouseDown}
|
|
81
|
+
onDoubleClick={pane.reset}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Tool-step presentation metadata — extracted from HarnessRouter's workbench.
|
|
2
|
+
// toolMeta(name, args) -> { Icon, label, chip? }: a rich end-user-facing row for one tool step.
|
|
3
|
+
// summarizeSteps(steps) -> "Ran 5 commands, read 2 files, wrote a file" natural-language recap.
|
|
4
|
+
import {
|
|
5
|
+
IcTool, IcPlug, IcSkill, IcTerminal, IcDoc, IcList, IcGlobe, IcSearch, IcScroll, IcSpawn,
|
|
6
|
+
} from './icons.jsx';
|
|
7
|
+
|
|
8
|
+
export function humanize(s) {
|
|
9
|
+
return (s || '').replace(/[_\-]+/g, ' ').trim().replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10
|
+
}
|
|
11
|
+
export function parseArgs(args) {
|
|
12
|
+
try { return (typeof args === 'string' ? JSON.parse(args) : args) || {}; } catch { return {}; }
|
|
13
|
+
}
|
|
14
|
+
export function baseName(p) { return String(p || '').split('/').filter(Boolean).pop() || String(p || ''); }
|
|
15
|
+
export function prettyJson(s) { try { return JSON.stringify(JSON.parse(s), null, 2); } catch { return s || ''; } }
|
|
16
|
+
|
|
17
|
+
// Rich end-user-facing metadata for one tool step: icon + label (+ optional filename/kind chip).
|
|
18
|
+
export function toolMeta(name, args) {
|
|
19
|
+
const n = name || ''; const a = parseArgs(args);
|
|
20
|
+
const mcp = n.match(/^mcp__(.+?)__(.+)$/);
|
|
21
|
+
if (mcp) return { Icon: IcPlug, label: `${humanize(mcp[1])} · ${humanize(mcp[2])}` };
|
|
22
|
+
switch (n) {
|
|
23
|
+
case 'Skill': return { Icon: IcSkill, label: 'Skill', chip: String(a.command || a.name || a.skill || a.skill_name || '') || undefined };
|
|
24
|
+
case 'ToolSearch': return { Icon: IcSearch, label: 'Finding tools' };
|
|
25
|
+
case 'TaskCreate': return { Icon: IcList, label: 'Added task' + (a.subject ? `: ${a.subject}` : '') };
|
|
26
|
+
case 'TaskUpdate': {
|
|
27
|
+
const s = String(a.status || '');
|
|
28
|
+
return { Icon: IcList, label: s === 'completed' ? 'Completed task' : s === 'in_progress' ? 'Started task' : 'Updated task' };
|
|
29
|
+
}
|
|
30
|
+
case 'Bash': {
|
|
31
|
+
const cmd = String(a.command || '');
|
|
32
|
+
const label = /^\s*mkdir/.test(cmd) ? 'Create working directory' : /^\s*(cd|ls|pwd|cat|find)\b/.test(cmd) ? 'Inspected the workspace' : 'Ran a command';
|
|
33
|
+
return { Icon: IcTerminal, label };
|
|
34
|
+
}
|
|
35
|
+
case 'Write': return { Icon: IcDoc, label: 'Wrote a file', chip: baseName(a.file_path || a.path) };
|
|
36
|
+
case 'Edit': case 'MultiEdit': return { Icon: IcDoc, label: 'Edited a file', chip: baseName(a.file_path || a.path) };
|
|
37
|
+
case 'Read': return { Icon: IcScroll, label: 'Read ' + (baseName(a.file_path || a.path) || 'a file') };
|
|
38
|
+
case 'Glob': return { Icon: IcSearch, label: 'Found files' };
|
|
39
|
+
case 'Grep': return { Icon: IcSearch, label: 'Searched code' };
|
|
40
|
+
case 'LS': return { Icon: IcList, label: 'Listed files' };
|
|
41
|
+
case 'WebSearch': return { Icon: IcGlobe, label: 'Searched the web' };
|
|
42
|
+
case 'WebFetch': return { Icon: IcGlobe, label: 'Fetched a web page' };
|
|
43
|
+
case 'Task': case 'Agent': return { Icon: IcSpawn, label: 'Ran a sub-agent' };
|
|
44
|
+
default: return { Icon: IcTool, label: humanize(n) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Natural-language summary for a group of steps, counted per operation type and concatenated,
|
|
49
|
+
// e.g. "Ran 5 commands" or "Ran 5 commands, read 2 files, wrote a file".
|
|
50
|
+
export function summarizeSteps(steps) {
|
|
51
|
+
// name -> a stable category key (Edit/MultiEdit collapse; mcp__*/unknown -> 'tool')
|
|
52
|
+
const catOf = (n) => {
|
|
53
|
+
if (/^mcp__/.test(n)) return 'tool';
|
|
54
|
+
return ({ Bash: 'bash', Write: 'write', Edit: 'edit', MultiEdit: 'edit', Read: 'read', Glob: 'glob',
|
|
55
|
+
Grep: 'grep', LS: 'ls', WebSearch: 'websearch', WebFetch: 'webfetch', Task: 'agent', Agent: 'agent',
|
|
56
|
+
ToolSearch: 'toolsearch', Skill: 'skill', TaskCreate: 'taskcreate', TaskUpdate: 'taskupdate' })[n] || 'tool';
|
|
57
|
+
};
|
|
58
|
+
// category -> phrase(count). Lowercase; the first word of the whole summary is capitalized below.
|
|
59
|
+
const phrase = (cat, c) => {
|
|
60
|
+
const one = c === 1;
|
|
61
|
+
switch (cat) {
|
|
62
|
+
case 'bash': return one ? 'ran a command' : `ran ${c} commands`;
|
|
63
|
+
case 'write': return one ? 'wrote a file' : `wrote ${c} files`;
|
|
64
|
+
case 'edit': return one ? 'edited a file' : `edited ${c} files`;
|
|
65
|
+
case 'read': return one ? 'read a file' : `read ${c} files`;
|
|
66
|
+
case 'grep': return one ? 'searched code' : `searched code ${c} times`;
|
|
67
|
+
case 'glob': return 'found files';
|
|
68
|
+
case 'ls': return 'listed files';
|
|
69
|
+
case 'websearch': return one ? 'searched the web' : `searched the web ${c} times`;
|
|
70
|
+
case 'webfetch': return one ? 'fetched a page' : `fetched ${c} pages`;
|
|
71
|
+
case 'agent': return one ? 'ran a sub-agent' : `ran ${c} sub-agents`;
|
|
72
|
+
case 'toolsearch': return 'loaded tools';
|
|
73
|
+
case 'skill': return one ? 'used a skill' : `used ${c} skills`;
|
|
74
|
+
case 'taskcreate': return one ? 'added a task' : `added ${c} tasks`;
|
|
75
|
+
case 'taskupdate': return one ? 'updated a task' : `updated ${c} tasks`;
|
|
76
|
+
default: return one ? 'used a tool' : `used ${c} tools`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// count per category, preserving first-seen order
|
|
80
|
+
const order = [];
|
|
81
|
+
const counts = {};
|
|
82
|
+
for (const s of steps) {
|
|
83
|
+
const cat = catOf(s.name || '');
|
|
84
|
+
if (!(cat in counts)) { counts[cat] = 0; order.push(cat); }
|
|
85
|
+
counts[cat]++;
|
|
86
|
+
}
|
|
87
|
+
if (order.length === 0) return 'Working…';
|
|
88
|
+
const parts = order.map((cat) => phrase(cat, counts[cat]));
|
|
89
|
+
const j = parts.join(', ');
|
|
90
|
+
return j.charAt(0).toUpperCase() + j.slice(1);
|
|
91
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// ReifyUI public type surface.
|
|
2
|
+
//
|
|
3
|
+
// The implementation is plain-ESM React (.js/.jsx), so these declarations are
|
|
4
|
+
// authored by hand rather than inferred. Components accept the props documented in
|
|
5
|
+
// the README; where a prop set is open-ended (render slots, passthrough) the type is
|
|
6
|
+
// intentionally permissive rather than falsely precise.
|
|
7
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
// ── streaming ──────────────────────────────────────────────────────────────
|
|
10
|
+
export interface SSEEvent { type: string; [k: string]: unknown; }
|
|
11
|
+
|
|
12
|
+
/** Semantic callbacks over the Responses SSE shape. All optional — handle only what you render. */
|
|
13
|
+
export interface ResponseHandlers {
|
|
14
|
+
/** The response id, as soon as response.created arrives. */
|
|
15
|
+
onCreated?(responseId: string): void;
|
|
16
|
+
/** The server-side session id, for continuing this conversation on the next turn. */
|
|
17
|
+
onSession?(sessionId: string): void;
|
|
18
|
+
onReasoningDelta?(text: string): void;
|
|
19
|
+
onTextDelta?(text: string): void;
|
|
20
|
+
onToolCall?(name: string, args: string, callId: string): void;
|
|
21
|
+
onToolResult?(callId: string, output: string): void;
|
|
22
|
+
onFile?(file: { container_id: string; file_id: string; filename: string }): void;
|
|
23
|
+
/** Terminal event. `status` distinguishes completed / incomplete / failed (incl. cancels). */
|
|
24
|
+
onDone?(status: string, response: unknown): void;
|
|
25
|
+
onError?(message: string): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ResponsesDispatcher {
|
|
29
|
+
responseId: string | null;
|
|
30
|
+
dispatch(event: SSEEvent): void;
|
|
31
|
+
}
|
|
32
|
+
/** Event-shape decoding only — pair with readSSEStream when you own the read loop. */
|
|
33
|
+
export function createResponsesDispatcher(handlers: ResponseHandlers): ResponsesDispatcher;
|
|
34
|
+
|
|
35
|
+
/** Frame an SSE byte stream. Takes the response BODY, and hands back each frame's raw `data:`
|
|
36
|
+
* payload as a STRING — parsing is the caller's (see pumpResponsesStream for the parsed form). */
|
|
37
|
+
export function readSSEStream(
|
|
38
|
+
body: ReadableStream<Uint8Array>,
|
|
39
|
+
onData: (data: string) => void,
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
|
|
42
|
+
/** Read + decode in one call. Resolves to the response id. */
|
|
43
|
+
export function pumpResponsesStream(
|
|
44
|
+
body: ReadableStream<Uint8Array>,
|
|
45
|
+
handlers: ResponseHandlers,
|
|
46
|
+
): Promise<string | null>;
|
|
47
|
+
|
|
48
|
+
// ── block state machine ─────────────────────────────────────────────────────
|
|
49
|
+
// An assistant turn is an ORDERED list of blocks appended as events arrive, so tool activity
|
|
50
|
+
// interleaves with prose in real time instead of every tool being hoisted above the text.
|
|
51
|
+
export interface ToolStep {
|
|
52
|
+
name: string;
|
|
53
|
+
args?: string;
|
|
54
|
+
result?: unknown;
|
|
55
|
+
callId?: string;
|
|
56
|
+
[k: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
export type Block =
|
|
59
|
+
| { kind: 'text'; text: string }
|
|
60
|
+
| { kind: 'tools'; reasoning: string; steps: ToolStep[] };
|
|
61
|
+
|
|
62
|
+
// The transforms are generic over the caller's block type: they only ever read `kind` (and, in
|
|
63
|
+
// withResult, a step's `callId`/`result`), and otherwise pass values through untouched. An app
|
|
64
|
+
// with a stricter Block/ToolStep of its own keeps it, rather than having every result widened to
|
|
65
|
+
// this module's shape. Block above is the DEFAULT for apps that don't declare their own.
|
|
66
|
+
/** Append prose, merging into a trailing text block. */
|
|
67
|
+
export function withText<B = Block>(blocks: B[], delta: string): B[];
|
|
68
|
+
/** Append reasoning, merging into a trailing tools block. */
|
|
69
|
+
export function withReasoning<B = Block>(blocks: B[], delta: string): B[];
|
|
70
|
+
/** Append a tool step, merging into a trailing tools block. */
|
|
71
|
+
export function withStep<B = Block, S = ToolStep>(blocks: B[], step: S): B[];
|
|
72
|
+
/** Attach a result to the pending step with this call id. */
|
|
73
|
+
export function withResult<B = Block>(blocks: B[], callId: string, output: unknown): B[];
|
|
74
|
+
/** All prose of an assistant MESSAGE joined — takes the message, not its blocks. */
|
|
75
|
+
export function asstText(message: { blocks: readonly unknown[] }): string;
|
|
76
|
+
|
|
77
|
+
// ── conversation store ──────────────────────────────────────────────────────
|
|
78
|
+
// A tiny keyed store with a React binding: `use(key)` subscribes, `get`/`set` read and write
|
|
79
|
+
// outside render. Values are whatever the caller puts in, so they stay generic per key.
|
|
80
|
+
export interface ConversationStore {
|
|
81
|
+
get<T = unknown>(key: string): T;
|
|
82
|
+
/** Shallow-merges a partial into the key's current state (or the partial a function returns). */
|
|
83
|
+
set<T = unknown>(key: string, patch: Partial<T> | ((prev: T) => Partial<T>)): void;
|
|
84
|
+
seed(key: string, value: unknown): void;
|
|
85
|
+
updateLastAssistant(key: string, update: (msg: unknown) => unknown): void;
|
|
86
|
+
use<T = unknown>(key: string): T;
|
|
87
|
+
}
|
|
88
|
+
/** `makeInitial(key)` supplies the starting value the first time a key is read. */
|
|
89
|
+
export function createConversationStore(
|
|
90
|
+
makeInitial?: (key: string) => unknown,
|
|
91
|
+
): ConversationStore;
|
|
92
|
+
|
|
93
|
+
// ── icons ───────────────────────────────────────────────────────────────────
|
|
94
|
+
export const Svg: ComponentType<{ s?: number; children?: ReactNode }>;
|
|
95
|
+
export const Chevron: ComponentType<{ dir?: 'left' | 'right' | 'down'; size?: number }>;
|
|
96
|
+
export const IcTool: ComponentType;
|
|
97
|
+
export const IcPlug: ComponentType;
|
|
98
|
+
export const IcSkill: ComponentType;
|
|
99
|
+
export const IcTerminal: ComponentType;
|
|
100
|
+
export const IcDoc: ComponentType;
|
|
101
|
+
export const IcList: ComponentType;
|
|
102
|
+
export const IcGlobe: ComponentType;
|
|
103
|
+
export const IcSearch: ComponentType;
|
|
104
|
+
export const IcScroll: ComponentType;
|
|
105
|
+
export const IcSpawn: ComponentType;
|
|
106
|
+
export const IcCheck: ComponentType;
|
|
107
|
+
export const IcThink: ComponentType;
|
|
108
|
+
export const IcSend: ComponentType;
|
|
109
|
+
|
|
110
|
+
// ── tool metadata helpers ─────────────────────────────────────────────────────
|
|
111
|
+
export function humanize(name: string): string;
|
|
112
|
+
export function parseArgs(raw: unknown): Record<string, unknown>;
|
|
113
|
+
export function baseName(path: string): string;
|
|
114
|
+
export function prettyJson(value: unknown): string;
|
|
115
|
+
export function toolMeta(name: string): { label: string; icon?: ComponentType; [k: string]: unknown };
|
|
116
|
+
export function summarizeSteps(steps: unknown[]): string;
|
|
117
|
+
|
|
118
|
+
// ── components (permissive props: see README for slot contracts) ─────────────
|
|
119
|
+
export const ToolGroup: ComponentType<Record<string, unknown>>;
|
|
120
|
+
export const ToolRow: ComponentType<Record<string, unknown>>;
|
|
121
|
+
/** The message list. `messages` is the conversation you own — this renders it and its tool
|
|
122
|
+
* timeline; every render slot is optional. */
|
|
123
|
+
// Generic over YOUR message type: the renderer never inspects a message beyond `role` and its
|
|
124
|
+
// blocks, so the slots hand back whatever shape you passed in rather than widening it.
|
|
125
|
+
export interface ChatMessagesProps<M = any> {
|
|
126
|
+
messages: M[];
|
|
127
|
+
renderMarkdown?: (text: string) => ReactNode;
|
|
128
|
+
renderMessage?(message: M, index: number): ReactNode;
|
|
129
|
+
renderStep?(step: ToolStep, index: number): ReactNode;
|
|
130
|
+
userExtras?(message: M, index: number): ReactNode;
|
|
131
|
+
/** Rendered on the live "working" row — a node, not a slot function. */
|
|
132
|
+
workingExtra?: ReactNode;
|
|
133
|
+
assistantFooter?(message: M, index: number): ReactNode;
|
|
134
|
+
statusLabels?: Record<string, string>;
|
|
135
|
+
workingLabel?: string;
|
|
136
|
+
toolLabels?: Record<string, string>;
|
|
137
|
+
[k: string]: unknown;
|
|
138
|
+
}
|
|
139
|
+
export const ChatMessages: <M = unknown>(props: ChatMessagesProps<M>) => ReactNode;
|
|
140
|
+
export const ChatMessagesSkeleton: ComponentType<Record<string, unknown>>;
|
|
141
|
+
export const UserTurn: ComponentType<Record<string, unknown>>;
|
|
142
|
+
export const AssistantTurn: ComponentType<Record<string, unknown>>;
|
|
143
|
+
export const DEFAULT_STATUS_LABELS: Record<string, string>;
|
|
144
|
+
export const Composer: ComponentType<Record<string, unknown>>;
|
|
145
|
+
export const CodeBlock: ComponentType<{ code?: string; lang?: string; [k: string]: unknown }>;
|
|
146
|
+
|
|
147
|
+
// ── resizable pane ──────────────────────────────────────────────────────────
|
|
148
|
+
export function useResizablePane(options?: Record<string, unknown>): {
|
|
149
|
+
size: number;
|
|
150
|
+
setSize: (n: number) => void;
|
|
151
|
+
[k: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
export const PaneResizer: ComponentType<Record<string, unknown>>;
|
|
154
|
+
|
|
155
|
+
// ── task list ───────────────────────────────────────────────────────────────
|
|
156
|
+
export interface TaskListPage { items: unknown[]; cursor?: string; }
|
|
157
|
+
export interface TaskListProps {
|
|
158
|
+
fetchPage: (cursor: string) => Promise<TaskListPage> | TaskListPage;
|
|
159
|
+
selected?: string | null;
|
|
160
|
+
onSelect?: (id: string) => void;
|
|
161
|
+
onNew?: () => void;
|
|
162
|
+
onDelete?: (item: any) => void;
|
|
163
|
+
header?: ReactNode;
|
|
164
|
+
renderMeta?: (item: any) => ReactNode;
|
|
165
|
+
refreshNonce?: number;
|
|
166
|
+
emptyLabel?: string;
|
|
167
|
+
newLabel?: string;
|
|
168
|
+
idKey?: string; titleKey?: string; statusKey?: string; timeKey?: string;
|
|
169
|
+
}
|
|
170
|
+
export const TaskList: ComponentType<TaskListProps>;
|
|
171
|
+
export function taskStatusGroup(status: string): 'working' | 'done' | 'failed' | 'idle';
|
|
172
|
+
|
|
173
|
+
// ── dialogs (alert / confirm / prompt, in-app) ───────────────────────────────
|
|
174
|
+
export type DialogVariant = 'destructive' | 'error' | 'warning' | 'success';
|
|
175
|
+
export interface DialogLabels {
|
|
176
|
+
confirm?: string; cancel?: string; ok?: string; create?: string; required?: string;
|
|
177
|
+
}
|
|
178
|
+
export interface AlertOptions {
|
|
179
|
+
title?: string; message?: ReactNode; variant?: DialogVariant; confirmLabel?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface ConfirmOptions extends AlertOptions {
|
|
182
|
+
destructive?: boolean; cancelLabel?: string;
|
|
183
|
+
}
|
|
184
|
+
export interface PromptOptions extends ConfirmOptions {
|
|
185
|
+
label?: string; placeholder?: string; help?: ReactNode;
|
|
186
|
+
defaultValue?: string; inputType?: string;
|
|
187
|
+
multiline?: boolean; rows?: number; required?: boolean;
|
|
188
|
+
/** Return an error message to reject, or null/undefined to accept. */
|
|
189
|
+
validate?: (value: string) => string | null | undefined;
|
|
190
|
+
}
|
|
191
|
+
export interface CreateType { kind: string; label: string; color?: string; icon?: ReactNode; }
|
|
192
|
+
export interface CreateOptions extends PromptOptions {
|
|
193
|
+
types?: CreateType[]; defaultKind?: string;
|
|
194
|
+
}
|
|
195
|
+
export interface DialogApi {
|
|
196
|
+
alert(opts: AlertOptions): Promise<boolean>;
|
|
197
|
+
confirm(opts: ConfirmOptions): Promise<boolean>;
|
|
198
|
+
/** Resolves to the entered string, or null when cancelled. */
|
|
199
|
+
prompt(opts: PromptOptions): Promise<string | null>;
|
|
200
|
+
create(opts: CreateOptions): Promise<{ kind: string; name: string } | null>;
|
|
201
|
+
labels: Required<DialogLabels>;
|
|
202
|
+
}
|
|
203
|
+
export const DialogHost: ComponentType<{
|
|
204
|
+
children?: ReactNode; locale?: 'en' | 'zh'; labels?: DialogLabels;
|
|
205
|
+
}>;
|
|
206
|
+
export function useDialog(): DialogApi;
|
|
207
|
+
|
|
208
|
+
// ── auth client (optional; couples to a /v1/auth-style backend) ──────────────
|
|
209
|
+
export interface AuthConfig { engine: string; product: string; loginHash?: string; }
|
|
210
|
+
export function configureAuth(cfg: Partial<AuthConfig> & { product: string; engine: string }): void;
|
|
211
|
+
export function authConfig(): AuthConfig;
|
|
212
|
+
export const SESSION_EVENT: string;
|
|
213
|
+
export function getSession(): unknown | null;
|
|
214
|
+
export function clearSession(): void;
|
|
215
|
+
export function getToken(): string | null;
|
|
216
|
+
export function isAuthed(): boolean;
|
|
217
|
+
export function login(email: string, password: string): Promise<unknown>;
|
|
218
|
+
export function register(payload: Record<string, unknown>): Promise<unknown>;
|
|
219
|
+
export function googleSignIn(credential: string, extra?: Record<string, unknown>): Promise<unknown>;
|
|
220
|
+
export function requestPasswordReset(email: string): Promise<unknown>;
|
|
221
|
+
export function switchOrg(orgId: string): Promise<unknown>;
|
|
222
|
+
export function refreshToken(): Promise<unknown>;
|
|
223
|
+
export function handleAuthExpired(): void;
|
|
224
|
+
export function logout(): void;
|
|
225
|
+
export function authFetch(input: string, init?: RequestInit): Promise<Response>;
|
|
226
|
+
export function fetchBalance(): Promise<unknown>;
|
|
227
|
+
export const AuthForm: ComponentType<Record<string, unknown>>;
|
|
228
|
+
export const GoogleButton: ComponentType<Record<string, unknown>>;
|
|
229
|
+
export const GOOGLE_ENABLED: boolean;
|
|
230
|
+
|
|
231
|
+
// ── AI spreadsheet grid ──────────────────────────────────────────────────────
|
|
232
|
+
export const SheetGrid: ComponentType<Record<string, unknown>>;
|
|
233
|
+
export function sheetToDelimited(sheet: unknown, delimiter?: string): string;
|
|
234
|
+
export function sheetToAoA(sheet: unknown): unknown[][];
|
package/src/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// UI Core — shared Conversational Agent surface (extracted from HarnessRouter).
|
|
2
|
+
// Plain ESM React source: consumers alias this package (Vite resolve.alias / Next webpack alias
|
|
3
|
+
// + tsconfig paths) and import straight from source. No build step. Only peer dep: react.
|
|
4
|
+
export { createResponsesDispatcher, readSSEStream, pumpResponsesStream } from './stream/responses.js';
|
|
5
|
+
export { withText, withReasoning, withStep, withResult, asstText } from './state/blocks.js';
|
|
6
|
+
export { createConversationStore } from './state/conversationStore.js';
|
|
7
|
+
export { Svg, Chevron, IcTool, IcPlug, IcSkill, IcTerminal, IcDoc, IcList, IcGlobe, IcSearch, IcScroll, IcSpawn, IcCheck, IcThink, IcSend } from './components/icons.jsx';
|
|
8
|
+
export { humanize, parseArgs, baseName, prettyJson, toolMeta, summarizeSteps } from './components/toolMeta.js';
|
|
9
|
+
export { ToolGroup, ToolRow } from './components/ToolSteps.jsx';
|
|
10
|
+
export { ChatMessages, ChatMessagesSkeleton, UserTurn, AssistantTurn, DEFAULT_STATUS_LABELS } from './components/ChatMessages.jsx';
|
|
11
|
+
export { Composer } from './components/Composer.jsx';
|
|
12
|
+
// CodeBlock lazy-imports highlight.js — the consuming app must depend on highlight.js (^11),
|
|
13
|
+
// same rule as mermaid for the Mermaid blocks. See components/CodeBlock.jsx.
|
|
14
|
+
export { CodeBlock } from './components/CodeBlock.jsx';
|
|
15
|
+
export { useResizablePane, PaneResizer } from './components/resizable.jsx';
|
|
16
|
+
// Master list beside a conversation (runs/sessions): filter, status, cursor pagination.
|
|
17
|
+
// Transport-agnostic — the consumer supplies fetchPage(cursor) -> {items, cursor}.
|
|
18
|
+
export { TaskList, taskStatusGroup } from './components/TaskList.jsx';
|
|
19
|
+
// In-app alert/confirm/prompt. Native browser popups block the event loop and can't be styled,
|
|
20
|
+
// which reads as a browser warning rather than as part of the product — these replace them with
|
|
21
|
+
// the same awaited call-site shape. Needs styles/dialog.css and a <DialogHost> at the root.
|
|
22
|
+
export { DialogHost, useDialog } from './components/Dialog.jsx';
|
|
23
|
+
// Shared product auth (extracted from ContextualGraph): the engine /v1/auth
|
|
24
|
+
// client (configureAuth({product, engine}) once at boot) + the sign-in form
|
|
25
|
+
// and Google SSO button. Consumers may also deep-import './auth/*'.
|
|
26
|
+
export {
|
|
27
|
+
configureAuth, authConfig, SESSION_EVENT,
|
|
28
|
+
getSession, clearSession, getToken, isAuthed,
|
|
29
|
+
login, register, googleSignIn, requestPasswordReset, switchOrg,
|
|
30
|
+
refreshToken, handleAuthExpired, logout, authFetch, fetchBalance,
|
|
31
|
+
} from './auth/client.js';
|
|
32
|
+
export { AuthForm } from './auth/AuthForm.jsx';
|
|
33
|
+
export { GoogleButton, GOOGLE_ENABLED } from './auth/GoogleButton.jsx';
|
|
34
|
+
// Shared AI-spreadsheet grid (reusable in the Sheets product AND studio Spaces).
|
|
35
|
+
export { SheetGrid, sheetToDelimited, sheetToAoA } from './sheet/SheetGrid.jsx';
|