@frankieai/react 0.2.9 → 0.2.10

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
@@ -7,6 +7,26 @@ import { VariantProps } from 'class-variance-authority';
7
7
  import { ClassValue } from 'clsx';
8
8
 
9
9
  type PageContext = Record<string, string | number | boolean | null>;
10
+ /**
11
+ * How the widget reaches the host's own API for client-side tool execution.
12
+ *
13
+ * When a workspace marks an API source `execution: "client"`, Frankie asks the
14
+ * browser to make the call itself — from the user's existing session — instead
15
+ * of calling the API from Frankie's servers. This says where that API lives and
16
+ * how the browser authenticates to it: normally the app's own cookies
17
+ * (`credentials: "include"` on a same-origin or CORS-allowed API), or a bearer
18
+ * token the app already holds, added via `headers`. Frankie sends no credential
19
+ * of its own; the host API authorizes the call exactly as it would any request
20
+ * from the host's frontend.
21
+ */
22
+ interface HostApiClientOptions {
23
+ /** Base URL that operation paths resolve against, e.g. "/api" or "https://api.acme.com". */
24
+ baseUrl: string;
25
+ /** fetch credentials mode. "include" sends the app's cookies. Defaults to "same-origin". */
26
+ credentials?: RequestCredentials;
27
+ /** Extra headers for every host call (e.g. an app access token). Awaited per call. */
28
+ headers?: () => Promise<Record<string, string>> | Record<string, string>;
29
+ }
10
30
  /**
11
31
  * The hosted Frankie data plane. Embedding needs only a publishable key, so
12
32
  * `baseUrl` defaults here — override it only when self-hosting the server.
@@ -24,6 +44,13 @@ interface FrankieClientOptions {
24
44
  */
25
45
  getUserToken?: () => Promise<string | undefined> | string | undefined;
26
46
  fetchImpl?: typeof fetch;
47
+ /**
48
+ * Reaches the host's own API for `execution: "client"` tool calls (see
49
+ * `HostApiClientOptions`). Required only for workspaces that use client-side
50
+ * execution; omit it and a client-mode tool reports that no host API is
51
+ * configured rather than calling anything.
52
+ */
53
+ api?: HostApiClientOptions;
27
54
  /**
28
55
  * Remember the session (and, in the hook, the transcript) in localStorage so a
29
56
  * page reload resumes the same anonymous conversation. Authenticated chat
@@ -51,7 +78,8 @@ declare class FrankieClient {
51
78
  private readonly baseUrl;
52
79
  private readonly doFetch;
53
80
  private session?;
54
- private sessionUserToken?;
81
+ /** Identity (JWT `sub`, else the raw token) the cached session was issued for. */
82
+ private sessionUserKey?;
55
83
  constructor(options: FrankieClientOptions);
56
84
  get sessionId(): string | undefined;
57
85
  get conversationId(): string | undefined;
@@ -79,6 +107,14 @@ declare class FrankieClient {
79
107
  attachments?: ChatAttachment[];
80
108
  signal?: AbortSignal;
81
109
  }, onEvent: (event: FrankieServerEvent) => void): Promise<void>;
110
+ /**
111
+ * Execute one host API call in the browser and report the outcome back to the
112
+ * server. Never throws: a transport failure or a missing `api` client becomes
113
+ * a result the model can see and explain, exactly like a non-2xx status.
114
+ */
115
+ private runClientTool;
116
+ private callHostApi;
117
+ private postToolResult;
82
118
  private unwrap;
83
119
  }
84
120
  declare function readEventStream(body: ReadableStream<Uint8Array>): AsyncGenerator<FrankieServerEvent>;
@@ -88,6 +124,15 @@ interface FrankieProviderProps extends FrankieClientOptions {
88
124
  context?: PageContext;
89
125
  theme?: WidgetTheme;
90
126
  config?: PublicWidgetConfig;
127
+ /**
128
+ * Set to `false` if the host compiles Frankie's classes itself instead of
129
+ * loading `@frankieai/react/styles.css` — e.g. a Tailwind v4 host that
130
+ * `@source`s this package — so it isn't given a second, independently-themed
131
+ * copy of the stylesheet when its own build never sets the styles-ready
132
+ * sentinel. Defaults to `true`: a host that simply forgot the import, or
133
+ * whose CSS chunk hasn't landed yet, still gets a correctly-styled widget.
134
+ */
135
+ injectStyles?: boolean;
91
136
  }
