@alexkroman1/aai-ui 16.1.0 → 18.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.
Files changed (39) hide show
  1. package/README.md +3 -2
  2. package/dist/_page-shell.d.ts +11 -0
  3. package/dist/{chat-view-DsylXJsw.js → chat-view-P12pHKQU.js} +1 -1
  4. package/dist/{client-config-DJQHnYjm.js → client-config-CFhkMkmv.js} +15 -13
  5. package/dist/client-config.d.ts +14 -13
  6. package/dist/components/chat-view.js +1 -1
  7. package/dist/components/controls.js +1 -1
  8. package/dist/components/message-list.js +1 -1
  9. package/dist/components/tool-call-block.js +1 -1
  10. package/dist/context.d.ts +27 -5
  11. package/dist/context.js +3 -3
  12. package/dist/default-client/assets/index-5XG8PqGw.css +2 -0
  13. package/dist/default-client/assets/index-tc-nAWq3.js +121 -0
  14. package/dist/default-client/index.html +2 -2
  15. package/dist/default-client.d.ts +21 -0
  16. package/dist/define-client.js +4 -4
  17. package/dist/hooks.d.ts +19 -9
  18. package/dist/hooks.js +1 -1
  19. package/dist/index.d.ts +17 -13
  20. package/dist/index.js +734 -433
  21. package/dist/internal.js +3 -3
  22. package/dist/{message-list-BLyPRS1Q.js → message-list-CJX560b5.js} +1 -1
  23. package/dist/page.d.ts +47 -21
  24. package/dist/{session-core-gwePM95B.js → session-core-TOdm_Con.js} +424 -174
  25. package/dist/session-core-audio-effects.d.ts +26 -0
  26. package/dist/session-core-audio-setup.d.ts +38 -31
  27. package/dist/session-core-audio-state.d.ts +152 -0
  28. package/dist/session-core-messages.d.ts +9 -10
  29. package/dist/session-core-types.d.ts +60 -21
  30. package/dist/session-core-user-turn.d.ts +30 -0
  31. package/dist/session-core.js +1 -1
  32. package/dist/use-push-to-talk.d.ts +105 -0
  33. package/dist/{use-workflow-run-CNahvlgL.js → use-workflow-run-ZqJWJn2-.js} +24 -11
  34. package/dist/workflow-client.d.ts +26 -12
  35. package/package.json +2 -2
  36. package/dist/default-client/assets/index-CMh4E-Ci.css +0 -2
  37. package/dist/default-client/assets/index-eOmPq2sS.js +0 -284
  38. package/dist/{tool-call-block-C2t_5fpp.js → tool-call-block-4gXoL_eP.js} +1 -1
  39. package/dist/{url-chips-D62RTz7v.js → url-chips-0n35fPJY.js} +1 -1
@@ -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-eOmPq2sS.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-tc-nAWq3.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="./assets/client-audio-constants-CP13UQZt.js">
11
- <link rel="stylesheet" crossorigin href="./assets/index-CMh4E-Ci.css">
11
+ <link rel="stylesheet" crossorigin href="./assets/index-5XG8PqGw.css">
12
12
  </head>
13
13
  <body>
14
14
  <main id="app"></main>
@@ -1,2 +1,23 @@
1
1
  /** @jsxImportSource react */
2
+ /**
3
+ * The page every agent gets with NO `client.tsx` of its own — and which page
4
+ * follows the agent's declared front door.
5
+ *
6
+ * One bundle serves both, because the CLI serves one directory for every agent
7
+ * (`resolveClientDir`'s fallback to `defaultClientDir()`): the choice cannot be
8
+ * made at build time, so it is made here, from the `page` field
9
+ * `GET client-config` reports precisely so a browser knows before it dials.
10
+ *
11
+ * It used to call `mountClient({})` unconditionally. For a WORKFLOW APP that
12
+ * renders a start screen and then opens a `/websocket` the server declines by
13
+ * design — a dead page — which is why "you do not need a `client.tsx`" was only
14
+ * ever true of a voice agent. Both mounts have a default shell now, so it is
15
+ * true of either.
16
+ *
17
+ * The name is FORWARDED rather than looked up twice: on the platform this
18
+ * endpoint is the broker, so a request able to boot a sandbox should not be
19
+ * issued once here and again by the shell. Both shells treat an explicit name as
20
+ * final and skip their own lookup. An agent that declared none still costs the
21
+ * shell its own request, which is what it cost before.
22
+ */
2
23
  import "../styles.css";
