@frankieai/react 0.1.5 → 0.2.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/frankie.css +1 -1
- package/dist/index.cjs +247 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -11
- package/dist/index.d.ts +16 -11
- package/dist/index.js +245 -152
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/chat/ChatPanel.tsx +3 -2
- package/src/components/chat/FrankieChatPage.tsx +73 -101
- package/src/components/chat/FrankieWidget.tsx +7 -3
- package/src/hooks/FrankieProvider.tsx +12 -4
- package/src/hooks/useFrankieChat.ts +19 -6
- package/src/lib/client.ts +16 -6
- package/src/styles/frankie.css +22 -1
- package/src/widget.test.tsx +35 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
3
|
-
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme } from '@frankieai/core';
|
|
3
|
+
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill } from '@frankieai/core';
|
|
4
4
|
export { FrankieServerEvent, PublicWidgetConfig, WidgetTheme } from '@frankieai/core';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -19,15 +19,15 @@ interface FrankieClientOptions {
|
|
|
19
19
|
publishableKey: string;
|
|
20
20
|
/**
|
|
21
21
|
* Fetches a short-lived JWT for the signed-in user from the host's own
|
|
22
|
-
* backend. Called
|
|
22
|
+
* backend. Called before each turn; return undefined after sign-out.
|
|
23
23
|
* Omit only for tenants that allow anonymous chat.
|
|
24
24
|
*/
|
|
25
25
|
getUserToken?: () => Promise<string | undefined> | string | undefined;
|
|
26
26
|
fetchImpl?: typeof fetch;
|
|
27
27
|
/**
|
|
28
28
|
* Remember the session (and, in the hook, the transcript) in localStorage so a
|
|
29
|
-
* page reload resumes the same conversation.
|
|
30
|
-
*
|
|
29
|
+
* page reload resumes the same anonymous conversation. Authenticated chat
|
|
30
|
+
* never writes tokens or transcripts to localStorage; it uses server history.
|
|
31
31
|
*/
|
|
32
32
|
persist?: boolean;
|
|
33
33
|
/** Override localStorage namespace for session and transcript. */
|
|
@@ -51,6 +51,7 @@ declare class FrankieClient {
|
|
|
51
51
|
private readonly baseUrl;
|
|
52
52
|
private readonly doFetch;
|
|
53
53
|
private session?;
|
|
54
|
+
private sessionUserToken?;
|
|
54
55
|
constructor(options: FrankieClientOptions);
|
|
55
56
|
get sessionId(): string | undefined;
|
|
56
57
|
get conversationId(): string | undefined;
|
|
@@ -146,6 +147,8 @@ interface SendOptions {
|
|
|
146
147
|
model?: string;
|
|
147
148
|
}
|
|
148
149
|
interface UseFrankieChatResult {
|
|
150
|
+
loadedSkills: LoadedSkill[] | null;
|
|
151
|
+
restoring: boolean;
|
|
149
152
|
messages: ChatMessage[];
|
|
150
153
|
/** True from the moment a message is sent until the turn ends. */
|
|
151
154
|
busy: boolean;
|
|
@@ -185,6 +188,8 @@ interface FrankieWidgetProps extends ChatPanelProps {
|
|
|
185
188
|
/** Distance from the viewport edges, in pixels. */
|
|
186
189
|
offset?: number;
|
|
187
190
|
defaultOpen?: boolean;
|
|
191
|
+
/** Host overlays should sit above the assistant. Override for your layer system. */
|
|
192
|
+
zIndex?: number;
|
|
188
193
|
/** Controlled mode: pass both to drive open state from the host app. */
|
|
189
194
|
open?: boolean;
|
|
190
195
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -201,7 +206,7 @@ interface FrankieWidgetProps extends ChatPanelProps {
|
|
|
201
206
|
* Renders `position: fixed` at the document level, so it does not care what
|
|
202
207
|
* layout the host page uses.
|
|
203
208
|
*/
|
|
204
|
-
declare function FrankieWidget({ position, offset, defaultOpen, open: controlledOpen, onOpenChange, renderLauncher, ...panelProps }: FrankieWidgetProps): react.JSX.Element;
|
|
209
|
+
declare function FrankieWidget({ position, offset, defaultOpen, zIndex, open: controlledOpen, onOpenChange, renderLauncher, ...panelProps }: FrankieWidgetProps): react.JSX.Element;
|
|
205
210
|
|
|
206
211
|
interface FrankieInlineProps extends ChatPanelProps {
|
|
207
212
|
/** Extra styles on the filling wrapper — e.g. a `maxWidth` to centre the column. */
|
|
@@ -221,13 +226,13 @@ declare function FrankieInline({ className, style, ...panelProps }: FrankieInlin
|
|
|
221
226
|
interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
|
|
222
227
|
className?: string;
|
|
223
228
|
style?: CSSProperties;
|
|
229
|
+
/** Include the built-in conversation sidebar. Defaults to true. */
|
|
230
|
+
showHistory?: boolean;
|
|
231
|
+
/** Optional host navigation, e.g. a Back to dashboard link. */
|
|
232
|
+
navigation?: React.ReactNode;
|
|
224
233
|
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
* The shell, header, empty state and composer are all scoped under
|
|
228
|
-
* `.frankie-root`, so host application styles remain untouched.
|
|
229
|
-
*/
|
|
230
|
-
declare function FrankieChatPage({ className, style, header, footer, emptyState, renderMessage, renderTool, placeholder, autoFocus, ...providerProps }: FrankieChatPageProps): react.JSX.Element;
|
|
234
|
+
/** Reusable product chat with one shared conversation state and scoped styling. */
|
|
235
|
+
declare function FrankieChatPage({ className, style, header, footer, emptyState, renderMessage, renderTool, placeholder, autoFocus, showHistory, navigation, ...provider }: FrankieChatPageProps): react.JSX.Element;
|
|
231
236
|
|
|
232
237
|
interface ComposerAttachmentsConfig {
|
|
233
238
|
enabled: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
3
|
-
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme } from '@frankieai/core';
|
|
3
|
+
import { PublicWidgetConfig, CreateSessionResponse, ChatAttachment, FrankieServerEvent, WidgetTheme, LoadedSkill } from '@frankieai/core';
|
|
4
4
|
export { FrankieServerEvent, PublicWidgetConfig, WidgetTheme } from '@frankieai/core';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -19,15 +19,15 @@ interface FrankieClientOptions {
|
|
|
19
19
|
publishableKey: string;
|
|
20
20
|
/**
|
|
21
21
|
* Fetches a short-lived JWT for the signed-in user from the host's own
|
|
22
|
-
* backend. Called
|
|
22
|
+
* backend. Called before each turn; return undefined after sign-out.
|
|
23
23
|
* Omit only for tenants that allow anonymous chat.
|
|
24
24
|
*/
|
|
25
25
|
getUserToken?: () => Promise<string | undefined> | string | undefined;
|
|
26
26
|
fetchImpl?: typeof fetch;
|
|
27
27
|
/**
|
|
28
28
|
* Remember the session (and, in the hook, the transcript) in localStorage so a
|
|
29
|
-
* page reload resumes the same conversation.
|
|
30
|
-
*
|
|
29
|
+
* page reload resumes the same anonymous conversation. Authenticated chat
|
|
30
|
+
* never writes tokens or transcripts to localStorage; it uses server history.
|
|
31
31
|
*/
|
|
32
32
|
persist?: boolean;
|
|
33
33
|
/** Override localStorage namespace for session and transcript. */
|
|
@@ -51,6 +51,7 @@ declare class FrankieClient {
|
|
|
51
51
|
private readonly baseUrl;
|
|
52
52
|
private readonly doFetch;
|
|
53
53
|
private session?;
|
|
54
|
+
private sessionUserToken?;
|
|
54
55
|
constructor(options: FrankieClientOptions);
|
|
55
56
|
get sessionId(): string | undefined;
|
|
56
57
|
get conversationId(): string | undefined;
|
|
@@ -146,6 +147,8 @@ interface SendOptions {
|
|
|
146
147
|
model?: string;
|
|
147
148
|
}
|
|
148
149
|
interface UseFrankieChatResult {
|
|
150
|
+
loadedSkills: LoadedSkill[] | null;
|
|
151
|
+
restoring: boolean;
|
|
149
152
|
messages: ChatMessage[];
|
|
150
153
|
/** True from the moment a message is sent until the turn ends. */
|
|
151
154
|
busy: boolean;
|
|
@@ -185,6 +188,8 @@ interface FrankieWidgetProps extends ChatPanelProps {
|
|
|
185
188
|
/** Distance from the viewport edges, in pixels. */
|
|
186
189
|
offset?: number;
|
|
187
190
|
defaultOpen?: boolean;
|
|
191
|
+
/** Host overlays should sit above the assistant. Override for your layer system. */
|
|
192
|
+
zIndex?: number;
|
|
188
193
|
/** Controlled mode: pass both to drive open state from the host app. */
|
|
189
194
|
open?: boolean;
|
|
190
195
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -201,7 +206,7 @@ interface FrankieWidgetProps extends ChatPanelProps {
|
|
|
201
206
|
* Renders `position: fixed` at the document level, so it does not care what
|
|
202
207
|
* layout the host page uses.
|
|
203
208
|
*/
|
|
204
|
-
declare function FrankieWidget({ position, offset, defaultOpen, open: controlledOpen, onOpenChange, renderLauncher, ...panelProps }: FrankieWidgetProps): react.JSX.Element;
|
|
209
|
+
declare function FrankieWidget({ position, offset, defaultOpen, zIndex, open: controlledOpen, onOpenChange, renderLauncher, ...panelProps }: FrankieWidgetProps): react.JSX.Element;
|
|
205
210
|
|
|
206
211
|
interface FrankieInlineProps extends ChatPanelProps {
|
|
207
212
|
/** Extra styles on the filling wrapper — e.g. a `maxWidth` to centre the column. */
|
|
@@ -221,13 +226,13 @@ declare function FrankieInline({ className, style, ...panelProps }: FrankieInlin
|
|
|
221
226
|
interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
|
|
222
227
|
className?: string;
|
|
223
228
|
style?: CSSProperties;
|
|
229
|
+
/** Include the built-in conversation sidebar. Defaults to true. */
|
|
230
|
+
showHistory?: boolean;
|
|
231
|
+
/** Optional host navigation, e.g. a Back to dashboard link. */
|
|
232
|
+
navigation?: React.ReactNode;
|
|
224
233
|
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
* The shell, header, empty state and composer are all scoped under
|
|
228
|
-
* `.frankie-root`, so host application styles remain untouched.
|
|
229
|
-
*/
|
|
230
|
-
declare function FrankieChatPage({ className, style, header, footer, emptyState, renderMessage, renderTool, placeholder, autoFocus, ...providerProps }: FrankieChatPageProps): react.JSX.Element;
|
|
234
|
+
/** Reusable product chat with one shared conversation state and scoped styling. */
|
|
235
|
+
declare function FrankieChatPage({ className, style, header, footer, emptyState, renderMessage, renderTool, placeholder, autoFocus, showHistory, navigation, ...provider }: FrankieChatPageProps): react.JSX.Element;
|
|
231
236
|
|
|
232
237
|
interface ComposerAttachmentsConfig {
|
|
233
238
|
enabled: boolean;
|