@alexkroman1/aai-ui 6.11.0 → 7.0.0
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 +104 -3
- package/dist/_run-controls.d.ts +33 -0
- package/dist/{chat-view-ByQFf94G.js → chat-view-BKsFfFZJ.js} +57 -11
- package/dist/client-config-B4nznRvH.js +134 -0
- package/dist/client-config.d.ts +45 -2
- package/dist/client-dir.d.ts +3 -1
- package/dist/client-dir.js +3 -1
- package/dist/components/auto-scroll.d.ts +24 -13
- package/dist/components/button.d.ts +8 -4
- package/dist/components/button.js +4 -4
- package/dist/components/chat-view.d.ts +4 -3
- package/dist/components/chat-view.js +1 -1
- package/dist/components/console-shell.d.ts +71 -10
- package/dist/components/controls.d.ts +15 -4
- package/dist/components/controls.js +48 -2
- package/dist/components/form-fields.d.ts +142 -0
- package/dist/components/form-types.d.ts +6 -0
- package/dist/components/form.d.ts +38 -80
- package/dist/components/markdown.d.ts +31 -5
- package/dist/components/message-list.d.ts +21 -4
- package/dist/components/message-list.js +1 -1
- package/dist/components/sidebar-layout.d.ts +11 -0
- package/dist/components/sidebar-layout.js +2 -0
- package/dist/components/start-screen.d.ts +8 -0
- package/dist/components/start-screen.js +2 -0
- package/dist/components/tool-call-block.js +1 -1
- package/dist/components/tool-call-row.d.ts +24 -0
- package/dist/components/upload-progress.d.ts +17 -7
- package/dist/components/workflow-fields.d.ts +10 -22
- package/dist/components/workflow-progress.d.ts +29 -10
- package/dist/context.d.ts +36 -0
- package/dist/context.js +105 -14
- package/dist/default-client/assets/index-S5fkKi6B.css +2 -0
- package/dist/default-client/assets/index-fEkrcZgo.js +293 -0
- package/dist/default-client/index.html +2 -2
- package/dist/define-client.d.ts +67 -62
- package/dist/define-client.js +56 -22
- package/dist/hooks.d.ts +88 -3
- package/dist/index.d.ts +12 -11
- package/dist/index.js +501 -167
- package/dist/internal.d.ts +40 -0
- package/dist/internal.js +6 -0
- package/dist/{message-list-CpPV7dGx.js → message-list-DHddO4QC.js} +217 -72
- package/dist/{session-core-CAfYmUbg.js → session-core-C2JtLArh.js} +267 -165
- package/dist/session-core-audio-setup.d.ts +3 -0
- package/dist/session-core-messages.d.ts +3 -0
- package/dist/session-core-state.d.ts +146 -0
- package/dist/session-core-types.d.ts +77 -32
- package/dist/session-core.d.ts +3 -2
- package/dist/session-core.js +1 -1
- package/dist/{tool-call-block-D6pTEPrT.js → tool-call-block-DoF-cSIZ.js} +27 -19
- package/dist/tool-config-context-DzAofqi_.js +19 -0
- package/dist/types.d.ts +31 -5
- package/dist/types.js +5 -4
- package/dist/{controls-CjG91QJ4.js → url-chips-DpM7Oocj.js} +3 -46
- package/dist/use-conversation.d.ts +122 -0
- package/dist/use-download-url.d.ts +83 -0
- package/dist/use-workflow-form.d.ts +59 -3
- package/dist/use-workflow-run.d.ts +35 -0
- package/dist/use-workflow-stream.d.ts +36 -62
- package/dist/workflow-client.d.ts +36 -11
- package/dist/workflow-status-labels.d.ts +35 -0
- package/package.json +10 -5
- package/styles.css +14 -0
- package/dist/default-client/assets/index-DTLrhtTF.css +0 -2
- package/dist/default-client/assets/index-DXODx_9r.js +0 -293
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
<title>aai</title>
|
|
7
7
|
<link rel="icon" href="./favicon.ico" />
|
|
8
8
|
<style>html, body { background: #FBF8F2; margin: 0; }</style>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-fEkrcZgo.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/client-audio-constants-Ck0IJO4c.js">
|
|
11
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
11
|
+
<link rel="stylesheet" crossorigin href="./assets/index-S5fkKi6B.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<main id="app"></main>
|
package/dist/define-client.d.ts
CHANGED
|
@@ -4,86 +4,90 @@ import { type ToolDisplayConfig } from "./components/tool-config-context.ts";
|
|
|
4
4
|
import type { SessionCore } from "./session-core-types.ts";
|
|
5
5
|
import type { ClientTheme, VoiceSessionOptions } from "./types.ts";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* component).
|
|
7
|
+
* Configuration passed to {@link client}.
|
|
9
8
|
*
|
|
10
9
|
* The session-forwarded fields are picked from {@link VoiceSessionOptions}
|
|
11
10
|
* (one source of truth for types and docs) rather than re-declared — a
|
|
12
|
-
* re-declared copy is exactly how doc comments drift.
|
|
11
|
+
* re-declared copy is exactly how doc comments drift. It is NOT the session's
|
|
12
|
+
* own options type: that is {@link VoiceSessionOptions}, which
|
|
13
|
+
* `createSessionCore` takes and which three of these fields come from.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* **One flat type, not a union of tiers.** `component` is what decides which
|
|
17
|
+
* shell renders — absent, the default one (StartScreen + ChatView, optional
|
|
18
|
+
* sidebar); present, the caller's own component inside the same providers —
|
|
19
|
+
* and that decision is made at runtime, where every field can be honoured. It
|
|
20
|
+
* used to be a union whose two arms banned each other's fields with `?: never`,
|
|
21
|
+
* and the failure that shape produces is recorded twice in this file's history:
|
|
22
|
+
* `client({ name, component })` and `client({ component, tools })` were both
|
|
23
|
+
* the natural thing to write, both were refused with *"Type 'string' is not
|
|
24
|
+
* assignable to type 'undefined'"*, and both cost a build round each time
|
|
25
|
+
* before the ban was lifted. What was left banned was `sidebar` beside a
|
|
26
|
+
* `component`, which invited the identical failure for a combination
|
|
27
|
+
* {@link client} can simply render.
|
|
13
28
|
*
|
|
14
29
|
* @public
|
|
15
30
|
*/
|
|
16
|
-
export type
|
|
31
|
+
export type ClientConfig = Pick<VoiceSessionOptions, "onSessionId" | "resumeSessionId" | "WebSocket"> & {
|
|
17
32
|
/** CSS selector or DOM element to render into. Defaults to `"#app"`. */
|
|
18
33
|
target?: string | HTMLElement;
|
|
19
34
|
/** Base URL of the AAI platform server. Derived from `location.href` by default. */
|
|
20
35
|
platformUrl?: string;
|
|
21
36
|
/** Theme color overrides. */
|
|
22
37
|
theme?: ClientTheme;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Full custom component to render instead of the default shell.
|
|
40
|
+
*
|
|
41
|
+
* It is rendered inside the same providers the default shell gets, so every
|
|
42
|
+
* session hook, `useTheme` and the tool display config work in it unchanged.
|
|
43
|
+
*/
|
|
44
|
+
component?: ComponentType;
|
|
45
|
+
/**
|
|
46
|
+
* Agent name shown in the header and start screen — and, with a `component`,
|
|
47
|
+
* the page title, there being no shell header to put it in. Left out, the
|
|
48
|
+
* default shell asks the agent for its own declared name.
|
|
49
|
+
*/
|
|
33
50
|
name?: string;
|
|
34
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Optional sidebar component rendered alongside the main pane.
|
|
53
|
+
*
|
|
54
|
+
* Beside a `component` it is the custom component that becomes the main pane,
|
|
55
|
+
* in the same {@link SidebarLayout} the default shell uses.
|
|
56
|
+
*/
|
|
35
57
|
sidebar?: ComponentType;
|
|
36
58
|
/** CSS width of the sidebar. Defaults to `"18rem"`. */
|
|
37
59
|
sidebarWidth?: string;
|
|
38
|
-
/** Tool display config: icon and label overrides keyed by tool name. */
|
|
39
|
-
tools?: ToolDisplayConfig;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Tier 2: custom component — renders the provided `component` inside the
|
|
43
|
-
* providers instead of the default shell.
|
|
44
|
-
*
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
export type ComponentTier = BaseOptions & {
|
|
48
|
-
/** Full custom component to render instead of the default shell. */
|
|
49
|
-
component: ComponentType;
|
|
50
60
|
/**
|
|
51
|
-
*
|
|
52
|
-
* in, so it becomes the page title.
|
|
61
|
+
* Which side the sidebar sits on. Defaults to `"left"`.
|
|
53
62
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* use for the value — a custom-UI page otherwise inherits whatever title
|
|
59
|
-
* the HTML shell shipped with — so it is honoured instead of banned.
|
|
63
|
+
* Routed through the same {@link SidebarLayout} whether the main pane is the
|
|
64
|
+
* default shell or a `component`, for the reason `sidebar` itself is: the two
|
|
65
|
+
* branches build the same layout and a field honoured by only one of them is
|
|
66
|
+
* the shape this config used to have.
|
|
60
67
|
*/
|
|
61
|
-
|
|
62
|
-
sidebar?: never;
|
|
63
|
-
sidebarWidth?: never;
|
|
68
|
+
sidebarPosition?: "left" | "right";
|
|
64
69
|
/**
|
|
65
|
-
*
|
|
70
|
+
* Element rendered in place of the AAI logo — on the start card, and in the
|
|
71
|
+
* shell header once the session begins.
|
|
66
72
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
* Both, because they are one mark: an agent whose start screen shows a slice
|
|
74
|
+
* of pizza and whose header shows our logo reads as two products.
|
|
75
|
+
*/
|
|
76
|
+
icon?: ReactNode;
|
|
77
|
+
/** A line under the title on the start card. */
|
|
78
|
+
subtitle?: string;
|
|
79
|
+
/** Label of the start CTA. Defaults to `"Start Conversation"`. */
|
|
80
|
+
buttonText?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Tool display config: icon and label overrides keyed by tool name.
|
|
71
83
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* the usual way to build one. So the value was always honoured at runtime;
|
|
77
|
-
* only the type refused it.
|
|
84
|
+
* Honoured with a custom `component` too: {@link client} installs it into
|
|
85
|
+
* `ToolConfigContext`, and the consumer is `ToolCallBlock` — which a custom
|
|
86
|
+
* component renders as soon as it uses `MessageList` or `ChatView`, the usual
|
|
87
|
+
* way to build one.
|
|
78
88
|
*/
|
|
79
89
|
tools?: ToolDisplayConfig;
|
|
80
90
|
};
|
|
81
|
-
/**
|
|
82
|
-
* Configuration passed to {@link client}.
|
|
83
|
-
*
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
|
-
export type ClientConfig = ConfigTier | ComponentTier;
|
|
87
91
|
/**
|
|
88
92
|
* Handle returned by {@link client} for cleanup.
|
|
89
93
|
*
|
|
@@ -141,18 +145,19 @@ export declare function mountRoot(container: HTMLElement, node: ReactNode, onDis
|
|
|
141
145
|
/**
|
|
142
146
|
* Define and mount a client UI for a voice agent.
|
|
143
147
|
*
|
|
144
|
-
* **
|
|
145
|
-
*
|
|
148
|
+
* **Config only:** leave `component` out and the default shell renders
|
|
149
|
+
* (StartScreen + ChatView, optional sidebar).
|
|
146
150
|
*
|
|
147
|
-
* **
|
|
148
|
-
*
|
|
149
|
-
*
|
|
151
|
+
* **A custom component:** pass `component` and it is rendered inside the same
|
|
152
|
+
* providers instead of the default shell — beside a `sidebar` if one is given,
|
|
153
|
+
* in the same {@link SidebarLayout}. A provided `name` then also sets
|
|
154
|
+
* `document.title`, there being no shell header to show it in.
|
|
150
155
|
*
|
|
151
156
|
* Mounts into `target` — a CSS selector or DOM element, defaulting to
|
|
152
157
|
* `"#app"` — and throws `Element not found: <target>` when the selector
|
|
153
158
|
* matches nothing.
|
|
154
159
|
*
|
|
155
|
-
* @example
|
|
160
|
+
* @example The default shell
|
|
156
161
|
* ```tsx
|
|
157
162
|
* import { client } from "@alexkroman1/aai-ui";
|
|
158
163
|
*
|
|
@@ -168,7 +173,7 @@ export declare function mountRoot(container: HTMLElement, node: ReactNode, onDis
|
|
|
168
173
|
* });
|
|
169
174
|
* ```
|
|
170
175
|
*
|
|
171
|
-
* @example
|
|
176
|
+
* @example A custom component
|
|
172
177
|
* ```tsx
|
|
173
178
|
* import { client, useSession } from "@alexkroman1/aai-ui";
|
|
174
179
|
*
|
package/dist/define-client.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as fetchClientConfig } from "./client-config-B4nznRvH.js";
|
|
2
2
|
import { SessionProvider, ThemeProvider } from "./context.js";
|
|
3
|
-
import { t as ChatView } from "./chat-view-
|
|
3
|
+
import { t as ChatView } from "./chat-view-BKsFfFZJ.js";
|
|
4
4
|
import { n as setPageTitle, t as pageBaseUrl } from "./_utils-B6498_bm.js";
|
|
5
|
-
import {
|
|
5
|
+
import { t as ToolConfigContext } from "./tool-config-context-DzAofqi_.js";
|
|
6
6
|
import { SidebarLayout } from "./components/sidebar-layout.js";
|
|
7
7
|
import { StartScreen } from "./components/start-screen.js";
|
|
8
|
+
import { t as createSessionCore } from "./session-core-C2JtLArh.js";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
import { createElement, useEffect, useState } from "react";
|
|
10
11
|
import { flushSync } from "react-dom";
|
|
@@ -62,13 +63,20 @@ function mountRoot(container, node, onDispose) {
|
|
|
62
63
|
* Default shell rendered in config tier.
|
|
63
64
|
* Wraps StartScreen → (SidebarLayout →) ChatView.
|
|
64
65
|
*/
|
|
65
|
-
function DefaultShell({ name, Sidebar,
|
|
66
|
-
const chat = /* @__PURE__ */ jsx(ChatView, {
|
|
66
|
+
function DefaultShell({ name, icon, subtitle, buttonText, Sidebar, ...layout }) {
|
|
67
|
+
const chat = /* @__PURE__ */ jsx(ChatView, {
|
|
68
|
+
title: name,
|
|
69
|
+
icon
|
|
70
|
+
});
|
|
67
71
|
return /* @__PURE__ */ jsx(StartScreen, {
|
|
68
72
|
title: name,
|
|
73
|
+
icon,
|
|
74
|
+
subtitle,
|
|
75
|
+
buttonText,
|
|
69
76
|
children: Sidebar ? /* @__PURE__ */ jsx(SidebarLayout, {
|
|
70
77
|
sidebar: /* @__PURE__ */ jsx(Sidebar, {}),
|
|
71
|
-
sidebarWidth,
|
|
78
|
+
sidebarWidth: layout.sidebarWidth,
|
|
79
|
+
sidebarPosition: layout.sidebarPosition,
|
|
72
80
|
children: chat
|
|
73
81
|
}) : chat
|
|
74
82
|
});
|
|
@@ -90,7 +98,8 @@ function DefaultShell({ name, Sidebar, sidebarWidth }) {
|
|
|
90
98
|
* reconnect land on a REPLACEMENT sandbox, so it may not be served from
|
|
91
99
|
* anything this render already has.
|
|
92
100
|
*/
|
|
93
|
-
function DefaultRoot({ platformUrl,
|
|
101
|
+
function DefaultRoot({ platformUrl, ...display }) {
|
|
102
|
+
const { name } = display;
|
|
94
103
|
const [resolved, setResolved] = useState(null);
|
|
95
104
|
const needsLookup = name === void 0;
|
|
96
105
|
useEffect(() => {
|
|
@@ -104,26 +113,56 @@ function DefaultRoot({ platformUrl, name, Sidebar, sidebarWidth }) {
|
|
|
104
113
|
};
|
|
105
114
|
}, [platformUrl, needsLookup]);
|
|
106
115
|
return /* @__PURE__ */ jsx(DefaultShell, {
|
|
107
|
-
|
|
116
|
+
...display,
|
|
117
|
+
name: name ?? resolved?.name
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The tree under the providers: the caller's component, or the default shell.
|
|
122
|
+
*
|
|
123
|
+
* A custom component owns the whole page, so there is no header to hang a
|
|
124
|
+
* `sidebar` off — but the layout the default shell uses is right here, and
|
|
125
|
+
* `client({ component, sidebar })` names one pane and one aside, which is
|
|
126
|
+
* exactly what it renders. Honouring the combination rather than ignoring it is
|
|
127
|
+
* the same call this file already made for `name` and `tools`.
|
|
128
|
+
*/
|
|
129
|
+
function rootFor(config, platformUrl) {
|
|
130
|
+
const Custom = config.component;
|
|
131
|
+
const Sidebar = config.sidebar;
|
|
132
|
+
if (!Custom) return /* @__PURE__ */ jsx(DefaultRoot, {
|
|
133
|
+
platformUrl,
|
|
134
|
+
name: config.name,
|
|
135
|
+
icon: config.icon,
|
|
136
|
+
subtitle: config.subtitle,
|
|
137
|
+
buttonText: config.buttonText,
|
|
108
138
|
Sidebar,
|
|
109
|
-
sidebarWidth
|
|
139
|
+
sidebarWidth: config.sidebarWidth,
|
|
140
|
+
sidebarPosition: config.sidebarPosition
|
|
141
|
+
});
|
|
142
|
+
if (!Sidebar) return /* @__PURE__ */ jsx(Custom, {});
|
|
143
|
+
return /* @__PURE__ */ jsx(SidebarLayout, {
|
|
144
|
+
sidebar: /* @__PURE__ */ jsx(Sidebar, {}),
|
|
145
|
+
sidebarWidth: config.sidebarWidth,
|
|
146
|
+
sidebarPosition: config.sidebarPosition,
|
|
147
|
+
children: /* @__PURE__ */ jsx(Custom, {})
|
|
110
148
|
});
|
|
111
149
|
}
|
|
112
150
|
/**
|
|
113
151
|
* Define and mount a client UI for a voice agent.
|
|
114
152
|
*
|
|
115
|
-
* **
|
|
116
|
-
*
|
|
153
|
+
* **Config only:** leave `component` out and the default shell renders
|
|
154
|
+
* (StartScreen + ChatView, optional sidebar).
|
|
117
155
|
*
|
|
118
|
-
* **
|
|
119
|
-
*
|
|
120
|
-
*
|
|
156
|
+
* **A custom component:** pass `component` and it is rendered inside the same
|
|
157
|
+
* providers instead of the default shell — beside a `sidebar` if one is given,
|
|
158
|
+
* in the same {@link SidebarLayout}. A provided `name` then also sets
|
|
159
|
+
* `document.title`, there being no shell header to show it in.
|
|
121
160
|
*
|
|
122
161
|
* Mounts into `target` — a CSS selector or DOM element, defaulting to
|
|
123
162
|
* `"#app"` — and throws `Element not found: <target>` when the selector
|
|
124
163
|
* matches nothing.
|
|
125
164
|
*
|
|
126
|
-
* @example
|
|
165
|
+
* @example The default shell
|
|
127
166
|
* ```tsx
|
|
128
167
|
* import { client } from "@alexkroman1/aai-ui";
|
|
129
168
|
*
|
|
@@ -139,7 +178,7 @@ function DefaultRoot({ platformUrl, name, Sidebar, sidebarWidth }) {
|
|
|
139
178
|
* });
|
|
140
179
|
* ```
|
|
141
180
|
*
|
|
142
|
-
* @example
|
|
181
|
+
* @example A custom component
|
|
143
182
|
* ```tsx
|
|
144
183
|
* import { client, useSession } from "@alexkroman1/aai-ui";
|
|
145
184
|
*
|
|
@@ -166,12 +205,7 @@ function client(config) {
|
|
|
166
205
|
WebSocket: config.WebSocket
|
|
167
206
|
});
|
|
168
207
|
setPageTitle(config.name);
|
|
169
|
-
const rootNode =
|
|
170
|
-
platformUrl,
|
|
171
|
-
name: config.name,
|
|
172
|
-
Sidebar: config.sidebar,
|
|
173
|
-
sidebarWidth: config.sidebarWidth
|
|
174
|
-
});
|
|
208
|
+
const rootNode = rootFor(config, platformUrl);
|
|
175
209
|
const toolConfig = config.tools ?? {};
|
|
176
210
|
return {
|
|
177
211
|
session,
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,18 +1,65 @@
|
|
|
1
1
|
import type { DefaultToolResult, StateProjection } from "@alexkroman1/aai";
|
|
2
2
|
import type { ToolCallInfo } from "./types.ts";
|
|
3
3
|
/**
|
|
4
|
-
* Fire a callback when
|
|
4
|
+
* Fire a callback when ONE named tool settles, with its parsed JSON result.
|
|
5
5
|
*
|
|
6
6
|
* For new code prefer explicit events — `ctx.send(event, data)` in the tool
|
|
7
7
|
* paired with {@link useEvent} here — over listening to tool results.
|
|
8
8
|
*
|
|
9
|
+
* A component that mounts late still receives the results of calls that
|
|
10
|
+
* already completed, because a result is a value the UI is driven from rather
|
|
11
|
+
* than a moment. Each call fires exactly once per hook instance.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { useState } from "react";
|
|
16
|
+
* import { useToolResult } from "@alexkroman1/aai-ui";
|
|
17
|
+
*
|
|
18
|
+
* type Quote = { symbol: string; price: number };
|
|
19
|
+
*
|
|
20
|
+
* function QuoteCard() {
|
|
21
|
+
* const [quote, setQuote] = useState<Quote>();
|
|
22
|
+
* useToolResult<Quote>("get_quote", (result) => setQuote(result));
|
|
23
|
+
* return quote ? <p>{quote.symbol}: {quote.price}</p> : null;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
9
27
|
* @typeParam R - The result shape. Defaults to {@link DefaultToolResult}
|
|
10
28
|
* (`any`) so the ordinary untyped spelling compiles; pass the shape —
|
|
11
29
|
* `useToolResult<Quote>(…)` — for real checking.
|
|
30
|
+
* @param toolName - Only calls of this tool fire the callback.
|
|
31
|
+
* @param callback - Called with the parsed result and the call itself.
|
|
12
32
|
*
|
|
13
33
|
* @public
|
|
14
34
|
*/
|
|
15
35
|
export declare function useToolResult<R = DefaultToolResult>(toolName: string, callback: (result: R, toolCall: ToolCallInfo) => void): void;
|
|
36
|
+
/**
|
|
37
|
+
* Fire a callback when ANY tool call settles — the tool's name is the
|
|
38
|
+
* callback's first argument.
|
|
39
|
+
*
|
|
40
|
+
* The unfiltered form, for a chrome rendering a log of everything the agent
|
|
41
|
+
* did rather than reacting to one tool.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* import { useState } from "react";
|
|
46
|
+
* import { useToolResult } from "@alexkroman1/aai-ui";
|
|
47
|
+
*
|
|
48
|
+
* function ToolLog() {
|
|
49
|
+
* const [lines, setLines] = useState<string[]>([]);
|
|
50
|
+
* useToolResult((name, result) => {
|
|
51
|
+
* setLines((prev) => [...prev, `${name}: ${JSON.stringify(result)}`]);
|
|
52
|
+
* });
|
|
53
|
+
* return <pre>{lines.join("\n")}</pre>;
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @typeParam R - The result shape. Defaults to {@link DefaultToolResult}.
|
|
58
|
+
* @param callback - Called with the tool's name, the parsed result, and the
|
|
59
|
+
* call itself.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
16
63
|
export declare function useToolResult<R = DefaultToolResult>(callback: (name: string, result: R, toolCall: ToolCallInfo) => void): void;
|
|
17
64
|
/**
|
|
18
65
|
* The agent's projected session state, or `null` before the first push.
|
|
@@ -133,10 +180,48 @@ export declare function useAgentState<S = DefaultToolResult>(fallback: S): S;
|
|
|
133
180
|
*/
|
|
134
181
|
export declare function useEvent<T = unknown>(event: string, callback: (data: T) => void): void;
|
|
135
182
|
/**
|
|
136
|
-
* Fire a callback when
|
|
137
|
-
*
|
|
183
|
+
* Fire a callback when ONE named tool starts, before its result arrives.
|
|
184
|
+
*
|
|
185
|
+
* A start is a MOMENT rather than a value, so unlike {@link useToolResult}
|
|
186
|
+
* this never replays: a component that mounts mid-session learns nothing about
|
|
187
|
+
* calls that started before it.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* import { useState } from "react";
|
|
192
|
+
* import { useToolCallStart } from "@alexkroman1/aai-ui";
|
|
193
|
+
*
|
|
194
|
+
* function Searching() {
|
|
195
|
+
* const [busy, setBusy] = useState(false);
|
|
196
|
+
* useToolCallStart("search_catalog", () => setBusy(true));
|
|
197
|
+
* return busy ? <p>Searching the catalog…</p> : null;
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @param toolName - Only calls of this tool fire the callback.
|
|
202
|
+
* @param callback - Called with the pending call.
|
|
138
203
|
*
|
|
139
204
|
* @public
|
|
140
205
|
*/
|
|
141
206
|
export declare function useToolCallStart(toolName: string, callback: (toolCall: ToolCallInfo) => void): void;
|
|
207
|
+
/**
|
|
208
|
+
* Fire a callback when ANY tool call starts — read the tool's name off the
|
|
209
|
+
* call itself (`toolCall.name`).
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* import { useState } from "react";
|
|
214
|
+
* import { useToolCallStart } from "@alexkroman1/aai-ui";
|
|
215
|
+
*
|
|
216
|
+
* function Activity() {
|
|
217
|
+
* const [now, setNow] = useState<string>();
|
|
218
|
+
* useToolCallStart((toolCall) => setNow(toolCall.name));
|
|
219
|
+
* return now ? <p>Running {now}…</p> : null;
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @param callback - Called with the pending call.
|
|
224
|
+
*
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
142
227
|
export declare function useToolCallStart(callback: (toolCall: ToolCallInfo) => void): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { type ClientConfigResponse, fetchClientConfig, } from "./client-config.ts";
|
|
2
2
|
export { AutoScroll } from "./components/auto-scroll.tsx";
|
|
3
3
|
export { Button, type ButtonSize, type ButtonVariant } from "./components/button.tsx";
|
|
4
4
|
export { ChatView } from "./components/chat-view.tsx";
|
|
5
|
-
export {
|
|
5
|
+
export { ConsoleShell, type ConsoleShellProps } from "./components/console-shell.tsx";
|
|
6
|
+
export { Controls, type ControlsProps } from "./components/controls.tsx";
|
|
6
7
|
export { CheckboxField, Field, type FieldShell, FileField, type FileRead, type FileValue, Form, type FormProps, type FormValues, NumberField, SelectField, SubmitButton, TextAreaField, TextField, } from "./components/form.tsx";
|
|
7
|
-
export { Markdown, type MarkdownVariant } from "./components/markdown.tsx";
|
|
8
|
-
export { MessageList } from "./components/message-list.tsx";
|
|
8
|
+
export { Markdown, type MarkdownProps, type MarkdownVariant } from "./components/markdown.tsx";
|
|
9
|
+
export { MessageList, type MessageListProps } from "./components/message-list.tsx";
|
|
9
10
|
export { SidebarLayout } from "./components/sidebar-layout.tsx";
|
|
10
11
|
export { StartScreen } from "./components/start-screen.tsx";
|
|
11
12
|
export { ToolCallRow, type ToolCallRowProps, type ToolCallRowVariant, } from "./components/tool-call-row.tsx";
|
|
12
13
|
export type { ToolDisplayConfig } from "./components/tool-config-context.ts";
|
|
13
|
-
export { ToolConfigContext } from "./components/tool-config-context.ts";
|
|
14
14
|
export { UploadProgressBar } from "./components/upload-progress.tsx";
|
|
15
|
-
export { ApiUrlChip, SessionUrlChips, UiUrlChip } from "./components/url-chips.tsx";
|
|
16
15
|
export { WorkflowFields } from "./components/workflow-fields.tsx";
|
|
17
16
|
export { WorkflowProgress } from "./components/workflow-progress.tsx";
|
|
18
17
|
export type { Session } from "./context.ts";
|
|
19
|
-
export {
|
|
20
|
-
export type {
|
|
18
|
+
export { useSession, useSessionSelector, useTheme } from "./context.ts";
|
|
19
|
+
export type { ClientConfig, ClientHandle } from "./define-client.tsx";
|
|
21
20
|
export { client } from "./define-client.tsx";
|
|
22
21
|
export { useAgentState, useEvent, useToolCallStart, useToolResult } from "./hooks.ts";
|
|
23
22
|
export { type PageConfig, type PageHandle, page } from "./page.tsx";
|
|
24
23
|
export { createSessionCore } from "./session-core.ts";
|
|
25
|
-
export type { AgentCustomEvent, SessionCore,
|
|
24
|
+
export type { AgentCustomEvent, SessionCore, SessionSnapshot, } from "./session-core-types.ts";
|
|
26
25
|
export type { AgentState, ChatMessage, ClientTheme, SessionError, SessionErrorCode, ToolCallInfo, VoiceSessionOptions, WebSocketConstructor, } from "./types.ts";
|
|
27
|
-
export {
|
|
26
|
+
export { type ConversationItem, type UseConversationResult, useConversation, } from "./use-conversation.ts";
|
|
27
|
+
export { type UseDownloadUrlOptions, type UseDownloadUrlResult, useDownloadUrl, } from "./use-download-url.ts";
|
|
28
28
|
export { TRANSCRIBING_PLACEHOLDER, type UseUserTranscriptResult, useUserTranscript, } from "./use-user-transcript.ts";
|
|
29
29
|
export { type UploadStatus, type UseWorkflowSubmitOptions, type UseWorkflowsOptions, type UseWorkflowsResult, useWorkflowSubmit, useWorkflows, type WorkflowSubmission, } from "./use-workflow-form.ts";
|
|
30
30
|
export { DEFAULT_PROGRESS_POLL_MS, type UseWorkflowProgressResult, useWorkflowProgress, } from "./use-workflow-progress.ts";
|
|
31
31
|
export { DEFAULT_WORKFLOW_POLL_MS, MAX_MISSING_READS, type UseWorkflowRunResult, useWorkflowRun, } from "./use-workflow-run.ts";
|
|
32
32
|
export { type UseWorkflowRunsOptions, type UseWorkflowRunsResult, useWorkflowRuns, } from "./use-workflow-runs.ts";
|
|
33
33
|
export { type UseWorkflowStreamOptions, useWorkflowStream, type WorkflowStreamSubmission, } from "./use-workflow-stream.ts";
|
|
34
|
-
export { createWorkflowApi, isTerminal, type WorkflowApi, type WorkflowApiOptions, type WorkflowOutputOf, type WorkflowRun, type WorkflowSummary, } from "./workflow-client.ts";
|
|
34
|
+
export { createWorkflowApi, isTerminal, type WorkflowApi, type WorkflowApiOptions, type WorkflowOutputOf, type WorkflowRun, type WorkflowRunStatus, type WorkflowSummary, } from "./workflow-client.ts";
|
|
35
|
+
export { WORKFLOW_STATUS_LABELS } from "./workflow-status-labels.ts";
|