@tangle-network/agent-app 1.0.16 → 1.0.18

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 (41) hide show
  1. package/dist/assistant/index.js +8 -8
  2. package/dist/catalog/index.js +1 -1
  3. package/dist/chat-react/index.js +5 -5
  4. package/dist/chat-routes/index.js +4 -4
  5. package/dist/{chunk-TGSVYWIF.js → chunk-4XGDZPHB.js} +5 -5
  6. package/dist/{chunk-TGSVYWIF.js.map → chunk-4XGDZPHB.js.map} +1 -1
  7. package/dist/{chunk-QAHBSKWG.js → chunk-G37LZ2FN.js} +2 -2
  8. package/dist/{chunk-R7PEKDCG.js → chunk-GOPBMDCQ.js} +3 -3
  9. package/dist/{chunk-N3KRSGVG.js → chunk-HWWER7G6.js} +2 -2
  10. package/dist/{chunk-ARCXYOMS.js → chunk-IQZSV5YG.js} +3 -3
  11. package/dist/{chunk-NC4K5QWP.js → chunk-K7HE6EM4.js} +2 -2
  12. package/dist/{chunk-AHBVQRJA.js → chunk-MK7VUZU7.js} +4 -4
  13. package/dist/{chunk-2VG6Q4TS.js → chunk-MM2GG3IX.js} +3 -3
  14. package/dist/{chunk-RO25WIVS.js → chunk-SLXJZGXE.js} +17 -10
  15. package/dist/chunk-SLXJZGXE.js.map +1 -0
  16. package/dist/{chunk-AMUXRAUO.js → chunk-VLMXVCDQ.js} +4 -1
  17. package/dist/chunk-VLMXVCDQ.js.map +1 -0
  18. package/dist/{chunk-44SU6LII.js → chunk-X7PYE5C5.js} +2 -2
  19. package/dist/{mention-editor-NTEV2G63.js → mention-editor-HLEB37RK.js} +3 -3
  20. package/dist/public-consultation/index.js +3 -3
  21. package/dist/runtime/index.js +3 -3
  22. package/dist/runtime/model-catalog.d.ts +7 -16
  23. package/dist/runtime/router-turn.js +2 -2
  24. package/dist/settings-react/index.js +2 -2
  25. package/dist/studio-react/index.js +2 -2
  26. package/dist/web-react/agent-profile-editor.js +5 -5
  27. package/dist/web-react/index.js +8 -8
  28. package/dist/web-react/model-picker.d.ts +3 -17
  29. package/dist/workspace-react/index.js +4 -4
  30. package/package.json +1 -1
  31. package/dist/chunk-AMUXRAUO.js.map +0 -1
  32. package/dist/chunk-RO25WIVS.js.map +0 -1
  33. /package/dist/{chunk-QAHBSKWG.js.map → chunk-G37LZ2FN.js.map} +0 -0
  34. /package/dist/{chunk-R7PEKDCG.js.map → chunk-GOPBMDCQ.js.map} +0 -0
  35. /package/dist/{chunk-N3KRSGVG.js.map → chunk-HWWER7G6.js.map} +0 -0
  36. /package/dist/{chunk-ARCXYOMS.js.map → chunk-IQZSV5YG.js.map} +0 -0
  37. /package/dist/{chunk-NC4K5QWP.js.map → chunk-K7HE6EM4.js.map} +0 -0
  38. /package/dist/{chunk-AHBVQRJA.js.map → chunk-MK7VUZU7.js.map} +0 -0
  39. /package/dist/{chunk-2VG6Q4TS.js.map → chunk-MM2GG3IX.js.map} +0 -0
  40. /package/dist/{chunk-44SU6LII.js.map → chunk-X7PYE5C5.js.map} +0 -0
  41. /package/dist/{mention-editor-NTEV2G63.js.map → mention-editor-HLEB37RK.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopover
3
- } from "./chunk-RO25WIVS.js";
3
+ } from "./chunk-SLXJZGXE.js";
4
4
 
5
5
  // src/web-react/popover-dialog.ts
6
6
  import { useEffect, useId } from "react";
@@ -45,4 +45,4 @@ function usePopoverDialog(open, onOpenChange) {
45
45
  export {
46
46
  usePopoverDialog
47
47
  };
48
- //# sourceMappingURL=chunk-QAHBSKWG.js.map
48
+ //# sourceMappingURL=chunk-G37LZ2FN.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HarnessPicker,
3
3
  filterAcceptedFiles
4
- } from "./chunk-ARCXYOMS.js";
4
+ } from "./chunk-IQZSV5YG.js";
5
5
  import {
6
6
  EffortPicker,
7
7
  ModelPicker,
@@ -9,7 +9,7 @@ import {
9
9
  POPOVER_OPTION_FOCUS,
10
10
  PopoverSurface,
11
11
  effortLevelsFromIds
12
- } from "./chunk-RO25WIVS.js";
12
+ } from "./chunk-SLXJZGXE.js";
13
13
  import {
14
14
  isCommitSha,
15
15
  parseGitHubLocation,
@@ -2382,4 +2382,4 @@ export {
2382
2382
  AGENT_PROFILE_EDITOR_SECTIONS,
2383
2383
  AgentProfileEditor
2384
2384
  };
2385
- //# sourceMappingURL=chunk-R7PEKDCG.js.map
2385
+ //# sourceMappingURL=chunk-GOPBMDCQ.js.map
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-DCPOEDPK.js";
9
9
  import {
10
10
  normalizeModelId
11
- } from "./chunk-AMUXRAUO.js";
11
+ } from "./chunk-VLMXVCDQ.js";
12
12
 
13
13
  // src/runtime/loop.ts
14
14
  import {
@@ -985,4 +985,4 @@ export {
985
985
  composeRouterTurnPrompt,
986
986
  runRouterTurn
987
987
  };
988
- //# sourceMappingURL=chunk-N3KRSGVG.js.map
988
+ //# sourceMappingURL=chunk-HWWER7G6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopoverDialog
3
- } from "./chunk-QAHBSKWG.js";
3
+ } from "./chunk-G37LZ2FN.js";
4
4
  import {
5
5
  CheckGlyph,
6
6
  EffortPicker,
@@ -11,7 +11,7 @@ import {
11
11
  pickerRootClass,
12
12
  quietPickerTriggerClass,
13
13
  usePopover
14
- } from "./chunk-RO25WIVS.js";
14
+ } from "./chunk-SLXJZGXE.js";
15
15
  import {
16
16
  snapHarnessToModel,
17
17
  snapModelToHarness
@@ -576,4 +576,4 @@ export {
576
576
  HarnessPicker,
577
577
  AgentSessionControls
578
578
  };
579
- //# sourceMappingURL=chunk-ARCXYOMS.js.map
579
+ //# sourceMappingURL=chunk-IQZSV5YG.js.map
@@ -113,7 +113,7 @@ import {
113
113
  import {
114
114
  composeRouterTurnPromptSections,
115
115
  runRouterTurn
116
- } from "./chunk-N3KRSGVG.js";
116
+ } from "./chunk-HWWER7G6.js";
117
117
  import {
118
118
  createIntelligenceTurnTraceSink,
119
119
  createTurnTrace,
@@ -4153,4 +4153,4 @@ export {
4153
4153
  createChatTurnRoutes,
4154
4154
  streamChatRouteAsSandboxEvents
4155
4155
  };
4156
- //# sourceMappingURL=chunk-NC4K5QWP.js.map
4156
+ //# sourceMappingURL=chunk-K7HE6EM4.js.map
@@ -7,7 +7,7 @@ import {
7
7
  filterAcceptedFiles,
8
8
  isAcceptedFileType,
9
9
  renamePastedImages
10
- } from "./chunk-ARCXYOMS.js";
10
+ } from "./chunk-IQZSV5YG.js";
11
11
  import {
12
12
  useWorkspacePrewarmHandle
13
13
  } from "./chunk-2HQP2CTA.js";
@@ -15,7 +15,7 @@ import {
15
15
  OVERLAY_SHADOW,
16
16
  POPOVER_OPTION_FOCUS,
17
17
  PopoverSurface
18
- } from "./chunk-RO25WIVS.js";
18
+ } from "./chunk-SLXJZGXE.js";
19
19
  import {
20
20
  filterCommandPaletteItems
21
21
  } from "./chunk-SJWIZT7B.js";
@@ -615,7 +615,7 @@ function MicGlyph({ className }) {
615
615
  // src/web-react/chat-composer.tsx
616
616
  import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
617
617
  function createLazyMentionEditor() {
618
- return lazy2(() => import("./mention-editor-NTEV2G63.js").then((m) => m.loadMentionEditor()));
618
+ return lazy2(() => import("./mention-editor-HLEB37RK.js").then((m) => m.loadMentionEditor()));
619
619
  }
620
620
  var IS_APPLE_PLATFORM = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform);
621
621
  var DEFAULT_MAX_HEIGHT = 168;
@@ -1853,4 +1853,4 @@ export {
1853
1853
  ComposerModeControls,
1854
1854
  EntryComposer
1855
1855
  };
1856
- //# sourceMappingURL=chunk-AHBVQRJA.js.map
1856
+ //# sourceMappingURL=chunk-MK7VUZU7.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  usePopoverDialog
3
- } from "./chunk-QAHBSKWG.js";
3
+ } from "./chunk-G37LZ2FN.js";
4
4
  import {
5
5
  CheckGlyph,
6
6
  OVERLAY_SHADOW,
7
7
  PopoverSurface
8
- } from "./chunk-RO25WIVS.js";
8
+ } from "./chunk-SLXJZGXE.js";
9
9
 
10
10
  // src/web-react/workspace-switcher.tsx
11
11
  import { useCallback, useState } from "react";
@@ -156,4 +156,4 @@ export {
156
156
  WorkspaceSwitcher,
157
157
  WorkspaceInitial
158
158
  };
159
- //# sourceMappingURL=chunk-2VG6Q4TS.js.map
159
+ //# sourceMappingURL=chunk-MM2GG3IX.js.map
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  MAX_RECOMMENDED_MODELS,
9
9
  sortModelsByFreshness
10
- } from "./chunk-AMUXRAUO.js";
10
+ } from "./chunk-VLMXVCDQ.js";
11
11
 
12
12
  // src/web-react/popover-surface.tsx
13
13
  import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
@@ -261,8 +261,15 @@ function formatContext(len) {
261
261
  if (len >= 1e3) return `${Math.round(len / 1e3)}K ctx`;
262
262
  return `${len} ctx`;
263
263
  }
264
- function logoBrand(model) {
265
- return model.maker?.trim() || model.provider;
264
+ function ModelMarks({ model, size, renderProviderBadge }) {
265
+ const brand = model.maker?.trim() || model.provider;
266
+ const host = model.servedBy?.trim();
267
+ const primary = renderProviderBadge ? renderProviderBadge(brand) : /* @__PURE__ */ jsx3(ProviderLogo, { provider: brand, size });
268
+ if (!host || host.toLowerCase() === brand.toLowerCase()) return primary;
269
+ return /* @__PURE__ */ jsxs2("span", { className: "inline-flex items-center gap-0.5", children: [
270
+ primary,
271
+ /* @__PURE__ */ jsx3(ProviderLogo, { provider: host, size })
272
+ ] });
266
273
  }
267
274
  function SectionHeader({ children }) {
268
275
  return /* @__PURE__ */ jsx3("div", { className: "px-3 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children });
@@ -286,7 +293,7 @@ function ModelRow({
286
293
  type: "button",
287
294
  onClick: onSelect,
288
295
  "aria-pressed": selected,
289
- title: `${model.name} (${model.id})`,
296
+ title: `${model.name} (${model.id})${model.servedBy ? ` \xB7 served by ${model.servedBy}` : ""}`,
290
297
  className: `flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${selected ? "bg-primary/10 font-medium" : "hover:bg-accent"}`,
291
298
  children: [
292
299
  thumb ? (
@@ -302,10 +309,10 @@ function ModelRow({
302
309
  className: `size-10 shrink-0 rounded-md border border-border object-cover${unavailable ? " opacity-50" : ""}`
303
310
  }
304
311
  )
305
- ) : /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: renderProviderBadge ? renderProviderBadge(logoBrand(model)) : /* @__PURE__ */ jsx3(ProviderLogo, { provider: logoBrand(model), size: 16 }) }),
312
+ ) : /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: /* @__PURE__ */ jsx3(ModelMarks, { model, size: 16, renderProviderBadge }) }),
306
313
  /* @__PURE__ */ jsxs2("span", { className: "min-w-0 flex-1", children: [
307
314
  /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 items-center gap-1.5", children: [
308
- thumb && /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: renderProviderBadge ? renderProviderBadge(logoBrand(model)) : /* @__PURE__ */ jsx3(ProviderLogo, { provider: logoBrand(model), size: 14 }) }),
315
+ thumb && /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: /* @__PURE__ */ jsx3(ModelMarks, { model, size: 14, renderProviderBadge }) }),
309
316
  /* @__PURE__ */ jsx3("span", { className: `min-w-0 break-words [overflow-wrap:anywhere]${unavailable ? " text-muted-foreground" : ""}`, children: model.name }),
310
317
  flagged && /* @__PURE__ */ jsx3(StatusPill, { tone: "warning", size: "sm", className: "shrink-0", title: model.statusReason, "data-model-status": model.status, children: unavailable ? "Unavailable" : "Limited" })
311
318
  ] }),
