@marimo-team/islands 0.23.9-dev21 → 0.23.9-dev22

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.
@@ -34996,7 +34996,7 @@ ${d}`,
34996
34996
  return Logger.warn("Failed to get version from mount config"), null;
34997
34997
  }
34998
34998
  }
34999
- marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.9-dev21");
34999
+ marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.9-dev22");
35000
35000
  showCodeInRunModeAtom = atom(true);
35001
35001
  atom(null);
35002
35002
  var import_compiler_runtime = require_compiler_runtime();
package/dist/main.js CHANGED
@@ -26,7 +26,7 @@ import { $ as useCellActions, At as DeferredRequestRegistry, B as safeExtractSet
26
26
  import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BNjes6Yx.js";
27
27
  import { o as useSize, s as Root$2, u as createLucideIcon } from "./dist-C1BYNeCR.js";
28
28
  import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-CyLiCjSf.js";
29
- import { $ as TableBody, $t as ChevronLeft, A as ComboboxItem, At as ChartErrorState, B as contextAwarePanelOpen, Bt as $fae977aafc393c5c$export$6b862160d295c8e, C as prettifyRowColumnCount, Ct as dateToLocalISODate, D as DatePicker, Dt as TabsContent, E as useInternalStateWithSync, Et as Tabs, F as CommandList, Ft as RenderTextWithLinks, G as slotsController, H as contextAwarePanelType, Ht as GripHorizontal, I as CommandSeparator, It as Kbd, Jt as Code, K as Toggle, Kt as Ellipsis, L as smartMatch, Lt as HtmlOutput, M as CommandEmpty, Mt as ChartLoadingState, N as CommandInput, Nt as LazyVegaEmbed, O as DateRangePicker, Ot as TabsList, P as CommandItem, Pt as useOverflowDetection, Q as Table, Qt as ChevronsDownUp, R as ContextAwarePanelItem, Rt as EmotionCacheProvider, S as downloadSizeLimitAtom, St as Maps, T as getColumnCountForDisplay, Tt as dateToLocalISOTime, U as isCellAwareAtom, Ut as Funnel, V as contextAwarePanelOwner, Vt as TextWrap, W as SlotNames, Wt as EyeOff, X as Fill, Xt as ChevronsRight, Yt as ChevronsUpDown, Z as Provider$1, Zt as ChevronsLeft, _ as downloadBlob, _t as SELECT_COLUMN_ID, at as generateColumns, b as Progress, bt as getMimeValues, c as Slide, ct as ColumnChartContext, d as JsonOutput, dt as useIntersectionObserver, en as ArrowDownWideNarrow, et as TableCell, f as OutputArea, ft as usePrevious$1, g as ADD_PRINTING_CLASS, gt as INDEX_COLUMN_NAME, h as InstallPackageButton, ht as loadTableData, it as NAMELESS_COLUMN_PREFIX, j as Command, jt as ChartInfoState, k as Combobox, kt as TabsTrigger, l as RadioGroup, lt as ColumnChartSpecModel, m as DataTable, mt as loadTableAndRawData, n as marimoVersionAtom, nt as TableHeader, o as SLIDE_TYPE_OPTIONS_BY_VALUE, ot as inferFieldTypes, p as OutputRenderer, pt as getPageIndexForRow, qt as Download, r as showCodeInRunModeAtom, rt as TableRow, st as renderCellValue, t as useNotebookCodeAvailable, tt as TableHead, u as RadioGroupItem, ut as DelayMount, v as downloadByURL, vt as TOO_MANY_ROWS, w as prettifyRowCount, wt as dateToLocalISODateTime, x as Filenames, xt as isNullishFilter, y as downloadHTMLAsImage, yt as toFieldTypes, z as PANEL_TYPES, zt as $fae977aafc393c5c$export$588937bcd60ade55, __tla as __tla_2 } from "./code-visibility-k3JE3fvP.js";
29
+ import { $ as TableBody, $t as ChevronLeft, A as ComboboxItem, At as ChartErrorState, B as contextAwarePanelOpen, Bt as $fae977aafc393c5c$export$6b862160d295c8e, C as prettifyRowColumnCount, Ct as dateToLocalISODate, D as DatePicker, Dt as TabsContent, E as useInternalStateWithSync, Et as Tabs, F as CommandList, Ft as RenderTextWithLinks, G as slotsController, H as contextAwarePanelType, Ht as GripHorizontal, I as CommandSeparator, It as Kbd, Jt as Code, K as Toggle, Kt as Ellipsis, L as smartMatch, Lt as HtmlOutput, M as CommandEmpty, Mt as ChartLoadingState, N as CommandInput, Nt as LazyVegaEmbed, O as DateRangePicker, Ot as TabsList, P as CommandItem, Pt as useOverflowDetection, Q as Table, Qt as ChevronsDownUp, R as ContextAwarePanelItem, Rt as EmotionCacheProvider, S as downloadSizeLimitAtom, St as Maps, T as getColumnCountForDisplay, Tt as dateToLocalISOTime, U as isCellAwareAtom, Ut as Funnel, V as contextAwarePanelOwner, Vt as TextWrap, W as SlotNames, Wt as EyeOff, X as Fill, Xt as ChevronsRight, Yt as ChevronsUpDown, Z as Provider$1, Zt as ChevronsLeft, _ as downloadBlob, _t as SELECT_COLUMN_ID, at as generateColumns, b as Progress, bt as getMimeValues, c as Slide, ct as ColumnChartContext, d as JsonOutput, dt as useIntersectionObserver, en as ArrowDownWideNarrow, et as TableCell, f as OutputArea, ft as usePrevious$1, g as ADD_PRINTING_CLASS, gt as INDEX_COLUMN_NAME, h as InstallPackageButton, ht as loadTableData, it as NAMELESS_COLUMN_PREFIX, j as Command, jt as ChartInfoState, k as Combobox, kt as TabsTrigger, l as RadioGroup, lt as ColumnChartSpecModel, m as DataTable, mt as loadTableAndRawData, n as marimoVersionAtom, nt as TableHeader, o as SLIDE_TYPE_OPTIONS_BY_VALUE, ot as inferFieldTypes, p as OutputRenderer, pt as getPageIndexForRow, qt as Download, r as showCodeInRunModeAtom, rt as TableRow, st as renderCellValue, t as useNotebookCodeAvailable, tt as TableHead, u as RadioGroupItem, ut as DelayMount, v as downloadByURL, vt as TOO_MANY_ROWS, w as prettifyRowCount, wt as dateToLocalISODateTime, x as Filenames, xt as isNullishFilter, y as downloadHTMLAsImage, yt as toFieldTypes, z as PANEL_TYPES, zt as $fae977aafc393c5c$export$588937bcd60ade55, __tla as __tla_2 } from "./code-visibility-smy6VSJ-.js";
30
30
  import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-B81PFEja.js";
31
31
  import { t as Check } from "./check-DTbrK0zt.js";
32
32
  import { A as Trigger$1, C as $a916eb452884faea$export$b7a616150fdb9f44, E as $18f2051aff69b9bf$export$a54013f0d02a8f82, F as X, L as ChevronDown, M as usePrevious$2, N as useDirection, P as createCollection, S as logNever, T as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as clamp$2, k as Icon, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, x as assertNever } from "./strings-Bu3vlb6W.js";
@@ -36093,7 +36093,7 @@ ${c}
36093
36093
  if (l && l !== "slide") return l;
36094
36094
  if (c == null ? void 0 : c.has(e)) return "skip";
36095
36095
  }
36096
- var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-BykBckM-.js"));
36096
+ var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-B0ZyILyK.js"));
36097
36097
  const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
36098
36098
  var _a3;
36099
36099
  let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { cellsWithOutput: h, skippedIds: g, slideTypes: _, startCellIndex: v } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
9
9
  import { ct as kioskModeAtom } from "./html-to-image-Bi7maU1p.js";
10
10
  import "./chunk-5FQGJX7Z-BNjes6Yx.js";
11
11
  import { u as createLucideIcon } from "./dist-C1BYNeCR.js";
12
- import { Gt as Expand, J as PanelGroup, Jt as Code, Wt as EyeOff, Y as PanelResizeHandle, a as DEFAULT_SLIDE_TYPE, c as Slide, i as DEFAULT_DECK_TRANSITION, q as Panel, s as SlideSidebar, t as useNotebookCodeAvailable } from "./code-visibility-k3JE3fvP.js";
12
+ import { Gt as Expand, J as PanelGroup, Jt as Code, Wt as EyeOff, Y as PanelResizeHandle, a as DEFAULT_SLIDE_TYPE, c as Slide, i as DEFAULT_DECK_TRANSITION, q as Panel, s as SlideSidebar, t as useNotebookCodeAvailable } from "./code-visibility-smy6VSJ-.js";
13
13
  import { q as useDebouncedCallback } from "./input-BwcGY_X1.js";
14
14
  import "./toDate-DNWCUEQp.js";
15
15
  import "./react-dom-BTJzcVJ9.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.9-dev21",
3
+ "version": "0.23.9-dev22",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -4,46 +4,51 @@ import type { AiModel } from "@marimo-team/llm-info";
4
4
  import { beforeEach, describe, expect, it, vi } from "vitest";
5
5
  import type { UserConfig } from "@/core/config/config-schema";
6
6
 
7
- // Mock the models.json import
8
7
  vi.mock("@marimo-team/llm-info/models.json", () => {
9
- const models: AiModel[] = [
10
- {
11
- name: "GPT-4",
12
- model: "gpt-4",
13
- description: "OpenAI GPT-4 model",
14
- providers: ["openai"],
15
- roles: ["chat", "edit"],
16
- thinking: false,
17
- },
18
- {
19
- name: "Claude 3",
20
- model: "claude-3-sonnet",
21
- description: "Anthropic Claude 3 Sonnet",
22
- providers: ["anthropic"],
23
- roles: ["chat", "edit"],
24
- thinking: false,
25
- },
26
- {
27
- name: "Gemini Pro",
28
- model: "gemini-pro",
29
- description: "Google Gemini Pro model",
30
- providers: ["google"],
31
- roles: ["chat", "edit"],
32
- thinking: false,
33
- },
34
- {
35
- name: "Ollama Model",
36
- model: "llama2",
37
- description: "Ollama Llama 2 model",
38
- providers: ["ollama"],
39
- roles: ["chat", "edit"],
40
- thinking: false,
41
- },
42
- ];
43
-
44
- return {
45
- models: models,
8
+ const make = (
9
+ overrides: Partial<AiModel> & Pick<AiModel, "name" | "model">,
10
+ ): AiModel => ({
11
+ description: "",
12
+ roles: ["chat", "edit"],
13
+ capabilities: [],
14
+ input_types: [],
15
+ output_types: [],
16
+ release_date: "1970-01-01",
17
+ ...overrides,
18
+ });
19
+
20
+ const models: Record<string, AiModel[]> = {
21
+ openai: [
22
+ make({
23
+ name: "GPT-4",
24
+ model: "gpt-4",
25
+ description: "OpenAI GPT-4 model",
26
+ }),
27
+ ],
28
+ anthropic: [
29
+ make({
30
+ name: "Claude 3",
31
+ model: "claude-3-sonnet",
32
+ description: "Anthropic Claude 3 Sonnet",
33
+ }),
34
+ ],
35
+ google: [
36
+ make({
37
+ name: "Gemini Pro",
38
+ model: "gemini-pro",
39
+ description: "Google Gemini Pro model",
40
+ }),
41
+ ],
42
+ ollama: [
43
+ make({
44
+ name: "Ollama Model",
45
+ model: "llama2",
46
+ description: "Ollama Llama 2 model",
47
+ }),
48
+ ],
46
49
  };
50
+
51
+ return { models };
47
52
  });
48
53
 
49
54
  // Must import after mock
@@ -305,7 +305,7 @@ const AiModelDropdownItem = ({
305
305
  <div className="flex flex-row w-full items-center">
306
306
  <span>{model.name}</span>
307
307
  <div className="ml-auto">
308
- {model.thinking && (
308
+ {model.capabilities.includes("thinking") && (
309
309
  <Tooltip content="Reasoning model">
310
310
  <BrainIcon
311
311
  className={`h-5 w-5 rounded-md p-1 ${getTagColour("thinking")}`}
@@ -362,7 +362,7 @@ export const AiModelInfoDisplay = ({
362
362
  </div>
363
363
  )}
364
364
 
365
- {model.thinking && (
365
+ {model.capabilities.includes("thinking") && (
366
366
  <div className="flex items-center gap-2">
367
367
  <div className="w-2 h-2 bg-purple-500 rounded-full animate-pulse" />
368
368
  <span className="text-xs text-muted-foreground">
@@ -509,7 +509,7 @@ const ModelInfoCard = ({ model }: { model: AiModel }) => {
509
509
  <Tooltip content="Custom model">
510
510
  {model.custom && <BotIcon className="h-4 w-4" />}
511
511
  </Tooltip>
512
- {model.thinking && (
512
+ {model.capabilities.includes("thinking") && (
513
513
  <div
514
514
  className={cn(
515
515
  "flex items-center gap-1 rounded px-1 py-0.5 w-fit",
@@ -1,46 +1,52 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
 
4
- // Mock the models.json import
5
4
  vi.mock("@marimo-team/llm-info/models.json", () => {
6
- const models: AiModel[] = [
7
- {
8
- name: "GPT-4",
9
- model: "gpt-4",
10
- description: "OpenAI GPT-4 model",
11
- providers: ["openai"],
12
- roles: ["chat", "edit"],
13
- thinking: false,
14
- },
15
- {
16
- name: "Claude 3",
17
- model: "claude-3-sonnet",
18
- description: "Anthropic Claude 3 Sonnet",
19
- providers: ["anthropic"],
20
- roles: ["chat", "edit"],
21
- thinking: false,
22
- },
23
- {
24
- name: "Gemini Pro",
25
- model: "gemini-pro",
26
- description: "Google Gemini Pro model",
27
- providers: ["google"],
28
- roles: ["chat", "edit"],
29
- thinking: false,
30
- },
31
- {
32
- name: "Multi Provider Model",
33
- model: "multi-model",
34
- description: "Model available on multiple providers",
35
- providers: ["openai", "anthropic"],
36
- roles: ["chat", "edit"],
37
- thinking: false,
38
- },
39
- ];
40
-
41
- return {
42
- models: models,
5
+ const make = (
6
+ overrides: Partial<AiModel> & Pick<AiModel, "name" | "model">,
7
+ ): AiModel => ({
8
+ description: "",
9
+ roles: ["chat", "edit"],
10
+ capabilities: [],
11
+ input_types: [],
12
+ output_types: [],
13
+ release_date: "1970-01-01",
14
+ ...overrides,
15
+ });
16
+
17
+ const multiModel = make({
18
+ name: "Multi Provider Model",
19
+ model: "multi-model",
20
+ description: "Model available on multiple providers",
21
+ });
22
+
23
+ const models: Record<string, AiModel[]> = {
24
+ openai: [
25
+ make({
26
+ name: "GPT-4",
27
+ model: "gpt-4",
28
+ description: "OpenAI GPT-4 model",
29
+ }),
30
+ multiModel,
31
+ ],
32
+ anthropic: [
33
+ make({
34
+ name: "Claude 3",
35
+ model: "claude-3-sonnet",
36
+ description: "Anthropic Claude 3 Sonnet",
37
+ }),
38
+ multiModel,
39
+ ],
40
+ google: [
41
+ make({
42
+ name: "Gemini Pro",
43
+ model: "gemini-pro",
44
+ description: "Google Gemini Pro model",
45
+ }),
46
+ ],
43
47
  };
48
+
49
+ return { models };
44
50
  });
45
51
 
46
52
  import type { AiModel } from "@marimo-team/llm-info";
@@ -107,14 +113,15 @@ describe("AiModelRegistry", () => {
107
113
  });
108
114
 
109
115
  const ids = [...registry.getModelsMap().keys()];
110
- // Include custom and all default ones.
116
+ // Include custom and all default ones; iteration follows provider
117
+ // sections in the source data (openai → anthropic → google).
111
118
  expect(ids).toEqual([
112
119
  "openai/custom-gpt",
113
120
  "openai/gpt-4",
114
- "anthropic/claude-3-sonnet",
115
- "google/gemini-pro",
116
121
  "openai/multi-model",
122
+ "anthropic/claude-3-sonnet",
117
123
  "anthropic/multi-model",
124
+ "google/gemini-pro",
118
125
  ]);
119
126
  });
120
127
  });
@@ -125,9 +132,9 @@ describe("AiModelRegistry", () => {
125
132
  const openaiModels = registry.getModelsByProvider("openai");
126
133
 
127
134
  expect(openaiModels).toHaveLength(2); // gpt-4 and multi-model
128
- expect(
129
- openaiModels.every((model) => model.providers.includes("openai")),
130
- ).toBe(true);
135
+ expect(openaiModels.every((model) => model.provider === "openai")).toBe(
136
+ true,
137
+ );
131
138
  });
132
139
 
133
140
  it("should return empty array for provider with no models", () => {
@@ -147,9 +154,9 @@ describe("AiModelRegistry", () => {
147
154
  expect(customModel?.name).toBe("custom-gpt");
148
155
  expect(customModel?.model).toBe("custom-gpt");
149
156
  expect(customModel?.description).toBe("Custom model");
150
- expect(customModel?.providers).toEqual(["openai"]);
157
+ expect(customModel?.provider).toBe("openai");
151
158
  expect(customModel?.roles).toEqual([]);
152
- expect(customModel?.thinking).toBe(false);
159
+ expect(customModel?.capabilities).toEqual([]);
153
160
  });
154
161
 
155
162
  it("should filter models based on displayed models", () => {
@@ -309,7 +316,10 @@ describe("AiModelRegistry", () => {
309
316
 
310
317
  expect(multiModelInOpenai).toBeDefined();
311
318
  expect(multiModelInAnthropic).toBeDefined();
312
- expect(multiModelInOpenai).toEqual(multiModelInAnthropic);
319
+ // Same model id, but each entry belongs to its own provider.
320
+ expect(multiModelInOpenai?.provider).toBe("openai");
321
+ expect(multiModelInAnthropic?.provider).toBe("anthropic");
322
+ expect(multiModelInOpenai?.name).toBe(multiModelInAnthropic?.name);
313
323
  });
314
324
 
315
325
  it("should handle displayed models filter with non-existent models", () => {
@@ -339,20 +349,20 @@ describe("AiModelRegistry", () => {
339
349
  expect(model).toHaveProperty("name");
340
350
  expect(model).toHaveProperty("model");
341
351
  expect(model).toHaveProperty("description");
342
- expect(model).toHaveProperty("providers");
352
+ expect(model).toHaveProperty("provider");
343
353
  expect(model).toHaveProperty("roles");
344
- expect(model).toHaveProperty("thinking");
354
+ expect(model).toHaveProperty("capabilities");
345
355
  expect(model).toHaveProperty("custom");
346
356
 
347
357
  expect(typeof model.name).toBe("string");
348
358
  expect(typeof model.model).toBe("string");
349
359
  expect(typeof model.description).toBe("string");
350
- expect(Array.isArray(model.providers)).toBe(true);
360
+ expect(typeof model.provider).toBe("string");
351
361
  expect(Array.isArray(model.roles)).toBe(true);
352
- expect(typeof model.thinking).toBe("boolean");
362
+ expect(Array.isArray(model.capabilities)).toBe(true);
353
363
  expect(typeof model.custom).toBe("boolean");
354
364
 
355
- expect(model.providers).toContain(provider);
365
+ expect(model.provider).toBe(provider);
356
366
  }
357
367
  }
358
368
  });
@@ -367,31 +377,33 @@ describe("AiModelRegistry", () => {
367
377
 
368
378
  expect(customModel).toMatchInlineSnapshot(`
