@smarter.sh/ui-chat 0.11.0 → 0.36.0-alpha.3

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 (31) hide show
  1. package/README.md +78 -64
  2. package/dist/embed.js +56 -66
  3. package/dist/embed.js.map +1 -1
  4. package/dist/smarter-chat-library.es.js +4509 -10334
  5. package/dist/smarter-chat-library.es.js.map +1 -1
  6. package/dist/smarter-chat-library.umd.js +50 -60
  7. package/dist/smarter-chat-library.umd.js.map +1 -1
  8. package/dist/types/src/components/SmarterChat/Component.d.ts +13 -13
  9. package/dist/types/src/components/SmarterChat/HeaderButton.d.ts +9 -0
  10. package/dist/types/src/components/SmarterChat/icons.d.ts +0 -9
  11. package/dist/types/src/components/SmarterChat/index.d.ts +3 -0
  12. package/dist/types/src/contract.gen.d.ts +14 -3
  13. package/dist/types/src/embed/element.d.ts +1 -1
  14. package/dist/types/src/index.d.ts +4 -4
  15. package/dist/types/src/lib/api.d.ts +8 -1
  16. package/dist/types/src/lib/i18n.d.ts +6 -5
  17. package/dist/types/src/types.d.ts +22 -10
  18. package/dist/ui-chat.css +1 -1
  19. package/package.json +8 -5
  20. package/LICENSE +0 -671
  21. package/dist/types/src/components/Console/Component.d.ts +0 -17
  22. package/dist/types/src/components/Console/ServerLogs.d.ts +0 -8
  23. package/dist/types/src/components/Console/data.d.ts +0 -7
  24. package/dist/types/src/components/Console/enums.d.ts +0 -9
  25. package/dist/types/src/components/Console/index.d.ts +0 -2
  26. package/dist/types/src/components/DocsDialog/Component.d.ts +0 -8
  27. package/dist/types/src/components/DocsDialog/data.d.ts +0 -18
  28. package/dist/types/src/components/DocsDialog/index.d.ts +0 -2
  29. package/dist/types/src/lib/ansi.d.ts +0 -33
  30. package/dist/types/src/lib/layout.d.ts +0 -42
  31. package/dist/types/src/lib/logStream.d.ts +0 -30
