@frankieai/react 0.1.4 → 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/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 once per session, and again when a session expires.
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. On by default in the browser;
30
- * set false for an ephemeral chat that starts fresh every load.
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. */
@@ -218,15 +223,16 @@ interface FrankieInlineProps extends ChatPanelProps {
218
223
  */
219
224
  declare function FrankieInline({ className, style, ...panelProps }: FrankieInlineProps): react.JSX.Element;
220
225
 
221
- /**
222
- * A complete chat route in one component. This is the simplest way to add a
223
- * dedicated /chat page to an app while keeping the existing floating widget.
224
- */
225
226
  interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
226
227
  className?: string;
227
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;
228
233
  }
229
- 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;
230
236
 
231
237
  interface ComposerAttachmentsConfig {
232
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 once per session, and again when a session expires.
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. On by default in the browser;
30
- * set false for an ephemeral chat that starts fresh every load.
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. */
@@ -218,15 +223,16 @@ interface FrankieInlineProps extends ChatPanelProps {
218
223
  */
219
224
  declare function FrankieInline({ className, style, ...panelProps }: FrankieInlineProps): react.JSX.Element;
220
225
 
221
- /**
222
- * A complete chat route in one component. This is the simplest way to add a
223
- * dedicated /chat page to an app while keeping the existing floating widget.
224
- */
225
226
  interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
226
227
  className?: string;
227
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;
228
233
  }
229
- 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;
230
236
 
231
237
  interface ComposerAttachmentsConfig {
232
238
  enabled: boolean;