@alexkroman1/aai-ui 5.0.0 → 5.0.1

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.
@@ -1,4 +1,4 @@
1
- import{i as e}from"./index-0-DXv-S4.js";import{t}from"./_module-url-BX0RuRU2.js";var n=t(`
1
+ import{i as e}from"./index-RQnhfgSS.js";import{t}from"./_module-url-BX0RuRU2.js";var n=t(`
2
2
  class PlaybackProcessor extends AudioWorkletProcessor {
3
3
  constructor(options) {
4
4
  super();
@@ -6,7 +6,7 @@
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-0-DXv-S4.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-RQnhfgSS.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="./assets/index-CRfdZPH1.css">
11
11
  </head>
12
12
  <body>
@@ -1,4 +1,4 @@
1
- import { r as fetchClientConfig, t as createSessionCore } from "./session-core-Bjkr4PAP.js";
1
+ import { r as fetchClientConfig, t as createSessionCore } from "./session-core-ByBLnLfW.js";
2
2
  import { SessionProvider, ThemeProvider } from "./context.js";
3
3
  import { t as ChatView } from "./chat-view-CW-tZCMm.js";
4
4
  import { n as ToolConfigContext } from "./tool-call-block-DIxpG8GM.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as buildAgentUrl, r as fetchClientConfig, t as createSessionCore } from "./session-core-Bjkr4PAP.js";
1
+ import { n as buildAgentUrl, r as fetchClientConfig, t as createSessionCore } from "./session-core-ByBLnLfW.js";
2
2
  import { SessionProvider, ThemeProvider, useSession, useSessionSelector, useTheme } from "./context.js";
3
3
  import { Button } from "./components/button.js";
4
4
  import { t as ChatView } from "./chat-view-CW-tZCMm.js";
@@ -8,28 +8,48 @@ import ReconnectingWebSocket from "partysocket/ws";
8
8
  *
9
9
  * `GET client-config` (relative to the agent's base URL — see
10
10
  * `sdk/client-config.ts` in `@alexkroman1/aai`) gives the default client the
11
- * agent's display name and greeting before any connection exists. Every
12
- * failure path — network error, 404 from an older server, malformed body —
13
- * degrades to the empty default, so this lookup can never break an existing
14
- * agent.
11
+ * agent's display name and greeting before any connection exists. For that
12
+ * use every failure path — network error, 404 from an older server,
13
+ * malformed body — degrades to the empty default (`fetchClientConfig`), so
14
+ * the lookup can never break an existing agent.
15
+ *
16
+ * The session's broker decision needs the opposite: `loadClientConfig`
17
+ * keeps "the lookup failed" (`null`) distinct from "the server answered and
18
+ * named no sessionUrl" (`{}`). See its doc comment.
15
19
  */
16
20
  /** Resolve a relative endpoint path against the agent's base URL. */
17
21
  function buildAgentUrl(platformUrl, endpointPath) {
18
22
  return new URL(endpointPath, platformUrl.endsWith("/") ? platformUrl : `${platformUrl}/`);
19
23
  }
20
24
  const AGENT_DEFAULT = {};
21
- /** Fetch the agent's client config; any failure yields the agent default. */
22
- async function fetchClientConfig(platformUrl, fetchFn) {
25
+ /**
26
+ * Fetch the agent's client config, reporting `null` when the lookup did not
27
+ * produce an answer (network error, non-2xx, unparsable body).
28
+ *
29
+ * The distinction from `fetchClientConfig` matters for exactly one caller:
30
+ * the session's per-attempt broker decision. A config that ARRIVED and named
31
+ * no `sessionUrl` means "this server is not a broker" (`aai dev`, an older
32
+ * server) — a durable fact worth latching. A lookup that FAILED means
33
+ * nothing about the server, and treating the two alike is how a single 503
34
+ * (a sandbox mid-boot, or one that failed to start) pinned a session to the
35
+ * platform's `/:slug/websocket` — answered `410 Gone` on every retry, with
36
+ * no re-brokering even after the agent recovered.
37
+ */
38
+ async function loadClientConfig(platformUrl, fetchFn) {
23
39
  const doFetch = fetchFn ?? ((input, init) => globalThis.fetch(input, init));
24
40
  try {
25
41
  const resp = await doFetch(buildAgentUrl(platformUrl, CLIENT_CONFIG_PATH).href);
26
- if (!resp.ok) return AGENT_DEFAULT;
42
+ if (!resp.ok) return null;
27
43
  const parsed = ClientConfigResponseSchema.safeParse(await resp.json());
28
- return parsed.success ? parsed.data : AGENT_DEFAULT;
44
+ return parsed.success ? parsed.data : null;
29
45
  } catch {
30
- return AGENT_DEFAULT;
46
+ return null;
31
47
  }
32
48
  }
49
+ /** Fetch the agent's client config; any failure yields the agent default. */
50
+ async function fetchClientConfig(platformUrl, fetchFn) {
51
+ return await loadClientConfig(platformUrl, fetchFn) ?? AGENT_DEFAULT;
52
+ }
33
53
  //#endregion
34
54
  //#region session-core-audio-setup.ts
35
55
  /**
@@ -636,9 +656,9 @@ function createSessionCore(options) {
636
656
  * greeting-suppression fallback for a server whose config carried no id.
637
657
  */
638
658
  async function currentWsUrl() {
639
- const cfg = serverIsBroker === false ? {} : await fetchClientConfig(options.platformUrl);
640
- serverIsBroker = cfg.sessionUrl !== void 0;
641
- const url = cfg.sessionUrl ? buildBrokeredWsUrl(cfg.sessionUrl, hasConnected, sessionId) : buildWsUrl(options.platformUrl, hasConnected, sessionId);
659
+ const cfg = serverIsBroker === false ? null : await loadClientConfig(options.platformUrl);
660
+ if (cfg) serverIsBroker = cfg.sessionUrl !== void 0;
661
+ const url = cfg?.sessionUrl ? buildBrokeredWsUrl(cfg.sessionUrl, hasConnected, sessionId) : buildWsUrl(options.platformUrl, hasConnected, sessionId);
642
662
  const display = new URL(url);
643
663
  display.search = "";
644
664
  if (display.toString() !== currentSnapshot.apiUrl) updateState({ apiUrl: display.toString() });
@@ -1,2 +1,2 @@
1
- import { t as createSessionCore } from "./session-core-Bjkr4PAP.js";
1
+ import { t as createSessionCore } from "./session-core-ByBLnLfW.js";
2
2
  export { createSessionCore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-ui",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -22,7 +22,7 @@
22
22
  "react-markdown": "^10.1.0",
23
23
  "remark-gfm": "^4.0.1",
24
24
  "use-sync-external-store": "^1.6.0",
25
- "@alexkroman1/aai": "5.0.0"
25
+ "@alexkroman1/aai": "5.0.1"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^19.0.0",