@iloveagents/foundry-web-shell 0.9.0 → 0.10.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ask the backend what it does when the client sends no reasoning effort.
3
+ *
4
+ * The composer's `Auto` option sends nothing, so the level that actually
5
+ * applies is the backend's. Showing the user which one that is turns `Auto`
6
+ * from "some level, who knows" into a statement they can act on — it decides
7
+ * cost and latency, so guessing is not acceptable.
8
+ *
9
+ * Every non-success path RESETS the store to `null` rather than leaving a
10
+ * previous value behind. This function may be called again when the context
11
+ * changes; keeping a stale level after a failed refresh would show the user
12
+ * a label that no longer describes the backend — the exact lie this feature
13
+ * exists to prevent. Unknown is safe; wrong is not.
14
+ *
15
+ * `fetchImpl` is the shell's agent fetch (auth + base URL); tests and custom
16
+ * shells inject their own via the same `agentFetch` seam as the rest of the
17
+ * shell.
18
+ */
19
+ export declare function loadChatConfig(fetchImpl: typeof fetch): Promise<void>;
@@ -0,0 +1,43 @@
1
+ import { reasoningDefaultStore } from "@iloveagents/foundry-agent";
2
+ const VALID = ["low", "medium", "high", "xhigh"];
3
+ /**
4
+ * Ask the backend what it does when the client sends no reasoning effort.
5
+ *
6
+ * The composer's `Auto` option sends nothing, so the level that actually
7
+ * applies is the backend's. Showing the user which one that is turns `Auto`
8
+ * from "some level, who knows" into a statement they can act on — it decides
9
+ * cost and latency, so guessing is not acceptable.
10
+ *
11
+ * Every non-success path RESETS the store to `null` rather than leaving a
12
+ * previous value behind. This function may be called again when the context
13
+ * changes; keeping a stale level after a failed refresh would show the user
14
+ * a label that no longer describes the backend — the exact lie this feature
15
+ * exists to prevent. Unknown is safe; wrong is not.
16
+ *
17
+ * `fetchImpl` is the shell's agent fetch (auth + base URL); tests and custom
18
+ * shells inject their own via the same `agentFetch` seam as the rest of the
19
+ * shell.
20
+ */
21
+ export async function loadChatConfig(fetchImpl) {
22
+ const reset = () => reasoningDefaultStore.getState().setResolved(null);
23
+ try {
24
+ const response = await fetchImpl("/api/chat/config");
25
+ if (!response.ok) {
26
+ reset();
27
+ return;
28
+ }
29
+ const body = (await response.json());
30
+ const effort = body?.reasoning?.defaultEffort;
31
+ // `null` is meaningful (reasoning switched off) and anything unrecognised
32
+ // is treated the same as unknown — neither is coerced into a level.
33
+ if (typeof effort === "string" && VALID.includes(effort)) {
34
+ reasoningDefaultStore.getState().setResolved(effort);
35
+ }
36
+ else {
37
+ reset();
38
+ }
39
+ }
40
+ catch {
41
+ reset();
42
+ }
43
+ }
package/dist/shell-app.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Suspense, useCallback, useMemo, useRef } from "react";
2
+ import { Suspense, useCallback, useEffect, useMemo, useRef } from "react";
3
3
  import { BrowserRouter, Routes, Route, useLocation } from "react-router";
4
4
  import { AGUIRuntimeProvider } from "@iloveagents/foundry-web-ui";
5
5
  import { ShellAuth } from "./auth-default.js";
6
6
  import { ShellLayout } from "./shell-layout.js";
7
7
  import { defaultAgentFetch } from "./service-fetch-default.js";
8
+ import { loadChatConfig } from "./load-chat-config.js";
8
9
  /**
9
10
  * Inner shell component — pure React (no `createRoot`). Imported by
10
11
  * `bootstrap-shell.tsx` for production and by `__tests__/` for assertions.
@@ -12,6 +13,14 @@ import { defaultAgentFetch } from "./service-fetch-default.js";
12
13
  * Wrapper ordering is contractual; see `wrapper-order.test.tsx`.
13
14
  */
14
15
  export function ShellApp({ modules, pages, baseThemeLayers, authProvider, agentFetch, }) {
16
+ // Ask the backend what `Auto` currently resolves to, so the composer's
17
+ // effort picker can name the level instead of leaving the user guessing.
18
+ // Uses the same agentFetch seam as everything else (auth, base URL, test
19
+ // override); failure resets the level to unknown and the picker says so.
20
+ const resolvedAgentFetch = agentFetch ?? defaultAgentFetch;
21
+ useEffect(() => {
22
+ void loadChatConfig(resolvedAgentFetch);
23
+ }, [resolvedAgentFetch]);
15
24
  // Merge module pages with customer pages — customer wins on path collision
16
25
  // (last-wins). Stable order: customer pages first (they appear in Routes
17
26
  // before module pages, and React Router matches the FIRST matching route).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iloveagents/foundry-web-shell",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "description": "Browser bootstrap and layout shell for Foundry UI — bootstrapShell({ modules, pages, theme, authProvider }) mounts the SPA around foundry-web-ui. Module-agnostic.",
6
6
  "keywords": [
@@ -45,9 +45,9 @@
45
45
  "zustand": "^5.0.0"
46
46
  },
47
47
  "dependencies": {
48
- "@iloveagents/foundry-agent": "^0.9.0",
49
- "@iloveagents/foundry-web-primitives": "^0.9.0",
50
- "@iloveagents/foundry-web-ui": "^0.9.0"
48
+ "@iloveagents/foundry-agent": "^0.10.0",
49
+ "@iloveagents/foundry-web-primitives": "^0.10.0",
50
+ "@iloveagents/foundry-web-ui": "^0.10.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@assistant-ui/react": "^0.15.1",