@zenera/chat-widget 0.0.0-stage → 0.1.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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -2
  3. package/dist/index.js +16 -0
  4. package/dist/shadow-DmEgvnQS.js +4 -0
  5. package/dist/styles.css +2 -0
  6. package/dist/types/packages/chat-widget/src/index.d.ts +4 -0
  7. package/dist/types/packages/chat-widget/src/launcher/geometry.d.ts +27 -0
  8. package/dist/types/packages/chat-widget/src/launcher/index.d.ts +17 -0
  9. package/dist/types/packages/chat-widget/src/launcher/presentation.d.ts +59 -0
  10. package/dist/types/packages/chat-widget/src/launcher/shell.d.ts +22 -0
  11. package/dist/types/packages/chat-widget/src/reducer.d.ts +63 -0
  12. package/dist/types/packages/chat-widget/src/transport.d.ts +98 -0
  13. package/dist/types/packages/chat-widget/src/ui/ChatSidebar.d.ts +54 -0
  14. package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +37 -0
  15. package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +42 -0
  16. package/dist/types/packages/chat-widget/src/ui/ZeneraChatLauncher.d.ts +15 -0
  17. package/dist/types/packages/chat-widget/src/ui/ZeneraChatWidget.d.ts +26 -0
  18. package/dist/types/packages/chat-widget/src/ui/index.d.ts +9 -0
  19. package/dist/types/packages/chat-widget/src/ui/internal/InterruptCard.d.ts +35 -0
  20. package/dist/types/packages/chat-widget/src/ui/internal/KnownToolContent.d.ts +7 -0
  21. package/dist/types/packages/chat-widget/src/ui/internal/McpToolContent.d.ts +7 -0
  22. package/dist/types/packages/chat-widget/src/ui/internal/MemoryToolContent.d.ts +10 -0
  23. package/dist/types/packages/chat-widget/src/ui/internal/ShadowFrame.d.ts +6 -0
  24. package/dist/types/packages/chat-widget/src/ui/internal/ToolCallCard.d.ts +25 -0
  25. package/dist/types/packages/chat-widget/src/ui/internal/ToolContent.d.ts +22 -0
  26. package/dist/types/packages/chat-widget/src/ui/internal/composerDraft.d.ts +4 -0
  27. package/dist/types/packages/chat-widget/src/ui/internal/memoryPresentation.d.ts +13 -0
  28. package/dist/types/packages/chat-widget/src/ui/internal/toolPresentation.d.ts +23 -0
  29. package/dist/types/packages/chat-widget/src/useChatThread.d.ts +24 -0
  30. package/dist/types/packages/chat-widget/src/useThreadList.d.ts +11 -0
  31. package/dist/types/packages/chat-widget/src/widget.d.ts +32 -0
  32. package/dist/types/shared/components/Button.d.ts +11 -0
  33. package/dist/types/shared/components/CodeBlock.d.ts +5 -0
  34. package/dist/types/shared/components/CollapsibleBubble.d.ts +7 -0
  35. package/dist/types/shared/components/CopyButton.d.ts +6 -0
  36. package/dist/types/shared/components/DeleteButton.d.ts +13 -0
  37. package/dist/types/shared/components/Hint.d.ts +7 -0
  38. package/dist/types/shared/components/Input.d.ts +2 -0
  39. package/dist/types/shared/components/Markdown.d.ts +6 -0
  40. package/dist/types/shared/components/Mermaid.d.ts +8 -0
  41. package/dist/types/shared/components/Textarea.d.ts +2 -0
  42. package/dist/types/shared/lib/clipboard.d.ts +4 -0
  43. package/dist/types/shared/lib/colorScheme.d.ts +1 -0
  44. package/dist/types/shared/lib/focus.d.ts +2 -0
  45. package/dist/types/shared/lib/highlight.d.ts +3 -0
  46. package/dist/types/shared/lib/portalContainer.d.ts +2 -0
  47. package/dist/types/shared/lib/promptHistory.d.ts +32 -0
  48. package/dist/types/shared/lib/utils.d.ts +2 -0
  49. package/dist/ui.js +2823 -0
  50. package/dist/useThreadList-Pg29akQ4.js +576 -0
  51. package/dist/widget/chat-widget.iife.js +315 -0
  52. package/package.json +89 -5
