fi-glass 1.1.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.
@@ -0,0 +1,57 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties, Ref, TextareaHTMLAttributes } from 'react';
3
+
4
+ interface ComposerProps {
5
+ /** Current message value */
6
+ message: string;
7
+ /** Is sending message (disables input) */
8
+ loading?: boolean;
9
+ /** Placeholder text */
10
+ placeholder?: string;
11
+ /** Called on every edit */
12
+ onMessageChange: (value: string) => void;
13
+ /** Called on Enter (without Shift) */
14
+ onSend: () => void;
15
+ /** Max rows before the textarea scrolls */
16
+ maxRows?: number;
17
+ /** Class for the outer area wrapper */
18
+ areaClassName?: string;
19
+ /** Class for the AutoResizeTextarea wrapper */
20
+ wrapperClassName?: string;
21
+ /** Inline style for the input wrapper (e.g. flex-grow so it fills the area). */
22
+ wrapperStyle?: CSSProperties;
23
+ /** Class for the <textarea> itself */
24
+ textareaClassName?: string;
25
+ /**
26
+ * Typed ref to the inner <textarea> (B3-FIGLASS-10) so the owner can manage
27
+ * focus (e.g. refocus after dictation/send/stream) without touching DOM
28
+ * internals.
29
+ */
30
+ textareaRef?: Ref<HTMLTextAreaElement>;
31
+ }
32
+ declare function Composer({ message, loading, placeholder, onMessageChange, onSend, maxRows, areaClassName, wrapperClassName, wrapperStyle, textareaClassName, textareaRef, }: ComposerProps): react.JSX.Element;
33
+
34
+ interface AutoResizeTextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
35
+ /** Max rows before scrolling */
36
+ maxRows?: number;
37
+ /** Show character counter */
38
+ showCounter?: boolean;
39
+ /** Max characters */
40
+ maxLength?: number;
41
+ /** Additional wrapper CSS classes */
42
+ wrapperClassName?: string;
43
+ /**
44
+ * Inline style for the wrapper div. Lets the Composer/surface own the input's
45
+ * layout (e.g. `flex: 1 1 0%` so it fills a flex composer) WITHOUT a consumer
46
+ * reaching into the internal `.relative` wrapper from CSS.
47
+ */
48
+ wrapperStyle?: CSSProperties;
49
+ }
50
+ /**
51
+ * Forwards its ref to the inner <textarea> (B3-FIGLASS-10) so an owner (e.g. the
52
+ * conversation surface) can manage focus through a TYPED handle instead of
53
+ * reaching into this component's internal DOM.
54
+ */
55
+ declare const AutoResizeTextarea: react.ForwardRefExoticComponent<AutoResizeTextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
56
+
57
+ export { AutoResizeTextarea, type AutoResizeTextareaProps, Composer, type ComposerProps };
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+
3
+ // src/composer/AutoResizeTextarea.tsx
4
+ import {
5
+ forwardRef,
6
+ useEffect,
7
+ useImperativeHandle,
8
+ useRef,
9
+ useState
10
+ } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ var AutoResizeTextarea = forwardRef(function AutoResizeTextarea2({
13
+ value,
14
+ onChange,
15
+ maxRows = 5,
16
+ showCounter = false,
17
+ maxLength,
18
+ wrapperClassName = "",
19
+ wrapperStyle,
20
+ className = "",
21
+ ...props
22
+ }, ref) {
23
+ const textareaRef = useRef(null);
24
+ useImperativeHandle(ref, () => textareaRef.current);
25
+ const [rows, setRows] = useState(1);
26
+ useEffect(() => {
27
+ if (!textareaRef.current) return;
28
+ const textarea = textareaRef.current;
29
+ textarea.rows = 1;
30
+ textarea.style.height = "auto";
31
+ const computed = window.getComputedStyle(textarea);
32
+ const parsed = parseFloat(computed.lineHeight);
33
+ const lineHeight = Number.isFinite(parsed) && parsed > 0 ? parsed : 20;
34
+ const newRows = Math.max(
35
+ 1,
36
+ Math.min(Math.ceil(textarea.scrollHeight / lineHeight), maxRows)
37
+ );
38
+ setRows(newRows);
39
+ textarea.rows = newRows;
40
+ textarea.style.height = `${newRows * lineHeight}px`;
41
+ textarea.style.width = "100%";
42
+ }, [value, maxRows]);
43
+ const charCount = typeof value === "string" ? value.length : 0;
44
+ const isNearLimit = maxLength && charCount > maxLength * 0.9;
45
+ const isOverLimit = maxLength && charCount > maxLength;
46
+ return /* @__PURE__ */ jsxs("div", { className: `relative ${wrapperClassName}`, style: wrapperStyle, children: [
47
+ /* @__PURE__ */ jsx(
48
+ "textarea",
49
+ {
50
+ ref: textareaRef,
51
+ value,
52
+ onChange,
53
+ maxLength,
54
+ className: `
55
+ resize-none
56
+ ${className}
57
+ `,
58
+ rows,
59
+ ...props
60
+ }
61
+ ),
62
+ showCounter && maxLength && /* @__PURE__ */ jsxs("div", { className: isOverLimit ? "chat-char-counter-error" : isNearLimit ? "chat-char-counter-warning" : "chat-char-counter-ok", children: [
63
+ charCount,
64
+ "/",
65
+ maxLength
66
+ ] })
67
+ ] });
68
+ });
69
+
70
+ // src/composer/Composer.tsx
71
+ import { jsx as jsx2 } from "react/jsx-runtime";
72
+ function Composer({
73
+ message,
74
+ loading = false,
75
+ placeholder = "Escribe tu mensaje...",
76
+ onMessageChange,
77
+ onSend,
78
+ maxRows = 5,
79
+ areaClassName,
80
+ wrapperClassName,
81
+ wrapperStyle,
82
+ textareaClassName,
83
+ textareaRef
84
+ }) {
85
+ const handleKeyDown = (e) => {
86
+ if (e.key === "Enter" && !e.shiftKey) {
87
+ e.preventDefault();
88
+ onSend();
89
+ }
90
+ };
91
+ return /* @__PURE__ */ jsx2("div", { className: areaClassName, children: /* @__PURE__ */ jsx2(
92
+ AutoResizeTextarea,
93
+ {
94
+ ref: textareaRef,
95
+ value: message,
96
+ onChange: (e) => onMessageChange(e.target.value),
97
+ onKeyDown: handleKeyDown,
98
+ placeholder,
99
+ disabled: loading,
100
+ maxRows,
101
+ showCounter: false,
102
+ wrapperClassName,
103
+ wrapperStyle,
104
+ className: textareaClassName
105
+ }
106
+ ) });
107
+ }
108
+ export {
109
+ AutoResizeTextarea,
110
+ Composer
111
+ };
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/composer/AutoResizeTextarea.tsx","../../src/composer/Composer.tsx"],"sourcesContent":["'use client';\n\n/**\n * fi-glass · AutoResizeTextarea — textarea that grows with content up to maxRows.\n * Extracted verbatim from aurity ChatUtilities on 2026-06-01 (Americio).\n *\n * Pure: React hooks + DOM measurement only. All styling arrives via className /\n * wrapperClassName, so an app dresses it however it likes.\n */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n type CSSProperties,\n type TextareaHTMLAttributes,\n} from 'react';\n\nexport interface AutoResizeTextareaProps\n extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Max rows before scrolling */\n maxRows?: number;\n /** Show character counter */\n showCounter?: boolean;\n /** Max characters */\n maxLength?: number;\n /** Additional wrapper CSS classes */\n wrapperClassName?: string;\n /**\n * Inline style for the wrapper div. Lets the Composer/surface own the input's\n * layout (e.g. `flex: 1 1 0%` so it fills a flex composer) WITHOUT a consumer\n * reaching into the internal `.relative` wrapper from CSS.\n */\n wrapperStyle?: CSSProperties;\n}\n\n/**\n * Forwards its ref to the inner <textarea> (B3-FIGLASS-10) so an owner (e.g. the\n * conversation surface) can manage focus through a TYPED handle instead of\n * reaching into this component's internal DOM.\n */\nexport const AutoResizeTextarea = forwardRef<\n HTMLTextAreaElement,\n AutoResizeTextareaProps\n>(function AutoResizeTextarea(\n {\n value,\n onChange,\n maxRows = 5,\n showCounter = false,\n maxLength,\n wrapperClassName = '',\n wrapperStyle,\n className = '',\n ...props\n },\n ref,\n) {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);\n const [rows, setRows] = useState(1);\n\n // Auto-resize on content change\n useEffect(() => {\n if (!textareaRef.current) return;\n\n const textarea = textareaRef.current;\n // B3-FIGLASS-16: reset to the MINIMAL state before measuring. The rows\n // attribute left over from the previous render sets the textarea's\n // intrinsic height, and scrollHeight can never report less than that — so\n // a textarea that had grown to 5 rows kept measuring 5 rows forever, even\n // after its content was deleted (grew on type, never shrank on delete).\n // One row + auto height makes scrollHeight track the content alone.\n textarea.rows = 1;\n textarea.style.height = 'auto';\n\n // B3-FIGLASS-15: measure the REAL line height instead of assuming 20px.\n // The old hardcode made an empty textarea compute ceil(24/20) = 2 rows with\n // the default 16px/24px font — a permanently inflated empty composer. The\n // floor of 1 row also guards jsdom (scrollHeight 0) and any glitched\n // measurement from ever collapsing the input to 0.\n const computed = window.getComputedStyle(textarea);\n const parsed = parseFloat(computed.lineHeight);\n const lineHeight = Number.isFinite(parsed) && parsed > 0 ? parsed : 20;\n const newRows = Math.max(\n 1,\n Math.min(Math.ceil(textarea.scrollHeight / lineHeight), maxRows),\n );\n\n setRows(newRows);\n // Restore rows imperatively too: when newRows equals the previous render's\n // value React skips the attribute, which would leave the reset `1` behind.\n textarea.rows = newRows;\n textarea.style.height = `${newRows * lineHeight}px`;\n // Fill the wrapper width. Set imperatively (not via the style prop) so it\n // never collides with the imperative height above on re-render — a composer\n // textarea should always span its container.\n textarea.style.width = '100%';\n }, [value, maxRows]);\n\n const charCount = typeof value === 'string' ? value.length : 0;\n const isNearLimit = maxLength && charCount > maxLength * 0.9;\n const isOverLimit = maxLength && charCount > maxLength;\n\n return (\n <div className={`relative ${wrapperClassName}`} style={wrapperStyle}>\n <textarea\n ref={textareaRef}\n value={value}\n onChange={onChange}\n maxLength={maxLength}\n className={`\n resize-none\n ${className}\n `}\n rows={rows}\n {...props}\n />\n\n {/* Character counter */}\n {showCounter && maxLength && (\n <div className={isOverLimit ? 'chat-char-counter-error' : isNearLimit ? 'chat-char-counter-warning' : 'chat-char-counter-ok'}>\n {charCount}/{maxLength}\n </div>\n )}\n </div>\n );\n});\n","'use client';\n\n/**\n * fi-glass · Composer — chat text input (auto-resize + Enter-to-send).\n * Extracted from aurity ChatWidgetInput on 2026-06-01 (Americio).\n *\n * Fully callback-driven and voice-agnostic: the mic/send live OUTSIDE the\n * composer (in the app's toolbar), so \"composer without voice\" is the default\n * state — render this alone and there is no voice anywhere.\n *\n * CONFIGURABILITY (fire test): the app controls value/submit via props and\n * dresses every element via className props — no fi-glass edit needed to restyle\n * or to drop voice (there is none to drop here).\n */\n\nimport { type CSSProperties, type KeyboardEvent, type Ref } from 'react';\nimport { AutoResizeTextarea } from './AutoResizeTextarea';\n\nexport interface ComposerProps {\n /** Current message value */\n message: string;\n /** Is sending message (disables input) */\n loading?: boolean;\n /** Placeholder text */\n placeholder?: string;\n /** Called on every edit */\n onMessageChange: (value: string) => void;\n /** Called on Enter (without Shift) */\n onSend: () => void;\n /** Max rows before the textarea scrolls */\n maxRows?: number;\n /** Class for the outer area wrapper */\n areaClassName?: string;\n /** Class for the AutoResizeTextarea wrapper */\n wrapperClassName?: string;\n /** Inline style for the input wrapper (e.g. flex-grow so it fills the area). */\n wrapperStyle?: CSSProperties;\n /** Class for the <textarea> itself */\n textareaClassName?: string;\n /**\n * Typed ref to the inner <textarea> (B3-FIGLASS-10) so the owner can manage\n * focus (e.g. refocus after dictation/send/stream) without touching DOM\n * internals.\n */\n textareaRef?: Ref<HTMLTextAreaElement>;\n}\n\nexport function Composer({\n message,\n loading = false,\n placeholder = 'Escribe tu mensaje...',\n onMessageChange,\n onSend,\n maxRows = 5,\n areaClassName,\n wrapperClassName,\n wrapperStyle,\n textareaClassName,\n textareaRef,\n}: ComposerProps) {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n onSend();\n }\n };\n\n return (\n <div className={areaClassName}>\n <AutoResizeTextarea\n ref={textareaRef}\n value={message}\n onChange={(e) => onMessageChange(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={loading}\n maxRows={maxRows}\n showCounter={false}\n wrapperClassName={wrapperClassName}\n wrapperStyle={wrapperStyle}\n className={textareaClassName}\n />\n </div>\n );\n}\n"],"mappings":";AAUA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AA0FD,cAeE,YAfF;AAjEC,IAAM,qBAAqB,WAGhC,SAASA,oBACT;AAAA,EACE;AAAA,EACA;AAAA,EACA,UAAU;AAAA,E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5DK,gBAAAC,YAAA;AAtBC,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,UAAU;AAAA,EACV,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkB;AAChB,QAAM,gBAAgB,CAAC,MAAqB;AAC1C,QAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,QAAE,eAAe;AACjB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SACE,gBAAAA,KAAC,SAAI,WAAW,eACd,0BAAAA;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,OAAO;AAAA,MACP,UAAU,CAAC,MAAM,gBAAgB,EAAE,OAAO,KAAK;AAAA,MAC/C,WAAW;AAAA,MACX;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA,WAAW;AAAA;AAAA,EACb,GACF;AAEJ;","names":["AutoResizeTextarea","jsx"]}
@@ -0,0 +1,80 @@
1
+ import { ConversationLibrary, ConversationSummary, ConversationRecord, ChatMessage } from '@free-intelligence/core';
2
+
3
+ /**
4
+ * IndexedDBConversationLibrary — a browser ConversationLibrary (DD-002B1.2).
5
+ *
6
+ * Implements the @free-intelligence/core ConversationLibrary contract over
7
+ * IndexedDB, zero external dependencies (a small promisified wrapper). This is
8
+ * the first concrete adapter for the local-first transcript persistence the
9
+ * core contract describes; later layers may add a backend adapter against the
10
+ * SAME contract.
11
+ *
12
+ * Privacy: this adapter is a dumb store — it persists exactly the records it is
13
+ * given. Sanitization (role/content/timestamp only, no tokens / metadata /
14
+ * glass-box) happens upstream in core helpers, which the conversation hook uses
15
+ * to build every record before `put`.
16
+ *
17
+ * SSR safety: the constructor never touches `indexedDB` (only stores config), so
18
+ * instantiating during a server render is harmless. Any method that needs the DB
19
+ * rejects with a CLEAR error when IndexedDB is unavailable (server render /
20
+ * storage disabled) — it never fails silently.
21
+ */
22
+
23
+ interface IndexedDBConversationLibraryOptions {
24
+ /** Database name. Default: `free-intelligence-conversations`. */
25
+ dbName?: string;
26
+ /** Object store name. Default: `conversations`. */
27
+ storeName?: string;
28
+ }
29
+ declare class IndexedDBConversationLibrary implements ConversationLibrary {
30
+ private readonly dbName;
31
+ private readonly storeName;
32
+ private dbPromise;
33
+ constructor(options?: IndexedDBConversationLibraryOptions);
34
+ /** Open (and lazily create) the database. Rejects clearly if unavailable. */
35
+ private open;
36
+ /** Run one request inside a transaction and resolve with its result. */
37
+ private run;
38
+ /** All conversations as light summaries, newest `updatedAt` first. */
39
+ list(): Promise<ConversationSummary[]>;
40
+ /** The full record for `id`, or `null` if none. */
41
+ get(id: string): Promise<ConversationRecord | null>;
42
+ /** Insert or replace a record by its `id`. */
43
+ put(record: ConversationRecord): Promise<void>;
44
+ /** Remove the record for `id` (no-op if absent). */
45
+ delete(id: string): Promise<void>;
46
+ /** Remove every stored conversation. */
47
+ clear(): Promise<void>;
48
+ }
49
+
50
+ interface UseConversationLibraryOptions {
51
+ /** Mint a new conversation id. Default: `crypto.randomUUID`. Injectable for tests. */
52
+ idFactory?: () => string;
53
+ /** ISO timestamp provider for createdAt/updatedAt. Default: wall clock. Injectable for tests. */
54
+ now?: () => string;
55
+ }
56
+ interface ConversationLibraryState {
57
+ /** False until the first hydration from storage finishes. */
58
+ ready: boolean;
59
+ /** All conversations as light summaries, newest first (for the sidebar). */
60
+ conversations: ConversationSummary[];
61
+ /** The active conversation id (doubles as the backend session_id). */
62
+ activeId: string | null;
63
+ /** The active conversation's messages (seed for the live thread). */
64
+ activeMessages: ChatMessage[];
65
+ /** The active conversation's full record, or null if not yet persisted. */
66
+ activeRecord: ConversationRecord | null;
67
+ /** Start a fresh conversation: new id, empty thread, NOT persisted until first message. */
68
+ newConversation: () => void;
69
+ /** Load and activate an existing conversation by id. Throws clearly if it is gone. */
70
+ switchConversation: (id: string) => Promise<void>;
71
+ /** Delete a conversation; if it was active, activate the next most recent (or a fresh one). */
72
+ deleteConversation: (id: string) => Promise<void>;
73
+ /** Persist the active conversation's messages (no-op for an empty thread). */
74
+ persist: (messages: ChatMessage[]) => Promise<void>;
75
+ /** Re-read the summary list from storage. */
76
+ refresh: () => Promise<void>;
77
+ }
78
+ declare function useConversationLibrary(library: ConversationLibrary, options?: UseConversationLibraryOptions): ConversationLibraryState;
79
+
80
+ export { type ConversationLibraryState, IndexedDBConversationLibrary, type IndexedDBConversationLibraryOptions, type UseConversationLibraryOptions, useConversationLibrary };
@@ -0,0 +1,207 @@
1
+ 'use client';
2
+
3
+ // src/conversation/IndexedDBConversationLibrary.ts
4
+ import { summarizeConversation } from "@free-intelligence/core";
5
+ var DEFAULT_DB_NAME = "free-intelligence-conversations";
6
+ var DEFAULT_STORE_NAME = "conversations";
7
+ var DB_VERSION = 1;
8
+ var UPDATED_AT_INDEX = "by_updatedAt";
9
+ function indexedDBUnavailable() {
10
+ return typeof indexedDB === "undefined";
11
+ }
12
+ function unavailableError() {
13
+ return new Error(
14
+ "IndexedDBConversationLibrary: IndexedDB is not available in this environment (server-side render or storage disabled). Use this adapter only in the browser."
15
+ );
16
+ }
17
+ var IndexedDBConversationLibrary = class {
18
+ constructor(options = {}) {
19
+ this.dbPromise = null;
20
+ this.dbName = options.dbName ?? DEFAULT_DB_NAME;
21
+ this.storeName = options.storeName ?? DEFAULT_STORE_NAME;
22
+ }
23
+ /** Open (and lazily create) the database. Rejects clearly if unavailable. */
24
+ open() {
25
+ if (indexedDBUnavailable()) return Promise.reject(unavailableError());
26
+ if (!this.dbPromise) {
27
+ this.dbPromise = new Promise((resolve, reject) => {
28
+ const request = indexedDB.open(this.dbName, DB_VERSION);
29
+ request.onupgradeneeded = () => {
30
+ const db = request.result;
31
+ if (!db.objectStoreNames.contains(this.storeName)) {
32
+ const store = db.createObjectStore(this.storeName, { keyPath: "id" });
33
+ store.createIndex(UPDATED_AT_INDEX, "updatedAt", { unique: false });
34
+ }
35
+ };
36
+ request.onsuccess = () => resolve(request.result);
37
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB open failed"));
38
+ });
39
+ }
40
+ return this.dbPromise;
41
+ }
42
+ /** Run one request inside a transaction and resolve with its result. */
43
+ async run(mode, makeRequest) {
44
+ const db = await this.open();
45
+ return new Promise((resolve, reject) => {
46
+ const transaction = db.transaction(this.storeName, mode);
47
+ const request = makeRequest(transaction.objectStore(this.storeName));
48
+ request.onsuccess = () => resolve(request.result);
49
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
50
+ });
51
+ }
52
+ /** All conversations as light summaries, newest `updatedAt` first. */
53
+ async list() {
54
+ const records = await this.run(
55
+ "readonly",
56
+ (store) => store.getAll()
57
+ );
58
+ return records.map(summarizeConversation).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
59
+ }
60
+ /** The full record for `id`, or `null` if none. */
61
+ async get(id) {
62
+ const record = await this.run(
63
+ "readonly",
64
+ (store) => store.get(id)
65
+ );
66
+ return record ?? null;
67
+ }
68
+ /** Insert or replace a record by its `id`. */
69
+ async put(record) {
70
+ await this.run("readwrite", (store) => store.put(record));
71
+ }
72
+ /** Remove the record for `id` (no-op if absent). */
73
+ async delete(id) {
74
+ await this.run("readwrite", (store) => store.delete(id));
75
+ }
76
+ /** Remove every stored conversation. */
77
+ async clear() {
78
+ await this.run("readwrite", (store) => store.clear());
79
+ }
80
+ };
81
+
82
+ // src/conversation/useConversationLibrary.ts
83
+ import { useCallback, useEffect, useState } from "react";
84
+ import {
85
+ CONVERSATION_SCHEMA_VERSION,
86
+ deriveConversationTitle,
87
+ deriveConversationPreview,
88
+ sanitizeConversationMessage
89
+ } from "@free-intelligence/core";
90
+ function useConversationLibrary(library, options = {}) {
91
+ const idFactory = options.idFactory ?? (() => crypto.randomUUID());
92
+ const nowFn = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
93
+ const [ready, setReady] = useState(false);
94
+ const [conversations, setConversations] = useState([]);
95
+ const [activeId, setActiveId] = useState(null);
96
+ const [activeMessages, setActiveMessages] = useState([]);
97
+ const [activeRecord, setActiveRecord] = useState(null);
98
+ const refresh = useCallback(async () => {
99
+ setConversations(await library.list());
100
+ }, [library]);
101
+ useEffect(() => {
102
+ let cancelled = false;
103
+ void (async () => {
104
+ try {
105
+ const list = await library.list();
106
+ if (cancelled) return;
107
+ setConversations(list);
108
+ if (list.length > 0) {
109
+ const record = await library.get(list[0].id);
110
+ if (cancelled) return;
111
+ setActiveId(list[0].id);
112
+ setActiveMessages(record?.messages ?? []);
113
+ setActiveRecord(record ?? null);
114
+ } else {
115
+ setActiveId(idFactory());
116
+ setActiveMessages([]);
117
+ setActiveRecord(null);
118
+ }
119
+ } finally {
120
+ if (!cancelled) setReady(true);
121
+ }
122
+ })();
123
+ return () => {
124
+ cancelled = true;
125
+ };
126
+ }, [library]);
127
+ const newConversation = useCallback(() => {
128
+ setActiveId(idFactory());
129
+ setActiveMessages([]);
130
+ setActiveRecord(null);
131
+ }, [idFactory]);
132
+ const switchConversation = useCallback(
133
+ async (id) => {
134
+ const record = await library.get(id);
135
+ if (!record) {
136
+ await refresh();
137
+ throw new Error(
138
+ `useConversationLibrary: conversation "${id}" not found`
139
+ );
140
+ }
141
+ setActiveId(id);
142
+ setActiveMessages(record.messages);
143
+ setActiveRecord(record);
144
+ },
145
+ [library, refresh]
146
+ );
147
+ const persist = useCallback(
148
+ async (messages) => {
149
+ if (messages.length === 0) return;
150
+ const id = activeId ?? idFactory();
151
+ const now = nowFn();
152
+ const createdAt = activeRecord?.id === id ? activeRecord.createdAt : now;
153
+ const clean = messages.map(sanitizeConversationMessage);
154
+ const record = {
155
+ id,
156
+ title: deriveConversationTitle(clean),
157
+ createdAt,
158
+ updatedAt: now,
159
+ messages: clean,
160
+ preview: deriveConversationPreview(clean),
161
+ schemaVersion: CONVERSATION_SCHEMA_VERSION
162
+ };
163
+ await library.put(record);
164
+ setActiveId(id);
165
+ setActiveMessages(record.messages);
166
+ setActiveRecord(record);
167
+ await refresh();
168
+ },
169
+ [activeId, activeRecord, idFactory, nowFn, library, refresh]
170
+ );
171
+ const deleteConversation = useCallback(
172
+ async (id) => {
173
+ await library.delete(id);
174
+ const list = await library.list();
175
+ setConversations(list);
176
+ if (id !== activeId) return;
177
+ if (list.length > 0) {
178
+ const record = await library.get(list[0].id);
179
+ setActiveId(list[0].id);
180
+ setActiveMessages(record?.messages ?? []);
181
+ setActiveRecord(record ?? null);
182
+ } else {
183
+ setActiveId(idFactory());
184
+ setActiveMessages([]);
185
+ setActiveRecord(null);
186
+ }
187
+ },
188
+ [library, activeId, idFactory]
189
+ );
190
+ return {
191
+ ready,
192
+ conversations,
193
+ activeId,
194
+ activeMessages,
195
+ activeRecord,
196
+ newConversation,
197
+ switchConversation,
198
+ deleteConversation,
199
+ persist,
200
+ refresh
201
+ };
202
+ }
203
+ export {
204
+ IndexedDBConversationLibrary,
205
+ useConversationLibrary
206
+ };
207
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/conversation/IndexedDBConversationLibrary.ts","../../src/conversation/useConversationLibrary.ts"],"sourcesContent":["/**\n * IndexedDBConversationLibrary — a browser ConversationLibrary (DD-002B1.2).\n *\n * Implements the @free-intelligence/core ConversationLibrary contract over\n * IndexedDB, zero external dependencies (a small promisified wrapper). This is\n * the first concrete adapter for the local-first transcript persistence the\n * core contract describes; later layers may add a backend adapter against the\n * SAME contract.\n *\n * Privacy: this adapter is a dumb store — it persists exactly the records it is\n * given. Sanitization (role/content/timestamp only, no tokens / metadata /\n * glass-box) happens upstream in core helpers, which the conversation hook uses\n * to build every record before `put`.\n *\n * SSR safety: the constructor never touches `indexedDB` (only stores config), so\n * instantiating during a server render is harmless. Any method that needs the DB\n * rejects with a CLEAR error when IndexedDB is unavailable (server render /\n * storage disabled) — it never fails silently.\n */\n\nimport type {\n ConversationLibrary,\n ConversationRecord,\n ConversationSummary,\n} from '@free-intelligence/core';\nimport { summarizeConversation } from '@free-intelligence/core';\n\nexport interface IndexedDBConversationLibraryOptions {\n /** Database name. Default: `free-intelligence-conversations`. */\n dbName?: string;\n /** Object store name. Default: `conversations`. */\n storeName?: string;\n}\n\nconst DEFAULT_DB_NAME = 'free-intelligence-conversations';\nconst DEFAULT_STORE_NAME = 'conversations';\nconst DB_VERSION = 1;\nconst UPDATED_AT_INDEX = 'by_updatedAt';\n\nfunction indexedDBUnavailable(): boolean {\n return typeof indexedDB === 'undefined';\n}\n\nfunction unavailableError(): Error {\n return new Error(\n 'IndexedDBConversationLibrary: IndexedDB is not available in this ' +\n 'environment (server-side render or storage disabled). Use this adapter ' +\n 'only in the browser.',\n );\n}\n\nexport class IndexedDBConversationLibrary implements ConversationLibrary {\n private readonly dbName: string;\n private readonly storeName: string;\n private dbPromise: Promise<IDBDatabase> | null = null;\n\n constructor(options: IndexedDBConversationLibraryOptions = {}) {\n this.dbName = options.dbName ?? DEFAULT_DB_NAME;\n this.storeName = options.storeName ?? DEFAULT_STORE_NAME;\n }\n\n /** Open (and lazily create) the database. Rejects clearly if unavailable. */\n private open(): Promise<IDBDatabase> {\n if (indexedDBUnavailable()) return Promise.reject(unavailableError());\n if (!this.dbPromise) {\n this.dbPromise = new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(this.dbName, DB_VERSION);\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db.objectStoreNames.contains(this.storeName)) {\n const store = db.createObjectStore(this.storeName, { keyPath: 'id' });\n store.createIndex(UPDATED_AT_INDEX, 'updatedAt', { unique: false });\n }\n };\n request.onsuccess = () => resolve(request.result);\n request.onerror = () =>\n reject(request.error ?? new Error('IndexedDB open failed'));\n });\n }\n return this.dbPromise;\n }\n\n /** Run one request inside a transaction and resolve with its result. */\n private async run<T>(\n mode: IDBTransactionMode,\n makeRequest: (store: IDBObjectStore) => IDBRequest,\n ): Promise<T> {\n const db = await this.open();\n return new Promise<T>((resolve, reject) => {\n const transaction = db.transaction(this.storeName, mode);\n const request = makeRequest(transaction.objectStore(this.storeName));\n request.onsuccess = () => resolve(request.result as T);\n request.onerror = () =>\n reject(request.error ?? new Error('IndexedDB request failed'));\n });\n }\n\n /** All conversations as light summaries, newest `updatedAt` first. */\n async list(): Promise<ConversationSummary[]> {\n const records = await this.run<ConversationRecord[]>('readonly', (store) =>\n store.getAll(),\n );\n return records\n .map(summarizeConversation)\n .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n }\n\n /** The full record for `id`, or `null` if none. */\n async get(id: string): Promise<ConversationRecord | null> {\n const record = await this.run<ConversationRecord | undefined>(\n 'readonly',\n (store) => store.get(id),\n );\n return record ?? null;\n }\n\n /** Insert or replace a record by its `id`. */\n async put(record: ConversationRecord): Promise<void> {\n await this.run('readwrite', (store) => store.put(record));\n }\n\n /** Remove the record for `id` (no-op if absent). */\n async delete(id: string): Promise<void> {\n await this.run('readwrite', (store) => store.delete(id));\n }\n\n /** Remove every stored conversation. */\n async clear(): Promise<void> {\n await this.run('readwrite', (store) => store.clear());\n }\n}\n","'use client';\n\n/**\n * useConversationLibrary — the reusable multi-conversation manager (DD-002B1.2).\n *\n * Wraps any ConversationLibrary (e.g. IndexedDBConversationLibrary) into the\n * state a sidebar needs: the list of summaries, the active conversation's id +\n * messages, and the lifecycle (new / switch / delete / persist). It owns the\n * conversation identity; the active id is what a consumer (og118) will reuse as\n * the backend session_id so the local transcript and the server thread share one\n * identity.\n *\n * It does NOT render anything and takes no transport/agent dependency — the app\n * composes it with `useAgentConversation` (live thread) and builds the sidebar\n * UI itself. Keeping the manager here (not in the consumer) is the framework-first\n * answer to DD-002: every future shell inherits conversation persistence.\n *\n * Privacy: every persisted record is built through core helpers\n * (`sanitizeConversationMessage` + title/preview derivation), so only\n * role/content/timestamp reach storage — never tokens, metadata, tool payloads\n * or glass-box state.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport {\n type ChatMessage,\n type ConversationLibrary,\n type ConversationRecord,\n type ConversationSummary,\n CONVERSATION_SCHEMA_VERSION,\n deriveConversationTitle,\n deriveConversationPreview,\n sanitizeConversationMessage,\n} from '@free-intelligence/core';\n\nexport interface UseConversationLibraryOptions {\n /** Mint a new conversation id. Default: `crypto.randomUUID`. Injectable for tests. */\n idFactory?: () => string;\n /** ISO timestamp provider for createdAt/updatedAt. Default: wall clock. Injectable for tests. */\n now?: () => string;\n}\n\nexport interface ConversationLibraryState {\n /** False until the first hydration from storage finishes. */\n ready: boolean;\n /** All conversations as light summaries, newest first (for the sidebar). */\n conversations: ConversationSummary[];\n /** The active conversation id (doubles as the backend session_id). */\n activeId: string | null;\n /** The active conversation's messages (seed for the live thread). */\n activeMessages: ChatMessage[];\n /** The active conversation's full record, or null if not yet persisted. */\n activeRecord: ConversationRecord | null;\n /** Start a fresh conversation: new id, empty thread, NOT persisted until first message. */\n newConversation: () => void;\n /** Load and activate an existing conversation by id. Throws clearly if it is gone. */\n switchConversation: (id: string) => Promise<void>;\n /** Delete a conversation; if it was active, activate the next most recent (or a fresh one). */\n deleteConversation: (id: string) => Promise<void>;\n /** Persist the active conversation's messages (no-op for an empty thread). */\n persist: (messages: ChatMessage[]) => Promise<void>;\n /** Re-read the summary list from storage. */\n refresh: () => Promise<void>;\n}\n\nexport function useConversationLibrary(\n library: ConversationLibrary,\n options: UseConversationLibraryOptions = {},\n): ConversationLibraryState {\n const idFactory = options.idFactory ?? (() => crypto.randomUUID());\n const nowFn = options.now ?? (() => new Date().toISOString());\n\n const [ready, setReady] = useState(false);\n const [conversations, setConversations] = useState<ConversationSummary[]>([]);\n const [activeId, setActiveId] = useState<string | null>(null);\n const [activeMessages, setActiveMessages] = useState<ChatMessage[]>([]);\n const [activeRecord, setActiveRecord] = useState<ConversationRecord | null>(null);\n\n const refresh = useCallback(async () => {\n setConversations(await library.list());\n }, [library]);\n\n // Mount: hydrate from storage. Activate the most recent conversation, or seed a\n // fresh in-memory id (NOT persisted) when there is nothing stored yet.\n useEffect(() => {\n let cancelled = false;\n void (async () => {\n try {\n const list = await library.list();\n if (cancelled) return;\n setConversations(list);\n if (list.length > 0) {\n const record = await library.get(list[0].id);\n if (cancelled) return;\n setActiveId(list[0].id);\n setActiveMessages(record?.messages ?? []);\n setActiveRecord(record ?? null);\n } else {\n setActiveId(idFactory());\n setActiveMessages([]);\n setActiveRecord(null);\n }\n } finally {\n if (!cancelled) setReady(true);\n }\n })();\n return () => {\n cancelled = true;\n };\n // Hydrate once per library instance; idFactory is stable enough for mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [library]);\n\n const newConversation = useCallback(() => {\n setActiveId(idFactory());\n setActiveMessages([]);\n setActiveRecord(null);\n }, [idFactory]);\n\n const switchConversation = useCallback(\n async (id: string) => {\n const record = await library.get(id);\n if (!record) {\n // Stale summary (record deleted elsewhere): refresh and surface clearly.\n await refresh();\n throw new Error(\n `useConversationLibrary: conversation \"${id}\" not found`,\n );\n }\n setActiveId(id);\n setActiveMessages(record.messages);\n setActiveRecord(record);\n },\n [library, refresh],\n );\n\n const persist = useCallback(\n async (messages: ChatMessage[]) => {\n // Never persist an empty thread — a brand-new conversation stays in-memory\n // until its first real message.\n if (messages.length === 0) return;\n const id = activeId ?? idFactory();\n const now = nowFn();\n // Preserve createdAt when updating the same record; otherwise it's new.\n const createdAt = activeRecord?.id === id ? activeRecord.createdAt : now;\n const clean = messages.map(sanitizeConversationMessage);\n const record: ConversationRecord = {\n id,\n title: deriveConversationTitle(clean),\n createdAt,\n updatedAt: now,\n messages: clean,\n preview: deriveConversationPreview(clean),\n schemaVersion: CONVERSATION_SCHEMA_VERSION,\n };\n await library.put(record);\n setActiveId(id);\n setActiveMessages(record.messages);\n setActiveRecord(record);\n await refresh();\n },\n [activeId, activeRecord, idFactory, nowFn, library, refresh],\n );\n\n const deleteConversation = useCallback(\n async (id: string) => {\n await library.delete(id);\n const list = await library.list();\n setConversations(list);\n if (id !== activeId) return;\n // Deleted the active one: fall back to the next most recent, or a fresh id.\n if (list.length > 0) {\n const record = await library.get(list[0].id);\n setActiveId(list[0].id);\n setActiveMessages(record?.messages ?? []);\n setActiveRecord(record ?? null);\n } else {\n setActiveId(idFactory());\n setActiveMessages([]);\n setActiveRecord(null);\n }\n },\n [library, activeId, idFactory],\n );\n\n return {\n ready,\n conversations,\n activeId,\n activeMessages,\n activeRecord,\n newConversation,\n switchConversation,\n deleteConversation,\n persist,\n refresh,\n };\n}\n"],"mappings":";AAyBA,SAAS,6BAA6B;AAStC,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;AAC3B,IAAM,aAAa;AACnB,IAAM,mBAAmB;AAEzB,SAAS,uBAAgC;AACvC,SAAO,OAAO,cAAc;AAC9B;AAEA,SAAS,mBAA0B;AACjC,SAAO,IAAI;AAAA,IACT;AAAA,EAGF;AACF;AAEO,IAAM,+BAAN,MAAkE;AAAA,EAKvE,YAAY,UAA+C,CAAC,GAAG;AAF/D,SAAQ,YAAyC;AAG/C,SAAK,SAAS,QAAQ,UAAU;AAChC,SAAK,YAAY,QAAQ,aAAa;AAAA,EACxC;AAAA;AAAA,EAGQ,OAA6B;AACnC,QAAI,qBAAqB,EAAG,QAAO,QAAQ,OAAO,iBAAiB,CAAC;AACpE,QAAI,CAAC,KAAK,WAAW;AACnB,WAAK,YAAY,IAAI,QAAqB,CAAC,SAAS,WAAW;AAC7D,cAAM,UAAU,UAAU,KAAK,KAAK,QAAQ,UAAU;AACtD,gBAAQ,kBAAkB,MAAM;AAC9B,gBAAM,KAAK,QAAQ;AACnB,cAAI,CAAC,GAAG,iBAAiB,SAAS,KAAK,SAAS,GAAG;AACjD,kBAAM,QAAQ,GAAG,kBAAkB,KAAK,WAAW,EAAE,SAAS,KAAK,CAAC;AACpE,kBAAM,YAAY,kBAAkB,aAAa,EAAE,QAAQ,MAAM,CAAC;AAAA,UACpE;AAAA,QACF;AACA,gBAAQ,YAAY,MAAM,QAAQ,QAAQ,MAAM;AAChD,gBAAQ,UAAU,MAChB,OAAO,QAAQ,SAAS,IAAI,MAAM,uBAAuB,CAAC;AAAA,MAC9D,CAAC;AAAA,IACH;A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AAE;AACtB,0BAAkB,QAAQ,YAAY,CAAC,CAAC;AACxC,wBAAgB,UAAU,IAAI;AAAA,MAChC,OAAO;AACL,oBAAY,UAAU,CAAC;AACvB,0BAAkB,CAAC,CAAC;AACpB,wBAAgB,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,SAAS,UAAU,SAAS;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,19 @@
1
+ import { ThemeTokens } from '@free-intelligence/core';
2
+
3
+ /**
4
+ * glassTheme — the concrete values that fill core's ThemeTokens slots for the
5
+ * `fi-glass` material.
6
+ *
7
+ * The runtime CSS lives next to this file (tokens.css / glass.css) and emits the
8
+ * same values as `--glass-*` custom properties. This object is the typed mirror:
9
+ * it gives programmatic access to the values and lets future materials
10
+ * (fi-slate, fi-paper, …) be diffed against the very same slot shape.
11
+ *
12
+ * NOTE: values are intentionally duplicated between this object and tokens.css
13
+ * during phase 1 (CSS is the runtime source of truth; this is documentation +
14
+ * typing). A later phase may generate the CSS from this object to remove the
15
+ * duplication — deliberately out of scope here.
16
+ */
17
+ declare const glassTheme: ThemeTokens;
18
+
19
+ export { glassTheme as g };
@@ -0,0 +1,9 @@
1
+ export { g as glassTheme } from './glass-theme-D-leVuKb.js';
2
+ export { CollapsibleText, CollapsibleTextProps, CopyButton, CopyButtonProps, MessageBubble, MessageBubbleProps, MessageContent, MessageContentProps, MessageList, MessageListGroup, MessageListProps, markdownStyles, messageStyles, normalizeStreamedMarkdown } from './messages/index.js';
3
+ export { AutoResizeTextarea, AutoResizeTextareaProps, Composer, ComposerProps } from './composer/index.js';
4
+ export { AUDIO_QUEUE_DEFAULTS, AudioArtifact, AudioArtifactState, AudioDraftPlayer, AudioDraftPlayerProps, AudioElementLike, AudioPlayer, AudioPlayerController, AudioPlayerOptions, AudioPlayerProps, AudioPlayerState, AudioPlayerStatus, AudioQueueItem, AudioQueueItemProps, AudioQueuePanel, AudioQueuePanelProps, AudioQueuePolicy, AudioQueueStore, AudioQueueStoreOptions, AudioVisualizer, AudioVisualizerProps, AudioVisualizerVariant, BUTTON_SIZES, ButtonSize, ButtonSizeConfig, COLOR_THEMES, ColorTheme, ComposerMicSlot, ComposerMicSlotProps, PulseConfig, PulseRings, PulseRingsProps, PulseStyle, RecordingButton, RecordingButtonProps, RecordingStateType, RecordingTimer, RecordingTimerProps, RichAudioPlayer, RichAudioPlayerProps, STATUS_TEXT_EN, STATUS_TEXT_ES, SpeakButton, SpeakButtonProps, StateColors, StatusText, StatusTextConfig, StatusTextProps, StoredAudioArtifact, UseAudioPlayerOptions, UseAudioPlayerReturn, UseAudioQueueOptions, UseAudioQueueReturn, UseDictationOptions, UseDictationReturn, UseDurableRecordingOptions, UseDurableRecordingReturn, UseVoiceOptions, UseVoiceReturn, VoiceMicButton, artifactLabel, createAudioPlayer, formatArtifactDuration, formatArtifactSize, formatPlaybackTime, formatRecordingTime, isPending, isTerminal, makeArtifactId, makeRecorder, mergeWavBlobs, normalizeLevels, resampleLevels, useAudioAnalysis, useAudioPlayer, useAudioQueue, useDictation, useDurableRecording, useRecorder, useVoice } from './voice/index.js';
5
+ export { AnimationConfig, BreakpointMatches, Breakpoints, CHAT_BREAKPOINTS, ChatBehavior, ChatBreakpoints, ChatConfig, ChatContent, ChatContentProps, ChatFilePreview, ChatFilePreviewProps, ChatNavDest, ChatStartScreen, ChatStartScreenProps, ChatSurface, ChatSurfaceProps, ChatTheme, ChatToolbar, ChatToolbarProps, ChatViewMode, ChatWidget, ChatWidgetContainer, ChatWidgetContainerProps, ChatWidgetHeader, ChatWidgetHeaderProps, ChatWidgetProps, FloatingButton, FloatingButtonProps, PersonaType, ResponseMode, ShellStreamingState, TimestampConfig, UploadStatus, UseChatWidgetStateOptions, UseChatWidgetStateReturn, UseMediaQueryOptions, VoiceRecordingState, clearMediaQueryCache, defaultAnimationConfig, defaultBehavior, defaultChatConfig, defaultTheme, defaultTimestampConfig, mergeChatConfig, useBreakpoints, useChatWidgetState, useMediaQuery } from './shell/index.js';
6
+ export { PersonaSelector, PersonaSelectorProps, PersonaSlotContext } from './persona-selector/index.js';
7
+ import '@free-intelligence/core';
8
+ import 'react';
9
+ import 'lucide-react';