neko-harness 0.4.5 → 0.4.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/README.md +7 -3
- package/dist/client/assets/{index-zaSSWfyH.js → index--Ml3HA5z.js} +58 -58
- package/dist/client/assets/index-Cdi87SA6.css +2 -0
- package/dist/client/index.html +2 -2
- package/dist/gateway.js +274 -61
- package/dist/neko.js +711 -168
- package/package.json +1 -1
- package/dist/client/assets/index-Bwk2sNhZ.css +0 -2
package/dist/neko.js
CHANGED
|
@@ -80,7 +80,7 @@ function updateAction(input) {
|
|
|
80
80
|
return "install";
|
|
81
81
|
return "none";
|
|
82
82
|
}
|
|
83
|
-
var RUNNING_VERSION = "0.4.
|
|
83
|
+
var RUNNING_VERSION = "0.4.6", APPLICATION_PROTOCOL = 8, ApplicationProtocolError;
|
|
84
84
|
var init_application_version = __esm(() => {
|
|
85
85
|
ApplicationProtocolError = class ApplicationProtocolError extends Error {
|
|
86
86
|
constructor() {
|
|
@@ -691,18 +691,71 @@ var init_config = __esm(() => {
|
|
|
691
691
|
});
|
|
692
692
|
|
|
693
693
|
// packages/core/src/credential-providers.ts
|
|
694
|
+
function isModelProvider(id) {
|
|
695
|
+
return MODEL_PROVIDERS.some((item) => item.id === id);
|
|
696
|
+
}
|
|
694
697
|
function credentialProvider(id) {
|
|
695
698
|
const spec = CREDENTIAL_PROVIDERS.find((item) => item.id === id);
|
|
696
699
|
if (!spec)
|
|
697
700
|
throw new Error(`Unknown credential provider: ${id}`);
|
|
698
701
|
return spec;
|
|
699
702
|
}
|
|
700
|
-
|
|
703
|
+
function normalizeEnabledProviders(saved) {
|
|
704
|
+
const wanted = new Set([...LOCKED_PROVIDERS, ...saved ?? DEFAULT_ENABLED_PROVIDERS]);
|
|
705
|
+
return MODEL_PROVIDERS.map((item) => item.id).filter((id) => wanted.has(id));
|
|
706
|
+
}
|
|
707
|
+
var model = (id, name, envVar, signupUrl) => ({ id, kind: "model", name, envVar, signupUrl, keyless: false }), MODEL_PROVIDERS, SEARCH_CREDENTIAL_PROVIDERS, CREDENTIAL_PROVIDERS, DEFAULT_ENABLED_PROVIDERS, LOCKED_PROVIDERS;
|
|
701
708
|
var init_credential_providers = __esm(() => {
|
|
709
|
+
MODEL_PROVIDERS = [
|
|
710
|
+
model("deepseek", "DeepSeek", "DEEPSEEK_API_KEY", "https://platform.deepseek.com/api_keys"),
|
|
711
|
+
model("openrouter", "OpenRouter", "OPENROUTER_API_KEY", "https://openrouter.ai/keys"),
|
|
712
|
+
model("opencode-go", "OpenCode Go", "OPENCODE_API_KEY", "https://opencode.ai/auth"),
|
|
713
|
+
model("opencode", "OpenCode Zen", "OPENCODE_API_KEY", "https://opencode.ai/auth"),
|
|
714
|
+
model("openai", "OpenAI", "OPENAI_API_KEY", "https://platform.openai.com/api-keys"),
|
|
715
|
+
model("google", "Google", "GEMINI_API_KEY", "https://aistudio.google.com/apikey"),
|
|
716
|
+
model("groq", "Groq", "GROQ_API_KEY", "https://console.groq.com/keys"),
|
|
717
|
+
model("mistral", "Mistral", "MISTRAL_API_KEY", "https://console.mistral.ai/api-keys"),
|
|
718
|
+
model("xai", "xAI", "XAI_API_KEY", "https://console.x.ai"),
|
|
719
|
+
model("together", "Together", "TOGETHER_API_KEY", "https://api.together.ai/settings/api-keys"),
|
|
720
|
+
model("fireworks", "Fireworks", "FIREWORKS_API_KEY", "https://fireworks.ai/account/api-keys"),
|
|
721
|
+
model("cerebras", "Cerebras", "CEREBRAS_API_KEY", "https://cloud.cerebras.ai"),
|
|
722
|
+
model("nvidia", "NVIDIA", "NVIDIA_API_KEY", "https://build.nvidia.com/settings/api-keys"),
|
|
723
|
+
model("huggingface", "Hugging Face", "HF_TOKEN", "https://huggingface.co/settings/tokens"),
|
|
724
|
+
model("vercel-ai-gateway", "Vercel AI Gateway", "AI_GATEWAY_API_KEY", "https://vercel.com/ai-gateway"),
|
|
725
|
+
model("moonshotai", "Moonshot AI", "MOONSHOT_API_KEY", "https://platform.moonshot.ai/console/api-keys"),
|
|
726
|
+
model("moonshotai-cn", "Moonshot AI CN", "MOONSHOT_API_KEY", "https://platform.moonshot.cn/console/api-keys"),
|
|
727
|
+
model("minimax", "MiniMax", "MINIMAX_API_KEY", "https://platform.minimax.io"),
|
|
728
|
+
model("minimax-cn", "MiniMax CN", "MINIMAX_CN_API_KEY", "https://platform.minimaxi.com"),
|
|
729
|
+
model("zai", "Z.AI", "ZAI_API_KEY", "https://z.ai/manage-apikey/apikey-list"),
|
|
730
|
+
model("zai-coding-cn", "Z.AI Coding CN", "ZAI_CODING_CN_API_KEY", "https://bigmodel.cn/usercenter/proj-mgmt/apikeys"),
|
|
731
|
+
model("qwen-token-plan", "Qwen Token Plan", "QWEN_TOKEN_PLAN_API_KEY", "https://modelstudio.console.alibabacloud.com"),
|
|
732
|
+
model("qwen-token-plan-cn", "Qwen Token Plan CN", "QWEN_TOKEN_PLAN_CN_API_KEY", "https://bailian.console.aliyun.com"),
|
|
733
|
+
model("qwen-token-plan-individual", "Qwen Token Plan Individual", "QWEN_TOKEN_PLAN_API_KEY", "https://modelstudio.console.alibabacloud.com"),
|
|
734
|
+
model("xiaomi", "Xiaomi MiMo", "XIAOMI_API_KEY", "https://platform.xiaomimimo.com"),
|
|
735
|
+
model("xiaomi-token-plan-cn", "Xiaomi Token Plan CN", "XIAOMI_TOKEN_PLAN_CN_API_KEY", "https://platform.xiaomimimo.com"),
|
|
736
|
+
model("xiaomi-token-plan-ams", "Xiaomi Token Plan AMS", "XIAOMI_TOKEN_PLAN_AMS_API_KEY", "https://platform.xiaomimimo.com"),
|
|
737
|
+
model("xiaomi-token-plan-sgp", "Xiaomi Token Plan SGP", "XIAOMI_TOKEN_PLAN_SGP_API_KEY", "https://platform.xiaomimimo.com"),
|
|
738
|
+
model("baseten", "Baseten", "BASETEN_API_KEY", "https://app.baseten.co/settings/api_keys"),
|
|
739
|
+
model("ant-ling", "Ant Ling", "ANT_LING_API_KEY", "https://ling.tbox.cn"),
|
|
740
|
+
model("kimi-coding", "Kimi For Coding", "KIMI_API_KEY", "https://www.kimi.com/code/console"),
|
|
741
|
+
model("meta", "Meta", "META_API_KEY", "https://llama.developer.meta.com")
|
|
742
|
+
];
|
|
743
|
+
SEARCH_CREDENTIAL_PROVIDERS = [
|
|
744
|
+
{
|
|
745
|
+
id: "tavily",
|
|
746
|
+
kind: "search",
|
|
747
|
+
name: "Tavily",
|
|
748
|
+
envVar: "TAVILY_API_KEY",
|
|
749
|
+
signupUrl: "https://app.tavily.com",
|
|
750
|
+
keyless: true
|
|
751
|
+
}
|
|
752
|
+
];
|
|
702
753
|
CREDENTIAL_PROVIDERS = [
|
|
703
|
-
|
|
704
|
-
|
|
754
|
+
...MODEL_PROVIDERS,
|
|
755
|
+
...SEARCH_CREDENTIAL_PROVIDERS
|
|
705
756
|
];
|
|
757
|
+
DEFAULT_ENABLED_PROVIDERS = ["deepseek"];
|
|
758
|
+
LOCKED_PROVIDERS = ["deepseek"];
|
|
706
759
|
});
|
|
707
760
|
|
|
708
761
|
// packages/core/src/credentials.ts
|
|
@@ -1521,7 +1574,7 @@ async function acquireSlot(tx, round, cwd) {
|
|
|
1521
1574
|
slots.items.push({ taskId: round.taskId, parentId: round.parentId, cwd, coder: round.role === "coder" });
|
|
1522
1575
|
return true;
|
|
1523
1576
|
}
|
|
1524
|
-
function createSubagentExtension(prepare, discard) {
|
|
1577
|
+
function createSubagentExtension(prepare, discard, guard) {
|
|
1525
1578
|
const finish = async (tx, input, status, report) => {
|
|
1526
1579
|
const round = (await tx.doc(DelegationsDoc, input.parentId)).items.find((r) => r.taskId === input.taskId);
|
|
1527
1580
|
round.status = status;
|
|
@@ -1665,6 +1718,8 @@ function createSubagentExtension(prepare, discard) {
|
|
|
1665
1718
|
if (!args.task.trim() || !args.title.trim() || Buffer.byteLength(args.task) > 32768)
|
|
1666
1719
|
throw new Error("Task/title must be nonempty; task limit is 32 KiB.");
|
|
1667
1720
|
const agent = await api.agent(context);
|
|
1721
|
+
if (agent.model)
|
|
1722
|
+
await guard?.(agent.model);
|
|
1668
1723
|
const round = await api.commit(async (tx) => {
|
|
1669
1724
|
const rounds = await refreshDelegations(tx, api.conversationId);
|
|
1670
1725
|
const receipt = rounds.find((r) => r.taskId === api.taskId);
|
|
@@ -4250,7 +4305,7 @@ function mergeUsage(base, extra) {
|
|
|
4250
4305
|
}
|
|
4251
4306
|
return result;
|
|
4252
4307
|
}
|
|
4253
|
-
function namingTask() {
|
|
4308
|
+
function namingTask(canUse) {
|
|
4254
4309
|
let active = 0;
|
|
4255
4310
|
const waits = new Set;
|
|
4256
4311
|
return defineTask3({
|
|
@@ -4287,7 +4342,7 @@ function namingTask() {
|
|
|
4287
4342
|
try {
|
|
4288
4343
|
const saved = await runtime.snapshot(SessionMetadataDoc, runtime.conversationId, context);
|
|
4289
4344
|
const model = saved?.model && runtime.models.getModel(saved.model.provider, saved.model.modelId);
|
|
4290
|
-
if (!saved || !model || saved.attempts >= 2 || !getSupportedThinkingLevels(model).includes("off")) {
|
|
4345
|
+
if (!saved || !model || saved.attempts >= 2 || !getSupportedThinkingLevels(model).includes("off") || !await canUse(model.provider, model.id)) {
|
|
4291
4346
|
await runtime.commit(async (tx) => {
|
|
4292
4347
|
(await tx.doc(SessionMetadataDoc, runtime.conversationId)).naming = "fallback";
|
|
4293
4348
|
return { status: "terminal", outcome: { status: "completed", result: null } };
|
|
@@ -4367,12 +4422,13 @@ class SessionMetadataManager {
|
|
|
4367
4422
|
#known = new Set;
|
|
4368
4423
|
#unsubscribe;
|
|
4369
4424
|
#live = new Map;
|
|
4370
|
-
task
|
|
4425
|
+
task;
|
|
4371
4426
|
harness;
|
|
4372
4427
|
storage;
|
|
4373
4428
|
context;
|
|
4374
4429
|
report;
|
|
4375
|
-
constructor(harness, storage, context, registry, report = console.error) {
|
|
4430
|
+
constructor(harness, storage, context, registry, report = console.error, canUseModel = async () => true) {
|
|
4431
|
+
this.task = namingTask(canUseModel);
|
|
4376
4432
|
this.harness = harness;
|
|
4377
4433
|
this.storage = storage;
|
|
4378
4434
|
this.context = context;
|
|
@@ -5673,7 +5729,7 @@ import { homedir as homedir5 } from "os";
|
|
|
5673
5729
|
import { join as join7 } from "path";
|
|
5674
5730
|
import { BACKGROUND_CONTEXT as BACKGROUND_CONTEXT3 } from "@earendil-works/chord/context";
|
|
5675
5731
|
import { clampThinkingLevel, createModels, getSupportedThinkingLevels as getSupportedThinkingLevels2 } from "@earendil-works/pi-ai/models";
|
|
5676
|
-
import {
|
|
5732
|
+
import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
|
|
5677
5733
|
import {
|
|
5678
5734
|
AssistantEntry as AssistantEntry2,
|
|
5679
5735
|
createRegistry,
|
|
@@ -5692,6 +5748,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
5692
5748
|
const context = options.context ?? BACKGROUND_CONTEXT3;
|
|
5693
5749
|
const defaultCwd = normalizeWorkspace(options.cwd);
|
|
5694
5750
|
const model = options.model ?? DEFAULT_MODEL;
|
|
5751
|
+
const modelOverride = options.modelOverride;
|
|
5695
5752
|
const providers = options.providers ?? [];
|
|
5696
5753
|
const credentials = options.credentials ?? (options.storage === "memory" && !options.credentialsPath ? new InMemoryCredentialStore : new FileCredentialStore(options.credentialsPath));
|
|
5697
5754
|
const runtimeKeys = new Map;
|
|
@@ -5711,15 +5768,45 @@ async function createNekoRuntime(options = {}) {
|
|
|
5711
5768
|
delete: (id) => credentials.delete(id)
|
|
5712
5769
|
} : credentials;
|
|
5713
5770
|
const models = createModels({ credentials: effectiveCredentials });
|
|
5714
|
-
|
|
5771
|
+
for (const provider of builtinProviders())
|
|
5772
|
+
if (isModelProvider(provider.id))
|
|
5773
|
+
models.setProvider(provider);
|
|
5715
5774
|
for (const provider of providers)
|
|
5716
5775
|
models.setProvider(provider);
|
|
5776
|
+
let enabled = new Set(normalizeEnabledProviders(null));
|
|
5777
|
+
const guardProvider = async (ref) => {
|
|
5778
|
+
if (!ref || !isModelProvider(ref.provider))
|
|
5779
|
+
return;
|
|
5780
|
+
const spec = credentialProvider(ref.provider);
|
|
5781
|
+
if (!enabled.has(ref.provider))
|
|
5782
|
+
throw new Error(`PROVIDER_DISABLED: ${spec.name} is not enabled. Enable it in /login or Web settings, or switch model.`);
|
|
5783
|
+
if (!await models.checkAuth(ref.provider))
|
|
5784
|
+
throw new Error(`PROVIDER_KEY_REQUIRED: Configure a ${spec.name} API key in /login or Web settings.`);
|
|
5785
|
+
};
|
|
5717
5786
|
const resolveLevel = (ref, level) => {
|
|
5718
5787
|
const info = models.getModel(ref.provider, ref.modelId);
|
|
5719
5788
|
if (!info)
|
|
5720
5789
|
throw new Error("Unknown model");
|
|
5721
5790
|
return clampThinkingLevel(info, level);
|
|
5722
5791
|
};
|
|
5792
|
+
let modelInfoCache;
|
|
5793
|
+
const allModels = () => {
|
|
5794
|
+
modelInfoCache ??= models.getModels().map((model) => ({
|
|
5795
|
+
provider: model.provider,
|
|
5796
|
+
modelId: model.id,
|
|
5797
|
+
name: model.name,
|
|
5798
|
+
contextWindow: model.contextWindow,
|
|
5799
|
+
input: model.input,
|
|
5800
|
+
...model.inputLimits ? { inputLimits: model.inputLimits } : {},
|
|
5801
|
+
reasoning: model.reasoning,
|
|
5802
|
+
supportedThinkingLevels: getSupportedThinkingLevels2(model),
|
|
5803
|
+
thinkingLevelAdjustments: Object.fromEntries(["off", "minimal", "low", "medium", "high", "xhigh", "max"].map((level) => [
|
|
5804
|
+
level,
|
|
5805
|
+
clampThinkingLevel(model, level)
|
|
5806
|
+
]))
|
|
5807
|
+
}));
|
|
5808
|
+
return modelInfoCache;
|
|
5809
|
+
};
|
|
5723
5810
|
const workspaceFiles = new WorkspaceFiles;
|
|
5724
5811
|
const storage = options.storage === "memory" ? new MemoryStorage : await openNodeSqliteStorage(options.storagePath ?? DEFAULT_STORAGE_PATH);
|
|
5725
5812
|
const registry = createRegistry();
|
|
@@ -5746,7 +5833,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
5746
5833
|
registry.install(createNekoPrompt(resourceSnapshots.current));
|
|
5747
5834
|
registry.install(createSubagentExtension(async (id, requestId, cwd) => {
|
|
5748
5835
|
resourceSnapshots.stage(id, requestId, cwd, await loadResources(cwd));
|
|
5749
|
-
}, resourceSnapshots.discard));
|
|
5836
|
+
}, resourceSnapshots.discard, (ref) => guardProvider(ref)));
|
|
5750
5837
|
const jobs = new JobManager;
|
|
5751
5838
|
registry.install(jobs.extension);
|
|
5752
5839
|
registry.install(createTodoExtension());
|
|
@@ -5764,7 +5851,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
5764
5851
|
registry,
|
|
5765
5852
|
settings: {
|
|
5766
5853
|
get compaction() {
|
|
5767
|
-
return compactionPolicy(contextState,
|
|
5854
|
+
return compactionPolicy(contextState, allModels().filter((model) => !isModelProvider(model.provider) || enabled.has(model.provider)).map((model) => model.contextWindow));
|
|
5768
5855
|
}
|
|
5769
5856
|
},
|
|
5770
5857
|
onReport: options.onReport,
|
|
@@ -5806,13 +5893,15 @@ async function createNekoRuntime(options = {}) {
|
|
|
5806
5893
|
throw error;
|
|
5807
5894
|
}
|
|
5808
5895
|
await questions.reconcileAll();
|
|
5896
|
+
const rootModel = modelOverride ?? model;
|
|
5809
5897
|
const conversation = await harness.root(context, {
|
|
5810
5898
|
agent: {
|
|
5811
|
-
model,
|
|
5812
|
-
thinkingLevel: resolveLevel(
|
|
5899
|
+
model: rootModel,
|
|
5900
|
+
thinkingLevel: resolveLevel(rootModel, options.thinkingLevel ?? "high"),
|
|
5813
5901
|
cwd: defaultCwd
|
|
5814
5902
|
}
|
|
5815
5903
|
});
|
|
5904
|
+
enabled = new Set(normalizeEnabledProviders((await harness.snapshot(ProviderSettingsDoc, conversation.id, context))?.enabled));
|
|
5816
5905
|
const savedSearch = (await harness.snapshot(SearchSettingsDoc, conversation.id, context))?.provider;
|
|
5817
5906
|
if (isSearchProvider(savedSearch))
|
|
5818
5907
|
searchProvider = savedSearch;
|
|
@@ -5858,7 +5947,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
5858
5947
|
};
|
|
5859
5948
|
if (existing.length === 0)
|
|
5860
5949
|
await touchConversation(conversation.id);
|
|
5861
|
-
const metadata = new SessionMetadataManager(harness, storage, context, registry, options.onReport);
|
|
5950
|
+
const metadata = new SessionMetadataManager(harness, storage, context, registry, options.onReport, (provider, modelId) => guardProvider({ provider, modelId }).then(() => true, () => false));
|
|
5862
5951
|
if (existing.length === 0)
|
|
5863
5952
|
await metadata.initialize(conversation.id);
|
|
5864
5953
|
for (const record of existing)
|
|
@@ -5919,9 +6008,8 @@ async function createNekoRuntime(options = {}) {
|
|
|
5919
6008
|
data.skill = skill;
|
|
5920
6009
|
});
|
|
5921
6010
|
}
|
|
5922
|
-
if (!duplicate
|
|
5923
|
-
|
|
5924
|
-
}
|
|
6011
|
+
if (!duplicate)
|
|
6012
|
+
await guardProvider(agent.model);
|
|
5925
6013
|
if (!duplicate && agent.model) {
|
|
5926
6014
|
const resolved = models.getModel(agent.model.provider, agent.model.modelId);
|
|
5927
6015
|
if (resolved)
|
|
@@ -6053,8 +6141,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
6053
6141
|
},
|
|
6054
6142
|
async compact(instructions) {
|
|
6055
6143
|
const agent = await target.agent(context);
|
|
6056
|
-
|
|
6057
|
-
throw new Error("DEEPSEEK_KEY_REQUIRED: Configure DeepSeek in /login or Web settings.");
|
|
6144
|
+
await guardProvider(agent.model);
|
|
6058
6145
|
await admit(target.id, async () => {
|
|
6059
6146
|
const live = await harness.snapshot(importLiveDoc, target.id, context);
|
|
6060
6147
|
if (live?.compactions?.length || (await readCompaction(harness, storage, target.id, context))?.phase === "waiting-to-apply")
|
|
@@ -6280,11 +6367,13 @@ async function createNekoRuntime(options = {}) {
|
|
|
6280
6367
|
},
|
|
6281
6368
|
async createConversation(createOptions) {
|
|
6282
6369
|
const workspace = await addWorkspace(createOptions?.cwd ?? defaultCwd);
|
|
6370
|
+
const savedDefault = (await harness.snapshot(DefaultModelDoc, conversation.id, context))?.model ?? null;
|
|
6371
|
+
const effective = createOptions?.model ?? modelOverride ?? savedDefault ?? model;
|
|
6283
6372
|
const created = await harness.createConversation({
|
|
6284
6373
|
ownership: { kind: "ownerless" },
|
|
6285
6374
|
agent: {
|
|
6286
|
-
model:
|
|
6287
|
-
thinkingLevel: resolveLevel(
|
|
6375
|
+
model: effective,
|
|
6376
|
+
thinkingLevel: resolveLevel(effective, createOptions?.thinkingLevel ?? options.thinkingLevel ?? "high"),
|
|
6288
6377
|
cwd: workspace.path
|
|
6289
6378
|
}
|
|
6290
6379
|
}, context);
|
|
@@ -6314,6 +6403,8 @@ async function createNekoRuntime(options = {}) {
|
|
|
6314
6403
|
const targetModel = ref && models.getModel(ref.provider, ref.modelId);
|
|
6315
6404
|
if (!targetModel)
|
|
6316
6405
|
throw new Error("Unknown model");
|
|
6406
|
+
if (change.model && isModelProvider(ref.provider) && !enabled.has(ref.provider))
|
|
6407
|
+
throw new Error(`PROVIDER_DISABLED: ${credentialProvider(ref.provider).name} is not enabled.`);
|
|
6317
6408
|
await session.conversation.configure({ model: ref, thinkingLevel: clampThinkingLevel(targetModel, change.thinkingLevel ?? current.thinkingLevel) }, context);
|
|
6318
6409
|
return true;
|
|
6319
6410
|
});
|
|
@@ -6368,20 +6459,62 @@ async function createNekoRuntime(options = {}) {
|
|
|
6368
6459
|
}
|
|
6369
6460
|
},
|
|
6370
6461
|
listModels() {
|
|
6371
|
-
return
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6462
|
+
return allModels();
|
|
6463
|
+
},
|
|
6464
|
+
async listSelectableModels() {
|
|
6465
|
+
const availability = new Map;
|
|
6466
|
+
const result = [];
|
|
6467
|
+
for (const info of allModels()) {
|
|
6468
|
+
const managed = isModelProvider(info.provider);
|
|
6469
|
+
if (managed && !enabled.has(info.provider))
|
|
6470
|
+
continue;
|
|
6471
|
+
if (!availability.has(info.provider))
|
|
6472
|
+
availability.set(info.provider, !managed || Boolean(await models.checkAuth(info.provider)));
|
|
6473
|
+
result.push({ ...info, available: availability.get(info.provider) ?? false });
|
|
6474
|
+
}
|
|
6475
|
+
return result;
|
|
6476
|
+
},
|
|
6477
|
+
enabledProviders() {
|
|
6478
|
+
return MODEL_PROVIDERS.map((item) => item.id).filter((id) => enabled.has(id));
|
|
6479
|
+
},
|
|
6480
|
+
async setProviderEnabled(provider, value) {
|
|
6481
|
+
if (!isModelProvider(provider))
|
|
6482
|
+
throw new Error("Unknown model provider.");
|
|
6483
|
+
if (typeof value !== "boolean")
|
|
6484
|
+
throw new Error("Enabled must be a boolean.");
|
|
6485
|
+
if (!value && LOCKED_PROVIDERS.includes(provider))
|
|
6486
|
+
throw new Error("DeepSeek is always enabled.");
|
|
6487
|
+
const next = new Set(enabled);
|
|
6488
|
+
if (value)
|
|
6489
|
+
next.add(provider);
|
|
6490
|
+
else
|
|
6491
|
+
next.delete(provider);
|
|
6492
|
+
const list = normalizeEnabledProviders([...next]);
|
|
6493
|
+
await harness.commit(async (tx) => {
|
|
6494
|
+
(await tx.doc(ProviderSettingsDoc, conversation.id)).enabled = list;
|
|
6495
|
+
}, context);
|
|
6496
|
+
enabled = new Set(list);
|
|
6497
|
+
},
|
|
6498
|
+
async defaultModel() {
|
|
6499
|
+
const saved = (await harness.snapshot(DefaultModelDoc, conversation.id, context))?.model ?? null;
|
|
6500
|
+
if (modelOverride)
|
|
6501
|
+
return { effective: modelOverride, source: "cli" };
|
|
6502
|
+
if (saved)
|
|
6503
|
+
return { effective: saved, source: "saved" };
|
|
6504
|
+
if (options.model)
|
|
6505
|
+
return { effective: model, source: "config" };
|
|
6506
|
+
return { effective: model, source: "default" };
|
|
6507
|
+
},
|
|
6508
|
+
async setDefaultModel(ref) {
|
|
6509
|
+
if (ref !== null) {
|
|
6510
|
+
if (!models.getModel(ref.provider, ref.modelId))
|
|
6511
|
+
throw new Error("Unknown model");
|
|
6512
|
+
if (isModelProvider(ref.provider) && !enabled.has(ref.provider))
|
|
6513
|
+
throw new Error(`PROVIDER_DISABLED: ${credentialProvider(ref.provider).name} is not enabled.`);
|
|
6514
|
+
}
|
|
6515
|
+
await harness.commit(async (tx) => {
|
|
6516
|
+
(await tx.doc(DefaultModelDoc, conversation.id)).model = ref;
|
|
6517
|
+
}, context);
|
|
6385
6518
|
},
|
|
6386
6519
|
async getAgent(id) {
|
|
6387
6520
|
const session = await sessionFor(id);
|
|
@@ -6422,7 +6555,7 @@ async function createNekoRuntime(options = {}) {
|
|
|
6422
6555
|
}
|
|
6423
6556
|
};
|
|
6424
6557
|
}
|
|
6425
|
-
var DEFAULT_MODEL, DEFAULT_STORAGE_PATH, neverAborted = () => new AbortController().signal, ArchivedDoc, WorkspacesDoc, SearchSettingsDoc, ContextSettingsDoc, ActivityDoc;
|
|
6558
|
+
var DEFAULT_MODEL, DEFAULT_STORAGE_PATH, neverAborted = () => new AbortController().signal, ArchivedDoc, WorkspacesDoc, SearchSettingsDoc, ProviderSettingsDoc, DefaultModelDoc, ContextSettingsDoc, ActivityDoc;
|
|
6426
6559
|
var init_runtime = __esm(() => {
|
|
6427
6560
|
init_agent_file_search();
|
|
6428
6561
|
init_compaction();
|
|
@@ -6479,6 +6612,22 @@ var init_runtime = __esm(() => {
|
|
|
6479
6612
|
fork: "initial",
|
|
6480
6613
|
initial: () => ({ provider: null })
|
|
6481
6614
|
});
|
|
6615
|
+
ProviderSettingsDoc = defineDoc7({
|
|
6616
|
+
kind: "app.neko.provider-settings",
|
|
6617
|
+
version: 1,
|
|
6618
|
+
scope: "conversation",
|
|
6619
|
+
history: "latest",
|
|
6620
|
+
fork: "initial",
|
|
6621
|
+
initial: () => ({ enabled: null })
|
|
6622
|
+
});
|
|
6623
|
+
DefaultModelDoc = defineDoc7({
|
|
6624
|
+
kind: "app.neko.default-model",
|
|
6625
|
+
version: 1,
|
|
6626
|
+
scope: "conversation",
|
|
6627
|
+
history: "latest",
|
|
6628
|
+
fork: "initial",
|
|
6629
|
+
initial: () => ({ model: null })
|
|
6630
|
+
});
|
|
6482
6631
|
ContextSettingsDoc = defineDoc7({
|
|
6483
6632
|
kind: "app.neko.context-settings",
|
|
6484
6633
|
version: 1,
|
|
@@ -6654,7 +6803,7 @@ function contract(name, def) {
|
|
|
6654
6803
|
]));
|
|
6655
6804
|
return remote(name, { ...def, host: hostNamed(GATEWAY_HOST), variants });
|
|
6656
6805
|
}
|
|
6657
|
-
var GATEWAY_HOST = "neko", rpc = (args, result) => [args, result], str, num, bool, nil, integer, nullableString, phase, level, thinking,
|
|
6806
|
+
var GATEWAY_HOST = "neko", rpc = (args, result) => [args, result], str, num, bool, nil, integer, nullableString, phase, level, thinking, model2, change, usage, image, skill, call, DelegationSchema, SubagentSummarySchema, jobStatus, JobSummarySchema, JobOutputSchema, QueuedInputSchema, WithdrawResultSchema, SteerResultSchema, TodoItemSchema, TodoListSchema, QuestionOptionSchema, questionStatus, QuestionSummarySchema, WorkspaceEntrySchema, WorkspaceDirSchema, WorkspaceFileSchema, ChangeSummarySchema, ChangedFileSchema, ChangeListSchema, ChangeOpSchema, ChangeDetailSchema, QuestionListSchema, QuestionRecordSchema, QuestionResponseSchema, ToolInteractionSchema, ChatViewSchema, SessionSummarySchema, DirectoryStateSchema, WorkspaceSummarySchema, WorkspaceStateSchema, credentialStatus, CredentialStateSchema, AttachmentSchema, chatInput, NekoSessionDirectory, NekoSessionManagement, resize, inputLimits, modelInfo, NekoModels, imageChunk, NekoSubagent, NekoChat, browse, page, NekoWorkspaces, provider, NekoCredentials, SearchSettingsStateSchema, NekoSearchSettings, contextSource, ContextSettingsStateSchema, nullable = (schema) => Type7.Union([schema, nil]), ContextSettingsPatchSchema, NekoContextSettings, defaultModelSource, DefaultModelStateSchema, NekoDefaultModel, FileCandidatesSchema, NekoWorkspaceFiles, marketSkill, preview, scope, installResult, NekoSkillMarket, ApplicationInfoSchema, NekoApplicationInfo;
|
|
6658
6807
|
var init_contract = __esm(() => {
|
|
6659
6808
|
init_interactions();
|
|
6660
6809
|
str = Type7.String();
|
|
@@ -6666,8 +6815,8 @@ var init_contract = __esm(() => {
|
|
|
6666
6815
|
phase = Type7.Enum(["pending", "running", "done"]);
|
|
6667
6816
|
level = Type7.Enum(["project", "user", "builtin"]);
|
|
6668
6817
|
thinking = Type7.Enum(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
6669
|
-
|
|
6670
|
-
change = Type7.Object({ model: Type7.Optional(
|
|
6818
|
+
model2 = Type7.Object({ provider: str, modelId: str });
|
|
6819
|
+
change = Type7.Object({ model: Type7.Optional(model2), thinkingLevel: Type7.Optional(thinking) }, { additionalProperties: false });
|
|
6671
6820
|
usage = Type7.Object({ input: num, output: num, cacheRead: num, cacheWrite: num, cost: num });
|
|
6672
6821
|
image = Type7.Object({
|
|
6673
6822
|
name: str,
|
|
@@ -6905,7 +7054,7 @@ var init_contract = __esm(() => {
|
|
|
6905
7054
|
subagents: Type7.Optional(Type7.Array(DelegationSchema)),
|
|
6906
7055
|
taskUsage: Type7.Optional(usage),
|
|
6907
7056
|
model: str,
|
|
6908
|
-
agent: Type7.Object({ model: Type7.Union([
|
|
7057
|
+
agent: Type7.Object({ model: Type7.Union([model2, nil]), thinkingLevel: Type7.Union([thinking, nil]) }),
|
|
6909
7058
|
cwd: str,
|
|
6910
7059
|
busy: bool,
|
|
6911
7060
|
status: nullableString,
|
|
@@ -6990,7 +7139,7 @@ var init_contract = __esm(() => {
|
|
|
6990
7139
|
firstPromptPreview: str,
|
|
6991
7140
|
createdAt: num,
|
|
6992
7141
|
lastMessageAt: Type7.Union([num, nil]),
|
|
6993
|
-
model: Type7.Union([
|
|
7142
|
+
model: Type7.Union([model2, nil]),
|
|
6994
7143
|
status: Type7.Enum(["idle", "running", "error"]),
|
|
6995
7144
|
awaitingAnswer: Type7.Optional(bool),
|
|
6996
7145
|
id: str
|
|
@@ -7001,11 +7150,12 @@ var init_contract = __esm(() => {
|
|
|
7001
7150
|
credentialStatus = Type7.Object({
|
|
7002
7151
|
savedConfigured: bool,
|
|
7003
7152
|
environmentConfigured: bool,
|
|
7004
|
-
source: Type7.Enum(["saved", "environment", "runtime", "keyless", "none"])
|
|
7153
|
+
source: Type7.Enum(["saved", "environment", "runtime", "keyless", "none"]),
|
|
7154
|
+
enabled: Type7.Optional(bool)
|
|
7005
7155
|
});
|
|
7006
7156
|
CredentialStateSchema = Type7.Object({
|
|
7007
7157
|
revision: integer,
|
|
7008
|
-
statuses: Type7.
|
|
7158
|
+
statuses: Type7.Record(str, credentialStatus)
|
|
7009
7159
|
});
|
|
7010
7160
|
AttachmentSchema = Type7.Object({ sessionId: str, attachmentId: str });
|
|
7011
7161
|
chatInput = Type7.Object({ sessionId: str, attachmentId: str }, { additionalProperties: false });
|
|
@@ -7047,6 +7197,7 @@ var init_contract = __esm(() => {
|
|
|
7047
7197
|
provider: str,
|
|
7048
7198
|
modelId: str,
|
|
7049
7199
|
name: str,
|
|
7200
|
+
available: bool,
|
|
7050
7201
|
contextWindow: num,
|
|
7051
7202
|
input: Type7.Array(str),
|
|
7052
7203
|
inputLimits: Type7.Optional(inputLimits),
|
|
@@ -7152,16 +7303,17 @@ var init_contract = __esm(() => {
|
|
|
7152
7303
|
}
|
|
7153
7304
|
}
|
|
7154
7305
|
});
|
|
7155
|
-
provider = Type7.
|
|
7306
|
+
provider = Type7.String({ minLength: 1, maxLength: 64 });
|
|
7156
7307
|
NekoCredentials = contract("neko.credentials", {
|
|
7157
|
-
version:
|
|
7308
|
+
version: 2,
|
|
7158
7309
|
input: Type7.Object({}, { additionalProperties: false }),
|
|
7159
7310
|
variants: {
|
|
7160
7311
|
ready: {
|
|
7161
7312
|
state: { state: CredentialStateSchema },
|
|
7162
7313
|
methods: {
|
|
7163
7314
|
save: rpc(Type7.Object({ provider, key: Type7.String({ minLength: 1, maxLength: 8192 }) }, { additionalProperties: false }), nil),
|
|
7164
|
-
remove: rpc(Type7.Object({ provider }, { additionalProperties: false }), nil)
|
|
7315
|
+
remove: rpc(Type7.Object({ provider }, { additionalProperties: false }), nil),
|
|
7316
|
+
setEnabled: rpc(Type7.Object({ provider, enabled: bool }, { additionalProperties: false }), nil)
|
|
7165
7317
|
}
|
|
7166
7318
|
}
|
|
7167
7319
|
}
|
|
@@ -7237,6 +7389,24 @@ var init_contract = __esm(() => {
|
|
|
7237
7389
|
}
|
|
7238
7390
|
}
|
|
7239
7391
|
});
|
|
7392
|
+
defaultModelSource = Type7.Enum(["cli", "saved", "config", "default"]);
|
|
7393
|
+
DefaultModelStateSchema = Type7.Object({
|
|
7394
|
+
effective: model2,
|
|
7395
|
+
source: defaultModelSource
|
|
7396
|
+
});
|
|
7397
|
+
NekoDefaultModel = contract("neko.default-model", {
|
|
7398
|
+
version: 1,
|
|
7399
|
+
input: Type7.Object({}, { additionalProperties: false }),
|
|
7400
|
+
variants: {
|
|
7401
|
+
ready: {
|
|
7402
|
+
state: { state: DefaultModelStateSchema },
|
|
7403
|
+
methods: {
|
|
7404
|
+
set: rpc(model2, nil),
|
|
7405
|
+
clear: rpc(nil, nil)
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7409
|
+
});
|
|
7240
7410
|
FileCandidatesSchema = Type7.Object({
|
|
7241
7411
|
entries: Type7.Array(Type7.Object({ name: str, path: str, kind: Type7.Enum(["file", "directory"]) }), { maxItems: 100 }),
|
|
7242
7412
|
limited: bool,
|
|
@@ -7672,8 +7842,8 @@ function createGatewayConnection(link, serverId) {
|
|
|
7672
7842
|
let business;
|
|
7673
7843
|
let protocolChecked = false;
|
|
7674
7844
|
function bindBusiness() {
|
|
7675
|
-
const directory = get(NekoSessionDirectory), management = get(NekoSessionManagement), models = get(NekoModels), workspaces = get(NekoWorkspaces), workspaceFiles = get(NekoWorkspaceFiles), credentials = get(NekoCredentials), searchSettings = get(NekoSearchSettings), contextSettings = get(NekoContextSettings), skillMarket = get(NekoSkillMarket);
|
|
7676
|
-
keep.push(directory.state.subscribe(() => {}), workspaces.state.subscribe(() => {}), credentials.state.subscribe(() => {}), searchSettings.state.subscribe(() => {}), contextSettings.state.subscribe(() => {}));
|
|
7845
|
+
const directory = get(NekoSessionDirectory), management = get(NekoSessionManagement), models = get(NekoModels), workspaces = get(NekoWorkspaces), workspaceFiles = get(NekoWorkspaceFiles), credentials = get(NekoCredentials), searchSettings = get(NekoSearchSettings), contextSettings = get(NekoContextSettings), defaultModel = get(NekoDefaultModel), skillMarket = get(NekoSkillMarket);
|
|
7846
|
+
keep.push(directory.state.subscribe(() => {}), workspaces.state.subscribe(() => {}), credentials.state.subscribe(() => {}), searchSettings.state.subscribe(() => {}), contextSettings.state.subscribe(() => {}), defaultModel.state.subscribe(() => {}));
|
|
7677
7847
|
return {
|
|
7678
7848
|
directory,
|
|
7679
7849
|
management,
|
|
@@ -7683,6 +7853,7 @@ function createGatewayConnection(link, serverId) {
|
|
|
7683
7853
|
credentials,
|
|
7684
7854
|
searchSettings,
|
|
7685
7855
|
contextSettings,
|
|
7856
|
+
defaultModel,
|
|
7686
7857
|
skillMarket
|
|
7687
7858
|
};
|
|
7688
7859
|
}
|
|
@@ -7709,6 +7880,7 @@ function createGatewayConnection(link, serverId) {
|
|
|
7709
7880
|
credentials,
|
|
7710
7881
|
searchSettings,
|
|
7711
7882
|
contextSettings,
|
|
7883
|
+
defaultModel,
|
|
7712
7884
|
workspaceFiles,
|
|
7713
7885
|
skillMarket
|
|
7714
7886
|
} = services();
|
|
@@ -7720,6 +7892,7 @@ function createGatewayConnection(link, serverId) {
|
|
|
7720
7892
|
credentials.ready,
|
|
7721
7893
|
searchSettings.ready,
|
|
7722
7894
|
contextSettings.ready,
|
|
7895
|
+
defaultModel.ready,
|
|
7723
7896
|
workspaceFiles.ready,
|
|
7724
7897
|
skillMarket.ready
|
|
7725
7898
|
]), signal);
|
|
@@ -7763,6 +7936,9 @@ function createGatewayConnection(link, serverId) {
|
|
|
7763
7936
|
get contextSettings() {
|
|
7764
7937
|
return services().contextSettings;
|
|
7765
7938
|
},
|
|
7939
|
+
get defaultModel() {
|
|
7940
|
+
return services().defaultModel;
|
|
7941
|
+
},
|
|
7766
7942
|
get skillMarket() {
|
|
7767
7943
|
return services().skillMarket;
|
|
7768
7944
|
},
|
|
@@ -20022,6 +20198,10 @@ function formatTokens(tokens) {
|
|
|
20022
20198
|
return `${(tokens / 1000).toFixed(1)}k`;
|
|
20023
20199
|
return String(tokens);
|
|
20024
20200
|
}
|
|
20201
|
+
function modelDisplayName(model) {
|
|
20202
|
+
const slash = model.indexOf("/");
|
|
20203
|
+
return slash < 0 || slash === model.length - 1 ? model : model.slice(slash + 1);
|
|
20204
|
+
}
|
|
20025
20205
|
|
|
20026
20206
|
// packages/tui/src/labels.ts
|
|
20027
20207
|
var commands, labels;
|
|
@@ -20036,13 +20216,13 @@ var init_labels = __esm(() => {
|
|
|
20036
20216
|
{ name: "exit", description: "Exit neko TUI" },
|
|
20037
20217
|
{ name: "new", description: "Create a new session" },
|
|
20038
20218
|
{ name: "sessions", description: "Switch or create a session" },
|
|
20039
|
-
{ name: "login", description: "
|
|
20219
|
+
{ name: "login", description: "Manage model providers and API keys" },
|
|
20040
20220
|
{ name: "model", description: "Choose a model" },
|
|
20041
20221
|
{ name: "agents", description: "View agent tasks and activity" },
|
|
20042
20222
|
{ name: "jobs", description: "View background jobs" },
|
|
20043
20223
|
{ name: "todos", description: "View the assistant's todo list" },
|
|
20044
20224
|
{ name: "question", description: "Answer the assistant's question (Ctrl+O)" },
|
|
20045
|
-
{ name: "search", description: "Choose the web search provider (Tavily/DeepSeek)" },
|
|
20225
|
+
{ name: "search", description: "Choose the web search provider (Tavily/DeepSeek); K sets its key" },
|
|
20046
20226
|
{ name: "context", description: "Tune context compaction and tool result pruning" },
|
|
20047
20227
|
{ name: "theme", description: "Choose color theme (auto/light/dark)" },
|
|
20048
20228
|
{ name: "think", description: "Set thinking level (/think high)" },
|
|
@@ -20111,7 +20291,7 @@ class StatusFooter {
|
|
|
20111
20291
|
const statusText = truncateToWidth2(s.compaction ?? s.busy ?? labels.ready, Math.min(28, Math.floor(space / 2)));
|
|
20112
20292
|
const tone = this.#tone();
|
|
20113
20293
|
const statusStyled = tone === "error" ? theme.error(statusText) : tone === "warning" ? theme.warning(statusText) : tone === "accent" ? theme.accent(statusText) : theme.ok(statusText);
|
|
20114
|
-
const modelShort = s.model
|
|
20294
|
+
const modelShort = modelDisplayName(s.model);
|
|
20115
20295
|
const identity = [
|
|
20116
20296
|
{ text: basename4(s.cwd) || s.cwd, slot: theme.muted },
|
|
20117
20297
|
{ text: modelShort, slot: theme.model },
|
|
@@ -20660,16 +20840,21 @@ import {
|
|
|
20660
20840
|
isKeyRelease as isKeyRelease2,
|
|
20661
20841
|
matchesKey as matchesKey5,
|
|
20662
20842
|
renderFakeCursor,
|
|
20663
|
-
truncateToWidth as truncateToWidth3
|
|
20843
|
+
truncateToWidth as truncateToWidth3,
|
|
20844
|
+
visibleWidth as visibleWidth3
|
|
20664
20845
|
} from "@earendil-works/pi-tui";
|
|
20665
20846
|
|
|
20666
20847
|
class LoginPanel {
|
|
20667
20848
|
height = 10;
|
|
20668
20849
|
focused = false;
|
|
20669
20850
|
open = false;
|
|
20670
|
-
#
|
|
20851
|
+
#level = "list";
|
|
20852
|
+
#filter = new Input({ prompt: "\u276F ", placeholder: "Type to filter" });
|
|
20853
|
+
#index = 0;
|
|
20854
|
+
#inputs = new Map;
|
|
20671
20855
|
#state;
|
|
20672
20856
|
#provider = "deepseek";
|
|
20857
|
+
#group = "model";
|
|
20673
20858
|
#message = "";
|
|
20674
20859
|
#busy = false;
|
|
20675
20860
|
#confirmingRemove = false;
|
|
@@ -20680,24 +20865,35 @@ class LoginPanel {
|
|
|
20680
20865
|
#closed;
|
|
20681
20866
|
#save;
|
|
20682
20867
|
#remove;
|
|
20868
|
+
#toggle;
|
|
20683
20869
|
#autoCloseMs;
|
|
20684
20870
|
constructor(options) {
|
|
20685
20871
|
this.#changed = options.changed;
|
|
20686
20872
|
this.#closed = options.closed;
|
|
20687
20873
|
this.#save = options.save;
|
|
20688
20874
|
this.#remove = options.remove;
|
|
20875
|
+
this.#toggle = options.toggle;
|
|
20689
20876
|
this.#autoCloseMs = options.autoCloseMs ?? AUTO_CLOSE_MS;
|
|
20690
20877
|
}
|
|
20691
|
-
show(state, subscribe) {
|
|
20878
|
+
show(state, subscribe, initial) {
|
|
20692
20879
|
this.#generation++;
|
|
20693
20880
|
this.#clearCloseTimer();
|
|
20694
20881
|
this.open = true;
|
|
20882
|
+
this.#level = "list";
|
|
20695
20883
|
this.#busy = false;
|
|
20696
20884
|
this.#confirmingRemove = false;
|
|
20697
20885
|
this.#message = "";
|
|
20698
|
-
this.#
|
|
20886
|
+
this.#inputs.clear();
|
|
20887
|
+
this.#filter = new Input({ prompt: "\u276F ", placeholder: "Type to filter" });
|
|
20888
|
+
this.#index = 0;
|
|
20699
20889
|
this.#provider = "deepseek";
|
|
20890
|
+
this.#group = "model";
|
|
20700
20891
|
this.#state = state;
|
|
20892
|
+
if (initial) {
|
|
20893
|
+
this.#provider = initial.provider;
|
|
20894
|
+
this.#group = initial.group;
|
|
20895
|
+
this.#level = "key";
|
|
20896
|
+
}
|
|
20701
20897
|
this.#unsubscribe?.();
|
|
20702
20898
|
this.#unsubscribe = subscribe((value) => {
|
|
20703
20899
|
if (this.open) {
|
|
@@ -20712,26 +20908,96 @@ class LoginPanel {
|
|
|
20712
20908
|
this.#clearCloseTimer();
|
|
20713
20909
|
this.open = false;
|
|
20714
20910
|
this.#confirmingRemove = false;
|
|
20715
|
-
this.#
|
|
20911
|
+
this.#inputs.clear();
|
|
20912
|
+
this.#filter = new Input({ prompt: "\u276F ", placeholder: "Type to filter" });
|
|
20716
20913
|
this.#unsubscribe?.();
|
|
20717
20914
|
this.#unsubscribe = undefined;
|
|
20718
20915
|
this.#closed();
|
|
20719
20916
|
this.#changed();
|
|
20720
20917
|
}
|
|
20721
20918
|
invalidate() {}
|
|
20919
|
+
get #input() {
|
|
20920
|
+
let input = this.#inputs.get(this.#provider);
|
|
20921
|
+
if (!input) {
|
|
20922
|
+
input = new Input;
|
|
20923
|
+
this.#inputs.set(this.#provider, input);
|
|
20924
|
+
}
|
|
20925
|
+
return input;
|
|
20926
|
+
}
|
|
20927
|
+
get #status() {
|
|
20928
|
+
return this.#state?.statuses[this.#provider];
|
|
20929
|
+
}
|
|
20930
|
+
#visible() {
|
|
20931
|
+
const query = compact(this.#filter.getValue());
|
|
20932
|
+
const all = listRows();
|
|
20933
|
+
if (query === "")
|
|
20934
|
+
return all;
|
|
20935
|
+
return all.filter(({ spec }) => compact(`${spec.name} ${spec.id} ${spec.envVar}`).includes(query));
|
|
20936
|
+
}
|
|
20937
|
+
#isEnabled(spec) {
|
|
20938
|
+
return isLocked(spec.id) || this.#state?.statuses[spec.id]?.enabled === true;
|
|
20939
|
+
}
|
|
20722
20940
|
handleInput(data) {
|
|
20723
20941
|
if (isKeyRelease2(data))
|
|
20724
20942
|
return;
|
|
20725
|
-
if (matchesKey5(data, "
|
|
20943
|
+
if (matchesKey5(data, "ctrl+c")) {
|
|
20944
|
+
this.close();
|
|
20945
|
+
return;
|
|
20946
|
+
}
|
|
20947
|
+
if (this.#level === "list")
|
|
20948
|
+
this.#handleList(data);
|
|
20949
|
+
else
|
|
20950
|
+
this.#handleKey(data);
|
|
20951
|
+
this.#changed();
|
|
20952
|
+
}
|
|
20953
|
+
#handleList(data) {
|
|
20954
|
+
if (matchesKey5(data, "escape")) {
|
|
20726
20955
|
this.close();
|
|
20727
20956
|
return;
|
|
20728
20957
|
}
|
|
20958
|
+
if (this.#busy)
|
|
20959
|
+
return;
|
|
20960
|
+
const items = this.#visible();
|
|
20961
|
+
if (matchesKey5(data, "up") || matchesKey5(data, "down")) {
|
|
20962
|
+
const delta = matchesKey5(data, "up") ? -1 : 1;
|
|
20963
|
+
this.#index = Math.max(0, Math.min(items.length - 1, this.#index + delta));
|
|
20964
|
+
this.#message = "";
|
|
20965
|
+
} else if (matchesKey5(data, "space")) {
|
|
20966
|
+
const row = items[this.#index];
|
|
20967
|
+
if (row)
|
|
20968
|
+
this.#toggleEnabled(row);
|
|
20969
|
+
} else if (matchesKey5(data, "enter")) {
|
|
20970
|
+
const row = items[this.#index];
|
|
20971
|
+
if (!row)
|
|
20972
|
+
return;
|
|
20973
|
+
this.#provider = row.spec.id;
|
|
20974
|
+
this.#group = row.group;
|
|
20975
|
+
this.#level = "key";
|
|
20976
|
+
this.#message = "";
|
|
20977
|
+
} else {
|
|
20978
|
+
const before = this.#filter.getValue();
|
|
20979
|
+
this.#filter.handleInput(data);
|
|
20980
|
+
if (this.#filter.getValue() !== before) {
|
|
20981
|
+
this.#index = 0;
|
|
20982
|
+
this.#message = "";
|
|
20983
|
+
}
|
|
20984
|
+
}
|
|
20985
|
+
}
|
|
20986
|
+
#handleKey(data) {
|
|
20987
|
+
if (matchesKey5(data, "escape")) {
|
|
20988
|
+
if (this.#busy || this.#closeTimer !== undefined)
|
|
20989
|
+
this.close();
|
|
20990
|
+
else
|
|
20991
|
+
this.#backToList();
|
|
20992
|
+
return;
|
|
20993
|
+
}
|
|
20729
20994
|
if (this.#busy)
|
|
20730
20995
|
return;
|
|
20731
20996
|
const confirming = this.#confirmingRemove;
|
|
20732
20997
|
this.#confirmingRemove = false;
|
|
20733
20998
|
if (confirming && !matchesKey5(data, "ctrl+r"))
|
|
20734
20999
|
this.#message = "";
|
|
21000
|
+
const input = this.#input;
|
|
20735
21001
|
if (matchesKey5(data, "enter"))
|
|
20736
21002
|
this.#apply(false);
|
|
20737
21003
|
else if (matchesKey5(data, "ctrl+r") && this.#status?.savedConfigured) {
|
|
@@ -20741,23 +21007,52 @@ class LoginPanel {
|
|
|
20741
21007
|
this.#confirmingRemove = true;
|
|
20742
21008
|
this.#message = "Press Ctrl+R again to remove the saved key.";
|
|
20743
21009
|
}
|
|
20744
|
-
} else if (matchesKey5(data, "tab")
|
|
20745
|
-
this.#
|
|
21010
|
+
} else if (matchesKey5(data, "tab"))
|
|
21011
|
+
this.#backToList();
|
|
20746
21012
|
else {
|
|
20747
|
-
|
|
20748
|
-
if (
|
|
20749
|
-
|
|
21013
|
+
input.handleInput(data);
|
|
21014
|
+
if (input.getValue().length > 4096)
|
|
21015
|
+
input.setValue(input.getValue().slice(0, 4096));
|
|
20750
21016
|
}
|
|
20751
|
-
this.#changed();
|
|
20752
21017
|
}
|
|
20753
|
-
|
|
20754
|
-
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
this.#
|
|
21018
|
+
#backToList() {
|
|
21019
|
+
const index = this.#visible().findIndex((row) => row.spec.id === this.#provider && row.group === this.#group);
|
|
21020
|
+
if (index >= 0)
|
|
21021
|
+
this.#index = index;
|
|
21022
|
+
this.#level = "list";
|
|
21023
|
+
this.#confirmingRemove = false;
|
|
20759
21024
|
this.#message = "";
|
|
20760
21025
|
}
|
|
21026
|
+
async#toggleEnabled({ spec, group }) {
|
|
21027
|
+
if (group === "search") {
|
|
21028
|
+
this.#message = isModelProvider(spec.id) ? `${spec.name} shares its key with the model provider and has no enable switch here.` : `${spec.name} is a web search credential and has no enable switch.`;
|
|
21029
|
+
return;
|
|
21030
|
+
}
|
|
21031
|
+
if (isLocked(spec.id)) {
|
|
21032
|
+
this.#message = `${spec.name} is always enabled.`;
|
|
21033
|
+
return;
|
|
21034
|
+
}
|
|
21035
|
+
if (!isModelProvider(spec.id))
|
|
21036
|
+
return;
|
|
21037
|
+
const enable = !this.#isEnabled(spec);
|
|
21038
|
+
const generation = this.#generation;
|
|
21039
|
+
this.#busy = true;
|
|
21040
|
+
this.#message = enable ? "Enabling..." : "Disabling...";
|
|
21041
|
+
this.#changed();
|
|
21042
|
+
try {
|
|
21043
|
+
await this.#toggle(spec.id, enable);
|
|
21044
|
+
if (generation === this.#generation)
|
|
21045
|
+
this.#message = enable ? `${spec.name} enabled. Press Enter to add a key.` : `${spec.name} disabled.`;
|
|
21046
|
+
} catch (error) {
|
|
21047
|
+
if (generation === this.#generation)
|
|
21048
|
+
this.#message = error instanceof Error ? error.message : "Could not update the provider. Try again.";
|
|
21049
|
+
} finally {
|
|
21050
|
+
if (generation === this.#generation) {
|
|
21051
|
+
this.#busy = false;
|
|
21052
|
+
this.#changed();
|
|
21053
|
+
}
|
|
21054
|
+
}
|
|
21055
|
+
}
|
|
20761
21056
|
#clearCloseTimer() {
|
|
20762
21057
|
if (this.#closeTimer !== undefined)
|
|
20763
21058
|
clearTimeout(this.#closeTimer);
|
|
@@ -20796,7 +21091,7 @@ class LoginPanel {
|
|
|
20796
21091
|
else
|
|
20797
21092
|
await this.#save(provider, key);
|
|
20798
21093
|
if (generation === this.#generation) {
|
|
20799
|
-
this.#
|
|
21094
|
+
this.#inputs.set(provider, new Input);
|
|
20800
21095
|
this.#message = remove ? "Saved key removed." : "Saved. Used by the next request.";
|
|
20801
21096
|
this.#scheduleAutoClose(generation);
|
|
20802
21097
|
}
|
|
@@ -20810,34 +21105,100 @@ class LoginPanel {
|
|
|
20810
21105
|
}
|
|
20811
21106
|
}
|
|
20812
21107
|
}
|
|
21108
|
+
#frame(rows, help, width) {
|
|
21109
|
+
const body = Math.max(0, this.height - 1);
|
|
21110
|
+
while (rows.length < body)
|
|
21111
|
+
rows.push("");
|
|
21112
|
+
return [...rows.slice(0, body), help].map((line) => theme.panel(` ${truncateToWidth3(line, Math.max(1, width - 2), "...", true)} `));
|
|
21113
|
+
}
|
|
20813
21114
|
render(width) {
|
|
21115
|
+
return this.#level === "list" ? this.#renderList(width) : this.#renderKey(width);
|
|
21116
|
+
}
|
|
21117
|
+
#renderList(width) {
|
|
21118
|
+
const w = Math.max(1, width - 2);
|
|
21119
|
+
const items = this.#visible();
|
|
21120
|
+
this.#index = Math.max(0, Math.min(this.#index, items.length - 1));
|
|
21121
|
+
const selected = items[this.#index];
|
|
21122
|
+
const rows = [theme.accent(style.bold("Model providers and API keys"))];
|
|
21123
|
+
if (this.height >= 4) {
|
|
21124
|
+
this.#filter.focused = this.focused;
|
|
21125
|
+
rows.push(...this.#filter.render(w).slice(0, 1));
|
|
21126
|
+
}
|
|
21127
|
+
const showStatus = this.height >= 6;
|
|
21128
|
+
const entries = [];
|
|
21129
|
+
let group;
|
|
21130
|
+
for (const row of items) {
|
|
21131
|
+
const next = row.group === "search" ? "Web search" : "Model providers";
|
|
21132
|
+
if (next !== group)
|
|
21133
|
+
entries.push({ header: next });
|
|
21134
|
+
group = next;
|
|
21135
|
+
entries.push({ row });
|
|
21136
|
+
}
|
|
21137
|
+
const count = Math.max(1, this.height - rows.length - 1 - (showStatus ? 1 : 0));
|
|
21138
|
+
const at = entries.findIndex((entry) => ("row" in entry) && entry.row === selected);
|
|
21139
|
+
const start = Math.max(0, Math.min(at - Math.floor(count / 2), entries.length - count));
|
|
21140
|
+
for (const entry of entries.slice(start, start + count)) {
|
|
21141
|
+
if ("header" in entry) {
|
|
21142
|
+
rows.push(theme.dim(` ${entry.header}`));
|
|
21143
|
+
continue;
|
|
21144
|
+
}
|
|
21145
|
+
const { spec, group: rowGroup } = entry.row;
|
|
21146
|
+
const status = this.#state?.statuses[spec.id];
|
|
21147
|
+
const enabled = this.#isEnabled(spec);
|
|
21148
|
+
const modelRow = rowGroup === "model";
|
|
21149
|
+
const mark = modelRow ? enabled ? "[x]" : "[ ]" : " ";
|
|
21150
|
+
const right = status ? `${status.source} \xB7 env ${status.environmentConfigured ? "set" : "unset"}` : "loading";
|
|
21151
|
+
const leftWidth = Math.max(1, w - 3 - visibleWidth3(right));
|
|
21152
|
+
const left = truncateToWidth3(`${mark} ${spec.name}${modelRow && isLocked(spec.id) ? " (always on)" : ""}`, leftWidth, "...");
|
|
21153
|
+
const label = `${left}${" ".repeat(Math.max(1, leftWidth - visibleWidth3(left) + 1))}${right}`;
|
|
21154
|
+
if (entry.row === selected)
|
|
21155
|
+
rows.push(theme.selection(`\u276F ${label}`));
|
|
21156
|
+
else
|
|
21157
|
+
rows.push(modelRow && !enabled ? theme.dim(` ${label}`) : ` ${label}`);
|
|
21158
|
+
}
|
|
21159
|
+
if (items.length === 0)
|
|
21160
|
+
rows.push("No matching providers");
|
|
21161
|
+
if (showStatus) {
|
|
21162
|
+
while (rows.length < this.height - 2)
|
|
21163
|
+
rows.push("");
|
|
21164
|
+
const hint = selected ? selected.group === "search" && isModelProvider(selected.spec.id) ? `Same key as the ${selected.spec.name} model provider. Environment variable: ${selected.spec.envVar}` : `Environment variable: ${selected.spec.envVar}` : "";
|
|
21165
|
+
rows.push(this.#message || (hint ? theme.dim(hint) : ""));
|
|
21166
|
+
}
|
|
21167
|
+
const help = this.#busy ? shortcutHints(["Esc", "Close"]) : shortcutHints(["\u2191\u2193", "Select"], ["Space", "Toggle"], ["Enter", "Key"], ["Esc", "Close"]);
|
|
21168
|
+
return this.#frame(rows, help, width);
|
|
21169
|
+
}
|
|
21170
|
+
#renderKey(width) {
|
|
20814
21171
|
const state = this.#status;
|
|
20815
|
-
const spec =
|
|
20816
|
-
const tabs = CREDENTIAL_PROVIDERS.map((item) => item.id === this.#provider ? `[${item.id}]` : ` ${item.id} `).join(" ");
|
|
21172
|
+
const spec = CREDENTIAL_PROVIDERS.find((item) => item.id === this.#provider) ?? CREDENTIAL_PROVIDERS[0];
|
|
20817
21173
|
const source = state?.source === "keyless" ? "keyless (rate-limited)" : state?.source ?? "Loading...";
|
|
20818
21174
|
const keyLength = this.#input.getValue().length;
|
|
20819
21175
|
const marker = this.focused ? CURSOR_MARKER2 : "";
|
|
20820
21176
|
const keyRow = keyLength > 0 ? `API Key: ********${marker}${this.focused ? renderFakeCursor(" ") : ""} (${keyLength} characters)` : `API Key: ${marker}${this.focused ? `${renderFakeCursor("(")}paste key)` : "(paste key)"}`;
|
|
20821
|
-
const
|
|
20822
|
-
|
|
20823
|
-
|
|
20824
|
-
|
|
20825
|
-
|
|
20826
|
-
|
|
20827
|
-
|
|
20828
|
-
];
|
|
20829
|
-
|
|
20830
|
-
|
|
20831
|
-
|
|
20832
|
-
|
|
20833
|
-
|
|
20834
|
-
|
|
20835
|
-
|
|
20836
|
-
|
|
21177
|
+
const tag = this.#group === "search" ? isModelProvider(spec.id) ? "web search, same key as model provider" : "web search" : this.#isEnabled(spec) ? "enabled" : "disabled";
|
|
21178
|
+
const defaultMessage = spec.keyless ? `Without a key, ${spec.name} runs in rate-limited keyless mode.` : this.#group === "model" && !this.#isEnabled(spec) ? "Provider is disabled. Esc, then Space enables it." : "Saved key overrides environment.";
|
|
21179
|
+
const provider = `Provider: ${spec.name} (${tag})`;
|
|
21180
|
+
const message = this.#message || defaultMessage;
|
|
21181
|
+
const environment = `Environment: ${spec.envVar} ${state ? state.environmentConfigured ? "Configured" : "Not configured" : "Loading..."}`;
|
|
21182
|
+
const sourceRow = `Active source: ${source}`;
|
|
21183
|
+
const rows = this.height - 1 >= 6 ? [provider, environment, sourceRow, keyRow, message, spec.signupUrl] : [provider, keyRow, message, environment, sourceRow, spec.signupUrl];
|
|
21184
|
+
const help = this.#busy ? shortcutHints(["Esc", "Close"]) : this.#confirmingRemove ? shortcutHints(["Ctrl+R", "Confirm remove"], ["Esc", "Back"]) : state?.savedConfigured ? shortcutHints(["Enter", "Save"], ["Ctrl+R", "Remove"], ["Tab", "Providers"], ["Esc", "Back"]) : shortcutHints(["Enter", "Save"], ["Tab", "Providers"], ["Esc", "Back"]);
|
|
21185
|
+
return this.#frame(rows, help, width);
|
|
21186
|
+
}
|
|
21187
|
+
}
|
|
21188
|
+
var AUTO_CLOSE_MS = 800, isLocked = (id) => LOCKED_PROVIDERS.includes(id), SEARCH_ALIASES, listRows = () => {
|
|
21189
|
+
const all = CREDENTIAL_PROVIDERS.map((spec) => ({ spec, group: spec.kind === "search" ? "search" : "model" }));
|
|
21190
|
+
for (const id of SEARCH_ALIASES) {
|
|
21191
|
+
const spec = CREDENTIAL_PROVIDERS.find((item) => item.id === id);
|
|
21192
|
+
if (spec)
|
|
21193
|
+
all.push({ spec, group: "search" });
|
|
21194
|
+
}
|
|
21195
|
+
return all;
|
|
21196
|
+
}, compact = (value) => value.toLowerCase().replace(/\s+/g, "");
|
|
20837
21197
|
var init_login = __esm(() => {
|
|
20838
21198
|
init_src();
|
|
20839
21199
|
init_theme();
|
|
20840
21200
|
init_shortcut_hints();
|
|
21201
|
+
SEARCH_ALIASES = ["deepseek"];
|
|
20841
21202
|
});
|
|
20842
21203
|
|
|
20843
21204
|
// packages/tui/src/components/notice.ts
|
|
@@ -20861,7 +21222,7 @@ import {
|
|
|
20861
21222
|
isKeyRelease as isKeyRelease3,
|
|
20862
21223
|
matchesKey as matchesKey6,
|
|
20863
21224
|
truncateToWidth as truncateToWidth4,
|
|
20864
|
-
visibleWidth as
|
|
21225
|
+
visibleWidth as visibleWidth4,
|
|
20865
21226
|
wrapTextWithAnsi as wrapTextWithAnsi3
|
|
20866
21227
|
} from "@earendil-works/pi-tui";
|
|
20867
21228
|
|
|
@@ -20869,7 +21230,9 @@ class PickerPanel {
|
|
|
20869
21230
|
pointerSelection = false;
|
|
20870
21231
|
agentNavigation = false;
|
|
20871
21232
|
emptyText;
|
|
21233
|
+
groupedFilter = false;
|
|
20872
21234
|
listKey;
|
|
21235
|
+
help;
|
|
20873
21236
|
search = new Input2({ prompt: "\u276F ", placeholder: "Type to filter" });
|
|
20874
21237
|
#items = [];
|
|
20875
21238
|
#index = 0;
|
|
@@ -20877,6 +21240,7 @@ class PickerPanel {
|
|
|
20877
21240
|
#generation = 0;
|
|
20878
21241
|
#state = "closed";
|
|
20879
21242
|
#error = "";
|
|
21243
|
+
#hint = "";
|
|
20880
21244
|
#title = "";
|
|
20881
21245
|
#load;
|
|
20882
21246
|
#pick;
|
|
@@ -20896,6 +21260,9 @@ class PickerPanel {
|
|
|
20896
21260
|
set focused(value) {
|
|
20897
21261
|
this.search.focused = value;
|
|
20898
21262
|
}
|
|
21263
|
+
set hint(value) {
|
|
21264
|
+
this.#hint = value;
|
|
21265
|
+
}
|
|
20899
21266
|
invalidate() {}
|
|
20900
21267
|
async show(title, load, pick) {
|
|
20901
21268
|
if (this.open)
|
|
@@ -20939,6 +21306,9 @@ class PickerPanel {
|
|
|
20939
21306
|
this.pointerSelection = false;
|
|
20940
21307
|
this.agentNavigation = false;
|
|
20941
21308
|
this.emptyText = undefined;
|
|
21309
|
+
this.groupedFilter = false;
|
|
21310
|
+
this.help = undefined;
|
|
21311
|
+
this.#hint = "";
|
|
20942
21312
|
this.listKey = undefined;
|
|
20943
21313
|
++this.#generation;
|
|
20944
21314
|
for (const detail of this.#details)
|
|
@@ -20969,9 +21339,23 @@ class PickerPanel {
|
|
|
20969
21339
|
#details = [];
|
|
20970
21340
|
#filtered() {
|
|
20971
21341
|
const query = this.search.getValue().toLowerCase();
|
|
20972
|
-
if (query
|
|
21342
|
+
if (query === "")
|
|
21343
|
+
return this.#items;
|
|
21344
|
+
if (!this.groupedFilter)
|
|
20973
21345
|
return this.#items.filter((item) => !item.header && this.#matches(item, query));
|
|
20974
|
-
|
|
21346
|
+
const result = [];
|
|
21347
|
+
let header;
|
|
21348
|
+
for (const item of this.#items) {
|
|
21349
|
+
if (item.header)
|
|
21350
|
+
header = item;
|
|
21351
|
+
else if (this.#matches(item, query)) {
|
|
21352
|
+
if (header)
|
|
21353
|
+
result.push(header);
|
|
21354
|
+
header = undefined;
|
|
21355
|
+
result.push(item);
|
|
21356
|
+
}
|
|
21357
|
+
}
|
|
21358
|
+
return result;
|
|
20975
21359
|
}
|
|
20976
21360
|
#matches(item, query) {
|
|
20977
21361
|
return `${item.label} ${item.description ?? ""} ${item.searchText ?? ""}`.toLowerCase().includes(query);
|
|
@@ -21019,6 +21403,7 @@ class PickerPanel {
|
|
|
21019
21403
|
}
|
|
21020
21404
|
if (this.#state !== "ready")
|
|
21021
21405
|
return;
|
|
21406
|
+
this.#hint = "";
|
|
21022
21407
|
const items = this.#filtered();
|
|
21023
21408
|
if (this.listKey?.(data, items[this.#index]?.value)) {
|
|
21024
21409
|
this.changed();
|
|
@@ -21032,6 +21417,11 @@ class PickerPanel {
|
|
|
21032
21417
|
const item = items[this.#index];
|
|
21033
21418
|
if (!item || item.header)
|
|
21034
21419
|
return;
|
|
21420
|
+
if (item.blockedHint) {
|
|
21421
|
+
this.#hint = item.blockedHint;
|
|
21422
|
+
this.changed();
|
|
21423
|
+
return;
|
|
21424
|
+
}
|
|
21035
21425
|
const generation = this.#generation;
|
|
21036
21426
|
this.#state = "applying";
|
|
21037
21427
|
this.#pick(item.value).then((result) => {
|
|
@@ -21112,8 +21502,9 @@ class PickerPanel {
|
|
|
21112
21502
|
}
|
|
21113
21503
|
if (height >= 4)
|
|
21114
21504
|
rows.push(...this.search.render(w).slice(0, 1));
|
|
21115
|
-
const help = this.#state === "error" ? labels.retry : this.#state === "ready" ? this.agentNavigation ? shortcutHints(["\u2191\u2193", "Select"], ["\u2192/Enter", "Open"], ["\u2190", "Main"]) : labels.select : labels.close;
|
|
21116
|
-
const
|
|
21505
|
+
const help = this.#state === "error" ? labels.retry : this.#state === "ready" ? this.agentNavigation ? shortcutHints(["\u2191\u2193", "Select"], ["\u2192/Enter", "Open"], ["\u2190", "Main"]) : this.help ?? labels.select : labels.close;
|
|
21506
|
+
const hint = this.#state === "ready" && height >= 5 ? this.#hint : "";
|
|
21507
|
+
const available = Math.max(1, height - rows.length - 1 - (hint ? 1 : 0));
|
|
21117
21508
|
if (this.#state !== "ready")
|
|
21118
21509
|
rows.push(this.#state === "error" ? theme.error(`Error: ${this.#error}`) : this.#state === "applying" ? labels.applying : labels.loading);
|
|
21119
21510
|
else {
|
|
@@ -21125,7 +21516,7 @@ class PickerPanel {
|
|
|
21125
21516
|
this.#index = first;
|
|
21126
21517
|
}
|
|
21127
21518
|
const selected = items[this.#index];
|
|
21128
|
-
const details = height >= 9 && selected?.description ? wrapTextWithAnsi3(selected.description, w).slice(0, 2) : [];
|
|
21519
|
+
const details = height >= 9 && !hint && selected?.description ? wrapTextWithAnsi3(selected.description, w).slice(0, 2) : [];
|
|
21129
21520
|
const count = Math.max(1, available - details.length);
|
|
21130
21521
|
const start = Math.max(0, Math.min(this.#index - Math.floor(count / 2), items.length - count));
|
|
21131
21522
|
for (const [i, item] of items.slice(start, start + count).entries()) {
|
|
@@ -21134,9 +21525,9 @@ class PickerPanel {
|
|
|
21134
21525
|
continue;
|
|
21135
21526
|
}
|
|
21136
21527
|
const right = item.rightLabel ?? "";
|
|
21137
|
-
const leftWidth = Math.max(1, w - 3 -
|
|
21528
|
+
const leftWidth = Math.max(1, w - 3 - visibleWidth4(right));
|
|
21138
21529
|
const left = truncateToWidth4(item.label, leftWidth, "...");
|
|
21139
|
-
const label = right ? `${left}${" ".repeat(Math.max(1, leftWidth -
|
|
21530
|
+
const label = right ? `${left}${" ".repeat(Math.max(1, leftWidth - visibleWidth4(left) + 1))}${right}` : left;
|
|
21140
21531
|
const rendered = start + i === this.#index ? theme.selection(`\u276F ${label}`) : ` ${label}`;
|
|
21141
21532
|
if (this.pointerSelection)
|
|
21142
21533
|
this.#pointerRows.set(rows.length, start + i);
|
|
@@ -21144,9 +21535,11 @@ class PickerPanel {
|
|
|
21144
21535
|
}
|
|
21145
21536
|
if (items.length === 0)
|
|
21146
21537
|
rows.push(this.emptyText !== undefined && this.#items.length === 0 ? this.emptyText : labels.noResults);
|
|
21147
|
-
while (rows.length < height - 1 - details.length)
|
|
21538
|
+
while (rows.length < height - 1 - details.length - (hint ? 1 : 0))
|
|
21148
21539
|
rows.push("");
|
|
21149
21540
|
rows.push(...details.map((line) => theme.dim(line)));
|
|
21541
|
+
if (hint)
|
|
21542
|
+
rows.push(theme.warning(hint));
|
|
21150
21543
|
}
|
|
21151
21544
|
while (rows.length < height - 1)
|
|
21152
21545
|
rows.push("");
|
|
@@ -43111,8 +43504,6 @@ function serveSessions(host, runtime, context) {
|
|
|
43111
43504
|
for (const id of input.images ?? [])
|
|
43112
43505
|
uploads.value.release(id);
|
|
43113
43506
|
} catch (error) {
|
|
43114
|
-
if (error instanceof Error && error.message.startsWith("DEEPSEEK_KEY_REQUIRED:"))
|
|
43115
|
-
throw new ChordError4("invalid", "DEEPSEEK_KEY_REQUIRED: Configure DeepSeek in /login or Web settings.");
|
|
43116
43507
|
throw new ChordError4("invalid", error instanceof Error ? error.message : "Cannot submit message");
|
|
43117
43508
|
}
|
|
43118
43509
|
return null;
|
|
@@ -43982,13 +44373,20 @@ async function createNekoServerServices(options) {
|
|
|
43982
44373
|
status: info.status,
|
|
43983
44374
|
awaitingAnswer: info.awaitingAnswer
|
|
43984
44375
|
}));
|
|
43985
|
-
const readStatuses = async () =>
|
|
43986
|
-
|
|
44376
|
+
const readStatuses = async () => {
|
|
44377
|
+
const enabled = new Set(runtime.enabledProviders());
|
|
44378
|
+
return Object.fromEntries(await Promise.all(CREDENTIAL_PROVIDERS.map(async (spec) => {
|
|
44379
|
+
const status = await runtime.credentialStatus(spec.id);
|
|
44380
|
+
return [spec.id, spec.kind === "model" ? { ...status, enabled: enabled.has(spec.id) } : status];
|
|
44381
|
+
})));
|
|
44382
|
+
};
|
|
44383
|
+
const [sessions, workspaces, statuses, search, contextSettings0, defaultModel0] = await Promise.all([
|
|
43987
44384
|
list(),
|
|
43988
44385
|
runtime.listWorkspaces(),
|
|
43989
44386
|
readStatuses(),
|
|
43990
44387
|
runtime.searchSettings(),
|
|
43991
|
-
runtime.contextSettings()
|
|
44388
|
+
runtime.contextSettings(),
|
|
44389
|
+
runtime.defaultModel()
|
|
43992
44390
|
]);
|
|
43993
44391
|
let mutationTail = Promise.resolve();
|
|
43994
44392
|
const serialize = (fn) => {
|
|
@@ -44005,6 +44403,7 @@ async function createNekoServerServices(options) {
|
|
|
44005
44403
|
revision: 1,
|
|
44006
44404
|
...contextSettings0
|
|
44007
44405
|
});
|
|
44406
|
+
const defaultModel = self2.state("defaultModel", DefaultModelStateSchema, defaultModel0);
|
|
44008
44407
|
const refreshContextSettings = async (_input, ctx) => {
|
|
44009
44408
|
const next = await runtime.contextSettings();
|
|
44010
44409
|
const { revision, ...current } = contextSettings.value;
|
|
@@ -44012,6 +44411,12 @@ async function createNekoServerServices(options) {
|
|
|
44012
44411
|
contextSettings.replace(ctx, { revision: revision + 1, ...next });
|
|
44013
44412
|
return null;
|
|
44014
44413
|
};
|
|
44414
|
+
const refreshDefaultModel = async (_input, ctx) => {
|
|
44415
|
+
const next = await runtime.defaultModel();
|
|
44416
|
+
if (JSON.stringify(next) !== JSON.stringify(defaultModel.value))
|
|
44417
|
+
defaultModel.replace(ctx, next);
|
|
44418
|
+
return null;
|
|
44419
|
+
};
|
|
44015
44420
|
const refreshSearchSettings = async (_input, ctx) => {
|
|
44016
44421
|
const next = await runtime.searchSettings();
|
|
44017
44422
|
const current = searchSettings.value;
|
|
@@ -44040,6 +44445,7 @@ async function createNekoServerServices(options) {
|
|
|
44040
44445
|
credentials,
|
|
44041
44446
|
searchSettings,
|
|
44042
44447
|
contextSettings,
|
|
44448
|
+
defaultModel,
|
|
44043
44449
|
async refreshCredentials(_input, ctx) {
|
|
44044
44450
|
credentials.replace(ctx, {
|
|
44045
44451
|
revision: credentials.value.revision + 1,
|
|
@@ -44048,7 +44454,8 @@ async function createNekoServerServices(options) {
|
|
|
44048
44454
|
return null;
|
|
44049
44455
|
},
|
|
44050
44456
|
refreshSearchSettings,
|
|
44051
|
-
refreshContextSettings
|
|
44457
|
+
refreshContextSettings,
|
|
44458
|
+
refreshDefaultModel
|
|
44052
44459
|
};
|
|
44053
44460
|
}, { lifetime: "host" });
|
|
44054
44461
|
const shared = (self2) => self2.get(ServerState, {});
|
|
@@ -44071,7 +44478,17 @@ async function createNekoServerServices(options) {
|
|
|
44071
44478
|
remove: async (input, ctx) => {
|
|
44072
44479
|
await runtime.removeCredential(input.provider);
|
|
44073
44480
|
return hub.refreshCredentials(null, ctx);
|
|
44074
|
-
}
|
|
44481
|
+
},
|
|
44482
|
+
setEnabled: (input, ctx) => serialize(async () => {
|
|
44483
|
+
if (!isModelProvider(input.provider))
|
|
44484
|
+
throw new ChordError5("invalid", "Unknown model provider.");
|
|
44485
|
+
try {
|
|
44486
|
+
await runtime.setProviderEnabled(input.provider, input.enabled);
|
|
44487
|
+
} catch (error) {
|
|
44488
|
+
throw new ChordError5("invalid", error instanceof Error ? error.message : "Cannot change provider.");
|
|
44489
|
+
}
|
|
44490
|
+
return hub.refreshCredentials(null, ctx);
|
|
44491
|
+
})
|
|
44075
44492
|
};
|
|
44076
44493
|
});
|
|
44077
44494
|
host.serve(NekoSearchSettings, (_input, _principal, self2) => {
|
|
@@ -44100,9 +44517,24 @@ async function createNekoServerServices(options) {
|
|
|
44100
44517
|
})
|
|
44101
44518
|
};
|
|
44102
44519
|
});
|
|
44520
|
+
host.serve(NekoDefaultModel, (_input, _principal, self2) => {
|
|
44521
|
+
const hub = shared(self2);
|
|
44522
|
+
return {
|
|
44523
|
+
variant: "ready",
|
|
44524
|
+
state: hub.defaultModel,
|
|
44525
|
+
set: (input, ctx) => serialize(async () => {
|
|
44526
|
+
await runtime.setDefaultModel(input);
|
|
44527
|
+
return hub.refreshDefaultModel(null, ctx);
|
|
44528
|
+
}),
|
|
44529
|
+
clear: (_input, ctx) => serialize(async () => {
|
|
44530
|
+
await runtime.setDefaultModel(null);
|
|
44531
|
+
return hub.refreshDefaultModel(null, ctx);
|
|
44532
|
+
})
|
|
44533
|
+
};
|
|
44534
|
+
});
|
|
44103
44535
|
host.serve(NekoModels, () => ({
|
|
44104
44536
|
variant: "ready",
|
|
44105
|
-
list: async () =>
|
|
44537
|
+
list: async () => (await runtime.listSelectableModels()).map((value) => ({
|
|
44106
44538
|
...value,
|
|
44107
44539
|
input: [...value.input],
|
|
44108
44540
|
supportedThinkingLevels: [...value.supportedThinkingLevels]
|
|
@@ -44194,9 +44626,11 @@ var init_server_services = __esm(() => {
|
|
|
44194
44626
|
credentials: CredentialStateSchema,
|
|
44195
44627
|
searchSettings: SearchSettingsStateSchema,
|
|
44196
44628
|
contextSettings: ContextSettingsStateSchema,
|
|
44629
|
+
defaultModel: DefaultModelStateSchema,
|
|
44197
44630
|
refreshCredentials: method2(Type12.Null(), Type12.Null()),
|
|
44198
44631
|
refreshSearchSettings: method2(Type12.Null(), Type12.Null()),
|
|
44199
|
-
refreshContextSettings: method2(Type12.Null(), Type12.Null())
|
|
44632
|
+
refreshContextSettings: method2(Type12.Null(), Type12.Null()),
|
|
44633
|
+
refreshDefaultModel: method2(Type12.Null(), Type12.Null())
|
|
44200
44634
|
}
|
|
44201
44635
|
});
|
|
44202
44636
|
});
|
|
@@ -44210,7 +44644,6 @@ import { BACKGROUND_CONTEXT as BACKGROUND_CONTEXT4 } from "@earendil-works/chord
|
|
|
44210
44644
|
async function startGateway(options = {}) {
|
|
44211
44645
|
const context = options.context ?? BACKGROUND_CONTEXT4;
|
|
44212
44646
|
const fileConfig = loadNekoConfig(options.configDir);
|
|
44213
|
-
const model = options.model ?? fileConfig.defaultModel ?? DEFAULT_MODEL;
|
|
44214
44647
|
const storagePath = options.storagePath ?? fileConfig.storagePath ?? DEFAULT_STORAGE_PATH;
|
|
44215
44648
|
const host = options.host ?? fileConfig.gateway?.host ?? DEFAULT_HOST;
|
|
44216
44649
|
const port = options.port !== undefined ? options.port : fileConfig.gateway?.port ?? (process.platform === "win32" ? 0 : DEFAULT_PORT);
|
|
@@ -44228,7 +44661,8 @@ async function startGateway(options = {}) {
|
|
|
44228
44661
|
...options.apiKey !== undefined ? { apiKey: options.apiKey } : {},
|
|
44229
44662
|
...searchProvider !== undefined ? { searchProvider } : {},
|
|
44230
44663
|
...fileConfig.context !== undefined ? { contextSettings: fileConfig.context } : {},
|
|
44231
|
-
model,
|
|
44664
|
+
...fileConfig.defaultModel !== undefined ? { model: fileConfig.defaultModel } : {},
|
|
44665
|
+
...options.model !== undefined ? { modelOverride: options.model } : {},
|
|
44232
44666
|
thinkingLevel: options.thinkingLevel ?? fileConfig.thinkingLevel ?? "high",
|
|
44233
44667
|
...options.cwd !== undefined ? { cwd: options.cwd } : {},
|
|
44234
44668
|
...options.providers !== undefined ? { providers: options.providers } : {},
|
|
@@ -44243,7 +44677,6 @@ async function startGateway(options = {}) {
|
|
|
44243
44677
|
socketPath,
|
|
44244
44678
|
serverId,
|
|
44245
44679
|
nekoDir,
|
|
44246
|
-
model,
|
|
44247
44680
|
marketUrl,
|
|
44248
44681
|
promptHome: options.promptHome,
|
|
44249
44682
|
updates: options.updates,
|
|
@@ -44815,7 +45248,8 @@ function helpLines(platform = process.platform) {
|
|
|
44815
45248
|
]);
|
|
44816
45249
|
section("Web search", [
|
|
44817
45250
|
["/search", "Choose the web search provider"],
|
|
44818
|
-
["Enter", "Apply the highlighted provider"]
|
|
45251
|
+
["Enter", "Apply the highlighted provider"],
|
|
45252
|
+
["K", "Set the highlighted provider's API key (opens /login)"]
|
|
44819
45253
|
]);
|
|
44820
45254
|
section("Context", [
|
|
44821
45255
|
["/context", "Tune compaction and tool result pruning"],
|
|
@@ -45015,7 +45449,7 @@ import {
|
|
|
45015
45449
|
isKeyRepeat as isKeyRepeat3,
|
|
45016
45450
|
matchesKey as matchesKey10,
|
|
45017
45451
|
truncateToWidth as truncateToWidth6,
|
|
45018
|
-
visibleWidth as
|
|
45452
|
+
visibleWidth as visibleWidth5,
|
|
45019
45453
|
wrapTextWithAnsi as wrapTextWithAnsi5
|
|
45020
45454
|
} from "@earendil-works/pi-tui";
|
|
45021
45455
|
function settlementText(record, mine) {
|
|
@@ -45494,7 +45928,7 @@ class QuestionDock {
|
|
|
45494
45928
|
`\u2753 \u7B49\u5F85\u56DE\u7B54 (${n}) \xB7 Ctrl+O \u6216 /question`,
|
|
45495
45929
|
"\u2753 \u7B49\u5F85\u56DE\u7B54 \xB7 /question"
|
|
45496
45930
|
];
|
|
45497
|
-
const text = candidates.find((candidate) =>
|
|
45931
|
+
const text = candidates.find((candidate) => visibleWidth5(candidate) <= width - 1) ?? candidates.at(-1) ?? "";
|
|
45498
45932
|
return theme.warning(truncateToWidth6(` ${text}`, width));
|
|
45499
45933
|
}
|
|
45500
45934
|
#panel(entries, width) {
|
|
@@ -45539,7 +45973,7 @@ class QuestionDock {
|
|
|
45539
45973
|
["", maxScroll > 0 ? range : ""],
|
|
45540
45974
|
["", ""]
|
|
45541
45975
|
].map(([a, b]) => title + theme.dim([a, b].filter(Boolean).map((part) => ` \xB7 ${part}`).join("")));
|
|
45542
|
-
const rows = [headers.find((header) =>
|
|
45976
|
+
const rows = [headers.find((header) => visibleWidth5(header) <= width) ?? headers.at(-1) ?? title];
|
|
45543
45977
|
for (const line of bodyLines.slice(scroll, scroll + bodyRows))
|
|
45544
45978
|
rows.push(`${theme.dim("\u2502 ")}${line}`);
|
|
45545
45979
|
if (form) {
|
|
@@ -45619,7 +46053,7 @@ class QuestionDock {
|
|
|
45619
46053
|
];
|
|
45620
46054
|
}
|
|
45621
46055
|
const lines = candidates.map((parts) => ` ${shortcutHints(...parts)}`);
|
|
45622
|
-
return lines.find((line) =>
|
|
46056
|
+
return lines.find((line) => visibleWidth5(line) <= width) ?? truncateToWidth6(lines.at(-1) ?? "", width);
|
|
45623
46057
|
}
|
|
45624
46058
|
}
|
|
45625
46059
|
var QUESTION_MAX_ROWS = 14, QUESTION_MIN_ROWS = 6, SKIP_LABEL = "\u8DF3\u8FC7\u6B64\u95EE\u9898", QUESTION_KEY = "ctrl+o", canAutoOpen = (focus) => focus.online && focus.usable && focus.editorText === "" && !focus.autocomplete && !focus.overlayOpen && !focus.approvalFocused && !focus.sessionOperation && !focus.queueSelecting, keyOf = (session, id, version) => `${session}\x00${id}\x00${version}`, messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
@@ -45759,6 +46193,95 @@ var init_input_router = __esm(() => {
|
|
|
45759
46193
|
init_question_dock();
|
|
45760
46194
|
});
|
|
45761
46195
|
|
|
46196
|
+
// packages/tui/src/provider-ui.ts
|
|
46197
|
+
function providerSendBlock(model, credentials) {
|
|
46198
|
+
const status = model ? credentials?.statuses[model.provider] : undefined;
|
|
46199
|
+
if (!model || !status)
|
|
46200
|
+
return;
|
|
46201
|
+
const name = providerName(model.provider);
|
|
46202
|
+
if (status.enabled === false)
|
|
46203
|
+
return `${name} is disabled. Enable it with /login or switch model.`;
|
|
46204
|
+
if (status.source === "none")
|
|
46205
|
+
return `Configure ${name} with /login before sending.`;
|
|
46206
|
+
return;
|
|
46207
|
+
}
|
|
46208
|
+
function modelItems(models, current, defaultModel) {
|
|
46209
|
+
const currentKey = current ? modelKey(current) : undefined;
|
|
46210
|
+
const defaultKey = defaultModel ? modelKey(defaultModel) : undefined;
|
|
46211
|
+
const order = new Map(MODEL_PROVIDERS.map((spec, index) => [spec.id, index + 1]));
|
|
46212
|
+
const rank = (provider) => provider === current?.provider ? 0 : order.get(provider) ?? order.size + 1;
|
|
46213
|
+
const providers = [...new Set(models.map((model) => model.provider))].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
|
|
46214
|
+
const items = [];
|
|
46215
|
+
for (const provider of providers) {
|
|
46216
|
+
const group = models.filter((model) => model.provider === provider).sort((a, b) => Number(modelKey(b) === currentKey) - Number(modelKey(a) === currentKey) || a.name.localeCompare(b.name));
|
|
46217
|
+
const name = providerName(provider);
|
|
46218
|
+
const available = group.some((model) => model.available);
|
|
46219
|
+
items.push({
|
|
46220
|
+
value: `header:${provider}`,
|
|
46221
|
+
label: `${name}${available ? "" : " \xB7 needs key"}`,
|
|
46222
|
+
header: true
|
|
46223
|
+
});
|
|
46224
|
+
for (const model of group) {
|
|
46225
|
+
const key = modelKey(model);
|
|
46226
|
+
const image = model.input.includes("image");
|
|
46227
|
+
const tags = [
|
|
46228
|
+
...key === defaultKey ? ["default"] : [],
|
|
46229
|
+
...model.available ? [] : ["needs key"],
|
|
46230
|
+
formatTokens(model.contextWindow),
|
|
46231
|
+
...model.reasoning ? ["Thinking"] : [],
|
|
46232
|
+
...image ? ["Images"] : []
|
|
46233
|
+
];
|
|
46234
|
+
items.push({
|
|
46235
|
+
value: key,
|
|
46236
|
+
label: `${key}${key === currentKey ? " (Current)" : ""}${key === defaultKey ? " \u2605" : ""}`,
|
|
46237
|
+
rightLabel: tags.join(" \xB7 "),
|
|
46238
|
+
searchText: `${model.name} ${name}`,
|
|
46239
|
+
description: `${model.name} | ${formatTokens(model.contextWindow)} context${model.reasoning ? " | Thinking" : ""} | ${image ? "Images" : "Text only"}`,
|
|
46240
|
+
...model.available ? {} : { blockedHint: needsKeyHint(provider) }
|
|
46241
|
+
});
|
|
46242
|
+
}
|
|
46243
|
+
}
|
|
46244
|
+
return items;
|
|
46245
|
+
}
|
|
46246
|
+
function openModelPanel(panel, client, current, applyModel, notify) {
|
|
46247
|
+
let models = [];
|
|
46248
|
+
const currentKey = current ? modelKey(current) : null;
|
|
46249
|
+
const effectiveDefault = () => client.defaultModel.state.value?.effective ?? null;
|
|
46250
|
+
const items = () => modelItems(models, current, effectiveDefault());
|
|
46251
|
+
const stop = client.defaultModel.state.subscribe(() => panel.update(items()));
|
|
46252
|
+
panel.groupedFilter = true;
|
|
46253
|
+
panel.help = shortcutHints(["\u2191\u2193", "Select"], ["Enter", "Open"], ["D", "Toggle default"], ["Esc", "Close"]);
|
|
46254
|
+
panel.listKey = (data, value) => {
|
|
46255
|
+
if (data.toLowerCase() !== "d" || panel.search.getValue() !== "" || value === undefined)
|
|
46256
|
+
return false;
|
|
46257
|
+
const model = models.find((m) => modelKey(m) === value);
|
|
46258
|
+
if (!model)
|
|
46259
|
+
return false;
|
|
46260
|
+
if (!model.available) {
|
|
46261
|
+
panel.hint = needsKeyHint(model.provider);
|
|
46262
|
+
return true;
|
|
46263
|
+
}
|
|
46264
|
+
const effective = effectiveDefault();
|
|
46265
|
+
const toggle = effective !== null && modelKey(effective) === value ? client.defaultModel.clear(null) : client.defaultModel.set({ provider: model.provider, modelId: model.modelId });
|
|
46266
|
+
toggle.catch((error) => notify(error instanceof Error ? error.message : String(error)));
|
|
46267
|
+
return true;
|
|
46268
|
+
};
|
|
46269
|
+
panel.show("Models", async () => {
|
|
46270
|
+
models = await client.models.list(null);
|
|
46271
|
+
return items();
|
|
46272
|
+
}, async (value) => {
|
|
46273
|
+
const selected = models.find((m) => modelKey(m) === value);
|
|
46274
|
+
if (selected?.available && value !== currentKey)
|
|
46275
|
+
await applyModel(selected);
|
|
46276
|
+
});
|
|
46277
|
+
return stop;
|
|
46278
|
+
}
|
|
46279
|
+
var modelKey = (model) => `${model.provider}/${model.modelId}`, providerName = (id) => CREDENTIAL_PROVIDERS.find((spec) => spec.id === id)?.name ?? id, isProviderRejection = (message) => /^(PROVIDER_KEY_REQUIRED|PROVIDER_DISABLED):/.test(message), needsKeyHint = (provider) => `${providerName(provider)} needs a key. Use /login to configure it.`;
|
|
46280
|
+
var init_provider_ui = __esm(() => {
|
|
46281
|
+
init_src();
|
|
46282
|
+
init_shortcut_hints();
|
|
46283
|
+
});
|
|
46284
|
+
|
|
45762
46285
|
// packages/tui/src/queue-ui.ts
|
|
45763
46286
|
import { matchesKey as matchesKey12, truncateToWidth as truncateToWidth7 } from "@earendil-works/pi-tui";
|
|
45764
46287
|
|
|
@@ -45866,10 +46389,10 @@ function searchItems(settings, credentials) {
|
|
|
45866
46389
|
const status = credentials?.statuses[provider];
|
|
45867
46390
|
return status ? SOURCES2[status.source] : "loading";
|
|
45868
46391
|
};
|
|
45869
|
-
const deepseekMissing = credentials?.statuses.deepseek
|
|
46392
|
+
const deepseekMissing = credentials?.statuses.deepseek?.source === "none";
|
|
45870
46393
|
const descriptions = {
|
|
45871
46394
|
tavily: `Tavily search (${source("tavily")}). Default`,
|
|
45872
|
-
deepseek: deepseekMissing ? "No DeepSeek key.
|
|
46395
|
+
deepseek: deepseekMissing ? "No DeepSeek key. Press k (or use /login) to set one before choosing it" : `DeepSeek search and fetch with your DeepSeek API key (${source("deepseek")})`
|
|
45873
46396
|
};
|
|
45874
46397
|
return SEARCH_PROVIDERS.map((value) => ({
|
|
45875
46398
|
value,
|
|
@@ -45877,11 +46400,23 @@ function searchItems(settings, credentials) {
|
|
|
45877
46400
|
description: descriptions[value]
|
|
45878
46401
|
}));
|
|
45879
46402
|
}
|
|
45880
|
-
function openSearchPanel(panel, client, notify) {
|
|
46403
|
+
function openSearchPanel(panel, client, notify, openKey) {
|
|
45881
46404
|
const items = () => searchItems(client.searchSettings.state.value, client.credentials.state.value);
|
|
45882
46405
|
const refresh = () => panel.update(items());
|
|
45883
46406
|
const stops = [client.searchSettings.state.subscribe(refresh), client.credentials.state.subscribe(refresh)];
|
|
45884
46407
|
panel.emptyText = SEARCH_EMPTY;
|
|
46408
|
+
if (openKey) {
|
|
46409
|
+
panel.help = shortcutHints(["\u2191\u2193", "Select"], ["Enter", "Choose"], ["K", "Set key"], ["Esc", "Close"]);
|
|
46410
|
+
panel.listKey = (data, value) => {
|
|
46411
|
+
if (data.toLowerCase() !== "k" || panel.search.getValue() !== "" || value === undefined)
|
|
46412
|
+
return false;
|
|
46413
|
+
if (!SEARCH_PROVIDERS.includes(value))
|
|
46414
|
+
return false;
|
|
46415
|
+
panel.close();
|
|
46416
|
+
openKey(value);
|
|
46417
|
+
return true;
|
|
46418
|
+
};
|
|
46419
|
+
}
|
|
45885
46420
|
panel.show("Web search", async () => items(), async (value) => {
|
|
45886
46421
|
await client.searchSettings.set({ provider: value });
|
|
45887
46422
|
notify(`Web search provider set to ${NAMES[value]}.`);
|
|
@@ -45894,6 +46429,7 @@ function openSearchPanel(panel, client, notify) {
|
|
|
45894
46429
|
var SEARCH_EMPTY = "Search settings are unavailable.", NAMES, SOURCES2;
|
|
45895
46430
|
var init_search_ui = __esm(() => {
|
|
45896
46431
|
init_search_providers();
|
|
46432
|
+
init_shortcut_hints();
|
|
45897
46433
|
NAMES = { tavily: "Tavily", deepseek: "DeepSeek" };
|
|
45898
46434
|
SOURCES2 = {
|
|
45899
46435
|
saved: "saved key",
|
|
@@ -46424,7 +46960,7 @@ var init_subagents_ui = __esm(() => {
|
|
|
46424
46960
|
});
|
|
46425
46961
|
|
|
46426
46962
|
// packages/tui/src/todos-ui.ts
|
|
46427
|
-
import { matchesKey as matchesKey15, truncateToWidth as truncateToWidth8, visibleWidth as
|
|
46963
|
+
import { matchesKey as matchesKey15, truncateToWidth as truncateToWidth8, visibleWidth as visibleWidth6, wrapTextWithAnsi as wrapTextWithAnsi7 } from "@earendil-works/pi-tui";
|
|
46428
46964
|
function todoProgressText(list) {
|
|
46429
46965
|
if (!list || list.items.length === 0)
|
|
46430
46966
|
return;
|
|
@@ -46487,7 +47023,7 @@ class TodosDetail {
|
|
|
46487
47023
|
rows.push(row === 0 ? styled(item.status, glyph, `${number}${line}`) : theme.dim(`${indent}${line}`));
|
|
46488
47024
|
});
|
|
46489
47025
|
});
|
|
46490
|
-
const legend = height >= 5 &&
|
|
47026
|
+
const legend = height >= 5 && visibleWidth6(LEGEND) <= width ? [theme.dim(LEGEND)] : [];
|
|
46491
47027
|
const pinned = offline.length + 1 + legend.length;
|
|
46492
47028
|
const room = Math.max(1, height - pinned);
|
|
46493
47029
|
this.#max = Math.max(0, rows.length - room);
|
|
@@ -46715,6 +47251,7 @@ class NekoTuiApp {
|
|
|
46715
47251
|
#queueRow = new QueueRow;
|
|
46716
47252
|
#searchStop;
|
|
46717
47253
|
#contextStop;
|
|
47254
|
+
#modelStop;
|
|
46718
47255
|
#agentDetails = new Map;
|
|
46719
47256
|
#sessionId = "";
|
|
46720
47257
|
#viewUnsubscribe;
|
|
@@ -46773,6 +47310,8 @@ class NekoTuiApp {
|
|
|
46773
47310
|
this.#searchStop = undefined;
|
|
46774
47311
|
this.#contextStop?.();
|
|
46775
47312
|
this.#contextStop = undefined;
|
|
47313
|
+
this.#modelStop?.();
|
|
47314
|
+
this.#modelStop = undefined;
|
|
46776
47315
|
clearInterval(this.#sessionPanelTimer);
|
|
46777
47316
|
this.#sessionPanelTimer = undefined;
|
|
46778
47317
|
this.#ui.setFocus(this.#question.open ? this.#question : this.#editor);
|
|
@@ -46801,6 +47340,9 @@ class NekoTuiApp {
|
|
|
46801
47340
|
},
|
|
46802
47341
|
remove: async (provider) => {
|
|
46803
47342
|
await this.#gateway.client.credentials.remove({ provider });
|
|
47343
|
+
},
|
|
47344
|
+
toggle: async (provider, enabled) => {
|
|
47345
|
+
await this.#gateway.client.credentials.setEnabled({ provider, enabled });
|
|
46804
47346
|
}
|
|
46805
47347
|
});
|
|
46806
47348
|
const complete = fileCompletion(this.#commands, options.cwd ?? process.cwd(), (text) => this.addNotice(text), (query, signal) => this.#gateway.client.host.root((ctx) => this.#gateway.client.workspaceFiles.search({ workspaceRoot: this.#lastView?.cwd ?? options.cwd ?? process.cwd(), query }, ctx), { signal }));
|
|
@@ -47003,7 +47545,7 @@ class NekoTuiApp {
|
|
|
47003
47545
|
chat.compact({ instructions }).catch((e) => {
|
|
47004
47546
|
if (session === this.#sessionId) {
|
|
47005
47547
|
this.#editor.setText(text);
|
|
47006
|
-
this.addNotice(messageOf2(e), "error");
|
|
47548
|
+
this.addNotice(messageOf2(e), isProviderRejection(messageOf2(e)) ? "warning" : "error");
|
|
47007
47549
|
}
|
|
47008
47550
|
});
|
|
47009
47551
|
return;
|
|
@@ -47017,14 +47559,7 @@ class NekoTuiApp {
|
|
|
47017
47559
|
return;
|
|
47018
47560
|
}
|
|
47019
47561
|
if (trimmed === "/login") {
|
|
47020
|
-
|
|
47021
|
-
const service = this.#gateway.client.credentials;
|
|
47022
|
-
this.#login.show(service.state.value, (fn) => service.state.subscribe((value) => {
|
|
47023
|
-
if (value)
|
|
47024
|
-
fn(value);
|
|
47025
|
-
}));
|
|
47026
|
-
this.#ui.setFocus(this.#login);
|
|
47027
|
-
}
|
|
47562
|
+
this.#showLogin();
|
|
47028
47563
|
return;
|
|
47029
47564
|
}
|
|
47030
47565
|
if (trimmed.startsWith("/login ")) {
|
|
@@ -47080,9 +47615,10 @@ class NekoTuiApp {
|
|
|
47080
47615
|
const chat = this.#chat;
|
|
47081
47616
|
if (chat === undefined)
|
|
47082
47617
|
return;
|
|
47083
|
-
|
|
47618
|
+
const blocked = providerSendBlock(this.#lastView?.agent.model, this.#gateway.client.credentials.state.value);
|
|
47619
|
+
if (blocked) {
|
|
47084
47620
|
this.#editor.setText(text);
|
|
47085
|
-
this.addNotice(
|
|
47621
|
+
this.addNotice(blocked, "warning");
|
|
47086
47622
|
return;
|
|
47087
47623
|
}
|
|
47088
47624
|
this.sendImages(text);
|
|
@@ -47163,8 +47699,10 @@ class NekoTuiApp {
|
|
|
47163
47699
|
this.#imageDrafts.get(session)?.delete(ref);
|
|
47164
47700
|
this.#retryRequests.delete(session);
|
|
47165
47701
|
} catch (e) {
|
|
47166
|
-
if (session === this.#sessionId)
|
|
47167
|
-
|
|
47702
|
+
if (session === this.#sessionId) {
|
|
47703
|
+
const message = messageOf2(e);
|
|
47704
|
+
this.addNotice(message, isProviderRejection(message) ? "warning" : "error");
|
|
47705
|
+
}
|
|
47168
47706
|
} finally {
|
|
47169
47707
|
for (const id of ids)
|
|
47170
47708
|
await chat.releaseImage(id).catch(() => {});
|
|
@@ -47345,22 +47883,10 @@ class NekoTuiApp {
|
|
|
47345
47883
|
return;
|
|
47346
47884
|
const chat = this.#chat;
|
|
47347
47885
|
const current = this.#lastView?.agent.model;
|
|
47348
|
-
|
|
47349
|
-
|
|
47350
|
-
|
|
47351
|
-
models = await this.#gateway.client.models.list(null);
|
|
47352
|
-
return [...models].sort((a, b) => Number(keyOf2(b) === currentKey) - Number(keyOf2(a) === currentKey)).map((model) => ({
|
|
47353
|
-
value: keyOf2(model),
|
|
47354
|
-
label: `${model.name}${keyOf2(model) === currentKey ? " (Current)" : ""}`,
|
|
47355
|
-
description: `${keyOf2(model)} | ${formatContextWindow(model.contextWindow)} context${model.reasoning ? " | Thinking" : ""} | ${model.input.includes("image") ? "Images" : "Text only"}`
|
|
47356
|
-
}));
|
|
47357
|
-
}, async (value) => {
|
|
47358
|
-
const selected = models.find((m) => keyOf2(m) === value);
|
|
47359
|
-
if (selected && value !== currentKey)
|
|
47360
|
-
await chat?.configure({ model: { provider: selected.provider, modelId: selected.modelId } });
|
|
47361
|
-
});
|
|
47886
|
+
this.#modelStop = openModelPanel(this.#panel, this.#gateway.client, current, async (selected) => {
|
|
47887
|
+
await chat?.configure({ model: { provider: selected.provider, modelId: selected.modelId } });
|
|
47888
|
+
}, (message) => this.addNotice(message, "error"));
|
|
47362
47889
|
this.#ui.setFocus(this.#panel);
|
|
47363
|
-
await ready;
|
|
47364
47890
|
}
|
|
47365
47891
|
async openThemeOverlay() {
|
|
47366
47892
|
if (this.#exitStarted || this.#panel.open || this.#login.open)
|
|
@@ -47402,8 +47928,12 @@ class NekoTuiApp {
|
|
|
47402
47928
|
return;
|
|
47403
47929
|
try {
|
|
47404
47930
|
const model = (await this.#gateway.client.models.list(null)).find((m) => m.provider === ref.provider && m.modelId === ref.modelId);
|
|
47405
|
-
if (chat !== this.#chat || this.#exitStarted || this.#panel.open || this.#login.open
|
|
47931
|
+
if (chat !== this.#chat || this.#exitStarted || this.#panel.open || this.#login.open)
|
|
47932
|
+
return;
|
|
47933
|
+
if (!model) {
|
|
47934
|
+
this.addNotice("The current model is unavailable. Choose another with /model.", "warning");
|
|
47406
47935
|
return;
|
|
47936
|
+
}
|
|
47407
47937
|
if (raw) {
|
|
47408
47938
|
const level = model.supportedThinkingLevels.find((value) => value === raw);
|
|
47409
47939
|
if (!level) {
|
|
@@ -47562,10 +48092,20 @@ class NekoTuiApp {
|
|
|
47562
48092
|
});
|
|
47563
48093
|
return { consume: true };
|
|
47564
48094
|
}
|
|
48095
|
+
#showLogin(initial) {
|
|
48096
|
+
if (this.#panel.open || this.#login.open)
|
|
48097
|
+
return;
|
|
48098
|
+
const service = this.#gateway.client.credentials;
|
|
48099
|
+
this.#login.show(service.state.value, (fn) => service.state.subscribe((value) => {
|
|
48100
|
+
if (value)
|
|
48101
|
+
fn(value);
|
|
48102
|
+
}), initial);
|
|
48103
|
+
this.#ui.setFocus(this.#login);
|
|
48104
|
+
}
|
|
47565
48105
|
#showSearch() {
|
|
47566
48106
|
if (this.#exitStarted || this.#panel.open || this.#login.open)
|
|
47567
48107
|
return;
|
|
47568
|
-
this.#searchStop = openSearchPanel(this.#panel, this.#gateway.client, (message) => this.addNotice(message));
|
|
48108
|
+
this.#searchStop = openSearchPanel(this.#panel, this.#gateway.client, (message) => this.addNotice(message), (provider) => this.#showLogin({ provider, group: "search" }));
|
|
47569
48109
|
this.#ui.setFocus(this.#panel);
|
|
47570
48110
|
}
|
|
47571
48111
|
#showContext() {
|
|
@@ -47655,7 +48195,8 @@ class NekoTuiApp {
|
|
|
47655
48195
|
if (this.#imageWarningModel !== imageModel && view.items.some((i) => (i.type === "user" || i.type === "tool") && i.images?.length)) {
|
|
47656
48196
|
this.#imageWarningModel = imageModel;
|
|
47657
48197
|
this.#gateway.client.models.list(null).then((models) => {
|
|
47658
|
-
|
|
48198
|
+
const model = models.find((m) => m.provider === view.agent.model?.provider && m.modelId === view.agent.model?.modelId);
|
|
48199
|
+
if (this.#imageWarningModel === imageModel && model && !model.input.includes("image"))
|
|
47659
48200
|
this.addNotice("Text-only model: previous images are unavailable to the model; written analysis is retained.", "warning");
|
|
47660
48201
|
}).catch(() => {});
|
|
47661
48202
|
}
|
|
@@ -47849,7 +48390,7 @@ class NekoTuiApp {
|
|
|
47849
48390
|
#syncWelcome(view) {
|
|
47850
48391
|
const empty = view.items.length === 0 && view.streaming === null && !view.busy;
|
|
47851
48392
|
if (empty) {
|
|
47852
|
-
const modelShort = view.model
|
|
48393
|
+
const modelShort = modelDisplayName(view.model);
|
|
47853
48394
|
this.#welcome.setModelLine(view.agent.thinkingLevel !== null ? `${modelShort} \xB7 Think ${view.agent.thinkingLevel}` : modelShort);
|
|
47854
48395
|
if (!this.#welcomeAttached) {
|
|
47855
48396
|
this.#imageTranscript.addChild(this.#welcome);
|
|
@@ -47957,12 +48498,6 @@ function hiddenCommands(view) {
|
|
|
47957
48498
|
hidden.add("question");
|
|
47958
48499
|
return hidden;
|
|
47959
48500
|
}
|
|
47960
|
-
function keyOf2(model) {
|
|
47961
|
-
return `${model.provider}/${model.modelId}`;
|
|
47962
|
-
}
|
|
47963
|
-
function formatContextWindow(tokens) {
|
|
47964
|
-
return formatTokens(tokens);
|
|
47965
|
-
}
|
|
47966
48501
|
async function runTui(options = {}) {
|
|
47967
48502
|
options = { ...options, cwd: normalizeWorkspace(options.cwd) };
|
|
47968
48503
|
const gateway = await connectToGateway({
|
|
@@ -47986,7 +48521,7 @@ async function initialSessionId(gateway, cwd) {
|
|
|
47986
48521
|
return first.id;
|
|
47987
48522
|
return (await gateway.client.management.create({ ...cwd !== undefined ? { cwd } : {} })).id;
|
|
47988
48523
|
}
|
|
47989
|
-
var EXIT_COMMANDS, SESSIONS_COMMANDS, NEW_SESSION_VALUE = "__new__";
|
|
48524
|
+
var EXIT_COMMANDS, SESSIONS_COMMANDS, NEW_SESSION_VALUE = "__new__", keyOf2;
|
|
47990
48525
|
var init_tui = __esm(() => {
|
|
47991
48526
|
init_src();
|
|
47992
48527
|
init_application_updates();
|
|
@@ -48016,6 +48551,7 @@ var init_tui = __esm(() => {
|
|
|
48016
48551
|
init_jobs_ui();
|
|
48017
48552
|
init_labels();
|
|
48018
48553
|
init_layout();
|
|
48554
|
+
init_provider_ui();
|
|
48019
48555
|
init_question_dock();
|
|
48020
48556
|
init_queue_ui();
|
|
48021
48557
|
init_search_ui();
|
|
@@ -48027,6 +48563,7 @@ var init_tui = __esm(() => {
|
|
|
48027
48563
|
init_workspace2();
|
|
48028
48564
|
EXIT_COMMANDS = new Set(["/exit", "/quit"]);
|
|
48029
48565
|
SESSIONS_COMMANDS = new Set(["/sessions", "/session"]);
|
|
48566
|
+
keyOf2 = modelKey;
|
|
48030
48567
|
});
|
|
48031
48568
|
|
|
48032
48569
|
// packages/tui/src/main.ts
|
|
@@ -48110,7 +48647,7 @@ var USAGE = `\u7528\u6CD5: neko tui [\u9009\u9879]
|
|
|
48110
48647
|
|
|
48111
48648
|
\u6062\u590D\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6700\u8FD1\u4F7F\u7528\u7684\u4F1A\u8BDD\uFF0C\u4E0D\u5B58\u5728\u5219\u521B\u5EFA\u3002
|
|
48112
48649
|
\u6309\u9700\u62C9\u8D77\u7F51\u5173\uFF0C\u5C5E\u4E3B TUI \u9000\u51FA\u65F6\u968F\u4E4B\u505C\u6B62\u3002
|
|
48113
|
-
\u53EF\u7528 /login \u6216 DEEPSEEK_API_KEY \u914D\u7F6E\u51ED\u636E\uFF1B/search \u9009\u62E9\u8054\u7F51\u641C\u7D22\u670D\u52A1\uFF08tavily / deepseek\uFF0C\u9ED8\u8BA4 tavily\uFF09\uFF1B/context \u8C03\u6574\u4E0A\u4E0B\u6587\u538B\u7F29\u4E0E\u5DE5\u5177\u7ED3\u679C\u88C1\u526A\u3002`;
|
|
48650
|
+
\u53EF\u7528 /login \u6216 DEEPSEEK_API_KEY \u7B49\u73AF\u5883\u53D8\u91CF\u914D\u7F6E\u51ED\u636E\uFF08\u9664 DeepSeek \u5916\u7684 provider \u9700\u5148\u5728 /login \u542F\u7528\uFF09\uFF1B/search \u9009\u62E9\u8054\u7F51\u641C\u7D22\u670D\u52A1\uFF08tavily / deepseek\uFF0C\u9ED8\u8BA4 tavily\uFF09\uFF1B/context \u8C03\u6574\u4E0A\u4E0B\u6587\u538B\u7F29\u4E0E\u5DE5\u5177\u7ED3\u679C\u88C1\u526A\uFF1B/model \u4E2D\u53EF\u628A\u53EF\u9009\u6A21\u578B\u300C\u8BBE\u4E3A\u9ED8\u8BA4\u300D\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E --model\u3001\u9AD8\u4E8E\u914D\u7F6E\u6587\u4EF6 defaultModel\u3002`;
|
|
48114
48651
|
var init_main = __esm(async () => {
|
|
48115
48652
|
init_tui();
|
|
48116
48653
|
try {
|
|
@@ -49154,11 +49691,13 @@ var USAGE2 = `\u7528\u6CD5: neko web [\u9009\u9879]
|
|
|
49154
49691
|
--server-id <id> \u7F51\u5173\u903B\u8F91\u8EAB\u4EFD\uFF08\u9ED8\u8BA4\u8BFB\u53D6/\u751F\u6210 <\u6570\u636E\u76EE\u5F55>/gateway-server-id\uFF09
|
|
49155
49692
|
--storage <path> SQLite \u5B58\u50A8\u6587\u4EF6\uFF08\u9ED8\u8BA4 ~/.neko/neko.sqlite\uFF09
|
|
49156
49693
|
--cwd <dir> \u4F1A\u8BDD\u5DE5\u5177\u7684\u5DE5\u4F5C\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09
|
|
49157
|
-
--model <ref> \u6A21\u578B\uFF0C\u683C\u5F0F provider/modelId\
|
|
49694
|
+
--model <ref> \u6A21\u578B\uFF0C\u683C\u5F0F provider/modelId\uFF08modelId \u53EF\u542B /\uFF0C\u9ED8\u8BA4 deepseek/deepseek-flash\uFF09
|
|
49158
49695
|
--no-open \u4E0D\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668\uFF08\u9002\u7528\u4E8E\u8FDC\u7A0B\u6216\u65E0\u684C\u9762\u73AF\u5883\uFF09
|
|
49159
49696
|
-h, --help \u663E\u793A\u6B64\u5E2E\u52A9
|
|
49160
49697
|
|
|
49161
|
-
\u53EF\u5728 Web \u8BBE\u7F6E\u9875\u914D\u7F6E Key\
|
|
49698
|
+
\u53EF\u5728 Web \u8BBE\u7F6E\u9875\u300C\u6A21\u578B\u670D\u52A1\u300D\u542F\u7528 provider\uFF08\u5982 OpenRouter\u3001OpenCode Go\uFF09\u5E76\u914D\u7F6E Key\uFF0C\u8054\u7F51\u641C\u7D22\u5728\u300C\u8054\u7F51\u641C\u7D22\u300D\u9875\u8BBE\u7F6E\uFF1B
|
|
49699
|
+
\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u53EF\u628A\u53EF\u9009\u6A21\u578B\u300C\u8BBE\u4E3A\u9ED8\u8BA4\u300D\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E --model\u3001\u9AD8\u4E8E\u914D\u7F6E\u6587\u4EF6 defaultModel\uFF1B
|
|
49700
|
+
\u7F51\u5173\u5B50\u8FDB\u7A0B\u4E5F\u4F1A\u7EE7\u627F DEEPSEEK_API_KEY / OPENROUTER_API_KEY / OPENCODE_API_KEY \u7B49\u73AF\u5883\u53D8\u91CF\u3002`, server, shutdown;
|
|
49162
49701
|
var init_main2 = __esm(async () => {
|
|
49163
49702
|
init_src2();
|
|
49164
49703
|
init_open_browser();
|
|
@@ -49301,14 +49840,16 @@ var GATEWAY_USAGE = `\u7528\u6CD5: neko serve [\u9009\u9879]
|
|
|
49301
49840
|
--no-socket \u7981\u7528 Unix socket \u4F20\u8F93\uFF08\u4EC5 WebSocket\uFF09
|
|
49302
49841
|
--server-id <id> \u903B\u8F91\u670D\u52A1\u5668\u8EAB\u4EFD\uFF08\u9ED8\u8BA4\u8BFB\u53D6/\u751F\u6210 <\u6570\u636E\u76EE\u5F55>/gateway-server-id\uFF09
|
|
49303
49842
|
--cwd <dir> \u4F1A\u8BDD\u5DE5\u5177\u7684\u5DE5\u4F5C\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09
|
|
49304
|
-
--model <ref> \u6A21\u578B\uFF0C\u683C\u5F0F provider/modelId\
|
|
49843
|
+
--model <ref> \u6A21\u578B\uFF0C\u683C\u5F0F provider/modelId\uFF08modelId \u53EF\u542B /\uFF0C\u9ED8\u8BA4 deepseek/deepseek-flash\uFF09
|
|
49305
49844
|
--storage <path> SQLite \u5B58\u50A8\u6587\u4EF6\uFF08\u9ED8\u8BA4 ~/.neko/neko.sqlite\uFF09
|
|
49306
49845
|
--credentials <path> \u7528\u6237\u51ED\u636E\u6587\u4EF6\uFF08\u9ED8\u8BA4 ~/.neko/credentials.json\uFF09
|
|
49307
49846
|
--config <dir> neko.config.json \u67E5\u627E\u8D77\u59CB\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09
|
|
49308
49847
|
-h, --help \u663E\u793A\u6B64\u5E2E\u52A9
|
|
49309
49848
|
|
|
49310
|
-
\u53EF\u901A\u8FC7\u524D\u7AEF\u8BBE\u7F6E\u6216
|
|
49311
|
-
\
|
|
49849
|
+
\u53EF\u901A\u8FC7\u524D\u7AEF\u8BBE\u7F6E\u6216\u73AF\u5883\u53D8\u91CF\uFF08DEEPSEEK_API_KEY / OPENROUTER_API_KEY / OPENCODE_API_KEY / TAVILY_API_KEY \u7B49\uFF09\u914D\u7F6E\u51ED\u636E\uFF1B
|
|
49850
|
+
\u9664 DeepSeek \u5916\u7684\u6A21\u578B provider \u9700\u5148\u5728\u524D\u7AEF\u542F\u7528\uFF0C--model \u6307\u5411\u672A\u542F\u7528\u7684 provider \u65F6\u63D0\u4EA4\u4F1A\u88AB\u62D2\u7EDD\uFF1B
|
|
49851
|
+
\u8054\u7F51\u641C\u7D22\u670D\u52A1\u53EF\u5728\u524D\u7AEF\u8BBE\u7F6E\uFF0C\u6216\u7528\u914D\u7F6E\u6587\u4EF6 webSearch.provider\uFF08tavily / deepseek\uFF0C\u9ED8\u8BA4 tavily\uFF09\uFF1B
|
|
49852
|
+
\u9ED8\u8BA4\u6A21\u578B\u8FD8\u53EF\u5728 TUI /model \u6216 Web \u6A21\u578B\u9009\u62E9\u5668\u4E2D\u300C\u8BBE\u4E3A\u9ED8\u8BA4\u300D\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E --model\u3001\u9AD8\u4E8E\u914D\u7F6E\u6587\u4EF6 defaultModel\u3002`;
|
|
49312
49853
|
|
|
49313
49854
|
// packages/gateway/src/main.ts
|
|
49314
49855
|
var argv, shutdown2, options, gateway;
|
|
@@ -49352,8 +49893,10 @@ var USAGE3 = `\u7528\u6CD5: neko <\u547D\u4EE4> [\u9009\u9879]
|
|
|
49352
49893
|
-h, --help \u663E\u793A\u6B64\u5E2E\u52A9
|
|
49353
49894
|
|
|
49354
49895
|
\u5404\u547D\u4EE4\u7684\u9009\u9879\u8BE6\u89C1 neko <\u547D\u4EE4> --help\u3002
|
|
49355
|
-
\u53EF\u901A\u8FC7 TUI /login\u3001Web \u8BBE\u7F6E\u9875\u6216
|
|
49356
|
-
\
|
|
49896
|
+
\u53EF\u901A\u8FC7 TUI /login\u3001Web \u8BBE\u7F6E\u9875\u6216\u73AF\u5883\u53D8\u91CF\uFF08DEEPSEEK_API_KEY / OPENROUTER_API_KEY / OPENCODE_API_KEY / TAVILY_API_KEY \u7B49\uFF09\u914D\u7F6E\u51ED\u636E\uFF1B
|
|
49897
|
+
\u9664 DeepSeek \u5916\u7684\u6A21\u578B provider\uFF08\u5982 OpenRouter\u3001OpenCode Go\uFF09\u9700\u5148\u5728 /login \u6216 Web \u8BBE\u7F6E\u9875\u300C\u6A21\u578B\u670D\u52A1\u300D\u542F\u7528\uFF0C--model \u683C\u5F0F\u4E3A provider/modelId\u3002
|
|
49898
|
+
\u8054\u7F51\u641C\u7D22\u670D\u52A1\uFF08\u9ED8\u8BA4 Tavily\uFF0C\u53EF\u6539\u9009 DeepSeek\uFF09\u53EF\u7528 TUI /search\u3001Web \u8BBE\u7F6E\u9875\u300C\u8054\u7F51\u641C\u7D22\u300D\u6216\u914D\u7F6E\u6587\u4EF6 webSearch.provider \u9009\u62E9\u3002
|
|
49899
|
+
\u9ED8\u8BA4\u6A21\u578B\u53EF\u5728 TUI /model \u6216 Web \u6A21\u578B\u9009\u62E9\u5668\u300C\u8BBE\u4E3A\u9ED8\u8BA4\u300D\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E --model\u3001\u9AD8\u4E8E\u914D\u7F6E\u6587\u4EF6 defaultModel\u3002`;
|
|
49357
49900
|
var [command2, ...rest] = process.argv.slice(2);
|
|
49358
49901
|
switch (command2) {
|
|
49359
49902
|
case "update": {
|