@alexkroman1/aai-ui 0.12.2 → 0.13.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.
Files changed (215) hide show
  1. package/README.md +257 -0
  2. package/dist/_colors-CpZO-88A.js +78 -0
  3. package/dist/_module-url-C13kAJ87.js +15 -0
  4. package/dist/_page-shell.d.ts +11 -0
  5. package/dist/_recover-run.d.ts +79 -0
  6. package/dist/_repeat-until.d.ts +30 -0
  7. package/dist/_run-controls.d.ts +33 -0
  8. package/dist/_submission-state.d.ts +92 -0
  9. package/dist/_tap-to-talk-state.d.ts +88 -0
  10. package/dist/_utils-Mi-SCFA1.js +47 -0
  11. package/dist/_utils.d.ts +26 -0
  12. package/dist/_web-storage.d.ts +43 -0
  13. package/dist/_workflow-api-ref.d.ts +37 -0
  14. package/dist/_workflow-files.d.ts +34 -0
  15. package/dist/_workflow-test-defs.d.ts +38 -0
  16. package/dist/aai-logo-D8pMVn9_.js +85 -0
  17. package/dist/agent-state-labels.d.ts +65 -0
  18. package/dist/agent-state.d.ts +108 -0
  19. package/dist/audio/capture.d.ts +44 -0
  20. package/dist/audio/index.d.ts +18 -0
  21. package/dist/audio/index.js +431 -0
  22. package/dist/audio/preconnect.d.ts +87 -0
  23. package/dist/audio/voice-io.d.ts +112 -0
  24. package/dist/build-default-client.d.ts +1 -0
  25. package/dist/chat-view-BCbI7gD4.js +396 -0
  26. package/dist/client-config-C7fQrioM.js +139 -0
  27. package/dist/client-config.d.ts +119 -0
  28. package/dist/client-dir.d.ts +44 -0
  29. package/dist/client-dir.js +58 -0
  30. package/dist/client-identity.d.ts +131 -0
  31. package/dist/client-tool.d.ts +51 -0
  32. package/dist/components/_colors.d.ts +73 -0
  33. package/dist/components/_form-readiness.d.ts +56 -0
  34. package/dist/components/_form-values.d.ts +19 -0
  35. package/dist/components/aai-logo.d.ts +12 -0
  36. package/dist/components/audio-result.d.ts +94 -0
  37. package/dist/components/auto-scroll.d.ts +74 -0
  38. package/dist/components/bullet-list.d.ts +74 -0
  39. package/dist/components/button.d.ts +58 -0
  40. package/dist/components/button.js +85 -0
  41. package/dist/components/chat-view.d.ts +35 -0
  42. package/dist/components/chat-view.js +3 -0
  43. package/dist/components/console-shell.d.ts +85 -0
  44. package/dist/components/controls.d.ts +33 -0
  45. package/dist/components/controls.js +49 -0
  46. package/dist/components/conversation-view.d.ts +130 -0
  47. package/dist/components/eyebrow.d.ts +12 -0
  48. package/dist/components/facts.d.ts +81 -0
  49. package/dist/components/form-fields.d.ts +142 -0
  50. package/dist/components/form-types.d.ts +73 -0
  51. package/dist/components/form.d.ts +96 -0
  52. package/dist/components/markdown.d.ts +57 -0
  53. package/dist/components/message-list.d.ts +48 -0
  54. package/dist/components/message-list.js +3 -0
  55. package/dist/components/session-controls.d.ts +125 -0
  56. package/dist/components/session-error-banner.d.ts +69 -0
  57. package/dist/components/session-state-dot.d.ts +111 -0
  58. package/dist/components/sidebar-layout.d.ts +42 -0
  59. package/dist/components/sidebar-layout.js +56 -0
  60. package/dist/components/start-screen.d.ts +37 -0
  61. package/dist/components/start-screen.js +71 -0
  62. package/dist/components/tool-call-block.d.ts +28 -0
  63. package/dist/components/tool-call-block.js +3 -0
  64. package/dist/components/tool-call-row.d.ts +75 -0
  65. package/dist/components/tool-config-context.d.ts +22 -0
  66. package/dist/components/upload-progress.d.ts +76 -0
  67. package/dist/components/url-chips.d.ts +29 -0
  68. package/dist/components/workflow-fields.d.ts +46 -0
  69. package/dist/components/workflow-pending-note.d.ts +81 -0
  70. package/dist/components/workflow-progress.d.ts +81 -0
  71. package/dist/components/workflow-run-error.d.ts +48 -0
  72. package/dist/components/workflow-run-panel.d.ts +79 -0
  73. package/dist/context.d.ts +288 -0
  74. package/dist/context.js +382 -0
  75. package/dist/conversation-log.d.ts +88 -0
  76. package/dist/default-client/assets/_module-url-BX0RuRU2.js +1 -0
  77. package/dist/default-client/assets/audio-cGFGID-2.js +1 -0
  78. package/dist/default-client/assets/capture-processor-BUABoo3_.js +90 -0
  79. package/dist/default-client/assets/index-8ihb1Urm.css +2 -0
  80. package/dist/default-client/assets/index-BQURVARl.js +126 -0
  81. package/dist/default-client/assets/playback-processor-ABOa11j0.js +314 -0
  82. package/dist/default-client/favicon.ico +0 -0
  83. package/dist/default-client/index.html +15 -0
  84. package/dist/default-client.d.ts +23 -0
  85. package/dist/define-client.d.ts +162 -26
  86. package/dist/define-client.js +201 -55
  87. package/dist/eyebrow-UfmSz9yy.js +27 -0
  88. package/dist/hooks-DN4gHYsj.js +182 -0
  89. package/dist/hooks.d.ts +172 -0
  90. package/dist/hooks.js +3 -0
  91. package/dist/hooks.test-d.d.ts +14 -0
  92. package/dist/inbox-protocol.d.ts +128 -0
  93. package/dist/inbox.d.ts +132 -0
  94. package/dist/index.d.ts +129 -32
  95. package/dist/index.js +5503 -18
  96. package/dist/internal.d.ts +43 -0
  97. package/dist/internal.js +8 -0
  98. package/dist/linked-client.d.ts +70 -0
  99. package/dist/message-list-DHZcLhRA.js +682 -0
  100. package/dist/notice-player.d.ts +70 -0
  101. package/dist/page.d.ts +114 -0
  102. package/dist/phone.d.ts +50 -0
  103. package/dist/route-fetch.d.ts +79 -0
  104. package/dist/session/audio-effects.d.ts +31 -0
  105. package/dist/session/audio-setup.d.ts +57 -0
  106. package/dist/session/audio-state.d.ts +157 -0
  107. package/dist/session/browser-session.d.ts +30 -0
  108. package/dist/session/close.d.ts +26 -0
  109. package/dist/session/dial.d.ts +65 -0
  110. package/dist/session/handshake.d.ts +60 -0
  111. package/dist/session/index.d.ts +17 -0
  112. package/dist/session/index.js +2 -0
  113. package/dist/session/messages.d.ts +63 -0
  114. package/dist/session/mic.d.ts +64 -0
  115. package/dist/session/preconnect.d.ts +48 -0
  116. package/dist/session/reconnect.d.ts +25 -0
  117. package/dist/session/resume-store.d.ts +57 -0
  118. package/dist/session/state.d.ts +146 -0
  119. package/dist/session/ticket.d.ts +44 -0
  120. package/dist/session/types.d.ts +476 -0
  121. package/dist/session/url.d.ts +17 -0
  122. package/dist/session/user-turn.d.ts +55 -0
  123. package/dist/session-CE0Ipsb3.js +2129 -0
  124. package/dist/stored-value.d.ts +103 -0
  125. package/dist/tool-call-block-uXtMOUWN.js +204 -0
  126. package/dist/tool-config-context-Es4YUzV2.js +19 -0
  127. package/dist/types.d.ts +272 -34
  128. package/dist/types.js +35 -4
  129. package/dist/upload/files.d.ts +83 -0
  130. package/dist/upload/index.d.ts +15 -0
  131. package/dist/upload/pause.d.ts +31 -0
  132. package/dist/upload/recall.d.ts +67 -0
  133. package/dist/upload/report.d.ts +26 -0
  134. package/dist/upload/session.d.ts +99 -0
  135. package/dist/url-chips-oyy_Eiqh.js +239 -0
  136. package/dist/use-client-runs.d.ts +87 -0
  137. package/dist/use-conversation-log.d.ts +86 -0
  138. package/dist/use-conversation.d.ts +131 -0
  139. package/dist/use-copy.d.ts +74 -0
  140. package/dist/use-download-url.d.ts +84 -0
  141. package/dist/use-flash.d.ts +61 -0
  142. package/dist/use-inbox.d.ts +101 -0
  143. package/dist/use-push-to-talk.d.ts +105 -0
  144. package/dist/use-route-mutation.d.ts +113 -0
  145. package/dist/use-route.d.ts +82 -0
  146. package/dist/use-run-key.d.ts +133 -0
  147. package/dist/use-session-controls.d.ts +69 -0
  148. package/dist/use-session-id.d.ts +57 -0
  149. package/dist/use-tap-to-talk.d.ts +138 -0
  150. package/dist/use-user-transcript-uyHhzy4d.js +73 -0
  151. package/dist/use-user-transcript.d.ts +75 -0
  152. package/dist/use-workflow-form.d.ts +285 -0
  153. package/dist/use-workflow-progress.d.ts +137 -0
  154. package/dist/use-workflow-run-DdhWmbx-.js +697 -0
  155. package/dist/use-workflow-run.d.ts +100 -0
  156. package/dist/use-workflow-runs.d.ts +71 -0
  157. package/dist/use-workflow-stream.d.ts +154 -0
  158. package/dist/use-workflows.d.ts +77 -0
  159. package/dist/workflow-client.d.ts +136 -0
  160. package/dist/workflow-def-types.d.ts +31 -0
  161. package/dist/workflow-events.d.ts +39 -0
  162. package/dist/workflow-field-kind.d.ts +95 -0
  163. package/dist/workflow-status-labels.d.ts +35 -0
  164. package/dist/worklets/_module-url.d.ts +10 -0
  165. package/dist/worklets/_playback-bench-harness.d.ts +181 -0
  166. package/dist/worklets/_playback-bench-host.d.ts +63 -0
  167. package/dist/worklets/_playback-bench-page.d.ts +65 -0
  168. package/dist/worklets/_tts-trace-harness.d.ts +142 -0
  169. package/dist/worklets/_worklet-test-utils.d.ts +27 -0
  170. package/dist/worklets/capture-processor.d.ts +4 -2
  171. package/dist/worklets/capture-processor.js +73 -33
  172. package/dist/worklets/playback-processor.d.ts +4 -2
  173. package/dist/worklets/playback-processor.js +258 -42
  174. package/package.json +58 -31
  175. package/styles.css +152 -30
  176. package/dist/_components/app.d.ts +0 -23
  177. package/dist/_components/app.js +0 -41
  178. package/dist/_components/button.d.ts +0 -50
  179. package/dist/_components/button.js +0 -46
  180. package/dist/_components/chat-view.d.ts +0 -29
  181. package/dist/_components/chat-view.js +0 -61
  182. package/dist/_components/controls.d.ts +0 -18
  183. package/dist/_components/controls.js +0 -37
  184. package/dist/_components/error-banner.d.ts +0 -21
  185. package/dist/_components/error-banner.js +0 -27
  186. package/dist/_components/message-bubble.d.ts +0 -23
  187. package/dist/_components/message-bubble.js +0 -35
  188. package/dist/_components/message-list.d.ts +0 -21
  189. package/dist/_components/message-list.js +0 -76
  190. package/dist/_components/sidebar-layout.d.ts +0 -21
  191. package/dist/_components/sidebar-layout.js +0 -36
  192. package/dist/_components/start-screen.d.ts +0 -26
  193. package/dist/_components/start-screen.js +0 -51
  194. package/dist/_components/state-indicator.d.ts +0 -29
  195. package/dist/_components/state-indicator.js +0 -37
  196. package/dist/_components/thinking-indicator.d.ts +0 -16
  197. package/dist/_components/thinking-indicator.js +0 -34
  198. package/dist/_components/tool-call-block.d.ts +0 -27
  199. package/dist/_components/tool-call-block.js +0 -118
  200. package/dist/_components/tool-icons.d.ts +0 -17
  201. package/dist/_components/tool-icons.js +0 -128
  202. package/dist/_components/transcript.d.ts +0 -25
  203. package/dist/_components/transcript.js +0 -35
  204. package/dist/audio.d.ts +0 -45
  205. package/dist/audio.js +0 -121
  206. package/dist/client-context.d.ts +0 -33
  207. package/dist/client-context.js +0 -15
  208. package/dist/client-handler.d.ts +0 -43
  209. package/dist/session-CWB7vmqz.js +0 -429
  210. package/dist/session.d.ts +0 -69
  211. package/dist/session.js +0 -2
  212. package/dist/signals.d.ts +0 -120
  213. package/dist/signals.js +0 -161
  214. package/dist/tsdown.config.d.ts +0 -2
  215. package/dist/types.test-d.d.ts +0 -7
