@aintela/chat 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/{atMentions-CCNBOf5W.js → atMentions-BhAwZTm1.js} +104 -88
- package/dist/atMentions-BhAwZTm1.js.map +1 -0
- package/dist/components.js +9822 -11029
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{httpArtifactService-kXjuQtGa.js → httpArtifactService-qcYDyDh_.js} +47 -28
- package/dist/httpArtifactService-qcYDyDh_.js.map +1 -0
- package/dist/{httpSessionService-CMT6k-Nu.js → httpSessionService-DXlT2vxT.js} +33 -22
- package/dist/httpSessionService-DXlT2vxT.js.map +1 -0
- package/dist/index.js +237 -221
- package/dist/services.js +2 -2
- package/dist/src/components/AiChat/AiChatContext.d.ts +0 -3
- package/dist/src/components/AiChat/AiChatTypes.d.ts +0 -11
- package/dist/src/components/AiChat/ChatPane/ChatPane.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/MessageAgent.d.ts +0 -1
- package/dist/src/components/AiChat/ChatPane/MessagePart.d.ts +5 -3
- package/dist/src/components/AiChat/ChatPane/MessagePart.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/friendlyToolConfig.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/messageAgentThoughts.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/parts/uiToolDispatcher.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.test.d.ts +1 -0
- package/dist/src/components/AiChat/index.d.ts +1 -3
- package/dist/src/components/index.d.ts +0 -3
- package/dist/src/components/v2/AiChatFloating.d.ts +3 -0
- package/dist/src/components/v2/PromptV2.d.ts +47 -6
- package/dist/src/components/v2/PromptV2.test.d.ts +1 -0
- package/dist/src/components/v2/icons.d.ts +1 -0
- package/dist/src/components/v2/index.d.ts +27 -25
- package/dist/src/components/v2/useVisualViewport.d.ts +20 -0
- package/dist/src/models/Notification.d.ts +11 -0
- package/dist/src/models/index.d.ts +1 -1
- package/dist/src/services/storageService.d.ts +18 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/swallowNextClick.d.ts +16 -0
- package/dist/src/utils/urlParser.test.d.ts +1 -0
- package/dist/tests/fakes/fakeChatServices.d.ts +42 -0
- package/dist/{useChatSessions-CpHq0e1n.js → useChatSessions-1AAvAdPW.js} +2 -2
- package/dist/{useChatSessions-CpHq0e1n.js.map → useChatSessions-1AAvAdPW.js.map} +1 -1
- package/dist/utils.js +22 -21
- package/package.json +1 -1
- package/dist/atMentions-CCNBOf5W.js.map +0 -1
- package/dist/httpArtifactService-kXjuQtGa.js.map +0 -1
- package/dist/httpSessionService-CMT6k-Nu.js.map +0 -1
- package/dist/src/components/AiChat/AiChatFloating.d.ts +0 -3
- package/dist/src/components/AiChat/ChatPane/LastPrompts.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/Prompt.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/SubAgentBox.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/TaskList.d.ts +0 -6
- package/dist/src/components/v2/AiChatFloatingV2.d.ts +0 -3
|
@@ -15,6 +15,17 @@ interface PromptV2Props {
|
|
|
15
15
|
/** Show the prompt-history popover trigger inside the pill. Default true. */
|
|
16
16
|
showLastPrompts?: boolean;
|
|
17
17
|
showConfigOptions?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Show the paperclip next to the send button. Default true.
|
|
20
|
+
*
|
|
21
|
+
* This hides the BUTTON, not the feature: drag & drop and paste keep
|
|
22
|
+
* working, and an image that arrives either way still gets its
|
|
23
|
+
* thumbnail and still rides out with the message. Pass `false` where
|
|
24
|
+
* an explicit "attach a file" affordance would be misleading — a host
|
|
25
|
+
* whose agent has nothing to do with images, or a surface too cramped
|
|
26
|
+
* to spend a slot on it.
|
|
27
|
+
*/
|
|
28
|
+
showAttachmentButton?: boolean;
|
|
18
29
|
/**
|
|
19
30
|
* Placeholder text for the textarea. Defaults to the data-explorer
|
|
20
31
|
* phrasing ("Pergunte sobre seus dados…"); hosts in other domains
|
|
@@ -80,12 +91,30 @@ interface PromptV2Props {
|
|
|
80
91
|
*/
|
|
81
92
|
sendButtonProps?: Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color'>;
|
|
82
93
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* the
|
|
87
|
-
*
|
|
88
|
-
*
|
|
94
|
+
* How the send (and the suspended "continue") button reads.
|
|
95
|
+
*
|
|
96
|
+
* - `'label'` — the filled `Enviar ↵` chip.
|
|
97
|
+
* - `'icon'` — the paper-plane glyph alone. What a narrow surface wants: the
|
|
98
|
+
* chip costs ~90px of a phone's action row, and `↵` is a promise a
|
|
99
|
+
* touch keyboard does not keep.
|
|
100
|
+
* - `'auto'` (default) — `'icon'` on a coarse pointer or a dark theme,
|
|
101
|
+
* `'label'` otherwise. Preserves the behaviour from before this prop
|
|
102
|
+
* existed, which keyed off the theme mode alone.
|
|
103
|
+
*
|
|
104
|
+
* The connecting state is a spinner in every variant.
|
|
105
|
+
*/
|
|
106
|
+
sendButtonVariant?: 'auto' | 'icon' | 'label';
|
|
107
|
+
/**
|
|
108
|
+
* Allow submitting with an empty textarea. Defaults to `true`.
|
|
109
|
+
*
|
|
110
|
+
* The permissive default is what a host with its own content surface
|
|
111
|
+
* needs: the dashboard composer's sketch, or an image attachment, IS the
|
|
112
|
+
* message, and forcing the user to type something alongside it would be
|
|
113
|
+
* busywork. Attachments count as content on their own, so an image with no
|
|
114
|
+
* text is a valid send whatever this is set to.
|
|
115
|
+
*
|
|
116
|
+
* Hosts where the typed text IS the intent — the data explorer — pass
|
|
117
|
+
* `false` so an empty send is refused and the button reads disabled.
|
|
89
118
|
*/
|
|
90
119
|
allowEmptyDraft?: boolean;
|
|
91
120
|
/**
|
|
@@ -191,6 +220,18 @@ interface PromptV2Props {
|
|
|
191
220
|
* - `'popover'` / `'panel'` — force one, for hosts that know better than the media query.
|
|
192
221
|
*/
|
|
193
222
|
mentionPicker?: 'auto' | 'popover' | 'panel';
|
|
223
|
+
/**
|
|
224
|
+
* Where the `#` date picker opens — the calendar's twin of `mentionPicker`, and for the same
|
|
225
|
+
* reason: caret-anchored means "right under the keyboard" on a phone, and a calendar is much
|
|
226
|
+
* taller than a mention row, so it loses that fight badly.
|
|
227
|
+
* - `'auto'` (default) — caret-anchored where there's a mouse, screen-centered on a coarse pointer.
|
|
228
|
+
* - `'popover'` / `'center'` — force one.
|
|
229
|
+
*
|
|
230
|
+
* Centered is modal-looking (a scrim) but is NOT a focus trap: the textarea keeps focus and the
|
|
231
|
+
* caret, so the picked date splices in exactly where `#` was typed. Tapping the scrim or pressing
|
|
232
|
+
* Escape dismisses it, leaving the `#` as plain text.
|
|
233
|
+
*/
|
|
234
|
+
datePicker?: 'auto' | 'popover' | 'center';
|
|
194
235
|
/** Chip tint for unfilled `[template placeholders]` (#447). Falls back to `slashColor`, then `hashColor`. */
|
|
195
236
|
placeholderColor?: string;
|
|
196
237
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -24,6 +24,7 @@ export declare const PauseIcon: (p: IconProps) => React.ReactElement<any, string
|
|
|
24
24
|
export declare const StopIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
25
25
|
export declare const HistoryIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
26
26
|
export declare const MenuIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
27
|
+
export declare const PaperclipIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
27
28
|
export declare const PenIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
28
29
|
export declare const RotateIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
29
30
|
export declare const UndoIcon: (p: IconProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -4,20 +4,20 @@ export * from './icons';
|
|
|
4
4
|
export * from './styles';
|
|
5
5
|
export { Sparkline } from './Sparkline';
|
|
6
6
|
export type { SparklineProps } from './Sparkline';
|
|
7
|
-
export { AppShellV2 } from './AppShellV2';
|
|
8
|
-
export type { AppShellV2Props } from './AppShellV2';
|
|
9
|
-
export { AppRailV2 } from './AppRailV2';
|
|
10
|
-
export type { AppRailV2Props, AppRailV2View } from './AppRailV2';
|
|
11
|
-
export { AppBarV2, APPBAR_V2_HEIGHT } from './AppBarV2';
|
|
12
|
-
export type { AppBarV2Props } from './AppBarV2';
|
|
13
|
-
export { MobileDrawerV2, MOBILE_NAV_DEFAULT, } from './MobileDrawerV2';
|
|
14
|
-
export type { MobileDrawerV2Props, MobileDrawerV2NavItem } from './MobileDrawerV2';
|
|
7
|
+
export { AppShellV2 as AppShell, AppShellV2 } from './AppShellV2';
|
|
8
|
+
export type { AppShellV2Props as AppShellProps, AppShellV2Props } from './AppShellV2';
|
|
9
|
+
export { AppRailV2 as AppRail, AppRailV2 } from './AppRailV2';
|
|
10
|
+
export type { AppRailV2Props as AppRailProps, AppRailV2Props, AppRailV2View as AppRailView, AppRailV2View } from './AppRailV2';
|
|
11
|
+
export { AppBarV2 as AppBar, AppBarV2, APPBAR_V2_HEIGHT as APPBAR_HEIGHT, APPBAR_V2_HEIGHT } from './AppBarV2';
|
|
12
|
+
export type { AppBarV2Props as AppBarProps, AppBarV2Props } from './AppBarV2';
|
|
13
|
+
export { MobileDrawerV2 as MobileDrawer, MobileDrawerV2, MOBILE_NAV_DEFAULT, } from './MobileDrawerV2';
|
|
14
|
+
export type { MobileDrawerV2Props as MobileDrawerProps, MobileDrawerV2Props, MobileDrawerV2NavItem as MobileDrawerNavItem, MobileDrawerV2NavItem, } from './MobileDrawerV2';
|
|
15
15
|
export { useResponsiveLayout } from './useResponsiveLayout';
|
|
16
16
|
export type { ResponsiveLayout } from './useResponsiveLayout';
|
|
17
|
-
export { AiChatFloatingV2 } from './
|
|
18
|
-
export { AiChatV2Pane } from './AiChatV2Pane';
|
|
19
|
-
export type { AiChatV2PaneProps } from './AiChatV2Pane';
|
|
20
|
-
export { PromptV2 } from './PromptV2';
|
|
17
|
+
export { AiChatFloating, AiChatFloating as AiChatFloatingV2 } from './AiChatFloating';
|
|
18
|
+
export { AiChatV2Pane as AiChatPane, AiChatV2Pane } from './AiChatV2Pane';
|
|
19
|
+
export type { AiChatV2PaneProps as AiChatPaneProps, AiChatV2PaneProps } from './AiChatV2Pane';
|
|
20
|
+
export { PromptV2 as Prompt, PromptV2 } from './PromptV2';
|
|
21
21
|
export type { PromptTriggerItem } from './PromptV2';
|
|
22
22
|
export { TriggerDropdown } from './TriggerDropdown';
|
|
23
23
|
export type { TriggerDropdownProps } from './TriggerDropdown';
|
|
@@ -26,18 +26,20 @@ export type { PromptGhostHintProps } from './PromptGhostHint';
|
|
|
26
26
|
export { MentionPickerPanel } from './MentionPickerPanel';
|
|
27
27
|
export type { MentionPickerPanelProps } from './MentionPickerPanel';
|
|
28
28
|
export { useCoarsePointer } from './useCoarsePointer';
|
|
29
|
+
export { useVisualViewport } from './useVisualViewport';
|
|
30
|
+
export type { VisualViewportRect } from './useVisualViewport';
|
|
29
31
|
export { PromptDateMarkers } from './PromptDateMarkers';
|
|
30
32
|
export type { PromptDateMarker } from './PromptDateMarkers';
|
|
31
|
-
export { LastPromptsV2 } from './LastPromptsV2';
|
|
32
|
-
export type { LastPromptsV2Props } from './LastPromptsV2';
|
|
33
|
-
export { ChatsHistoryV2 } from './ChatsHistoryV2';
|
|
34
|
-
export type { ChatsHistoryV2Props, ChatsHistoryV2Item, } from './ChatsHistoryV2';
|
|
35
|
-
export { TaskListV2 } from './TaskListV2';
|
|
36
|
-
export type { TaskListV2Props } from './TaskListV2';
|
|
37
|
-
export { SubAgentBoxV2 } from './SubAgentBoxV2';
|
|
38
|
-
export type { SubAgentBoxV2Props, SubAgentBoxV2Level } from './SubAgentBoxV2';
|
|
39
|
-
export { AgentActivityV2 } from './AgentActivityV2';
|
|
40
|
-
export type { AgentActivityV2Props } from './AgentActivityV2';
|
|
41
|
-
export { RunProgressPanelV2 } from './RunProgressPanelV2';
|
|
42
|
-
export type { RunProgressPanelV2Props } from './RunProgressPanelV2';
|
|
43
|
-
export { RunProgressStripV2 } from './RunProgressStripV2';
|
|
33
|
+
export { LastPromptsV2 as LastPrompts, LastPromptsV2 } from './LastPromptsV2';
|
|
34
|
+
export type { LastPromptsV2Props as LastPromptsProps, LastPromptsV2Props } from './LastPromptsV2';
|
|
35
|
+
export { ChatsHistoryV2 as ChatsHistory, ChatsHistoryV2 } from './ChatsHistoryV2';
|
|
36
|
+
export type { ChatsHistoryV2Props as ChatsHistoryProps, ChatsHistoryV2Props, ChatsHistoryV2Item as ChatsHistoryItem, ChatsHistoryV2Item, } from './ChatsHistoryV2';
|
|
37
|
+
export { TaskListV2 as TaskList, TaskListV2 } from './TaskListV2';
|
|
38
|
+
export type { TaskListV2Props as TaskListProps, TaskListV2Props } from './TaskListV2';
|
|
39
|
+
export { SubAgentBoxV2 as SubAgentBox, SubAgentBoxV2 } from './SubAgentBoxV2';
|
|
40
|
+
export type { SubAgentBoxV2Props as SubAgentBoxProps, SubAgentBoxV2Props, SubAgentBoxV2Level as SubAgentBoxLevel, SubAgentBoxV2Level } from './SubAgentBoxV2';
|
|
41
|
+
export { AgentActivityV2 as AgentActivity, AgentActivityV2 } from './AgentActivityV2';
|
|
42
|
+
export type { AgentActivityV2Props as AgentActivityProps, AgentActivityV2Props } from './AgentActivityV2';
|
|
43
|
+
export { RunProgressPanelV2 as RunProgressPanel, RunProgressPanelV2 } from './RunProgressPanelV2';
|
|
44
|
+
export type { RunProgressPanelV2Props as RunProgressPanelProps, RunProgressPanelV2Props } from './RunProgressPanelV2';
|
|
45
|
+
export { RunProgressStripV2 as RunProgressStrip, RunProgressStripV2 } from './RunProgressStripV2';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The part of the page a keyboard is NOT covering, in client (fixed-position) coordinates. */
|
|
2
|
+
export interface VisualViewportRect {
|
|
3
|
+
top: number;
|
|
4
|
+
left: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The live visual viewport — the rectangle actually visible to the user, which is what a surface meant to be
|
|
10
|
+
* "centred on screen" has to centre inside.
|
|
11
|
+
*
|
|
12
|
+
* `position: fixed; inset: 0` is centred on the LAYOUT viewport, and with a keyboard up the two are different
|
|
13
|
+
* rectangles: the layout viewport still spans the area behind the keyboard, so anything centred in it drifts
|
|
14
|
+
* down under the keys — the taller the surface (a calendar is ~340px), the more of it disappears. In a Capacitor
|
|
15
|
+
* WebView with `KeyboardResize.Native` the frame does shrink, but measurably NOT to the visible area (29px of
|
|
16
|
+
* page stayed behind the keyboard on an iPhone 15), so even there the frame is the wrong rectangle to trust.
|
|
17
|
+
*
|
|
18
|
+
* Only subscribes while `active`, so the ordinary desktop case adds no listeners.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useVisualViewport(active: boolean): VisualViewportRect;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
export type NotificationType = 'info' | 'warning' | 'error';
|
|
2
|
+
/**
|
|
3
|
+
* A stable identity for the notifications the library raises on its own, so a host can recognise one
|
|
4
|
+
* without matching its (pt-BR, and freely reworded) `message`.
|
|
5
|
+
*
|
|
6
|
+
* - `connection-restarting` — a working socket dropped and the gateway is redialling. Hosts that draw
|
|
7
|
+
* their own connection affordance suppress this one; see `AgentGatewayWSAsync`'s `everConnected`
|
|
8
|
+
* gate for why it is not raised on the initial dial.
|
|
9
|
+
*/
|
|
10
|
+
export type NotificationKind = 'connection-restarting';
|
|
2
11
|
export interface BasicNotification {
|
|
3
12
|
type: NotificationType;
|
|
4
13
|
message: string;
|
|
5
14
|
details?: string;
|
|
15
|
+
/** Set on library-raised notifications. Absent on anything a host pushes through the port. */
|
|
16
|
+
kind?: NotificationKind;
|
|
6
17
|
}
|
|
7
18
|
export interface EnvironmentNotification extends BasicNotification {
|
|
8
19
|
id: string;
|
|
@@ -26,7 +26,7 @@ export { PromptUtils } from './Prompt';
|
|
|
26
26
|
export type { EndMessageData } from './EndMessageData';
|
|
27
27
|
export type { LlmSession, LlmCreateSessionResponse } from './LlmSession';
|
|
28
28
|
export type { ServerResponse } from './serverReponse';
|
|
29
|
-
export type { BasicNotification, EnvironmentNotification } from './Notification';
|
|
29
|
+
export type { BasicNotification, EnvironmentNotification, NotificationKind, NotificationType } from './Notification';
|
|
30
30
|
export { MemoryContexts, MemoryContextLabels } from './Memory';
|
|
31
31
|
export type { SemanticMemory, SemanticMemoryInput, SemanticMemorySearchOptions } from './Memory';
|
|
32
32
|
export type { FunctionDetails, ThoughtDetails, TextDetails, ErrorDetails, ToolEventDetails, ExecutableCodeDetails, CodeExecutionResultDetails, } from './ServerEvent';
|
|
@@ -17,6 +17,24 @@ export interface IStorageService {
|
|
|
17
17
|
/** The only implementation — no consumer has ever supplied its own. */
|
|
18
18
|
export declare class LocalStorageService implements IStorageService {
|
|
19
19
|
getPrompts(): Prompt[];
|
|
20
|
+
/**
|
|
21
|
+
* Record a sent prompt, most recent first, de-duplicated by text.
|
|
22
|
+
*
|
|
23
|
+
* Asking the same thing again MOVES that entry to the top rather than adding
|
|
24
|
+
* a second copy — the history is a list of distinct things you have asked,
|
|
25
|
+
* and a repeated question spending two of the twelve visible rows costs a
|
|
26
|
+
* suggestion for nothing. The repeat's own `id` and `created` win, because
|
|
27
|
+
* what the list orders by is when you last asked.
|
|
28
|
+
*
|
|
29
|
+
* The dedupe used to look only at `prompts[0]`, and then unshifted anyway:
|
|
30
|
+
* a consecutive repeat overwrote the older copy's id and timestamp AND
|
|
31
|
+
* appended a new row, so the same text appeared twice with the same id.
|
|
32
|
+
*
|
|
33
|
+
* Matching is exact on `promptText` (`PromptUtils.createPrompt` has already
|
|
34
|
+
* trimmed it). Two prompts differing only in case or inner whitespace stay
|
|
35
|
+
* separate entries — that is deliberate, not an oversight: normalising them
|
|
36
|
+
* would mean re-surfacing text the user never typed.
|
|
37
|
+
*/
|
|
20
38
|
storePrompt(prompt: Prompt): void;
|
|
21
39
|
clearAllPrompts(): void;
|
|
22
40
|
}
|
|
@@ -14,6 +14,7 @@ export { default as SortableTable } from './sortable-table';
|
|
|
14
14
|
export { tokenizeForHighlight, chipLocations } from './promptHighlight';
|
|
15
15
|
export type { HighlightToken } from './promptHighlight';
|
|
16
16
|
export { placeCaret } from './placeCaret';
|
|
17
|
+
export { swallowNextClick } from './swallowNextClick';
|
|
17
18
|
export { detectTrigger, applyTriggerInsertion, findPlaceholder, placeholderAt, activatePlaceholder, advanceToPlaceholder, } from './promptTriggers';
|
|
18
19
|
export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder } from './promptTriggers';
|
|
19
20
|
export { fetchAtMentions, isSectionStart } from './atMentions';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eat the compatibility `click` that follows a `pointerdown`/`touchend` you have already acted on.
|
|
3
|
+
*
|
|
4
|
+
* A touch that lands on a control which then unmounts (or opens something over the spot) leaves the
|
|
5
|
+
* browser's synthesised click to fall on **whatever is now under the finger** — that is how picking a
|
|
6
|
+
* location once sent the prompt, the send button having slid under the tap. The same click is also
|
|
7
|
+
* what a `<ClickAwayListener>` sees as "the user clicked outside", so a surface opened during
|
|
8
|
+
* `pointerdown` is closed again microseconds later by the click of the very gesture that opened it.
|
|
9
|
+
*
|
|
10
|
+
* Cancelling `pointerdown` would suppress the compatibility events, but on touch that also kills
|
|
11
|
+
* scrolling — so the click is intercepted instead.
|
|
12
|
+
*
|
|
13
|
+
* Capture phase, so it never reaches the target (or a document-level away-listener); self-removing,
|
|
14
|
+
* and time-boxed in case no click arrives at all (the browser is not obliged to send one).
|
|
15
|
+
*/
|
|
16
|
+
export declare function swallowNextClick(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AiChatContextState } from '../../src/components/AiChat/AiChatContext';
|
|
2
|
+
import { AiChatStore } from '../../src/components/AiChat/stateConfiguration';
|
|
3
|
+
import { EventBusService } from '../../src/services/eventBusService';
|
|
4
|
+
import { SendMessageOptions } from '../../src/components/AiChat/AiChatTypes';
|
|
5
|
+
import { MakeGatewayOptions, FakeNotificationCapture } from './makeGateway';
|
|
6
|
+
import { FakeStorage } from './fakeStorage';
|
|
7
|
+
import { FakeWebSocketConnection } from './fakeWebSocket';
|
|
8
|
+
/** One turn the component asked to send, as the UI phrased it. */
|
|
9
|
+
export interface RecordedSend {
|
|
10
|
+
text: string;
|
|
11
|
+
options?: SendMessageOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface FakeChatServices {
|
|
14
|
+
/** Hand this to `<AiChatServiceContext.Provider value={…}>`. */
|
|
15
|
+
context: AiChatContextState;
|
|
16
|
+
/** The same object — mutate a field then re-render to test a context switch. */
|
|
17
|
+
store: AiChatStore;
|
|
18
|
+
bus: EventBusService;
|
|
19
|
+
ws: FakeWebSocketConnection;
|
|
20
|
+
storage: FakeStorage;
|
|
21
|
+
notifications: FakeNotificationCapture;
|
|
22
|
+
/** Everything the component passed to `sendMessage`, in order. */
|
|
23
|
+
sent: RecordedSend[];
|
|
24
|
+
}
|
|
25
|
+
export interface FakeChatServicesOptions extends MakeGatewayOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Context fields to replace. The `show*` flags, `partRenderers`, `uiTools`
|
|
28
|
+
* and the callbacks are the interesting ones; passing a service here
|
|
29
|
+
* overrides the real one built below.
|
|
30
|
+
*/
|
|
31
|
+
overrides?: Partial<AiChatContextState>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build a complete chat-services context for a component test.
|
|
35
|
+
*
|
|
36
|
+
* `sendMessage` records rather than sends — the components under test are being
|
|
37
|
+
* asked "did you decide to send, and with what?", which is a different question
|
|
38
|
+
* from "does the gateway put it on the wire" (that one is
|
|
39
|
+
* `agentGatewayAgentContext.test.ts`). Tests that want the real path can
|
|
40
|
+
* override `sendMessage` with `services.context.agentGatewayService`'s.
|
|
41
|
+
*/
|
|
42
|
+
export declare function fakeChatServices(options?: FakeChatServicesOptions): FakeChatServices;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var L = Object.defineProperty;
|
|
2
2
|
var d = (e, t) => L(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
import { useMemo as h, useState as v, useCallback as g, useEffect as C } from "react";
|
|
4
|
-
import { H } from "./httpSessionService-
|
|
4
|
+
import { H } from "./httpSessionService-DXlT2vxT.js";
|
|
5
5
|
const w = 6e4, y = 60 * w, l = 24 * y;
|
|
6
6
|
function k(e) {
|
|
7
7
|
if (!e) return;
|
|
@@ -104,4 +104,4 @@ d(Y, "useChatSessions");
|
|
|
104
104
|
export {
|
|
105
105
|
Y as u
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=useChatSessions-
|
|
107
|
+
//# sourceMappingURL=useChatSessions-1AAvAdPW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatSessions-CpHq0e1n.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACzBS,IAAOR,IAAgB,GAAG,KAAK,MAAMQ,IAAOT,CAAS,CAAC,MACtDS,IAAOP,IAAe,GAAG,KAAK,MAAMO,IAAOR,CAAO,CAAC,MACnDQ,IAAO,IAAIP,IAAe,GAAG,KAAK,MAAMO,IAAOP,CAAM,CAAC,MACnDM,EAAK,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,WAAW;AAChF;AARSF,EAAAC,GAAA;AAUT,SAASG,IAAqB;AAC1B,QAAML,wBAAQ,KAAA;AACd,SAAAA,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACdA;AACX;AAJSC,EAAAI,GAAA;AAMT,SAASC,EAAYC,GAAkD;AACnE,QAAMC,IAAQH,EAAA,GACRI,IAAY,IAAI,KAAKD,EAAM,QAAA,IAAYX,CAAM,GAC7Ca,IAAU,IAAI,KAAKF,EAAM,QAAA,IAAY,IAAIX,CAAM,GAC/Cc,IAAW,IAAI,KAAKH,EAAM,QAAA,IAAY,KAAKX,CAAM,GAGjDe,IAAkD;AAAA,IACpD,CAAC,SAAS,CAAA,CAAE;AAAA,IACZ,CAAC,aAAa,CAAA,CAAE;AAAA,IAChB,CAAC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AAUwB,GAAGtB,CAAQ,CAAC;AAAA,IAC5C,CAACoB,GAAQpB,CAAQ;AAAA,EAAA,GAGfwB,IAASnB,EAAQ,MAAMlB,EAAYC,CAAK,GAAG,CAACA,CAAK,CAAC,GAElDqC,IAASR,EAAY,OAAOS,GAAYC,MAAkB;AAC5D,IAAAjB;AAAA,MAAY,CAAAkB,MACRA,EAAQ,IAAI,CAAAN,MAAMA,EAAE,OAAOI,IAAK,EAAE,GAAGJ,GAAG,UAAUK,EAAA,IAAUL,CAAE;AAAA,IAAA;AAElE,QAAI;AACA,YAAMf,EAAe,aAAamB,GAAI,EAAE,UAAUC,GAAO;AAAA,IAC7D,SAAST,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
|
|
1
|
+
{"version":3,"file":"useChatSessions-1AAvAdPW.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACzBS,IAAOR,IAAgB,GAAG,KAAK,MAAMQ,IAAOT,CAAS,CAAC,MACtDS,IAAOP,IAAe,GAAG,KAAK,MAAMO,IAAOR,CAAO,CAAC,MACnDQ,IAAO,IAAIP,IAAe,GAAG,KAAK,MAAMO,IAAOP,CAAM,CAAC,MACnDM,EAAK,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,WAAW;AAChF;AARSF,EAAAC,GAAA;AAUT,SAASG,IAAqB;AAC1B,QAAML,wBAAQ,KAAA;AACd,SAAAA,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACdA;AACX;AAJSC,EAAAI,GAAA;AAMT,SAASC,EAAYC,GAAkD;AACnE,QAAMC,IAAQH,EAAA,GACRI,IAAY,IAAI,KAAKD,EAAM,QAAA,IAAYX,CAAM,GAC7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1
|
var u = Object.defineProperty;
|
|
2
2
|
var a = (e, t) => u(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
import { a as c, b as s } from "./environmentUtils-VZNTCzEE.js";
|
|
4
|
-
import { A as
|
|
5
|
-
import { S as Y, a as Z, b as j, c as
|
|
6
|
-
const m = "https://agent.tripapi.com.br", p = "http://localagent:8000", S = /* @__PURE__ */ a((e) => new URLSearchParams(e.location.search).get("local") === "true" ? p : c() ?? m, "getAgentBaseUrl"), f = "https://storage.googleapis.com/aibi_artifacts_bucket", I = /* @__PURE__ */ a(() => f, "getArtifactsBaseUrl"),
|
|
7
|
-
function
|
|
4
|
+
import { A as k, D as U, g as x, c as M, d as V, e as G, f as R, i as H, r as W } from "./environmentUtils-VZNTCzEE.js";
|
|
5
|
+
import { S as Y, a as Z, b as j, c as q, d as z, e as Q, f as $, g as J, h as X, i as ee, j as te, k as oe, l as ae, p as re, m as ie, s as ne, o as se, q as le, t as ce } from "./atMentions-BhAwZTm1.js";
|
|
6
|
+
const m = "https://agent.tripapi.com.br", p = "http://localagent:8000", S = /* @__PURE__ */ a((e) => new URLSearchParams(e.location.search).get("local") === "true" ? p : c() ?? m, "getAgentBaseUrl"), f = "https://storage.googleapis.com/aibi_artifacts_bucket", I = /* @__PURE__ */ a(() => f, "getArtifactsBaseUrl"), n = {}, h = (n == null ? void 0 : n.VITE_CADDY) == "true";
|
|
7
|
+
function w() {
|
|
8
8
|
const e = h ? "http://wsserver.localhost" : "http://localhost:8000";
|
|
9
9
|
if (typeof window < "u" && (window != null && window.location)) {
|
|
10
10
|
const t = window.location.host.toLowerCase();
|
|
@@ -12,11 +12,11 @@ function F() {
|
|
|
12
12
|
}
|
|
13
13
|
return typeof process < "u" && process.env && (process.env.AGENT_BASE_URL || process.env.DOTNET_API_URL) || e;
|
|
14
14
|
}
|
|
15
|
-
a(
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
}, "setEbiContextData"),
|
|
15
|
+
a(w, "getDotNetBaseUrl");
|
|
16
|
+
const F = /* @__PURE__ */ a((e, t, r = null, d = null) => {
|
|
17
|
+
const i = e.customElements.get("ebi-context-data");
|
|
18
|
+
i && (i.user = t, i.context = r || null, i.sessionId = d);
|
|
19
|
+
}, "setEbiContextData"), v = /* @__PURE__ */ a((e) => {
|
|
20
20
|
const t = window.customElements.get("ebi-context-data");
|
|
21
21
|
t && (t.sessionId = e);
|
|
22
22
|
}, "setEbiContextSessionId");
|
|
@@ -300,17 +300,17 @@ const B = ((l = s("ALLOWED_EMAILS")) == null ? void 0 : l.split(",")) ?? [], N =
|
|
|
300
300
|
export {
|
|
301
301
|
T as ALLOWED_DOMAINS,
|
|
302
302
|
B as ALLOWED_EMAILS,
|
|
303
|
-
|
|
303
|
+
k as ANALYTICS_AGENT_NAME,
|
|
304
304
|
N as AUTH_CONFIG,
|
|
305
|
-
|
|
305
|
+
U as DEV_SERVER_CONFIG,
|
|
306
306
|
y as GOOGLE_CLIENT_ID,
|
|
307
307
|
Y as SortableTable,
|
|
308
308
|
Z as activatePlaceholder,
|
|
309
309
|
j as advanceToPlaceholder,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
q as applyTriggerInsertion,
|
|
311
|
+
z as chipLocations,
|
|
312
|
+
Q as chunkArray,
|
|
313
|
+
$ as detectTrigger,
|
|
314
314
|
J as extractInteractionId,
|
|
315
315
|
X as extractLinkAction,
|
|
316
316
|
ee as fetchAtMentions,
|
|
@@ -318,7 +318,7 @@ export {
|
|
|
318
318
|
S as getAgentBaseUrl,
|
|
319
319
|
x as getAgentServerBaseUrl,
|
|
320
320
|
I as getArtifactsBaseUrl,
|
|
321
|
-
|
|
321
|
+
w as getDotNetBaseUrl,
|
|
322
322
|
s as getEnvVar,
|
|
323
323
|
M as getEnvironmentInfo,
|
|
324
324
|
O as getIconByName,
|
|
@@ -331,13 +331,14 @@ export {
|
|
|
331
331
|
ae as isValidInteractionId,
|
|
332
332
|
o as materialIcons,
|
|
333
333
|
re as placeCaret,
|
|
334
|
-
|
|
334
|
+
ie as placeholderAt,
|
|
335
335
|
W as resolveApiUrl,
|
|
336
336
|
b as searchIcons,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
F as setEbiContextData,
|
|
338
|
+
v as setEbiContextSessionId,
|
|
339
|
+
ne as splitBigLinesWithSpaces,
|
|
340
340
|
se as startsWithInteractionId,
|
|
341
|
-
le as
|
|
341
|
+
le as swallowNextClick,
|
|
342
|
+
ce as tokenizeForHighlight
|
|
342
343
|
};
|
|
343
344
|
//# sourceMappingURL=utils.js.map
|