engine7 7.1.46 → 7.1.48

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +33 -11
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1859,6 +1859,7 @@ function getDefaultValues(stateDir) {
1859
1859
  wechatAccountId: "",
1860
1860
  customBaseUrl: "",
1861
1861
  customModelId: "",
1862
+ customApi: "anthropic",
1862
1863
  tavilyKey: "",
1863
1864
  apiPort: 16990
1864
1865
  };
@@ -1885,11 +1886,15 @@ async function interactiveConfig(rl, defaults) {
1885
1886
  }
1886
1887
  v.customBaseUrl = "";
1887
1888
  v.customModelId = "";
1889
+ v.customApi = "anthropic";
1888
1890
  if (v.primaryProvider === "custom") {
1889
- v.primaryProvider = await ask(rl, "Provider ID\uFF08\u5C0F\u5199\u5B57\u6BCD\uFF0C\u5982 kimi / moonshot / openrouter\uFF09", "custom");
1890
- v.customBaseUrl = await ask(rl, "Anthropic \u517C\u5BB9 baseUrl\uFF08\u5982 https://api.moonshot.cn/anthropic\uFF09");
1891
- const cm = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 kimi-k2-turbo-preview\uFF09");
1892
- v.customModelId = cm;
1891
+ v.primaryProvider = await ask(rl, "Provider ID\uFF08\u5C0F\u5199\u5B57\u6BCD\uFF0C\u5982 kimi / moonshot / openrouter / zai\uFF09", "custom");
1892
+ const apiOptions = ["anthropic (Anthropic \u517C\u5BB9\uFF0C\u63A8\u8350)", "openai-completions (OpenAI \u517C\u5BB9 /v1/chat/completions)"];
1893
+ const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0);
1894
+ v.customApi = chosenApi.startsWith("anthropic") ? "anthropic" : "openai-completions";
1895
+ const baseUrlExample = v.customApi === "anthropic" ? "\uFF08\u5982 https://api.moonshot.cn/anthropic\uFF09" : "\uFF08\u5982 https://api.deepinfra.com/v1/openai\uFF09";
1896
+ v.customBaseUrl = await ask(rl, "baseUrl " + baseUrlExample);
1897
+ v.customModelId = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 kimi-k2-turbo-preview\uFF09");
1893
1898
  }
1894
1899
  const keyMap = {
1895
1900
  dashscope: "DashScope API Key",
@@ -1898,18 +1903,21 @@ async function interactiveConfig(rl, defaults) {
1898
1903
  deepseek: "DeepSeek API Key"
1899
1904
  };
1900
1905
  v.primaryApiKey = await ask(rl, keyMap[v.primaryProvider] || v.primaryProvider + " API Key");
1901
- if (v.customModelId) {
1902
- v.primaryModel = v.primaryProvider + "/" + v.customModelId;
1903
- }
1904
1906
  const modelMap = {
1905
1907
  dashscope: ["dashscope/qwen3.7-max", "dashscope/qwen3.7-plus"],
1906
1908
  minimax: ["minimax/MiniMax-M3", "minimax/MiniMax-M2.7"],
1907
1909
  zhipu: ["zhipu/glm-5.3", "zhipu/glm-5v-turbo"],
1908
1910
  deepseek: ["deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash"]
1909
1911
  };
1910
- if (!v.customModelId) {
1911
- const models = modelMap[v.primaryProvider] || ["dashscope/qwen3.7-max"];
1912
+ if (v.customModelId) {
1913
+ v.primaryModel = v.primaryProvider + "/" + v.customModelId;
1914
+ } else if (modelMap[v.primaryProvider]) {
1915
+ const models = modelMap[v.primaryProvider];
1912
1916
  v.primaryModel = await askChoice(rl, "\u4E3B\u6A21\u578B:", models, 0);
1917
+ } else {
1918
+ console.log("\u26A0\uFE0F \u8FD8\u7F3A\u6A21\u578B ID\uFF0C\u8865\u4E00\u4E0B\uFF1A");
1919
+ v.customModelId = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 glm-5.3 / kimi-k2-turbo-preview\uFF09");
1920
+ v.primaryModel = v.primaryProvider + "/" + v.customModelId;
1913
1921
  }
1914
1922
  const visionCapableMap = {
1915
1923
  "dashscope/qwen3.7-max": true,
@@ -2156,7 +2164,7 @@ function generateConfig(v) {
2156
2164
  if (!providerDefs[v.primaryProvider] && v.customModelId) {
2157
2165
  config.models.providers[v.primaryProvider] = {
2158
2166
  baseUrl: (v.customBaseUrl || "").trim(),
2159
- api: "anthropic",
2167
+ api: v.customApi,
2160
2168
  apiKey: "env:" + v.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY",
2161
2169
  models: [
2162
2170
  { id: v.customModelId, name: v.customModelId, reasoning: false, input: ["text"], contextWindow: 2e5, maxTokens: 8192 }
@@ -2344,7 +2352,21 @@ async function main() {
2344
2352
  if (args[i] === "--state-dir" && args[i + 1]) stateDir = args[++i].trim();
2345
2353
  else if (args[i] === "--config" && args[i + 1]) configName = args[++i].trim();
2346
2354
  }
2347
- if (!stateDir) stateDir = path3.resolve(process.cwd());
2355
+ if (!stateDir) {
2356
+ const cwd = path3.resolve(process.cwd());
2357
+ if (fs3.existsSync(path3.join(cwd, "configs"))) {
2358
+ stateDir = cwd;
2359
+ } else {
2360
+ const pointer = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7.json");
2361
+ if (fs3.existsSync(pointer)) {
2362
+ try {
2363
+ stateDir = JSON.parse(fs3.readFileSync(pointer, "utf8")).stateDir || "";
2364
+ } catch {
2365
+ }
2366
+ }
2367
+ if (!stateDir) stateDir = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
2368
+ }
2369
+ }
2348
2370
  if (!target && !isLegacyAddchannel) {
2349
2371
  console.log("\u{1F527} engine7 reconfig \u2014 \u91CD\u65B0\u914D\u7F6E\u5DF2\u88C5\u7684 agent");
2350
2372
  console.log(" \u7528\u6CD5: engine7 reconfig <\u76EE\u6807>");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.46",
3
+ "version": "7.1.48",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — 给助手一个家 / A home for your AI assistant",
6
6
  "main": "dist/main.mjs",