92
137
  interface FrankieContextValue {
93
138
  client: FrankieClient;
@@ -96,8 +141,9 @@ interface FrankieContextValue {
96
141
  loading: boolean;
97
142
  context?: PageContext;
98
143
  theme?: WidgetTheme;
144
+ injectStyles: boolean;
99
145
  }
100
- declare function FrankieProvider({ children, context, theme, config: providedConfig, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
146
+ declare function FrankieProvider({ children, context, theme, config: providedConfig, injectStyles, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
101
147
  declare function useFrankie(): FrankieContextValue;
102
148
  declare function useFrankieTheme(): WidgetTheme | undefined;
103
149
 
@@ -287,6 +333,12 @@ interface MessageBubbleProps {
287
333
  }
288
334
  declare const MessageBubble: react.NamedExoticComponent<MessageBubbleProps>;
289
335
  declare function TypingDots(): react.JSX.Element;
336
+ /**
337
+ * A shimmering skeleton shown while the reply is still being produced — before
338
+ * the first words, or during the pause after a tool result while the model
339
+ * composes its answer — so those gaps read as "loading" rather than frozen.
340
+ */
341
+ declare function Thinking(): react.JSX.Element;
290
342
 
291
343
  /**
292
344
  * A deliberately small Markdown subset — headings, paragraphs, lists, fenced
@@ -417,4 +469,4 @@ declare function resolveMode(mode: WidgetTheme["mode"]): "light" | "dark";
417
469
  /** shadcn/ui's class helper: conditional classes with Tailwind conflict resolution. */
418
470
  declare function cn(...inputs: ClassValue[]): string;
419
471
 
420
- export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Choices, Composer, type ExtractedChoices, FRANKIE_CLOUD_URL, FrankieApiError, FrankieChatPage, type FrankieChatPageProps, FrankieClient, type FrankieClientOptions, FrankieInline, type FrankieInlineProps, FrankieProvider, type FrankieProviderProps, FrankieWidget, type FrankieWidgetProps, Markdown, type MessageAttachment, MessageBubble, type PageContext, ScrollArea, type SendOptions, Separator, SuggestedPrompts, Textarea, type ToolActivity, ToolActivityList, ToolActivityRow, TypingDots, type UseFrankieChatResult, type UserChatMessage, applyEvent, buttonVariants, cn, extractChoices, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
472
+ export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Choices, Composer, type ExtractedChoices, FRANKIE_CLOUD_URL, FrankieApiError, FrankieChatPage, type FrankieChatPageProps, FrankieClient, type FrankieClientOptions, FrankieInline, type FrankieInlineProps, FrankieProvider, type FrankieProviderProps, FrankieWidget, type FrankieWidgetProps, Markdown, type MessageAttachment, MessageBubble, type PageContext, ScrollArea, type SendOptions, Separator, SuggestedPrompts, Textarea, Thinking, type ToolActivity, ToolActivityList, ToolActivityRow, TypingDots, type UseFrankieChatResult, type UserChatMessage, applyEvent, buttonVariants, cn, extractChoices, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,26 @@ import { VariantProps } from 'class-variance-authority';
7
7
  import { ClassValue } from 'clsx';
8
8
 
9
9
  type PageContext = Record<string, string | number | boolean | null>;
10
+ /**
11
+ * How the widget reaches the host's own API for client-side tool execution.
12
+ *
13
+ * When a workspace marks an API source `execution: "client"`, Frankie asks the
14
+ * browser to make the call itself — from the user's existing session — instead
15
+ * of calling the API from Frankie's servers. This says where that API lives and
16
+ * how the browser authenticates to it: normally the app's own cookies
17
+ * (`credentials: "include"` on a same-origin or CORS-allowed API), or a bearer
18
+ * token the app already holds, added via `headers`. Frankie sends no credential
19
+ * of its own; the host API authorizes the call exactly as it would any request
20
+ * from the host's frontend.
21
+ */
22
+ interface HostApiClientOptions {
23
+ /** Base URL that operation paths resolve against, e.g. "/api" or "https://api.acme.com". */
24
+ baseUrl: string;
25
+ /** fetch credentials mode. "include" sends the app's cookies. Defaults to "same-origin". */
26
+ credentials?: RequestCredentials;
27
+ /** Extra headers for every host call (e.g. an app access token). Awaited per call. */
28
+ headers?: () => Promise<Record<string, string>> | Record<string, string>;
29
+ }
10
30
  /**
11
31
  * The hosted Frankie data plane. Embedding needs only a publishable key, so
12
32
  * `baseUrl` defaults here — override it only when self-hosting the server.
@@ -24,6 +44,13 @@ interface FrankieClientOptions {
24
44
  */
25
45
  getUserToken?: () => Promise<string | undefined> | string | undefined;
26
46
  fetchImpl?: typeof fetch;
47
+ /**
48
+ * Reaches the host's own API for `execution: "client"` tool calls (see
49
+ * `HostApiClientOptions`). Required only for workspaces that use client-side
50
+ * execution; omit it and a client-mode tool reports that no host API is
51
+ * configured rather than calling anything.
52
+ */
53
+ api?: HostApiClientOptions;
27
54
  /**
28
55
  * Remember the session (and, in the hook, the transcript) in localStorage so a
29
56
  * page reload resumes the same anonymous conversation. Authenticated chat
@@ -51,7 +78,8 @@ declare class FrankieClient {
51
78
  private readonly baseUrl;
52
79
  private readonly doFetch;
53
80
  private session?;
54
- private sessionUserToken?;
81
+ /** Identity (JWT `sub`, else the raw token) the cached session was issued for. */
82
+ private sessionUserKey?;
55
83
  constructor(options: FrankieClientOptions);
56
84
  get sessionId(): string | undefined;
57
85
  get conversationId(): string | undefined;
@@ -79,6 +107,14 @@ declare class FrankieClient {
79
107
  attachments?: ChatAttachment[];
80
108
  signal?: AbortSignal;
81
109
  }, onEvent: (event: FrankieServerEvent) => void): Promise<void>;
110
+ /**
111
+ * Execute one host API call in the browser and report the outcome back to the
112
+ * server. Never throws: a transport failure or a missing `api` client becomes
113
+ * a result the model can see and explain, exactly like a non-2xx status.
114
+ */
115
+ private runClientTool;
116
+ private callHostApi;
117
+ private postToolResult;
82
118
  private unwrap;
83
119
  }
84
120
  declare function readEventStream(body: ReadableStream<Uint8Array>): AsyncGenerator<FrankieServerEvent>;
@@ -88,6 +124,15 @@ interface FrankieProviderProps extends FrankieClientOptions {
88
124
  context?: PageContext;
89
125
  theme?: WidgetTheme;
90
126
  config?: PublicWidgetConfig;
127
+ /**
128
+ * Set to `false` if the host compiles Frankie's classes itself instead of
129
+ * loading `@frankieai/react/styles.css` — e.g. a Tailwind v4 host that
130
+ * `@source`s this package — so it isn't given a second, independently-themed
131
+ * copy of the stylesheet when its own build never sets the styles-ready
132
+ * sentinel. Defaults to `true`: a host that simply forgot the import, or
133
+ * whose CSS chunk hasn't landed yet, still gets a correctly-styled widget.
134
+ */
135
+ injectStyles?: boolean;
91
136
  }
92
137
  interface FrankieContextValue {
93
138
  client: FrankieClient;
@@ -96,8 +141,9 @@ interface FrankieContextValue {
96
141
  loading: boolean;
97
142
  context?: PageContext;
98
143
  theme?: WidgetTheme;
144
+ injectStyles: boolean;
99
145
  }
100
- declare function FrankieProvider({ children, context, theme, config: providedConfig, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
146
+ declare function FrankieProvider({ children, context, theme, config: providedConfig, injectStyles, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
101
147
  declare function useFrankie(): FrankieContextValue;
102
148
  declare function useFrankieTheme(): WidgetTheme | undefined;
103
149
 
@@ -287,6 +333,12 @@ interface MessageBubbleProps {
287
333
  }
288
334
  declare const MessageBubble: react.NamedExoticComponent<MessageBubbleProps>;
289
335
  declare function TypingDots(): react.JSX.Element;
336
+ /**
337
+ * A shimmering skeleton shown while the reply is still being produced — before
338
+ * the first words, or during the pause after a tool result while the model
339
+ * composes its answer — so those gaps read as "loading" rather than frozen.
340
+ */
341
+ declare function Thinking(): react.JSX.Element;
290
342
 
291
343
  /**
292
344
  * A deliberately small Markdown subset — headings, paragraphs, lists, fenced
@@ -417,4 +469,4 @@ declare function resolveMode(mode: WidgetTheme["mode"]): "light" | "dark";
417
469
  /** shadcn/ui's class helper: conditional classes with Tailwind conflict resolution. */
418
470
  declare function cn(...inputs: ClassValue[]): string;
419
471
 
420
- export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Choices, Composer, type ExtractedChoices, FRANKIE_CLOUD_URL, FrankieApiError, FrankieChatPage, type FrankieChatPageProps, FrankieClient, type FrankieClientOptions, FrankieInline, type FrankieInlineProps, FrankieProvider, type FrankieProviderProps, FrankieWidget, type FrankieWidgetProps, Markdown, type MessageAttachment, MessageBubble, type PageContext, ScrollArea, type SendOptions, Separator, SuggestedPrompts, Textarea, type ToolActivity, ToolActivityList, ToolActivityRow, TypingDots, type UseFrankieChatResult, type UserChatMessage, applyEvent, buttonVariants, cn, extractChoices, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
472
+ export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Choices, Composer, type ExtractedChoices, FRANKIE_CLOUD_URL, FrankieApiError, FrankieChatPage, type FrankieChatPageProps, FrankieClient, type FrankieClientOptions, FrankieInline, type FrankieInlineProps, FrankieProvider, type FrankieProviderProps, FrankieWidget, type FrankieWidgetProps, Markdown, type MessageAttachment, MessageBubble, type PageContext, ScrollArea, type SendOptions, Separator, SuggestedPrompts, Textarea, Thinking, type ToolActivity, ToolActivityList, ToolActivityRow, TypingDots, type UseFrankieChatResult, type UserChatMessage, applyEvent, buttonVariants, cn, extractChoices, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };