@btst/stack 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.cjs +321 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.mjs +306 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.cjs +168 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.mjs +146 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.cjs +29 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.mjs +29 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.cjs +16 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.mjs +16 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.cjs +35 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs +35 -3
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +123 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +121 -0
- package/dist/packages/ui/src/components/accordion.cjs +67 -0
- package/dist/packages/ui/src/components/accordion.mjs +62 -0
- package/dist/plugins/ai-chat/client/components/index.cjs +2 -0
- package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
- package/dist/plugins/ai-chat/client/components/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/index.cjs +2 -0
- package/dist/plugins/ai-chat/client/index.d.cts +5 -176
- package/dist/plugins/ai-chat/client/index.d.mts +5 -176
- package/dist/plugins/ai-chat/client/index.d.ts +5 -176
- package/dist/plugins/ai-chat/client/index.mjs +1 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +6 -0
- package/dist/shared/stack.DaOcgmrM.d.cts +323 -0
- package/dist/shared/stack.DaOcgmrM.d.mts +323 -0
- package/dist/shared/stack.DaOcgmrM.d.ts +323 -0
- package/package.json +1 -1
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +41 -2
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +16 -1
- package/src/plugins/ai-chat/client/components/chat-message.tsx +59 -3
- package/src/plugins/ai-chat/client/components/index.ts +2 -0
- package/src/plugins/ai-chat/client/components/tool-call-display.tsx +197 -0
- package/src/plugins/ai-chat/client/index.ts +12 -1
- package/src/plugins/ai-chat/client/overrides.ts +71 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +6 -0
- package/dist/shared/stack.DorMi9CZ.d.cts +0 -80
- package/dist/shared/stack.DorMi9CZ.d.mts +0 -80
- package/dist/shared/stack.DorMi9CZ.d.ts +0 -80
|
@@ -1,183 +1,12 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ComponentType } from 'react';
|
|
4
3
|
import * as _btst_yar from '@btst/yar';
|
|
5
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
5
|
import { S as SerializedConversation, a as SerializedMessage } from '../../../shared/stack.Be1QIHEn.cjs';
|
|
7
|
-
|
|
6
|
+
import { A as AiChatMode } from '../../../shared/stack.DaOcgmrM.cjs';
|
|
7
|
+
export { a as AiChatPluginOverrides, b as AllowedFileType, i as ChatInput, C as ChatInterface, e as ChatLayout, f as ChatLayoutProps, h as ChatMessage, g as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, j as ToolCallDisplay, T as ToolCallProps, d as ToolCallRenderer, c as ToolCallState } from '../../../shared/stack.DaOcgmrM.cjs';
|
|
8
|
+
export { UIMessage } from 'ai';
|
|
8
9
|
import 'react/jsx-runtime';
|
|
9
|
-
import 'ai';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* AI Chat plugin localization strings
|
|
13
|
-
*/
|
|
14
|
-
interface AiChatLocalization {
|
|
15
|
-
CHAT_PLACEHOLDER: string;
|
|
16
|
-
CHAT_SEND_BUTTON: string;
|
|
17
|
-
CHAT_EMPTY_STATE: string;
|
|
18
|
-
CHAT_LOADING: string;
|
|
19
|
-
CHAT_ERROR: string;
|
|
20
|
-
CHAT_RETRY: string;
|
|
21
|
-
CHAT_GENERIC_ERROR_TITLE: string;
|
|
22
|
-
CHAT_GENERIC_ERROR_MESSAGE: string;
|
|
23
|
-
CHAT_PAGE_NOT_FOUND_TITLE: string;
|
|
24
|
-
CHAT_PAGE_NOT_FOUND_DESCRIPTION: string;
|
|
25
|
-
SIDEBAR_TITLE: string;
|
|
26
|
-
SIDEBAR_NEW_CHAT: string;
|
|
27
|
-
SIDEBAR_NO_CONVERSATIONS: string;
|
|
28
|
-
SIDEBAR_SEARCH_PLACEHOLDER: string;
|
|
29
|
-
CONVERSATION_RENAME: string;
|
|
30
|
-
CONVERSATION_RENAME_PLACEHOLDER: string;
|
|
31
|
-
CONVERSATION_RENAME_SAVE: string;
|
|
32
|
-
CONVERSATION_RENAME_CANCEL: string;
|
|
33
|
-
CONVERSATION_DELETE: string;
|
|
34
|
-
CONVERSATION_DELETE_CONFIRM_TITLE: string;
|
|
35
|
-
CONVERSATION_DELETE_CONFIRM_DESCRIPTION: string;
|
|
36
|
-
CONVERSATION_DELETE_CONFIRM_BUTTON: string;
|
|
37
|
-
CONVERSATION_DELETE_CANCEL: string;
|
|
38
|
-
IMAGE_UPLOAD_BUTTON: string;
|
|
39
|
-
IMAGE_UPLOAD_UPLOADING: string;
|
|
40
|
-
IMAGE_UPLOAD_ERROR_NOT_IMAGE: string;
|
|
41
|
-
IMAGE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
42
|
-
IMAGE_UPLOAD_SUCCESS: string;
|
|
43
|
-
IMAGE_UPLOAD_FAILURE: string;
|
|
44
|
-
FILE_UPLOAD_BUTTON: string;
|
|
45
|
-
FILE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
46
|
-
FILE_UPLOAD_SUCCESS: string;
|
|
47
|
-
FILE_UPLOAD_FAILURE: string;
|
|
48
|
-
TIME_JUST_NOW: string;
|
|
49
|
-
TIME_MINUTES_AGO: string;
|
|
50
|
-
TIME_HOURS_AGO: string;
|
|
51
|
-
TIME_YESTERDAY: string;
|
|
52
|
-
TIME_DAYS_AGO: string;
|
|
53
|
-
MESSAGE_COPY: string;
|
|
54
|
-
MESSAGE_COPIED: string;
|
|
55
|
-
MESSAGE_RETRY: string;
|
|
56
|
-
MESSAGE_EDIT: string;
|
|
57
|
-
MESSAGE_SAVE: string;
|
|
58
|
-
MESSAGE_CANCEL: string;
|
|
59
|
-
A11Y_USER_MESSAGE: string;
|
|
60
|
-
A11Y_ASSISTANT_MESSAGE: string;
|
|
61
|
-
A11Y_COPY_CODE: string;
|
|
62
|
-
A11Y_CODE_COPIED: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Plugin mode for AI Chat
|
|
67
|
-
* - 'authenticated': Conversations persisted with userId (default)
|
|
68
|
-
* - 'public': Stateless chat, no persistence (ideal for public chatbots)
|
|
69
|
-
*/
|
|
70
|
-
type AiChatMode = "authenticated" | "public";
|
|
71
|
-
/**
|
|
72
|
-
* Allowed file type categories for uploads
|
|
73
|
-
*/
|
|
74
|
-
type AllowedFileType = "image" | "text" | "pdf" | "markdown" | "csv" | "json";
|
|
75
|
-
/**
|
|
76
|
-
* Default allowed file types (images only for best AI model compatibility)
|
|
77
|
-
* Consumers can expand this by passing allowedFileTypes in overrides
|
|
78
|
-
*/
|
|
79
|
-
declare const DEFAULT_ALLOWED_FILE_TYPES: AllowedFileType[];
|
|
80
|
-
/**
|
|
81
|
-
* Context passed to lifecycle hooks
|
|
82
|
-
*/
|
|
83
|
-
interface RouteContext$1 {
|
|
84
|
-
/** Current route path */
|
|
85
|
-
path: string;
|
|
86
|
-
/** Route parameters (e.g., { id: "abc123" }) */
|
|
87
|
-
params?: Record<string, string>;
|
|
88
|
-
/** Whether rendering on server (true) or client (false) */
|
|
89
|
-
isSSR: boolean;
|
|
90
|
-
/** Additional context properties */
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Overridable components and functions for the AI Chat plugin
|
|
95
|
-
*
|
|
96
|
-
* External consumers can provide their own implementations of these
|
|
97
|
-
* to customize the behavior for their framework (Next.js, React Router, etc.)
|
|
98
|
-
*/
|
|
99
|
-
interface AiChatPluginOverrides {
|
|
100
|
-
/**
|
|
101
|
-
* Plugin mode - should match backend config
|
|
102
|
-
* @default 'authenticated'
|
|
103
|
-
*/
|
|
104
|
-
mode?: AiChatMode;
|
|
105
|
-
/**
|
|
106
|
-
* API base URL
|
|
107
|
-
*/
|
|
108
|
-
apiBaseURL: string;
|
|
109
|
-
/**
|
|
110
|
-
* API base path
|
|
111
|
-
*/
|
|
112
|
-
apiBasePath: string;
|
|
113
|
-
/**
|
|
114
|
-
* Navigation function for programmatic navigation
|
|
115
|
-
*/
|
|
116
|
-
navigate: (path: string) => void | Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Refresh function to invalidate server-side cache (e.g., Next.js router.refresh())
|
|
119
|
-
*/
|
|
120
|
-
refresh?: () => void | Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Link component for navigation
|
|
123
|
-
*/
|
|
124
|
-
Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
|
|
125
|
-
/**
|
|
126
|
-
* Image component for displaying images
|
|
127
|
-
*/
|
|
128
|
-
Image?: ComponentType<React.ImgHTMLAttributes<HTMLImageElement> & Record<string, any>>;
|
|
129
|
-
/**
|
|
130
|
-
* Function used to upload a file and return its URL.
|
|
131
|
-
* Called for images, PDFs, text files, and other supported file types.
|
|
132
|
-
*/
|
|
133
|
-
uploadFile?: (file: File) => Promise<string>;
|
|
134
|
-
/**
|
|
135
|
-
* Allowed file types for upload.
|
|
136
|
-
* By default, all types are enabled: image, text, pdf, markdown, csv, json
|
|
137
|
-
* Set to empty array to disable file uploads entirely.
|
|
138
|
-
* @default ['image', 'text', 'pdf', 'markdown', 'csv', 'json']
|
|
139
|
-
*/
|
|
140
|
-
allowedFileTypes?: AllowedFileType[];
|
|
141
|
-
/**
|
|
142
|
-
* Localization object for the AI Chat plugin
|
|
143
|
-
*/
|
|
144
|
-
localization?: Partial<AiChatLocalization>;
|
|
145
|
-
/**
|
|
146
|
-
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
147
|
-
*/
|
|
148
|
-
headers?: HeadersInit;
|
|
149
|
-
/**
|
|
150
|
-
* Whether to show the attribution
|
|
151
|
-
* @default true
|
|
152
|
-
*/
|
|
153
|
-
showAttribution?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Called when a route is rendered
|
|
156
|
-
* @param routeName - Name of the route (e.g., 'chat', 'chatConversation')
|
|
157
|
-
* @param context - Route context with path, params, etc.
|
|
158
|
-
*/
|
|
159
|
-
onRouteRender?: (routeName: string, context: RouteContext$1) => void | Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Called when a route encounters an error
|
|
162
|
-
* @param routeName - Name of the route
|
|
163
|
-
* @param error - The error that occurred
|
|
164
|
-
* @param context - Route context
|
|
165
|
-
*/
|
|
166
|
-
onRouteError?: (routeName: string, error: Error, context: RouteContext$1) => void | Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Called before the chat page is rendered
|
|
169
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
170
|
-
* @param context - Route context
|
|
171
|
-
*/
|
|
172
|
-
onBeforeChatPageRendered?: (context: RouteContext$1) => boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Called before a conversation page is rendered
|
|
175
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
176
|
-
* @param id - The conversation ID
|
|
177
|
-
* @param context - Route context
|
|
178
|
-
*/
|
|
179
|
-
onBeforeConversationPageRendered?: (id: string, context: RouteContext$1) => boolean;
|
|
180
|
-
}
|
|
181
10
|
|
|
182
11
|
/**
|
|
183
12
|
* Context passed to route hooks
|
|
@@ -323,5 +152,5 @@ declare const aiChatClientPlugin: (config: AiChatClientConfig) => _btst_stack_pl
|
|
|
323
152
|
};
|
|
324
153
|
}>;
|
|
325
154
|
|
|
326
|
-
export {
|
|
327
|
-
export type { AiChatClientConfig, AiChatClientHooks,
|
|
155
|
+
export { aiChatClientPlugin };
|
|
156
|
+
export type { AiChatClientConfig, AiChatClientHooks, LoaderContext, RouteContext };
|
|
@@ -1,183 +1,12 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ComponentType } from 'react';
|
|
4
3
|
import * as _btst_yar from '@btst/yar';
|
|
5
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
5
|
import { S as SerializedConversation, a as SerializedMessage } from '../../../shared/stack.Be1QIHEn.mjs';
|
|
7
|
-
|
|
6
|
+
import { A as AiChatMode } from '../../../shared/stack.DaOcgmrM.mjs';
|
|
7
|
+
export { a as AiChatPluginOverrides, b as AllowedFileType, i as ChatInput, C as ChatInterface, e as ChatLayout, f as ChatLayoutProps, h as ChatMessage, g as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, j as ToolCallDisplay, T as ToolCallProps, d as ToolCallRenderer, c as ToolCallState } from '../../../shared/stack.DaOcgmrM.mjs';
|
|
8
|
+
export { UIMessage } from 'ai';
|
|
8
9
|
import 'react/jsx-runtime';
|
|
9
|
-
import 'ai';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* AI Chat plugin localization strings
|
|
13
|
-
*/
|
|
14
|
-
interface AiChatLocalization {
|
|
15
|
-
CHAT_PLACEHOLDER: string;
|
|
16
|
-
CHAT_SEND_BUTTON: string;
|
|
17
|
-
CHAT_EMPTY_STATE: string;
|
|
18
|
-
CHAT_LOADING: string;
|
|
19
|
-
CHAT_ERROR: string;
|
|
20
|
-
CHAT_RETRY: string;
|
|
21
|
-
CHAT_GENERIC_ERROR_TITLE: string;
|
|
22
|
-
CHAT_GENERIC_ERROR_MESSAGE: string;
|
|
23
|
-
CHAT_PAGE_NOT_FOUND_TITLE: string;
|
|
24
|
-
CHAT_PAGE_NOT_FOUND_DESCRIPTION: string;
|
|
25
|
-
SIDEBAR_TITLE: string;
|
|
26
|
-
SIDEBAR_NEW_CHAT: string;
|
|
27
|
-
SIDEBAR_NO_CONVERSATIONS: string;
|
|
28
|
-
SIDEBAR_SEARCH_PLACEHOLDER: string;
|
|
29
|
-
CONVERSATION_RENAME: string;
|
|
30
|
-
CONVERSATION_RENAME_PLACEHOLDER: string;
|
|
31
|
-
CONVERSATION_RENAME_SAVE: string;
|
|
32
|
-
CONVERSATION_RENAME_CANCEL: string;
|
|
33
|
-
CONVERSATION_DELETE: string;
|
|
34
|
-
CONVERSATION_DELETE_CONFIRM_TITLE: string;
|
|
35
|
-
CONVERSATION_DELETE_CONFIRM_DESCRIPTION: string;
|
|
36
|
-
CONVERSATION_DELETE_CONFIRM_BUTTON: string;
|
|
37
|
-
CONVERSATION_DELETE_CANCEL: string;
|
|
38
|
-
IMAGE_UPLOAD_BUTTON: string;
|
|
39
|
-
IMAGE_UPLOAD_UPLOADING: string;
|
|
40
|
-
IMAGE_UPLOAD_ERROR_NOT_IMAGE: string;
|
|
41
|
-
IMAGE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
42
|
-
IMAGE_UPLOAD_SUCCESS: string;
|
|
43
|
-
IMAGE_UPLOAD_FAILURE: string;
|
|
44
|
-
FILE_UPLOAD_BUTTON: string;
|
|
45
|
-
FILE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
46
|
-
FILE_UPLOAD_SUCCESS: string;
|
|
47
|
-
FILE_UPLOAD_FAILURE: string;
|
|
48
|
-
TIME_JUST_NOW: string;
|
|
49
|
-
TIME_MINUTES_AGO: string;
|
|
50
|
-
TIME_HOURS_AGO: string;
|
|
51
|
-
TIME_YESTERDAY: string;
|
|
52
|
-
TIME_DAYS_AGO: string;
|
|
53
|
-
MESSAGE_COPY: string;
|
|
54
|
-
MESSAGE_COPIED: string;
|
|
55
|
-
MESSAGE_RETRY: string;
|
|
56
|
-
MESSAGE_EDIT: string;
|
|
57
|
-
MESSAGE_SAVE: string;
|
|
58
|
-
MESSAGE_CANCEL: string;
|
|
59
|
-
A11Y_USER_MESSAGE: string;
|
|
60
|
-
A11Y_ASSISTANT_MESSAGE: string;
|
|
61
|
-
A11Y_COPY_CODE: string;
|
|
62
|
-
A11Y_CODE_COPIED: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Plugin mode for AI Chat
|
|
67
|
-
* - 'authenticated': Conversations persisted with userId (default)
|
|
68
|
-
* - 'public': Stateless chat, no persistence (ideal for public chatbots)
|
|
69
|
-
*/
|
|
70
|
-
type AiChatMode = "authenticated" | "public";
|
|
71
|
-
/**
|
|
72
|
-
* Allowed file type categories for uploads
|
|
73
|
-
*/
|
|
74
|
-
type AllowedFileType = "image" | "text" | "pdf" | "markdown" | "csv" | "json";
|
|
75
|
-
/**
|
|
76
|
-
* Default allowed file types (images only for best AI model compatibility)
|
|
77
|
-
* Consumers can expand this by passing allowedFileTypes in overrides
|
|
78
|
-
*/
|
|
79
|
-
declare const DEFAULT_ALLOWED_FILE_TYPES: AllowedFileType[];
|
|
80
|
-
/**
|
|
81
|
-
* Context passed to lifecycle hooks
|
|
82
|
-
*/
|
|
83
|
-
interface RouteContext$1 {
|
|
84
|
-
/** Current route path */
|
|
85
|
-
path: string;
|
|
86
|
-
/** Route parameters (e.g., { id: "abc123" }) */
|
|
87
|
-
params?: Record<string, string>;
|
|
88
|
-
/** Whether rendering on server (true) or client (false) */
|
|
89
|
-
isSSR: boolean;
|
|
90
|
-
/** Additional context properties */
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Overridable components and functions for the AI Chat plugin
|
|
95
|
-
*
|
|
96
|
-
* External consumers can provide their own implementations of these
|
|
97
|
-
* to customize the behavior for their framework (Next.js, React Router, etc.)
|
|
98
|
-
*/
|
|
99
|
-
interface AiChatPluginOverrides {
|
|
100
|
-
/**
|
|
101
|
-
* Plugin mode - should match backend config
|
|
102
|
-
* @default 'authenticated'
|
|
103
|
-
*/
|
|
104
|
-
mode?: AiChatMode;
|
|
105
|
-
/**
|
|
106
|
-
* API base URL
|
|
107
|
-
*/
|
|
108
|
-
apiBaseURL: string;
|
|
109
|
-
/**
|
|
110
|
-
* API base path
|
|
111
|
-
*/
|
|
112
|
-
apiBasePath: string;
|
|
113
|
-
/**
|
|
114
|
-
* Navigation function for programmatic navigation
|
|
115
|
-
*/
|
|
116
|
-
navigate: (path: string) => void | Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Refresh function to invalidate server-side cache (e.g., Next.js router.refresh())
|
|
119
|
-
*/
|
|
120
|
-
refresh?: () => void | Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Link component for navigation
|
|
123
|
-
*/
|
|
124
|
-
Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
|
|
125
|
-
/**
|
|
126
|
-
* Image component for displaying images
|
|
127
|
-
*/
|
|
128
|
-
Image?: ComponentType<React.ImgHTMLAttributes<HTMLImageElement> & Record<string, any>>;
|
|
129
|
-
/**
|
|
130
|
-
* Function used to upload a file and return its URL.
|
|
131
|
-
* Called for images, PDFs, text files, and other supported file types.
|
|
132
|
-
*/
|
|
133
|
-
uploadFile?: (file: File) => Promise<string>;
|
|
134
|
-
/**
|
|
135
|
-
* Allowed file types for upload.
|
|
136
|
-
* By default, all types are enabled: image, text, pdf, markdown, csv, json
|
|
137
|
-
* Set to empty array to disable file uploads entirely.
|
|
138
|
-
* @default ['image', 'text', 'pdf', 'markdown', 'csv', 'json']
|
|
139
|
-
*/
|
|
140
|
-
allowedFileTypes?: AllowedFileType[];
|
|
141
|
-
/**
|
|
142
|
-
* Localization object for the AI Chat plugin
|
|
143
|
-
*/
|
|
144
|
-
localization?: Partial<AiChatLocalization>;
|
|
145
|
-
/**
|
|
146
|
-
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
147
|
-
*/
|
|
148
|
-
headers?: HeadersInit;
|
|
149
|
-
/**
|
|
150
|
-
* Whether to show the attribution
|
|
151
|
-
* @default true
|
|
152
|
-
*/
|
|
153
|
-
showAttribution?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Called when a route is rendered
|
|
156
|
-
* @param routeName - Name of the route (e.g., 'chat', 'chatConversation')
|
|
157
|
-
* @param context - Route context with path, params, etc.
|
|
158
|
-
*/
|
|
159
|
-
onRouteRender?: (routeName: string, context: RouteContext$1) => void | Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Called when a route encounters an error
|
|
162
|
-
* @param routeName - Name of the route
|
|
163
|
-
* @param error - The error that occurred
|
|
164
|
-
* @param context - Route context
|
|
165
|
-
*/
|
|
166
|
-
onRouteError?: (routeName: string, error: Error, context: RouteContext$1) => void | Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Called before the chat page is rendered
|
|
169
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
170
|
-
* @param context - Route context
|
|
171
|
-
*/
|
|
172
|
-
onBeforeChatPageRendered?: (context: RouteContext$1) => boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Called before a conversation page is rendered
|
|
175
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
176
|
-
* @param id - The conversation ID
|
|
177
|
-
* @param context - Route context
|
|
178
|
-
*/
|
|
179
|
-
onBeforeConversationPageRendered?: (id: string, context: RouteContext$1) => boolean;
|
|
180
|
-
}
|
|
181
10
|
|
|
182
11
|
/**
|
|
183
12
|
* Context passed to route hooks
|
|
@@ -323,5 +152,5 @@ declare const aiChatClientPlugin: (config: AiChatClientConfig) => _btst_stack_pl
|
|
|
323
152
|
};
|
|
324
153
|
}>;
|
|
325
154
|
|
|
326
|
-
export {
|
|
327
|
-
export type { AiChatClientConfig, AiChatClientHooks,
|
|
155
|
+
export { aiChatClientPlugin };
|
|
156
|
+
export type { AiChatClientConfig, AiChatClientHooks, LoaderContext, RouteContext };
|
|
@@ -1,183 +1,12 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ComponentType } from 'react';
|
|
4
3
|
import * as _btst_yar from '@btst/yar';
|
|
5
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
5
|
import { S as SerializedConversation, a as SerializedMessage } from '../../../shared/stack.Be1QIHEn.js';
|
|
7
|
-
|
|
6
|
+
import { A as AiChatMode } from '../../../shared/stack.DaOcgmrM.js';
|
|
7
|
+
export { a as AiChatPluginOverrides, b as AllowedFileType, i as ChatInput, C as ChatInterface, e as ChatLayout, f as ChatLayoutProps, h as ChatMessage, g as ChatSidebar, D as DEFAULT_ALLOWED_FILE_TYPES, j as ToolCallDisplay, T as ToolCallProps, d as ToolCallRenderer, c as ToolCallState } from '../../../shared/stack.DaOcgmrM.js';
|
|
8
|
+
export { UIMessage } from 'ai';
|
|
8
9
|
import 'react/jsx-runtime';
|
|
9
|
-
import 'ai';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* AI Chat plugin localization strings
|
|
13
|
-
*/
|
|
14
|
-
interface AiChatLocalization {
|
|
15
|
-
CHAT_PLACEHOLDER: string;
|
|
16
|
-
CHAT_SEND_BUTTON: string;
|
|
17
|
-
CHAT_EMPTY_STATE: string;
|
|
18
|
-
CHAT_LOADING: string;
|
|
19
|
-
CHAT_ERROR: string;
|
|
20
|
-
CHAT_RETRY: string;
|
|
21
|
-
CHAT_GENERIC_ERROR_TITLE: string;
|
|
22
|
-
CHAT_GENERIC_ERROR_MESSAGE: string;
|
|
23
|
-
CHAT_PAGE_NOT_FOUND_TITLE: string;
|
|
24
|
-
CHAT_PAGE_NOT_FOUND_DESCRIPTION: string;
|
|
25
|
-
SIDEBAR_TITLE: string;
|
|
26
|
-
SIDEBAR_NEW_CHAT: string;
|
|
27
|
-
SIDEBAR_NO_CONVERSATIONS: string;
|
|
28
|
-
SIDEBAR_SEARCH_PLACEHOLDER: string;
|
|
29
|
-
CONVERSATION_RENAME: string;
|
|
30
|
-
CONVERSATION_RENAME_PLACEHOLDER: string;
|
|
31
|
-
CONVERSATION_RENAME_SAVE: string;
|
|
32
|
-
CONVERSATION_RENAME_CANCEL: string;
|
|
33
|
-
CONVERSATION_DELETE: string;
|
|
34
|
-
CONVERSATION_DELETE_CONFIRM_TITLE: string;
|
|
35
|
-
CONVERSATION_DELETE_CONFIRM_DESCRIPTION: string;
|
|
36
|
-
CONVERSATION_DELETE_CONFIRM_BUTTON: string;
|
|
37
|
-
CONVERSATION_DELETE_CANCEL: string;
|
|
38
|
-
IMAGE_UPLOAD_BUTTON: string;
|
|
39
|
-
IMAGE_UPLOAD_UPLOADING: string;
|
|
40
|
-
IMAGE_UPLOAD_ERROR_NOT_IMAGE: string;
|
|
41
|
-
IMAGE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
42
|
-
IMAGE_UPLOAD_SUCCESS: string;
|
|
43
|
-
IMAGE_UPLOAD_FAILURE: string;
|
|
44
|
-
FILE_UPLOAD_BUTTON: string;
|
|
45
|
-
FILE_UPLOAD_ERROR_TOO_LARGE: string;
|
|
46
|
-
FILE_UPLOAD_SUCCESS: string;
|
|
47
|
-
FILE_UPLOAD_FAILURE: string;
|
|
48
|
-
TIME_JUST_NOW: string;
|
|
49
|
-
TIME_MINUTES_AGO: string;
|
|
50
|
-
TIME_HOURS_AGO: string;
|
|
51
|
-
TIME_YESTERDAY: string;
|
|
52
|
-
TIME_DAYS_AGO: string;
|
|
53
|
-
MESSAGE_COPY: string;
|
|
54
|
-
MESSAGE_COPIED: string;
|
|
55
|
-
MESSAGE_RETRY: string;
|
|
56
|
-
MESSAGE_EDIT: string;
|
|
57
|
-
MESSAGE_SAVE: string;
|
|
58
|
-
MESSAGE_CANCEL: string;
|
|
59
|
-
A11Y_USER_MESSAGE: string;
|
|
60
|
-
A11Y_ASSISTANT_MESSAGE: string;
|
|
61
|
-
A11Y_COPY_CODE: string;
|
|
62
|
-
A11Y_CODE_COPIED: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Plugin mode for AI Chat
|
|
67
|
-
* - 'authenticated': Conversations persisted with userId (default)
|
|
68
|
-
* - 'public': Stateless chat, no persistence (ideal for public chatbots)
|
|
69
|
-
*/
|
|
70
|
-
type AiChatMode = "authenticated" | "public";
|
|
71
|
-
/**
|
|
72
|
-
* Allowed file type categories for uploads
|
|
73
|
-
*/
|
|
74
|
-
type AllowedFileType = "image" | "text" | "pdf" | "markdown" | "csv" | "json";
|
|
75
|
-
/**
|
|
76
|
-
* Default allowed file types (images only for best AI model compatibility)
|
|
77
|
-
* Consumers can expand this by passing allowedFileTypes in overrides
|
|
78
|
-
*/
|
|
79
|
-
declare const DEFAULT_ALLOWED_FILE_TYPES: AllowedFileType[];
|
|
80
|
-
/**
|
|
81
|
-
* Context passed to lifecycle hooks
|
|
82
|
-
*/
|
|
83
|
-
interface RouteContext$1 {
|
|
84
|
-
/** Current route path */
|
|
85
|
-
path: string;
|
|
86
|
-
/** Route parameters (e.g., { id: "abc123" }) */
|
|
87
|
-
params?: Record<string, string>;
|
|
88
|
-
/** Whether rendering on server (true) or client (false) */
|
|
89
|
-
isSSR: boolean;
|
|
90
|
-
/** Additional context properties */
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Overridable components and functions for the AI Chat plugin
|
|
95
|
-
*
|
|
96
|
-
* External consumers can provide their own implementations of these
|
|
97
|
-
* to customize the behavior for their framework (Next.js, React Router, etc.)
|
|
98
|
-
*/
|
|
99
|
-
interface AiChatPluginOverrides {
|
|
100
|
-
/**
|
|
101
|
-
* Plugin mode - should match backend config
|
|
102
|
-
* @default 'authenticated'
|
|
103
|
-
*/
|
|
104
|
-
mode?: AiChatMode;
|
|
105
|
-
/**
|
|
106
|
-
* API base URL
|
|
107
|
-
*/
|
|
108
|
-
apiBaseURL: string;
|
|
109
|
-
/**
|
|
110
|
-
* API base path
|
|
111
|
-
*/
|
|
112
|
-
apiBasePath: string;
|
|
113
|
-
/**
|
|
114
|
-
* Navigation function for programmatic navigation
|
|
115
|
-
*/
|
|
116
|
-
navigate: (path: string) => void | Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Refresh function to invalidate server-side cache (e.g., Next.js router.refresh())
|
|
119
|
-
*/
|
|
120
|
-
refresh?: () => void | Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Link component for navigation
|
|
123
|
-
*/
|
|
124
|
-
Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
|
|
125
|
-
/**
|
|
126
|
-
* Image component for displaying images
|
|
127
|
-
*/
|
|
128
|
-
Image?: ComponentType<React.ImgHTMLAttributes<HTMLImageElement> & Record<string, any>>;
|
|
129
|
-
/**
|
|
130
|
-
* Function used to upload a file and return its URL.
|
|
131
|
-
* Called for images, PDFs, text files, and other supported file types.
|
|
132
|
-
*/
|
|
133
|
-
uploadFile?: (file: File) => Promise<string>;
|
|
134
|
-
/**
|
|
135
|
-
* Allowed file types for upload.
|
|
136
|
-
* By default, all types are enabled: image, text, pdf, markdown, csv, json
|
|
137
|
-
* Set to empty array to disable file uploads entirely.
|
|
138
|
-
* @default ['image', 'text', 'pdf', 'markdown', 'csv', 'json']
|
|
139
|
-
*/
|
|
140
|
-
allowedFileTypes?: AllowedFileType[];
|
|
141
|
-
/**
|
|
142
|
-
* Localization object for the AI Chat plugin
|
|
143
|
-
*/
|
|
144
|
-
localization?: Partial<AiChatLocalization>;
|
|
145
|
-
/**
|
|
146
|
-
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
147
|
-
*/
|
|
148
|
-
headers?: HeadersInit;
|
|
149
|
-
/**
|
|
150
|
-
* Whether to show the attribution
|
|
151
|
-
* @default true
|
|
152
|
-
*/
|
|
153
|
-
showAttribution?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Called when a route is rendered
|
|
156
|
-
* @param routeName - Name of the route (e.g., 'chat', 'chatConversation')
|
|
157
|
-
* @param context - Route context with path, params, etc.
|
|
158
|
-
*/
|
|
159
|
-
onRouteRender?: (routeName: string, context: RouteContext$1) => void | Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Called when a route encounters an error
|
|
162
|
-
* @param routeName - Name of the route
|
|
163
|
-
* @param error - The error that occurred
|
|
164
|
-
* @param context - Route context
|
|
165
|
-
*/
|
|
166
|
-
onRouteError?: (routeName: string, error: Error, context: RouteContext$1) => void | Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Called before the chat page is rendered
|
|
169
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
170
|
-
* @param context - Route context
|
|
171
|
-
*/
|
|
172
|
-
onBeforeChatPageRendered?: (context: RouteContext$1) => boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Called before a conversation page is rendered
|
|
175
|
-
* Return false to prevent rendering (e.g., for authorization)
|
|
176
|
-
* @param id - The conversation ID
|
|
177
|
-
* @param context - Route context
|
|
178
|
-
*/
|
|
179
|
-
onBeforeConversationPageRendered?: (id: string, context: RouteContext$1) => boolean;
|
|
180
|
-
}
|
|
181
10
|
|
|
182
11
|
/**
|
|
183
12
|
* Context passed to route hooks
|
|
@@ -323,5 +152,5 @@ declare const aiChatClientPlugin: (config: AiChatClientConfig) => _btst_stack_pl
|
|
|
323
152
|
};
|
|
324
153
|
}>;
|
|
325
154
|
|
|
326
|
-
export {
|
|
327
|
-
export type { AiChatClientConfig, AiChatClientHooks,
|
|
155
|
+
export { aiChatClientPlugin };
|
|
156
|
+
export type { AiChatClientConfig, AiChatClientHooks, LoaderContext, RouteContext };
|
|
@@ -5,3 +5,4 @@ export { ChatLayout } from '../../../packages/better-stack/src/plugins/ai-chat/c
|
|
|
5
5
|
export { ChatSidebar } from '../../../packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs';
|
|
6
6
|
export { ChatMessage } from '../../../packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs';
|
|
7
7
|
export { ChatInput } from '../../../packages/better-stack/src/plugins/ai-chat/client/components/chat-input.mjs';
|
|
8
|
+
export { ToolCallDisplay } from '../../../packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.mjs';
|
|
@@ -158,6 +158,9 @@
|
|
|
158
158
|
.markdown-content .markdown-inner .markdown-body .hljs-params {
|
|
159
159
|
color: #ffb86c;
|
|
160
160
|
}
|
|
161
|
+
.markdown-content .markdown-inner .markdown-body .hljs-punctuation {
|
|
162
|
+
color: #c9d1d9;
|
|
163
|
+
}
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
/* Also support Tailwind dark class for dark mode */
|
|
@@ -167,6 +170,9 @@
|
|
|
167
170
|
.dark .markdown-content .markdown-inner .markdown-body .hljs-params {
|
|
168
171
|
color: #ffb86c;
|
|
169
172
|
}
|
|
173
|
+
.dark .markdown-content .markdown-inner .markdown-body .hljs-punctuation {
|
|
174
|
+
color: #c9d1d9;
|
|
175
|
+
}
|
|
170
176
|
|
|
171
177
|
.markdown-content .markdown-inner .markdown-code-block {
|
|
172
178
|
display: block;
|