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.
- package/LICENSE +77 -0
- package/README.md +162 -0
- package/dist/agent/index.d.ts +399 -0
- package/dist/agent/index.js +1979 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/composer/index.d.ts +57 -0
- package/dist/composer/index.js +112 -0
- package/dist/composer/index.js.map +1 -0
- package/dist/conversation/index.d.ts +80 -0
- package/dist/conversation/index.js +207 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/glass-theme-D-leVuKb.d.ts +19 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4316 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/index.d.ts +213 -0
- package/dist/messages/index.js +337 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/persona-selector/index.d.ts +54 -0
- package/dist/persona-selector/index.js +215 -0
- package/dist/persona-selector/index.js.map +1 -0
- package/dist/shell/index.d.ts +429 -0
- package/dist/shell/index.js +1566 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/theme/index.d.ts +58 -0
- package/dist/theme/index.js +38 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/voice/index.d.ts +790 -0
- package/dist/voice/index.js +2591 -0
- package/dist/voice/index.js.map +1 -0
- package/package.json +85 -0
- package/src/theme/glass-chat-preset.ts +74 -0
- package/src/theme/glass-chat.css +217 -0
- package/src/theme/glass-theme.ts +26 -0
- package/src/theme/glass.css +27 -0
- package/src/theme/index.css +3 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/tokens.css +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Required Notice: Copyright 2026 Bernard Uriza Orozco
|
|
2
|
+
Required Notice: Commercial licensing available — contact bernarduriza@gmail.com
|
|
3
|
+
Required Notice: Source — https://github.com/BernardUriza/free-intelligence
|
|
4
|
+
|
|
5
|
+
# PolyForm Noncommercial License 1.0.0
|
|
6
|
+
|
|
7
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
8
|
+
|
|
9
|
+
## Acceptance
|
|
10
|
+
|
|
11
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
12
|
+
|
|
13
|
+
## Copyright License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
16
|
+
|
|
17
|
+
## Distribution License
|
|
18
|
+
|
|
19
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
20
|
+
|
|
21
|
+
## Notices
|
|
22
|
+
|
|
23
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
24
|
+
|
|
25
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
26
|
+
|
|
27
|
+
## Changes and New Works License
|
|
28
|
+
|
|
29
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
30
|
+
|
|
31
|
+
## Patent License
|
|
32
|
+
|
|
33
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
34
|
+
|
|
35
|
+
## Noncommercial Purposes
|
|
36
|
+
|
|
37
|
+
Any noncommercial purpose is a permitted purpose.
|
|
38
|
+
|
|
39
|
+
## Personal Uses
|
|
40
|
+
|
|
41
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
42
|
+
|
|
43
|
+
## Noncommercial Organizations
|
|
44
|
+
|
|
45
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
46
|
+
|
|
47
|
+
## Fair Use
|
|
48
|
+
|
|
49
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
54
|
+
|
|
55
|
+
## Patent Defense
|
|
56
|
+
|
|
57
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
58
|
+
|
|
59
|
+
## Violations
|
|
60
|
+
|
|
61
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
62
|
+
|
|
63
|
+
## No Liability
|
|
64
|
+
|
|
65
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
66
|
+
|
|
67
|
+
## Definitions
|
|
68
|
+
|
|
69
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
70
|
+
|
|
71
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
72
|
+
|
|
73
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
74
|
+
|
|
75
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
76
|
+
|
|
77
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# fi-glass
|
|
2
|
+
|
|
3
|
+
The **glassmorphism material (skin)** for Free Intelligence chat frontends —
|
|
4
|
+
glass-box agentic UI rendered as frosted surfaces. Depends only on
|
|
5
|
+
`@free-intelligence/core`. One build → N consumers (aurity, og118, …).
|
|
6
|
+
|
|
7
|
+
Subpath exports: `fi-glass` (root), `fi-glass/theme`, `fi-glass/theme.css`,
|
|
8
|
+
`fi-glass/messages`, `fi-glass/composer`, `fi-glass/voice`, `fi-glass/shell`,
|
|
9
|
+
`fi-glass/persona-selector`, `fi-glass/agent`.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ⚠️ Tailwind is required for the visual primitives
|
|
14
|
+
|
|
15
|
+
This is the one coupling that isn't obvious from the type signatures, so read it
|
|
16
|
+
before you wire fi-glass into a fresh app.
|
|
17
|
+
|
|
18
|
+
`fi-glass/messages` (and the shell that renders it) emit **Tailwind utility
|
|
19
|
+
class strings** — `messageStyles` / `markdownStyles` are values like
|
|
20
|
+
`'group relative py-3 px-4'`, `'bg-white/[0.02]'`, `'text-slate-300'`. They are
|
|
21
|
+
**not** compiled CSS. fi-glass ships the class *strings* in its `dist`; your app
|
|
22
|
+
is what turns them into styles. So a consumer must:
|
|
23
|
+
|
|
24
|
+
1. **Have Tailwind** (v3 or v4) configured in the app.
|
|
25
|
+
2. **Tell Tailwind to scan fi-glass's `dist`.** Tailwind ignores `node_modules`
|
|
26
|
+
by default, so the workspace path must be globbed **explicitly** — otherwise
|
|
27
|
+
the message primitives render unstyled.
|
|
28
|
+
|
|
29
|
+
### Tailwind v3 — `tailwind.config.js`
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
module.exports = {
|
|
33
|
+
content: [
|
|
34
|
+
'./app/**/*.{ts,tsx}',
|
|
35
|
+
'./components/**/*.{ts,tsx}',
|
|
36
|
+
// fi-glass ships class strings in its dist — Tailwind must scan them:
|
|
37
|
+
'../../packages/fi-glass/dist/**/*.{js,mjs}',
|
|
38
|
+
],
|
|
39
|
+
// ...
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Tailwind v4 — CSS `@source`
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
@import 'tailwindcss';
|
|
47
|
+
/* fi-glass ships class strings in its dist — scan them: */
|
|
48
|
+
@source '../../packages/fi-glass/dist/**/*.{js,mjs}';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Adjust the relative path to wherever the workspace resolves `fi-glass` for your
|
|
52
|
+
app. (A compiled-CSS option for the message primitives is on the roadmap; until
|
|
53
|
+
then the content-glob is the supported path.)
|
|
54
|
+
|
|
55
|
+
### Theme tokens
|
|
56
|
+
|
|
57
|
+
The glassmorphism tokens (`--glass-blur`, `--glass-border`, …) come from the CSS,
|
|
58
|
+
imported via the package subpath — no build step:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import 'fi-glass/theme.css';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Shell: `<ChatWidget>` vs `<ChatSurface>`
|
|
67
|
+
|
|
68
|
+
Two compositions over the same `ChatHook` spine. Pick by shape:
|
|
69
|
+
|
|
70
|
+
| | `<ChatWidget>` | `<ChatSurface>` |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| Shape | Floating bubble (FloatingButton when closed) + view modes | Full-page, chat-first (the chat IS the page) |
|
|
73
|
+
| Closed state | Yes (launcher) | None — mounts always open |
|
|
74
|
+
| Layout | Floats / minimizes / maximizes | Fills its parent (the page owns height) |
|
|
75
|
+
| Use it for | A chat dock in a corner of an app | A dedicated chat route, e.g. og118 `/` |
|
|
76
|
+
|
|
77
|
+
`ChatSurface` is not a fork: internally it is `<ChatWidget>` pinned to the
|
|
78
|
+
embedded + open + fullscreen view, reusing `ChatWidgetContainer`'s view-mode
|
|
79
|
+
math. It only removes the launcher.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { ChatSurface } from 'fi-glass/shell';
|
|
83
|
+
|
|
84
|
+
// A hello-chat: only the conversation essentials. Voice / upload / personas /
|
|
85
|
+
// response-mode are OFF because their handlers are omitted (feature-off by
|
|
86
|
+
// absence) — the toolbar hides them automatically.
|
|
87
|
+
export default function Page() {
|
|
88
|
+
return (
|
|
89
|
+
<div className="h-dvh">
|
|
90
|
+
<ChatSurface
|
|
91
|
+
chatHook={chat}
|
|
92
|
+
message={message}
|
|
93
|
+
onMessageChange={setMessage}
|
|
94
|
+
onSend={send}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Optional capabilities (feature-off by absence)
|
|
102
|
+
|
|
103
|
+
`ChatWidgetProps` requires only `chatHook` + `message` / `onMessageChange` /
|
|
104
|
+
`onSend`. Everything else is optional, and **a control is shown only when its
|
|
105
|
+
handler is wired**:
|
|
106
|
+
|
|
107
|
+
- **Voice** — pass `onVoiceStart` / `onVoiceStop` (+ `voiceState`) to show the mic.
|
|
108
|
+
- **Upload** — pass `onAttach` (+ `uploadFile` / `uploadStatus` / `isUploadActive`).
|
|
109
|
+
- **Personas** — pass the `personaSelector` slot (+ `onPersonaChange` / `personaName`).
|
|
110
|
+
- **Response mode** — pass `onResponseModeToggle` (+ `responseMode`).
|
|
111
|
+
- **Clear / thinking / curl** — pass `onClearConversation` / `onShowThinkingToggle` / `onCopyCurl`.
|
|
112
|
+
|
|
113
|
+
Omit any of them and the corresponding toolbar control simply doesn't render —
|
|
114
|
+
no stubs, no dead buttons.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Voice playback: `useAudioPlayer` / `<AudioPlayer>`
|
|
119
|
+
|
|
120
|
+
The voice stack is two halves. **Synthesis** turns text into an `AudioSource`
|
|
121
|
+
(`useVoice(adapter)` + `SpeakButton`); **playback** turns that source into sound.
|
|
122
|
+
Playback is the reusable foundation here — an app no longer re-wires its own
|
|
123
|
+
`<audio>`, play/stop, loading/error and object-URL cleanup.
|
|
124
|
+
|
|
125
|
+
Three layers, pick the one you need (all from `fi-glass/voice`):
|
|
126
|
+
|
|
127
|
+
- `createAudioPlayer(opts)` — headless engine (no React). Owns the element, the
|
|
128
|
+
play/pause/stop state machine, and **revokes only the object URLs it created**
|
|
129
|
+
(a `{ url }` source is left alone for streaming). Dependency-injected, so it
|
|
130
|
+
unit-tests in node with a fake element — no DOM, no network.
|
|
131
|
+
- `useAudioPlayer(opts)` — React hook over the engine; disposes (and revokes) on
|
|
132
|
+
unmount.
|
|
133
|
+
- `<AudioPlayer source={...} />` — minimal accessible controls (play/pause + stop,
|
|
134
|
+
loading spinner, `role="alert"` error). Restyle via `className` props.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { useVoice, useAudioPlayer } from 'fi-glass/voice';
|
|
138
|
+
|
|
139
|
+
function Message({ text, adapter }) {
|
|
140
|
+
const { generateAudio, audioUrl } = useVoice(adapter); // text -> AudioSource
|
|
141
|
+
const player = useAudioPlayer({ onError: report }); // AudioSource -> sound
|
|
142
|
+
|
|
143
|
+
// The hook owns cleanup; or drop in <AudioPlayer source={blob} /> directly.
|
|
144
|
+
return <button onClick={() => generateAudio(text)}>Speak</button>;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Playback needs no adapter — it consumes an `AudioSource` (a `Blob` or `{ url }`),
|
|
149
|
+
so it works with any synthesis path.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Agent panel: `<AgentPanel>`
|
|
154
|
+
|
|
155
|
+
Renders one reduced agentic turn (`AgentTurnState` from core's
|
|
156
|
+
`applyAgentEvent`): the plan checklist (with guard banner woven in), the live
|
|
157
|
+
tool-call steps, and sources. Each sub-panel self-hides when empty.
|
|
158
|
+
|
|
159
|
+
`PlanChecklist` renders the full plan lifecycle that core v1.1.0 exposes:
|
|
160
|
+
per-step `done` / `failed` / `cancelled` (struck) statuses, `note` annotations,
|
|
161
|
+
a `revised` / `re-planned` badge when the plan is amended mid-turn, and a
|
|
162
|
+
terminal `completed` / `failed` / `cancelled` outcome badge.
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ToolCall, AgentTurnState, GuardRejection, AgentPlan, AgentTurnStatus, AgentHook, ChatMessage, VoiceAdapter } from '@free-intelligence/core';
|
|
4
|
+
import { LucideIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tool classification + live-status helpers for the Steps audit trail.
|
|
8
|
+
*
|
|
9
|
+
* Pure and generic — a raw tool name like `mcp__brightdata__scrape_as_markdown`
|
|
10
|
+
* or `Bash` → a visual category + a short display name + a live status. No app
|
|
11
|
+
* deps, no icons (the icon set maps a category → a component separately).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type ToolCategory = 'search' | 'scrape' | 'browser' | 'rag' | 'bash' | 'introspect' | 'generic';
|
|
15
|
+
/** Classify a raw tool name into a visual category (loose substring match, so a
|
|
16
|
+
* rename like `scrape_as_markdown` → `scrape_markdown` still resolves). */
|
|
17
|
+
declare function classifyTool(name: string): ToolCategory;
|
|
18
|
+
/** Strip the `mcp__<server>__` prefix for display (`scrape_as_markdown`). */
|
|
19
|
+
declare function shortToolName(name: string): string;
|
|
20
|
+
type ToolVisualStatus = 'active' | 'sent' | 'done' | 'error';
|
|
21
|
+
/** Index of the latest still-open (pending) tool — the one to highlight live. */
|
|
22
|
+
declare function latestOpenToolIndex(steps: ToolCall[]): number;
|
|
23
|
+
/** Visual status for one step: only the latest open step reads "active". */
|
|
24
|
+
declare function toolVisualStatus(step: ToolCall, index: number, latestOpenIndex: number, live: boolean): ToolVisualStatus;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* AgentIconSet — the icons the agent panels need, with lucide defaults.
|
|
28
|
+
*
|
|
29
|
+
* Icons are injectable per panel (the `icons` prop merges over these defaults),
|
|
30
|
+
* so an app can swap the icon language without forking the components. The tool
|
|
31
|
+
* map is keyed by visual category (see toolClassify), not lucide names, so a
|
|
32
|
+
* swap is a one-line change here.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
interface AgentIconSet {
|
|
36
|
+
/** Plan checklist header. */
|
|
37
|
+
plan: LucideIcon;
|
|
38
|
+
/** Guard/warning indicator. */
|
|
39
|
+
warning: LucideIcon;
|
|
40
|
+
/** Assistant identity (Steps panel header). */
|
|
41
|
+
bot: LucideIcon;
|
|
42
|
+
/** Sources panel header. */
|
|
43
|
+
sources: LucideIcon;
|
|
44
|
+
/** Outgoing-link arrow on each source row. */
|
|
45
|
+
external: LucideIcon;
|
|
46
|
+
/** Per-category tool icons for the Steps audit trail. */
|
|
47
|
+
tools: Record<ToolCategory, LucideIcon>;
|
|
48
|
+
}
|
|
49
|
+
declare const defaultAgentIcons: AgentIconSet;
|
|
50
|
+
/** Merge caller overrides over the defaults (deep-merges the `tools` map). */
|
|
51
|
+
declare function resolveIcons(overrides?: Partial<AgentIconSet>): AgentIconSet;
|
|
52
|
+
/** Resolve the icon for a raw tool name via its category. */
|
|
53
|
+
declare function toolIcon(icons: AgentIconSet, name: string): LucideIcon;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Class-name slots so the consuming app keeps its own CSS — fi-glass ships
|
|
57
|
+
* neutral defaults (empty strings) and never hardcodes app-specific class names
|
|
58
|
+
* (no `iai-*` / `aplay-*` leaking into the framework). insult_ai passes its
|
|
59
|
+
* `iai-card-soft` / `iai-hint` / branded source-row strings to preserve render;
|
|
60
|
+
* og118 passes its own (or nothing for the neutral look).
|
|
61
|
+
*/
|
|
62
|
+
interface AgentClassNames {
|
|
63
|
+
/** Card/surface container of a panel. */
|
|
64
|
+
card?: string;
|
|
65
|
+
/** Dimmed small-text hint (counts, queued labels, guard tag). */
|
|
66
|
+
hint?: string;
|
|
67
|
+
/** A single source row (`<a>`) in the Sources panel. */
|
|
68
|
+
sourceRow?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface AgentPanelProps {
|
|
72
|
+
/**
|
|
73
|
+
* The reduced state of one agentic turn (built by core's `applyAgentEvent`).
|
|
74
|
+
* Passed directly — NOT via the AgentHook — because consumers render a panel
|
|
75
|
+
* per historical turn/message, and the hook models only the current turn.
|
|
76
|
+
* A single-turn app simply passes `agentHook.turn`.
|
|
77
|
+
*/
|
|
78
|
+
turn: AgentTurnState;
|
|
79
|
+
/** Optional target (URL/claim) for the Steps live label. */
|
|
80
|
+
target?: string;
|
|
81
|
+
classNames?: AgentClassNames;
|
|
82
|
+
icons?: Partial<AgentIconSet>;
|
|
83
|
+
enableSlowBanner?: boolean;
|
|
84
|
+
slowThresholdMs?: number;
|
|
85
|
+
/** Replace the default Sources panel (e.g. an app's branded source list). */
|
|
86
|
+
renderSources?: (sources: string[]) => ReactNode;
|
|
87
|
+
/** Override the guard-rejection banner (copy is app-owned). */
|
|
88
|
+
renderGuardBanner?: (rejection: GuardRejection) => ReactNode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The glass-box agentic panel: Plan (contract, guard woven in) + Steps (live
|
|
92
|
+
* audit trail) + Sources (evidence). Each sub-panel self-hides when it has
|
|
93
|
+
* nothing to show, so an early/no-tool turn degrades gracefully.
|
|
94
|
+
*/
|
|
95
|
+
declare function AgentPanel({ turn, target, classNames, icons, enableSlowBanner, slowThresholdMs, renderSources, renderGuardBanner, }: AgentPanelProps): react.JSX.Element;
|
|
96
|
+
|
|
97
|
+
interface PlanChecklistProps {
|
|
98
|
+
plan: AgentPlan | null;
|
|
99
|
+
classNames?: AgentClassNames;
|
|
100
|
+
icons?: Partial<AgentIconSet>;
|
|
101
|
+
/**
|
|
102
|
+
* Override the guard-rejection banner. The guard is a QUALITY woven into the
|
|
103
|
+
* plan, not a separate widget — when a rejection is present this renders it.
|
|
104
|
+
* The default copy is generic ("A guard blocked this plan"); apps that want
|
|
105
|
+
* their own wording (e.g. "PlanGuard blocked this plan") pass this slot.
|
|
106
|
+
*/
|
|
107
|
+
renderGuardBanner?: (rejection: GuardRejection) => ReactNode;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The agent's plan-of-action as a live checklist. Renders only when a plan was
|
|
111
|
+
* declared. Visual rule: signal > detail — this says WHAT the agent committed
|
|
112
|
+
* to; the Steps panel shows every tool call as it happens.
|
|
113
|
+
*/
|
|
114
|
+
declare function PlanChecklist({ plan, classNames, icons, renderGuardBanner, }: PlanChecklistProps): react.JSX.Element | null;
|
|
115
|
+
|
|
116
|
+
interface StepsPanelProps {
|
|
117
|
+
steps: ToolCall[];
|
|
118
|
+
status: AgentTurnStatus;
|
|
119
|
+
/** Optional target (URL/claim) the agent is working on, for the live label. */
|
|
120
|
+
target?: string;
|
|
121
|
+
classNames?: AgentClassNames;
|
|
122
|
+
icons?: Partial<AgentIconSet>;
|
|
123
|
+
/** Show the "still working" reassurance banner past the threshold (default true). */
|
|
124
|
+
enableSlowBanner?: boolean;
|
|
125
|
+
/** Milliseconds before the slow banner appears (default 12s). */
|
|
126
|
+
slowThresholdMs?: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Collapsible audit trail that lists every tool call as it happens. Auto-expands
|
|
130
|
+
* while the turn is live and collapses on done. The "thinking" status is generic
|
|
131
|
+
* here — fi-glass knows nothing about clinical/roast modes; the slow banner is a
|
|
132
|
+
* plain prop (apps that have their own slow UI pass enableSlowBanner={false}).
|
|
133
|
+
*/
|
|
134
|
+
declare function StepsPanel({ steps, status, target, classNames, icons, enableSlowBanner, slowThresholdMs, }: StepsPanelProps): react.JSX.Element | null;
|
|
135
|
+
|
|
136
|
+
interface SourcesPanelProps {
|
|
137
|
+
/** Evidence references (e.g. source URLs). Contract field name = `sources`. */
|
|
138
|
+
sources: string[];
|
|
139
|
+
classNames?: AgentClassNames;
|
|
140
|
+
icons?: Partial<AgentIconSet>;
|
|
141
|
+
/** Header label (default "Sources"). */
|
|
142
|
+
label?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The Sources panel — the references the agent actually fetched/cited. fi-glass
|
|
146
|
+
* ships a neutral default; an app with branded styling (e.g. insult_ai's Bright
|
|
147
|
+
* Data receipts) can pass its row class via `classNames.sourceRow`, or replace
|
|
148
|
+
* this whole panel through the AgentPanel's `renderSources` slot.
|
|
149
|
+
*/
|
|
150
|
+
declare function SourcesPanel({ sources, classNames, icons, label, }: SourcesPanelProps): react.JSX.Element | null;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Predicate an app passes to CLAIM a specific error class as its own. When it
|
|
154
|
+
* returns true for a failed turn, the conversation still reverts the optimistic
|
|
155
|
+
* message but does NOT raise the generic recoverable `turnError` — the app shows
|
|
156
|
+
* its own UI instead (e.g. og118's 401 token-gate banner, where a blind "retry"
|
|
157
|
+
* would just 401 again). The idle-timeout failure is never app-handled.
|
|
158
|
+
*/
|
|
159
|
+
type AppHandledError = (turn: AgentTurnState) => boolean;
|
|
160
|
+
/** A recoverable failure of the in-flight turn, surfaced for retry/dismiss. */
|
|
161
|
+
interface TurnError {
|
|
162
|
+
/** `timeout` = the idle watchdog fired; `stream` = the transport reported error. */
|
|
163
|
+
kind: 'timeout' | 'stream';
|
|
164
|
+
/** Human-readable, app-displayable reason. */
|
|
165
|
+
message: string;
|
|
166
|
+
}
|
|
167
|
+
/** Default idle watchdog: a turn with no state change for this long is hung. */
|
|
168
|
+
declare const DEFAULT_TURN_TIMEOUT_MS = 60000;
|
|
169
|
+
interface UseAgentConversationOptions {
|
|
170
|
+
/** Identity of the active conversation. When it changes, the thread re-hydrates. */
|
|
171
|
+
conversationId?: string | null;
|
|
172
|
+
/** Messages to seed the thread with (the active conversation's stored transcript). */
|
|
173
|
+
initialMessages?: ChatMessage[];
|
|
174
|
+
/** Called when the thread changes from real activity (fold/revert) — a persist hook. */
|
|
175
|
+
onMessagesChange?: (messages: ChatMessage[]) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Idle watchdog in ms: if the live turn's state does not change for this long
|
|
178
|
+
* while streaming, the turn is declared failed (timeout). Measured since the
|
|
179
|
+
* LAST turn-state change, not since send — a long-but-active turn (streaming
|
|
180
|
+
* tokens, running steps) keeps resetting it and never trips. Pass a small
|
|
181
|
+
* value in tests; `0` disables the watchdog. Defaults to 60s.
|
|
182
|
+
*/
|
|
183
|
+
turnTimeoutMs?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Claim a specific error class as app-handled (see {@link AppHandledError}).
|
|
186
|
+
* Such a failure still reverts the optimistic message but is NOT surfaced as a
|
|
187
|
+
* generic `turnError` — the app renders its own UI for it. Timeouts ignore this.
|
|
188
|
+
*/
|
|
189
|
+
isAppHandledError?: AppHandledError;
|
|
190
|
+
}
|
|
191
|
+
interface AgentConversation {
|
|
192
|
+
/** The visible thread of completed turns (user + assistant), in send order. */
|
|
193
|
+
messages: ChatMessage[];
|
|
194
|
+
/** The current/live turn's reduced state (for the in-flight glass-box). */
|
|
195
|
+
turn: AgentTurnState;
|
|
196
|
+
/**
|
|
197
|
+
* Whether a turn is actively streaming. This is the CONVERSATION's view, not
|
|
198
|
+
* the transport's: once the watchdog declares a turn hung, this is false even
|
|
199
|
+
* if the underlying `agent.isStreaming` is still stuck true — so the surface
|
|
200
|
+
* leaves the "thinking…" state and can render the recoverable error instead.
|
|
201
|
+
*/
|
|
202
|
+
isStreaming: boolean;
|
|
203
|
+
/** A recoverable failure of the last turn (timeout/stream), or null. */
|
|
204
|
+
turnError: TurnError | null;
|
|
205
|
+
/** Send a message: pushes it optimistically, then drives the agent turn. */
|
|
206
|
+
send: (text: string) => void;
|
|
207
|
+
/** Re-send the last user text after a failure. No-op if there is nothing to retry. */
|
|
208
|
+
retry: () => void;
|
|
209
|
+
/** Clear the current turnError without re-sending (the optimistic msg is already reverted). */
|
|
210
|
+
dismissError: () => void;
|
|
211
|
+
/** Clear the whole thread and reset the underlying turn/session. */
|
|
212
|
+
newConversation: () => void;
|
|
213
|
+
}
|
|
214
|
+
declare function useAgentConversation(agent: AgentHook, options?: UseAgentConversationOptions): AgentConversation;
|
|
215
|
+
|
|
216
|
+
interface AgentConversationSurfaceProps {
|
|
217
|
+
/** The conversation state + actions from `useAgentConversation`. */
|
|
218
|
+
conversation: AgentConversation;
|
|
219
|
+
/** Composer placeholder copy (app-owned). */
|
|
220
|
+
composerPlaceholder?: string;
|
|
221
|
+
/** Label for the new-conversation button. Default: "New chat". */
|
|
222
|
+
newChatLabel?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Render the built-in new-conversation button above the composer. Default
|
|
225
|
+
* true. An app whose chrome already owns that affordance (e.g. a sidebar's
|
|
226
|
+
* "+ New chat") sets false to avoid a duplicate CTA (B3-OG118-5) — a typed
|
|
227
|
+
* opt-out, not consumer CSS hiding framework internals.
|
|
228
|
+
*/
|
|
229
|
+
showNewChatButton?: boolean;
|
|
230
|
+
/** Rendered when the thread is empty and idle (e.g. an app start screen). */
|
|
231
|
+
emptyState?: ReactNode;
|
|
232
|
+
/** Slot rendered just above the composer (e.g. an app's auth banner). */
|
|
233
|
+
aboveComposer?: ReactNode;
|
|
234
|
+
/** Pass-through styling/icons for the live-turn AgentPanel. */
|
|
235
|
+
agentPanelProps?: Partial<Omit<AgentPanelProps, 'turn'>>;
|
|
236
|
+
/**
|
|
237
|
+
* Floating composer box class (style hook for the app) — the single frosted
|
|
238
|
+
* container that wraps BOTH the textarea row and the controls row (mic/send),
|
|
239
|
+
* mirroring the shell's `chat-input-floating-box` (AURITY). Apply the
|
|
240
|
+
* glass-chat preset here (`glass-chat-composer`), not on `composerAreaClassName`:
|
|
241
|
+
* the controls belong INSIDE the box, not floating next to it.
|
|
242
|
+
*/
|
|
243
|
+
composerBoxClassName?: string;
|
|
244
|
+
/** Composer textarea-row wrapper class (spacing inside the box). */
|
|
245
|
+
composerAreaClassName?: string;
|
|
246
|
+
/** Composer textarea class (style hook for the app). */
|
|
247
|
+
composerTextareaClassName?: string;
|
|
248
|
+
/** Controls-row class (the mic/send row inside the box; layout stays framework-owned). */
|
|
249
|
+
composerControlsClassName?: string;
|
|
250
|
+
/**
|
|
251
|
+
* When true (and no `renderActions` override), each transcript message gets a
|
|
252
|
+
* default {@link CopyButton} in the bubble's actions slot. Default: false
|
|
253
|
+
* (the dense agentic surface stays action-free unless the app opts in). The
|
|
254
|
+
* live streaming message never gets a copy action.
|
|
255
|
+
*/
|
|
256
|
+
showCopyAction?: boolean;
|
|
257
|
+
/** Per-message header slot (avatar + author/meta) → MessageBubble.header. */
|
|
258
|
+
renderHeader?: (message: ChatMessage) => ReactNode;
|
|
259
|
+
/** Per-message badge slot (model/provenance chip) → MessageBubble.badge. */
|
|
260
|
+
renderBadge?: (message: ChatMessage) => ReactNode;
|
|
261
|
+
/** Per-message actions slot (overrides showCopyAction) → MessageBubble.actions. */
|
|
262
|
+
renderActions?: (message: ChatMessage) => ReactNode;
|
|
263
|
+
/**
|
|
264
|
+
* Extra class for message bubbles → MessageBubble.className.
|
|
265
|
+
*
|
|
266
|
+
* Accepts either:
|
|
267
|
+
* - a `string` applied to EVERY bubble regardless of role (legacy, unchanged), or
|
|
268
|
+
* - a `(message) => string | undefined` resolver so a consumer can return a
|
|
269
|
+
* DIFFERENT class per role (e.g. `glass-chat-bubble-user` vs
|
|
270
|
+
* `glass-chat-bubble-assistant`) without re-implementing the surface or
|
|
271
|
+
* duplicating MessageBubble.
|
|
272
|
+
*
|
|
273
|
+
* B3-VOICE-FIGLASS-3: the tri-consumer visual audit found the only real
|
|
274
|
+
* reusable gap was that this surface could not vary bubble styling by role —
|
|
275
|
+
* og118 was forced to apply one assistant class to user AND assistant. The
|
|
276
|
+
* function form closes that gap. Backward-compatible: omit it for defaults,
|
|
277
|
+
* pass a string for the previous all-roles behavior. The resolver is also
|
|
278
|
+
* called for the live streaming (assistant) bubble; a resolver that returns
|
|
279
|
+
* `undefined` for any message (e.g. an unknown role) simply yields no extra
|
|
280
|
+
* class, so it never throws.
|
|
281
|
+
*/
|
|
282
|
+
messageBubbleClassName?: string | ((message: ChatMessage) => string | undefined);
|
|
283
|
+
/**
|
|
284
|
+
* The app's voice engine. When it exposes `transcribe`, the surface lights up
|
|
285
|
+
* an in-composer dictation mic and feeds the recognized text straight into the
|
|
286
|
+
* composer — no consumer wiring, exactly how a `synthesize`-capable adapter
|
|
287
|
+
* lights up the SpeakButton. Omit it (or pass one without `transcribe`) and
|
|
288
|
+
* there is no mic at all (backward-compatible default).
|
|
289
|
+
*
|
|
290
|
+
* B3-VOICE-FIGLASS-4: the STT canary (og118) revealed the surface owned the
|
|
291
|
+
* composer's text state with no way to receive dictated text. Rather than
|
|
292
|
+
* thread a callback, the surface consumes the VoiceAdapter capability — the
|
|
293
|
+
* pattern core prescribes ("add a capability via an adapter member, never by
|
|
294
|
+
* threading a new callback through the components").
|
|
295
|
+
*/
|
|
296
|
+
voiceAdapter?: VoiceAdapter;
|
|
297
|
+
/** Class for the dictation mic slot wrapper (only rendered when STT is available). */
|
|
298
|
+
micSlotClassName?: string;
|
|
299
|
+
/** Class for the dictation mic button. */
|
|
300
|
+
micButtonClassName?: string;
|
|
301
|
+
/** Called on a recording/transcription failure surfaced by dictation. */
|
|
302
|
+
onVoiceError?: (message: string) => void;
|
|
303
|
+
/**
|
|
304
|
+
* Wrapper class for the live dictation visualizer (the equalizer that reacts
|
|
305
|
+
* to the mic while recording). Only rendered while dictation is active, fed by
|
|
306
|
+
* the analyser's frequency bands — so every shell inherits reactive bars
|
|
307
|
+
* without re-wiring Web Audio. Omit for the unstyled default.
|
|
308
|
+
*/
|
|
309
|
+
voiceVisualizerClassName?: string;
|
|
310
|
+
/** Per-bar class for the live dictation visualizer. */
|
|
311
|
+
voiceVisualizerBarClassName?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Render an explicit send button in the composer row (in addition to
|
|
314
|
+
* Enter-to-send). Default true — a visible affordance matches the shell
|
|
315
|
+
* composer (AURITY). Set false for an Enter-only composer.
|
|
316
|
+
*/
|
|
317
|
+
showSendButton?: boolean;
|
|
318
|
+
/** Class for the send button. */
|
|
319
|
+
sendButtonClassName?: string;
|
|
320
|
+
/** Class for the send button icon. */
|
|
321
|
+
sendButtonIconClassName?: string;
|
|
322
|
+
/** aria-label for the send button. Default: "Enviar mensaje". */
|
|
323
|
+
sendLabel?: string;
|
|
324
|
+
/**
|
|
325
|
+
* B3-VOICE-OG118-6 — append text to the composer from an external source
|
|
326
|
+
* (e.g. a durable-queue transcription). When non-empty, the surface appends
|
|
327
|
+
* this text to the current input and calls `onComposerAppendConsumed`. Pull-once
|
|
328
|
+
* pattern: set to a string → surface consumes → consumer resets to ''.
|
|
329
|
+
*/
|
|
330
|
+
composerAppend?: string;
|
|
331
|
+
/** Called immediately after the surface appends `composerAppend`. Reset to ''. */
|
|
332
|
+
onComposerAppendConsumed?: () => void;
|
|
333
|
+
/**
|
|
334
|
+
* B3-VOICE-OG118-6 — replace the built-in `ComposerMicSlot` + `useDictation`
|
|
335
|
+
* with custom content (e.g. a durable-recording button). When provided, no
|
|
336
|
+
* built-in mic is rendered and no dictation visualizer is shown. The `voiceAdapter`
|
|
337
|
+
* prop still gates TTS-only features; pass `undefined` or an adapter without
|
|
338
|
+
* `transcribe` to avoid a phantom built-in mic alongside the override.
|
|
339
|
+
*/
|
|
340
|
+
micSlotOverride?: ReactNode;
|
|
341
|
+
/**
|
|
342
|
+
* B3-FIGLASS-8 — recoverable turn-failure UI. When `conversation.turnError`
|
|
343
|
+
* is set (a hung/timed-out or errored turn), the surface renders a recoverable
|
|
344
|
+
* banner with retry/dismiss INSTEAD of the zombie "thinking…" panel. These are
|
|
345
|
+
* the consumer's style/copy hooks; sensible defaults render without any.
|
|
346
|
+
*/
|
|
347
|
+
errorClassName?: string;
|
|
348
|
+
/** Retry button copy. Default: "Reintentar". */
|
|
349
|
+
retryLabel?: string;
|
|
350
|
+
/** Dismiss button copy. Default: "Descartar". */
|
|
351
|
+
dismissLabel?: string;
|
|
352
|
+
/** Class for the retry button. */
|
|
353
|
+
retryButtonClassName?: string;
|
|
354
|
+
/** Class for the dismiss button. */
|
|
355
|
+
dismissButtonClassName?: string;
|
|
356
|
+
/**
|
|
357
|
+
* B3-FIGLASS-12 — pin-to-bottom scroll during streaming (ChatGPT parity).
|
|
358
|
+
* The transcript stays pinned to the newest content while a turn streams;
|
|
359
|
+
* the user scrolling up unpins it; a floating button jumps back. Powered by
|
|
360
|
+
* use-stick-to-bottom (ResizeObserver + spring, no overflow-anchor — Safari
|
|
361
|
+
* doesn't support it). Default true. This finally consumes the autoscroll
|
|
362
|
+
* promise that config.ts declared and nothing implemented.
|
|
363
|
+
*/
|
|
364
|
+
autoScroll?: boolean;
|
|
365
|
+
/** aria-label for the floating scroll-to-bottom button. Default: "Ir al final". */
|
|
366
|
+
scrollToBottomLabel?: string;
|
|
367
|
+
/** Visual class for the scroll-to-bottom button (placement stays framework-owned). */
|
|
368
|
+
scrollToBottomClassName?: string;
|
|
369
|
+
/** Icon class for the scroll-to-bottom button. */
|
|
370
|
+
scrollToBottomIconClassName?: string;
|
|
371
|
+
/**
|
|
372
|
+
* B3-FIGLASS-12 — clamp long USER messages behind a "show more" disclosure
|
|
373
|
+
* (ChatGPT parity: max-height + mask-image fade + aria-expanded toggle).
|
|
374
|
+
* Assistant messages and the live streaming bubble are never clamped.
|
|
375
|
+
* Default true.
|
|
376
|
+
*/
|
|
377
|
+
collapseUserMessages?: boolean;
|
|
378
|
+
/** Collapsed max height in px. Default 264 (11 lines at 24px leading). */
|
|
379
|
+
collapseMaxHeight?: number;
|
|
380
|
+
/** Disclosure copy (app-owned). Defaults: "Mostrar más" / "Mostrar menos". */
|
|
381
|
+
showMoreLabel?: string;
|
|
382
|
+
showLessLabel?: string;
|
|
383
|
+
/** Class for the disclosure toggle button. */
|
|
384
|
+
collapseToggleClassName?: string;
|
|
385
|
+
}
|
|
386
|
+
declare function AgentConversationSurface({ conversation, composerPlaceholder, newChatLabel, showNewChatButton, emptyState, aboveComposer, agentPanelProps, composerBoxClassName, composerAreaClassName, composerTextareaClassName, composerControlsClassName, showCopyAction, renderHeader, renderBadge, renderActions, messageBubbleClassName, voiceAdapter, micSlotClassName, micButtonClassName, onVoiceError, voiceVisualizerClassName, voiceVisualizerBarClassName, showSendButton, sendButtonClassName, sendButtonIconClassName, sendLabel, composerAppend, onComposerAppendConsumed, micSlotOverride, errorClassName, retryLabel, dismissLabel, retryButtonClassName, dismissButtonClassName, autoScroll, scrollToBottomLabel, scrollToBottomClassName, scrollToBottomIconClassName, collapseUserMessages, collapseMaxHeight, showMoreLabel, showLessLabel, collapseToggleClassName, }: AgentConversationSurfaceProps): react.JSX.Element;
|
|
387
|
+
|
|
388
|
+
interface ScrollToBottomButtonProps {
|
|
389
|
+
onClick: () => void;
|
|
390
|
+
/** Accessible label. Default: "Ir al final". */
|
|
391
|
+
label?: string;
|
|
392
|
+
/** Visual class. When set, the default skin is dropped (placement stays). */
|
|
393
|
+
className?: string;
|
|
394
|
+
/** Icon class. */
|
|
395
|
+
iconClassName?: string;
|
|
396
|
+
}
|
|
397
|
+
declare function ScrollToBottomButton({ onClick, label, className, iconClassName, }: ScrollToBottomButtonProps): react.JSX.Element;
|
|
398
|
+
|
|
399
|
+
export { type AgentClassNames, type AgentConversation, AgentConversationSurface, type AgentConversationSurfaceProps, type AgentIconSet, AgentPanel, type AgentPanelProps, type AppHandledError, DEFAULT_TURN_TIMEOUT_MS, PlanChecklist, type PlanChecklistProps, ScrollToBottomButton, type ScrollToBottomButtonProps, SourcesPanel, type SourcesPanelProps, StepsPanel, type StepsPanelProps, type ToolCategory, type ToolVisualStatus, type TurnError, type UseAgentConversationOptions, classifyTool, defaultAgentIcons, latestOpenToolIndex, resolveIcons, shortToolName, toolIcon, toolVisualStatus, useAgentConversation };
|