clawfast 2.2.1 → 2.2.2
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/clawfast.cjs +126 -5
- package/package.json +1 -1
package/dist/clawfast.cjs
CHANGED
|
@@ -689,7 +689,7 @@ var clawfastVersion, isDevVersion, isNewerVersion;
|
|
|
689
689
|
var init_version = __esm({
|
|
690
690
|
"src/version.ts"() {
|
|
691
691
|
"use strict";
|
|
692
|
-
clawfastVersion = () => true ? "2.2.
|
|
692
|
+
clawfastVersion = () => true ? "2.2.2" : devVersionFromPackageJson();
|
|
693
693
|
isDevVersion = () => clawfastVersion().includes("-dev");
|
|
694
694
|
isNewerVersion = (a, b) => {
|
|
695
695
|
const parse3 = (v) => v.split("-")[0].split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
@@ -45808,6 +45808,9 @@ function resolveLanguageModel2(key) {
|
|
|
45808
45808
|
if (isOpenRouterDynamicKey(key)) {
|
|
45809
45809
|
return openrouter2(openRouterSlugFromKey(key));
|
|
45810
45810
|
}
|
|
45811
|
+
if (isNvidiaDynamicKey(key)) {
|
|
45812
|
+
return nvidia.chat(nvidiaSlugFromKey(key));
|
|
45813
|
+
}
|
|
45811
45814
|
return myProvider.languageModel(key);
|
|
45812
45815
|
}
|
|
45813
45816
|
async function listOpenRouterModels(signal) {
|
|
@@ -45833,7 +45836,25 @@ async function listOpenRouterModels(signal) {
|
|
|
45833
45836
|
};
|
|
45834
45837
|
}).filter((m) => m !== null).sort((a, b) => a.name.localeCompare(b.name));
|
|
45835
45838
|
}
|
|
45836
|
-
|
|
45839
|
+
async function listNvidiaModels(signal) {
|
|
45840
|
+
const key = process.env.NVIDIA_API_KEY?.trim();
|
|
45841
|
+
if (!key) throw new Error("NVIDIA_API_KEY n\xE3o configurada");
|
|
45842
|
+
const baseURL = process.env.NVIDIA_BASE_URL || "https://integrate.api.nvidia.com/v1";
|
|
45843
|
+
const res = await fetch(`${baseURL.replace(/\/$/, "")}/models`, {
|
|
45844
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
45845
|
+
signal
|
|
45846
|
+
});
|
|
45847
|
+
if (!res.ok) {
|
|
45848
|
+
throw new Error(`NVIDIA /models falhou: HTTP ${res.status}`);
|
|
45849
|
+
}
|
|
45850
|
+
const json3 = await res.json();
|
|
45851
|
+
const data = Array.isArray(json3.data) ? json3.data : [];
|
|
45852
|
+
return data.map((raw) => {
|
|
45853
|
+
if (!isRecord(raw) || typeof raw.id !== "string") return null;
|
|
45854
|
+
return { id: raw.id, name: raw.id };
|
|
45855
|
+
}).filter((m) => m !== null).sort((a, b) => a.id.localeCompare(b.id));
|
|
45856
|
+
}
|
|
45857
|
+
var isRecord, isXaiModelSlug, isGeminiModelSlug, requestCanRouteToXai, requestCanRouteToGemini, hasOwnEncryptedContent, stripEncryptedContent, sanitizeOpenRouterRequestForXai, hasJsonRefKey, wrapToolContentIfGeminiRefSensitive, sanitizeOpenRouterRequestForGeminiFunctionResponses, patchKimiReasoningToolCalls, OPENROUTER_METADATA_HEADER, withOpenRouterMetadataHeader, openrouterPatchFetch, openrouter2, openai2, isNvidiaMistralModel, applyNvidiaMistralConfig, nvidiaPatchFetch, nvidia, deepseek, kimi, buildProviderMap, hasEnvValue, isDeepSeekEnabled, isKimiEnabled, CLI_MODEL_CHAIN, baseProviders, modelCutoffDates, modelDisplayNames, getModelDisplayName, getModelCutoffDate, myProvider, OPENROUTER_KEY_PREFIX, hasOpenRouterKey, isOpenRouterDynamicKey, openRouterSlugFromKey, openRouterKeyForSlug, NVIDIA_KEY_PREFIX, hasNvidiaKey, isNvidiaDynamicKey, nvidiaSlugFromKey, nvidiaKeyForSlug;
|
|
45837
45858
|
var init_providers = __esm({
|
|
45838
45859
|
"../lib/ai/providers.ts"() {
|
|
45839
45860
|
"use strict";
|
|
@@ -46180,6 +46201,11 @@ var init_providers = __esm({
|
|
|
46180
46201
|
isOpenRouterDynamicKey = (key) => key.startsWith(OPENROUTER_KEY_PREFIX);
|
|
46181
46202
|
openRouterSlugFromKey = (key) => key.slice(OPENROUTER_KEY_PREFIX.length);
|
|
46182
46203
|
openRouterKeyForSlug = (slug) => `${OPENROUTER_KEY_PREFIX}${slug}`;
|
|
46204
|
+
NVIDIA_KEY_PREFIX = "nvidia:";
|
|
46205
|
+
hasNvidiaKey = () => Boolean(process.env.NVIDIA_API_KEY?.trim());
|
|
46206
|
+
isNvidiaDynamicKey = (key) => key.startsWith(NVIDIA_KEY_PREFIX);
|
|
46207
|
+
nvidiaSlugFromKey = (key) => key.slice(NVIDIA_KEY_PREFIX.length);
|
|
46208
|
+
nvidiaKeyForSlug = (slug) => `${NVIDIA_KEY_PREFIX}${slug}`;
|
|
46183
46209
|
}
|
|
46184
46210
|
});
|
|
46185
46211
|
|
|
@@ -71775,6 +71801,33 @@ async function createAgent() {
|
|
|
71775
71801
|
selection: getModelSelection()
|
|
71776
71802
|
};
|
|
71777
71803
|
}
|
|
71804
|
+
if (isNvidiaDynamicKey(raw)) {
|
|
71805
|
+
if (!hasNvidiaKey()) {
|
|
71806
|
+
return {
|
|
71807
|
+
ok: false,
|
|
71808
|
+
message: "NVIDIA indispon\xEDvel: defina NVIDIA_API_KEY em .env.local (https://build.nvidia.com/)",
|
|
71809
|
+
selection: getModelSelection()
|
|
71810
|
+
};
|
|
71811
|
+
}
|
|
71812
|
+
const slug = nvidiaSlugFromKey(raw).trim();
|
|
71813
|
+
if (!slug) {
|
|
71814
|
+
return {
|
|
71815
|
+
ok: false,
|
|
71816
|
+
message: "informe o modelo NVIDIA (ex.: nvidia:openai/gpt-oss-120b)",
|
|
71817
|
+
selection: getModelSelection()
|
|
71818
|
+
};
|
|
71819
|
+
}
|
|
71820
|
+
const key = nvidiaKeyForSlug(slug);
|
|
71821
|
+
selectedModelKey = key;
|
|
71822
|
+
currentModelName = key;
|
|
71823
|
+
context2.modelName = key;
|
|
71824
|
+
await rebuildSystemPrompt(key);
|
|
71825
|
+
return {
|
|
71826
|
+
ok: true,
|
|
71827
|
+
message: `modelo fixado: ${labelFor(key)}`,
|
|
71828
|
+
selection: getModelSelection()
|
|
71829
|
+
};
|
|
71830
|
+
}
|
|
71778
71831
|
const choices = getModelChoices();
|
|
71779
71832
|
let match;
|
|
71780
71833
|
if (/^\d+$/.test(normalized)) {
|
|
@@ -72272,6 +72325,8 @@ ${resultText}`
|
|
|
72272
72325
|
setModelSelection,
|
|
72273
72326
|
isOpenRouterAvailable: hasOpenRouterKey,
|
|
72274
72327
|
listOpenRouterModels: (signal) => listOpenRouterModels(signal),
|
|
72328
|
+
isNvidiaAvailable: hasNvidiaKey,
|
|
72329
|
+
listNvidiaModels: (signal) => listNvidiaModels(signal),
|
|
72275
72330
|
close
|
|
72276
72331
|
};
|
|
72277
72332
|
}
|
|
@@ -72397,7 +72452,7 @@ Regras:
|
|
|
72397
72452
|
"fallback-openai-chat-latest": "OpenAI - chat-latest",
|
|
72398
72453
|
"model-nvidia-nemotron": "NVIDIA - nemotron-3-ultra-550b"
|
|
72399
72454
|
};
|
|
72400
|
-
labelFor = (key) => isOpenRouterDynamicKey(key) ? `OpenRouter - ${openRouterSlugFromKey(key)}` : MODEL_LABELS[key] ?? key;
|
|
72455
|
+
labelFor = (key) => isOpenRouterDynamicKey(key) ? `OpenRouter - ${openRouterSlugFromKey(key)}` : isNvidiaDynamicKey(key) ? `NVIDIA - ${nvidiaSlugFromKey(key)}` : MODEL_LABELS[key] ?? key;
|
|
72401
72456
|
loginRequiredHint = (msg) => {
|
|
72402
72457
|
if (/account is suspended|violation of user policies|account has been suspended/i.test(
|
|
72403
72458
|
msg
|
|
@@ -73252,7 +73307,7 @@ async function main() {
|
|
|
73252
73307
|
`
|
|
73253
73308
|
);
|
|
73254
73309
|
const COMMANDS = [
|
|
73255
|
-
{ name: "/model", desc: "trocar o modelo (setas; OpenRouter c/ busca)" },
|
|
73310
|
+
{ name: "/model", desc: "trocar o modelo (setas; NVIDIA/OpenRouter c/ busca)" },
|
|
73256
73311
|
{ name: "/api", desc: "trocar chave de API (NVIDIA / OpenRouter)" },
|
|
73257
73312
|
{ name: "/skills", desc: "listar as skills instaladas" },
|
|
73258
73313
|
{ name: "/skillcreator", desc: "criar uma nova skill" },
|
|
@@ -73529,6 +73584,7 @@ ${C5.dim}ja disponivel para todos os modelos nesta sessao.${C5.reset}
|
|
|
73529
73584
|
}
|
|
73530
73585
|
];
|
|
73531
73586
|
const openRouterProvider = KEY_PROVIDERS.find((p) => p.id === "openrouter");
|
|
73587
|
+
const nvidiaProvider = KEY_PROVIDERS.find((p) => p.id === "nvidia");
|
|
73532
73588
|
const promptAndSwapKey = async (provider, inlineKey = "") => {
|
|
73533
73589
|
let raw = inlineKey;
|
|
73534
73590
|
if (!raw) {
|
|
@@ -73632,9 +73688,60 @@ ${C5.dim}salva em ${C5.reset}${C5.cyan}${file2}${C5.reset}
|
|
|
73632
73688
|
printFatal(err);
|
|
73633
73689
|
}
|
|
73634
73690
|
};
|
|
73691
|
+
const openNvidiaPicker = async () => {
|
|
73692
|
+
if (!agent.isNvidiaAvailable()) {
|
|
73693
|
+
process.stdout.write(
|
|
73694
|
+
`${C5.dim}NVIDIA ainda sem chave. Vamos adicionar uma.${C5.reset}
|
|
73695
|
+
`
|
|
73696
|
+
);
|
|
73697
|
+
const ok = await promptAndSwapKey(nvidiaProvider);
|
|
73698
|
+
if (!ok) return;
|
|
73699
|
+
}
|
|
73700
|
+
process.stdout.write(`${C5.dim}buscando cat\xE1logo NVIDIA\u2026${C5.reset}
|
|
73701
|
+
`);
|
|
73702
|
+
let models;
|
|
73703
|
+
try {
|
|
73704
|
+
models = await agent.listNvidiaModels();
|
|
73705
|
+
} catch (err) {
|
|
73706
|
+
process.stdout.write(
|
|
73707
|
+
`${C5.red}\u2717 falha ao listar modelos NVIDIA: ${err instanceof Error ? err.message : String(err)}${C5.reset}
|
|
73708
|
+
`
|
|
73709
|
+
);
|
|
73710
|
+
return;
|
|
73711
|
+
}
|
|
73712
|
+
if (models.length === 0) {
|
|
73713
|
+
process.stdout.write(
|
|
73714
|
+
`${C5.yellow}\u26A0 a NVIDIA n\xE3o retornou nenhum modelo${C5.reset}
|
|
73715
|
+
`
|
|
73716
|
+
);
|
|
73717
|
+
return;
|
|
73718
|
+
}
|
|
73719
|
+
const items = models.map((m) => ({
|
|
73720
|
+
label: m.name,
|
|
73721
|
+
hint: m.id
|
|
73722
|
+
}));
|
|
73723
|
+
const choice2 = await inputUI.searchSelect(
|
|
73724
|
+
"NVIDIA \u2014 buscar modelo",
|
|
73725
|
+
items,
|
|
73726
|
+
{ placeholder: "digite para filtrar (nome ou slug)" }
|
|
73727
|
+
);
|
|
73728
|
+
if (choice2 === null) {
|
|
73729
|
+
process.stdout.write(`${C5.dim}sele\xE7\xE3o de modelo cancelada${C5.reset}
|
|
73730
|
+
`);
|
|
73731
|
+
return;
|
|
73732
|
+
}
|
|
73733
|
+
try {
|
|
73734
|
+
printModelResult(
|
|
73735
|
+
await agent.setModelSelection(`nvidia:${models[choice2].id}`)
|
|
73736
|
+
);
|
|
73737
|
+
} catch (err) {
|
|
73738
|
+
printFatal(err);
|
|
73739
|
+
}
|
|
73740
|
+
};
|
|
73635
73741
|
const openModelSelector = async () => {
|
|
73636
73742
|
const state = agent.getModelSelection();
|
|
73637
73743
|
const orAvailable = agent.isOpenRouterAvailable();
|
|
73744
|
+
const nvAvailable = agent.isNvidiaAvailable();
|
|
73638
73745
|
const items = [
|
|
73639
73746
|
{
|
|
73640
73747
|
label: "Auto \u2014 cadeia de fallback autom\xE1tica",
|
|
@@ -73642,13 +73749,19 @@ ${C5.dim}salva em ${C5.reset}${C5.cyan}${file2}${C5.reset}
|
|
|
73642
73749
|
},
|
|
73643
73750
|
...state.chain.map((c) => ({ label: c.label, hint: c.key }))
|
|
73644
73751
|
];
|
|
73752
|
+
const nvidiaIdx = items.length;
|
|
73753
|
+
items.push({
|
|
73754
|
+
label: "NVIDIA \u2014 buscar no cat\xE1logo completo",
|
|
73755
|
+
hint: nvAvailable ? "lista todos os modelos da NVIDIA build" : "pede a API key e lista o cat\xE1logo"
|
|
73756
|
+
});
|
|
73645
73757
|
const openRouterIdx = items.length;
|
|
73646
73758
|
items.push({
|
|
73647
73759
|
label: "OpenRouter \u2014 buscar no cat\xE1logo completo",
|
|
73648
73760
|
hint: orAvailable ? "lista todos os modelos da sua conta" : "pede a API key e lista o cat\xE1logo"
|
|
73649
73761
|
});
|
|
73650
73762
|
const activeIsOpenRouter = state.activeModelKey.startsWith("openrouter:");
|
|
73651
|
-
const
|
|
73763
|
+
const activeIsNvidiaDynamic = state.activeModelKey.startsWith("nvidia:");
|
|
73764
|
+
const activeIdx = state.mode === "auto" ? 0 : activeIsNvidiaDynamic ? nvidiaIdx : activeIsOpenRouter ? openRouterIdx : Math.max(
|
|
73652
73765
|
0,
|
|
73653
73766
|
1 + state.chain.findIndex((c) => c.key === state.activeModelKey)
|
|
73654
73767
|
);
|
|
@@ -73658,6 +73771,10 @@ ${C5.dim}salva em ${C5.reset}${C5.cyan}${file2}${C5.reset}
|
|
|
73658
73771
|
`);
|
|
73659
73772
|
return;
|
|
73660
73773
|
}
|
|
73774
|
+
if (choice2 === nvidiaIdx) {
|
|
73775
|
+
await openNvidiaPicker();
|
|
73776
|
+
return;
|
|
73777
|
+
}
|
|
73661
73778
|
if (choice2 === openRouterIdx) {
|
|
73662
73779
|
await openOpenRouterPicker();
|
|
73663
73780
|
return;
|
|
@@ -73720,6 +73837,10 @@ ${C5.dim}salva em ${C5.reset}${C5.cyan}${file2}${C5.reset}
|
|
|
73720
73837
|
await openOpenRouterPicker();
|
|
73721
73838
|
return;
|
|
73722
73839
|
}
|
|
73840
|
+
if (arg.toLowerCase() === "nvidia" || arg.toLowerCase() === "nv") {
|
|
73841
|
+
await openNvidiaPicker();
|
|
73842
|
+
return;
|
|
73843
|
+
}
|
|
73723
73844
|
try {
|
|
73724
73845
|
printModelResult(await agent.setModelSelection(arg));
|
|
73725
73846
|
} catch (err) {
|