@alexkroman1/aai-ui 5.0.0 → 5.1.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/dist/client-config.d.ts +23 -4
- package/dist/default-client/assets/{audio-Bu1LSuiR.js → audio-BnLV_QB3.js} +1 -1
- package/dist/default-client/assets/{capture-processor-ssRD81Mo.js → capture-processor-ChXugkMd.js} +1 -1
- package/dist/default-client/assets/{index-0-DXv-S4.js → index-22Wylv4z.js} +26 -26
- package/dist/default-client/assets/{playback-processor-CRwbxC1v.js → playback-processor-BfJzQKW5.js} +1 -1
- package/dist/default-client/index.html +1 -1
- package/dist/define-client.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{session-core-Bjkr4PAP.js → session-core-CwCaFzL8.js} +33 -16
- package/dist/session-core-types.d.ts +7 -3
- package/dist/session-core.js +1 -1
- package/package.json +2 -2
package/dist/client-config.d.ts
CHANGED
|
@@ -3,14 +3,33 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `GET client-config` (relative to the agent's base URL — see
|
|
5
5
|
* `sdk/client-config.ts` in `@alexkroman1/aai`) gives the default client the
|
|
6
|
-
* agent's display name and greeting before any connection exists.
|
|
7
|
-
* failure path — network error, 404 from an older server,
|
|
8
|
-
* degrades to the empty default, so
|
|
9
|
-
* agent.
|
|
6
|
+
* agent's display name and greeting before any connection exists. For that
|
|
7
|
+
* use every failure path — network error, 404 from an older server,
|
|
8
|
+
* malformed body — degrades to the empty default (`fetchClientConfig`), so
|
|
9
|
+
* the lookup can never break an existing agent.
|
|
10
|
+
*
|
|
11
|
+
* The session's broker decision needs the opposite: `loadClientConfig`
|
|
12
|
+
* keeps "the lookup failed" (`null`) distinct from "the server answered and
|
|
13
|
+
* named no sessionUrl" (`{}`). See its doc comment.
|
|
10
14
|
*/
|
|
11
15
|
import { type ClientConfigResponse } from "@alexkroman1/aai/protocol";
|
|
12
16
|
export type { ClientConfigResponse } from "@alexkroman1/aai/protocol";
|
|
13
17
|
/** Resolve a relative endpoint path against the agent's base URL. */
|
|
14
18
|
export declare function buildAgentUrl(platformUrl: string, endpointPath: string): URL;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the agent's client config, reporting `null` when the lookup did not
|
|
21
|
+
* produce an answer (network error, non-2xx, unparsable body).
|
|
22
|
+
*
|
|
23
|
+
* The distinction from `fetchClientConfig` matters for exactly one caller:
|
|
24
|
+
* the session's per-attempt broker decision. A config that ARRIVED and named
|
|
25
|
+
* no `sessionUrl` means "this server is not a broker" (`aai dev`, an older
|
|
26
|
+
* server) — a durable fact worth latching. A lookup that FAILED means
|
|
27
|
+
* nothing about the server, and treating the two alike is how a single 503
|
|
28
|
+
* (a sandbox mid-boot, or one that failed to start) pinned a session to the
|
|
29
|
+
* platform's `/:slug/websocket` — a WebSocket redirect browsers don't
|
|
30
|
+
* follow, so every retry failed with no re-brokering even after the agent
|
|
31
|
+
* recovered.
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadClientConfig(platformUrl: string, fetchFn?: typeof globalThis.fetch): Promise<ClientConfigResponse | null>;
|
|
15
34
|
/** Fetch the agent's client config; any failure yields the agent default. */
|
|
16
35
|
export declare function fetchClientConfig(platformUrl: string, fetchFn?: typeof globalThis.fetch): Promise<ClientConfigResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t,t as n}from"./index-
|
|
1
|
+
import{a as e,o as t,t as n}from"./index-22Wylv4z.js";function r(e,t,n){if(e!==t)throw Error(`Browser refused the ${n} sample rate: asked for ${t} Hz, got ${e} Hz`)}function i(e){e.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{})}function a(e,t,n){let r=new AudioWorkletNode(e,`capture-processor`,{channelCount:1,channelCountMode:`explicit`}),i=null;return r.port.onmessage=e=>{let r=e.data;r.event===`chunk`&&r.buffer?t(r.buffer):r.event===`silent`?n?.():r.event===`stopped`&&(i?.(),i=null)},{node:r,start(){r.port.postMessage({event:`start`})},stop(){return new Promise(e=>{let t=setTimeout(e,250);i=()=>{clearTimeout(t),e()},r.port.postMessage({event:`stop`})})}}}async function o(o){let{sttSampleRate:s,ttsSampleRate:c,captureWorkletSrc:l,playbackWorkletSrc:u,onMicData:d,onError:f,onPlaybackStats:p,onMicSilent:m}=o,h=new AudioContext({sampleRate:c,latencyHint:`playback`}),g=s===c,_=g?h:new AudioContext({sampleRate:s,latencyHint:`interactive`});async function v(){let e=g?[h]:[h,_];await Promise.all(e.map(e=>e.close().catch(e=>{console.warn(`AudioContext close failed:`,e)})))}let y=navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:`default`},...n}}),b;try{[b]=await Promise.all([y,h.resume(),_.resume(),_.audioWorklet.addModule(l),h.audioWorklet.addModule(u)]),r(_.sampleRate,s,`capture`),r(h.sampleRate,c,`playback`)}catch(e){throw i(y),await v(),e}let x=_.createMediaStreamSource(b),S=a(_,d,m);x.connect(S.node),S.node.onprocessorerror=()=>{let e=Error(`Audio capture worklet crashed`);console.error(`[aai-ui]`,e.message),f?.(e)},S.start();let C=null,w=null,T=new AbortController;function E(){if(C)return C;let e=new AudioWorkletNode(h,`playback-processor`);return e.connect(h.destination),e.port.onmessage=e=>{if(e.data.event===`stop`){let t=e.data.stats;if(t&&t.concealedSamples>0&&p?.(t),e.data.reason===`interrupt`)return;w?.(),w=null}},e.onprocessorerror=()=>{let e=Error(`Audio playback worklet crashed`);console.error(`[aai-ui]`,e.message),w?.(),w=null,f?.(e)},C=e,e}let D={enqueue(e){T.signal.aborted||e.byteLength!==0&&E().port.postMessage({event:`write`,buffer:new Uint8Array(e)},[e])},done(){return!C||(C.port.postMessage({event:`done`}),h.state!==`running`)?Promise.resolve():new Promise(n=>{w?.();let r=()=>{clearInterval(i),clearTimeout(a),w===r&&(w=null),n()},i=setInterval(()=>{h.state!==`running`&&r()},t),a=setTimeout(r,e);w=r})},flush(){C&&(w?.(),w=null,C.port.postMessage({event:`interrupt`}))},async close(){if(!T.signal.aborted){T.abort(),await S.stop(),x.disconnect(),S.node.disconnect(),C&&C.disconnect();for(let e of b.getTracks())e.stop();await v()}},async[Symbol.asyncDispose](){await D.close()}};return D}export{o as createVoiceIO};
|
package/dist/default-client/assets/{capture-processor-ssRD81Mo.js → capture-processor-ChXugkMd.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t}from"./index-
|
|
1
|
+
import{n as e,r as t}from"./index-22Wylv4z.js";import{t as n}from"./_module-url-BX0RuRU2.js";var r=n(`
|
|
2
2
|
class CaptureProcessor extends AudioWorkletProcessor {
|
|
3
3
|
constructor(options) {
|
|
4
4
|
super();
|