@zenera/chat-widget 0.1.4 → 0.1.6
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/README.md +53 -8
- package/dist/catalog-BYJPdVB0.js +358 -0
- package/dist/index-Dw5Lv6cs.js +3151 -0
- package/dist/index.js +22 -14
- package/dist/shadow-CEK6vAGQ.js +4 -0
- package/dist/styles.css +1 -1
- package/dist/types/packages/chat-widget/src/index.d.ts +4 -2
- package/dist/types/packages/chat-widget/src/interceptors.d.ts +50 -0
- package/dist/types/packages/chat-widget/src/reducer.d.ts +14 -0
- package/dist/types/packages/chat-widget/src/transport.d.ts +37 -4
- package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +22 -2
- package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +8 -2
- package/dist/types/packages/chat-widget/src/ui/internal/composerDraft.d.ts +1 -1
- package/dist/types/packages/chat-widget/src/useAttachments.d.ts +32 -0
- package/dist/types/packages/chat-widget/src/useChatThread.d.ts +3 -2
- package/dist/types/packages/chat-widget/src/widget.d.ts +8 -2
- package/dist/types/shared/components/A2uiSurface.d.ts +3 -0
- package/dist/types/shared/components/a2ui/Chart.d.ts +2 -0
- package/dist/types/shared/components/a2ui/ChartView.d.ts +3 -0
- package/dist/types/shared/components/a2ui/DataTable.d.ts +2 -0
- package/dist/types/shared/components/a2ui/Notice.d.ts +6 -0
- package/dist/types/shared/components/a2ui/catalog.d.ts +2 -0
- package/dist/types/shared/components/a2ui/catalogApi.d.ts +16 -0
- package/dist/types/shared/components/a2ui/chartData.d.ts +8 -0
- package/dist/types/shared/components/a2ui/tableData.d.ts +21 -0
- package/dist/types/shared/components/a2ui/useChartPayload.d.ts +9 -0
- package/dist/types/shared/lib/a2ui.d.ts +22 -0
- package/dist/types/shared/lib/a2uiData.d.ts +2 -0
- package/dist/types/shared/lib/a2uiFeed.d.ts +40 -0
- package/dist/types/shared/lib/promptHistory.d.ts +1 -1
- package/dist/ui.js +15 -2822
- package/dist/useThreadList-BbWSgDw_.js +899 -0
- package/dist/widget/chat-widget.iife.js +6179 -88
- package/package.json +7 -9
- package/dist/shadow-BRAwePHz.js +0 -4
- package/dist/useThreadList-Pg29akQ4.js +0 -576
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { basicCatalog } from '@a2ui/web_core/v0_9';
|
|
2
|
+
import type { ComponentApi } from '@a2ui/web_core/v0_9';
|
|
3
|
+
/** An identifier, never fetched. Changing it breaks the agents' validators. */
|
|
4
|
+
export declare const ZENERA_CATALOG_ID = "https://zenera.ai/a2ui/catalogs/zenera/v1/catalog.json";
|
|
5
|
+
/** What an EChart's properties are, once the renderer has checked them against ChartApi. */
|
|
6
|
+
export interface ChartProps {
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const ChartApi: ComponentApi;
|
|
10
|
+
/** What a DataTable's properties are, once checked against TableApi. */
|
|
11
|
+
export interface TableProps {
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const TableApi: ComponentApi;
|
|
16
|
+
export declare const deriveZeneraCatalog: (zenera: ComponentApi[]) => typeof basicCatalog;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A copy of a parsed option without what must not reach echarts: object-internal keys, the keys
|
|
3
|
+
* of OPTION_KEYS, `image://` symbols, a `formatter` with markup (tooltips are HTML), and
|
|
4
|
+
* anything nested deeper than MAX_DEPTH.
|
|
5
|
+
*/
|
|
6
|
+
export declare function clean(value: unknown, depth?: number): unknown;
|
|
7
|
+
/** The option an answer is, cleaned; null when the answer is not an object or has nothing in it. */
|
|
8
|
+
export declare function parseChart(payload: unknown): Record<string, unknown> | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ColumnType = 'string' | 'number' | 'date' | 'boolean';
|
|
2
|
+
export type Cell = string | number | boolean | null;
|
|
3
|
+
export type Row = Record<string, Cell>;
|
|
4
|
+
export interface Column {
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
type: ColumnType;
|
|
8
|
+
sortable: boolean;
|
|
9
|
+
align: 'left' | 'right' | 'center';
|
|
10
|
+
}
|
|
11
|
+
export interface TablePage {
|
|
12
|
+
columns: Column[];
|
|
13
|
+
rows: Row[];
|
|
14
|
+
/** Rows of the whole table, not of this page. */
|
|
15
|
+
total: number;
|
|
16
|
+
}
|
|
17
|
+
/** The page an answer is; null when it is not an object or has no rows and no columns. */
|
|
18
|
+
export declare function parseTable(payload: unknown): TablePage | null;
|
|
19
|
+
export declare function formatCell(value: Cell, type: ColumnType): string;
|
|
20
|
+
/** A copy of `rows` ordered by a column; empty cells come last either way, ties keep their order. */
|
|
21
|
+
export declare function sortRows(rows: Row[], column: Column, direction: 'asc' | 'desc'): Row[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ParsedA2ui {
|
|
2
|
+
messages: Record<string, unknown>[];
|
|
3
|
+
/**
|
|
4
|
+
* The updateComponents message still being written, cut down to the components already
|
|
5
|
+
* complete in it, so a form can appear component by component while its message streams.
|
|
6
|
+
*/
|
|
7
|
+
partial?: Record<string, unknown> & {
|
|
8
|
+
updateComponents: {
|
|
9
|
+
surfaceId: string;
|
|
10
|
+
components: unknown[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** the text cannot be a stream of A2UI messages: the block is not (valid) A2UI */
|
|
14
|
+
broken: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function parseA2ui(code: string): ParsedA2ui;
|
|
17
|
+
/**
|
|
18
|
+
* The ids of the components this one shows inside itself (children, a Card's child, Tabs,
|
|
19
|
+
* a Modal's trigger and content), or null for a leaf such as Text. A container with none
|
|
20
|
+
* of its children available has nothing to show.
|
|
21
|
+
*/
|
|
22
|
+
export declare function childRefs(component: Record<string, unknown>): string[] | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactCatalogComponent } from '@a2ui/react/v0_9';
|
|
2
|
+
import type { SurfaceModel } from '@a2ui/web_core/v0_9';
|
|
3
|
+
import { type ParsedA2ui } from './a2ui.js';
|
|
4
|
+
export type A2uiLib = Awaited<ReturnType<typeof loadA2ui>>;
|
|
5
|
+
export declare const loadA2ui: () => Promise<{
|
|
6
|
+
core: typeof import("@a2ui/web_core/v0_9");
|
|
7
|
+
catalog: (typeof import("../components/a2ui/catalog.js"))["zeneraCatalog"];
|
|
8
|
+
Surface: (typeof import("@a2ui/react/v0_9"))["A2uiSurface"];
|
|
9
|
+
}>;
|
|
10
|
+
export interface FeedState {
|
|
11
|
+
/** the surfaces with something to show: their root component is there */
|
|
12
|
+
surfaces: SurfaceModel<ReactCatalogComponent>[];
|
|
13
|
+
/**
|
|
14
|
+
* ready: there is something to draw; building: nothing yet; rejected: the processor
|
|
15
|
+
* refused what came and there is nothing to draw; deleted: every surface was removed again
|
|
16
|
+
*/
|
|
17
|
+
status: 'ready' | 'building' | 'rejected' | 'deleted';
|
|
18
|
+
}
|
|
19
|
+
export declare class A2uiFeed {
|
|
20
|
+
private lib;
|
|
21
|
+
private processor;
|
|
22
|
+
private code;
|
|
23
|
+
private fed;
|
|
24
|
+
private rejected;
|
|
25
|
+
/** per surface, the components waiting for one of their children */
|
|
26
|
+
private held;
|
|
27
|
+
constructor(lib: A2uiLib);
|
|
28
|
+
/** `parsed` is parseA2ui(code), which the caller already needs. */
|
|
29
|
+
update(code: string, { messages, partial }: ParsedA2ui): FeedState;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
private reset;
|
|
32
|
+
/** Returns the errors the processor reported for the message. */
|
|
33
|
+
private send;
|
|
34
|
+
/**
|
|
35
|
+
* Cuts an updateComponents message down to the components that can be shown: leaves, and
|
|
36
|
+
* containers with a child that is already on the surface or comes with them. The rest wait
|
|
37
|
+
* and are tried again with every later message. Returns null when nothing can be shown yet.
|
|
38
|
+
*/
|
|
39
|
+
private withoutEmptyContainers;
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type KeyboardEvent } from 'react';
|
|
2
|
-
export type HistorySurface = 'chat' | 'test-chat';
|
|
2
|
+
export type HistorySurface = 'chat' | 'test-chat' | 'meta-chat';
|
|
3
3
|
export declare const MAX_ENTRIES = 30;
|
|
4
4
|
export declare const MAX_ENTRY_CHARS = 10000;
|
|
5
5
|
export declare const historyKey: (surface: HistorySurface, userId: string, projectId: string) => string;
|