@@ -0,0 +1,98 @@
1
+ import type { AGUIEvent, Message } from '@ag-ui/core';
2
+ export declare class ChatHttpError extends Error {
3
+ readonly status: number;
4
+ readonly body: Record<string, unknown>;
5
+ constructor(status: number, body: Record<string, unknown>);
6
+ }
7
+ export interface ThreadInfo {
8
+ id: string;
9
+ projectId: string;
10
+ title: string;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ export interface ThreadSnapshot {
15
+ threadId: string;
16
+ /** only for a thread from before run logs */
17
+ messages: Message[];
18
+ /** the ended runs, in order; the one going is followed on its own */
19
+ events: AGUIEvent[];
20
+ running: {
21
+ runId: string;
22
+ } | null;
23
+ }
24
+ /** A paused run's interrupt as zenera-app keeps it (server/interrupts/routes.ts). */
25
+ export interface InterruptInfo {
26
+ id: string;
27
+ kind: string;
28
+ backend: string | null;
29
+ server: string | null;
30
+ status: 'pending' | 'resolved' | 'cancelled' | 'superseded';
31
+ /** queued: settled, the run is about to go on; sent: it did; stale / failed: it will not */
32
+ resumeState: 'queued' | 'sent' | 'stale' | 'failed' | null;
33
+ }
34
+ export interface ChatTransport {
35
+ listThreads(): Promise<{
36
+ threads: ThreadInfo[];
37
+ }>;
38
+ createThread(title?: string): Promise<{
39
+ thread: ThreadInfo;
40
+ }>;
41
+ loadThread(threadId: string): Promise<ThreadSnapshot>;
42
+ deleteThread(threadId: string): Promise<unknown>;
43
+ cancel(threadId: string, runId: string): Promise<{
44
+ ok: boolean;
45
+ }>;
46
+ /** Only for a backend that pauses runs for the user (zenera-app). */
47
+ interrupt?(id: string): Promise<InterruptInfo>;
48
+ /** "Not now": the paused call fails saying so, and the backend resumes the run. */
49
+ cancelInterrupt?(id: string): Promise<InterruptInfo>;
50
+ /** A run from its start: all of it so far, then live until it ends. */
51
+ follow(threadId: string, runId: string, onEvent: (event: AGUIEvent) => void, signal?: AbortSignal): Promise<void>;
52
+ /** Starts a run: resolves when its stream ends, rejects on an HTTP error or abort. */
53
+ run(threadId: string, turn: {
54
+ runId: string;
55
+ messageId: string;
56
+ text: string;
57
+ }, onEvent: (event: AGUIEvent) => void, signal?: AbortSignal): Promise<void>;
58
+ }
59
+ /** 'chats': the user's private chats; 'test-chats': the project editor's Test-tab chats. */
60
+ export type ChatCollection = 'chats' | 'test-chats';
61
+ export interface ChatTransportOptions {
62
+ /** prefix of the API's URLs, e.g. `https://zenera.example.com`; default: the page's origin */
63
+ baseUrl?: string;
64
+ collection?: ChatCollection;
65
+ /** replaces the global `fetch`, e.g. to add credentials or to refresh a token */
66
+ fetch?: typeof fetch;
67
+ /** added to every request; a function is called for each one */
68
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
69
+ }
70
+ export declare function readEvents(res: Response, onEvent: (event: AGUIEvent) => void): Promise<void>;
71
+ export declare function createChatTransport(projectId: string, { baseUrl, collection, fetch: doFetch, headers }?: ChatTransportOptions): ChatTransport;
72
+ /** The request a runtime token is for: what the server sees as `METHOD originalUrl`. */
73
+ export interface RuntimeRequest {
74
+ method: string;
75
+ /** path and query, e.g. `/api/sessions/<id>/runs` */
76
+ path: string;
77
+ }
78
+ export interface RuntimeTransportOptions {
79
+ /** the runtime's address, e.g. `http://127.0.0.1:3000` */
80
+ baseUrl: string;
81
+ /**
82
+ * The caller's JWT, or a function that returns one for each request. An `--insecure`
83
+ * server only decodes it (`zen server token --user <id>`, a fixed string will do). A
84
+ * signed server wants a fresh EdDSA token bound to the request (`req`), which only a
85
+ * trusted backend can make: sign there and call it from this function.
86
+ */
87
+ token: string | ((request: RuntimeRequest) => string | Promise<string>);
88
+ /** replaces the global `fetch` */
89
+ fetch?: typeof fetch;
90
+ }
91
+ /**
92
+ * A Zenera runtime (`zen server`) without zenera-app in between: `/api/sessions`, the user
93
+ * named by the JWT's `sub`. The runtime has no create call: a session exists from its first
94
+ * run, so `createThread` only makes the id and the thread joins the list after that run.
95
+ * The runtime sets CORS for no origin but `file://`, so a page on another origin needs a
96
+ * proxy (or the page the runtime itself serves at /chat).
97
+ */
98
+ export declare function createRuntimeTransport({ baseUrl, token, fetch: doFetch, }: RuntimeTransportOptions): ChatTransport;
@@ -0,0 +1,54 @@
1
+ import { type PointerEvent, type ReactNode } from 'react';
2
+ import type { ChatTransport, ThreadInfo } from '../transport.js';
3
+ /** The messages beside the sidebar never get narrower than this: the sidebar folds or stops. */
4
+ export declare const MIN_CHAT_BODY_WIDTH = 300;
5
+ export type SidebarSide = 'left' | 'right';
6
+ /** The sidebar's width for a pointer at `clientX`, the outer edge of the sidebar being fixed. */
7
+ export declare function widthFromPointer(side: SidebarSide, clientX: number, rect: {
8
+ left: number;
9
+ right: number;
10
+ }): number;
11
+ export interface SidebarLayout {
12
+ collapsed: boolean;
13
+ width: number;
14
+ resizing: boolean;
15
+ /** folds or unfolds it, and remembers the choice */
16
+ toggle: () => void;
17
+ /** folds or unfolds it for the page, e.g. from a prop; not remembered */
18
+ setCollapsed: (collapsed: boolean) => void;
19
+ startResize: (e: PointerEvent<HTMLElement>) => void;
20
+ }
21
+ /**
22
+ * Width and folded state of the sidebar, kept in localStorage under `${storageKey}Collapsed` and
23
+ * `${storageKey}Width`. With no choice made yet a narrow window starts folded, unless
24
+ * `initialCollapsed` says otherwise (it wins over what is stored). `side` is the side of the
25
+ * chat the sidebar is on, which decides the direction of a drag.
26
+ */
27
+ export declare function useSidebarLayout(storageKey?: string, side?: SidebarSide, initialCollapsed?: boolean): SidebarLayout;
28
+ export interface ChatSidebarProps {
29
+ transport: ChatTransport | null;
30
+ layout: SidebarLayout;
31
+ activeThreadId: string | null;
32
+ /** opens a thread; not needed when `renderLink` makes the rows links */
33
+ onSelect?: (threadId: string) => void;
34
+ onNew: () => void;
35
+ /** a thread was deleted, e.g. to leave it when it was the open one */
36
+ onDelete?: (threadId: string) => void;
37
+ /** draws the clickable part of a row, e.g. a router link; `props` has its classes and title */
38
+ renderLink?: (thread: ThreadInfo, props: {
39
+ className: string;
40
+ children: ReactNode;
41
+ }) => ReactNode;
42
+ /** disables "New chat", e.g. while a thread is being created */
43
+ newDisabled?: boolean;
44
+ /** the list is loaded again when this changes, e.g. after a turn ended */
45
+ refreshKey?: unknown;
46
+ /** under the list, e.g. a button of the page; draw it for `layout.collapsed` too */
47
+ footer?: ReactNode;
48
+ /** the side of the chat the sidebar is on; use the same for `useSidebarLayout`. Default `'left'` */
49
+ side?: SidebarSide;
50
+ /** draws a button that folds and unfolds the sidebar, above "New chat"; default `false` */
51
+ showToggle?: boolean;
52
+ className?: string;
53
+ }
54
+ export declare function ChatSidebar({ transport, layout, activeThreadId, onSelect, onNew, onDelete, renderLink, newDisabled, refreshKey, footer, side, showToggle, className, }: ChatSidebarProps): import("react").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import type { ChatItem } from '../reducer.js';
2
+ import { type InterruptActions } from './internal/InterruptCard.js';
3
+ export declare function agentLabels(items: ChatItem[]): Map<string, string>;
4
+ export declare function ChatMessages({ items, running, interrupts, }: {
5
+ items: ChatItem[];
6
+ running: boolean;
7
+ interrupts?: InterruptActions;
8
+ }): import("react").JSX.Element;
9
+ export declare function EmptyChat({ title, nudge, variants, }: {
10
+ title?: string;
11
+ nudge?: number;
12
+ variants?: StarterMessage[];
13
+ }): import("react").JSX.Element;
14
+ /** What an empty chat says: a heading, and a line under it. A string is just the heading. */
15
+ export type StarterMessage = string | {
16
+ title: string;
17
+ subtitle?: string;
18
+ };
19
+ export declare function starterAt(variants: StarterMessage[], index: number): {
20
+ title: string;
21
+ subtitle?: string;
22
+ };
23
+ interface ComposerProps {
24
+ disabled: boolean;
25
+ running: boolean;
26
+ placeholder: string;
27
+ /** where ↑/↓ finds the messages sent before; see `historyKey` in lib/promptHistory */
28
+ historyKey?: string;
29
+ /** where the unsent text is kept; see `composerDraftKey` in ./internal/composerDraft */
30
+ draftKey?: string;
31
+ /** each change takes the keyboard focus, e.g. "New chat" pressed while the chat is empty */
32
+ focusSignal?: number;
33
+ onSend: (text: string) => void;
34
+ onStop: () => void;
35
+ }
36
+ export declare function Composer(props: ComposerProps): import("react").JSX.Element;
37
+ export {};
@@ -0,0 +1,42 @@
1
+ import { type CSSProperties } from 'react';
2
+ import type { ChatTransport } from '../transport.js';
3
+ import { type StarterMessage } from './ChatThreadView.js';
4
+ export interface ZeneraChatProps {
5
+ transport: ChatTransport | null;
6
+ /** the thread to show; null for a chat that has none yet */
7
+ threadId: string | null;
8
+ /** a thread was created for the first message */
9
+ onThreadChange?: (threadId: string) => void;
10
+ /** called when a turn has ended, e.g. to refresh a list of threads */
11
+ onTurnEnd?: () => void;
12
+ placeholder?: string;
13
+ /**
14
+ * what an empty chat says (heading and optional subtitle), instead of nothing. In
15
+ * <ZeneraChatWidget> each "New chat" shows the next one, in order. Leave out for a blank chat.
16
+ */
17
+ starterMessages?: StarterMessage[];
18
+ /** see `historyKey` */
19
+ historyKey?: string;
20
+ /** see `composerDraftKey` */
21
+ draftKey?: string;
22
+ /** draw the chat in a shadow root (default) or in the page */
23
+ isolate?: boolean;
24
+ /** colours and radius to use instead of the defaults, e.g. `{ primary: '#7c3aed' }` */
25
+ theme?: Partial<Record<ThemeToken, string>>;
26
+ /** layout of the chat's outer element (its size, margins) */
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ }
30
+ export type ThemeToken = 'background' | 'foreground' | 'card' | 'card-foreground' | 'popover' | 'popover-foreground' | 'primary' | 'primary-foreground' | 'secondary' | 'secondary-foreground' | 'muted' | 'muted-foreground' | 'accent' | 'accent-foreground' | 'destructive' | 'border' | 'input' | 'ring' | 'surface-input' | 'surface-code' | 'success' | 'warning' | 'danger' | 'info' | 'teal' | 'radius';
31
+ export declare const themeStyle: (theme?: ZeneraChatProps["theme"]) => CSSProperties | undefined;
32
+ export declare function ZeneraChat({ isolate, className, style, theme, ...props }: ZeneraChatProps): import("react").JSX.Element;
33
+ export type ChatBodyProps = Omit<ZeneraChatProps, 'isolate' | 'theme' | 'className' | 'style'> & {
34
+ rootClassName?: string;
35
+ rootStyle?: CSSProperties;
36
+ dark?: boolean;
37
+ /** inside another `.zenera-chat` (see ZeneraChatWidget), which already has the tokens and `dark` */
38
+ nested?: boolean;
39
+ /** counts "New chat" presses; each one moves `starterMessages` on to the next */
40
+ newChatSignal?: number;
41
+ };
42
+ export declare function ChatBody({ transport, threadId, onThreadChange, onTurnEnd, placeholder, starterMessages, newChatSignal, historyKey, draftKey, rootClassName, rootStyle, dark, nested, }: ChatBodyProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { Presentation } from '../launcher/presentation.js';
3
+ export type { DockedPresentation, OverlayPresentation, PopupPresentation, Presentation, Side, } from '../launcher/presentation.js';
4
+ export interface ZeneraChatLauncherProps {
5
+ /** the id of the element the chat is put in; no other element of the page may have it */
6
+ chatId: string;
7
+ presentation: Presentation;
8
+ /** controls whether the panel is open; leave out to let the launcher keep it */
9
+ open?: boolean;
10
+ /** the panel opened or closed, by a click, Escape or a change of `open` */
11
+ onOpenChange?: (open: boolean) => void;
12
+ /** the chat: `<ZeneraChatWidget />` */
13
+ children: ReactNode;
14
+ }
15
+ export declare function ZeneraChatLauncher({ chatId, presentation, open, onOpenChange, children, }: ZeneraChatLauncherProps): import("react").ReactPortal | null;
@@ -0,0 +1,26 @@
1
+ import { type ZeneraChatProps } from './ZeneraChat.js';
2
+ import { type ChatSidebarProps, type SidebarSide } from './ChatSidebar.js';
3
+ export interface ZeneraChatWidgetProps extends Omit<ZeneraChatProps, 'threadId' | 'onThreadChange'> {
4
+ /** the open thread, to control it; leave out to let the workspace keep it */
5
+ threadId?: string | null;
6
+ /** a thread was opened, created for a first message, started anew (null) or deleted (null) */
7
+ onThreadChange?: (threadId: string | null) => void;
8
+ /** draws a thread's row, e.g. as a router link; see ChatSidebar */
9
+ renderLink?: ChatSidebarProps['renderLink'];
10
+ /** localStorage keys of the sidebar's width and fold: `${key}Width`, `${key}Collapsed` */
11
+ sidebarStorageKey?: string;
12
+ /** the side of the chat the thread list is on; default `'left'` */
13
+ sidebarSide?: SidebarSide;
14
+ /**
15
+ * folds (`true`) or unfolds (`false`) the thread list whenever it changes, e.g. from your own
16
+ * button; also the state it starts in. Leave out to keep what the user chose (remembered in
17
+ * localStorage), a narrow window starting folded
18
+ */
19
+ sidebarCollapsed?: boolean;
20
+ /** the thread list was folded or unfolded, by the user or `sidebarCollapsed`; also once on mount */
21
+ onSidebarCollapsedChange?: (collapsed: boolean) => void;
22
+ /** draws a button in the thread list that folds and unfolds it; default `false` */
23
+ sidebarToggle?: boolean;
24
+ sidebarClassName?: string;
25
+ }
26
+ export declare function ZeneraChatWidget({ isolate, className, style, theme, ...props }: ZeneraChatWidgetProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ export { ZeneraChat, type ZeneraChatProps } from './ZeneraChat.js';
2
+ export { ZeneraChatWidget, type ZeneraChatWidgetProps } from './ZeneraChatWidget.js';
3
+ export { ZeneraChatLauncher, type ZeneraChatLauncherProps } from './ZeneraChatLauncher.js';
4
+ export type { DockedPresentation, OverlayPresentation, PopupPresentation, Presentation, Side, } from '../launcher/presentation.js';
5
+ export { ChatSidebar, useSidebarLayout, type ChatSidebarProps, type SidebarLayout, type SidebarSide, } from './ChatSidebar.js';
6
+ export { ChatMessages, Composer, EmptyChat, type StarterMessage } from './ChatThreadView.js';
7
+ export { InterruptCard, InterruptsContext, interruptPhase, Shell, type InterruptActions, type InterruptCardProps, type InterruptPhase, } from './internal/InterruptCard.js';
8
+ export { composerDraftKey } from './internal/composerDraft.js';
9
+ export { historyKey } from '../../../../shared/lib/promptHistory.js';
@@ -0,0 +1,35 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import type { ChatInterrupt } from '../../reducer.js';
3
+ import type { InterruptInfo } from '../../transport.js';
4
+ export interface InterruptActions {
5
+ /** the zenera-app project of the chat, for cards that call its API */
6
+ projectId?: string;
7
+ /** how the backend has each interrupt, by id; missing: not asked yet, or not this user's */
8
+ info: Record<string, InterruptInfo>;
9
+ cancel: (id: string) => Promise<void>;
10
+ /** ask now how the interrupts stand */
11
+ refresh?: () => void;
12
+ /** cards by interrupt kind (metadata.kind, else the reason); a kind not here gets the plain card */
13
+ cards?: Record<string, ComponentType<InterruptCardProps>>;
14
+ }
15
+ export declare const InterruptsContext: import("react").Context<InterruptActions | null>;
16
+ export interface InterruptCardProps {
17
+ interrupt: ChatInterrupt;
18
+ /** the backend's status of it, if this user may see it */
19
+ info?: InterruptInfo;
20
+ actions: InterruptActions;
21
+ }
22
+ /** Where the card stands, from the chat (a later run started) and from zenera-app. */
23
+ export type InterruptPhase = 'waiting' | 'resuming' | 'resolved' | 'cancelled' | 'superseded' | 'failed';
24
+ export declare function interruptPhase(i: ChatInterrupt, info?: InterruptInfo): InterruptPhase;
25
+ /** The card's frame: icon, title, a line of text, and its buttons. Theme colors only. */
26
+ export declare function Shell({ icon, title, text, tone, children, }: {
27
+ icon: ReactNode;
28
+ title: ReactNode;
29
+ text?: ReactNode;
30
+ tone: 'active' | 'done' | 'muted' | 'danger';
31
+ children?: ReactNode;
32
+ }): import("react").JSX.Element;
33
+ export declare function InterruptCard({ interrupt }: {
34
+ interrupt: ChatInterrupt;
35
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ export declare function KnownToolContent({ name, input, value, args, partial, }: {
2
+ name: string;
3
+ input: boolean;
4
+ value: unknown;
5
+ args?: unknown;
6
+ partial?: boolean;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export declare function McpToolContent({ name, input, value, args, partial, }: {
2
+ name: string;
3
+ input: boolean;
4
+ value: unknown;
5
+ args?: unknown;
6
+ partial?: boolean;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ type RenderValue = (value: unknown) => ReactNode;
3
+ export declare function MemoryToolContent({ name, input, value, text, renderValue, }: {
4
+ name: string;
5
+ input: boolean;
6
+ value: unknown;
7
+ text: string;
8
+ renderValue: RenderValue;
9
+ }): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export declare function ShadowFrame({ children, className, style, }: {
3
+ children: ReactNode;
4
+ className?: string;
5
+ style?: CSSProperties;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { ChatItem } from '../../reducer.js';
2
+ import { type ReactNode } from 'react';
3
+ import { type ToolFamily, type ToolPayload } from './toolPresentation.js';
4
+ export declare function NestedContent({ className, children, }: {
5
+ className?: string;
6
+ children: ReactNode;
7
+ }): import("react").JSX.Element;
8
+ export declare function ToolPayloadContent({ payload, raw, markdown, receiving, tool, }: {
9
+ payload: ToolPayload;
10
+ raw: boolean;
11
+ markdown?: boolean;
12
+ receiving?: boolean;
13
+ tool?: {
14
+ name: string;
15
+ family: ToolFamily;
16
+ input: boolean;
17
+ args: unknown;
18
+ };
19
+ }): import("react").JSX.Element;
20
+ export declare function ToolCallCard({ item, running, }: {
21
+ item: Extract<ChatItem, {
22
+ kind: 'tool';
23
+ }>;
24
+ running: boolean;
25
+ }): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare function ToolLink({ url, children }: {
3
+ url: string;
4
+ children?: ReactNode;
5
+ }): import("react").JSX.Element;
6
+ export declare function ToolDocument({ text, path }: {
7
+ text: string;
8
+ path?: string;
9
+ }): import("react").JSX.Element;
10
+ export declare function ToolValue({ value, field, depth, }: {
11
+ value: unknown;
12
+ field?: string;
13
+ depth?: number;
14
+ }): import("react").JSX.Element;
15
+ export declare function ToolMetadata({ value }: {
16
+ value: Record<string, unknown>;
17
+ }): import("react").JSX.Element;
18
+ export declare function ToolDetails({ value, omit, renderValue, }: {
19
+ value: Record<string, unknown>;
20
+ omit: string[];
21
+ renderValue?: (value: unknown) => ReactNode;
22
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ /** `threadId` null is the new chat that has no thread yet. */
2
+ export declare const composerDraftKey: (surface: "chat" | "test-chat", userId: string, projectId: string, threadId: string | null) => string;
3
+ export declare function loadDraft(key: string): string;
4
+ export declare function saveDraft(key: string, text: string): void;
@@ -0,0 +1,13 @@
1
+ export interface MemoryOutlineEntry {
2
+ id: string;
3
+ kind: string;
4
+ depth: number;
5
+ score?: string;
6
+ relation?: string;
7
+ lines: string[];
8
+ }
9
+ export interface MemoryOutline {
10
+ entries: MemoryOutlineEntry[];
11
+ notes: string[];
12
+ }
13
+ export declare function parseMemoryOutline(text: string): MemoryOutline | undefined;
@@ -0,0 +1,23 @@
1
+ export type ToolFamily = 'memory' | 'file' | 'command' | 'web' | 'agent' | 'mcp' | 'other';
2
+ export interface ToolPayload {
3
+ value: unknown;
4
+ raw: string;
5
+ incomplete: boolean;
6
+ omitted?: number;
7
+ }
8
+ export declare function record(value: unknown): Record<string, unknown> | undefined;
9
+ export declare function formatJsonFragment(text: string): string;
10
+ export declare function parseToolPayload(text: string): ToolPayload;
11
+ /** A Bifrost server name as people read it (GitHub_Remote -> GitHub Remote); as server/mcp/pages.ts. */
12
+ export declare function serviceName(server: string): string;
13
+ export declare function toolPresentation(name: string, payload: ToolPayload, result?: ToolPayload): {
14
+ title: string;
15
+ family: ToolFamily;
16
+ preview: string;
17
+ };
18
+ export interface ToolOutcome {
19
+ label: string;
20
+ tone: 'muted' | 'success' | 'danger' | 'warning';
21
+ pending?: boolean;
22
+ }
23
+ export declare function toolOutcome(result: ToolPayload | undefined, isError: boolean | undefined, running: boolean): ToolOutcome;
@@ -0,0 +1,24 @@
1
+ import { type ChatState } from './reducer.js';
2
+ import { type ChatTransport, type ChatTransportOptions, type InterruptInfo, type RuntimeTransportOptions } from './transport.js';
3
+ export interface ChatThread extends ChatState {
4
+ /** the project's pod status while it is waking up, else null */
5
+ starting: string | null;
6
+ /** the connection to a run going was lost and is being made again */
7
+ reconnecting: boolean;
8
+ send: (text: string) => Promise<void>;
9
+ cancel: () => void;
10
+ /** how zenera-app has each interrupt of `interrupts`, once asked (none: not the user's own) */
11
+ interruptInfo: Record<string, InterruptInfo>;
12
+ /** "Not now" on an interrupt: the run goes on without it */
13
+ cancelInterrupt: (id: string) => Promise<void>;
14
+ /** ask now how the waiting interrupts stand (e.g. a connect popup reported back) */
15
+ refreshInterrupts: () => void;
16
+ }
17
+ /** The zenera-app transport of a project's chats, kept while its arguments are unchanged. */
18
+ export declare function useChatTransport(projectId: string | null, { baseUrl, collection, fetch, headers }?: ChatTransportOptions): ChatTransport | null;
19
+ /**
20
+ * The transport of a Zenera runtime (`zen server`), kept while `baseUrl`, `token` and `fetch`
21
+ * are unchanged. Pass a string token, or a function that is stable (module level or useCallback).
22
+ */
23
+ export declare function useRuntimeTransport({ baseUrl, token, fetch, }: RuntimeTransportOptions): ChatTransport;
24
+ export declare function useChatThread(transport: ChatTransport | null, threadId: string | null): ChatThread;
@@ -0,0 +1,11 @@
1
+ import type { ChatTransport, ThreadInfo } from './transport.js';
2
+ export interface ThreadList {
3
+ threads: ThreadInfo[];
4
+ loading: boolean;
5
+ error: string | null;
6
+ /** a delete is in flight */
7
+ removing: boolean;
8
+ refresh: () => void;
9
+ remove: (threadId: string) => Promise<void>;
10
+ }
11
+ export declare function useThreadList(transport: ChatTransport | null, refreshKey?: unknown): ThreadList;
@@ -0,0 +1,32 @@
1
+ import { type ChatTransport, type RuntimeTransportOptions } from './transport.js';
2
+ import { mount as mountLauncher } from './launcher/index.js';
3
+ import { type ZeneraChatWidgetProps } from './ui/ZeneraChatWidget.js';
4
+ export interface WidgetOptions extends Pick<RuntimeTransportOptions, 'baseUrl' | 'token'>, Pick<ZeneraChatWidgetProps, 'placeholder' | 'starterMessages' | 'theme' | 'isolate' | 'className' | 'style' | 'historyKey' | 'draftKey' | 'sidebarSide' | 'sidebarCollapsed' | 'onSidebarCollapsedChange' | 'sidebarToggle'> {
5
+ /** the thread to open; leave out (or null) for a new chat */
6
+ threadId?: string | null;
7
+ /** the chat's height, e.g. `'600px'`; default: that of the element, else 600px */
8
+ height?: string;
9
+ onThreadChange?: (threadId: string | null) => void;
10
+ onTurnEnd?: () => void;
11
+ }
12
+ export interface ZeneraChatWidgetHandle {
13
+ /** the element the chat is drawn in: the one given to `mount`, or the one it made */
14
+ readonly element: HTMLElement;
15
+ /** whether the thread list is folded; `undefined` until the chat has been drawn */
16
+ readonly sidebarCollapsed: boolean | undefined;
17
+ /** folds the thread list, or unfolds it when it is folded */
18
+ toggleSidebar: () => void;
19
+ /** changes some options; a new `baseUrl` makes a new connection */
20
+ update: (options: Partial<WidgetOptions>) => void;
21
+ /** takes the chat out of the page */
22
+ unmount: () => void;
23
+ }
24
+ /** The runtime's transport, reading `token` anew for each request so an update reaches it. */
25
+ export declare function widgetTransport(read: () => WidgetOptions): ChatTransport;
26
+ /**
27
+ * Draws the chat in `target`. Without a target it makes a detached element of its own (filling
28
+ * whatever it is put in), for a launcher or for you to append where you want it: `handle.element`.
29
+ */
30
+ export declare function mount(target: string | Element, options: WidgetOptions): ZeneraChatWidgetHandle;
31
+ export declare function mount(options: WidgetOptions): ZeneraChatWidgetHandle;
32
+ export { mountLauncher };
@@ -0,0 +1,11 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "link" | "secondary" | "outline" | "ghost" | "destructive" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ }
10
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare function CodeBlock({ code, lang, className, }: {
2
+ code: string;
3
+ lang?: string;
4
+ className?: string;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare const COLLAPSED_PX = 240;
3
+ export declare const needsCollapse: (contentPx: number) => boolean;
4
+ export declare function CollapsibleBubble({ children, className, }: {
5
+ children: ReactNode;
6
+ className?: string;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare const messageCopyReveal = "opacity-0 group-hover/msg:opacity-100 [@media(hover:none)]:opacity-100";
2
+ export declare function CopyButton({ text, label, className, }: {
3
+ text: string;
4
+ label?: string;
5
+ className?: string;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ export declare function useConfirmDelete(onDelete: (id: string) => void, ms?: number): {
2
+ armed: string | null;
3
+ request: (id: string) => void;
4
+ disarm: () => void;
5
+ };
6
+ export declare function DeleteButton({ armed, onClick, disabled, label, alwaysShown, className, }: {
7
+ armed: boolean;
8
+ onClick: () => void;
9
+ disabled?: boolean;
10
+ label?: string;
11
+ alwaysShown?: boolean;
12
+ className?: string;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ export declare function Hint({ label, side, className, children, }: {
3
+ label: ReactNode;
4
+ side?: 'top' | 'right' | 'bottom' | 'left';
5
+ className?: string;
6
+ children: ReactElement;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const Input: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,6 @@
1
+ export declare function Markdown({ children, className, lines, linkAction, }: {
2
+ children: string;
3
+ className?: string;
4
+ lines?: boolean;
5
+ linkAction?: (href: string) => (() => void) | undefined;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `natural`: drawn at its own size (one font size for every diagram on a page), scrolled sideways
3
+ * when wider than its box; otherwise shrunk to fit the box's width.
4
+ */
5
+ export declare function Mermaid({ code, natural }: {
6
+ code: string;
7
+ natural?: boolean;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,4 @@
1
+ import type { ClipboardEvent } from 'react';
2
+ export declare function writeClipboard(text: string): Promise<void>;
3
+ export declare const withoutTrailingNewlines: (text: string) => string;
4
+ export declare function copyWithoutTrailingNewlines(e: ClipboardEvent<HTMLElement>): void;
@@ -0,0 +1 @@
1
+ export declare function useColorScheme(): 'light' | 'dark';
@@ -0,0 +1,2 @@
1
+ export declare function canTakeFocus(within?: Element | null): boolean;
2
+ export declare function focusTextarea(el: HTMLTextAreaElement | null, within?: Element | null): void;
@@ -0,0 +1,3 @@
1
+ export declare const DOCKERFILE: RegExp;
2
+ export declare function languageOf(path: string): string | undefined;
3
+ export declare function highlight(code: string, lang?: string): string | null;