engine7 7.1.54 → 7.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1831,9 +1831,14 @@ async function ask(rl, question, defaultValue) {
1831
1831
  });
1832
1832
  });
1833
1833
  }
1834
- async function askChoice(rl, question, choices, defaultIdx = 0) {
1834
+ async function askChoice(rl, question, choices, defaultIdx = 0, current) {
1835
+ let currentIdx = -1;
1836
+ if (current) {
1837
+ currentIdx = choices.findIndex((c) => c === current || c.split(" ")[0] === current || current.startsWith(c.split(" ")[0]));
1838
+ }
1839
+ if (currentIdx >= 0) defaultIdx = currentIdx;
1835
1840
  console.log(question);
1836
- choices.forEach((c, i) => console.log(` ${i + 1}. ${c}`));
1841
+ choices.forEach((c, i) => console.log(` ${i + 1}. ${c}${i === currentIdx ? " \u2190\uFF08\u4E0A\u6B21\u5DF2\u9009\uFF09" : ""}`));
1837
1842
  const answer = await ask(rl, `\u9009\u62E9 (1-${choices.length})`, String(defaultIdx + 1));
1838
1843
  const idx = parseInt(answer, 10) - 1;
1839
1844
  return choices[idx >= 0 && idx < choices.length ? idx : defaultIdx];
@@ -1861,6 +1866,7 @@ function getDefaultValues(stateDir) {
1861
1866
  customBaseUrl: existing.customBaseUrl || "",
1862
1867
  customModelId: existing.customModelId || "",
1863
1868
  customApi: existing.customApi || "anthropic",
1869
+ customProviderId: existing.customProviderId || "",
1864
1870
  tavilyKey: existing.tavilyKey || "",
1865
1871
  apiPort: existing.apiPort || 16990
1866
1872
  };
@@ -1875,7 +1881,13 @@ function loadExistingValues(stateDir) {
1875
1881
  const providers = j.models?.providers || {};
1876
1882
  const firstId = Object.keys(providers)[0];
1877
1883
  if (firstId) {
1878
- out.primaryProvider = firstId;
1884
+ const builtin = ["dashscope", "minimax", "zhipu", "deepseek"];
1885
+ if (builtin.includes(firstId)) {
1886
+ out.primaryProvider = firstId;
1887
+ } else {
1888
+ out.primaryProvider = "custom";
1889
+ out.customProviderId = firstId;
1890
+ }
1879
1891
  const p = providers[firstId];
1880
1892
  const keyRef = typeof p?.apiKey === "string" ? p.apiKey : "";
1881
1893
  if (keyRef.startsWith("env:")) {
@@ -1950,22 +1962,21 @@ async function interactiveConfig(rl, defaults) {
1950
1962
  "deepseek (DeepSeek)": "deepseek",
1951
1963
  "custom (\u81EA\u5B9A\u4E49/\u5176\u4ED6 Anthropic \u517C\u5BB9\u7AEF\u70B9)": "custom"
1952
1964
  };
1953
- const chosenProvider = await askChoice(rl, "\u4E3B\u6A21\u578B Provider:", providers, 0);
1965
+ const chosenProvider = await askChoice(rl, "\u4E3B\u6A21\u578B Provider:", providers, 0, defaults.primaryProvider);
1954
1966
  v.primaryProvider = providerMap[chosenProvider] || "dashscope";
1955
1967
  v.zhipuPlan = "";
1956
1968
  if (v.primaryProvider === "zhipu") {
1957
1969
  const planOptions = ["coding-plan (GLM Coding \u8BA2\u9605\uFF0C\u5305\u6708)", "api-pay (API \u6309\u91CF\u4ED8\u8D39)"];
1958
- const chosenPlan = await askChoice(rl, "\u667A\u8C31\u8BA2\u9605\u7C7B\u578B:", planOptions, 0);
1970
+ const chosenPlan = await askChoice(rl, "\u667A\u8C31\u8BA2\u9605\u7C7B\u578B:", planOptions, 0, defaults.zhipuPlan === "token" ? "api-pay" : defaults.zhipuPlan === "coding" ? "coding-plan" : void 0);
1959
1971
  v.zhipuPlan = chosenPlan.startsWith("coding") ? "coding" : "token";
1960
1972
  }
1961
1973
  v.customBaseUrl = "";
1962
1974
  v.customModelId = "";
1963
1975
  v.customApi = "anthropic";
1964
1976
  if (v.primaryProvider === "custom") {
1965
- const isKnownCustom = defaults.primaryProvider !== "dashscope" && defaults.primaryProvider !== "minimax" && defaults.primaryProvider !== "zhipu" && defaults.primaryProvider !== "deepseek";
1966
- v.primaryProvider = await ask(rl, "Provider ID\uFF08\u5C0F\u5199\u5B57\u6BCD\uFF0C\u5982 kimi / moonshot / openrouter / zai\uFF09", isKnownCustom ? defaults.primaryProvider : "custom");
1977
+ v.primaryProvider = await ask(rl, "Provider ID\uFF08\u5C0F\u5199\u5B57\u6BCD\uFF0C\u5982 kimi / moonshot / openrouter / zai\uFF09", defaults.customProviderId || "custom");
1967
1978
  const apiOptions = ["anthropic (Anthropic \u517C\u5BB9\uFF0C\u63A8\u8350)", "openai-completions (OpenAI \u517C\u5BB9 /v1/chat/completions)"];
1968
- const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0);
1979
+ const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0, defaults.customApi || void 0);
1969
1980
  v.customApi = chosenApi.startsWith("anthropic") ? "anthropic" : "openai-completions";
1970
1981
  const baseUrlExample = v.customApi === "anthropic" ? "\uFF08\u5982 https://api.moonshot.cn/anthropic\uFF09" : "\uFF08\u5982 https://api.deepinfra.com/v1/openai\uFF09";
1971
1982
  v.customBaseUrl = await ask(rl, `baseUrl ${baseUrlExample}`, defaults.customBaseUrl || "");
@@ -1999,7 +2010,7 @@ async function interactiveConfig(rl, defaults) {
1999
2010
  v.primaryModel = v.primaryProvider + "/" + v.customModelId;
2000
2011
  } else if (modelMap[v.primaryProvider]) {
2001
2012
  const models = modelMap[v.primaryProvider];
2002
- v.primaryModel = await askChoice(rl, "\u4E3B\u6A21\u578B:", models, 0);
2013
+ v.primaryModel = await askChoice(rl, "\u4E3B\u6A21\u578B:", models, 0, defaults.primaryModel || void 0);
2003
2014
  } else {
2004
2015
  console.log("\u26A0\uFE0F \u8FD8\u7F3A\u6A21\u578B ID\uFF0C\u8865\u4E00\u4E0B\uFF1A");
2005
2016
  v.customModelId = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 glm-5.3 / kimi-k2-turbo-preview\uFF09");
@@ -13167,7 +13167,7 @@ var AnthropicProvider = class {
13167
13167
  this.config = config;
13168
13168
  let u = (config.baseUrl || "https://api.anthropic.com").trim();
13169
13169
  while (u.endsWith("/")) u = u.slice(0, -1);
13170
- this.baseUrl = u + "/";
13170
+ this.baseUrl = u;
13171
13171
  this.sessionId = randomUUID3();
13172
13172
  }
13173
13173
  config;
package/dist/main.mjs CHANGED
@@ -13541,7 +13541,7 @@ var AnthropicProvider = class {
13541
13541
  this.config = config2;
13542
13542
  let u = (config2.baseUrl || "https://api.anthropic.com").trim();
13543
13543
  while (u.endsWith("/")) u = u.slice(0, -1);
13544
- this.baseUrl = u + "/";
13544
+ this.baseUrl = u;
13545
13545
  this.sessionId = randomUUID3();
13546
13546
  }
13547
13547
  config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.54",
3
+ "version": "7.1.56",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — 给助手一个家 / A home for your AI assistant",
6
6
  "main": "dist/main.mjs",