zidane 5.0.3 → 5.0.5

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.
@@ -179,18 +179,37 @@ function modelsForDescriptor(descriptor) {
179
179
  }
180
180
  }
181
181
  /**
182
- * Look up the model's max context window via the descriptor's model source.
183
- * Returns `null` when the model isn't known (custom slugs, providers without
184
- * a registry); callers should hide the context indicator in that case.
182
+ * Resolve a single model's metadata via the descriptor's model source.
183
+ * Mirrors {@link modelsForDescriptor} routing: descriptor's own list wins,
184
+ * pi-ai's registry is the fallback. Returns `null` when the model isn't
185
+ * known.
185
186
  */
186
- function getContextWindow(descriptor, modelId) {
187
- if (descriptor.models) return descriptor.models.find((m) => m.id === modelId)?.contextWindow ?? null;
187
+ function getModelInfo(descriptor, modelId) {
188
+ if (descriptor.models) return descriptor.models.find((m) => m.id === modelId) ?? null;
188
189
  try {
189
- return getModel(piIdOf(descriptor), modelId)?.contextWindow ?? null;
190
+ return getModel(piIdOf(descriptor), modelId) ?? null;
190
191
  } catch {
191
192
  return null;
192
193
  }
193
194
  }
195
+ /**
196
+ * Look up the model's max context window via the descriptor's model source.
197
+ * Returns `null` when the model isn't known (custom slugs, providers without
198
+ * a registry); callers should hide the context indicator in that case.
199
+ */
200
+ function getContextWindow(descriptor, modelId) {
201
+ return getModelInfo(descriptor, modelId)?.contextWindow ?? null;
202
+ }
203
+ /**
204
+ * Whether the given model exposes a reasoning / extended-thinking knob.
205
+ * Drives the TUI's effort picker visibility — the `ctrl+n` shortcut and
206
+ * the bottom-bar `effortName` segment only surface when this is `true`.
207
+ * Returns `false` for unknown models (no registry entry → no advertised
208
+ * capability).
209
+ */
210
+ function modelSupportsReasoning(descriptor, modelId) {
211
+ return getModelInfo(descriptor, modelId)?.reasoning === true;
212
+ }
194
213
  //#endregion
195
214
  //#region src/chat/credentials.ts
196
215
  /** POSIX mode for the credentials file. Ignored on Windows. */
@@ -2601,6 +2620,79 @@ function buildMcpServers(opts) {
2601
2620
  return opts.discovered.filter((d) => allow.has(d.config.name)).map((d) => d.config);
2602
2621
  }
2603
2622
  //#endregion
2623
+ //#region src/chat/model-catalog.ts
2624
+ /**
2625
+ * Build the unified catalog from a list of available providers.
2626
+ *
2627
+ * Provider order is preserved (callers typically pass the picker order
2628
+ * — alphabetical, auth-detection order, etc.); model order inside each
2629
+ * provider matches whatever `modelsFor` returns. The current selection
2630
+ * (when set) is bubbled to the top of its provider's section so it
2631
+ * shows first without disturbing relative ordering elsewhere.
2632
+ *
2633
+ * `modelsFor` is injected (not imported from `./providers`) so the same
2634
+ * helper works with hosts that supply their own model resolver via
2635
+ * `ResolvedConfig.modelsFor`.
2636
+ */
2637
+ function buildModelCatalog(opts) {
2638
+ const entries = [];
2639
+ for (const provider of opts.providers) {
2640
+ const models = opts.modelsFor(provider.key);
2641
+ if (models.length === 0) continue;
2642
+ let ordered = models;
2643
+ if (opts.current?.providerKey === provider.key) {
2644
+ const idx = models.findIndex((m) => m.id === opts.current?.modelId);
2645
+ if (idx > 0) {
2646
+ const next = models.slice();
2647
+ const [active] = next.splice(idx, 1);
2648
+ next.unshift(active);
2649
+ ordered = next;
2650
+ }
2651
+ }
2652
+ for (const model of ordered) entries.push({
2653
+ providerKey: provider.key,
2654
+ providerLabel: provider.label,
2655
+ model,
2656
+ searchCorpus: buildSearchCorpus(provider, model)
2657
+ });
2658
+ }
2659
+ return entries;
2660
+ }
2661
+ /**
2662
+ * Filter `catalog` by a user query. Empty / whitespace-only queries
2663
+ * pass everything through unchanged (`O(1)` short-circuit). Multi-term
2664
+ * queries (space-separated) require EVERY term to appear somewhere in
2665
+ * the entry's search corpus — so `"claude opus"` matches `claude-opus-4`
2666
+ * regardless of how the words are interleaved with provider names.
2667
+ *
2668
+ * Match is case-insensitive (the corpus is pre-lowercased; the query
2669
+ * is lowercased once per call).
2670
+ */
2671
+ function filterModelCatalog(catalog, query) {
2672
+ const trimmed = query.trim().toLowerCase();
2673
+ if (!trimmed) return catalog.slice();
2674
+ const terms = trimmed.split(/\s+/);
2675
+ return catalog.filter((entry) => terms.every((t) => entry.searchCorpus.includes(t)));
2676
+ }
2677
+ /**
2678
+ * Find a catalog entry's index by its `{providerKey, modelId}` tuple.
2679
+ * Returns `-1` when not present. Useful when re-rendering the picker
2680
+ * (a query just narrowed the list, where did the selection land?).
2681
+ */
2682
+ function indexOfEntry(catalog, target) {
2683
+ if (!target) return -1;
2684
+ return catalog.findIndex((e) => e.providerKey === target.providerKey && e.model.id === target.modelId);
2685
+ }
2686
+ function buildSearchCorpus(provider, model) {
2687
+ return [
2688
+ provider.key,
2689
+ provider.label,
2690
+ model.id,
2691
+ model.name ?? "",
2692
+ model.provider ?? ""
2693
+ ].join(" ").toLowerCase();
2694
+ }
2695
+ //#endregion
2604
2696
  //#region src/chat/oauth.ts
2605
2697
  function supportsOAuth(descriptor) {
2606
2698
  return descriptor.oauthProvider !== void 0;
@@ -3582,6 +3674,6 @@ function countNeighbors(turnIds, turnId) {
3582
3674
  };
3583
3675
  }
3584
3676
  //#endregion
3585
- export { BUILTIN_THEMES as $, BUILTIN_AGENTS as $t, readProjects as A, applyInsert as At, cleanTitle as B, removeProviderCredential as Bt, useSafeModeQueue as C, findGitRoot$1 as Ct, isOnSafelist as D, FILES_TRIGGER as Dt, getSafelist as E, uniqueSkillNamesFromReferences as Et, supportsOAuth as F, detectAuth as Ft, shortId as G, cerebrasDescriptor as Gt, ageString as H, writeCredentials as Ht, buildMcpServers as I, applyApiKeyEnv as It, DEFAULT_SETTINGS as J, modelsForDescriptor as Jt, listProjectFiles as K, credKeyOf as Kt, defaultMcpsConfigPaths as L, credentialsPath as Lt, writeProjects as M, findActiveTrigger as Mt, splitPromptSegments as N, mergeReferences as Nt, matchesSafelistEntry as O, createFilesCompletionProvider as Ot, runOAuthLogin as P, useCompletion as Pt, useSettings as Q, BUILD_AGENT as Qt, discoverProjectMcps as R, readCredentials as Rt, useSafeModeActions as S, toolResultText as St, addToSafelist as T, createSkillsCompletionProvider as Tt, compactPath as U, BUILTIN_PROVIDERS as Ut, generateSessionTitle as V, setProviderCredential as Vt, fmtTokens as W, anthropicDescriptor as Wt, SETTINGS_TOGGLES as X, openrouterDescriptor as Xt, SETTINGS_CHOICES as Y, openaiDescriptor as Yt, SettingsProvider as Z, piIdOf as Zt, discoverProjectSkills as _, saveState as _t, ThemeProvider as a, CATPPUCCIN_LATTE as at, writeSessionExport as b, titleFromTurns as bt, useSurfaces as c, ConfigProvider as ct, finalizeStreamingMarkdown as d, createStateStore as dt, DEFAULT_AGENT_ID as en, DEFAULT_THEME as et, finalizeStreamingMarkdownForOwner as f, deriveSessionTitle as ft, defaultSkillScanPaths as g, loadState as gt, buildSkillsConfig as h, listSessionMeta as ht, turnAsText as i, CATPPUCCIN_FRAPPE as it, suggestSafelistEntry as j, collectReferences as jt, projectsFilePath as k, uniqueFilesFromReferences as kt, useSyntaxStyles as l, useConfig as lt, useStreamBuffer as m, lastContextSizeFromTurns as mt, deleteTurnSafely as n, resolveAgentId as nn, resolveTheme as nt, useColors as o, CATPPUCCIN_MACCHIATO as ot, turnContextSize as p, eventsFromTurns as pt, useEnabledToggleSet as q, getContextWindow as qt, truncateTurnsAt as r, singleAgentRegistry as rn, VAPORWAVE_THEME as rt, useSelectStyle as s, CATPPUCCIN_MOCHA as st, countNeighbors as t, PLAN_AGENT as tn, resolveChipColor as tt, useTheme as u, resolveConfig as ut, renderSession as v, selectableTurnIds as vt, IMPLICITLY_SAFE_TOOLS as w, SKILLS_TRIGGER as wt, SafeModeProvider as x, toolCallPreview as xt, resolveSessionExportTarget as y, stripSpawnTokensLine as yt, parseMcpsFile as z, readProviderCredential as zt };
3677
+ export { SETTINGS_TOGGLES as $, modelsForDescriptor as $t, readProjects as A, FILES_TRIGGER as At, defaultMcpsConfigPaths as B, credentialsPath as Bt, useSafeModeQueue as C, titleFromTurns as Ct, isOnSafelist as D, SKILLS_TRIGGER as Dt, getSafelist as E, findGitRoot$1 as Et, supportsOAuth as F, findActiveTrigger as Ft, ageString as G, writeCredentials as Gt, parseMcpsFile as H, readProviderCredential as Ht, buildModelCatalog as I, mergeReferences as It, shortId as J, cerebrasDescriptor as Jt, compactPath as K, BUILTIN_PROVIDERS as Kt, filterModelCatalog as L, useCompletion as Lt, writeProjects as M, uniqueFilesFromReferences as Mt, splitPromptSegments as N, applyInsert as Nt, matchesSafelistEntry as O, createSkillsCompletionProvider as Ot, runOAuthLogin as P, collectReferences as Pt, SETTINGS_CHOICES as Q, modelSupportsReasoning as Qt, indexOfEntry as R, detectAuth as Rt, useSafeModeActions as S, stripSpawnTokensLine as St, addToSafelist as T, toolResultText as Tt, cleanTitle as U, removeProviderCredential as Ut, discoverProjectMcps as V, readCredentials as Vt, generateSessionTitle as W, setProviderCredential as Wt, useEnabledToggleSet as X, getContextWindow as Xt, listProjectFiles as Y, credKeyOf as Yt, DEFAULT_SETTINGS as Z, getModelInfo as Zt, discoverProjectSkills as _, lastContextSizeFromTurns as _t, ThemeProvider as a, DEFAULT_AGENT_ID as an, resolveTheme as at, writeSessionExport as b, saveState as bt, useSurfaces as c, singleAgentRegistry as cn, CATPPUCCIN_LATTE as ct, finalizeStreamingMarkdown as d, ConfigProvider as dt, openaiDescriptor as en, SettingsProvider as et, finalizeStreamingMarkdownForOwner as f, useConfig as ft, defaultSkillScanPaths as g, eventsFromTurns as gt, buildSkillsConfig as h, deriveSessionTitle as ht, turnAsText as i, BUILTIN_AGENTS as in, resolveChipColor as it, suggestSafelistEntry as j, createFilesCompletionProvider as jt, projectsFilePath as k, uniqueSkillNamesFromReferences as kt, useSyntaxStyles as l, CATPPUCCIN_MACCHIATO as lt, useStreamBuffer as m, createStateStore as mt, deleteTurnSafely as n, piIdOf as nn, BUILTIN_THEMES as nt, useColors as o, PLAN_AGENT as on, VAPORWAVE_THEME as ot, turnContextSize as p, resolveConfig as pt, fmtTokens as q, anthropicDescriptor as qt, truncateTurnsAt as r, BUILD_AGENT as rn, DEFAULT_THEME as rt, useSelectStyle as s, resolveAgentId as sn, CATPPUCCIN_FRAPPE as st, countNeighbors as t, openrouterDescriptor as tn, useSettings as tt, useTheme as u, CATPPUCCIN_MOCHA as ut, renderSession as v, listSessionMeta as vt, IMPLICITLY_SAFE_TOOLS as w, toolCallPreview as wt, SafeModeProvider as x, selectableTurnIds as xt, resolveSessionExportTarget as y, loadState as yt, buildMcpServers as z, applyApiKeyEnv as zt };
3586
3678
 
3587
- //# sourceMappingURL=turn-operations-CHS2Prne.js.map
3679
+ //# sourceMappingURL=turn-operations-DZ3TrljX.js.map