fi-glass 1.1.1 → 1.3.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/dist/agent/index.d.ts +45 -6
- package/dist/agent/index.js +74 -7
- package/dist/agent/index.js.map +1 -1
- package/package.json +2 -2
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
3
|
import { ToolCall, AgentTurnState, GuardRejection, AgentPlan, AgentTurnStatus, AgentHook, ChatMessage, VoiceAdapter } from '@free-intelligence/core';
|
|
4
4
|
import { LucideIcon } from 'lucide-react';
|
|
5
5
|
|
|
@@ -167,11 +167,25 @@ interface TurnError {
|
|
|
167
167
|
/** Default idle watchdog: a turn with no state change for this long is hung. */
|
|
168
168
|
declare const DEFAULT_TURN_TIMEOUT_MS = 60000;
|
|
169
169
|
interface UseAgentConversationOptions {
|
|
170
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Controlled mode: when provided, the CONSUMER owns the visible thread. The
|
|
172
|
+
* hook returns these verbatim as `conversation.messages` and stops folding —
|
|
173
|
+
* `send` drives `agent.send(text)` but pushes no optimistic message and folds
|
|
174
|
+
* no finished turn (the consumer maps its own transport into this transcript).
|
|
175
|
+
* For workflow adapters whose single send yields many agent-handoff messages
|
|
176
|
+
* (the 1-send -> 8+ messages case the single-turn fold cannot express; the
|
|
177
|
+
* Activist OS canary that surfaced this). Mutually exclusive with
|
|
178
|
+
* `initialMessages`/`conversationId`/`onMessagesChange` (those are bypassed —
|
|
179
|
+
* the consumer owns persistence); if both `externalMessages` and
|
|
180
|
+
* `initialMessages` are passed, `externalMessages` wins. Undefined =
|
|
181
|
+
* uncontrolled (the hook owns the thread, byte-identical to before).
|
|
182
|
+
*/
|
|
183
|
+
externalMessages?: ChatMessage[];
|
|
184
|
+
/** Identity of the active conversation. When it changes, the thread re-hydrates. (Ignored in controlled mode.) */
|
|
171
185
|
conversationId?: string | null;
|
|
172
|
-
/** Messages to seed the thread with (the active conversation's stored transcript). */
|
|
186
|
+
/** Messages to seed the thread with (the active conversation's stored transcript). (Ignored in controlled mode.) */
|
|
173
187
|
initialMessages?: ChatMessage[];
|
|
174
|
-
/** Called when the thread changes from real activity (fold/revert) — a persist hook. */
|
|
188
|
+
/** Called when the thread changes from real activity (fold/revert) — a persist hook. (Not called in controlled mode.) */
|
|
175
189
|
onMessagesChange?: (messages: ChatMessage[]) => void;
|
|
176
190
|
/**
|
|
177
191
|
* Idle watchdog in ms: if the live turn's state does not change for this long
|
|
@@ -213,9 +227,20 @@ interface AgentConversation {
|
|
|
213
227
|
}
|
|
214
228
|
declare function useAgentConversation(agent: AgentHook, options?: UseAgentConversationOptions): AgentConversation;
|
|
215
229
|
|
|
230
|
+
type AgentConversationSurfaceLayout = 'viewport' | 'contained';
|
|
216
231
|
interface AgentConversationSurfaceProps {
|
|
217
232
|
/** The conversation state + actions from `useAgentConversation`. */
|
|
218
233
|
conversation: AgentConversation;
|
|
234
|
+
/**
|
|
235
|
+
* FG-2 (canary-driven, activist-os): how the surface root sizes itself.
|
|
236
|
+
* - `"viewport"` (DEFAULT): root is `height: 100dvh` — the full-page behavior
|
|
237
|
+
* every existing consumer relies on.
|
|
238
|
+
* - `"contained"`: root is `height: 100%` + `minHeight: 0` + `overflow: hidden`,
|
|
239
|
+
* so it fills whatever fixed-height cell an app shell gives it (header + main
|
|
240
|
+
* + artifacts rail + footer) and scrolls the transcript internally instead of
|
|
241
|
+
* forcing page scroll.
|
|
242
|
+
*/
|
|
243
|
+
layout?: AgentConversationSurfaceLayout;
|
|
219
244
|
/** Composer placeholder copy (app-owned). */
|
|
220
245
|
composerPlaceholder?: string;
|
|
221
246
|
/** Label for the new-conversation button. Default: "New chat". */
|
|
@@ -383,7 +408,7 @@ interface AgentConversationSurfaceProps {
|
|
|
383
408
|
/** Class for the disclosure toggle button. */
|
|
384
409
|
collapseToggleClassName?: string;
|
|
385
410
|
}
|
|
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;
|
|
411
|
+
declare function AgentConversationSurface({ conversation, layout, 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
412
|
|
|
388
413
|
interface ScrollToBottomButtonProps {
|
|
389
414
|
onClick: () => void;
|
|
@@ -396,4 +421,18 @@ interface ScrollToBottomButtonProps {
|
|
|
396
421
|
}
|
|
397
422
|
declare function ScrollToBottomButton({ onClick, label, className, iconClassName, }: ScrollToBottomButtonProps): react.JSX.Element;
|
|
398
423
|
|
|
399
|
-
|
|
424
|
+
type AgentWorkspaceShellVisual = 'aurora' | 'midnight' | 'clinical';
|
|
425
|
+
type AgentWorkspaceShellDensity = 'compact' | 'comfortable' | 'spacious';
|
|
426
|
+
interface AgentWorkspaceShellProps {
|
|
427
|
+
visual?: AgentWorkspaceShellVisual;
|
|
428
|
+
density?: AgentWorkspaceShellDensity;
|
|
429
|
+
header?: ReactNode;
|
|
430
|
+
conversation: ReactNode;
|
|
431
|
+
rail?: ReactNode;
|
|
432
|
+
footer?: ReactNode;
|
|
433
|
+
className?: string;
|
|
434
|
+
style?: CSSProperties;
|
|
435
|
+
}
|
|
436
|
+
declare function AgentWorkspaceShell({ visual, density, header, conversation, rail, footer, className, style, }: AgentWorkspaceShellProps): react.JSX.Element;
|
|
437
|
+
|
|
438
|
+
export { type AgentClassNames, type AgentConversation, AgentConversationSurface, type AgentConversationSurfaceLayout, type AgentConversationSurfaceProps, type AgentIconSet, AgentPanel, type AgentPanelProps, AgentWorkspaceShell, type AgentWorkspaceShellDensity, type AgentWorkspaceShellProps, type AgentWorkspaceShellVisual, 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 };
|
package/dist/agent/index.js
CHANGED
|
@@ -381,15 +381,19 @@ import {
|
|
|
381
381
|
var DEFAULT_TURN_TIMEOUT_MS = 6e4;
|
|
382
382
|
function useAgentConversation(agent, options = {}) {
|
|
383
383
|
const {
|
|
384
|
+
externalMessages,
|
|
384
385
|
conversationId,
|
|
385
386
|
initialMessages,
|
|
386
387
|
onMessagesChange,
|
|
387
388
|
turnTimeoutMs = DEFAULT_TURN_TIMEOUT_MS,
|
|
388
389
|
isAppHandledError
|
|
389
390
|
} = options;
|
|
391
|
+
const controlled = externalMessages !== void 0;
|
|
390
392
|
const [messages, setMessages] = useState2(
|
|
391
393
|
initialMessages ?? []
|
|
392
394
|
);
|
|
395
|
+
const controlledRef = useRef(controlled);
|
|
396
|
+
controlledRef.current = controlled;
|
|
393
397
|
const [turnError, setTurnError] = useState2(null);
|
|
394
398
|
const [timedOut, setTimedOut] = useState2(false);
|
|
395
399
|
const pending = useRef(false);
|
|
@@ -403,6 +407,7 @@ function useAgentConversation(agent, options = {}) {
|
|
|
403
407
|
const skipPersist = useRef(true);
|
|
404
408
|
const mounted = useRef(false);
|
|
405
409
|
const revertOptimistic = useCallback(() => {
|
|
410
|
+
if (controlledRef.current) return;
|
|
406
411
|
setMessages((prev) => {
|
|
407
412
|
const last = prev[prev.length - 1];
|
|
408
413
|
return last?.role === "user" ? prev.slice(0, -1) : prev;
|
|
@@ -415,12 +420,14 @@ function useAgentConversation(agent, options = {}) {
|
|
|
415
420
|
lastSent.current = t;
|
|
416
421
|
setTurnError(null);
|
|
417
422
|
setTimedOut(false);
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
if (!controlled) {
|
|
424
|
+
skipPersist.current = true;
|
|
425
|
+
setMessages((prev) => [...prev, makeUserMessage(t)]);
|
|
426
|
+
}
|
|
420
427
|
pending.current = true;
|
|
421
428
|
void agent.send(t);
|
|
422
429
|
},
|
|
423
|
-
[agent]
|
|
430
|
+
[agent, controlled]
|
|
424
431
|
);
|
|
425
432
|
const retry = useCallback(() => {
|
|
426
433
|
if (lastSent.current) send(lastSent.current);
|
|
@@ -442,6 +449,7 @@ function useAgentConversation(agent, options = {}) {
|
|
|
442
449
|
}
|
|
443
450
|
return;
|
|
444
451
|
}
|
|
452
|
+
if (controlledRef.current) return;
|
|
445
453
|
if (agent.turn.text) {
|
|
446
454
|
skipPersist.current = false;
|
|
447
455
|
setMessages((prev) => [...prev, foldAssistantTurn(agent.turn)]);
|
|
@@ -467,6 +475,7 @@ function useAgentConversation(agent, options = {}) {
|
|
|
467
475
|
mounted.current = true;
|
|
468
476
|
return;
|
|
469
477
|
}
|
|
478
|
+
if (controlledRef.current) return;
|
|
470
479
|
skipPersist.current = true;
|
|
471
480
|
pending.current = false;
|
|
472
481
|
setTurnError(null);
|
|
@@ -475,6 +484,7 @@ function useAgentConversation(agent, options = {}) {
|
|
|
475
484
|
agent.reset?.();
|
|
476
485
|
}, [conversationId]);
|
|
477
486
|
useEffect2(() => {
|
|
487
|
+
if (controlledRef.current) return;
|
|
478
488
|
if (skipPersist.current) {
|
|
479
489
|
skipPersist.current = false;
|
|
480
490
|
return;
|
|
@@ -485,12 +495,12 @@ function useAgentConversation(agent, options = {}) {
|
|
|
485
495
|
skipPersist.current = true;
|
|
486
496
|
setTurnError(null);
|
|
487
497
|
setTimedOut(false);
|
|
488
|
-
setMessages([]);
|
|
498
|
+
if (!controlled) setMessages([]);
|
|
489
499
|
pending.current = false;
|
|
490
500
|
agent.reset?.();
|
|
491
|
-
}, [agent]);
|
|
501
|
+
}, [agent, controlled]);
|
|
492
502
|
return {
|
|
493
|
-
messages,
|
|
503
|
+
messages: externalMessages ?? messages,
|
|
494
504
|
turn: agent.turn,
|
|
495
505
|
isStreaming: agent.isStreaming && !timedOut,
|
|
496
506
|
turnError,
|
|
@@ -1643,6 +1653,7 @@ function ScrollToBottomButton({
|
|
|
1643
1653
|
import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1644
1654
|
function AgentConversationSurface({
|
|
1645
1655
|
conversation,
|
|
1656
|
+
layout = "viewport",
|
|
1646
1657
|
composerPlaceholder,
|
|
1647
1658
|
newChatLabel = "New chat",
|
|
1648
1659
|
showNewChatButton = true,
|
|
@@ -1736,12 +1747,13 @@ function AgentConversationSurface({
|
|
|
1736
1747
|
send(t);
|
|
1737
1748
|
};
|
|
1738
1749
|
const canSend = input.trim().length > 0 && !isStreaming;
|
|
1750
|
+
const rootStyle = layout === "contained" ? { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, overflow: "hidden" } : { display: "flex", flexDirection: "column", height: "100dvh" };
|
|
1739
1751
|
return (
|
|
1740
1752
|
// B3-FIGLASS-15: the ROOT is full-width — the fluid cap (100% minus a 60px
|
|
1741
1753
|
// gutter) lives on INNER content wrappers (transcript + composer), never on
|
|
1742
1754
|
// the scroll container, so the scrollbar renders at the viewport edge like
|
|
1743
1755
|
// ChatGPT/AURITY /chat instead of glued to the centered column.
|
|
1744
|
-
/* @__PURE__ */ jsxs19("div", { style:
|
|
1756
|
+
/* @__PURE__ */ jsxs19("div", { style: rootStyle, children: [
|
|
1745
1757
|
/* @__PURE__ */ jsxs19("div", { style: { position: "relative", flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
|
|
1746
1758
|
/* @__PURE__ */ jsx26(
|
|
1747
1759
|
"div",
|
|
@@ -1959,9 +1971,64 @@ function AgentConversationSurface({
|
|
|
1959
1971
|
] })
|
|
1960
1972
|
);
|
|
1961
1973
|
}
|
|
1974
|
+
|
|
1975
|
+
// src/agent/AgentWorkspaceShell.tsx
|
|
1976
|
+
import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1977
|
+
function AgentWorkspaceShell({
|
|
1978
|
+
visual = "aurora",
|
|
1979
|
+
density = "comfortable",
|
|
1980
|
+
header,
|
|
1981
|
+
conversation,
|
|
1982
|
+
rail,
|
|
1983
|
+
footer,
|
|
1984
|
+
className,
|
|
1985
|
+
style
|
|
1986
|
+
}) {
|
|
1987
|
+
const rootStyle = {
|
|
1988
|
+
display: "flex",
|
|
1989
|
+
flexDirection: "column",
|
|
1990
|
+
height: "100dvh",
|
|
1991
|
+
minHeight: 0,
|
|
1992
|
+
overflow: "hidden"
|
|
1993
|
+
};
|
|
1994
|
+
const mainStyle = {
|
|
1995
|
+
display: "grid",
|
|
1996
|
+
gridTemplateColumns: rail ? "minmax(0, 1fr) minmax(280px, 360px)" : "minmax(0, 1fr)",
|
|
1997
|
+
flex: "1 1 auto",
|
|
1998
|
+
minHeight: 0,
|
|
1999
|
+
overflow: "hidden"
|
|
2000
|
+
};
|
|
2001
|
+
const conversationStyle = { minHeight: 0, overflow: "hidden" };
|
|
2002
|
+
const railStyle = { minHeight: 0, overflowY: "auto" };
|
|
2003
|
+
const rootClassName = [
|
|
2004
|
+
"fi-agent-workspace",
|
|
2005
|
+
`fi-visual-${visual}`,
|
|
2006
|
+
`fi-density-${density}`,
|
|
2007
|
+
className
|
|
2008
|
+
].filter(Boolean).join(" ");
|
|
2009
|
+
return /* @__PURE__ */ jsxs20(
|
|
2010
|
+
"div",
|
|
2011
|
+
{
|
|
2012
|
+
"data-fi-workspace": "agent",
|
|
2013
|
+
"data-fi-visual": visual,
|
|
2014
|
+
"data-fi-density": density,
|
|
2015
|
+
className: rootClassName,
|
|
2016
|
+
style: { ...rootStyle, ...style },
|
|
2017
|
+
children: [
|
|
2018
|
+
header != null && /* @__PURE__ */ jsx27("div", { "data-fi-slot": "header", children: header }),
|
|
2019
|
+
/* @__PURE__ */ jsxs20("div", { "data-fi-slot": "main", style: mainStyle, children: [
|
|
2020
|
+
/* @__PURE__ */ jsx27("div", { "data-fi-slot": "conversation", style: conversationStyle, children: conversation }),
|
|
2021
|
+
rail != null && /* @__PURE__ */ jsx27("div", { "data-fi-slot": "rail", style: railStyle, children: rail })
|
|
2022
|
+
] }),
|
|
2023
|
+
footer != null && /* @__PURE__ */ jsx27("div", { "data-fi-slot": "footer", children: footer })
|
|
2024
|
+
]
|
|
2025
|
+
}
|
|
2026
|
+
);
|
|
2027
|
+
}
|
|
1962
2028
|
export {
|
|
1963
2029
|
AgentConversationSurface,
|
|
1964
2030
|
AgentPanel,
|
|
2031
|
+
AgentWorkspaceShell,
|
|
1965
2032
|
DEFAULT_TURN_TIMEOUT_MS,
|
|
1966
2033
|
PlanChecklist,
|
|
1967
2034
|
ScrollToBottomButton,
|