@tangle-network/agent-app 0.46.47 → 0.46.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant/index.js +5 -5
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +5 -1
- package/dist/chat-react/index.js +3 -3
- package/dist/{chunk-PI3IVWFC.js → chunk-E5HZ4JPA.js} +4 -3
- package/dist/chunk-E5HZ4JPA.js.map +1 -0
- package/dist/{chunk-QUEKC2DS.js → chunk-J35PLM4G.js} +2 -2
- package/dist/{chunk-67ISDCXH.js → chunk-NGYEVU6R.js} +2 -2
- package/dist/{chunk-OS2FGYJQ.js → chunk-OU3VTK3I.js} +62 -18
- package/dist/chunk-OU3VTK3I.js.map +1 -0
- package/dist/{chunk-NKTTJE26.js → chunk-PX3FB6QZ.js} +3 -3
- package/dist/{mention-editor-ZQHH7FHK.js → mention-editor-4KS5HCV6.js} +3 -3
- package/dist/preset-cloudflare/detached-turn-workflow.d.ts +60 -0
- package/dist/preset-cloudflare/index.d.ts +1 -0
- package/dist/preset-cloudflare/index.js +41 -1
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/runtime/index.js +7 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/model-catalog.d.ts +21 -2
- package/dist/studio-react/index.js +3 -3
- package/dist/web-react/index.js +5 -5
- package/package.json +2 -2
- package/dist/chunk-OS2FGYJQ.js.map +0 -1
- package/dist/chunk-PI3IVWFC.js.map +0 -1
- /package/dist/{chunk-QUEKC2DS.js.map → chunk-J35PLM4G.js.map} +0 -0
- /package/dist/{chunk-67ISDCXH.js.map → chunk-NGYEVU6R.js.map} +0 -0
- /package/dist/{chunk-NKTTJE26.js.map → chunk-PX3FB6QZ.js.map} +0 -0
- /package/dist/{mention-editor-ZQHH7FHK.js.map → mention-editor-4KS5HCV6.js.map} +0 -0
package/dist/assistant/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChatEmptyState,
|
|
3
3
|
ChatMessages
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-NGYEVU6R.js";
|
|
5
|
+
import "../chunk-J35PLM4G.js";
|
|
6
6
|
import "../chunk-3HUFJ5LO.js";
|
|
7
7
|
import "../chunk-FBVLEGEG.js";
|
|
8
8
|
import "../chunk-ENLRJYVW.js";
|
|
9
9
|
import "../chunk-GEYACSFW.js";
|
|
10
10
|
import {
|
|
11
11
|
ChatComposer
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-PX3FB6QZ.js";
|
|
13
13
|
import "../chunk-L7MB2LLM.js";
|
|
14
14
|
import {
|
|
15
15
|
ModelPicker
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-E5HZ4JPA.js";
|
|
17
17
|
import "../chunk-BATKJP3P.js";
|
|
18
18
|
import {
|
|
19
19
|
AsyncView
|
|
@@ -28,7 +28,7 @@ import "../chunk-ZMMIQOFI.js";
|
|
|
28
28
|
import "../chunk-M3K2HVQD.js";
|
|
29
29
|
import "../chunk-YJMCRXQQ.js";
|
|
30
30
|
import "../chunk-MCYJON3F.js";
|
|
31
|
-
import "../chunk-
|
|
31
|
+
import "../chunk-OU3VTK3I.js";
|
|
32
32
|
|
|
33
33
|
// src/assistant/sse.ts
|
|
34
34
|
var SSEChunkParser = class {
|
package/dist/catalog/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* no agent-runtime) so pickers and client hooks have a safe import target.
|
|
13
13
|
* Server code may keep importing from `./runtime`; the two share one source.
|
|
14
14
|
*/
|
|
15
|
-
export { buildCatalog, fetchModelCatalog, isChatCapableModel, normalizeModelId, sortModelsByFreshness, __resetCatalogCache, type CatalogModel, type ModelCatalog, type RouterModel, } from '../runtime/model-catalog';
|
|
15
|
+
export { buildCatalog, catalogModelForId, fetchModelCatalog, isChatCapableModel, normalizeModelId, resolveCatalogModelId, sortModelsByFreshness, __resetCatalogCache, type CatalogModel, type ModelCatalog, type RouterModel, } from '../runtime/model-catalog';
|
package/dist/catalog/index.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__resetCatalogCache,
|
|
3
3
|
buildCatalog,
|
|
4
|
+
catalogModelForId,
|
|
4
5
|
fetchModelCatalog,
|
|
5
6
|
isChatCapableModel,
|
|
6
7
|
normalizeModelId,
|
|
8
|
+
resolveCatalogModelId,
|
|
7
9
|
sortModelsByFreshness
|
|
8
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-OU3VTK3I.js";
|
|
9
11
|
export {
|
|
10
12
|
__resetCatalogCache,
|
|
11
13
|
buildCatalog,
|
|
14
|
+
catalogModelForId,
|
|
12
15
|
fetchModelCatalog,
|
|
13
16
|
isChatCapableModel,
|
|
14
17
|
normalizeModelId,
|
|
18
|
+
resolveCatalogModelId,
|
|
15
19
|
sortModelsByFreshness
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=index.js.map
|
package/dist/chat-react/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComposerModeControls,
|
|
3
3
|
EntryComposer
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-PX3FB6QZ.js";
|
|
5
5
|
import "../chunk-L7MB2LLM.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-E5HZ4JPA.js";
|
|
7
7
|
import "../chunk-SJWIZT7B.js";
|
|
8
8
|
import "../chunk-SUO2R2ET.js";
|
|
9
9
|
import "../chunk-DXHUQ5NO.js";
|
|
10
10
|
import "../chunk-MCYJON3F.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-OU3VTK3I.js";
|
|
12
12
|
export {
|
|
13
13
|
ComposerModeControls,
|
|
14
14
|
EntryComposer
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MAX_RECOMMENDED_MODELS,
|
|
2
3
|
sortModelsByFreshness
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OU3VTK3I.js";
|
|
4
5
|
|
|
5
6
|
// src/web-react/provider-logo.tsx
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -318,7 +319,7 @@ function ModelPicker({ value, onChange, models, loading, renderProviderBadge, re
|
|
|
318
319
|
const recommended = sortedModels.filter((model) => {
|
|
319
320
|
if (!model.featured || isPriority(model)) return false;
|
|
320
321
|
return newestIds.has(model.id);
|
|
321
|
-
});
|
|
322
|
+
}).slice(0, MAX_RECOMMENDED_MODELS);
|
|
322
323
|
const recommendedIds = new Set(recommended.map((model) => model.id));
|
|
323
324
|
const byProvider = [];
|
|
324
325
|
for (const m of sortedModels) {
|
|
@@ -546,4 +547,4 @@ export {
|
|
|
546
547
|
EffortMeter,
|
|
547
548
|
EffortPicker
|
|
548
549
|
};
|
|
549
|
-
//# sourceMappingURL=chunk-
|
|
550
|
+
//# sourceMappingURL=chunk-E5HZ4JPA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web-react/provider-logo.tsx","../src/web-react/controls.tsx"],"sourcesContent":["/**\n * Provider brand marks — real logo path data (simple-icons / SVG Logos, both\n * CC0) inlined so the picker shows actual provider identity instead of\n * colored-initial monograms. Providers without a usable mark fall back to a\n * tinted monogram chip. Aliases (z-ai/zai, moonshot/moonshotai, deepseek_ai)\n * normalize to one entry.\n */\n\nimport type { ReactNode } from 'react'\n\ninterface LogoDef {\n viewBox: string\n fill: string\n paths: string[]\n}\n\nconst LOGOS: Record<string, LogoDef> = {\n anthropic: { viewBox: '0 0 24 24', fill: '#D97757', paths: [\"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z\"] },\n google: { viewBox: '0 0 24 24', fill: '#8E75B2', paths: [\"M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81\"] },\n deepseek: { viewBox: '0 0 24 24', fill: '#4D6BFE', paths: [\"M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45\"] },\n mistral: { viewBox: '0 0 24 24', fill: '#FA520F', paths: [\"M17.143 3.429v3.428h-3.429v3.429h-3.428V6.857H6.857V3.43H3.43v13.714H0v3.428h10.286v-3.428H6.857v-3.429h3.429v3.429h3.429v-3.429h3.428v3.429h-3.428v3.428H24v-3.428h-3.43V3.429z\"] },\n xai: { viewBox: '0 0 24 24', fill: '#000000', paths: [\"M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z\"] },\n nvidia: { viewBox: '0 0 24 24', fill: '#76B900', paths: [\"M8.948 8.798v-1.43a6.7 6.7 0 0 1 .424-.018c3.922-.124 6.493 3.374 6.493 3.374s-2.774 3.851-5.75 3.851c-.398 0-.787-.062-1.158-.185v-4.346c1.528.185 1.837.857 2.747 2.385l2.04-1.714s-1.492-1.952-4-1.952a6.016 6.016 0 0 0-.796.035m0-4.735v2.138l.424-.027c5.45-.185 9.01 4.47 9.01 4.47s-4.08 4.964-8.33 4.964c-.37 0-.733-.035-1.095-.097v1.325c.3.035.61.062.91.062 3.957 0 6.82-2.023 9.593-4.408.459.371 2.34 1.263 2.73 1.652-2.633 2.208-8.772 3.984-12.253 3.984-.335 0-.653-.018-.971-.053v1.864H24V4.063zm0 10.326v1.131c-3.657-.654-4.673-4.46-4.673-4.46s1.758-1.944 4.673-2.262v1.237H8.94c-1.528-.186-2.73 1.245-2.73 1.245s.68 2.412 2.739 3.11M2.456 10.9s2.164-3.197 6.5-3.533V6.201C4.153 6.59 0 10.653 0 10.653s2.35 6.802 8.948 7.42v-1.237c-4.84-.6-6.492-5.936-6.492-5.936z\"] },\n meta: { viewBox: '0 0 24 24', fill: '#0467DF', paths: [\"M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z\"] },\n moonshotai: { viewBox: '0 0 24 24', fill: '#16191E', paths: [\"m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866\"] },\n openai: { viewBox: '0 0 256 260', fill: '#10A37F', paths: [\"M239.184 106.203a64.72 64.72 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.72 64.72 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.67 64.67 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.77 64.77 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483m-97.56 136.338a48.4 48.4 0 0 1-31.105-11.255l1.535-.87l51.67-29.825a8.6 8.6 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601M37.158 197.93a48.35 48.35 0 0 1-5.781-32.589l1.534.921l51.722 29.826a8.34 8.34 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803M23.549 85.38a48.5 48.5 0 0 1 25.58-21.333v61.39a8.29 8.29 0 0 0 4.195 7.316l62.874 36.272l-21.845 12.636a.82.82 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405zm179.466 41.695l-63.08-36.63L161.73 77.86a.82.82 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.54 8.54 0 0 0-4.4-7.213m21.742-32.69l-1.535-.922l-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.72.72 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391zM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87l-51.67 29.825a8.6 8.6 0 0 0-4.246 7.367zm11.868-25.58L128.067 97.3l28.188 16.218v32.434l-28.086 16.218l-28.188-16.218z\"] },\n}\n\nconst ALIASES: Record<string, string> = {\n moonshot: 'moonshotai',\n deepseek_ai: 'deepseek',\n 'x-ai': 'xai',\n 'meta-llama': 'meta',\n}\n\nconst MONOGRAM: Record<string, { bg: string; fg: string }> = {\n cohere: { bg: '#fae8ff', fg: '#c026d3' },\n groq: { bg: '#fce7f3', fg: '#db2777' },\n cerebras: { bg: '#ccfbf1', fg: '#0d9488' },\n zai: { bg: '#ede9fe', fg: '#7c3aed' },\n 'z-ai': { bg: '#ede9fe', fg: '#7c3aed' },\n tuner: { bg: '#dbeafe', fg: '#2563eb' },\n}\n\nexport interface ProviderLogoProps {\n provider?: string\n size?: number\n}\n\n/** Real brand mark when we have one; tinted monogram otherwise. */\nexport function ProviderLogo({ provider, size = 16 }: ProviderLogoProps): ReactNode {\n const key = ALIASES[provider ?? ''] ?? provider ?? ''\n const logo = LOGOS[key]\n if (logo) {\n return (\n <svg width={size} height={size} viewBox={logo.viewBox} role=\"img\" aria-label={key}>\n {logo.paths.map((d, i) => (\n <path key={i} d={d} fill={logo.fill} />\n ))}\n </svg>\n )\n }\n // Unknown providers fall back to a neutral monogram drawn from theme tokens\n // (secondary tile, muted glyph) — the previous hardcoded grays (#f3f4f6 /\n // #6b7280) were tuned for light mode and read as a washed-out hole on dark.\n // `style` rather than the `fill` attribute so the var() references resolve.\n const mono = MONOGRAM[key]\n return (\n <svg width={size} height={size} viewBox=\"0 0 16 16\" role=\"img\" aria-label={key || 'model'}>\n <rect width=\"16\" height=\"16\" rx=\"4\" style={{ fill: mono ? mono.bg : 'hsl(var(--secondary))' }} />\n <text x=\"8\" y=\"11.6\" textAnchor=\"middle\" style={{ fill: mono ? mono.fg : 'hsl(var(--muted-foreground))' }} fontSize=\"9\" fontWeight=\"700\" fontFamily=\"system-ui, sans-serif\">\n {(key || '?').charAt(0).toUpperCase()}\n </text>\n </svg>\n )\n}\n","/**\n * Shared chat-shell control primitives — the LEAF that both the web-react barrel\n * (`./index`) and the composer children (`./agent-session-controls`,\n * `./seat-paywall`) import directly, so neither child has to reach back through\n * the barrel (which would re-create an import cycle). The barrel re-exports the\n * public names (`usePopover`, `usePending`, `ModelPicker`, `EffortPicker`, …)\n * unchanged, so the published export surface is identical.\n *\n * Styling contract matches the rest of `web-react`: Tailwind classes against the\n * shared design tokens; the glyphs are inline SVGs, no icon-library dependency.\n */\n\nimport {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { ProviderLogo } from './provider-logo'\nimport {\n MAX_RECOMMENDED_MODELS,\n sortModelsByFreshness,\n type CatalogModel,\n} from '../runtime/model-catalog'\n\n// ── shared glyphs (no icon-library dependency) ────────────────────────────\n\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\nfunction 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\nfunction 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\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') {\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 */\nconst 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 /** 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 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 matchTriggerWidth,\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 = contentHeight <= roomAbove || roomAbove >= roomBelow\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 left = Math.min(Math.max(POPOVER_VIEWPORT_MARGIN, anchor.left), rightBound)\n\n setStyle({\n position: 'fixed',\n top,\n left,\n maxHeight,\n visibility: 'visible',\n ...(matchTriggerWidth ? { minWidth: anchor.width } : {}),\n })\n }, [matchTriggerWidth, panelRef, 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])\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 style={style}\n {...{ [POPOVER_SURFACE_ATTR]: path }}\n className={`z-[1000] ${className ?? ''}`}\n >\n {children}\n </div>,\n document.body,\n )\n}\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 36px bordered pill — `rounded-full border\n * border-border bg-card font-medium`. A consumer that names no variant\n * renders exactly what it rendered before this prop existed.\n * - `quiet`: a 28px borderless text button — 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 */\nexport type PickerVariant = 'chip' | 'quiet'\n\n/** The quiet trigger at rest: geometry, type, and keyboard focus. */\nconst QUIET_PICKER_TRIGGER_BASE =\n 'inline-flex h-7 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\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\n// ── ModelPicker ───────────────────────────────────────────────────────────\n\nexport interface ModelPickerProps {\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 loading?: boolean\n /** Render a provider logo/badge; default is a generic sparkle. */\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}\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 return perM >= 1 ? `$${perM.toFixed(0)}/M` : `$${perM.toFixed(2)}/M`\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 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 = formatPrice(model.pricing?.prompt)\n const ctx = formatContext(model.contextLength)\n return (\n <button\n type=\"button\"\n onClick={onSelect}\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 {renderProviderBadge ? renderProviderBadge(model.provider) : <ProviderLogo provider={model.provider} size={16} />}\n <span className=\"truncate\">{model.name}</span>\n {!model.supportsTools && (\n <span className=\"shrink-0 rounded bg-secondary px-1.5 py-0.5 text-xs font-medium text-muted-foreground\">\n no tools\n </span>\n )}\n <span className=\"ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground\">\n {ctx && <span>{ctx}</span>}\n {price && <span>{price}</span>}\n </span>\n </button>\n )\n}\n\n/**\n * Searchable model picker pill + popover. A featured model is recommended\n * only when it is also that provider's newest entry. Older featured models\n * stay visible in their provider group instead of jumping above new releases.\n *\n * This is the CANONICAL ecosystem model picker (see \"UI chrome ownership\n * (picker canon)\" in AGENTS.md). sandbox-ui's `dashboard/ModelPicker` is\n * legacy — deprecated, frozen, removed at sandbox-ui's next major; new code\n * belongs here.\n */\nexport function ModelPicker({ value, onChange, models, loading, renderProviderBadge, recommendedLabel = 'Recommended', priorityGroup, variant = 'chip' }: ModelPickerProps) {\n const [open, setOpen] = useState(false)\n const [query, setQuery] = useState('')\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen)\n const inputRef = useRef<HTMLInputElement>(null)\n const panelId = useId()\n const sortedModels = useMemo(() => sortModelsByFreshness(models), [models])\n\n useEffect(() => {\n if (open) inputRef.current?.focus()\n }, [open])\n\n const selected = sortedModels.find((m) => m.id === value)\n\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 )\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 seenProviders = new Set<string>()\n const newestIds = new Set<string>()\n for (const model of sortedModels) {\n const provider = model.provider.toLowerCase()\n if (seenProviders.has(provider)) continue\n seenProviders.add(provider)\n newestIds.add(model.id)\n }\n const recommended = sortedModels\n .filter((model) => {\n if (!model.featured || isPriority(model)) return false\n return newestIds.has(model.id)\n })\n .slice(0, MAX_RECOMMENDED_MODELS)\n const recommendedIds = new Set(recommended.map((model) => model.id))\n const byProvider: Array<{ provider: string; items: CatalogModel[] }> = []\n for (const m of sortedModels) {\n if (recommendedIds.has(m.id) || isPriority(m)) continue\n const last = byProvider[byProvider.length - 1]\n if (last && last.provider === m.provider) last.items.push(m)\n else byProvider.push({ provider: m.provider, items: [m] })\n }\n return { priority, recommended, byProvider }\n }, [sortedModels, priorityGroup])\n\n const select = (id: string) => {\n onChange(id)\n setOpen(false)\n setQuery('')\n }\n\n return (\n <div ref={containerRef} className=\"relative inline-flex\">\n <button\n type=\"button\"\n {...triggerProps}\n aria-controls={open ? panelId : undefined}\n onClick={() => setOpen(!open)}\n data-state={open ? 'open' : 'closed'}\n className={\n variant === 'quiet'\n ? quietPickerTriggerClass()\n : 'inline-flex 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 }\n >\n {selected ? (renderProviderBadge ? renderProviderBadge(selected.provider) : <ProviderLogo provider={selected.provider} size={16} />) : <SparkleGlyph className=\"h-3.5 w-3.5 text-muted-foreground\" />}\n <span className=\"max-w-[160px] truncate\">{selected?.name ?? value}</span>\n <ChevronDown className=\"h-3.5 w-3.5 text-muted-foreground\" />\n </button>\n\n <PopoverSurface\n open={open}\n id={panelId}\n triggerRef={triggerRef}\n panelRef={panelRef}\n className={`flex w-[420px] max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-card-edge bg-popover ${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\">\n <SearchGlyph className=\"h-3.5 w-3.5 text-muted-foreground\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder=\"Search models...\"\n className=\"flex-1 bg-transparent text-sm placeholder:text-muted-foreground\"\n />\n </div>\n </div>\n {/* `min-h-0` is what lets the list absorb the surface's computed\n max-height on a short viewport instead of overflowing the panel. */}\n <div className=\"max-h-[400px] min-h-0 overflow-y-auto p-1 pb-2\">\n {loading && <div className=\"px-3 py-4 text-center text-sm text-muted-foreground\">Loading models...</div>}\n {!loading && filtered && (\n <>\n {filtered.length === 0 && (\n <div className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models match your search</div>\n )}\n {filtered.map((m) => (\n <ModelRow key={m.id} model={m} selected={m.id === value} onSelect={() => select(m.id)} renderProviderBadge={renderProviderBadge} />\n ))}\n </>\n )}\n {!loading && !filtered && models.length === 0 && (\n <div className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models available</div>\n )}\n {!loading && !filtered && models.length > 0 && (\n <>\n {priorityGroup && sections.priority.length > 0 && (\n <>\n <SectionHeader>{priorityGroup.label}</SectionHeader>\n {sections.priority.map((m) => (\n <ModelRow key={m.id} model={m} selected={m.id === value} onSelect={() => select(m.id)} renderProviderBadge={renderProviderBadge} />\n ))}\n </>\n )}\n {sections.recommended.length > 0 && (\n <>\n <SectionHeader>{recommendedLabel}</SectionHeader>\n {sections.recommended.map((m) => (\n <ModelRow key={m.id} model={m} selected={m.id === value} onSelect={() => select(m.id)} renderProviderBadge={renderProviderBadge} />\n ))}\n </>\n )}\n {sections.byProvider.map((g) => (\n <div key={g.provider}>\n <SectionHeader>{g.provider}</SectionHeader>\n {g.items.map((m) => (\n <ModelRow key={m.id} model={m} selected={m.id === value} onSelect={() => select(m.id)} renderProviderBadge={renderProviderBadge} />\n ))}\n </div>\n ))}\n </>\n )}\n </div>\n </PopoverSurface>\n </div>\n )\n}\n\n// ── EffortPicker ──────────────────────────────────────────────────────────\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}\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' }: EffortPickerProps) {\n const [open, setOpen] = useState(false)\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen)\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)}>\n <button\n type=\"button\"\n {...triggerProps}\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 variant === 'quiet'\n ? quietPickerTriggerClass()\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 } ${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 ? '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. */}\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}\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":";;;;;;AAyDU,cAWN,YAXM;AAzCV,IAAM,QAAiC;AAAA,EACrC,WAAW,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,0KAA0K,EAAE;AAAA,EACxO,QAAQ,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,8RAA8R,EAAE;AAAA,EACzV,UAAU,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,w7DAAw7D,EAAE;AAAA,EACr/D,SAAS,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,kLAAkL,EAAE;AAAA,EAC9O,KAAK,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,oMAAoM,EAAE;AAAA,EAC5P,QAAQ,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,qwBAAqwB,EAAE;AAAA,EACh0B,MAAM,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,ksCAAksC,EAAE;AAAA,EAC3vC,YAAY,EAAE,SAAS,aAAa,MAAM,WAAW,OAAO,CAAC,2hBAA2hB,EAAE;AAAA,EAC1lB,QA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4 @@ export {
|
|
|
812
812
|
formatSessionTimestamp,
|
|
813
813
|
SessionHistoryPanel
|
|
814
814
|
};
|
|
815
|
-
//# sourceMappingURL=chunk-
|
|
815
|
+
//# sourceMappingURL=chunk-J35PLM4G.js.map
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
PopoverSurface,
|
|
24
24
|
usePending,
|
|
25
25
|
usePopover
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-E5HZ4JPA.js";
|
|
27
27
|
import {
|
|
28
28
|
AsyncView
|
|
29
29
|
} from "./chunk-3UBAO3N5.js";
|
|
@@ -5959,4 +5959,4 @@ export {
|
|
|
5959
5959
|
useThinkingSeconds,
|
|
5960
5960
|
ChatMessages
|
|
5961
5961
|
};
|
|
5962
|
-
//# sourceMappingURL=chunk-
|
|
5962
|
+
//# sourceMappingURL=chunk-NGYEVU6R.js.map
|
|
@@ -5,10 +5,8 @@ var PROVIDER_TIER = [
|
|
|
5
5
|
"google",
|
|
6
6
|
"xai",
|
|
7
7
|
"deepseek",
|
|
8
|
-
"moonshotai",
|
|
9
8
|
"moonshot",
|
|
10
9
|
"zai",
|
|
11
|
-
"z-ai",
|
|
12
10
|
"mistral",
|
|
13
11
|
"groq",
|
|
14
12
|
"nvidia",
|
|
@@ -19,10 +17,27 @@ function normalizeProvider(provider) {
|
|
|
19
17
|
const normalized = provider.toLowerCase();
|
|
20
18
|
if (normalized === "moonshotai") return "moonshot";
|
|
21
19
|
if (normalized === "z-ai") return "zai";
|
|
20
|
+
if (normalized === "x-ai") return "xai";
|
|
21
|
+
if (normalized === "mistralai") return "mistral";
|
|
22
22
|
return normalized;
|
|
23
23
|
}
|
|
24
|
+
function providerForModel(model) {
|
|
25
|
+
const declared = model._provider ?? model.provider ?? model.routeability?.provider;
|
|
26
|
+
if (declared) return normalizeProvider(declared);
|
|
27
|
+
const id = normalizeModelId(model.id).toLowerCase();
|
|
28
|
+
if (/^claude-/.test(id)) return "anthropic";
|
|
29
|
+
if (/^(?:gpt-|o\d)/.test(id)) return "openai";
|
|
30
|
+
if (/^gemini-/.test(id)) return "google";
|
|
31
|
+
if (/^grok-/.test(id)) return "xai";
|
|
32
|
+
if (/^deepseek-/.test(id)) return "deepseek";
|
|
33
|
+
if (/^kimi-/.test(id)) return "moonshot";
|
|
34
|
+
if (/^glm-/.test(id)) return "zai";
|
|
35
|
+
if (/^mistral/.test(id)) return "mistral";
|
|
36
|
+
return "unknown";
|
|
37
|
+
}
|
|
38
|
+
var MAX_RECOMMENDED_MODELS = 3;
|
|
24
39
|
var EXCLUDED_ID = /(embedding|tts|transcribe|whisper|audio|realtime|image|lyria|sora|dall-e|moderation|content-safety|search-preview|search-api|deep-research|:batch$)/;
|
|
25
|
-
var
|
|
40
|
+
var DEFAULT_CANDIDATE_RULES = [
|
|
26
41
|
{ providers: ["anthropic"], match: /^claude-sonnet-[\d-]+$/ },
|
|
27
42
|
{ providers: ["anthropic"], match: /^claude-opus-[\d-]+$/ },
|
|
28
43
|
{ providers: ["anthropic"], match: /^claude-haiku-[\d-]+$/ },
|
|
@@ -108,7 +123,31 @@ function isChatCapableModel(m) {
|
|
|
108
123
|
}
|
|
109
124
|
var isChatModel = isChatCapableModel;
|
|
110
125
|
function isRouteable(m) {
|
|
111
|
-
|
|
126
|
+
const routeability = m.routeability;
|
|
127
|
+
if (!routeability) return true;
|
|
128
|
+
const chatEndpoint = routeability.endpoints?.chat_completions;
|
|
129
|
+
if (chatEndpoint?.routeable === false) return false;
|
|
130
|
+
if (chatEndpoint?.status !== void 0 && chatEndpoint.status !== "routeable") return false;
|
|
131
|
+
if (routeability.routeable === true || routeability.status === "routeable") return true;
|
|
132
|
+
if (routeability.routeable === false) return false;
|
|
133
|
+
return routeability.status === void 0;
|
|
134
|
+
}
|
|
135
|
+
function catalogModelForId(models, requestedId) {
|
|
136
|
+
const requested = requestedId?.trim();
|
|
137
|
+
if (!requested) return void 0;
|
|
138
|
+
const exact = models.find((model) => model.id === requested);
|
|
139
|
+
if (exact) return exact;
|
|
140
|
+
const slash = requested.indexOf("/");
|
|
141
|
+
const requestedProvider = slash > 0 ? normalizeProvider(requested.slice(0, slash)) : void 0;
|
|
142
|
+
const normalized = normalizeModelId(requested);
|
|
143
|
+
return models.find((model) => {
|
|
144
|
+
if (normalizeModelId(model.id) !== normalized) return false;
|
|
145
|
+
return requestedProvider === void 0 || normalizeProvider(model.provider) === requestedProvider;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function resolveCatalogModelId(models, selectedId, fallbackId) {
|
|
149
|
+
if (models.length === 0) return selectedId?.trim() || fallbackId?.trim();
|
|
150
|
+
return catalogModelForId(models, selectedId)?.id ?? catalogModelForId(models, fallbackId)?.id ?? models[0]?.id;
|
|
112
151
|
}
|
|
113
152
|
function buildCatalog(raw, opts) {
|
|
114
153
|
const candidates = raw.filter(
|
|
@@ -116,7 +155,7 @@ function buildCatalog(raw, opts) {
|
|
|
116
155
|
);
|
|
117
156
|
const groups = /* @__PURE__ */ new Map();
|
|
118
157
|
for (const m of candidates) {
|
|
119
|
-
const key = `${
|
|
158
|
+
const key = `${providerForModel(m)}::${normalizeModelId(m.id)}`;
|
|
120
159
|
const g = groups.get(key);
|
|
121
160
|
if (g) g.push(m);
|
|
122
161
|
else groups.set(key, [m]);
|
|
@@ -128,20 +167,20 @@ function buildCatalog(raw, opts) {
|
|
|
128
167
|
const mergedParams = new Set(group.flatMap((m) => m.supported_parameters ?? []));
|
|
129
168
|
reps.push({ model: rep, normId: normalizeModelId(rep.id), mergedParams });
|
|
130
169
|
}
|
|
131
|
-
const
|
|
132
|
-
for (const rule of
|
|
170
|
+
const defaultCandidateIds = [];
|
|
171
|
+
for (const rule of DEFAULT_CANDIDATE_RULES) {
|
|
133
172
|
const matches = reps.filter(
|
|
134
|
-
(r) => rule.providers.map(normalizeProvider).includes(
|
|
173
|
+
(r) => rule.providers.map(normalizeProvider).includes(providerForModel(r.model)) && rule.match.test(r.normId) && !defaultCandidateIds.includes(r.model.id)
|
|
135
174
|
);
|
|
136
175
|
if (!matches.length) continue;
|
|
137
176
|
matches.sort(
|
|
138
177
|
(a, b) => compareVersions(versionOf(b.normId), versionOf(a.normId)) || Number(a.normId.includes("preview")) - Number(b.normId.includes("preview")) || a.model.id.length - b.model.id.length
|
|
139
178
|
);
|
|
140
|
-
|
|
179
|
+
defaultCandidateIds.push(matches[0].model.id);
|
|
141
180
|
}
|
|
142
181
|
const toCatalogModel = (r) => {
|
|
143
182
|
const m = r.model;
|
|
144
|
-
const provider =
|
|
183
|
+
const provider = providerForModel(m);
|
|
145
184
|
return {
|
|
146
185
|
id: m.id,
|
|
147
186
|
name: m.name ?? m.id,
|
|
@@ -151,24 +190,26 @@ function buildCatalog(raw, opts) {
|
|
|
151
190
|
pricing: m.pricing?.prompt || m.pricing?.completion ? { prompt: m.pricing.prompt ?? void 0, completion: m.pricing.completion ?? void 0 } : void 0,
|
|
152
191
|
supportsTools: r.mergedParams.has("tools") || TOOL_CAPABLE_FAMILY.test(r.normId),
|
|
153
192
|
supportsReasoning: r.mergedParams.has("reasoning") || r.mergedParams.has("include_reasoning"),
|
|
154
|
-
featured:
|
|
193
|
+
featured: false
|
|
155
194
|
};
|
|
156
195
|
};
|
|
157
|
-
const
|
|
196
|
+
const defaultCandidatesInRuleOrder = defaultCandidateIds.map((id) => reps.find((r) => r.model.id === id)).map(toCatalogModel);
|
|
158
197
|
const sorted = sortModelsByFreshness(reps.map(toCatalogModel));
|
|
159
|
-
const
|
|
198
|
+
const recommendedIds = /* @__PURE__ */ new Set();
|
|
160
199
|
const seenProviders = /* @__PURE__ */ new Set();
|
|
161
200
|
for (const model of sorted) {
|
|
162
|
-
const provider = model.provider
|
|
201
|
+
const provider = normalizeProvider(model.provider);
|
|
202
|
+
if (providerRank(provider) >= PROVIDER_TIER.length) continue;
|
|
163
203
|
if (seenProviders.has(provider)) continue;
|
|
164
204
|
seenProviders.add(provider);
|
|
165
|
-
|
|
205
|
+
recommendedIds.add(model.id);
|
|
206
|
+
if (recommendedIds.size >= MAX_RECOMMENDED_MODELS) break;
|
|
166
207
|
}
|
|
167
208
|
const models = sorted.map(
|
|
168
|
-
(model) =>
|
|
209
|
+
(model) => recommendedIds.has(model.id) ? { ...model, featured: true } : model
|
|
169
210
|
);
|
|
170
211
|
const preferred = opts?.preferredDefault;
|
|
171
|
-
const defaultModelId = preferred && models.find((m) => m.id === preferred || normalizeModelId(m.id) === normalizeModelId(preferred))?.id ||
|
|
212
|
+
const defaultModelId = preferred && models.find((m) => m.id === preferred || normalizeModelId(m.id) === normalizeModelId(preferred))?.id || defaultCandidatesInRuleOrder.find((m) => m.supportsTools)?.id || models[0]?.id || null;
|
|
172
213
|
return { defaultModelId, fetchedAt: (/* @__PURE__ */ new Date()).toISOString(), models };
|
|
173
214
|
}
|
|
174
215
|
var CATALOG_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -196,11 +237,14 @@ function __resetCatalogCache() {
|
|
|
196
237
|
}
|
|
197
238
|
|
|
198
239
|
export {
|
|
240
|
+
MAX_RECOMMENDED_MODELS,
|
|
199
241
|
normalizeModelId,
|
|
200
242
|
sortModelsByFreshness,
|
|
201
243
|
isChatCapableModel,
|
|
244
|
+
catalogModelForId,
|
|
245
|
+
resolveCatalogModelId,
|
|
202
246
|
buildCatalog,
|
|
203
247
|
fetchModelCatalog,
|
|
204
248
|
__resetCatalogCache
|
|
205
249
|
};
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
250
|
+
//# sourceMappingURL=chunk-OU3VTK3I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/model-catalog.ts"],"sourcesContent":["/**\n * Model catalogue — computed live from the Tangle Router, never hand-curated.\n * Lifted from tuner-agent so every agent app's model picker shares one\n * filter/dedupe/rank/feature pipeline instead of re-deriving it.\n *\n * The router's /models endpoint returns every routeable model (~200), which is\n * unusable as a picker list: it mixes chat models with TTS/embedding/realtime\n * endpoints, dated snapshots alias their parents, and provider-prefixed ids\n * duplicate canonical ones. This module turns that into a product catalogue:\n *\n * filter (chat-capable, routeable) → dedupe (snapshot/prefix/:free aliases)\n * → rank (provider tier, current generation) → recommend (bounded shortlist)\n * → default (env override or preferred family)\n *\n * Freshness is automatic: everything is derived from the live router response,\n * so new models surface as soon as the router lists them. The only static\n * knowledge here is slow-moving: provider display order and family name\n * patterns (e.g. \"claude-sonnet-*\", \"gpt-N\"). A new release and a new family\n * both reach the first row from their versioned id with no catalogue edit.\n */\n\nexport interface RouterModel {\n id: string\n name?: string\n description?: 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 description?: string\n contextLength?: number\n pricing?: { prompt?: string; completion?: 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 first screen, not one row for every Router provider. */\nexport const MAX_RECOMMENDED_MODELS = 3\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: ['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/** 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-[45]|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> }> = []\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 reps.push({ model: rep, normId: normalizeModelId(rep.id), mergedParams })\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 return {\n id: m.id,\n name: m.name ?? m.id,\n provider,\n description: m.description ? m.description.slice(0, 160) : undefined,\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 seenProviders = new Set<string>()\n for (const model of sorted) {\n const provider = normalizeProvider(model.provider)\n if (providerRank(provider) >= PROVIDER_TIER.length) continue\n if (seenProviders.has(provider)) continue\n seenProviders.add(provider)\n recommendedIds.add(model.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":";AAqEA,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,WAAW,KAAK,EAAE,EAAG,QAAO;AAChC,MAAI,SAAS,KAAK,EAAE,EAAG,QAAO;AAC9B,MAAI,aAAa,KAAK,EAAE,EAAG,QAAO;AAClC,MAAI,SAAS,KAAK,EAAE,EAAG,QAAO;AAC9B,MAAI,QAAQ,KAAK,EAAE,EAAG,QAAO;AAC7B,MAAI,WAAW,KAAK,EAAE,EAAG,QAAO;AAChC,SAAO;AACT;AAGO,IAAM,yBAAyB;AAGtC,IAAM,cAAc;AAQpB,IAAM,0BAAyE;AAAA,EAC7E,EAAE,WAAW,CAAC,WAAW,GAAG,OAAO,yBAAyB;AAAA,EAC5D,EAAE,WAAW,CAAC,WAAW,GAAG,OAAO,uBAAuB;AAAA,EAC1D,EAAE,WAAW,CAAC,WAAW,GAAG,OAAO,wBAAwB;AAAA,EAC3D,EAAE,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
13
13
|
usePopover
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-E5HZ4JPA.js";
|
|
15
15
|
import {
|
|
16
16
|
filterCommandPaletteItems
|
|
17
17
|
} from "./chunk-SJWIZT7B.js";
|
|
@@ -273,7 +273,7 @@ import {
|
|
|
273
273
|
} from "react";
|
|
274
274
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
275
275
|
function createLazyMentionEditor() {
|
|
276
|
-
return lazy(() => import("./mention-editor-
|
|
276
|
+
return lazy(() => import("./mention-editor-4KS5HCV6.js").then((m) => m.loadMentionEditor()));
|
|
277
277
|
}
|
|
278
278
|
var MentionEditorBoundary = class extends Component {
|
|
279
279
|
state = { failed: false };
|
|
@@ -1852,4 +1852,4 @@ export {
|
|
|
1852
1852
|
ComposerModeControls,
|
|
1853
1853
|
EntryComposer
|
|
1854
1854
|
};
|
|
1855
|
-
//# sourceMappingURL=chunk-
|
|
1855
|
+
//# sourceMappingURL=chunk-PX3FB6QZ.js.map
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
} from "./chunk-L7MB2LLM.js";
|
|
11
11
|
import {
|
|
12
12
|
PopoverSurface
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-E5HZ4JPA.js";
|
|
14
|
+
import "./chunk-OU3VTK3I.js";
|
|
15
15
|
|
|
16
16
|
// src/web-react/mention-editor.tsx
|
|
17
17
|
import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
|
|
@@ -523,4 +523,4 @@ export {
|
|
|
523
523
|
loadMentionEditor,
|
|
524
524
|
loadTiptapModules
|
|
525
525
|
};
|
|
526
|
-
//# sourceMappingURL=mention-editor-
|
|
526
|
+
//# sourceMappingURL=mention-editor-4KS5HCV6.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TurnDriveResult } from '@tangle-network/sandbox';
|
|
2
|
+
import type { Outcome } from '../sandbox/outcome';
|
|
3
|
+
/** The stable identity a Workflow reuses on every retry of one turn. */
|
|
4
|
+
export interface DetachedTurnWorkflowIdentity {
|
|
5
|
+
/** Sandbox session resume key. */
|
|
6
|
+
sessionId: string;
|
|
7
|
+
/** Sandbox completed-turn idempotency key. */
|
|
8
|
+
turnId: string;
|
|
9
|
+
}
|
|
10
|
+
/** The part of Cloudflare's Workflow event needed by the tick. */
|
|
11
|
+
export interface CloudflareWorkflowEventLike<TPayload> {
|
|
12
|
+
payload: TPayload;
|
|
13
|
+
}
|
|
14
|
+
/** A duration accepted by Cloudflare Workflow `step.sleep`. */
|
|
15
|
+
export type CloudflareWorkflowSleepDuration = `${number} ${'second' | 'seconds' | 'minute' | 'minutes' | 'hour' | 'hours' | 'day' | 'days' | 'week' | 'weeks' | 'month' | 'months' | 'year' | 'years'}` | number;
|
|
16
|
+
/** The durable Workflow operations used by the tick. */
|
|
17
|
+
export interface CloudflareWorkflowStepLike {
|
|
18
|
+
do<T>(name: string, callback: (context: unknown) => Promise<T>): Promise<T>;
|
|
19
|
+
sleep(name: string, duration: CloudflareWorkflowSleepDuration): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** The states returned by the Sandbox `driveTurn` primitive. */
|
|
22
|
+
export type DetachedTurnDriveState = TurnDriveResult['state'];
|
|
23
|
+
/** The terminal result passed to product settlement. */
|
|
24
|
+
export type DetachedTurnTerminalResult = Exclude<TurnDriveResult, {
|
|
25
|
+
state: 'running';
|
|
26
|
+
}>;
|
|
27
|
+
/** A drive call's retryable transport boundary. */
|
|
28
|
+
export type DetachedTurnDriveOutcome = Outcome<TurnDriveResult>;
|
|
29
|
+
/** Options for one durable detached-turn Workflow run. */
|
|
30
|
+
export interface DetachedTurnWorkflowTickOptions<TPayload extends DetachedTurnWorkflowIdentity, TSettled> {
|
|
31
|
+
/** The Workflow event. Its payload must keep the same session and turn ids. */
|
|
32
|
+
event: CloudflareWorkflowEventLike<TPayload>;
|
|
33
|
+
/** Cloudflare's durable step runner. */
|
|
34
|
+
step: CloudflareWorkflowStepLike;
|
|
35
|
+
/**
|
|
36
|
+
* Run exactly one `driveSandboxTurn`/`box.driveTurn` pass.
|
|
37
|
+
*
|
|
38
|
+
* The callback runs inside one `step.do`. A transport failure is thrown from
|
|
39
|
+
* that step so Cloudflare retries the pass with the same deterministic ids.
|
|
40
|
+
*/
|
|
41
|
+
drive: (payload: TPayload) => Promise<DetachedTurnDriveOutcome>;
|
|
42
|
+
/**
|
|
43
|
+
* Read the completed Sandbox cache/session records and persist the product's
|
|
44
|
+
* deterministic assistant row. This callback MUST be idempotent because a
|
|
45
|
+
* Worker can stop after the write and before the Workflow step commits.
|
|
46
|
+
*/
|
|
47
|
+
settle: (payload: TPayload, result: DetachedTurnTerminalResult) => Promise<TSettled>;
|
|
48
|
+
/** Delay between one-tick drive passes. */
|
|
49
|
+
pollDelay?: CloudflareWorkflowSleepDuration;
|
|
50
|
+
/** Stable prefix for the Workflow's drive and wait step names. */
|
|
51
|
+
stepName?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Drive one detached Sandbox turn from a Cloudflare Workflow.
|
|
55
|
+
*
|
|
56
|
+
* Each drive step makes one prompt admission/status pass and returns promptly.
|
|
57
|
+
* A running pass sleeps durably before the next pass. The final settlement is
|
|
58
|
+
* also a step, so replayed Workflow execution never holds a live stream open.
|
|
59
|
+
*/
|
|
60
|
+
export declare function runDetachedTurnWorkflowTick<TPayload extends DetachedTurnWorkflowIdentity, TSettled>(options: DetachedTurnWorkflowTickOptions<TPayload, TSettled>): Promise<TSettled>;
|