engine7 7.1.112 → 7.1.114
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 +76 -42
- package/dist/engine-startup.mjs +667 -207
- package/dist/main.mjs +692 -243
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -1987,17 +1987,33 @@ var init_cli_init_config = __esm({
|
|
|
1987
1987
|
});
|
|
1988
1988
|
|
|
1989
1989
|
// src/config/secrets-env.ts
|
|
1990
|
+
import { createHash } from "node:crypto";
|
|
1990
1991
|
import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1991
|
-
import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
|
|
1992
|
+
import { basename as basename2, dirname as dirname2, join as join3, normalize } from "node:path";
|
|
1992
1993
|
function secretsHome() {
|
|
1993
1994
|
return process.env.HOME || process.env.USERPROFILE || ".";
|
|
1994
1995
|
}
|
|
1996
|
+
function normalizeStateDir(stateDir) {
|
|
1997
|
+
return normalize(stateDir).split("\\").join("/").replace(/\/+$/, "").toLowerCase();
|
|
1998
|
+
}
|
|
1999
|
+
function stateKey(stateDir) {
|
|
2000
|
+
return createHash("sha256").update(normalizeStateDir(stateDir)).digest("hex").slice(0, 8);
|
|
2001
|
+
}
|
|
2002
|
+
function isDefaultStateDir(stateDir) {
|
|
2003
|
+
return normalizeStateDir(stateDir) === normalizeStateDir(join3(secretsHome(), ".engine7"));
|
|
2004
|
+
}
|
|
1995
2005
|
function secretsCandidates(stateDir, configName) {
|
|
1996
|
-
|
|
1997
|
-
|
|
2006
|
+
const shared = join3(secretsHome(), ".engine7-secrets", `${configName}.env`);
|
|
2007
|
+
const inState = [
|
|
1998
2008
|
join3(stateDir, "configs", `.env.${configName}`),
|
|
1999
2009
|
join3(stateDir, "configs", ".env")
|
|
2000
2010
|
];
|
|
2011
|
+
if (isDefaultStateDir(stateDir)) return [shared, ...inState];
|
|
2012
|
+
return [
|
|
2013
|
+
join3(secretsHome(), ".engine7-secrets", `${configName}-${stateKey(stateDir)}.env`),
|
|
2014
|
+
shared,
|
|
2015
|
+
...inState
|
|
2016
|
+
];
|
|
2001
2017
|
}
|
|
2002
2018
|
function loadSecretsEnv(stateDir, configName) {
|
|
2003
2019
|
for (const p of secretsCandidates(stateDir, configName)) {
|
|
@@ -2023,13 +2039,14 @@ function resolveConfigIdentity(configPath) {
|
|
|
2023
2039
|
return { stateDir, configName: cfgName };
|
|
2024
2040
|
}
|
|
2025
2041
|
function writeSecretsValue(configPath, envKey, value) {
|
|
2026
|
-
const configName =
|
|
2042
|
+
const { stateDir, configName } = resolveConfigIdentity(configPath);
|
|
2027
2043
|
const dir = join3(secretsHome(), ".engine7-secrets");
|
|
2028
2044
|
mkdirSync2(dir, { recursive: true });
|
|
2029
|
-
const file2 =
|
|
2045
|
+
const file2 = secretsCandidates(stateDir, configName)[0];
|
|
2046
|
+
const seedFrom = existsSync3(file2) ? file2 : secretsCandidates(stateDir, configName).find((p) => existsSync3(p)) ?? null;
|
|
2030
2047
|
const lines = [];
|
|
2031
|
-
if (
|
|
2032
|
-
for (const line of readFileSync3(
|
|
2048
|
+
if (seedFrom) {
|
|
2049
|
+
for (const line of readFileSync3(seedFrom, "utf8").split(/\r?\n/)) {
|
|
2033
2050
|
if (new RegExp(`^\\s*${envKey}\\s*=`).test(line)) continue;
|
|
2034
2051
|
lines.push(line);
|
|
2035
2052
|
}
|
|
@@ -2300,7 +2317,10 @@ function loadConfig(configPath) {
|
|
|
2300
2317
|
channels: agentDefaults.channels || [],
|
|
2301
2318
|
extensions: agentDefaults.extensions,
|
|
2302
2319
|
maxTurns: agentDefaults.maxTurns,
|
|
2303
|
-
|
|
2320
|
+
// ⚠️ **默认 true**(0928 翀哥拍板):开源项目,功能不按 license 分档。
|
|
2321
|
+
// 要收起来才显式配 `agents.defaults.devMode: false`。
|
|
2322
|
+
// 反过来写(=== true)时,任何没手配这一格的配置都会静默落进"基础引擎模式"。
|
|
2323
|
+
devMode: agentDefaults.devMode !== false
|
|
2304
2324
|
};
|
|
2305
2325
|
const rawSession = raw.session || {};
|
|
2306
2326
|
const sessionScope = Object.keys(rawSession).length > 0 ? { ...rawSession } : void 0;
|
|
@@ -2742,20 +2762,20 @@ __export(paths_exports, {
|
|
|
2742
2762
|
isAutoMemPath: () => isAutoMemPath,
|
|
2743
2763
|
setMemoryDirOverride: () => setMemoryDirOverride
|
|
2744
2764
|
});
|
|
2745
|
-
import { join as join6, normalize, sep, isAbsolute, resolve as resolve2 } from "node:path";
|
|
2765
|
+
import { join as join6, normalize as normalize2, sep, isAbsolute, resolve as resolve2 } from "node:path";
|
|
2746
2766
|
function setMemoryDirOverride(dir) {
|
|
2747
2767
|
_overrideMemoryDir = dir;
|
|
2748
2768
|
}
|
|
2749
2769
|
function getAutoMemPath(workspace) {
|
|
2750
2770
|
const dir = _overrideMemoryDir ? isAbsolute(_overrideMemoryDir) ? _overrideMemoryDir : resolve2(workspace, _overrideMemoryDir) : join6(workspace, AUTO_MEM_DIRNAME);
|
|
2751
|
-
const normalized =
|
|
2771
|
+
const normalized = normalize2(dir);
|
|
2752
2772
|
return (normalized + sep).normalize("NFC");
|
|
2753
2773
|
}
|
|
2754
2774
|
function getAutoMemEntrypoint(workspace) {
|
|
2755
2775
|
return join6(getAutoMemPath(workspace), ENTRYPOINT_NAME);
|
|
2756
2776
|
}
|
|
2757
2777
|
function isAutoMemPath(absolutePath, workspace) {
|
|
2758
|
-
const normalizedPath =
|
|
2778
|
+
const normalizedPath = normalize2(absolutePath);
|
|
2759
2779
|
return normalizedPath.startsWith(getAutoMemPath(workspace));
|
|
2760
2780
|
}
|
|
2761
2781
|
async function ensureMemoryDirExists(memoryDir) {
|
|
@@ -4707,7 +4727,13 @@ var init_anthropic_provider = __esm({
|
|
|
4707
4727
|
thinking: { type: "enabled", budget_tokens: thinkingBudget }
|
|
4708
4728
|
} : params.disableThinking ? {
|
|
4709
4729
|
// 显式关闭 thinking(智谱 GLM-5.1 需要传 disabled 才真正关闭)
|
|
4710
|
-
|
|
4730
|
+
// 0928 修:MiniMax M3.1-Flash 系强制 adaptive,disabled 直接 400(码 2013,
|
|
4731
|
+
// 实证:proactive 后台调用换 M3.1 后 LLM UNREACHABLE)——该系降级发 adaptive
|
|
4732
|
+
...params.model?.includes("M3.1-Flash") ? {
|
|
4733
|
+
thinking: { type: "adaptive" }
|
|
4734
|
+
} : {
|
|
4735
|
+
thinking: { type: "disabled" }
|
|
4736
|
+
},
|
|
4711
4737
|
...params.temperature !== void 0 ? { temperature: params.temperature } : {}
|
|
4712
4738
|
} : {
|
|
4713
4739
|
...params.temperature !== void 0 ? { temperature: params.temperature } : {}
|
|
@@ -8553,7 +8579,7 @@ var init_skill_gate = __esm({
|
|
|
8553
8579
|
"use strict";
|
|
8554
8580
|
init_skill_gate_classifier();
|
|
8555
8581
|
init_skill_gate_window();
|
|
8556
|
-
USER_CHANNELS = /* @__PURE__ */ new Set(["discord", "feishu", "wechat", "telegram", "cli", "console", "voice-chat", "deskBuddy"]);
|
|
8582
|
+
USER_CHANNELS = /* @__PURE__ */ new Set(["discord", "feishu", "wechat", "telegram", "cli", "console", "voice-chat", "deskBuddy", "ccBridge"]);
|
|
8557
8583
|
loadedBySession = /* @__PURE__ */ new Map();
|
|
8558
8584
|
MAX_TRACKED_SESSIONS = 100;
|
|
8559
8585
|
}
|
|
@@ -14315,7 +14341,7 @@ Examples:
|
|
|
14315
14341
|
properties: {
|
|
14316
14342
|
to: { type: "string", description: "\u63A5\u6536\u8005ID\u3002\u586B channel_id \u65F6\u81EA\u52A8 @\u5BF9\u65B9\uFF1B\u4E0D\u586B channel_id \u65F6\u53D1 DM\u3002\u591A\u4E2A\u6536\u4EF6\u4EBA\u7528\u9017\u53F7\u5206\u9694\u3002" },
|
|
14317
14343
|
channel_id: { type: "string", description: "\u9891\u9053 ID\uFF08\u53EF\u9009\uFF09\u3002\u4E0D\u586B\u5219\u53D1 DM \u7ED9 to\u3002\u90FD\u4E0D\u586B\u65F6\u56DE\u590D\u6765\u6E90\u9891\u9053\u3002" },
|
|
14318
|
-
source: { type: "string", description: "\u6765\u6E90\u901A\u9053\uFF1Adiscord / feishu / wechat / deskBuddy\uFF08\u684C\u9762\u5C0F\u96EF\u8BED\u97F3\uFF09\u3002\u4E0D\u586B\u65F6\u4F7F\u7528\u5F53\u524D\u6765\u6E90\u901A\u9053\u3002", enum: ["discord", "feishu", "wechat", "deskBuddy"] },
|
|
14344
|
+
source: { type: "string", description: "\u6765\u6E90\u901A\u9053\uFF1Adiscord / feishu / wechat / deskBuddy\uFF08\u684C\u9762\u5C0F\u96EF\u8BED\u97F3\uFF09/ ccBridge\uFF08CC\uFF0C\u672C\u673A\u5F00\u53D1\u901A\u9053\uFF09\u3002\u4E0D\u586B\u65F6\u4F7F\u7528\u5F53\u524D\u6765\u6E90\u901A\u9053\u3002", enum: ["discord", "feishu", "wechat", "deskBuddy", "ccBridge"] },
|
|
14319
14345
|
content: { type: "string", description: "\u6D88\u606F\u6B63\u6587" }
|
|
14320
14346
|
},
|
|
14321
14347
|
required: ["content", "to"]
|
|
@@ -18662,7 +18688,7 @@ function getAgentName(ctx) {
|
|
|
18662
18688
|
return ctx.agentName || TEAM_LEAD_NAME;
|
|
18663
18689
|
}
|
|
18664
18690
|
function getTeamName(ctx) {
|
|
18665
|
-
return ctx.teamName;
|
|
18691
|
+
return ctx.teamName || getLeaderTeamName() || void 0;
|
|
18666
18692
|
}
|
|
18667
18693
|
async function handleMessage(recipientName, content, summary, ctx) {
|
|
18668
18694
|
const teamName = getTeamName(ctx);
|
|
@@ -19194,7 +19220,7 @@ var init_TeamDeleteTool = __esm({
|
|
|
19194
19220
|
},
|
|
19195
19221
|
isEnabled: () => isAgentSwarmsEnabled(),
|
|
19196
19222
|
handler: async (_args, ctx) => {
|
|
19197
|
-
const teamName = ctx.teamName;
|
|
19223
|
+
const teamName = ctx.teamName || getLeaderTeamName() || void 0;
|
|
19198
19224
|
if (teamName) {
|
|
19199
19225
|
const teamFile = readTeamFile(teamName);
|
|
19200
19226
|
if (teamFile) {
|
|
@@ -21715,9 +21741,9 @@ Follow these principles when generating episodic memories:
|
|
|
21715
21741
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
21716
21742
|
import { mkdirSync as mkdirSync18, readFileSync as readFileSync26, writeFileSync as writeFileSync18, existsSync as existsSync26, readdirSync as readdirSync8 } from "node:fs";
|
|
21717
21743
|
import { join as join36 } from "node:path";
|
|
21718
|
-
import { createHash } from "node:crypto";
|
|
21744
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
21719
21745
|
function contentHash(text) {
|
|
21720
|
-
return
|
|
21746
|
+
return createHash2("sha256").update(text.replace(/\s+/g, "")).digest("hex").slice(0, 40);
|
|
21721
21747
|
}
|
|
21722
21748
|
function mem7Root(stateDir) {
|
|
21723
21749
|
return join36(stateDir, "mem7");
|
|
@@ -29503,6 +29529,7 @@ __export(provision_free_exports, {
|
|
|
29503
29529
|
loadOrCreateInstallIdentity: () => loadOrCreateInstallIdentity,
|
|
29504
29530
|
provisionFreeToken: () => provisionFreeToken,
|
|
29505
29531
|
readInstallIdentity: () => readInstallIdentity,
|
|
29532
|
+
readInstallIdentityDetailed: () => readInstallIdentityDetailed,
|
|
29506
29533
|
writeIdentityContactEmail: () => writeIdentityContactEmail
|
|
29507
29534
|
});
|
|
29508
29535
|
import { randomBytes as randomBytes6, randomUUID as randomUUID9 } from "node:crypto";
|
|
@@ -29547,19 +29574,37 @@ function loadOrCreateInstallIdentity(stateDir) {
|
|
|
29547
29574
|
}
|
|
29548
29575
|
return identity;
|
|
29549
29576
|
}
|
|
29550
|
-
function
|
|
29577
|
+
function readInstallIdentityDetailed(stateDir) {
|
|
29578
|
+
const file2 = join51(stateDir, IDENTITY_FILE);
|
|
29579
|
+
if (!existsSync32(file2)) return { ok: false, reason: "missing" };
|
|
29580
|
+
let text;
|
|
29551
29581
|
try {
|
|
29552
|
-
|
|
29553
|
-
|
|
29554
|
-
|
|
29555
|
-
|
|
29582
|
+
text = readFileSync39(file2, "utf8");
|
|
29583
|
+
} catch (e) {
|
|
29584
|
+
return { ok: false, reason: "corrupt", detail: `\u5B58\u5728\u4F46\u8BFB\u4E0D\u4E86\uFF08${e?.message ?? e}\uFF09` };
|
|
29585
|
+
}
|
|
29586
|
+
let parsed;
|
|
29587
|
+
try {
|
|
29588
|
+
parsed = JSON.parse(text);
|
|
29589
|
+
} catch (e) {
|
|
29590
|
+
return { ok: false, reason: "corrupt", detail: `\u4E0D\u662F\u5408\u6CD5 JSON\uFF08${e?.message ?? e}\uFF09` };
|
|
29591
|
+
}
|
|
29592
|
+
if (typeof parsed?.installId !== "string" || typeof parsed?.installSecret !== "string") {
|
|
29593
|
+
return { ok: false, reason: "corrupt", detail: "\u7F3A installId / installSecret \u5B57\u6BB5" };
|
|
29594
|
+
}
|
|
29595
|
+
const email = readContactEmailOf(parsed);
|
|
29596
|
+
return {
|
|
29597
|
+
ok: true,
|
|
29598
|
+
identity: {
|
|
29556
29599
|
installId: parsed.installId,
|
|
29557
29600
|
installSecret: parsed.installSecret,
|
|
29558
29601
|
...email ? { contactEmail: email } : {}
|
|
29559
|
-
}
|
|
29560
|
-
}
|
|
29561
|
-
|
|
29562
|
-
|
|
29602
|
+
}
|
|
29603
|
+
};
|
|
29604
|
+
}
|
|
29605
|
+
function readInstallIdentity(stateDir) {
|
|
29606
|
+
const r = readInstallIdentityDetailed(stateDir);
|
|
29607
|
+
return r.ok ? r.identity : null;
|
|
29563
29608
|
}
|
|
29564
29609
|
function writeIdentityContactEmail(stateDir, email) {
|
|
29565
29610
|
const identity = loadOrCreateInstallIdentity(stateDir);
|
|
@@ -30649,7 +30694,7 @@ async function runConfigCommand(args) {
|
|
|
30649
30694
|
const writing = new Set(secretWrites.map((s) => s.name));
|
|
30650
30695
|
const others = readEnvKeys(fallback).filter((k) => !writing.has(k));
|
|
30651
30696
|
if (others.length > 0) {
|
|
30652
|
-
warnings.push(`\u8FD9\u6B21\u5199\u5165\u4F1A\u65B0\u5EFA ${writePath2}\uFF08\u5019\u9009 #1\uFF09\uFF1A
|
|
30697
|
+
warnings.push(`\u8FD9\u6B21\u5199\u5165\u4F1A\u65B0\u5EFA ${writePath2}\uFF08\u5019\u9009 #1\uFF09\uFF1A${fallback} \u91CC\u5176\u4F59 ${others.length} \u4E2A\u952E\uFF08${others.slice(0, 5).join(", ")}\uFF09\u4F1A\u4E00\u5E76\u5E26\u8FC7\u6765\uFF0C\u4F46\u6B64\u540E\u5BF9 ${fallback} \u7684\u4FEE\u6539\u4E0D\u518D\u751F\u6548\u2014\u2014\u5F15\u64CE\u53EA\u5728\u7B2C\u4E00\u4E2A\u5B58\u5728\u7684\u5019\u9009\u5904\u8BFB\u53D6\uFF0C\u4EE5\u540E\u8981\u6539\u8BF7\u6539 ${writePath2}`);
|
|
30653
30698
|
}
|
|
30654
30699
|
}
|
|
30655
30700
|
}
|
|
@@ -31969,13 +32014,8 @@ function loadExistingValues(stateDir) {
|
|
|
31969
32014
|
}
|
|
31970
32015
|
function readSecretsValue(stateDir, envName) {
|
|
31971
32016
|
try {
|
|
31972
|
-
const secretsDir = path42.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7-secrets");
|
|
31973
32017
|
const cfgBase = "main7";
|
|
31974
|
-
const
|
|
31975
|
-
path42.join(secretsDir, `${cfgBase}.env`),
|
|
31976
|
-
path42.join(stateDir, "configs", `.env.${cfgBase}`)
|
|
31977
|
-
];
|
|
31978
|
-
for (const p of candidates) {
|
|
32018
|
+
for (const p of secretsCandidates(stateDir, cfgBase)) {
|
|
31979
32019
|
if (fs41.existsSync(p)) {
|
|
31980
32020
|
for (const line of fs41.readFileSync(p, "utf8").split("\n")) {
|
|
31981
32021
|
const eq = line.indexOf("=");
|
|
@@ -32801,14 +32841,8 @@ engine7 start \u2014 \u542F\u52A8 Engine
|
|
|
32801
32841
|
}
|
|
32802
32842
|
console.log("");
|
|
32803
32843
|
const envForChild = { ...process.env };
|
|
32804
|
-
const
|
|
32805
|
-
const
|
|
32806
|
-
const secretCandidates = [
|
|
32807
|
-
path42.join(secretsDir, `${cfgBase}.env`),
|
|
32808
|
-
path42.join(path42.dirname(configPath2), `.env.${cfgBase}`),
|
|
32809
|
-
path42.join(path42.dirname(configPath2), ".env")
|
|
32810
|
-
];
|
|
32811
|
-
for (const secretPath of secretCandidates) {
|
|
32844
|
+
const { stateDir: secretsStateDir, configName: secretsCfgName } = resolveConfigIdentity(configPath2);
|
|
32845
|
+
for (const secretPath of secretsCandidates(secretsStateDir, secretsCfgName)) {
|
|
32812
32846
|
if (fs41.existsSync(secretPath)) {
|
|
32813
32847
|
const content = fs41.readFileSync(secretPath, "utf-8");
|
|
32814
32848
|
for (const line of content.split("\n")) {
|