engine7 7.1.52 → 7.1.54
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 +228 -103
- package/dist/engine-startup.mjs +9 -1
- package/dist/main.mjs +9 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1839,31 +1839,105 @@ async function askChoice(rl, question, choices, defaultIdx = 0) {
|
|
|
1839
1839
|
return choices[idx >= 0 && idx < choices.length ? idx : defaultIdx];
|
|
1840
1840
|
}
|
|
1841
1841
|
function getDefaultValues(stateDir) {
|
|
1842
|
+
const existing = loadExistingValues(stateDir);
|
|
1842
1843
|
return {
|
|
1843
1844
|
stateDir,
|
|
1844
|
-
agentName: "Agent",
|
|
1845
|
-
primaryProvider: "dashscope",
|
|
1846
|
-
zhipuPlan: "",
|
|
1847
|
-
primaryApiKey: "",
|
|
1848
|
-
primaryModel: "dashscope/qwen3.7-max",
|
|
1849
|
-
visionModel: "dashscope/qwen3.7-max",
|
|
1850
|
-
discordEnabled: false,
|
|
1851
|
-
discordToken: "",
|
|
1852
|
-
discordUserId: "",
|
|
1853
|
-
feishuEnabled: false,
|
|
1854
|
-
feishuAppId: "",
|
|
1855
|
-
feishuAppSecret: "",
|
|
1856
|
-
feishuOpenId: "",
|
|
1857
|
-
wechatEnabled: false,
|
|
1858
|
-
wechatToken: "",
|
|
1859
|
-
wechatAccountId: "",
|
|
1860
|
-
customBaseUrl: "",
|
|
1861
|
-
customModelId: "",
|
|
1862
|
-
customApi: "anthropic",
|
|
1863
|
-
tavilyKey: "",
|
|
1864
|
-
apiPort: 16990
|
|
1845
|
+
agentName: existing.agentName || "Agent",
|
|
1846
|
+
primaryProvider: existing.primaryProvider || "dashscope",
|
|
1847
|
+
zhipuPlan: existing.zhipuPlan || "",
|
|
1848
|
+
primaryApiKey: existing.primaryApiKey || "",
|
|
1849
|
+
primaryModel: existing.primaryModel || "dashscope/qwen3.7-max",
|
|
1850
|
+
visionModel: existing.visionModel || "dashscope/qwen3.7-max",
|
|
1851
|
+
discordEnabled: existing.discordEnabled ?? false,
|
|
1852
|
+
discordToken: existing.discordToken || "",
|
|
1853
|
+
discordUserId: existing.discordUserId || "",
|
|
1854
|
+
feishuEnabled: existing.feishuEnabled ?? false,
|
|
1855
|
+
feishuAppId: existing.feishuAppId || "",
|
|
1856
|
+
feishuAppSecret: existing.feishuAppSecret || "",
|
|
1857
|
+
feishuOpenId: existing.feishuOpenId || "",
|
|
1858
|
+
wechatEnabled: existing.wechatEnabled ?? false,
|
|
1859
|
+
wechatToken: existing.wechatToken || "",
|
|
1860
|
+
wechatAccountId: existing.wechatAccountId || "",
|
|
1861
|
+
customBaseUrl: existing.customBaseUrl || "",
|
|
1862
|
+
customModelId: existing.customModelId || "",
|
|
1863
|
+
customApi: existing.customApi || "anthropic",
|
|
1864
|
+
tavilyKey: existing.tavilyKey || "",
|
|
1865
|
+
apiPort: existing.apiPort || 16990
|
|
1865
1866
|
};
|
|
1866
1867
|
}
|
|
1868
|
+
function loadExistingValues(stateDir) {
|
|
1869
|
+
const configPath = path3.join(stateDir, "configs", "main7.json");
|
|
1870
|
+
try {
|
|
1871
|
+
if (!fs3.existsSync(configPath)) return {};
|
|
1872
|
+
const j = JSON.parse(fs3.readFileSync(configPath, "utf8"));
|
|
1873
|
+
const out = {};
|
|
1874
|
+
if (j.agents?.defaults?.name) out.agentName = j.agents.defaults.name;
|
|
1875
|
+
const providers = j.models?.providers || {};
|
|
1876
|
+
const firstId = Object.keys(providers)[0];
|
|
1877
|
+
if (firstId) {
|
|
1878
|
+
out.primaryProvider = firstId;
|
|
1879
|
+
const p = providers[firstId];
|
|
1880
|
+
const keyRef = typeof p?.apiKey === "string" ? p.apiKey : "";
|
|
1881
|
+
if (keyRef.startsWith("env:")) {
|
|
1882
|
+
const envName = keyRef.slice(4);
|
|
1883
|
+
out.primaryApiKey = readSecretsValue(stateDir, envName) || "";
|
|
1884
|
+
} else if (keyRef && !keyRef.startsWith("env:")) {
|
|
1885
|
+
out.primaryApiKey = keyRef;
|
|
1886
|
+
}
|
|
1887
|
+
if (p?.baseUrl && !["dashscope", "minimax", "zhipu", "deepseek"].includes(firstId)) {
|
|
1888
|
+
out.customBaseUrl = p.baseUrl;
|
|
1889
|
+
out.customApi = p.api || "anthropic";
|
|
1890
|
+
}
|
|
1891
|
+
const firstModel = p?.models?.[0]?.id;
|
|
1892
|
+
if (firstModel) {
|
|
1893
|
+
out.primaryModel = `${firstId}/${firstModel}`;
|
|
1894
|
+
out.customModelId = ["dashscope", "minimax", "zhipu", "deepseek"].includes(firstId) ? "" : firstModel;
|
|
1895
|
+
}
|
|
1896
|
+
if (j.agents?.defaults?.model?.vision) out.visionModel = j.agents.defaults.model.vision;
|
|
1897
|
+
}
|
|
1898
|
+
if (j.channels?.discord) {
|
|
1899
|
+
out.discordEnabled = !!j.channels.discord.enabled;
|
|
1900
|
+
out.discordToken = j.channels.discord.accounts?.default?.token || "";
|
|
1901
|
+
}
|
|
1902
|
+
if (j.channels?.feishu) {
|
|
1903
|
+
out.feishuEnabled = !!j.channels.feishu.enabled;
|
|
1904
|
+
out.feishuAppId = j.channels.feishu.appId || "";
|
|
1905
|
+
out.feishuAppSecret = j.channels.feishu.appSecret || "";
|
|
1906
|
+
}
|
|
1907
|
+
if (j.channels?.wechat) {
|
|
1908
|
+
out.wechatEnabled = !!j.channels.wechat.enabled;
|
|
1909
|
+
out.wechatToken = j.channels.wechat.token || "";
|
|
1910
|
+
out.wechatAccountId = j.channels.wechat.accountId || "";
|
|
1911
|
+
}
|
|
1912
|
+
if (j.tools?.tavily?.apiKey) out.tavilyKey = j.tools.tavily.apiKey;
|
|
1913
|
+
if (j.api?.port) out.apiPort = j.api.port;
|
|
1914
|
+
return out;
|
|
1915
|
+
} catch {
|
|
1916
|
+
return {};
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function readSecretsValue(stateDir, envName) {
|
|
1920
|
+
try {
|
|
1921
|
+
const secretsDir = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7-secrets");
|
|
1922
|
+
const cfgBase = path3.basename(stateDir) === ".engine7" ? "main7" : path3.basename(stateDir);
|
|
1923
|
+
const candidates = [
|
|
1924
|
+
path3.join(secretsDir, `${cfgBase}.env`),
|
|
1925
|
+
path3.join(stateDir, "configs", `.env.${cfgBase}`)
|
|
1926
|
+
];
|
|
1927
|
+
for (const p of candidates) {
|
|
1928
|
+
if (fs3.existsSync(p)) {
|
|
1929
|
+
for (const line of fs3.readFileSync(p, "utf8").split("\n")) {
|
|
1930
|
+
const eq = line.indexOf("=");
|
|
1931
|
+
if (eq > 0 && line.slice(0, eq).trim() === envName) {
|
|
1932
|
+
return line.slice(eq + 1).trim();
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
} catch {
|
|
1938
|
+
}
|
|
1939
|
+
return "";
|
|
1940
|
+
}
|
|
1867
1941
|
async function interactiveConfig(rl, defaults) {
|
|
1868
1942
|
const v = { ...defaults };
|
|
1869
1943
|
console.log("\n=== \u7B2C\u4E00\u6B65\uFF1A\u5FC5\u586B\u914D\u7F6E ===\n");
|
|
@@ -1888,13 +1962,23 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1888
1962
|
v.customModelId = "";
|
|
1889
1963
|
v.customApi = "anthropic";
|
|
1890
1964
|
if (v.primaryProvider === "custom") {
|
|
1891
|
-
|
|
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");
|
|
1892
1967
|
const apiOptions = ["anthropic (Anthropic \u517C\u5BB9\uFF0C\u63A8\u8350)", "openai-completions (OpenAI \u517C\u5BB9 /v1/chat/completions)"];
|
|
1893
1968
|
const chosenApi = await askChoice(rl, "API \u7C7B\u578B:", apiOptions, 0);
|
|
1894
1969
|
v.customApi = chosenApi.startsWith("anthropic") ? "anthropic" : "openai-completions";
|
|
1895
1970
|
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,
|
|
1897
|
-
v.
|
|
1971
|
+
v.customBaseUrl = await ask(rl, `baseUrl ${baseUrlExample}`, defaults.customBaseUrl || "");
|
|
1972
|
+
while (v.customBaseUrl) {
|
|
1973
|
+
try {
|
|
1974
|
+
new URL(v.customBaseUrl);
|
|
1975
|
+
break;
|
|
1976
|
+
} catch {
|
|
1977
|
+
console.log(`\u26A0\uFE0F \u65E0\u6548 URL\uFF1A\u300C${v.customBaseUrl}\u300D\u2014\u2014\u68C0\u67E5\u62FC\u5199\u3001\u534F\u8BAE\u5934\uFF08https://\uFF09\u3001\u6709\u6CA1\u6709\u591A\u4F59\u7A7A\u683C\u6216\u659C\u6760`);
|
|
1978
|
+
v.customBaseUrl = await ask(rl, `baseUrl ${baseUrlExample}`, "");
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
v.customModelId = await ask(rl, "\u6A21\u578B ID\uFF08\u5982 kimi-k2-turbo-preview\uFF09", defaults.customModelId || "");
|
|
1898
1982
|
}
|
|
1899
1983
|
const keyMap = {
|
|
1900
1984
|
dashscope: "DashScope API Key",
|
|
@@ -1902,7 +1986,9 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1902
1986
|
zhipu: "\u667A\u8C31 API Key",
|
|
1903
1987
|
deepseek: "DeepSeek API Key"
|
|
1904
1988
|
};
|
|
1905
|
-
|
|
1989
|
+
const existingKeyHint = defaults.primaryApiKey ? `(\u5F53\u524D: ${defaults.primaryApiKey.slice(0, 8)}...${defaults.primaryApiKey.slice(-4)}\uFF0C\u56DE\u8F66\u4FDD\u7559)` : "";
|
|
1990
|
+
const keyAns = await ask(rl, `${keyMap[v.primaryProvider] || v.primaryProvider + " API Key"} ${existingKeyHint}`, defaults.primaryApiKey || "");
|
|
1991
|
+
v.primaryApiKey = keyAns || defaults.primaryApiKey || "";
|
|
1906
1992
|
const modelMap = {
|
|
1907
1993
|
dashscope: ["dashscope/qwen3.7-max", "dashscope/qwen3.7-plus"],
|
|
1908
1994
|
minimax: ["minimax/MiniMax-M3", "minimax/MiniMax-M2.7"],
|
|
@@ -1939,101 +2025,132 @@ async function interactiveConfig(rl, defaults) {
|
|
|
1939
2025
|
console.log(` \u6CE8\u610F\uFF1AVision \u6A21\u578B\u7528\u4E86\u4E0D\u540C provider\uFF0C\u9700\u8981\u5728 config \u91CC\u8865\u5145\u5BF9\u5E94\u7684 API key`);
|
|
1940
2026
|
}
|
|
1941
2027
|
}
|
|
1942
|
-
console.log("\n=== \u7B2C\u4E8C\u6B65\uFF1A\u53EF\u9009\u914D\u7F6E\uFF08\u56DE\u8F66\u8DF3\u8FC7\uFF09===\n");
|
|
1943
|
-
const discordAns = await ask(rl, "\u542F\u7528 Discord? (y/n)", "n");
|
|
2028
|
+
console.log("\n=== \u7B2C\u4E8C\u6B65\uFF1A\u53EF\u9009\u914D\u7F6E\uFF08\u56DE\u8F66\u8DF3\u8FC7\uFF0C\u5DF2\u542F\u7528\u7684\u56DE\u8F66\u4FDD\u7559\uFF09===\n");
|
|
2029
|
+
const discordAns = await ask(rl, "\u542F\u7528 Discord? (y/n)", defaults.discordEnabled ? "y" : "n");
|
|
1944
2030
|
v.discordEnabled = discordAns.toLowerCase() === "y";
|
|
1945
2031
|
if (v.discordEnabled) {
|
|
1946
|
-
v.discordToken = await ask(rl,
|
|
1947
|
-
v.discordUserId = await ask(rl, "\u4F60\u7684 Discord User ID");
|
|
2032
|
+
v.discordToken = await ask(rl, `Discord Bot Token${defaults.discordToken ? ` (\u5F53\u524D: ${defaults.discordToken.slice(0, 12)}...\uFF0C\u56DE\u8F66\u4FDD\u7559)` : ""}`, defaults.discordToken || "");
|
|
2033
|
+
v.discordUserId = await ask(rl, "\u4F60\u7684 Discord User ID", defaults.discordUserId || "");
|
|
1948
2034
|
}
|
|
1949
|
-
const feishuAns = await ask(rl, "\u542F\u7528\u98DE\u4E66? (y/n)", "n");
|
|
2035
|
+
const feishuAns = await ask(rl, "\u542F\u7528\u98DE\u4E66? (y/n)", defaults.feishuEnabled ? "y" : "n");
|
|
1950
2036
|
v.feishuEnabled = feishuAns.toLowerCase() === "y";
|
|
1951
2037
|
if (v.feishuEnabled) {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2038
|
+
if (defaults.feishuAppId && defaults.feishuAppSecret) {
|
|
2039
|
+
console.log(`
|
|
2040
|
+
\u5F53\u524D\u5DF2\u914D\u7F6E\u98DE\u4E66: App ID ${defaults.feishuAppId}`);
|
|
2041
|
+
const keep = await ask(rl, "\u4FDD\u7559\u73B0\u6709\u98DE\u4E66\u914D\u7F6E? (y=\u4FDD\u7559\u56DE\u8F66\u9ED8\u8BA4/n=\u91CD\u65B0\u626B\u7801)", "y");
|
|
2042
|
+
if (keep.toLowerCase() !== "n") {
|
|
2043
|
+
v.feishuAppId = defaults.feishuAppId;
|
|
2044
|
+
v.feishuAppSecret = defaults.feishuAppSecret;
|
|
2045
|
+
v.feishuOpenId = defaults.feishuOpenId || "";
|
|
2046
|
+
console.log(" \u2705 \u4FDD\u7559\u73B0\u6709\u98DE\u4E66\u914D\u7F6E");
|
|
2047
|
+
} else {
|
|
2048
|
+
await configureFeishu(rl, v);
|
|
2049
|
+
}
|
|
2050
|
+
} else {
|
|
2051
|
+
await configureFeishu(rl, v);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
const wechatAns = await ask(rl, "\u542F\u7528\u5FAE\u4FE1? (y/n)", defaults.wechatEnabled ? "y" : "n");
|
|
2055
|
+
v.wechatEnabled = wechatAns.toLowerCase() === "y";
|
|
2056
|
+
if (v.wechatEnabled) {
|
|
2057
|
+
if (defaults.wechatToken && defaults.wechatAccountId) {
|
|
2058
|
+
console.log(`
|
|
2059
|
+
\u5F53\u524D\u5DF2\u914D\u7F6E\u5FAE\u4FE1: ${defaults.wechatAccountId}`);
|
|
2060
|
+
const keep = await ask(rl, "\u4FDD\u7559\u73B0\u6709\u5FAE\u4FE1\u914D\u7F6E? (y=\u4FDD\u7559/n=\u91CD\u65B0\u626B\u7801)", "y");
|
|
2061
|
+
if (keep.toLowerCase() !== "n") {
|
|
2062
|
+
v.wechatToken = defaults.wechatToken;
|
|
2063
|
+
v.wechatAccountId = defaults.wechatAccountId;
|
|
2064
|
+
console.log(" \u2705 \u4FDD\u7559\u73B0\u6709\u5FAE\u4FE1\u914D\u7F6E");
|
|
2065
|
+
} else {
|
|
2066
|
+
await configureWechat(rl, v);
|
|
2067
|
+
}
|
|
2068
|
+
} else {
|
|
2069
|
+
await configureWechat(rl, v);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
const tavilyKey = await ask(rl, `Tavily API Key\uFF08\u8054\u7F51\u641C\u7D22${defaults.tavilyKey ? `\uFF0C\u5F53\u524D: ${defaults.tavilyKey.slice(0, 8)}...\uFF0C\u56DE\u8F66\u4FDD\u7559` : "\uFF0C\u56DE\u8F66\u8DF3\u8FC7"}\uFF09`, defaults.tavilyKey || "");
|
|
2073
|
+
v.tavilyKey = tavilyKey;
|
|
2074
|
+
const portAns = await ask(rl, "API \u7AEF\u53E3", String(defaults.apiPort));
|
|
2075
|
+
v.apiPort = parseInt(portAns, 10) || defaults.apiPort;
|
|
2076
|
+
return v;
|
|
2077
|
+
}
|
|
2078
|
+
async function configureFeishu(rl, v) {
|
|
2079
|
+
console.log("\n \u98DE\u4E66\u914D\u7F6E\u65B9\u5F0F\uFF1A");
|
|
2080
|
+
console.log(" 1. \u626B\u7801\u81EA\u52A8\u521B\u5EFA\uFF08\u63A8\u8350\uFF0C30\u79D2\u641E\u5B9A\uFF09");
|
|
2081
|
+
console.log(" 2. \u624B\u52A8\u8F93\u5165 App ID / App Secret");
|
|
2082
|
+
const feishuMode = await ask(rl, "\u9009\u62E9 (1/2)", "1");
|
|
2083
|
+
if (feishuMode === "1") {
|
|
2084
|
+
console.log("\n\u{1F4DD} \u6B63\u5728\u751F\u6210\u98DE\u4E66\u4E8C\u7EF4\u7801...\n");
|
|
2085
|
+
const result = await registerFeishuApp({
|
|
2086
|
+
onLog: (msg) => console.log(` ${msg}`),
|
|
2087
|
+
onQrCode: async (url) => {
|
|
2088
|
+
try {
|
|
2089
|
+
const qr = await renderQrTerminal(url, { small: true });
|
|
2090
|
+
console.log(qr);
|
|
2091
|
+
} catch {
|
|
2092
|
+
console.log(`
|
|
1966
2093
|
\u8BF7\u5728\u624B\u673A\u6D4F\u89C8\u5668\u6253\u5F00\u6B64\u94FE\u63A5\u626B\u7801\uFF1A
|
|
1967
2094
|
${url}
|
|
1968
2095
|
`);
|
|
1969
|
-
}
|
|
1970
2096
|
}
|
|
1971
|
-
});
|
|
1972
|
-
if (result) {
|
|
1973
|
-
v.feishuAppId = result.appId;
|
|
1974
|
-
v.feishuAppSecret = result.appSecret;
|
|
1975
|
-
v.feishuOpenId = result.openId || "";
|
|
1976
|
-
console.log(`
|
|
1977
|
-
\u2705 App ID: ${result.appId}`);
|
|
1978
|
-
console.log(` \u2705 App Secret: ${result.appSecret.slice(0, 6)}...`);
|
|
1979
|
-
if (result.openId) {
|
|
1980
|
-
console.log(` \u2705 Open ID: ${result.openId}`);
|
|
1981
|
-
}
|
|
1982
|
-
} else {
|
|
1983
|
-
console.log("\n \u26A0\uFE0F \u626B\u7801\u8D85\u65F6\u6216\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165");
|
|
1984
|
-
v.feishuAppId = await ask(rl, "\u98DE\u4E66 App ID");
|
|
1985
|
-
v.feishuAppSecret = await ask(rl, "\u98DE\u4E66 App Secret");
|
|
1986
|
-
v.feishuOpenId = await ask(rl, "\u4F60\u7684\u98DE\u4E66 open_id\uFF08\u56DE\u8F66\u8DF3\u8FC7\uFF09", "");
|
|
1987
2097
|
}
|
|
2098
|
+
});
|
|
2099
|
+
if (result) {
|
|
2100
|
+
v.feishuAppId = result.appId;
|
|
2101
|
+
v.feishuAppSecret = result.appSecret;
|
|
2102
|
+
v.feishuOpenId = result.openId || "";
|
|
2103
|
+
console.log(`
|
|
2104
|
+
\u2705 App ID: ${result.appId}`);
|
|
2105
|
+
console.log(` \u2705 App Secret: ${result.appSecret.slice(0, 6)}...`);
|
|
2106
|
+
if (result.openId) console.log(` \u2705 Open ID: ${result.openId}`);
|
|
1988
2107
|
} else {
|
|
2108
|
+
console.log("\n \u26A0\uFE0F \u626B\u7801\u8D85\u65F6\u6216\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165");
|
|
1989
2109
|
v.feishuAppId = await ask(rl, "\u98DE\u4E66 App ID");
|
|
1990
2110
|
v.feishuAppSecret = await ask(rl, "\u98DE\u4E66 App Secret");
|
|
1991
2111
|
v.feishuOpenId = await ask(rl, "\u4F60\u7684\u98DE\u4E66 open_id\uFF08\u56DE\u8F66\u8DF3\u8FC7\uFF09", "");
|
|
1992
2112
|
}
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2113
|
+
} else {
|
|
2114
|
+
v.feishuAppId = await ask(rl, "\u98DE\u4E66 App ID");
|
|
2115
|
+
v.feishuAppSecret = await ask(rl, "\u98DE\u4E66 App Secret");
|
|
2116
|
+
v.feishuOpenId = await ask(rl, "\u4F60\u7684\u98DE\u4E66 open_id\uFF08\u56DE\u8F66\u8DF3\u8FC7\uFF09", "");
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
async function configureWechat(rl, v) {
|
|
2120
|
+
console.log("\n \u5FAE\u4FE1\u63A5\u5165\u65B9\u5F0F\uFF1A");
|
|
2121
|
+
console.log(" 1. \u626B\u7801\u7ED1\u5B9A\uFF08\u63A8\u8350\uFF0C\u7528\u4F60\u81EA\u5DF1\u7684\u5FAE\u4FE1\u626B\u4E00\u4E0B\u5C31\u884C\uFF09");
|
|
2122
|
+
console.log(" 2. \u624B\u52A8\u8F93\u5165 token\uFF08\u5DF2\u6709\u51ED\u8BC1\u65F6\uFF09");
|
|
2123
|
+
const wechatMode = await ask(rl, "\u9009\u62E9 (1/2)", "1");
|
|
2124
|
+
if (wechatMode === "1") {
|
|
2125
|
+
console.log("\n\u{1F4DD} \u6B63\u5728\u751F\u6210\u5FAE\u4FE1\u4E8C\u7EF4\u7801...\n");
|
|
2126
|
+
console.log(" \u63D0\u793A\uFF1A\u4E00\u4E2A\u5FAE\u4FE1\u53F7\u53EA\u80FD\u7ED1\u4E00\u4E2A bot\uFF1Bbot \u4E0D\u8FDB\u7FA4\uFF08\u817E\u8BAF\u9650\u5236\uFF09\uFF0C\u79C1\u804A 1v1");
|
|
2127
|
+
const cred = await wechatQrLogin({ timeoutSeconds: 300, stateDir: v.stateDir });
|
|
2128
|
+
if (cred) {
|
|
2129
|
+
v.wechatToken = cred.token;
|
|
2130
|
+
v.wechatAccountId = cred.accountId;
|
|
2131
|
+
console.log(`
|
|
2009
2132
|
\u2705 accountId: ${cred.accountId}`);
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
} else {
|
|
2020
|
-
console.log("\n \u26A0\uFE0F \u518D\u6B21\u5931\u8D25\uFF0C\u8DF3\u8FC7\u5FAE\u4FE1\uFF08\u4E4B\u540E\u53EF\u624B\u52A8\u914D\u7F6E\uFF09");
|
|
2021
|
-
v.wechatEnabled = false;
|
|
2022
|
-
}
|
|
2133
|
+
console.log(` \u2705 \u51ED\u8BC1\u5DF2\u81EA\u52A8\u4FDD\u5B58\uFF0Cconfig \u5C06\u81EA\u52A8\u5199\u5165`);
|
|
2134
|
+
} else {
|
|
2135
|
+
console.log("\n \u26A0\uFE0F \u626B\u7801\u8D85\u65F6\u6216\u5931\u8D25");
|
|
2136
|
+
const retry = await ask(rl, "\u91CD\u8BD5\u626B\u7801? (y/n)", "y");
|
|
2137
|
+
if (retry.toLowerCase() === "y") {
|
|
2138
|
+
const cred2 = await wechatQrLogin({ timeoutSeconds: 300, stateDir: v.stateDir });
|
|
2139
|
+
if (cred2) {
|
|
2140
|
+
v.wechatToken = cred2.token;
|
|
2141
|
+
v.wechatAccountId = cred2.accountId;
|
|
2023
2142
|
} else {
|
|
2143
|
+
console.log("\n \u26A0\uFE0F \u518D\u6B21\u5931\u8D25\uFF0C\u8DF3\u8FC7\u5FAE\u4FE1\uFF08\u4E4B\u540E\u53EF\u624B\u52A8\u914D\u7F6E\uFF09");
|
|
2024
2144
|
v.wechatEnabled = false;
|
|
2025
2145
|
}
|
|
2146
|
+
} else {
|
|
2147
|
+
v.wechatEnabled = false;
|
|
2026
2148
|
}
|
|
2027
|
-
} else {
|
|
2028
|
-
v.wechatToken = await ask(rl, "\u5FAE\u4FE1 token");
|
|
2029
|
-
v.wechatAccountId = await ask(rl, "\u5FAE\u4FE1 accountId");
|
|
2030
2149
|
}
|
|
2150
|
+
} else {
|
|
2151
|
+
v.wechatToken = await ask(rl, "\u5FAE\u4FE1 token");
|
|
2152
|
+
v.wechatAccountId = await ask(rl, "\u5FAE\u4FE1 accountId");
|
|
2031
2153
|
}
|
|
2032
|
-
const tavilyKey = await ask(rl, "Tavily API Key\uFF08\u8054\u7F51\u641C\u7D22\uFF0C\u56DE\u8F66\u8DF3\u8FC7\uFF09", "");
|
|
2033
|
-
v.tavilyKey = tavilyKey;
|
|
2034
|
-
const portAns = await ask(rl, "API \u7AEF\u53E3", String(defaults.apiPort));
|
|
2035
|
-
v.apiPort = parseInt(portAns, 10) || defaults.apiPort;
|
|
2036
|
-
return v;
|
|
2037
2154
|
}
|
|
2038
2155
|
function generateConfig(v) {
|
|
2039
2156
|
const workspace = path3.join(v.stateDir, "workspace").replace(/\\/g, "/");
|
|
@@ -2658,7 +2775,8 @@ engine7 start \u2014 \u542F\u52A8 Engine
|
|
|
2658
2775
|
if (eq > 0) {
|
|
2659
2776
|
const k = trimmed.slice(0, eq).trim();
|
|
2660
2777
|
const v = trimmed.slice(eq + 1).trim();
|
|
2661
|
-
|
|
2778
|
+
const cur = envForChild[k];
|
|
2779
|
+
if (k && (cur === void 0 || cur === "")) envForChild[k] = v;
|
|
2662
2780
|
}
|
|
2663
2781
|
}
|
|
2664
2782
|
console.log(`[start] Loaded API keys from ${secretPath}`);
|
|
@@ -3096,11 +3214,18 @@ WantedBy=default.target`;
|
|
|
3096
3214
|
\u26A0\uFE0F --force: \u6E05\u7A7A\u5DF2\u6709\u76EE\u5F55 ${opts.stateDir}`);
|
|
3097
3215
|
fs3.rmSync(opts.stateDir, { recursive: true, force: true });
|
|
3098
3216
|
} else {
|
|
3099
|
-
|
|
3217
|
+
const existingConfig = path3.join(opts.stateDir, "configs", "main7.json");
|
|
3218
|
+
if (fs3.existsSync(existingConfig)) {
|
|
3219
|
+
console.log(`
|
|
3220
|
+
\u267B\uFE0F \u68C0\u6D4B\u5230\u5DF2\u6709\u914D\u7F6E: ${existingConfig}`);
|
|
3221
|
+
console.log(` \u2192 \u590D\u8DD1\u6A21\u5F0F\uFF1A\u663E\u793A\u73B0\u6709\u914D\u7F6E\uFF0C\u56DE\u8F66\u4FDD\u7559\uFF0C\u6539\u4E86\u624D\u751F\u6548\uFF08\u4E0D\u4F1A\u6E05\u7A7A\u76EE\u5F55\uFF09`);
|
|
3222
|
+
} else {
|
|
3223
|
+
console.error(`
|
|
3100
3224
|
\u274C \u76EE\u5F55\u5DF2\u5B58\u5728\u4E14\u975E\u7A7A: ${opts.stateDir}`);
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3225
|
+
console.error(` \u8BF7\u9009\u62E9\u7A7A\u76EE\u5F55\uFF0C\u6216\u7528 --force \u6E05\u7A7A\u540E\u91CD\u65B0\u914D\u7F6E`);
|
|
3226
|
+
console.error(` \u4F8B: engine7 init --force`);
|
|
3227
|
+
process.exit(1);
|
|
3228
|
+
}
|
|
3104
3229
|
}
|
|
3105
3230
|
}
|
|
3106
3231
|
}
|
package/dist/engine-startup.mjs
CHANGED
|
@@ -12755,7 +12755,15 @@ function loadConfig(configPath) {
|
|
|
12755
12755
|
};
|
|
12756
12756
|
}
|
|
12757
12757
|
const agentDefaults = raw.agents?.defaults || {};
|
|
12758
|
-
|
|
12758
|
+
let defaultFallbackModel;
|
|
12759
|
+
if (Object.keys(providers).length > 0) {
|
|
12760
|
+
const firstProviderId = Object.keys(providers)[0];
|
|
12761
|
+
const firstProvider = providers[firstProviderId];
|
|
12762
|
+
if (firstProvider?.models?.length) {
|
|
12763
|
+
defaultFallbackModel = `${firstProviderId}/${firstProvider.models[0].id}`;
|
|
12764
|
+
}
|
|
12765
|
+
}
|
|
12766
|
+
const modelRef = process.env.ENGINE_MODEL || agentDefaults.model?.primary || defaultFallbackModel || Object.keys(providers)[0];
|
|
12759
12767
|
const modelAliases = {};
|
|
12760
12768
|
if (agentDefaults.models) {
|
|
12761
12769
|
for (const [ref, spec] of Object.entries(agentDefaults.models)) {
|
package/dist/main.mjs
CHANGED
|
@@ -12994,7 +12994,15 @@ function loadConfig(configPath2) {
|
|
|
12994
12994
|
};
|
|
12995
12995
|
}
|
|
12996
12996
|
const agentDefaults = raw.agents?.defaults || {};
|
|
12997
|
-
|
|
12997
|
+
let defaultFallbackModel;
|
|
12998
|
+
if (Object.keys(providers).length > 0) {
|
|
12999
|
+
const firstProviderId = Object.keys(providers)[0];
|
|
13000
|
+
const firstProvider = providers[firstProviderId];
|
|
13001
|
+
if (firstProvider?.models?.length) {
|
|
13002
|
+
defaultFallbackModel = `${firstProviderId}/${firstProvider.models[0].id}`;
|
|
13003
|
+
}
|
|
13004
|
+
}
|
|
13005
|
+
const modelRef = process.env.ENGINE_MODEL || agentDefaults.model?.primary || defaultFallbackModel || Object.keys(providers)[0];
|
|
12998
13006
|
const modelAliases = {};
|
|
12999
13007
|
if (agentDefaults.models) {
|
|
13000
13008
|
for (const [ref, spec] of Object.entries(agentDefaults.models)) {
|