369
379
  {
380
+ "capabilities": [],
370
381
  "custom": true,
371
382
  "description": "Custom model",
383
+ "input_types": [],
372
384
  "model": "custom-gpt",
373
385
  "name": "custom-gpt",
374
- "providers": [
375
- "openai",
376
- ],
386
+ "output_types": [],
387
+ "provider": "openai",
388
+ "release_date": "1970-01-01",
377
389
  "roles": [],
378
- "thinking": false,
379
390
  }
380
391
  `);
381
392
  expect(defaultModel).toMatchInlineSnapshot(`
382
393
  {
394
+ "capabilities": [],
383
395
  "custom": false,
384
396
  "description": "OpenAI GPT-4 model",
397
+ "input_types": [],
385
398
  "model": "gpt-4",
386
399
  "name": "GPT-4",
387
- "providers": [
388
- "openai",
389
- ],
400
+ "output_types": [],
401
+ "provider": "openai",
402
+ "release_date": "1970-01-01",
390
403
  "roles": [
391
404
  "chat",
392
405
  "edit",
393
406
  ],
394
- "thinking": false,
395
407
  }
396
408
  `);
397
409
  });
@@ -1,12 +1,8 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import type {
4
- AiModel as AiModelType,
5
- AiProvider,
6
- Role,
7
- } from "@marimo-team/llm-info";
8
- import { models } from "@marimo-team/llm-info/models.json";
9
- import { providers } from "@marimo-team/llm-info/providers.json";
3
+ import type { AiModel as AiModelType, AiProvider } from "@marimo-team/llm-info";
4
+ import { models as modelsJson } from "@marimo-team/llm-info/models.json";
5
+ import { providers as providersJson } from "@marimo-team/llm-info/providers.json";
10
6
  import { Logger } from "@/utils/Logger";
11
7
  import { MultiMap } from "@/utils/multi-map";
12
8
  import { once } from "@/utils/once";
@@ -14,13 +10,19 @@ import type { ProviderId } from "./ids/ids";
14
10
  import { AiModelId, type QualifiedModelId, type ShortModelId } from "./ids/ids";
15
11
 
16
12
  export interface AiModel extends AiModelType {
17
- roles: Role[];
18
13
  model: ShortModelId;
19
- providers: ProviderId[];
14
+ /** The provider this entry belongs to. */
15
+ provider: ProviderId;
20
16
  /** Whether this is a custom model. */
21
17
  custom: boolean;
22
18
  }
23
19
 
20
+ // JSON shape matches the `AiModel` schema (Zod-validated at codegen time).
21
+ const models = modelsJson as unknown as Partial<
22
+ Record<ProviderId, AiModelType[]>
23
+ >;
24
+ const providers = providersJson as unknown as readonly AiProvider[];
25
+
24
26
  interface KnownModelMaps {
25
27
  /** Map of qualified model ID to model info */
26
28
  modelMap: ReadonlyMap<QualifiedModelId, AiModel>;
@@ -32,24 +34,25 @@ export const getKnownModelMaps = once((): KnownModelMaps => {
32
34
  const modelMap = new Map<QualifiedModelId, AiModel>();
33
35
  const defaultModelByProvider = new Map<ProviderId, QualifiedModelId>();
34
36
 
35
- for (const model of models) {
36
- const modelId = model.model as ShortModelId;
37
- const modelInfo: AiModel = {
38
- ...model,
39
- model: model.model as ShortModelId,
40
- roles: model.roles.map((role) => role as Role),
41
- providers: model.providers as ProviderId[],
42
- custom: false,
43
- };
44
-
45
- const supportsChatOrEdit =
46
- modelInfo.roles.includes("chat") || modelInfo.roles.includes("edit");
37
+ for (const [providerKey, providerModels] of Object.entries(models)) {
38
+ if (!providerModels) {
39
+ continue;
40
+ }
41
+ const provider = providerKey as ProviderId;
42
+ for (const raw of providerModels) {
43
+ const modelId = raw.model as ShortModelId;
44
+ const modelInfo: AiModel = {
45
+ ...raw,
46
+ model: modelId,
47
+ provider,
48
+ custom: false,
49
+ };
47
50
 
48
- for (const provider of modelInfo.providers) {
49
51
  const qualifiedModelId: QualifiedModelId = `${provider}/${modelId}`;
50
52
  modelMap.set(qualifiedModelId, modelInfo);
51
53
 
52
- // Track first model per provider that supports chat or edit
54
+ const supportsChatOrEdit =
55
+ modelInfo.roles.includes("chat") || modelInfo.roles.includes("edit");
53
56
  if (supportsChatOrEdit && !defaultModelByProvider.has(provider)) {
54
57
  defaultModelByProvider.set(provider, qualifiedModelId);
55
58
  }
@@ -67,9 +70,8 @@ const getProviderMap = once(
67
70
  const providerMap = new Map<ProviderId, AiProvider>();
68
71
  const providerToOrderIdx = new Map<ProviderId, number>();
69
72
  providers.forEach((provider, idx) => {
70
- const providerId = provider.id as ProviderId;
71
- providerMap.set(providerId, provider);
72
- providerToOrderIdx.set(providerId, idx);
73
+ providerMap.set(provider.id, provider);
74
+ providerToOrderIdx.set(provider.id, idx);
73
75
  });
74
76
  return { providerMap, providerToOrderIdx };
75
77
  },
@@ -158,9 +160,12 @@ export class AiModelRegistry {
158
160
  name: modelId.shortModelId,
159
161
  model: modelId.shortModelId,
160
162
  description: "Custom model",
161
- providers: [modelId.providerId],
163
+ provider: modelId.providerId,
162
164
  roles: [],
163
- thinking: false,
165
+ capabilities: [],
166
+ input_types: [],
167
+ output_types: [],
168
+ release_date: "1970-01-01",
164
169
  custom: true,
165
170
  };
166
171
  customModelsMap.set(model, modelInfo);