@@ -1,17 +0,0 @@
1
- import { type ConsoleConfig } from "@/components/Console/data";
2
- import "@/components/Console/styles.css";
3
- interface ConsoleProps {
4
- /** The LLMClient's configuration, from its config api. Empty until it loads. */
5
- config: ConsoleConfig;
6
- /** The url of the user's server log stream. Without it, there is no "Server Logs" tab. */
7
- logStreamUrl?: string | null;
8
- /**
9
- * The minimum log level of the server logs, e.g. "DEBUG" in sandbox mode. Without it, the server's
10
- * own log level. A change reconnects the stream, which replays the history at the new level.
11
- */
12
- logLevel?: string | null;
13
- /** Changes when a new chat session starts, which clears the server logs. */
14
- resetKey?: number | string;
15
- }
16
- declare function Console({ config, logStreamUrl, logLevel, resetKey }: ConsoleProps): import("react").JSX.Element;
17
- export default Console;
@@ -1,8 +0,0 @@
1
- import type { LogEvent } from "@/lib/logStream";
2
- interface ServerLogsProps {
3
- logs: LogEvent[];
4
- connected: boolean;
5
- error: string | null;
6
- }
7
- declare function ServerLogs(props: ServerLogsProps): import("react").JSX.Element;
8
- export default ServerLogs;
@@ -1,7 +0,0 @@
1
- /** The data that the Console displays for each of its menu items. */
2
- import type { ChatConfig } from "../../types";
3
- import { type MenuItem } from "./enums";
4
- /** The LLMClient's configuration, from its config api. Empty until it loads. */
5
- export type ConsoleConfig = ChatConfig | Record<string, never> | null;
6
- /** The JSON objects to display for a menu item. */
7
- export declare function consoleData(config: ConsoleConfig, item: MenuItem): object[];
@@ -1,9 +0,0 @@
1
- /** The Console's menu items: the configuration, the chat session's histories, and the server logs. */
2
- export declare const MenuItems: {
3
- readonly CHAT_CONFIG: "chat_config";
4
- readonly LLMCLIENT_REQUEST_HISTORY: "llmclient_request_history";
5
- readonly CHAT_TOOL_CALL_HISTORY: "chat_tool_call_history";
6
- readonly CHAT_PLUGIN_USAGE_HISTORY: "chat_plugin_usage_history";
7
- readonly SERVER_LOGS: "server_logs";
8
- };
9
- export type MenuItem = (typeof MenuItems)[keyof typeof MenuItems];
@@ -1,2 +0,0 @@
1
- import Console from "@/components/Console/Component";
2
- export default Console;
@@ -1,8 +0,0 @@
1
- import { type DocSection } from "@/components/DocsDialog/data";
2
- import "@/components/DocsDialog/styles.css";
3
- interface DocsDialogProps {
4
- onClose: () => void;
5
- sections?: DocSection[];
6
- }
7
- declare function DocsDialog({ onClose, sections }: DocsDialogProps): import("react").JSX.Element;
8
- export default DocsDialog;
@@ -1,18 +0,0 @@
1
- /** A technical reference that the Docs dialog links to. */
2
- export interface DocLink {
3
- title: string;
4
- url: string;
5
- description: string;
6
- }
7
- /** A tab of the Docs dialog: the technical references for one audience. */
8
- export interface DocSection {
9
- title: string;
10
- description: string;
11
- links: DocLink[];
12
- }
13
- /** The technical references for prompt engineers, who build LLMClients in the sandbox. */
14
- export declare function promptEngineerLinks(): DocLink[];
15
- /** The technical references for software engineers, who build the applications that host them. */
16
- export declare function softwareEngineerLinks(): DocLink[];
17
- /** The tabs of the Docs dialog, from left to right. The first one is selected when it opens. */
18
- export declare function docSections(): DocSection[];
@@ -1,2 +0,0 @@
1
- import DocsDialog from "@/components/DocsDialog/Component";
2
- export default DocsDialog;
@@ -1,33 +0,0 @@
1
- /**
2
- * ANSI escape codes, as the server's log records have them, e.g. "\x1b[1;34m...\x1b[0m".
3
- *
4
- * The text of a log record is split into segments, each with the color and the emphasis that its
5
- * SGR (Select Graphic Rendition) codes give it, so that the Console displays the records as the
6
- * Smarter web console's log viewer (smarter-terminal-emulator, an xterm.js terminal) does. Other
7
- * escape sequences, e.g. cursor movements, are removed.
8
- */
9
- import type { CSSProperties } from "react";
10
- /** The xterm.js theme of smarter-terminal-emulator, by ANSI color number: 0-7, then bright 8-15. */
11
- export declare const ANSI_PALETTE: string[];
12
- /** The text style that SGR codes set. */
13
- export interface AnsiStyle {
14
- color?: string;
15
- backgroundColor?: string;
16
- bold?: boolean;
17
- dim?: boolean;
18
- italic?: boolean;
19
- underline?: boolean;
20
- }
21
- /** A run of text, with its style. */
22
- export interface AnsiSegment {
23
- text: string;
24
- style: AnsiStyle;
25
- }
26
- /** The style after the given SGR codes. An empty list of codes is a reset. */
27
- export declare function applySgr(style: AnsiStyle, codes: number[]): AnsiStyle;
28
- /** The text's segments, each with its style, without the escape sequences. */
29
- export declare function parseAnsi(text: string): AnsiSegment[];
30
- /** The text without its escape sequences. */
31
- export declare function stripAnsi(text: string): string;
32
- /** The css of a style. */
33
- export declare function ansiCss(style: AnsiStyle): CSSProperties;
@@ -1,42 +0,0 @@
1
- /**
2
- * The layout of the chat and the Console: the width of the chat, which the user changes by dragging
3
- * the separator between them, whether the Console is visible, and whether its server logs' long
4
- * lines wrap. They are remembered in the browser's localStorage, which may be unavailable, e.g. in a private window, so they have defaults.
5
- */
6
- import { type KeyboardEvent, type PointerEvent, type RefObject, type SetStateAction } from "react";
7
- /** The chat's width, as a percentage of the component's width. */
8
- export declare const DEFAULT_CHAT_WIDTH = 33.33;
9
- export declare const MIN_CHAT_WIDTH = 20;
10
- export declare const MAX_CHAT_WIDTH = 80;
11
- /** The change in the chat's width, in percent, for each arrow key press on the separator. */
12
- export declare const KEYBOARD_STEP = 5;
13
- export declare const CHAT_WIDTH_STORAGE_KEY = "smarter-chat.chat-width";
14
- export declare const CONSOLE_VISIBLE_STORAGE_KEY = "smarter-chat.console-visible";
15
- export declare const LOG_WRAP_STORAGE_KEY = "smarter-chat.log-wrap";
16
- export declare function clampChatWidth(width: number): number;
17
- /** Whether the Console is visible. It is, until the user hides it. */
18
- export declare function useConsoleVisible(): readonly [boolean, (action: SetStateAction<boolean>) => void];
19
- /** Whether the server logs' long lines wrap. They don't, until the user wraps them: they scroll. */
20
- export declare function useLogWrap(): readonly [boolean, (action: SetStateAction<boolean>) => void];
21
- /**
22
- * The chat's width, and the props of the separator that resizes it. The separator is a focusable
23
- * "separator", whose value is the chat's width: drag it, or use the arrow, Home and End keys.
24
- * Double-click it to restore the default width.
25
- */
26
- export declare function useChatWidth(containerRef: RefObject<HTMLElement | null>): {
27
- chatWidth: number;
28
- separatorProps: {
29
- role: string;
30
- tabIndex: number;
31
- "aria-orientation": "vertical";
32
- "aria-label": string;
33
- "aria-valuenow": number;
34
- "aria-valuemin": number;
35
- "aria-valuemax": number;
36
- onPointerDown: (event: PointerEvent<HTMLElement>) => void;
37
- onPointerMove: (event: PointerEvent<HTMLElement>) => void;
38
- onPointerUp: (event: PointerEvent<HTMLElement>) => void;
39
- onDoubleClick: () => void;
40
- onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
41
- };
42
- };
@@ -1,30 +0,0 @@
1
- /** A log record. Records that aren't JSON are displayed as their message. */
2
- export interface LogEvent {
3
- message: string;
4
- level?: string;
5
- levelname?: string;
6
- timestamp?: number | string;
7
- logger?: string;
8
- [key: string]: unknown;
9
- }
10
- /** The most records to keep. Older records are dropped. */
11
- export declare const MAX_LOG_EVENTS = 2000;
12
- /** The log level of the stream in sandbox mode. Production mode uses the server's log level. */
13
- export declare const SANDBOX_LOG_LEVEL = "DEBUG";
14
- /**
15
- * The log stream's url, for the records at or above the given log level, e.g. "DEBUG". Without a
16
- * level, the url is unchanged, and the stream sends the records at or above the server's log level.
17
- */
18
- export declare function logStreamUrlForLevel(streamUrl: string | null, level?: string | null): string | null;
19
- /**
20
- * The log stream's records, and its connection state. Connects only while streamUrl is set.
21
- *
22
- * clear() removes the records, e.g. for a new chat session. The records that were logged before
23
- * then are not displayed again, even when a reconnection replays the history.
24
- */
25
- export declare function useLogStream(streamUrl: string | null): {
26
- logs: LogEvent[];
27
- connected: boolean;
28
- error: string | null;
29
- clear: () => void;
30
- };