@@ -1,11 +1,11 @@
1
- import { t as ChatView } from "./chat-view-DsylXJsw.js";
2
- import { n as fetchClientConfig } from "./client-config-DJQHnYjm.js";
3
- import { SessionProvider, ThemeProvider } from "./context.js";
1
+ import { t as ChatView } from "./chat-view-P12pHKQU.js";
4
2
  import { n as setPageTitle, t as pageBaseUrl } from "./_utils-DnQDM9Uy.js";
3
+ import { n as fetchClientConfig } from "./client-config-CFhkMkmv.js";
4
+ import { SessionProvider, ThemeProvider } from "./context.js";
5
5
  import { t as ToolConfigContext } from "./tool-config-context-Es4YUzV2.js";
6
6
  import { SidebarLayout } from "./components/sidebar-layout.js";
7
7
  import { StartScreen } from "./components/start-screen.js";
8
- import { t as createBrowserSession } from "./session-core-gwePM95B.js";
8
+ import { t as createBrowserSession } from "./session-core-TOdm_Con.js";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
  import { createElement, useEffect, useState } from "react";
11
11
  import { flushSync } from "react-dom";
package/dist/hooks.d.ts CHANGED
@@ -102,8 +102,8 @@ export declare function useToolResult<R = unknown>(callback: (name: string, resu
102
102
  export declare function useAgentState<S = DefaultToolResult>(): S | null;
103
103
  /**
104
104
  * The agent's projected session state, typed and defaulted by the SAME
105
- * projection the agent pushes — pass `slot.projection(view)` and there is no
106
- * type argument to restate and no empty frame to derive.
105
+ * projection the agent pushes — pass `slot.projected` and there is no type
106
+ * argument to restate and no empty frame to derive.
107
107
  *
108
108
  * This is the overload to reach for whenever `syncState` is a slot projection,
109
109
  * because it closes the round-trip the other two leave open. A projection is
@@ -114,20 +114,29 @@ export declare function useAgentState<S = DefaultToolResult>(): S | null;
114
114
  * declaration and both were written by hand:
115
115
  *
116
116
  * ```tsx no-check
117
- * // `no-check`: the projection lives with the agent, in another file.
117
+ * // `no-check`: the slot lives with the agent, in another file.
118
118
  * // Before — the empty frame derived by hand, the type named three times:
119
119
  * const EMPTY: CartView = cartSlot.projection(cartView)(undefined);
120
120
  * const cart = useAgentState<CartView>(EMPTY);
121
121
  *
122
- * // After — `shared.ts` exports the projection once, both ends import it:
123
- * const cart = useAgentState(cartProjection);
122
+ * // After — the slot declares its `view`, and both ends pass the one object
123
+ * // it built at declaration:
124
+ * const cart = useAgentState(cartSlot.projected);
124
125
  * ```
125
126
  *
127
+ * **`slot.projected` is the spelling to prefer, and it retires the caveat
128
+ * below.** Declare the view on the slot (`sessionSlot(key, create, { view })`)
129
+ * and the projection is built ONCE where the slot is, so `agent({ syncState })`
130
+ * and this hook are handed the same object and nothing has to arrange for that.
131
+ * `slot.projection(view)` composes a NEW projection per call, which is what
132
+ * leaves both halves below to a convention.
133
+ *
126
134
  * The empty frame is memoized on the projection's identity, so a module-scope
127
135
  * projection (the normal case) produces ONE frame for the life of the
128
136
  * component — which the `fallback` overload can only ask you to arrange by
129
137
  * hoisting, and which a `slot.projection(view)` spelled inline in the render
130
- * body silently got wrong.
138
+ * body silently got wrong. A `slot.projected` cannot be spelled inline: it is
139
+ * the slot's own field.
131
140
  *
132
141
  * **The one case that cannot use this overload is a slot whose declaring module
133
142
  * is expensive to IMPORT.** A projection is built from the slot, so the browser
@@ -139,9 +148,10 @@ export declare function useAgentState<S = DefaultToolResult>(): S | null;
139
148
  * everywhere the slot's module is cheap, which is every other stateful
140
149
  * template.
141
150
  *
142
- * @param projection - The same `slot.projection(view)` the agent declares as
143
- * `syncState`. Export it from the module that declares the slot so the two
144
- * ends cannot drift.
151
+ * @param projection - The same projection the agent declares as `syncState`.
152
+ * `slot.projected` is that object by construction; a `slot.projection(view)`
153
+ * has to be exported from the module that declares the slot so the two ends
154
+ * cannot drift.
145
155
  *
146
156
  * @public
147
157
  */
package/dist/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useSessionSelector } from "./context.js";
2
1
  import { i as tryParseJSON } from "./_utils-DnQDM9Uy.js";
2
+ import { useSessionSelector } from "./context.js";
3
3
  import { useEffect, useMemo, useRef } from "react";
4
4
  //#region src/hooks.ts
5
5
  /** Index of the first item whose sequence number is above the watermark (tail scan from the end). */
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@
25
25
  * | --- | --- |
26
26
  * | the call itself | {@link useSession} (everything), {@link useSessionStatus}, {@link useSessionError}, {@link useSessionActions}, {@link useSessionSelector} |
27
27
  * | what was said | {@link useConversation}, {@link useUserTranscript} |
28
- * | what the agent projects | {@link useAgentState} — pass the `slot.projection(…)` the agent declared, and it types the state AND supplies the frame rendered before the first push |
28
+ * | what the agent projects | {@link useAgentState} — pass the `slot.projected` the agent declared as `syncState`, and it types the state AND supplies the frame rendered before the first push |
29
29
  * | tools, as they run | {@link useToolCallStart}, {@link useToolResult}, {@link useEvent} |
30
30
  * | a durable run | {@link useWorkflowSubmit} (start one), {@link useWorkflowRun} (watch one), {@link useWorkflowRuns} / {@link useWorkflows} (list), {@link useWorkflowProgress} / {@link useWorkflowStream} (its output as it arrives) |
31
31
  * | page chrome | {@link useTheme}, {@link useCopy}, {@link useFlash}, {@link useDownloadUrl}, {@link useRunKey} |
@@ -39,17 +39,20 @@
39
39
  *
40
40
  * ## Two things worth knowing before the reference below
41
41
  *
42
- * **Three names are re-exported from `@alexkroman1/aai`** — {@link WorkflowInputOf},
43
- * {@link WorkflowOutputOf} and {@link WorkflowSummary}, plus {@link isTerminal}
44
- * and {@link ClientConfigResponse}. They are one declaration with two reference
45
- * pages, not two types; a page takes them from here, an `agent.ts` from there.
42
+ * **Several names are re-exported from `@alexkroman1/aai`** —
43
+ * {@link WorkflowInputOf}, {@link WorkflowOutputOf}, {@link WorkflowSummary} and
44
+ * {@link AgentClient}, plus {@link isTerminal} and {@link ClientConfigResponse}.
45
+ * They are one declaration with two reference pages, not two types; a page takes
46
+ * them from here, an `agent.ts` from there.
46
47
  *
47
- * **{@link createWorkflowApi} is the browser's workflow client, and there are two
48
- * others.** `createWorkflowApiClient` (`@alexkroman1/aai/workflow-api`) is the
49
- * same call set for a caller with no page to default its base URL from — a
50
- * script, a cron job, a server — and `createAgentClient` on that subpath is a
51
- * superset that also reaches `/client-config`. Reach for the one here whenever
52
- * the code runs in a page the agent serves.
48
+ * **{@link createWorkflowApi} is the browser's client, and there is one other.**
49
+ * `createAgentClient` (`@alexkroman1/aai/workflow-api`) is the same
50
+ * {@link AgentClient} for a caller with no page to default its base URL from — a
51
+ * script, a cron job, a server. Reach for the one here whenever the code runs in
52
+ * a page the agent serves; it delegates to that factory, so there is one
53
+ * implementation of the routes and one `config()`. (It used to answer the
54
+ * narrower `WorkflowApi`, which made a page wanting the agent's own name build a
55
+ * second client for one read.)
53
56
  *
54
57
  * @module
55
58
  */
@@ -87,12 +90,13 @@ export { mountClient } from "./define-client.tsx";
87
90
  export { useAgentState, useEvent, useToolCallStart, useToolResult } from "./hooks.ts";
88
91
  export { mountPage, type PageConfig, type PageHandle } from "./page.tsx";
89
92
  export { createBrowserSession } from "./session-core.ts";
90
- export type { AgentCustomEvent, BrowserSession, SessionSnapshot, } from "./session-core-types.ts";
93
+ export type { AgentCustomEvent, BrowserSession, browserSessionBrand, SessionSnapshot, UserTurnControls, } from "./session-core-types.ts";
91
94
  export type { AgentState, ChatMessage, ClientTheme, SessionError, SessionErrorCode, ToolCallInfo, VoiceSessionOptions, WebSocketConstructor, } from "./types.ts";
92
95
  export { type ConversationItem, type UseConversationResult, useConversation, } from "./use-conversation.ts";
93
96
  export { type UseCopyResult, useCopy } from "./use-copy.ts";
94
97
  export { type UseDownloadUrlOptions, type UseDownloadUrlResult, useDownloadUrl, } from "./use-download-url.ts";
95
98
  export { type UseFlashResult, useFlash } from "./use-flash.ts";
99
+ export { type UsePushToTalkOptions, type UsePushToTalkResult, usePushToTalk, } from "./use-push-to-talk.ts";
96
100
  export { useRunKey } from "./use-run-key.ts";
97
101
  export { type UseSessionControlsResult, useSessionControls } from "./use-session-controls.ts";
98
102
  export { type UseUserTranscriptResult, useUserTranscript } from "./use-user-transcript.ts";
@@ -102,7 +106,7 @@ export { type UseWorkflowRunResult, useWorkflowRun } from "./use-workflow-run.ts
102
106
  export { type UseWorkflowRunsOptions, type UseWorkflowRunsResult, useWorkflowRuns, } from "./use-workflow-runs.ts";
103
107
  export { type UseWorkflowStreamOptions, useWorkflowStream, type WorkflowStreamSubmission, } from "./use-workflow-stream.ts";
104
108
  export { type UseWorkflowsOptions, type UseWorkflowsResult, useWorkflows, } from "./use-workflows.ts";
105
- export { createWorkflowApi, isTerminal, type WorkflowApi, type WorkflowApiOptions, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRun, type WorkflowRunStatus, type WorkflowSummary, } from "./workflow-client.ts";
109
+ export { type AgentClient, createWorkflowApi, isTerminal, type WorkflowApi, type WorkflowApiOptions, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRun, type WorkflowRunStatus, type WorkflowSummary, } from "./workflow-client.ts";
106
110
  export type { SubmitInputOf } from "./workflow-def-types.ts";
107
111
  export { fieldKindFor, type WorkflowFieldKind } from "./workflow-field-kind.ts";
108
112
  export { WORKFLOW_STATUS_LABELS } from "./workflow-status-labels.ts";