@@ -391,7 +398,7 @@ function ModelPicker({
391
398
  const q = query.trim().toLowerCase();
392
399
  if (!q) return null;
393
400
  return sortedModels.filter(
394
- (m) => m.id.toLowerCase().includes(q) || m.name.toLowerCase().includes(q) || (m.description?.toLowerCase() ?? "").includes(q) || m.provider.toLowerCase().includes(q) || (m.maker?.toLowerCase() ?? "").includes(q)
401
+ (m) => m.id.toLowerCase().includes(q) || m.name.toLowerCase().includes(q) || (m.description?.toLowerCase() ?? "").includes(q) || m.provider.toLowerCase().includes(q) || (m.maker?.toLowerCase() ?? "").includes(q) || (m.servedBy?.toLowerCase() ?? "").includes(q)
395
402
  );
396
403
  }, [sortedModels, query]);
397
404
  const sections = useMemo(() => {
@@ -437,12 +444,12 @@ function ModelPicker({
437
444
  changeOpen(true);
438
445
  }
439
446
  },
440
- title: selectedLabel || defaultOption?.label || "Select model",
447
+ title: selected ? `${selectedLabel}${selected.servedBy ? ` \xB7 served by ${selected.servedBy}` : ""}` : selectedLabel || defaultOption?.label || "Select model",
441
448
  "data-state": expanded ? "open" : "closed",
442
449
  className: `${variant === "field" ? fieldPickerTriggerClass({ interactive: !disabled }) : variant === "quiet" ? quietPickerTriggerClass({ interactive: !disabled }) : `${CHIP_PICKER_TRIGGER} ${disabled ? "" : "hover:bg-accent"}`} max-w-full disabled:cursor-not-allowed disabled:opacity-50`,
443
450
  children: [
444
451
  triggerContent ?? /* @__PURE__ */ jsxs2("span", { className: variant === "field" ? "flex min-w-0 flex-1 items-center gap-2" : "contents", children: [
445
- /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: selected ? renderProviderBadge ? renderProviderBadge(logoBrand(selected)) : /* @__PURE__ */ jsx3(ProviderLogo, { provider: logoBrand(selected), size: 16 }) : /* @__PURE__ */ jsx3(SparkleGlyph, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
452
+ /* @__PURE__ */ jsx3("span", { className: "shrink-0", "aria-hidden": true, children: selected ? /* @__PURE__ */ jsx3(ModelMarks, { model: selected, size: 16, renderProviderBadge }) : /* @__PURE__ */ jsx3(SparkleGlyph, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
446
453
  /* @__PURE__ */ jsx3("span", { className: variant === "field" ? `min-w-0 flex-1 truncate ${value ? "" : "text-muted-foreground"}` : "max-w-[160px] truncate", children: selectedLabel || defaultOption?.label || "Select model" })
447
454
  ] }),
448
455
  /* @__PURE__ */ jsx3(ChevronDown, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
@@ -724,4 +731,4 @@ export {
724
731
  EffortMeter,
725
732
  EffortPicker
726
733
  };
727
- //# sourceMappingURL=chunk-RO25WIVS.js.map
734
+ //# sourceMappingURL=chunk-SLXJZGXE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/web-react/popover-surface.tsx","../src/web-react/picker-presentation.ts","../src/web-react/use-pending.ts","../src/web-react/model-picker.tsx","../src/web-react/control-glyphs.tsx","../src/web-react/effort-picker.tsx"],"sourcesContent":["/** Portaled popover placement, nested focus, and outside-click ownership. */\nimport { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode, type RefObject } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * Keyboard + pointer model for a trigger-and-popover pair, dependency-free.\n * Outside-mousedown and Escape both close; Escape also returns focus to the\n * trigger so keyboard users aren't dropped at the top of the document. The\n * returned `triggerProps` carry the ARIA contract (`aria-haspopup`/\n * `aria-expanded`); spread them onto the trigger button.\n *\n * `panelRef` belongs to the popover panel and MUST be wired when the panel is\n * rendered through {@link PopoverSurface}: a portaled panel is not inside\n * `containerRef`, so a container-only outside test reads every click on the\n * menu's own rows as an outside click and closes before the row's handler runs.\n */\nexport function usePopover(open: boolean, setOpen: (open: boolean) => void) {\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const panelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!open) return\n function onMouseDown(e: MouseEvent) {\n const target = e.target as Node\n if (containerRef.current?.contains(target)) return\n const panel = panelRef.current\n if (panel?.contains(target)) return\n // A popover opened FROM this one portals as a SIBLING at body level, so\n // `contains` cannot see it and a click on its rows would read as outside.\n // Surfaces stamp their ancestor chain, so descendancy survives the portal.\n const ownPath = panel?.getAttribute(POPOVER_SURFACE_ATTR)\n const hitPath =\n target instanceof Element\n ? target.closest(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n : null\n if (ownPath && hitPath && (hitPath === ownPath || hitPath.startsWith(`${ownPath}${POPOVER_PATH_SEPARATOR}`))) return\n setOpen(false)\n }\n function onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && !e.defaultPrevented) {\n const ownPath = panelRef.current?.getAttribute(POPOVER_SURFACE_ATTR)\n const focusedPath = document.activeElement?.closest(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n if (ownPath && focusedPath?.startsWith(`${ownPath}${POPOVER_PATH_SEPARATOR}`)) return\n e.preventDefault()\n setOpen(false)\n triggerRef.current?.focus()\n }\n }\n document.addEventListener('mousedown', onMouseDown)\n document.addEventListener('keydown', onKeyDown)\n return () => {\n document.removeEventListener('mousedown', onMouseDown)\n document.removeEventListener('keydown', onKeyDown)\n }\n }, [open, setOpen])\n\n return {\n containerRef,\n triggerRef,\n panelRef,\n triggerProps: {\n ref: triggerRef,\n 'aria-haspopup': true as const,\n 'aria-expanded': open,\n },\n }\n}\n\n// ── PopoverSurface ────────────────────────────────────────────────────────\n\n/** Distance between the trigger and the panel it opens. */\nconst POPOVER_GAP = 8\n/** Minimum distance the panel keeps from every viewport edge. */\nconst POPOVER_VIEWPORT_MARGIN = 16\n/** Floor for the computed max-height, so a cramped side still shows rows\n * rather than collapsing to a sliver the user cannot read. */\nconst POPOVER_MIN_HEIGHT = 120\n\n/**\n * Marks the portaled panel in the DOM. Products and audits (see\n * `playground/scripts/popover-hit-test.mjs`) select on this rather than on a\n * Tailwind class, which is presentation and free to change.\n *\n * Its VALUE is the surface's ancestor path (`outer/inner`), which is what\n * restores \"is this click inside my popover\" after the portal flattens two\n * nested panels into two siblings of `<body>`.\n */\nexport const POPOVER_SURFACE_ATTR = 'data-agent-app-popover'\nconst POPOVER_PATH_SEPARATOR = '/'\n\n/**\n * `PopoverSurface` is now mounted (closed) inside every server-rendered\n * composer, so its hooks run on the server once per composer per request.\n * React 18 logs \"useLayoutEffect does nothing on the server\" for that; React 19\n * does not (measured silent on react-dom 19.2.8). The peer floor is `react >=18`,\n * so bind the synchronous hook only where there is a DOM and the effect hook\n * elsewhere — placement never runs on the server either way.\n */\nexport const useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nexport interface PopoverSurfaceProps {\n open: boolean\n /** The trigger the panel anchors to — `usePopover`'s `triggerRef`. */\n triggerRef: RefObject<HTMLElement | null>\n /** `usePopover`'s `panelRef`; also what the outside-click test consults. */\n panelRef: RefObject<HTMLDivElement | null>\n /** Presentation classes. Placement and elevation are owned here — a caller\n * must not pass `absolute`/`fixed`/`top-*`/`bottom-*`/`z-*`. */\n className?: string\n role?: string\n id?: string\n 'aria-label'?: string\n /** Make the panel at least as wide as its trigger. A portaled panel has no\n * `w-full` to inherit — the trigger is no longer its offset parent — so a\n * menu that used to stretch to a full-width trigger declares it here. */\n matchTriggerWidth?: boolean\n /** Preferred side. `above` suits controls docked at the bottom of a composer;\n * `below` suits headers, rows, and rails. Either flips when the other side has more room. */\n side?: 'above' | 'below'\n /** Which trigger edge the panel lines up with. `end` keeps a row's trailing menu over the row. */\n align?: 'start' | 'end'\n /** Opt in to remeasurement when asynchronous or filtered content changes. */\n contentKey?: unknown\n children: ReactNode\n}\n\n/**\n * The floating panel every canonical picker opens.\n *\n * It renders through a PORTAL to `document.body` and anchors itself to the\n * trigger in viewport coordinates, because an in-place `absolute` panel's\n * visibility is decided by markup this package does not own. Measured in\n * production: the shipped chat composer docks these controls inside a\n * horizontally scrolling rail (`overflow-x-auto`), and a scroll container\n * clips every positioned descendant whose containing block sits inside it —\n * so a correct 420x457 menu with correct coordinates painted zero pixels and\n * could not be clicked. An ancestor `transform`/`filter`/`contain` would trap\n * it the same way through the stacking context instead of the clip. Leaving\n * the DOM subtree is the only placement a host cannot re-break.\n *\n * Placement prefers ABOVE the trigger (these controls dock at the bottom of a\n * composer), flips below when there is more room there, clamps horizontally\n * into the viewport, and caps its own height to the space on the chosen side.\n * The panel is `visibility: hidden` for the measure pass so it never paints at\n * the pre-placement origin.\n */\nexport function PopoverSurface({\n open,\n triggerRef,\n panelRef,\n className,\n role,\n id,\n 'aria-label': ariaLabel,\n matchTriggerWidth,\n side = 'above',\n align = 'start',\n contentKey,\n children,\n}: PopoverSurfaceProps) {\n const surfaceId = useId()\n const [style, setStyle] = useState<CSSProperties>(() => ({\n position: 'fixed',\n top: 0,\n left: 0,\n visibility: 'hidden',\n }))\n\n const place = useCallback(() => {\n const trigger = triggerRef.current\n const panel = panelRef.current\n if (!trigger || !panel) return\n const anchor = trigger.getBoundingClientRect()\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n\n // `scrollHeight` is the panel's CONTENT height, so it does not feed back\n // on the `maxHeight` this function just applied — reading `offsetHeight`\n // here would measure the previous pass's clamp and ratchet the panel\n // smaller on every scroll event.\n const contentHeight = panel.scrollHeight\n const panelWidth = panel.offsetWidth\n\n const roomAbove = anchor.top - POPOVER_GAP - POPOVER_VIEWPORT_MARGIN\n const roomBelow = viewportHeight - anchor.bottom - POPOVER_GAP - POPOVER_VIEWPORT_MARGIN\n const above = side === 'above'\n ? contentHeight <= roomAbove || roomAbove >= roomBelow\n : !(contentHeight <= roomBelow || roomBelow >= roomAbove)\n const maxHeight = Math.max(POPOVER_MIN_HEIGHT, above ? roomAbove : roomBelow)\n const height = Math.min(contentHeight, maxHeight)\n\n const top = above ? Math.max(POPOVER_VIEWPORT_MARGIN, anchor.top - POPOVER_GAP - height) : anchor.bottom + POPOVER_GAP\n const rightBound = Math.max(POPOVER_VIEWPORT_MARGIN, viewportWidth - panelWidth - POPOVER_VIEWPORT_MARGIN)\n const preferredLeft = align === 'end' ? anchor.right - panelWidth : anchor.left\n const left = Math.min(Math.max(POPOVER_VIEWPORT_MARGIN, preferredLeft), rightBound)\n\n setStyle({\n position: 'fixed',\n top,\n left,\n maxHeight,\n visibility: 'visible',\n ...(matchTriggerWidth ? { minWidth: anchor.width } : {}),\n })\n }, [align, matchTriggerWidth, panelRef, side, triggerRef])\n\n // Layout effect: placement is resolved before the browser paints, so the\n // panel is never seen at the origin it mounts at.\n useBrowserLayoutEffect(() => {\n if (!open) {\n setStyle({ position: 'fixed', top: 0, left: 0, visibility: 'hidden' })\n return\n }\n place()\n }, [open, place, contentKey])\n\n useEffect(() => {\n if (!open) return\n const onViewportChange = () => place()\n // `capture` so the rail's OWN scroll re-anchors the panel — a scroll inside\n // an ancestor does not bubble to window.\n window.addEventListener('scroll', onViewportChange, true)\n window.addEventListener('resize', onViewportChange)\n return () => {\n window.removeEventListener('scroll', onViewportChange, true)\n window.removeEventListener('resize', onViewportChange)\n }\n }, [open, place])\n\n if (!open || typeof document === 'undefined') return null\n\n const ownerPath = triggerRef.current?.closest?.(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n const path = ownerPath ? `${ownerPath}${POPOVER_PATH_SEPARATOR}${surfaceId}` : surfaceId\n\n return createPortal(\n <div\n ref={panelRef}\n id={id}\n role={role}\n aria-label={ariaLabel}\n style={style}\n {...{ [POPOVER_SURFACE_ATTR]: path }}\n className={`z-[1000] ${className ?? ''}`}\n >\n {children}\n </div>,\n document.body,\n )\n}\n","/** Shared picker geometry, focus, and theme presentation. */\nimport { fieldPresentation, fieldSizes, fieldTouchText } from '@tangle-network/ui/presentation'\n\n/**\n * Focus treatment for a row inside a popover panel.\n *\n * The ring itself now comes from the `:focus-visible` floor in tokens.css, so\n * this no longer restates a width or a colour. What it still has to say is\n * WHERE the ring is drawn: a popover option is a full-width row inside a panel\n * that clips its own corners (`overflow-hidden rounded-xl`), and an outward\n * ring on the first or last row is clipped away by that panel. Pulling the\n * offset negative draws the same ring just inside the row instead.\n */\nexport const POPOVER_OPTION_FOCUS = 'focus-visible:[outline-offset:-2px]'\n\n/**\n * The one overlay elevation for floating surfaces — picker menus, popovers,\n * drawers, modals. Reads the theme's `--shadow-overlay` token, so every overlay\n * lifts with the same shadow and re-themes from one source. The floating\n * composer uses the quieter `shadow-raised` rung instead.\n *\n * Written as an arbitrary value rather than the preset's `shadow-overlay`\n * utility, because that utility only exists where the preset is part of the\n * Tailwind build. A host that gets its tokens through a precompiled bundle —\n * `@tangle-network/sandbox-ui` ships brand's tokens inlined, with no `@theme`\n * block surviving the compile — receives `--shadow-overlay` as a plain custom\n * property, from which no `shadow-overlay` utility can be generated, and these\n * surfaces render flat. The arbitrary form emits from the class alone and works\n * either way.\n */\nexport const OVERLAY_SHADOW = 'shadow-[var(--shadow-overlay)]'\n\n/**\n * Root geometry for a picker — the box that holds the trigger — in one place\n * because every picker in this family has to agree on it.\n *\n * Shrink-wrapping (`inline-flex`) is the default: these controls dock on a\n * composer row where an expanding pill shoves its neighbours around. A STACKED\n * panel wants the opposite — the compact `AgentSessionControls` gear popover\n * lays its controls out in a column, and a shrink-wrapped root there makes a\n * trigger's own `w-full` a no-op, since it fills a box the trigger itself\n * sized. That is what left Agent backend short of the panel edge and Thinking\n * narrower still.\n *\n * The panel is portaled ({@link PopoverSurface}), so widening the root widens\n * the TRIGGER only. A menu that should follow it declares `matchTriggerWidth`.\n */\nexport function pickerRootClass(fullWidth: boolean): string {\n return `relative ${fullWidth ? 'flex w-full' : 'inline-flex'}`\n}\n\n/**\n * How a picker's TRIGGER is drawn. The menu it opens is the same either way.\n *\n * - `chip` (default): the 32px bordered pill — `rounded-full border\n * border-border bg-card font-medium`, on the composer row's height.\n * - `quiet`: a 32px borderless text button (the control scale's sm, the\n * composer row's one height) — muted label, small glyph, a\n * surface fill on hover and while the menu is open, nothing else. For a\n * composer whose card already draws the border: three pills docked under\n * the input there read as three more cards, not as the input's controls.\n * - `field`: a full-width form field — the same height, radius, border,\n * well, and focus treatment as a text input at `--control-height`. For a\n * settings form, where a pill among inputs reads as a different control.\n */\nexport type PickerVariant = 'chip' | 'quiet' | 'field'\n\n/**\n * Trigger classes for a `field` picker: `@tangle-network/ui`'s own field\n * presentation and `md` field size, the classes its `Input` and `SelectTrigger`\n * draw, so a model, harness or timezone selector sits in a form as one more\n * field — the same well on every plane, the same border, hover and focus halo.\n */\nexport function fieldPickerTriggerClass({ interactive = true }: { interactive?: boolean } = {}): string {\n return `${fieldPresentation} ${fieldSizes.md} ${fieldTouchText} inline-flex w-full min-w-0 items-center justify-between gap-2 whitespace-nowrap border text-left font-normal text-foreground disabled:cursor-not-allowed disabled:opacity-50 ${\n interactive ? 'data-[state=open]:border-[var(--ix-hover-border)] data-[state=open]:shadow-[var(--ix-after)]' : 'cursor-default'}`\n}\n\n/** The chip trigger: a fixed 32px height (no vertical padding, so the 20px\n * line and the border cannot push it to 34px). A full-width EffortPicker in a\n * settings panel keeps the 36px field row instead. */\nexport const CHIP_PICKER_TRIGGER =\n 'inline-flex h-[var(--control-height-sm,2rem)] items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 text-sm font-medium text-foreground transition'\n\n/** The quiet trigger at rest: geometry, type, and keyboard focus. */\nconst QUIET_PICKER_TRIGGER_BASE =\n 'inline-flex h-[var(--control-height-sm,2rem)] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md bg-transparent px-2 text-sm font-normal text-muted-foreground transition focus:outline-none focus-visible:ring-2 focus-visible:ring-ring'\n\n/** The fills a quiet trigger shows on hover and while its menu is open — the\n * only two states it draws. Reads `data-state`, which every picker trigger\n * in this family stamps. */\nconst QUIET_PICKER_TRIGGER_INTERACTIVE =\n 'hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground'\n\n/**\n * Trigger classes for a `quiet` picker. Height, padding, radius, and type are\n * fixed here so the triggers on one composer row agree; a caller adds only\n * width (`w-full`) and alignment (`justify-between`).\n *\n * The focus ring is drawn on the element rather than left to the tokens.css\n * `:focus-visible` floor: a quiet trigger sits beside the composer's own action\n * buttons (attach, dictate, send), which draw `focus-visible:ring-2\n * focus-visible:ring-ring`, and a row whose controls answer keyboard focus two\n * different ways reads as two families.\n *\n * `interactive: false` is for a PINNED control (see `HarnessPicker`'s\n * `lockReason`): it keeps the resting treatment and draws no hover or open\n * fill, because a fill promises a menu the control will not open.\n */\nexport function quietPickerTriggerClass({ interactive = true }: { interactive?: boolean } = {}): string {\n return interactive\n ? `${QUIET_PICKER_TRIGGER_BASE} ${QUIET_PICKER_TRIGGER_INTERACTIVE}`\n : `${QUIET_PICKER_TRIGGER_BASE} cursor-default`\n}\n","import { useEffect, useRef, useState } from 'react'\n\n/**\n * Guard an async action against double-submit. `run` ignores re-entrant calls\n * while a promise is in flight and flips `pending` so the caller can disable\n * the control — the fix for double-charge / double-approve on a slow network.\n * Settles (success or throw) before clearing, and no-ops state updates after\n * unmount.\n */\nexport function usePending(): { pending: boolean; run: (action: () => void | Promise<void>) => void } {\n const [pending, setPending] = useState(false)\n const inFlight = useRef(false)\n const mounted = useRef(true)\n useEffect(() => {\n mounted.current = true\n return () => {\n mounted.current = false\n }\n }, [])\n const run = (action: () => void | Promise<void>) => {\n if (inFlight.current) return\n let result: void | Promise<void>\n try {\n result = action()\n } catch {\n return\n }\n if (!(result instanceof Promise)) return\n inFlight.current = true\n setPending(true)\n void result.finally(() => {\n inFlight.current = false\n if (mounted.current) setPending(false)\n })\n }\n return { pending, run }\n}\n","import { bindSearchPickerNavigation } from './focus-navigation'\n/** Searchable catalog selection and truthful model price presentation. */\nimport { useCallback, useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { ProviderLogo } from './provider-logo'\nimport { StatusPill } from '@tangle-network/ui/primitives'\nimport { MAX_RECOMMENDED_MODELS, sortModelsByFreshness, type CatalogModel } from '../runtime/model-catalog'\nimport { ChevronDown, CheckGlyph, SearchGlyph, SparkleGlyph } from './control-glyphs'\nimport { usePopover, PopoverSurface } from './popover-surface'\nimport { CHIP_PICKER_TRIGGER, OVERLAY_SHADOW, POPOVER_OPTION_FOCUS, fieldPickerTriggerClass, quietPickerTriggerClass, type PickerVariant } from './picker-presentation'\n\nexport interface ModelPickerProps {\n /** Controlled, opaque saved id. Never replaced merely because the catalogue omits it. */\n value: string\n onChange: (id: string) => void\n /** Catalogue models — from `GET`ing the app's catalogue route (see\n * `runtime/model-catalog`), plus any product-specific entries appended. */\n models: CatalogModel[]\n /** Host-owned request state. Loading takes precedence over error and results. */\n loading?: boolean\n /** Host-safe failure message. null/undefined means no failure; even '' is an error. */\n error?: string | null\n /** Ask the host to retry. The host owns fetching, loading, errors and cancellation. */\n onRetry?: () => void\n /** Disable the trigger and close an open picker; does not change the saved value. */\n disabled?: boolean\n /** Associations belong to the trigger button, not its surrounding div. */\n id?: string\n 'aria-label'?: string\n 'aria-labelledby'?: string\n 'aria-describedby'?: string\n /** Replaces the maker mark. A distinct route host still uses ProviderLogo. */\n renderProviderBadge?: (provider: string) => ReactNode\n /** Section label for `featured` models. */\n recommendedLabel?: string\n /** Pin a labeled section to the TOP of the list (above Recommended) for the\n * models a product wants surfaced first — e.g. a tuner app's own fine-tuned\n * models (`{ label: 'Your Fine-Tuned Models', match: (m) => m.provider === 'tuner' }`).\n * Matching models are shown only in this section, not duplicated below. */\n priorityGroup?: {\n label: string\n match: (model: CatalogModel) => boolean\n }\n /** Trigger treatment — see {@link PickerVariant}. Default `chip`. */\n variant?: PickerVariant\n /** Optional accessible trigger content for a picker docked beside an editable model field. */\n triggerContent?: ReactNode\n /**\n * Offer \"no selection\" as the first row, for a setting that may defer to a\n * default chosen elsewhere. Choosing it calls `onChange('')`, and the trigger\n * shows this label while `value` is empty.\n */\n defaultOption?: { label: string }\n}\n\nfunction formatPrice(p?: string): string | undefined {\n if (!p) return undefined\n const n = Number(p)\n if (isNaN(n) || n === 0) return undefined\n const perM = n * 1_000_000\n const amount = Number.isInteger(perM) ? perM.toFixed(0) : perM.toFixed(2)\n return `$${amount}/M`\n}\n\nconst OUTPUT_UNIT_LABEL: Record<NonNullable<CatalogModel['outputPrice']>['unit'], string> = {\n image: 'image',\n second: 'sec',\n minute: 'min',\n '1k_chars': '1K chars',\n}\n\n/** Per-output price in the unit that output comes in. Undefined when the catalogue has no price. */\nexport function formatModelPrice(model: Pick<CatalogModel, 'pricing' | 'outputPrice'>): string | undefined {\n const media = model.outputPrice\n if (media && Number.isFinite(media.usd) && media.usd > 0) {\n const amount = media.usd >= 1 ? media.usd.toFixed(2) : media.usd >= 0.01 ? String(Number(media.usd.toFixed(3))) : media.usd.toPrecision(2)\n return `$${amount}/${OUTPUT_UNIT_LABEL[media.unit]}`\n }\n return formatPrice(model.pricing?.prompt)\n}\n\nfunction formatContext(len?: number): string | undefined {\n if (!len) return undefined\n if (len >= 1_000_000) return `${(len / 1_000_000).toFixed(1)}M ctx`\n if (len >= 1_000) return `${Math.round(len / 1_000)}K ctx`\n return `${len} ctx`\n}\n\nfunction ModelMarks({ model, size, renderProviderBadge }: {\n model: Pick<CatalogModel, 'provider' | 'maker' | 'servedBy'>\n size: number\n renderProviderBadge?: (provider: string) => ReactNode\n}) {\n // Maker wins over the family. A fal-hosted Veo row shows Google, not fal.\n // A different route host is a second mark, so Together stays visible on GLM.\n const brand = model.maker?.trim() || model.provider\n const host = model.servedBy?.trim()\n const primary = renderProviderBadge ? renderProviderBadge(brand) : <ProviderLogo provider={brand} size={size} />\n if (!host || host.toLowerCase() === brand.toLowerCase()) return primary\n return <span className=\"inline-flex items-center gap-0.5\">{primary}<ProviderLogo provider={host} size={size} /></span>\n}\n\nfunction SectionHeader({ children }: { children: ReactNode }) {\n return (\n <div className=\"px-3 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n {children}\n </div>\n )\n}\n\nfunction ModelRow({\n model,\n selected,\n onSelect,\n renderProviderBadge,\n}: {\n model: CatalogModel\n selected: boolean\n onSelect: () => void\n renderProviderBadge?: (provider: string) => ReactNode\n}) {\n const price = formatModelPrice(model)\n const ctx = formatContext(model.contextLength)\n const media = model.output && model.output !== 'text'\n const thumb = media && (model.output === 'image' || model.output === 'video') ? model.previewUrl : undefined\n const unavailable = model.status === 'unavailable'\n const flagged = unavailable || model.status === 'limited'\n // A flagged model keeps its row and stays selectable; the warning tone, not a\n // grey sentence, says it cannot run as asked.\n const capability = model.capability ?? (flagged ? model.statusReason : undefined)\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n title={`${model.name} (${model.id})${model.servedBy ? ` · served by ${model.servedBy}` : ''}`}\n className={`flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${\n selected ? 'bg-primary/10 font-medium' : 'hover:bg-accent'\n }`}\n >\n {thumb ? (\n // A media model shows what it makes: a 40px example beside its name.\n <img src={thumb} alt=\"\" loading=\"lazy\" decoding=\"async\" data-model-preview\n className={`size-10 shrink-0 rounded-md border border-border object-cover${unavailable ? ' opacity-50' : ''}`} />\n ) : (\n <span className=\"shrink-0\" aria-hidden>\n <ModelMarks model={model} size={16} renderProviderBadge={renderProviderBadge} />\n </span>\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {thumb && (\n <span className=\"shrink-0\" aria-hidden>\n <ModelMarks model={model} size={14} renderProviderBadge={renderProviderBadge} />\n </span>\n )}\n <span className={`min-w-0 break-words [overflow-wrap:anywhere]${unavailable ? ' text-muted-foreground' : ''}`}>{model.name}</span>\n {flagged && (\n <StatusPill tone=\"warning\" size=\"sm\" className=\"shrink-0\" title={model.statusReason} data-model-status={model.status}>\n {unavailable ? 'Unavailable' : 'Limited'}\n </StatusPill>\n )}\n </span>\n {capability && (\n <span className=\"mt-0.5 block truncate text-xs font-normal text-muted-foreground\" data-model-capability>{capability}</span>\n )}\n {(ctx || price || (!media && !model.supportsTools)) && (\n <span className=\"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs font-normal text-muted-foreground\">\n {!media && !model.supportsTools && <span className=\"rounded bg-secondary px-1.5 py-0.5\">no tools</span>}\n {!media && ctx && <span>{ctx}</span>}\n {price && <span data-model-price>{price}</span>}\n </span>\n )}\n </span>\n {selected && <CheckGlyph className=\"h-3.5 w-3.5 shrink-0 text-primary\" />}\n </button>\n )\n}\n\n/** Canonical picker (docs/ui-picker-canon.md). The host owns fetch, retry, and the saved id. */\nexport function ModelPicker({\n value, onChange, models, loading = false, error, onRetry, disabled = false,\n id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy,\n renderProviderBadge, recommendedLabel = 'Recommended', priorityGroup,\n variant = 'chip', triggerContent, defaultOption,\n}: ModelPickerProps) {\n const [open, setOpen] = useState(false)\n const [query, setQuery] = useState('')\n const [showAll, setShowAll] = useState(false)\n const changeOpen = useCallback((next: boolean) => {\n setOpen(next && !disabled)\n if (!next) {\n setQuery('')\n setShowAll(false)\n }\n }, [disabled])\n const expanded = open && !disabled\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(expanded, changeOpen)\n const inputRef = useRef<HTMLInputElement>(null)\n const panelId = useId()\n const valueId = useId()\n const unavailable = error != null\n const sortedModels = useMemo(() => sortModelsByFreshness(models), [models])\n const contentKey = useMemo(() => ({ query, showAll, loading, error, models, value, priorityGroup }),\n [query, showAll, loading, error, models, value, priorityGroup])\n\n useEffect(() => {\n if (disabled) changeOpen(false)\n }, [disabled, changeOpen])\n\n useEffect(() => {\n if (!expanded) return\n // The portal's placement may commit a second render. Focus after that too.\n const focus = () => inputRef.current?.focus()\n focus()\n if (typeof requestAnimationFrame !== 'function') return\n const frame = requestAnimationFrame(focus)\n return () => cancelAnimationFrame(frame)\n }, [expanded])\n\n useEffect(() => {\n const panel = panelRef.current\n if (!expanded || !panel) return\n return bindSearchPickerNavigation({\n panel, input: () => inputRef.current, trigger: () => triggerRef.current,\n onClose: () => changeOpen(false), buttonSelector: 'button:not(:disabled)',\n homeEnd: true,\n })\n }, [expanded, changeOpen, panelRef, triggerRef])\n\n const selected = sortedModels.find((m) => m.id === value)\n const selectedLabel = selected?.name ?? value\n const describeValue = triggerContent != null || Boolean(id || ariaLabel || ariaLabelledBy)\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase()\n if (!q) return null\n return sortedModels.filter(\n (m) =>\n m.id.toLowerCase().includes(q) ||\n m.name.toLowerCase().includes(q) ||\n (m.description?.toLowerCase() ?? '').includes(q) ||\n m.provider.toLowerCase().includes(q) ||\n (m.maker?.toLowerCase() ?? '').includes(q) ||\n (m.servedBy?.toLowerCase() ?? '').includes(q),\n )\n }, [sortedModels, query])\n\n const sections = useMemo(() => {\n const isPriority = priorityGroup ? (m: CatalogModel) => priorityGroup.match(m) : () => false\n const priority = priorityGroup ? sortedModels.filter(isPriority) : []\n const featured = sortedModels.filter((model) => model.featured && !isPriority(model))\n const recommended = featured.slice(0, MAX_RECOMMENDED_MODELS)\n const visibleIds = new Set([...priority, ...recommended].map((model) => model.id))\n const currentSelection = sortedModels.find((model) => model.id === value && !visibleIds.has(model.id))\n const byProvider: Array<{ provider: string; items: CatalogModel[] }> = []\n for (const model of sortedModels) {\n if (visibleIds.has(model.id)) continue\n const last = byProvider[byProvider.length - 1]\n if (last && last.provider === model.provider) last.items.push(model)\n else byProvider.push({ provider: model.provider, items: [model] })\n }\n return { priority, recommended, currentSelection, byProvider }\n }, [sortedModels, priorityGroup, value])\n\n const select = (modelId: string) => {\n if (disabled || (modelId && (loading || unavailable))) return\n changeOpen(false)\n triggerRef.current?.focus()\n onChange(modelId)\n }\n const row = (model: CatalogModel) => (\n <ModelRow key={model.id} model={model} selected={model.id === value} onSelect={() => select(model.id)} renderProviderBadge={renderProviderBadge} />\n )\n\n return (\n <div ref={containerRef} className={variant === 'field' ? 'relative flex w-full min-w-0' : 'relative inline-flex min-w-0 max-w-full'}>\n <button\n type=\"button\"\n {...triggerProps}\n id={id}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[ariaDescribedBy, describeValue && value ? valueId : undefined].filter(Boolean).join(' ') || undefined}\n aria-haspopup=\"dialog\"\n aria-controls={expanded ? panelId : undefined}\n onClick={() => changeOpen(!expanded)}\n onKeyDown={(event) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n changeOpen(true)\n }\n }}\n title={selected ? `${selectedLabel}${selected.servedBy ? ` · served by ${selected.servedBy}` : ''}` : (selectedLabel || defaultOption?.label || 'Select model')}\n data-state={expanded ? 'open' : 'closed'}\n className={`${\n variant === 'field'\n ? fieldPickerTriggerClass({ interactive: !disabled })\n : variant === 'quiet'\n ? quietPickerTriggerClass({ interactive: !disabled })\n : `${CHIP_PICKER_TRIGGER} ${disabled ? '' : 'hover:bg-accent'}`\n } max-w-full disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {triggerContent ?? <span className={variant === 'field' ? 'flex min-w-0 flex-1 items-center gap-2' : 'contents'}>\n <span className=\"shrink-0\" aria-hidden>\n {selected ? <ModelMarks model={selected} size={16} renderProviderBadge={renderProviderBadge} /> : <SparkleGlyph className=\"h-3.5 w-3.5 text-muted-foreground\" />}\n </span>\n <span className={variant === 'field' ? `min-w-0 flex-1 truncate ${value ? '' : 'text-muted-foreground'}` : 'max-w-[160px] truncate'}>\n {selectedLabel || defaultOption?.label || 'Select model'}</span>\n </span>}\n <ChevronDown className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </button>\n {describeValue && value && <span id={valueId} className=\"sr-only\">Selected model: {selectedLabel}</span>}\n\n <PopoverSurface\n open={expanded}\n id={panelId}\n role=\"dialog\"\n aria-label=\"Choose a model\"\n contentKey={contentKey}\n triggerRef={triggerRef}\n panelRef={panelRef}\n matchTriggerWidth={variant === 'field'}\n side={variant === 'field' ? 'below' : undefined}\n className={`flex w-[420px] max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-card-edge bg-popover text-foreground ${OVERLAY_SHADOW}`}\n >\n <div className=\"shrink-0 border-b border-border px-3 py-2\">\n <div className=\"flex items-center gap-2 rounded-lg border border-strong bg-background px-3 py-2 focus-within:ring-2 focus-within:ring-ring\">\n <SearchGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n placeholder=\"Search models...\"\n aria-label=\"Search all models\"\n className=\"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n </div>\n {/* min-h-0 lets results absorb the surface's viewport height limit. */}\n <div className=\"max-h-[520px] min-h-0 overflow-y-auto p-1 pb-2\">\n {defaultOption && !query.trim() && (\n <button\n type=\"button\"\n onClick={() => select('')}\n aria-pressed={!value}\n className={`flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${\n value ? 'hover:bg-accent' : 'bg-primary/10 font-medium'\n }`}\n >\n <SparkleGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"min-w-0 flex-1\">{defaultOption.label}</span>\n {!value && <CheckGlyph className=\"h-3.5 w-3.5 shrink-0 text-primary\" />}\n </button>\n )}\n {value && !selected && (\n <div className=\"mx-2 mb-1 mt-2 rounded-lg bg-secondary px-3 py-2 text-sm\">\n <p className=\"text-xs font-medium text-muted-foreground\">Saved model</p>\n <p className=\"break-words [overflow-wrap:anywhere]\">{value}</p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {loading || unavailable ? 'Your saved selection is unchanged.' : 'Not in this catalogue. Your saved selection is unchanged.'}\n </p>\n </div>\n )}\n {loading ? (\n <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">Loading models...</div>\n ) : unavailable ? (\n <div className=\"px-3 py-4 text-sm\">\n <div role=\"alert\">\n <p className=\"font-medium\">Model catalogue unavailable</p>\n <p className=\"mt-1 break-words text-muted-foreground [overflow-wrap:anywhere]\">{error || 'The catalogue could not be loaded.'}</p>\n </div>\n {onRetry && <button type=\"button\" className={`mt-3 rounded-md border border-border bg-card px-3 py-2 font-medium hover:bg-accent ${POPOVER_OPTION_FOCUS}`}\n onClick={() => {\n // Retry may remove this button synchronously. Keep focus on\n // the stable search input while the host updates its state.\n inputRef.current?.focus()\n onRetry()\n }}>Retry</button>}\n </div>\n ) : models.length === 0 ? (\n <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models available</div>\n ) : filtered ? (\n <>\n {filtered.length === 0 && <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models match your search</div>}\n {filtered.map(row)}\n </>\n ) : (\n <>\n {priorityGroup && sections.priority.length > 0 && <>\n <SectionHeader>{priorityGroup.label}</SectionHeader>\n {sections.priority.map(row)}\n </>}\n {sections.currentSelection && !showAll && <>\n <SectionHeader>Selected model</SectionHeader>\n {row(sections.currentSelection)}\n </>}\n {sections.recommended.length > 0 && <>\n <SectionHeader>{recommendedLabel}</SectionHeader>\n {sections.recommended.map(row)}\n </>}\n {sections.recommended.length === 0 && sections.priority.length === 0 && !sections.currentSelection && (\n <div className=\"px-3 py-3 text-sm text-muted-foreground\">Search or browse all models</div>\n )}\n {sections.byProvider.length > 0 && <button\n type=\"button\"\n aria-expanded={showAll}\n onClick={() => setShowAll(!showAll)}\n className={`mt-2 w-full rounded-md px-3 py-2 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground ${POPOVER_OPTION_FOCUS}`}\n >{showAll ? 'Hide older models' : 'Browse all models'}</button>}\n {showAll && sections.byProvider.map((group) => (\n <div key={group.provider}>\n <SectionHeader>{group.provider}</SectionHeader>\n {group.items.map(row)}\n </div>\n ))}\n </>\n )}\n </div>\n </PopoverSurface>\n </div>\n )\n}\n","/** Inline glyphs shared by chat-shell pickers. */\nexport function ChevronDown({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n )\n}\n\nexport function SearchGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <path d=\"m21 21-4.3-4.3\" />\n </svg>\n )\n}\n\nexport function SparkleGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M12 3v3m0 12v3M3 12h3m12 0h3M5.6 5.6l2.1 2.1m8.6 8.6 2.1 2.1m0-12.8-2.1 2.1M7.7 16.3l-2.1 2.1\" />\n </svg>\n )\n}\n\n/** lucide `brain` (v1.27) inlined — `/web-react` ships no icon-library\n * dependency, so the thinking glyph follows the same pattern as the rest of\n * this set. */\nexport function BrainGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M12 18V5\" />\n <path d=\"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4\" />\n <path d=\"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5\" />\n <path d=\"M17.997 5.125a4 4 0 0 1 2.526 5.77\" />\n <path d=\"M18 18a4 4 0 0 0 2-7.464\" />\n <path d=\"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517\" />\n <path d=\"M6 18a4 4 0 0 1-2-7.464\" />\n <path d=\"M6.003 5.125a4 4 0 0 0-2.526 5.77\" />\n </svg>\n )\n}\n\n/** lucide `check` — the selected-row mark in the picker menus. */\nexport function CheckGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n )\n}\n","/** Reasoning-level selection and effort-meter presentation. */\nimport { useId, useState } from 'react'\nimport { BrainGlyph, ChevronDown, CheckGlyph } from './control-glyphs'\nimport { usePopover, PopoverSurface } from './popover-surface'\nimport { CHIP_PICKER_TRIGGER, OVERLAY_SHADOW, POPOVER_OPTION_FOCUS, pickerRootClass, fieldPickerTriggerClass, quietPickerTriggerClass, type PickerVariant } from './picker-presentation'\n\n/** One reasoning-budget level: the engine `id` is unchanged (the value the\n * product sends to the loop); only the user-facing `label` is renamed to the\n * plainer \"how hard should it think\" vocabulary from docs/product-surfaces.md.\n * `low`→Quick, `medium`→Standard, `high`→Extended. The mapping is overridable\n * via `EffortPickerProps.levels`, so a product can relabel without losing the\n * ids the runtime expects. */\nexport interface EffortLevel {\n id: string\n label: string\n}\n\n/**\n * The engine ids this package NAMES, and the word each one reads as.\n *\n * Deliberately WIDER than {@link DEFAULT_EFFORT_LEVELS}: the default list is\n * what a picker OFFERS when a product declares nothing, while this is the\n * vocabulary — the labels a named id keeps wherever it appears. The two are\n * different questions, and folding them together is what made a real engine\n * rung read as its own id: `xhigh` and `ultracode` are rungs claude-code\n * applies above `high`, so a product declaring them got \"Xhigh\" while every\n * neighbouring rung had a plain English word. Naming them here is what stops\n * each product inventing its own — the drift `effortLevelsFromIds` exists to\n * prevent. They stay OUT of the offered default because most backends do not\n * apply them, and offering a rung the backend ignores is the defect\n * `effortLevels` was added to close.\n */\nconst KNOWN_EFFORT_LABELS = {\n off: 'Off',\n low: 'Quick',\n medium: 'Standard',\n high: 'Extended',\n xhigh: 'Extra',\n ultracode: 'Ultra',\n} as const\n\nexport const DEFAULT_EFFORT_LEVELS: readonly EffortLevel[] = [\n { id: 'off', label: KNOWN_EFFORT_LABELS.off },\n { id: 'low', label: KNOWN_EFFORT_LABELS.low },\n { id: 'medium', label: KNOWN_EFFORT_LABELS.medium },\n { id: 'high', label: KNOWN_EFFORT_LABELS.high },\n]\n\n/**\n * The user-facing label for an engine level id: the canonical vocabulary when\n * the id is one this package names, otherwise the id itself made readable\n * (`auto` -> \"Auto\", `ultra-code` -> \"Ultra code\"). Never invents a depth word,\n * so an id nobody declared a label for still reads as ITSELF and never as some\n * other level.\n */\nexport function effortLevelLabel(id: string): string {\n const known = (KNOWN_EFFORT_LABELS as Record<string, string | undefined>)[id]\n if (known) return known\n const words = id.replace(/[-_]+/g, ' ').trim()\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : id\n}\n\n/**\n * Build a levels list from the engine ids a backend applies — the shape the\n * removed `ComposerAgentControls` took as `reasoning.available`, so a product\n * migrating that list has one call to make instead of a hand-written label map\n * per product (which is how \"Quick\" and \"Low\" drift apart across surfaces).\n */\nexport function effortLevelsFromIds(ids: readonly string[]): readonly EffortLevel[] {\n return ids.map((id) => ({ id, label: effortLevelLabel(id) }))\n}\n\n/**\n * The list {@link EffortPicker} RENDERS for `value` — the declared levels, plus\n * `value` itself when the declaration omits it.\n *\n * A picker cannot honestly resolve a selected value it was not given, and the\n * failure it used to take instead — fall back to the middle entry — renders the\n * session's real depth as a DIFFERENT level's name. That is exactly the defect\n * `levels` was added to prevent: the legacy adapter's `available` list excluded\n * the `auto` sentinel because the old picker injected it, so a product mapping\n * that list straight across ships a session running on `auto` labelled\n * \"Extended\". Admitting the value is not offering a new choice — it is\n * reporting the state the session is already in, and it disappears from the\n * list as soon as the user picks a declared level.\n *\n * A blank value is not admitted (there is no honest label for it); the picker\n * renders no selection instead.\n */\nexport function reconcileEffortLevels(\n value: string,\n levels: readonly EffortLevel[] = DEFAULT_EFFORT_LEVELS,\n): readonly EffortLevel[] {\n if (!value || levels.some((l) => l.id === value)) return levels\n return [{ id: value, label: effortLevelLabel(value) }, ...levels]\n}\n\n// ── effort strength meter ─────────────────────────────────────────────────\n\n/** Segments the meter draws — fixed geometry so the ladder stays tabular\n * across levels (and across the trigger and its menu rows). */\nexport const EFFORT_METER_SEGMENTS = 4\n\n/** Filled-segment opacity ladder: translucent on the left, heavy on the\n * right — the ramp carries strength even at a glance, the count carries it\n * exactly. Unfilled segments sit at a fixed ghost opacity. */\nconst EFFORT_METER_FILL_OPACITY = [0.25, 0.5, 0.75, 1] as const\nconst EFFORT_METER_GHOST_OPACITY = 0.15\n\n/** Level ids that mean \"no reasoning\" — the meter renders all-ghost. */\nconst OFF_LEVEL_IDS: ReadonlySet<string> = new Set(['off', 'none'])\n\n/**\n * Ids that name a POLICY rather than a depth: `auto` means \"let the harness and\n * model decide\", so it has no position on a strength ladder.\n *\n * Without this it lands wherever the declaration puts it and draws a filled\n * meter — measured on a product that offers `auto` first: every harness read\n * `Auto` at a FULL four bars, including `cli-base`, which has no agent to think\n * at all. A meter is a claim about how hard the run will think, and a sentinel\n * cannot make that claim.\n */\nconst UNPLACEABLE_LEVEL_IDS: ReadonlySet<string> = new Set(['auto'])\n\n/**\n * Filled-segment count for a level: 0 for off/none (or an id the levels list\n * does not carry); otherwise the level's position among the non-off choices\n * scaled onto the meter, so the ladder reads low < medium < high and the top\n * level fills the whole scale. The canonical four levels land 0 / 1 / 2 / 4.\n */\nexport function effortMeterFill(\n levelId: string,\n levels: readonly EffortLevel[] = DEFAULT_EFFORT_LEVELS,\n): number {\n if (OFF_LEVEL_IDS.has(levelId) || UNPLACEABLE_LEVEL_IDS.has(levelId)) return 0\n const active = levels.filter((l) => !OFF_LEVEL_IDS.has(l.id) && !UNPLACEABLE_LEVEL_IDS.has(l.id))\n const index = active.findIndex((l) => l.id === levelId)\n if (index < 0 || active.length === 0) return 0\n return Math.max(1, Math.floor(((index + 1) * EFFORT_METER_SEGMENTS) / active.length))\n}\n\n/**\n * The thinking-strength meter: four 12px bars, filled count = level, filled\n * opacity ramping 25→100% left to right (unfilled at a faint ghost). Purely\n * decorative — the level name is always rendered as text beside it, so the\n * meter is `aria-hidden` and adds no second accessible name.\n */\nexport function EffortMeter({ fill, className }: { fill: number; className?: string }) {\n return (\n <span aria-hidden className={`inline-flex items-center gap-[2px] ${className ?? ''}`}>\n {Array.from({ length: EFFORT_METER_SEGMENTS }, (_, i) => (\n <span\n key={i}\n className=\"h-3 w-[3px] rounded-full bg-current\"\n style={{ opacity: i < fill ? EFFORT_METER_FILL_OPACITY[i] : EFFORT_METER_GHOST_OPACITY }}\n />\n ))}\n </span>\n )\n}\n\nexport interface EffortPickerProps {\n value: string\n onChange: (id: string) => void\n /** Selectable levels (engine id + user-facing label). Defaults to the plain\n * \"Thinking\" vocabulary; override to relabel without changing the ids the\n * runtime receives.\n *\n * A list that omits the current `value` is not a rendering error the picker\n * papers over: `value` is reconciled INTO the rendered list under its own\n * name (see {@link reconcileEffortLevels}), because a control must report\n * the depth the session is running at and never some other list entry. */\n levels?: readonly EffortLevel[]\n /** Prefix shown before the active level on the pill — the \"what is this\"\n * context the bare value lacked. Default \"Thinking\". Pass '' to hide it. */\n label?: string\n /** Fill the container instead of shrink-wrapping — opt-in, default `false`;\n * see {@link pickerRootClass} for when and why. */\n fullWidth?: boolean\n /** Trigger treatment — see {@link PickerVariant}. Default `chip`. */\n variant?: PickerVariant\n /** Disable the trigger and close an open menu; does not change the value. */\n disabled?: boolean\n /** Associations belong to the trigger button, for a picker labelled by a form field. */\n id?: string\n 'aria-describedby'?: string\n}\n\n/** Thinking-budget selector pill, styled to match {@link ModelPicker}. Show\n * it only when the selected model `supportsReasoning`. \"Thinking\" is the\n * plain-English name for what was internally called \"effort\".\n *\n * The CANONICAL ecosystem effort picker — sandbox-ui's reasoning menu (inside\n * its `chat/AgentSessionControls`) is legacy and frozen. */\nexport function EffortPicker({ value, onChange, levels = DEFAULT_EFFORT_LEVELS, label = 'Thinking', fullWidth = false, variant = 'chip',\n disabled = false, id, 'aria-describedby': ariaDescribedBy }: EffortPickerProps) {\n const [requestedOpen, setOpen] = useState(false)\n const open = requestedOpen && !disabled\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen)\n const field = variant === 'field'\n const panelId = useId()\n const rendered = reconcileEffortLevels(value, levels)\n // The strength ladder is computed over the DECLARED levels only, so admitting\n // the selected value cannot shift where the declared ones sit on the meter.\n // A level the declaration does not carry has no position on that ladder, so\n // it renders with NO meter — an all-ghost meter is what `off` looks like, and\n // \"we cannot place this\" is not \"no thinking\".\n const isDeclared = (id: string) => levels.some((l) => l.id === id) && !UNPLACEABLE_LEVEL_IDS.has(id)\n const selected = rendered.find((l) => l.id === value)\n\n return (\n <div ref={containerRef} className={pickerRootClass(fullWidth || field)}>\n <button\n type=\"button\"\n {...triggerProps}\n id={id}\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-controls={open ? panelId : undefined}\n onClick={() => setOpen(!open)}\n title={label ? `${label} — how hard the agent reasons before answering` : 'Reasoning effort'}\n data-state={open ? 'open' : 'closed'}\n className={`${\n field\n ? fieldPickerTriggerClass({ interactive: !disabled })\n : variant === 'quiet'\n ? quietPickerTriggerClass()\n : fullWidth\n ? 'inline-flex min-h-[36px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent'\n : `${CHIP_PICKER_TRIGGER} shrink-0 hover:bg-accent`\n } ${fullWidth ? 'w-full' : ''}`}\n >\n <BrainGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n {/* Full width gives the label the slack, so the meter and chevron park\n on the trailing edge and the glyph stays against the text. */}\n <span className={fullWidth || field ? 'flex-1 truncate text-left' : undefined}>\n {label ? <span className=\"text-muted-foreground\">{label}: </span> : null}\n {selected ? selected.label : '—'}\n </span>\n {/* Quiet inherits the trigger's tone, so the meter is muted at rest\n and lifts with the label on hover instead of staying at full foreground. */}\n {selected && isDeclared(selected.id) && (\n <EffortMeter\n fill={effortMeterFill(selected.id, levels)}\n className={variant === 'quiet' ? 'shrink-0' : 'shrink-0 text-foreground'}\n />\n )}\n <ChevronDown className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </button>\n <PopoverSurface\n open={open}\n id={panelId}\n role=\"menu\"\n triggerRef={triggerRef}\n panelRef={panelRef}\n // A portaled panel has no `w-full` to inherit, so a full-width trigger\n // hands its measured width to the panel instead.\n matchTriggerWidth={fullWidth || field}\n side={field ? 'below' : undefined}\n className={`w-44 overflow-y-auto rounded-xl border border-card-edge bg-popover p-1 ${OVERLAY_SHADOW}`}\n >\n {rendered.map((l) => (\n <button\n key={l.id}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={l.id === value}\n onClick={() => {\n onChange(l.id)\n setOpen(false)\n }}\n className={`flex min-h-[40px] w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${\n l.id === value ? 'bg-primary/10 font-medium' : 'hover:bg-accent'\n }`}\n >\n <BrainGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate\">{l.label}</span>\n {isDeclared(l.id) && (\n <EffortMeter fill={effortMeterFill(l.id, levels)} className=\"ml-auto text-foreground\" />\n )}\n {l.id === value && (\n <CheckGlyph className={`${isDeclared(l.id) ? '' : 'ml-auto '}h-3.5 w-3.5 shrink-0 text-primary`} />\n )}\n </button>\n ))}\n </PopoverSurface>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,aAAa,WAAW,OAAO,iBAAiB,QAAQ,gBAAoE;AACrI,SAAS,oBAAoB;AA0OzB;AA5NG,SAAS,WAAW,MAAe,SAAkC;AAC1E,QAAM,eAAe,OAAuB,IAAI;AAChD,QAAM,aAAa,OAA0B,IAAI;AACjD,QAAM,WAAW,OAAuB,IAAI;AAE5C,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,aAAS,YAAY,GAAe;AAClC,YAAM,S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AEJ;","names":["useEffect","useRef","useState","useCallback","useEffect","useId","useRef","useState","jsx","jsx","jsxs","useState","useCallback","useRef","useId","useEffect","useId","useState","jsx","jsxs","useState","useId","id"]}
@@ -215,10 +215,13 @@ function buildCatalog(raw, opts) {
215
215
  const toCatalogModel = (r) => {
216
216
  const m = r.model;
217
217
  const provider = providerForModel(m);
218
+ const routeHost = normalizeProvider(m.routeability?.provider ?? "");
219
+ const servedBy = routeHost && routeHost !== "unknown" && routeHost !== provider ? routeHost : void 0;
218
220
  return {
219
221
  id: m.id,
220
222
  name: m.name ?? m.id,
221
223
  provider,
224
+ ...servedBy ? { servedBy } : {},
222
225
  description: m.description ? m.description.slice(0, 160) : void 0,
223
226
  releaseDate: r.releaseDate,
224
227
  contextLength: m.context_length,
@@ -281,4 +284,4 @@ export {
281
284
  fetchModelCatalog,
282
285
  __resetCatalogCache
283
286
  };
284
- //# sourceMappingURL=chunk-AMUXRAUO.js.map
287
+ //# sourceMappingURL=chunk-VLMXVCDQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/model-catalog.ts"],"sourcesContent":["/**\n * Model catalogue from the Tangle Router.\n *\n * Chat-capable routeable rows are deduped, ranked, and marked when they are a\n * current family. The router owns routeability. Known launch dates fill gaps\n * in its response. Every other routeable model stays searchable.\n */\n\nexport interface RouterModel {\n id: string\n name?: string\n description?: string\n release_date?: string\n released_at?: string\n _provider?: string\n provider?: string\n pricing?: { prompt?: string | null; completion?: string | null }\n context_length?: number\n architecture?: {\n modality?: string\n input_modalities?: string[]\n output_modalities?: string[]\n }\n supported_parameters?: string[]\n routeability?: {\n status?: string\n routeable?: boolean\n provider?: string\n endpoints?: {\n chat_completions?: {\n status?: string\n routeable?: boolean\n }\n }\n }\n}\n\n/** Define the structure and capabilities of a catalog item with optional pricing and feature flags */\nexport interface CatalogModel {\n id: string\n name: string\n provider: string\n /** The brand that made the model when it differs from the host in\n * `provider` (fal serves Seedance, Kling and Veo). The picker draws this\n * brand's logo when present; `provider` still groups and searches. */\n maker?: string\n /** API host when the Router serves the model through someone other than\n * `provider`. GLM 5.3 stays `zai`; Together is `servedBy`. */\n servedBy?: string\n description?: string\n /** Router-supplied or vendor-verified release date; never inferred from an id. */\n releaseDate?: string\n contextLength?: number\n pricing?: { prompt?: string; completion?: string }\n /** What one generation produces. Text when absent. */\n output?: 'text' | 'image' | 'video' | 'audio' | 'speech'\n /** USD for one unit of output, for media models: one image, one second of\n * video, one minute of audio, or 1,000 characters of speech. */\n outputPrice?: { usd: number; unit: 'image' | 'second' | 'minute' | '1k_chars' }\n /** An example of the model's output (an image, or a video poster frame). */\n previewUrl?: string\n /** One line on what the model is for, shown under its name. */\n capability?: string\n /** Whether the model can be sent now. Absent means available. A limited or\n * unavailable model stays selectable; the picker marks it in a warning tone. */\n status?: 'available' | 'limited' | 'unavailable'\n /** Why a limited or unavailable model is so, in words a person can act on. */\n statusReason?: string\n supportsTools: boolean\n supportsReasoning: boolean\n featured: boolean\n}\n\n/** Define a catalog containing models with a default ID and fetch timestamp */\nexport interface ModelCatalog {\n defaultModelId: string | null\n fetchedAt: string\n models: CatalogModel[]\n}\n\n/** Display order. Unlisted providers sort after these, alphabetically. */\nconst PROVIDER_TIER: string[] = [\n 'anthropic',\n 'openai',\n 'google',\n 'xai',\n 'deepseek',\n 'moonshot',\n 'zai',\n 'mistral',\n 'groq',\n 'nvidia',\n 'cohere',\n 'cerebras',\n]\n\n/** Router aliases that are one provider in a user-facing catalogue. */\nfunction normalizeProvider(provider: string): string {\n const normalized = provider.toLowerCase()\n if (normalized === 'moonshotai') return 'moonshot'\n if (normalized === 'z-ai') return 'zai'\n if (normalized === 'x-ai') return 'xai'\n if (normalized === 'mistralai') return 'mistral'\n return normalized\n}\n\n/** Resolve provider metadata across router response versions. */\nfunction providerForModel(model: RouterModel): string {\n const declared = model._provider ?? model.provider ?? model.routeability?.provider\n if (declared) return normalizeProvider(declared)\n\n const id = normalizeModelId(model.id).toLowerCase()\n if (/^claude-/.test(id)) return 'anthropic'\n if (/^(?:gpt-|o\\d)/.test(id)) return 'openai'\n if (/^gemini-/.test(id)) return 'google'\n if (/^grok-/.test(id)) return 'xai'\n if (/^deepseek-/.test(id)) return 'deepseek'\n if (/^kimi-/.test(id)) return 'moonshot'\n if (/^glm-/.test(id)) return 'zai'\n if (/^mistral/.test(id)) return 'mistral'\n return 'unknown'\n}\n\n/** A short, varied first screen. All other routeable entries remain searchable. */\nexport const MAX_RECOMMENDED_MODELS = 8\n\n/** Non-chat endpoints that pollute the router list (matched on normalized id). */\nconst EXCLUDED_ID = /(embedding|tts|transcribe|whisper|audio|realtime|image|lyria|sora|dall-e|moderation|content-safety|search-preview|search-api|deep-research|:batch$)/\n\n/**\n * Default families, in preference order. Each rule finds the highest-version\n * routeable model whose normalized id matches. Patterns anchor on the family\n * name and stop before specialty suffixes (codex, nano, lite, …) so the\n * mainline model wins.\n */\nconst DEFAULT_CANDIDATE_RULES: Array<{ providers: string[]; match: RegExp }> = [\n { providers: ['zai', 'z-ai'], match: /^glm-5\\.3$/ },\n { providers: ['openai'], match: /^gpt-6\\.1-sol$/ },\n { providers: ['openai'], match: /^gpt-6-astra$/ },\n { providers: ['anthropic'], match: /^claude-sonnet-[\\d-]+$/ },\n { providers: ['anthropic'], match: /^claude-opus-[\\d-]+$/ },\n { providers: ['anthropic'], match: /^claude-haiku-[\\d-]+$/ },\n { providers: ['openai'], match: /^gpt-\\d+(\\.\\d+)?$/ },\n { providers: ['openai'], match: /^gpt-\\d+(\\.\\d+)?-mini$/ },\n { providers: ['google'], match: /^gemini-[\\d.]+-pro(-preview)?$/ },\n { providers: ['google'], match: /^gemini-[\\d.]+-flash(-preview)?$/ },\n { providers: ['xai'], match: /^grok-[\\d.]+$/ },\n { providers: ['deepseek'], match: /^deepseek-(chat|v[\\d.]+(-\\w+)?)$/ },\n { providers: ['moonshotai', 'moonshot'], match: /^kimi-k[\\d.]+$/ },\n { providers: ['zai', 'z-ai'], match: /^glm-[\\d.]+$/ },\n { providers: ['mistral'], match: /^mistral-(large|medium)-?[\\d.-]*$/ },\n]\n\n/**\n * Current families are checked against the Router catalogue and live\n * completions. The 2026-09-30 probes served GPT 6.1 Sol, Astra, Gemini 3.7\n * Flash, and GLM 5.3. Opus/Sonnet 5 returned quota 503, so only their 5.5\n * successors may be featured once Router marks them routeable. DeepSeek V4.1\n * Flash and Kimi K3 remain searchable after quota/upstream failures.\n * An undated future member uses its family floor, not an invented launch date.\n */\nconst RECOMMENDED_FAMILIES: Array<{\n provider: string\n match: RegExp\n minVersion: number[]\n}> = [\n { provider: 'anthropic', match: /^claude-opus-\\d+(?:[-.]\\d+)*$/, minVersion: [5, 5] },\n { provider: 'anthropic', match: /^claude-sonnet-\\d+(?:[-.]\\d+)*$/, minVersion: [5, 5] },\n { provider: 'openai', match: /^gpt-\\d+(?:\\.\\d+)?-sol$/, minVersion: [6] },\n { provider: 'openai', match: /^gpt-\\d+(?:\\.\\d+)?-astra$/, minVersion: [6] },\n { provider: 'google', match: /^gemini-\\d+(?:\\.\\d+)?-flash(?:-preview)?$/, minVersion: [3, 5] },\n { provider: 'zai', match: /^glm-\\d+(?:\\.\\d+)?$/, minVersion: [5, 3] },\n]\n\nconst RECOMMENDATION_WINDOW_MS = 120 * 24 * 60 * 60 * 1000\n\n/** Exact launch dates from vendor announcements, checked 2026-09-30. */\nconst VERIFIED_RELEASE_DATES: Record<string, string> = {\n // https://www.anthropic.com/claude-opus-5-5\n 'claude-opus-5-5': '2026-09-22',\n // https://www.anthropic.com/claude-sonnet-5-5\n 'claude-sonnet-5-5': '2026-09-28',\n // https://developers.openai.com/api/docs/changelog\n 'gpt-6.1-sol': '2026-09-29',\n // https://openai.com/index/safety-overview-gpt-6-astra/\n 'gpt-6-astra': '2026-09-03',\n // https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-gemini-3-7-flash/\n 'gemini-3.7-flash': '2026-08-13',\n // https://z.ai/blog/glm-5.3\n 'glm-5.3': '2026-08-14',\n}\n\nfunction releaseDateFromRouter(model: RouterModel): string | undefined {\n const value = model.release_date ?? model.released_at\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}(?:T|$)/.test(value)) return undefined\n const time = Date.parse(value)\n return Number.isFinite(time) ? new Date(time).toISOString() : undefined\n}\n\n/** Families known to support tool calls even when router metadata omits it\n * (dated snapshots often lack the supported_parameters of their parent). */\nconst TOOL_CAPABLE_FAMILY = /^(claude|gpt-\\d|gpt-oss|o[134]|gemini|grok|deepseek|glm|kimi|mistral|ministral|magistral|command|nemotron|llama)/\n\n/** Strip provider prefix, :free suffix, and trailing date stamps. */\nexport function normalizeModelId(id: string): string {\n let tail = id.split('/').pop() ?? id\n tail = tail.replace(/:free$/, '')\n tail = tail.replace(/-\\d{8}$/, '')\n tail = tail.replace(/-\\d{4}-\\d{2}-\\d{2}$/, '')\n return tail\n}\n\n/** All numeric groups in a normalized id, for version comparison. */\nfunction versionOf(normId: string): number[] {\n return (normId.match(/\\d+/g) ?? []).map(Number)\n}\n\nfunction compareVersions(a: number[], b: number[]): number {\n const len = Math.max(a.length, b.length)\n for (let i = 0; i < len; i++) {\n const d = (a[i] ?? -1) - (b[i] ?? -1)\n if (d !== 0) return d\n }\n return 0\n}\n\n/**\n * Read the generation attached to a known model family.\n *\n * This deliberately does not read every number in the id. A parameter count\n * such as `gpt-oss-120b` is not newer than GPT 5.6.\n */\nfunction releaseVersion(id: string): number[] {\n const normalized = normalizeModelId(id).toLowerCase()\n const patterns = [\n /^claude-[a-z0-9]+-(\\d+(?:[.-]\\d+)*)/,\n /^gpt-(\\d+(?:\\.\\d+)*)/,\n /^o(\\d+(?:\\.\\d+)*)/,\n /^gemini-(\\d+(?:\\.\\d+)*)/,\n /^deepseek-v(\\d+(?:\\.\\d+)*)/,\n /^kimi-k(\\d+(?:\\.\\d+)*)/,\n /^glm-(\\d+(?:\\.\\d+)*)/,\n /^grok-(\\d+(?:\\.\\d+)*)/,\n /^mistral-(?:large|medium)-?(\\d+(?:[.-]\\d+)*)/,\n /^qwen-?(\\d+(?:\\.\\d+)*)/,\n /^llama-?(\\d+(?:\\.\\d+)*)/,\n ]\n for (const pattern of patterns) {\n const match = normalized.match(pattern)\n if (match?.[1]) return match[1].split(/[.-]/).map(Number)\n }\n return []\n}\n\n/**\n * Return a copy sorted for a model menu.\n *\n * Providers keep the shared display order. Within each provider, current\n * generations come first across families. Stable ids win ties with previews.\n * Callers can sort separate sections without changing `featured` or defaults.\n */\nexport function sortModelsByFreshness(models: readonly CatalogModel[]): CatalogModel[] {\n return [...models].sort((a, b) => {\n const providerA = normalizeProvider(a.provider)\n const providerB = normalizeProvider(b.provider)\n const providerOrder = providerRank(providerA) - providerRank(providerB)\n if (providerOrder !== 0) return providerOrder\n if (providerA !== providerB) return providerA.localeCompare(providerB)\n\n const generationOrder = compareVersions(releaseVersion(b.id), releaseVersion(a.id))\n if (generationOrder !== 0) return generationOrder\n\n const previewOrder = Number(/preview/i.test(a.id)) - Number(/preview/i.test(b.id))\n if (previewOrder !== 0) return previewOrder\n return a.id.localeCompare(b.id)\n })\n}\n\n/** Lower = preferred representative for an alias group. */\nfunction aliasPenalty(id: string): number {\n let p = 0\n if (id.includes('/')) p += 4\n if (/-\\d{8}$|-\\d{4}-\\d{2}-\\d{2}$/.test(id.replace(/:free$/, ''))) p += 2\n if (id.endsWith(':free')) p += 1\n return p\n}\n\nfunction providerRank(provider: string): number {\n const i = PROVIDER_TIER.indexOf(normalizeProvider(provider))\n return i === -1 ? PROVIDER_TIER.length : i\n}\n\n/**\n * Can this router entry serve a text chat turn?\n *\n * The router lists every routeable endpoint, which is not the same list a chat\n * picker should show: measured against the live catalogue (504 entries), this\n * rejects 35 — image generators, TTS voices, embedding models, and the\n * audio-IN transcription endpoints (`whisper-1`, `gpt-4o-transcribe`, …) that\n * emit text but cannot take a text prompt.\n *\n * A model whose metadata omits either modality list is KEPT. The router is the\n * source of that metadata and it is occasionally sparse; dropping a usable\n * model because a field is missing is the worse failure of the two.\n *\n * Exported because a picker needs the same answer `buildCatalog` uses — the\n * fleet had this predicate copied into a product component, where its narrower\n * spelling let the 10 transcription endpoints through.\n */\nexport function isChatCapableModel(m: RouterModel): boolean {\n const arch = m.architecture\n if (!arch?.input_modalities || !arch?.output_modalities) return true\n return arch.input_modalities.includes('text') && arch.output_modalities.includes('text')\n}\n\nconst isChatModel = isChatCapableModel\n\nfunction isRouteable(m: RouterModel): boolean {\n const routeability = m.routeability\n if (!routeability) return true\n const chatEndpoint = routeability.endpoints?.chat_completions\n if (chatEndpoint?.routeable === false) return false\n if (chatEndpoint?.status !== undefined && chatEndpoint.status !== 'routeable') return false\n if (routeability.routeable === true || routeability.status === 'routeable') return true\n if (routeability.routeable === false) return false\n return routeability.status === undefined\n}\n\n/** Find a catalogue row by direct or provider-prefixed model id. */\nexport function catalogModelForId(\n models: readonly CatalogModel[],\n requestedId: string | undefined,\n): CatalogModel | undefined {\n const requested = requestedId?.trim()\n if (!requested) return undefined\n\n const exact = models.find((model) => model.id === requested)\n if (exact) return exact\n\n const slash = requested.indexOf('/')\n const requestedProvider = slash > 0 ? normalizeProvider(requested.slice(0, slash)) : undefined\n const normalized = normalizeModelId(requested)\n return models.find((model) => {\n if (normalizeModelId(model.id) !== normalized) return false\n return requestedProvider === undefined || normalizeProvider(model.provider) === requestedProvider\n })\n}\n\n/**\n * Reconcile a persisted selection against the live catalogue.\n *\n * The returned id is always a catalogue id once the catalogue has entries.\n * This keeps a removed model from remaining selected while preserving the\n * current value during the brief empty/loading state.\n */\nexport function resolveCatalogModelId(\n models: readonly CatalogModel[],\n selectedId?: string,\n fallbackId?: string,\n): string | undefined {\n if (models.length === 0) return selectedId?.trim() || fallbackId?.trim()\n return catalogModelForId(models, selectedId)?.id\n ?? catalogModelForId(models, fallbackId)?.id\n ?? models[0]?.id\n}\n\n/**\n * Pure catalogue pipeline. `preferredDefault` (typically the MODEL_NAME env\n * var) wins when it survives filtering; otherwise the first featured model.\n */\nexport function buildCatalog(raw: RouterModel[], opts?: { preferredDefault?: string }): ModelCatalog {\n // Filter to chat-capable, routeable, non-specialty models\n const candidates = raw.filter(\n (m) =>\n m.id &&\n isRouteable(m) &&\n isChatModel(m) &&\n !EXCLUDED_ID.test(normalizeModelId(m.id)),\n )\n\n // Dedupe alias groups (dated snapshots, provider prefixes, :free variants).\n // Within a group, merge metadata so the representative keeps the richest\n // supported_parameters claim (snapshots often omit what the parent lists).\n const groups = new Map<string, RouterModel[]>()\n for (const m of candidates) {\n const key = `${providerForModel(m)}::${normalizeModelId(m.id)}`\n const g = groups.get(key)\n if (g) g.push(m)\n else groups.set(key, [m])\n }\n\n const reps: Array<{ model: RouterModel; normId: string; mergedParams: Set<string>; releaseDate?: string }> = []\n for (const group of groups.values()) {\n group.sort((a, b) => aliasPenalty(a.id) - aliasPenalty(b.id) || a.id.length - b.id.length)\n const rep = group[0]!\n const mergedParams = new Set<string>(group.flatMap((m) => m.supported_parameters ?? []))\n const verifiedDate = VERIFIED_RELEASE_DATES[normalizeModelId(rep.id)]\n const releaseDate = group.map(releaseDateFromRouter).find((date) => date !== undefined) ??\n (verifiedDate ? new Date(verifiedDate).toISOString() : undefined)\n reps.push({ model: rep, normId: normalizeModelId(rep.id), mergedParams, releaseDate })\n }\n\n // Resolve the default independently from menu recommendations.\n const defaultCandidateIds: string[] = []\n for (const rule of DEFAULT_CANDIDATE_RULES) {\n const matches = reps.filter(\n (r) =>\n rule.providers.map(normalizeProvider).includes(providerForModel(r.model)) &&\n rule.match.test(r.normId) &&\n !defaultCandidateIds.includes(r.model.id),\n )\n if (!matches.length) continue\n matches.sort(\n (a, b) =>\n compareVersions(versionOf(b.normId), versionOf(a.normId)) ||\n Number(a.normId.includes('preview')) - Number(b.normId.includes('preview')) ||\n a.model.id.length - b.model.id.length,\n )\n defaultCandidateIds.push(matches[0]!.model.id)\n }\n\n const toCatalogModel = (r: (typeof reps)[number]): CatalogModel => {\n const m = r.model\n const provider = providerForModel(m)\n const routeHost = normalizeProvider(m.routeability?.provider ?? '')\n const servedBy = routeHost && routeHost !== 'unknown' && routeHost !== provider ? routeHost : undefined\n return {\n id: m.id,\n name: m.name ?? m.id,\n provider,\n ...(servedBy ? { servedBy } : {}),\n description: m.description ? m.description.slice(0, 160) : undefined,\n releaseDate: r.releaseDate,\n contextLength: m.context_length,\n pricing:\n m.pricing?.prompt || m.pricing?.completion\n ? { prompt: m.pricing.prompt ?? undefined, completion: m.pricing.completion ?? undefined }\n : undefined,\n supportsTools: r.mergedParams.has('tools') || TOOL_CAPABLE_FAMILY.test(r.normId),\n supportsReasoning: r.mergedParams.has('reasoning') || r.mergedParams.has('include_reasoning'),\n featured: false,\n }\n }\n\n // Family rules retain the intentional default preference. Display order is\n // independent: every catalogue consumer gets provider-grouped freshness,\n // even when it does not render ModelPicker.\n const defaultCandidatesInRuleOrder = defaultCandidateIds\n .map((id) => reps.find((r) => r.model.id === id)!)\n .map(toCatalogModel)\n const sorted = sortModelsByFreshness(reps.map(toCatalogModel))\n const recommendedIds = new Set<string>()\n const recentSince = Date.now() - RECOMMENDATION_WINDOW_MS\n for (const family of RECOMMENDED_FAMILIES) {\n const current = sorted.find((model) =>\n normalizeProvider(model.provider) === family.provider &&\n family.match.test(normalizeModelId(model.id)) &&\n compareVersions(releaseVersion(model.id), family.minVersion) >= 0 &&\n (model.releaseDate === undefined || Date.parse(model.releaseDate) >= recentSince),\n )\n if (current) recommendedIds.add(current.id)\n if (recommendedIds.size >= MAX_RECOMMENDED_MODELS) break\n }\n const models = sorted.map((model) =>\n recommendedIds.has(model.id) ? { ...model, featured: true } : model,\n )\n\n const preferred = opts?.preferredDefault\n const defaultModelId =\n (preferred && models.find((m) => m.id === preferred || normalizeModelId(m.id) === normalizeModelId(preferred))?.id) ||\n defaultCandidatesInRuleOrder.find((m) => m.supportsTools)?.id ||\n models[0]?.id ||\n null\n\n return { defaultModelId, fetchedAt: new Date().toISOString(), models }\n}\n\n// ── Cached fetch ─────────────────────────────────────────────────────────\n\nconst CATALOG_TTL_MS = 5 * 60 * 1000\n\nlet _cache: { catalog: ModelCatalog; at: number } | null = null\n\n/**\n * Fetch the router model list and build the catalogue, with an in-isolate\n * cache (TTL 5 min). On router failure a stale catalogue is served rather\n * than erroring the picker.\n */\nexport async function fetchModelCatalog(cfg: {\n baseUrl: string\n apiKey: string\n preferredDefault?: string\n}): Promise<ModelCatalog> {\n if (_cache && Date.now() - _cache.at < CATALOG_TTL_MS) {\n return _cache.catalog\n }\n try {\n const res = await fetch(`${cfg.baseUrl}/models`, {\n headers: { Authorization: `Bearer ${cfg.apiKey}` },\n })\n if (!res.ok) throw new Error(`Router /models returned ${res.status}`)\n const data = (await res.json()) as { data?: RouterModel[] }\n const catalog = buildCatalog(data.data ?? [], { preferredDefault: cfg.preferredDefault })\n _cache = { catalog, at: Date.now() }\n return catalog\n } catch (err) {\n if (_cache) return _cache.catalog\n throw err\n }\n}\n\n/** Test-only: clear the catalogue cache. */\nexport function __resetCatalogCache(): void {\n _cache = null\n}\n"],"mappings":";AAiFA,IAAM,gBAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,SAAS,kBAAkB,UAA0B;AACnD,QAAM,aAAa,SAAS,YAAY;AACxC,MAAI,eAAe,aAAc,QAAO;AACxC,MAAI,eAAe,OAAQ,QAAO;AAClC,MAAI,eAAe,OAAQ,QAAO;AAClC,MAAI,eAAe,YAAa,QAAO;AACvC,SAAO;AACT;AAGA,SAAS,iBAAiB,OAA4B;AACpD,QAAM,WAAW,MAAM,aAAa,MAAM,YAAY,MAAM,cAAc;AAC1E,MAAI,SAAU,QAAO,kBAAkB,QAAQ;AAE/C,QAAM,KAAK,iBAAiB,MAAM,EAAE,EAAE,YAAY;AAClD,MAAI,WAAW,KAAK,EAAE,EAAG,QAAO;AAChC,MAAI,gBAAgB,KAAK,EAAE,EAAG,QAAO;AACrC,MAAI,WA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C3D,OAAO,CAAC,GAAG,MACX;AAEF,SAAO,EAAE,gBAAgB,YAAW,oBAAI,KAAK,GAAE,YAAY,GAAG,OAAO;AACvE;AAIA,IAAM,iBAAiB,IAAI,KAAK;AAEhC,IAAI,SAAuD;AAO3D,eAAsB,kBAAkB,KAId;AACxB,MAAI,UAAU,KAAK,IAAI,IAAI,OAAO,KAAK,gBAAgB;AACrD,WAAO,OAAO;AAAA,EAChB;AACA,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,IAAI,OAAO,WAAW;AAAA,MAC/C,SAAS,EAAE,eAAe,UAAU,IAAI,MAAM,GAAG;AAAA,IACnD,CAAC;AACD,QAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2BAA2B,IAAI,MAAM,EAAE;AACpE,UAAM,OAAQ,MAAM,IAAI,KAAK;AAC7B,UAAM,UAAU,aAAa,KAAK,QAAQ,CAAC,GAAG,EAAE,kBAAkB,IAAI,iBAAiB,CAAC;AACxF,aAAS,EAAE,SAAS,IAAI,KAAK,IAAI,EAAE;AACnC,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,QAAI,OAAQ,QAAO,OAAO;AAC1B,UAAM;AAAA,EACR;AACF;AAGO,SAAS,sBAA4B;AAC1C,WAAS;AACX;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runRouterTurn
3
- } from "./chunk-N3KRSGVG.js";
3
+ } from "./chunk-HWWER7G6.js";
4
4
 
5
5
  // src/runtime/protected-model.ts
6
6
  var GATEWAY_ORIGIN = "https://candidate-router.tangle.tools";
@@ -217,4 +217,4 @@ export {
217
217
  createRouterProtectedModelPort,
218
218
  runProtectedRouterTurn
219
219
  };
220
- //# sourceMappingURL=chunk-44SU6LII.js.map
220
+ //# sourceMappingURL=chunk-X7PYE5C5.js.map
@@ -10,10 +10,10 @@ import {
10
10
  } from "./chunk-L7MB2LLM.js";
11
11
  import {
12
12
  PopoverSurface
13
- } from "./chunk-RO25WIVS.js";
13
+ } from "./chunk-SLXJZGXE.js";
14
14
  import "./chunk-ZAMHLXNS.js";
15
15
  import "./chunk-RASGKEAL.js";
16
- import "./chunk-AMUXRAUO.js";
16
+ import "./chunk-VLMXVCDQ.js";
17
17
 
18
18
  // src/web-react/mention-editor.tsx
19
19
  import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
@@ -564,4 +564,4 @@ export {
564
564
  loadMentionEditor,
565
565
  loadTiptapModules
566
566
  };
567
- //# sourceMappingURL=mention-editor-NTEV2G63.js.map
567
+ //# sourceMappingURL=mention-editor-HLEB37RK.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createChatTurnRoutes,
3
3
  streamChatRouteAsSandboxEvents
4
- } from "../chunk-NC4K5QWP.js";
4
+ } from "../chunk-K7HE6EM4.js";
5
5
  import "../chunk-SBHFMDR7.js";
6
6
  import "../chunk-H6BRJU5M.js";
7
7
  import "../chunk-4DBHC63F.js";
@@ -33,10 +33,10 @@ import "../chunk-S5SRJJQG.js";
33
33
  import "../chunk-C3JXGK3R.js";
34
34
  import "../chunk-UGWQLQDS.js";
35
35
  import "../chunk-IDRATMRZ.js";
36
- import "../chunk-N3KRSGVG.js";
36
+ import "../chunk-HWWER7G6.js";
37
37
  import "../chunk-LPW4UVAZ.js";
38
38
  import "../chunk-DCPOEDPK.js";
39
- import "../chunk-AMUXRAUO.js";
39
+ import "../chunk-VLMXVCDQ.js";
40
40
  import "../chunk-5VE4IDSU.js";
41
41
  import "../chunk-67CSI5PU.js";
42
42
  import "../chunk-RCSAAWOH.js";
@@ -2,7 +2,7 @@ import {
2
2
  ProtectedModelSettlementError,
3
3
  createRouterProtectedModelPort,
4
4
  runProtectedRouterTurn
5
- } from "../chunk-44SU6LII.js";
5
+ } from "../chunk-X7PYE5C5.js";
6
6
  import {
7
7
  DURABLE_HOP_BUDGET_MS,
8
8
  asksForLanguage,
@@ -26,7 +26,7 @@ import {
26
26
  turnKnowledgeInstructions,
27
27
  workspaceKnowledgeForTurn,
28
28
  workspaceTurnCheckpoints
29
- } from "../chunk-N3KRSGVG.js";
29
+ } from "../chunk-HWWER7G6.js";
30
30
  import {
31
31
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
32
32
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -53,7 +53,7 @@ import {
53
53
  normalizeModelId,
54
54
  resolveCatalogModelId,
55
55
  sortModelsByFreshness
56
- } from "../chunk-AMUXRAUO.js";
56
+ } from "../chunk-VLMXVCDQ.js";
57
57
 
58
58
  // src/runtime/certified-delivery.ts
59
59
  import {