@frankieai/react 0.1.1 → 0.1.5

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
@@ -30,6 +30,16 @@ interface FrankieClientOptions {
30
30
  * set false for an ephemeral chat that starts fresh every load.
31
31
  */
32
32
  persist?: boolean;
33
+ /** Override localStorage namespace for session and transcript. */
34
+ storageNamespace?: string;
35
+ /** Stable id for a server-backed conversation. */
36
+ conversationId?: string;
37
+ }
38
+ interface ChatConversation {
39
+ id: string;
40
+ title: string;
41
+ createdAt: number;
42
+ updatedAt: number;
33
43
  }
34
44
  declare class FrankieApiError extends Error {
35
45
  readonly status: number;
@@ -43,45 +53,39 @@ declare class FrankieClient {
43
53
  private session?;
44
54
  constructor(options: FrankieClientOptions);
45
55
  get sessionId(): string | undefined;
56
+ get conversationId(): string | undefined;
46
57
  /** Whether this client persists across reloads (browser only, opt-out via `persist:false`). */
47
58
  get persist(): boolean;
48
- /** localStorage namespace for this tenant, shared with the chat hook. */
59
+ /** localStorage namespace for this tenant/conversation, shared with the chat hook. */
49
60
  get namespace(): string;
50
61
  private readStored;
51
62
  private writeStored;
52
63
  getConfig(signal?: AbortSignal): Promise<PublicWidgetConfig>;
53
- /** Opens (or reuses) a chat session. */
54
64
  ensureSession(context?: PageContext): Promise<CreateSessionResponse>;
55
- /** Forget the current session so the next send starts a fresh conversation. */
65
+ listConversations(): Promise<ChatConversation[]>;
66
+ resumeConversation(id?: string | undefined): Promise<{
67
+ messages: unknown[];
68
+ title: string;
69
+ } | undefined>;
70
+ syncConversation(messages: unknown[], title?: string): Promise<void>;
71
+ deleteConversation(id: string): Promise<void>;
72
+ private requireUserToken;
56
73
  resetSession(): void;
57
- /**
58
- * Sends a message and invokes `onEvent` for each server event as it arrives.
59
- * Resolves when the turn ends.
60
- */
61
74
  send(input: {
62
75
  message: string;
63
76
  context?: PageContext;
64
- /** Model id chosen by the user, honoured only if the workspace allows it. */
65
77
  model?: string;
66
- /** Files attached to this turn. */
67
78
  attachments?: ChatAttachment[];
68
79
  signal?: AbortSignal;
69
80
  }, onEvent: (event: FrankieServerEvent) => void): Promise<void>;
70
81
  private unwrap;
71
82
  }
72
- /** Parse the server's `data:`-only SSE stream into typed events. */
73
83
  declare function readEventStream(body: ReadableStream<Uint8Array>): AsyncGenerator<FrankieServerEvent>;
74
84
 
75
85
  interface FrankieProviderProps extends FrankieClientOptions {
76
86
  children: ReactNode;
77
- /**
78
- * Page context sent with every turn — current route, plan tier, whatever the
79
- * agent should know. Treated as data by the server, never as instructions.
80
- */
81
87
  context?: PageContext;
82
- /** Overrides for the server-side theme, so a host can restyle without a redeploy. */
83
88
  theme?: WidgetTheme;
84
- /** Skip the `/v1/config` fetch by supplying the config yourself. */
85
89
  config?: PublicWidgetConfig;
86
90
  }
87
91
  interface FrankieContextValue {
@@ -94,7 +98,6 @@ interface FrankieContextValue {
94
98
  }
95
99
  declare function FrankieProvider({ children, context, theme, config: providedConfig, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
96
100
  declare function useFrankie(): FrankieContextValue;
97
- /** The theme actually in effect: provider override wins over server config. */
98
101
  declare function useFrankieTheme(): WidgetTheme | undefined;
99
102
 
100
103
  interface ToolActivity {
@@ -215,6 +218,17 @@ interface FrankieInlineProps extends ChatPanelProps {
215
218
  */
216
219
  declare function FrankieInline({ className, style, ...panelProps }: FrankieInlineProps): react.JSX.Element;
217
220
 
221
+ interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
222
+ className?: string;
223
+ style?: CSSProperties;
224
+ }
225
+ /**
226
+ * A complete, polished chat route matching Frankie's own conversation canvas.
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;
231
+
218
232
  interface ComposerAttachmentsConfig {
219
233
  enabled: boolean;
220
234
  /** Accepted MIME patterns, e.g. "image/*". */
@@ -344,4 +358,4 @@ declare function resolveMode(mode: WidgetTheme["mode"]): "light" | "dark";
344
358
  /** shadcn/ui's class helper: conditional classes with Tailwind conflict resolution. */
345
359
  declare function cn(...inputs: ClassValue[]): string;
346
360
 
347
- export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Composer, FRANKIE_CLOUD_URL, FrankieApiError, 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, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
361
+ export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Composer, 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, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
package/dist/index.d.ts CHANGED
@@ -30,6 +30,16 @@ interface FrankieClientOptions {
30
30
  * set false for an ephemeral chat that starts fresh every load.
31
31
  */
32
32
  persist?: boolean;
33
+ /** Override localStorage namespace for session and transcript. */
34
+ storageNamespace?: string;
35
+ /** Stable id for a server-backed conversation. */
36
+ conversationId?: string;
37
+ }
38
+ interface ChatConversation {
39
+ id: string;
40
+ title: string;
41
+ createdAt: number;
42
+ updatedAt: number;
33
43
  }
34
44
  declare class FrankieApiError extends Error {
35
45
  readonly status: number;
@@ -43,45 +53,39 @@ declare class FrankieClient {
43
53
  private session?;
44
54
  constructor(options: FrankieClientOptions);
45
55
  get sessionId(): string | undefined;
56
+ get conversationId(): string | undefined;
46
57
  /** Whether this client persists across reloads (browser only, opt-out via `persist:false`). */
47
58
  get persist(): boolean;
48
- /** localStorage namespace for this tenant, shared with the chat hook. */
59
+ /** localStorage namespace for this tenant/conversation, shared with the chat hook. */
49
60
  get namespace(): string;
50
61
  private readStored;
51
62
  private writeStored;
52
63
  getConfig(signal?: AbortSignal): Promise<PublicWidgetConfig>;
53
- /** Opens (or reuses) a chat session. */
54
64
  ensureSession(context?: PageContext): Promise<CreateSessionResponse>;
55
- /** Forget the current session so the next send starts a fresh conversation. */
65
+ listConversations(): Promise<ChatConversation[]>;
66
+ resumeConversation(id?: string | undefined): Promise<{
67
+ messages: unknown[];
68
+ title: string;
69
+ } | undefined>;
70
+ syncConversation(messages: unknown[], title?: string): Promise<void>;
71
+ deleteConversation(id: string): Promise<void>;
72
+ private requireUserToken;
56
73
  resetSession(): void;
57
- /**
58
- * Sends a message and invokes `onEvent` for each server event as it arrives.
59
- * Resolves when the turn ends.
60
- */
61
74
  send(input: {
62
75
  message: string;
63
76
  context?: PageContext;
64
- /** Model id chosen by the user, honoured only if the workspace allows it. */
65
77
  model?: string;
66
- /** Files attached to this turn. */
67
78
  attachments?: ChatAttachment[];
68
79
  signal?: AbortSignal;
69
80
  }, onEvent: (event: FrankieServerEvent) => void): Promise<void>;
70
81
  private unwrap;
71
82
  }
72
- /** Parse the server's `data:`-only SSE stream into typed events. */
73
83
  declare function readEventStream(body: ReadableStream<Uint8Array>): AsyncGenerator<FrankieServerEvent>;
74
84
 
75
85
  interface FrankieProviderProps extends FrankieClientOptions {
76
86
  children: ReactNode;
77
- /**
78
- * Page context sent with every turn — current route, plan tier, whatever the
79
- * agent should know. Treated as data by the server, never as instructions.
80
- */
81
87
  context?: PageContext;
82
- /** Overrides for the server-side theme, so a host can restyle without a redeploy. */
83
88
  theme?: WidgetTheme;
84
- /** Skip the `/v1/config` fetch by supplying the config yourself. */
85
89
  config?: PublicWidgetConfig;
86
90
  }
87
91
  interface FrankieContextValue {
@@ -94,7 +98,6 @@ interface FrankieContextValue {
94
98
  }
95
99
  declare function FrankieProvider({ children, context, theme, config: providedConfig, ...clientOptions }: FrankieProviderProps): react.JSX.Element;
96
100
  declare function useFrankie(): FrankieContextValue;
97
- /** The theme actually in effect: provider override wins over server config. */
98
101
  declare function useFrankieTheme(): WidgetTheme | undefined;
99
102
 
100
103
  interface ToolActivity {
@@ -215,6 +218,17 @@ interface FrankieInlineProps extends ChatPanelProps {
215
218
  */
216
219
  declare function FrankieInline({ className, style, ...panelProps }: FrankieInlineProps): react.JSX.Element;
217
220
 
221
+ interface FrankieChatPageProps extends Omit<FrankieProviderProps, "children">, Pick<ChatPanelProps, "header" | "footer" | "emptyState" | "renderMessage" | "renderTool" | "placeholder" | "autoFocus"> {
222
+ className?: string;
223
+ style?: CSSProperties;
224
+ }
225
+ /**
226
+ * A complete, polished chat route matching Frankie's own conversation canvas.
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;
231
+
218
232
  interface ComposerAttachmentsConfig {
219
233
  enabled: boolean;
220
234
  /** Accepted MIME patterns, e.g. "image/*". */
@@ -344,4 +358,4 @@ declare function resolveMode(mode: WidgetTheme["mode"]): "light" | "dark";
344
358
  /** shadcn/ui's class helper: conditional classes with Tailwind conflict resolution. */
345
359
  declare function cn(...inputs: ClassValue[]): string;
346
360
 
347
- export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Composer, FRANKIE_CLOUD_URL, FrankieApiError, 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, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };
361
+ export { type AssistantChatMessage, Avatar, Badge, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, ChatPanel, type ChatPanelProps, Composer, 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, newAssistantMessage, newUserMessage, readEventStream, resolveMode, themeToCssVars, useFrankie, useFrankieChat, useFrankieTheme };