@@ -1,76 +0,0 @@
1
- import { useAutoScroll, useSession } from "../signals.js";
2
- import { MessageBubble } from "./message-bubble.js";
3
- import { ThinkingIndicator } from "./thinking-indicator.js";
4
- import { ToolCallBlock } from "./tool-call-block.js";
5
- import { Transcript } from "./transcript.js";
6
- import clsx from "clsx";
7
- import { useComputed } from "@preact/signals";
8
- import { jsx, jsxs } from "preact/jsx-runtime";
9
- //#region _components/message-list.tsx
10
- /**
11
- * Scrollable list of all chat messages, tool-call blocks, live transcript,
12
- * streaming agent utterance, and a thinking indicator.
13
- *
14
- * Messages and tool calls are interleaved in the correct order. The list
15
- * auto-scrolls to the latest content via {@link useAutoScroll}.
16
- *
17
- * Must be rendered inside a {@link SessionProvider}.
18
- *
19
- * @example
20
- * ```tsx
21
- * <MessageList className="flex-1" />
22
- * ```
23
- *
24
- * @param className - Additional CSS class names applied to the scroll container.
25
- *
26
- * @public
27
- */
28
- function MessageList({ className }) {
29
- const { session } = useSession();
30
- const scrollRef = useAutoScroll();
31
- const showThinking = useComputed(() => {
32
- if (session.state.value !== "thinking") return false;
33
- const last = session.toolCalls.value.at(-1);
34
- if (last?.status === "pending") return false;
35
- const lastMsg = session.messages.value.at(-1);
36
- return !lastMsg || lastMsg.role === "user" || Boolean(last);
37
- });
38
- const messages = session.messages.value;
39
- const toolCalls = session.toolCalls.value;
40
- const items = [];
41
- let tci = 0;
42
- for (const [i, msg] of messages.entries()) {
43
- items.push(/* @__PURE__ */ jsx(MessageBubble, { message: msg }, `msg-${i}`));
44
- let tc = toolCalls[tci];
45
- while (tc && tc.afterMessageIndex <= i) {
46
- items.push(/* @__PURE__ */ jsx(ToolCallBlock, { toolCall: tc }, tc.toolCallId));
47
- tci++;
48
- tc = toolCalls[tci];
49
- }
50
- }
51
- let tc = toolCalls[tci];
52
- while (tc) {
53
- items.push(/* @__PURE__ */ jsx(ToolCallBlock, { toolCall: tc }, tc.toolCallId));
54
- tci++;
55
- tc = toolCalls[tci];
56
- }
57
- return /* @__PURE__ */ jsx("div", {
58
- role: "log",
59
- class: clsx("flex-1 overflow-y-auto [scrollbar-width:none] bg-aai-surface", className),
60
- children: /* @__PURE__ */ jsxs("div", {
61
- class: "flex flex-col gap-4.5 p-4",
62
- children: [
63
- items,
64
- session.agentUtterance.value && /* @__PURE__ */ jsx(MessageBubble, { message: {
65
- role: "assistant",
66
- content: session.agentUtterance.value
67
- } }),
68
- /* @__PURE__ */ jsx(Transcript, { userUtterance: session.userUtterance }),
69
- showThinking.value && /* @__PURE__ */ jsx(ThinkingIndicator, {}),
70
- /* @__PURE__ */ jsx("div", { ref: scrollRef })
71
- ]
72
- })
73
- });
74
- }
75
- //#endregion
76
- export { MessageList };
@@ -1,21 +0,0 @@
1
- import type { ComponentChildren } from "preact";
2
- /**
3
- * A two-column layout with a fixed-width sidebar and a flexible main area.
4
- * Commonly used to pair a custom sidebar (cart, dashboard) with `<ChatView />`.
5
- *
6
- * @example
7
- * ```tsx
8
- * <SidebarLayout sidebar={<OrderPanel />}>
9
- * <ChatView />
10
- * </SidebarLayout>
11
- * ```
12
- *
13
- * @public
14
- */
15
- export declare function SidebarLayout({ sidebar, children, width, side, className, }: {
16
- sidebar: ComponentChildren;
17
- children: ComponentChildren;
18
- width?: string | undefined;
19
- side?: "left" | "right" | undefined;
20
- className?: string;
21
- }): import("preact").JSX.Element;
@@ -1,36 +0,0 @@
1
- import clsx from "clsx";
2
- import { jsx, jsxs } from "preact/jsx-runtime";
3
- //#region _components/sidebar-layout.tsx
4
- /**
5
- * A two-column layout with a fixed-width sidebar and a flexible main area.
6
- * Commonly used to pair a custom sidebar (cart, dashboard) with `<ChatView />`.
7
- *
8
- * @example
9
- * ```tsx
10
- * <SidebarLayout sidebar={<OrderPanel />}>
11
- * <ChatView />
12
- * </SidebarLayout>
13
- * ```
14
- *
15
- * @public
16
- */
17
- function SidebarLayout({ sidebar, children, width = "20rem", side = "left", className }) {
18
- const sidebarEl = /* @__PURE__ */ jsx("div", {
19
- class: clsx("flex-shrink-0 flex flex-col overflow-y-auto", side === "left" ? "border-r border-aai-border" : "border-l border-aai-border"),
20
- style: { width },
21
- children: sidebar
22
- });
23
- return /* @__PURE__ */ jsxs("div", {
24
- class: clsx("flex h-screen bg-aai-bg", className),
25
- children: [
26
- side === "left" && sidebarEl,
27
- /* @__PURE__ */ jsx("div", {
28
- class: "flex-1 min-w-0",
29
- children
30
- }),
31
- side === "right" && sidebarEl
32
- ]
33
- });
34
- }
35
- //#endregion
36
- export { SidebarLayout };
@@ -1,26 +0,0 @@
1
- import type { ComponentChildren } from "preact";
2
- /**
3
- * A centered start screen with icon, title, subtitle, and a start button.
4
- * Renders `children` (the main app) once the session has started.
5
- *
6
- * @example
7
- * ```tsx
8
- * function MyAgent() {
9
- * return (
10
- * <StartScreen icon="🍕" title="Pizza Palace" subtitle="Voice-powered ordering">
11
- * <ChatView />
12
- * </StartScreen>
13
- * );
14
- * }
15
- * ```
16
- *
17
- * @public
18
- */
19
- export declare function StartScreen({ children, icon, title, subtitle, buttonText, className, }: {
20
- children: ComponentChildren;
21
- icon?: ComponentChildren | undefined;
22
- title?: string | undefined;
23
- subtitle?: string | undefined;
24
- buttonText?: string | undefined;
25
- className?: string | undefined;
26
- }): import("preact").JSX.Element;
@@ -1,51 +0,0 @@
1
- import { useSession } from "../signals.js";
2
- import { Button } from "./button.js";
3
- import clsx from "clsx";
4
- import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
5
- //#region _components/start-screen.tsx
6
- /**
7
- * A centered start screen with icon, title, subtitle, and a start button.
8
- * Renders `children` (the main app) once the session has started.
9
- *
10
- * @example
11
- * ```tsx
12
- * function MyAgent() {
13
- * return (
14
- * <StartScreen icon="🍕" title="Pizza Palace" subtitle="Voice-powered ordering">
15
- * <ChatView />
16
- * </StartScreen>
17
- * );
18
- * }
19
- * ```
20
- *
21
- * @public
22
- */
23
- function StartScreen({ children, icon, title, subtitle, buttonText = "Start", className }) {
24
- const { started, start } = useSession();
25
- if (started.value) return /* @__PURE__ */ jsx(Fragment, { children });
26
- return /* @__PURE__ */ jsx("div", {
27
- class: clsx("flex items-center justify-center h-screen bg-aai-bg font-aai", className),
28
- children: /* @__PURE__ */ jsxs("div", {
29
- class: "flex flex-col items-center gap-4 bg-aai-surface border border-aai-border rounded-lg px-12 py-10 max-w-sm text-center",
30
- children: [
31
- icon,
32
- title && /* @__PURE__ */ jsx("h1", {
33
- class: "font-semibold text-aai-primary m-0",
34
- children: title
35
- }),
36
- subtitle && /* @__PURE__ */ jsx("p", {
37
- class: "text-sm text-aai-text-muted m-0",
38
- children: subtitle
39
- }),
40
- /* @__PURE__ */ jsx(Button, {
41
- size: "lg",
42
- className: "mt-2 w-full",
43
- onClick: start,
44
- children: buttonText
45
- })
46
- ]
47
- })
48
- });
49
- }
50
- //#endregion
51
- export { StartScreen };
@@ -1,29 +0,0 @@
1
- import type * as preact from "preact";
2
- import type { AgentState, Reactive } from "../types.ts";
3
- /**
4
- * Colored dot + label showing the current {@link AgentState}.
5
- *
6
- * State-to-color mapping:
7
- * - `disconnected` — gray
8
- * - `connecting` — yellow
9
- * - `ready` — green
10
- * - `listening` — blue
11
- * - `thinking` — purple
12
- * - `speaking` — red
13
- * - `error` — red
14
- *
15
- * @example
16
- * ```tsx
17
- * const { session } = useSession();
18
- * <StateIndicator state={session.state} />
19
- * ```
20
- *
21
- * @param state - A reactive {@link AgentState} value.
22
- * @param className - Additional CSS class names.
23
- *
24
- * @public
25
- */
26
- export declare function StateIndicator({ state, className, }: {
27
- state: Reactive<AgentState>;
28
- className?: string;
29
- }): preact.JSX.Element;
@@ -1,37 +0,0 @@
1
- import clsx from "clsx";
2
- import { jsx, jsxs } from "preact/jsx-runtime";
3
- //#region _components/state-indicator.tsx
4
- /**
5
- * Colored dot + label showing the current {@link AgentState}.
6
- *
7
- * State-to-color mapping:
8
- * - `disconnected` — gray
9
- * - `connecting` — yellow
10
- * - `ready` — green
11
- * - `listening` — blue
12
- * - `thinking` — purple
13
- * - `speaking` — red
14
- * - `error` — red
15
- *
16
- * @example
17
- * ```tsx
18
- * const { session } = useSession();
19
- * <StateIndicator state={session.state} />
20
- * ```
21
- *
22
- * @param state - A reactive {@link AgentState} value.
23
- * @param className - Additional CSS class names.
24
- *
25
- * @public
26
- */
27
- function StateIndicator({ state, className }) {
28
- return /* @__PURE__ */ jsxs("div", {
29
- class: clsx("inline-flex items-center justify-center gap-1.5 text-[13px] font-medium leading-[130%] text-aai-text-muted capitalize", className),
30
- children: [/* @__PURE__ */ jsx("div", {
31
- "data-state": state.value,
32
- class: "w-2 h-2 rounded-full data-[state=disconnected]:bg-aai-state-disconnected data-[state=connecting]:bg-aai-state-connecting data-[state=ready]:bg-aai-state-ready data-[state=listening]:bg-aai-state-listening data-[state=thinking]:bg-aai-state-thinking data-[state=speaking]:bg-aai-state-speaking data-[state=error]:bg-aai-state-error"
33
- }), state.value]
34
- });
35
- }
36
- //#endregion
37
- export { StateIndicator };
@@ -1,16 +0,0 @@
1
- import type * as preact from "preact";
2
- /**
3
- * Animated three-dot "thinking" indicator shown while the agent is processing.
4
- *
5
- * @example
6
- * ```tsx
7
- * {isThinking && <ThinkingIndicator />}
8
- * ```
9
- *
10
- * @param className - Additional CSS class names.
11
- *
12
- * @public
13
- */
14
- export declare function ThinkingIndicator({ className }: {
15
- className?: string;
16
- }): preact.JSX.Element;
@@ -1,34 +0,0 @@
1
- import clsx from "clsx";
2
- import { jsx } from "preact/jsx-runtime";
3
- //#region _components/thinking-indicator.tsx
4
- const DOT_STYLES = [
5
- 0,
6
- .16,
7
- .32
8
- ].map((delay) => ({
9
- animation: "aai-bounce 1.4s infinite ease-in-out both",
10
- animationDelay: `${delay}s`
11
- }));
12
- /**
13
- * Animated three-dot "thinking" indicator shown while the agent is processing.
14
- *
15
- * @example
16
- * ```tsx
17
- * {isThinking && <ThinkingIndicator />}
18
- * ```
19
- *
20
- * @param className - Additional CSS class names.
21
- *
22
- * @public
23
- */
24
- function ThinkingIndicator({ className }) {
25
- return /* @__PURE__ */ jsx("div", {
26
- class: clsx("flex items-center gap-2 text-aai-text-dim text-sm font-medium min-h-5", className),
27
- children: DOT_STYLES.map((style, i) => /* @__PURE__ */ jsx("div", {
28
- class: "w-1.5 h-1.5 rounded-full bg-aai-text-dim",
29
- style
30
- }, i))
31
- });
32
- }
33
- //#endregion
34
- export { ThinkingIndicator };
@@ -1,27 +0,0 @@
1
- import type * as preact from "preact";
2
- import type { ToolCallInfo } from "../types.ts";
3
- /**
4
- * Renders a tool invocation with an icon, title, subtitle, and a
5
- * collapsible result viewer.
6
- *
7
- * Built-in tool types (`web_search`, `visit_webpage`, `run_code`,
8
- * `fetch_json`, `user_input`) get custom icons and labels. Unknown tools
9
- * fall back to a generic bolt icon.
10
- *
11
- * While the tool call is pending a shimmer animation is shown. Once
12
- * complete, clicking the block expands the formatted JSON result.
13
- *
14
- * @example
15
- * ```tsx
16
- * <ToolCallBlock toolCall={toolCall} />
17
- * ```
18
- *
19
- * @param toolCall - The tool call to render (see {@link ToolCallInfo}).
20
- * @param className - Additional CSS class names.
21
- *
22
- * @public
23
- */
24
- export declare function ToolCallBlock({ toolCall, className, }: {
25
- toolCall: ToolCallInfo;
26
- className?: string;
27
- }): preact.JSX.Element;
@@ -1,118 +0,0 @@
1
- import { BoltIcon, ChatBubbleIcon, DownloadIcon, ExternalLinkIcon, SearchIcon, TerminalIcon } from "./tool-icons.js";
2
- import clsx from "clsx";
3
- import { useComputed, useSignal } from "@preact/signals";
4
- import { jsx, jsxs } from "preact/jsx-runtime";
5
- //#region _components/tool-call-block.tsx
6
- const argField = (key) => (args) => String(args[key] ?? "");
7
- const TOOL_CONFIG = {
8
- web_search: {
9
- Icon: SearchIcon,
10
- title: "Web Search",
11
- subtitle: argField("query")
12
- },
13
- visit_webpage: {
14
- Icon: ExternalLinkIcon,
15
- title: "Visit Page",
16
- subtitle: argField("url")
17
- },
18
- run_code: {
19
- Icon: TerminalIcon,
20
- title: "Run Code",
21
- subtitle: (args) => {
22
- const firstLine = String(args.code ?? "").split("\n")[0] ?? "";
23
- return firstLine.length > 80 ? `${firstLine.slice(0, 80)}...` : firstLine;
24
- }
25
- },
26
- fetch_json: {
27
- Icon: DownloadIcon,
28
- title: "Fetch JSON",
29
- subtitle: argField("url")
30
- },
31
- user_input: {
32
- Icon: ChatBubbleIcon,
33
- title: "Asking User",
34
- subtitle: argField("question")
35
- }
36
- };
37
- const DEFAULT_CONFIG = {
38
- Icon: BoltIcon,
39
- title: "",
40
- subtitle: (args) => {
41
- const summary = JSON.stringify(args);
42
- return summary.length > 80 ? `${summary.slice(0, 80)}...` : summary;
43
- }
44
- };
45
- function formatResult(result) {
46
- try {
47
- return JSON.stringify(JSON.parse(result), null, 2);
48
- } catch {
49
- return result;
50
- }
51
- }
52
- /**
53
- * Renders a tool invocation with an icon, title, subtitle, and a
54
- * collapsible result viewer.
55
- *
56
- * Built-in tool types (`web_search`, `visit_webpage`, `run_code`,
57
- * `fetch_json`, `user_input`) get custom icons and labels. Unknown tools
58
- * fall back to a generic bolt icon.
59
- *
60
- * While the tool call is pending a shimmer animation is shown. Once
61
- * complete, clicking the block expands the formatted JSON result.
62
- *
63
- * @example
64
- * ```tsx
65
- * <ToolCallBlock toolCall={toolCall} />
66
- * ```
67
- *
68
- * @param toolCall - The tool call to render (see {@link ToolCallInfo}).
69
- * @param className - Additional CSS class names.
70
- *
71
- * @public
72
- */
73
- function ToolCallBlock({ toolCall, className }) {
74
- const isOpen = useSignal(false);
75
- const config = TOOL_CONFIG[toolCall.toolName] ?? DEFAULT_CONFIG;
76
- const isPending = toolCall.status === "pending";
77
- const title = config.title || toolCall.toolName;
78
- const canExpand = !isPending && Boolean(toolCall.result);
79
- const formatted = useComputed(() => toolCall.result ? formatResult(toolCall.result) : "");
80
- return /* @__PURE__ */ jsxs("div", {
81
- class: clsx("flex flex-col", className),
82
- children: [/* @__PURE__ */ jsxs("button", {
83
- type: "button",
84
- "aria-expanded": canExpand ? isOpen.value : void 0,
85
- disabled: isPending,
86
- class: clsx("flex items-center gap-2 px-3 py-2 rounded-aai border border-aai-border bg-aai-surface-faint select-none text-left w-full", canExpand && "cursor-pointer"),
87
- onClick: () => {
88
- if (canExpand) isOpen.value = !isOpen.value;
89
- },
90
- children: [
91
- /* @__PURE__ */ jsx(config.Icon, { class: "w-4 h-4 text-aai-text-dim shrink-0" }),
92
- /* @__PURE__ */ jsx("span", {
93
- class: clsx("text-sm font-medium text-aai-text", isPending && "tool-shimmer"),
94
- children: title
95
- }),
96
- /* @__PURE__ */ jsx("span", {
97
- class: "text-sm text-aai-text-dim truncate flex-1 min-w-0",
98
- children: config.subtitle(toolCall.args)
99
- }),
100
- canExpand && /* @__PURE__ */ jsx("span", {
101
- class: "text-xs text-aai-text-dim shrink-0",
102
- children: isOpen.value ? "▾" : "▸"
103
- })
104
- ]
105
- }), isOpen.value && /* @__PURE__ */ jsxs("div", {
106
- class: "border-x border-b border-aai-border rounded-b-aai bg-aai-surface max-h-64 overflow-auto",
107
- children: [toolCall.toolName === "run_code" && toolCall.args.code && /* @__PURE__ */ jsx("pre", {
108
- class: "text-xs text-aai-text p-2 whitespace-pre-wrap border-b border-aai-border font-mono",
109
- children: String(toolCall.args.code)
110
- }), formatted.value && /* @__PURE__ */ jsx("pre", {
111
- class: "text-xs text-aai-text-dim p-2 whitespace-pre-wrap",
112
- children: formatted.value
113
- })]
114
- })]
115
- });
116
- }
117
- //#endregion
118
- export { ToolCallBlock };
@@ -1,17 +0,0 @@
1
- import type * as preact from "preact";
2
- type IconProps = {
3
- class?: string;
4
- };
5
- /** Magnifying glass icon for web_search. */
6
- export declare function SearchIcon(props: IconProps): preact.JSX.Element;
7
- /** External link icon for visit_webpage. */
8
- export declare function ExternalLinkIcon(props: IconProps): preact.JSX.Element;
9
- /** Terminal icon for run_code. */
10
- export declare function TerminalIcon(props: IconProps): preact.JSX.Element;
11
- /** Download icon for fetch_json. */
12
- export declare function DownloadIcon(props: IconProps): preact.JSX.Element;
13
- /** Chat bubble icon for user_input. */
14
- export declare function ChatBubbleIcon(props: IconProps): preact.JSX.Element;
15
- /** Bolt/lightning icon for default/unknown tools. */
16
- export declare function BoltIcon(props: IconProps): preact.JSX.Element;
17
- export {};
@@ -1,128 +0,0 @@
1
- import { jsx, jsxs } from "preact/jsx-runtime";
2
- //#region _components/tool-icons.tsx
3
- /** Magnifying glass icon for web_search. */
4
- function SearchIcon(props) {
5
- return /* @__PURE__ */ jsxs("svg", {
6
- viewBox: "0 0 16 16",
7
- fill: "none",
8
- stroke: "currentColor",
9
- "stroke-width": "1.5",
10
- class: props.class,
11
- children: [/* @__PURE__ */ jsx("circle", {
12
- cx: "7",
13
- cy: "7",
14
- r: "4.5"
15
- }), /* @__PURE__ */ jsx("path", {
16
- d: "M10.5 10.5L14 14",
17
- "stroke-linecap": "round"
18
- })]
19
- });
20
- }
21
- /** External link icon for visit_webpage. */
22
- function ExternalLinkIcon(props) {
23
- return /* @__PURE__ */ jsxs("svg", {
24
- viewBox: "0 0 16 16",
25
- fill: "none",
26
- stroke: "currentColor",
27
- "stroke-width": "1.5",
28
- class: props.class,
29
- children: [
30
- /* @__PURE__ */ jsx("path", {
31
- d: "M6 2H3a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1v-3",
32
- "stroke-linecap": "round"
33
- }),
34
- /* @__PURE__ */ jsx("path", {
35
- d: "M9 2h5v5",
36
- "stroke-linecap": "round",
37
- "stroke-linejoin": "round"
38
- }),
39
- /* @__PURE__ */ jsx("path", {
40
- d: "M14 2L7 9",
41
- "stroke-linecap": "round"
42
- })
43
- ]
44
- });
45
- }
46
- /** Terminal icon for run_code. */
47
- function TerminalIcon(props) {
48
- return /* @__PURE__ */ jsxs("svg", {
49
- viewBox: "0 0 16 16",
50
- fill: "none",
51
- stroke: "currentColor",
52
- "stroke-width": "1.5",
53
- class: props.class,
54
- children: [
55
- /* @__PURE__ */ jsx("rect", {
56
- x: "1",
57
- y: "2",
58
- width: "14",
59
- height: "12",
60
- rx: "1.5"
61
- }),
62
- /* @__PURE__ */ jsx("path", {
63
- d: "M4 6l3 2.5L4 11",
64
- "stroke-linecap": "round",
65
- "stroke-linejoin": "round"
66
- }),
67
- /* @__PURE__ */ jsx("path", {
68
- d: "M9 11h3",
69
- "stroke-linecap": "round"
70
- })
71
- ]
72
- });
73
- }
74
- /** Download icon for fetch_json. */
75
- function DownloadIcon(props) {
76
- return /* @__PURE__ */ jsxs("svg", {
77
- viewBox: "0 0 16 16",
78
- fill: "none",
79
- stroke: "currentColor",
80
- "stroke-width": "1.5",
81
- class: props.class,
82
- children: [
83
- /* @__PURE__ */ jsx("path", {
84
- d: "M8 2v9",
85
- "stroke-linecap": "round"
86
- }),
87
- /* @__PURE__ */ jsx("path", {
88
- d: "M4.5 8L8 11.5 11.5 8",
89
- "stroke-linecap": "round",
90
- "stroke-linejoin": "round"
91
- }),
92
- /* @__PURE__ */ jsx("path", {
93
- d: "M2 13h12",
94
- "stroke-linecap": "round"
95
- })
96
- ]
97
- });
98
- }
99
- /** Chat bubble icon for user_input. */
100
- function ChatBubbleIcon(props) {
101
- return /* @__PURE__ */ jsx("svg", {
102
- viewBox: "0 0 16 16",
103
- fill: "none",
104
- stroke: "currentColor",
105
- "stroke-width": "1.5",
106
- class: props.class,
107
- children: /* @__PURE__ */ jsx("path", {
108
- d: "M2 3a1 1 0 011-1h10a1 1 0 011 1v7a1 1 0 01-1 1H5l-3 3V3z",
109
- "stroke-linejoin": "round"
110
- })
111
- });
112
- }
113
- /** Bolt/lightning icon for default/unknown tools. */
114
- function BoltIcon(props) {
115
- return /* @__PURE__ */ jsx("svg", {
116
- viewBox: "0 0 16 16",
117
- fill: "none",
118
- stroke: "currentColor",
119
- "stroke-width": "1.5",
120
- class: props.class,
121
- children: /* @__PURE__ */ jsx("path", {
122
- d: "M9 1L3 9h5l-1 6 6-8H8l1-6z",
123
- "stroke-linejoin": "round"
124
- })
125
- });
126
- }
127
- //#endregion
128
- export { BoltIcon, ChatBubbleIcon, DownloadIcon, ExternalLinkIcon, SearchIcon, TerminalIcon };
@@ -1,25 +0,0 @@
1
- import type * as preact from "preact";
2
- import type { Reactive } from "../types.ts";
3
- /**
4
- * Live speech-to-text transcript shown while the user is speaking.
5
- * Returns `null` when there is no active utterance.
6
- *
7
- * Displays a {@link ThinkingIndicator} while waiting for the first
8
- * transcription text (i.e., `userUtterance` is `""`).
9
- *
10
- * @example
11
- * ```tsx
12
- * const { session } = useSession();
13
- * <Transcript userUtterance={session.userUtterance} />
14
- * ```
15
- *
16
- * @param userUtterance - Reactive string (`null` when idle, `""` when
17
- * listening but no text yet, or the transcript text).
18
- * @param className - Additional CSS class names.
19
- *
20
- * @public
21
- */
22
- export declare function Transcript({ userUtterance, className, }: {
23
- userUtterance: Reactive<string | null>;
24
- className?: string;
25
- }): preact.JSX.Element | null;