engine7 7.1.121 → 7.1.123
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 +243 -177
- package/dist/engine-startup.mjs +330 -148
- package/dist/main.mjs +330 -148
- package/dist/mem7-worker.mjs +15 -2
- package/package.json +1 -1
- package/templates/config.template.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -861,8 +861,8 @@ function parseWall(s) {
|
|
|
861
861
|
warnOnce("parseWall", "unparseable", raw);
|
|
862
862
|
return raw;
|
|
863
863
|
}
|
|
864
|
-
const
|
|
865
|
-
if (
|
|
864
|
+
const tail2 = raw.slice(m[0].length);
|
|
865
|
+
if (tail2 && !/^\.\d+$/.test(tail2)) {
|
|
866
866
|
warnOnce("parseWall", "unparseable-tail", raw);
|
|
867
867
|
return raw;
|
|
868
868
|
}
|
|
@@ -871,7 +871,7 @@ function parseWall(s) {
|
|
|
871
871
|
warnOnce("parseWall", "out-of-range", raw);
|
|
872
872
|
return raw;
|
|
873
873
|
}
|
|
874
|
-
const ms =
|
|
874
|
+
const ms = tail2 ? Math.round(Number(`0${tail2}`) * 1e3) : 0;
|
|
875
875
|
return withMs(wallToUtc(Y, Mo, D, H, Mi, S), ms);
|
|
876
876
|
}
|
|
877
877
|
function daysInMonth(y, mo) {
|
|
@@ -1047,7 +1047,7 @@ var init_read_budget = __esm({
|
|
|
1047
1047
|
check(depth = 0) {
|
|
1048
1048
|
if (this.failure) throw this.failure;
|
|
1049
1049
|
const elapsed = this.elapsedMs + (this.started === void 0 ? 0 : this.now() - this.started);
|
|
1050
|
-
const reason = depth > (this.limits.maxDepth ?? 256) ? "depth" : ++this.steps > (this.limits.maxSteps ??
|
|
1050
|
+
const reason = depth > (this.limits.maxDepth ?? 256) ? "depth" : ++this.steps > (this.limits.maxSteps ?? 25e4) ? "work" : elapsed >= (this.limits.maxMs ?? 4e3) ? "time" : void 0;
|
|
1051
1051
|
if (reason) {
|
|
1052
1052
|
this.failure = new MemoryReadBudgetExceededError(reason);
|
|
1053
1053
|
throw this.failure;
|
|
@@ -2292,6 +2292,11 @@ CREATE TABLE memory_state_outbox (
|
|
|
2292
2292
|
payload_json TEXT NOT NULL, created_at TEXT NOT NULL,
|
|
2293
2293
|
PRIMARY KEY(scope_id,event_seq), FOREIGN KEY(scope_id) REFERENCES memory_scopes(scope_id)
|
|
2294
2294
|
);
|
|
2295
|
+
-- 1013\uFF1A\u6309 (scope_id,kind) \u53D6 MAX(aggregate_version) \u7684\u805A\u5408\u7248\u672C\u67E5\u8BE2\uFF0C\u9760 PK \u53EA\u80FD\u547D\u4E2D scope_id\uFF0C
|
|
2296
|
+
-- \u4E4B\u540E\u8981\u626B\u8BE5 scope \u4E0B\u5168\u90E8 outbox \u884C\u7B97 MAX\u3002\u8BE5\u67E5\u8BE2\u5728\u5355\u6B21 buildMemoryContext \u91CC\u88AB\u8C03\u7528\u6570\u767E\u6B21
|
|
2297
|
+
-- \uFF08\u59B9\u59B9 2015 \u884C\u5E93 \u2248 140 \u4E07\u884C\u8BBF\u95EE\uFF09\uFF0C\u5B9E\u6D4B\u628A\u5F53\u524D\u4E0A\u4E0B\u6587\u88C5\u914D\u4ECE 719ms \u63A8\u5230 2617ms\uFF0C\u76F4\u63A5\u51FB\u7A7F
|
|
2298
|
+
-- turnReadBudgetMs \u9ED8\u8BA4 1500ms \u2192 \u5168\u8F6E\u964D\u7EA7 \u2192 \u5360\u4F4D\u7B26\u4E8B\u6545\u3002\u8986\u76D6\u7D22\u5F15\u8BA9 MAX \u9000\u5316\u6210\u7D22\u5F15\u672B\u9879\u5B9A\u4F4D\u3002
|
|
2299
|
+
CREATE INDEX IF NOT EXISTS idx_outbox_scope_kind_version ON memory_state_outbox(scope_id,kind,aggregate_version);
|
|
2295
2300
|
`;
|
|
2296
2301
|
}
|
|
2297
2302
|
});
|
|
@@ -10044,6 +10049,14 @@ function migrateMem7(db2, initializeLegacySchema) {
|
|
|
10044
10049
|
version: 29,
|
|
10045
10050
|
name: "idempotent-source-backed-chat-people-updates",
|
|
10046
10051
|
apply: (database) => database.exec(SOCIAL_WRITE_SCHEMA)
|
|
10052
|
+
}, {
|
|
10053
|
+
version: 30,
|
|
10054
|
+
name: "indexed-outbox-aggregate-revisions",
|
|
10055
|
+
// 存量库补索引:聚合版本查询此前要扫该 scope 下全部 outbox 行算 MAX,
|
|
10056
|
+
// 实测妹妹 182MB 库 buildMemoryContext 2617ms → 719ms(读预算默认 1500ms 本来必破)。
|
|
10057
|
+
apply: (database) => database.exec(
|
|
10058
|
+
"CREATE INDEX IF NOT EXISTS idx_outbox_scope_kind_version ON memory_state_outbox(scope_id,kind,aggregate_version)"
|
|
10059
|
+
)
|
|
10047
10060
|
}]);
|
|
10048
10061
|
} finally {
|
|
10049
10062
|
if (foreignKeys) db2.exec("PRAGMA foreign_keys=ON");
|
|
@@ -10069,7 +10082,7 @@ var init_migrations = __esm({
|
|
|
10069
10082
|
init_relationship_cognition();
|
|
10070
10083
|
init_relationship_notices();
|
|
10071
10084
|
init_relationship_history();
|
|
10072
|
-
MEM7_SCHEMA_VERSION =
|
|
10085
|
+
MEM7_SCHEMA_VERSION = 30;
|
|
10073
10086
|
}
|
|
10074
10087
|
});
|
|
10075
10088
|
|
|
@@ -10639,6 +10652,32 @@ var init_wechat = __esm({
|
|
|
10639
10652
|
}
|
|
10640
10653
|
});
|
|
10641
10654
|
|
|
10655
|
+
// src/cli-stdout.ts
|
|
10656
|
+
function writeTo(stream, text) {
|
|
10657
|
+
const p = new Promise((resolve20) => {
|
|
10658
|
+
stream.write(text, () => resolve20());
|
|
10659
|
+
});
|
|
10660
|
+
if (stream === process.stdout) tail = p;
|
|
10661
|
+
return p;
|
|
10662
|
+
}
|
|
10663
|
+
function writeStdout(text) {
|
|
10664
|
+
return writeTo(process.stdout, text);
|
|
10665
|
+
}
|
|
10666
|
+
function flushStdout() {
|
|
10667
|
+
return tail;
|
|
10668
|
+
}
|
|
10669
|
+
async function exitCli(code) {
|
|
10670
|
+
await flushStdout();
|
|
10671
|
+
return process.exit(code);
|
|
10672
|
+
}
|
|
10673
|
+
var tail;
|
|
10674
|
+
var init_cli_stdout = __esm({
|
|
10675
|
+
"src/cli-stdout.ts"() {
|
|
10676
|
+
"use strict";
|
|
10677
|
+
tail = Promise.resolve();
|
|
10678
|
+
}
|
|
10679
|
+
});
|
|
10680
|
+
|
|
10642
10681
|
// src/cli-events.ts
|
|
10643
10682
|
var cli_events_exports = {};
|
|
10644
10683
|
__export(cli_events_exports, {
|
|
@@ -10647,7 +10686,7 @@ __export(cli_events_exports, {
|
|
|
10647
10686
|
});
|
|
10648
10687
|
function createEmitter(sink = process.stdout) {
|
|
10649
10688
|
return (ev) => {
|
|
10650
|
-
sink
|
|
10689
|
+
void writeTo(sink, JSON.stringify(ev) + "\n");
|
|
10651
10690
|
};
|
|
10652
10691
|
}
|
|
10653
10692
|
function redirectConsoleToStderr() {
|
|
@@ -10657,6 +10696,7 @@ function redirectConsoleToStderr() {
|
|
|
10657
10696
|
var init_cli_events = __esm({
|
|
10658
10697
|
"src/cli-events.ts"() {
|
|
10659
10698
|
"use strict";
|
|
10699
|
+
init_cli_stdout();
|
|
10660
10700
|
}
|
|
10661
10701
|
});
|
|
10662
10702
|
|
|
@@ -11536,7 +11576,8 @@ var init_registry = __esm({
|
|
|
11536
11576
|
label: "\u6BCF\u8F6E\u8BB0\u5FC6\u8BFB\u53D6\u64CD\u4F5C\u4E0A\u9650",
|
|
11537
11577
|
effect: "hot",
|
|
11538
11578
|
internal: true,
|
|
11539
|
-
|
|
11579
|
+
// 上限必须 ≥ 代码默认值 250_000(1012 抬默认时漏了这里,导致托盘/CLI 拒收代码自己的默认值)
|
|
11580
|
+
validate: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= 5e5 ? null : "\u6BCF\u8F6E\u8BB0\u5FC6\u8BFB\u53D6\u64CD\u4F5C\u987B\u4E3A 1\u2013500000 \u6B21"
|
|
11540
11581
|
},
|
|
11541
11582
|
{
|
|
11542
11583
|
path: "mem7.relationships",
|
|
@@ -12006,7 +12047,9 @@ function generateConfig(v) {
|
|
|
12006
12047
|
appSecret: secretRef(envKeyOf("channels.feishu.appSecret"), v.feishuAppSecret),
|
|
12007
12048
|
connectionMode: "websocket",
|
|
12008
12049
|
dmPolicy: "pairing",
|
|
12009
|
-
|
|
12050
|
+
// 1011 翀哥:群默认 mention-only——@才回应(引擎 adapter 同款默认)。此前脚手架写
|
|
12051
|
+
// 'open' = 装机用户的机器人在群里每条都接话;免 @ 的群走 group.openGroups 局部豁免。
|
|
12052
|
+
groupPolicy: "mention-only"
|
|
12010
12053
|
},
|
|
12011
12054
|
...v.wechatEnabled && v.wechatToken ? {
|
|
12012
12055
|
wechat: {
|
|
@@ -14042,8 +14085,8 @@ var init_think_stripper = __esm({
|
|
|
14042
14085
|
holdLen() {
|
|
14043
14086
|
const b = this.buf;
|
|
14044
14087
|
for (let k = Math.min(MAX_TAG - 1, b.length); k > 0; k--) {
|
|
14045
|
-
const
|
|
14046
|
-
if (OPEN.startsWith(
|
|
14088
|
+
const tail2 = b.slice(b.length - k);
|
|
14089
|
+
if (OPEN.startsWith(tail2) || CLOSE.startsWith(tail2)) return k;
|
|
14047
14090
|
}
|
|
14048
14091
|
return 0;
|
|
14049
14092
|
}
|
|
@@ -16515,6 +16558,130 @@ var init_executor2 = __esm({
|
|
|
16515
16558
|
}
|
|
16516
16559
|
});
|
|
16517
16560
|
|
|
16561
|
+
// src/mem7/assistant-context.ts
|
|
16562
|
+
function emittedWithheldPlaceholder(text) {
|
|
16563
|
+
return typeof text === "string" && text.trim() === withheldSourceBody;
|
|
16564
|
+
}
|
|
16565
|
+
function withholdSource(message) {
|
|
16566
|
+
message.content = withheldSourceBody;
|
|
16567
|
+
delete message.memoryOriginalText;
|
|
16568
|
+
delete message.reasoning_content;
|
|
16569
|
+
delete message.thinking_signature;
|
|
16570
|
+
delete message.responses_reasoning;
|
|
16571
|
+
}
|
|
16572
|
+
function degradeUncheckedMemory(messages) {
|
|
16573
|
+
const safeMessages = [];
|
|
16574
|
+
for (const message of messages) {
|
|
16575
|
+
if (isAttachmentMessage(message)) {
|
|
16576
|
+
if (message.attachment.type !== "relevant_memories") safeMessages.push(message);
|
|
16577
|
+
continue;
|
|
16578
|
+
}
|
|
16579
|
+
safeMessages.push(message);
|
|
16580
|
+
}
|
|
16581
|
+
return safeMessages;
|
|
16582
|
+
}
|
|
16583
|
+
function memoryContextRefs(store, scope, value) {
|
|
16584
|
+
if (!value || typeof value !== "object") return [];
|
|
16585
|
+
const input = value;
|
|
16586
|
+
if (input.scopeId !== void 0 && input.scopeId !== scopeId(scope)) return [];
|
|
16587
|
+
const refs = /* @__PURE__ */ new Map();
|
|
16588
|
+
const add = (candidate) => {
|
|
16589
|
+
checkMemoryReadBudget();
|
|
16590
|
+
if (!candidate || typeof candidate.sourceId !== "string") return;
|
|
16591
|
+
const source = store.sources.get(scope, candidate.sourceId);
|
|
16592
|
+
if (!source || !store.socialSources.retained(scope, source.sourceId)) return;
|
|
16593
|
+
if (candidate.scopeId !== void 0 && candidate.scopeId !== scopeId(scope)) return;
|
|
16594
|
+
if (candidate.sourceVersion !== void 0 && candidate.sourceVersion !== source.sourceVersion) return;
|
|
16595
|
+
const ref = { scopeId: scopeId(scope), sourceId: source.sourceId, sourceVersion: source.sourceVersion };
|
|
16596
|
+
if (candidate.relationshipId !== void 0 || candidate.semanticVersion !== void 0) {
|
|
16597
|
+
if (typeof candidate.relationshipId !== "string" || !Number.isSafeInteger(candidate.semanticVersion) || candidate.semanticVersion < 1) return;
|
|
16598
|
+
ref.relationshipId = candidate.relationshipId;
|
|
16599
|
+
ref.semanticVersion = candidate.semanticVersion;
|
|
16600
|
+
}
|
|
16601
|
+
if (candidate.purpose !== void 0) {
|
|
16602
|
+
if (!["evidence", "context", "historical"].includes(candidate.purpose)) return;
|
|
16603
|
+
ref.purpose = candidate.purpose;
|
|
16604
|
+
}
|
|
16605
|
+
if (store.socialSources.referenceRetained(scope, ref)) refs.set(canonicalJson(ref), ref);
|
|
16606
|
+
};
|
|
16607
|
+
for (const list2 of [input.contextRefs, input.relationships?.contextRefs, input.citations, input.pendingSources]) {
|
|
16608
|
+
if (Array.isArray(list2)) for (const ref of list2) add(ref);
|
|
16609
|
+
}
|
|
16610
|
+
const relationships = Array.isArray(input.relationships) ? input.relationships : input.relationships?.relationships;
|
|
16611
|
+
if (Array.isArray(relationships)) for (const relationship of relationships) {
|
|
16612
|
+
if (!relationship || typeof relationship.relationshipId !== "string" || !Number.isSafeInteger(relationship.semanticVersion)) continue;
|
|
16613
|
+
for (const list2 of [relationship.evidenceSources, relationship.basisSources]) {
|
|
16614
|
+
if (Array.isArray(list2)) for (const source of list2) add({
|
|
16615
|
+
sourceId: source.sourceId,
|
|
16616
|
+
sourceVersion: source.sourceVersion,
|
|
16617
|
+
relationshipId: relationship.relationshipId,
|
|
16618
|
+
semanticVersion: relationship.semanticVersion,
|
|
16619
|
+
purpose: relationship.current === false ? "historical" : "context"
|
|
16620
|
+
});
|
|
16621
|
+
}
|
|
16622
|
+
}
|
|
16623
|
+
for (const list2 of [input.historicalEvidence, input.episodes, input.entries]) {
|
|
16624
|
+
if (Array.isArray(list2)) {
|
|
16625
|
+
for (const item of list2) if (Array.isArray(item.sourceIds)) for (const sourceId of item.sourceIds) add({ sourceId });
|
|
16626
|
+
}
|
|
16627
|
+
}
|
|
16628
|
+
if (typeof input.sourceId === "string" && Number.isSafeInteger(input.sourceVersion)) add(input);
|
|
16629
|
+
return [...refs.values()];
|
|
16630
|
+
}
|
|
16631
|
+
function assistantContextRefs(store, scope, messages) {
|
|
16632
|
+
const refs = /* @__PURE__ */ new Map();
|
|
16633
|
+
const add = (ref) => refs.set(canonicalJson(ref), ref);
|
|
16634
|
+
for (const message of messages) {
|
|
16635
|
+
checkMemoryReadBudget();
|
|
16636
|
+
if (isAttachmentMessage(message)) {
|
|
16637
|
+
if (message.attachment.type !== "relevant_memories") continue;
|
|
16638
|
+
for (const memory of message.attachment.memories) {
|
|
16639
|
+
if (memory.mem7 && scopeId(memory.mem7.scope) === scopeId(scope)) {
|
|
16640
|
+
for (const sourceId of memory.mem7.sourceIds) {
|
|
16641
|
+
const source = store.sources.get(scope, sourceId);
|
|
16642
|
+
if (source && store.socialSources.retained(scope, sourceId)) add({ scopeId: scopeId(scope), sourceId, sourceVersion: source.sourceVersion });
|
|
16643
|
+
}
|
|
16644
|
+
}
|
|
16645
|
+
if (memory.path.startsWith("mem7-context://")) {
|
|
16646
|
+
let value;
|
|
16647
|
+
try {
|
|
16648
|
+
value = JSON.parse(memory.content);
|
|
16649
|
+
} catch (error) {
|
|
16650
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
16651
|
+
continue;
|
|
16652
|
+
}
|
|
16653
|
+
for (const ref of memoryContextRefs(store, scope, value)) add(ref);
|
|
16654
|
+
}
|
|
16655
|
+
}
|
|
16656
|
+
} else if (message.content !== withheldSourceBody && message.memoryOriginKey && message.memoryScope && scopeId(message.memoryScope) === scopeId(scope)) {
|
|
16657
|
+
const source = store.sources.getByOrigin(scope, message.memoryOriginKey, message.memorySourceVersion ?? 1);
|
|
16658
|
+
if (source && source.role === message.role && store.socialSources.retained(scope, source.sourceId))
|
|
16659
|
+
add({ scopeId: scopeId(scope), sourceId: source.sourceId, sourceVersion: source.sourceVersion });
|
|
16660
|
+
}
|
|
16661
|
+
}
|
|
16662
|
+
return [...refs.values()];
|
|
16663
|
+
}
|
|
16664
|
+
function scrubUnavailableSourceMessages(store, scope, messages) {
|
|
16665
|
+
for (const message of messages) {
|
|
16666
|
+
checkMemoryReadBudget();
|
|
16667
|
+
if (isAttachmentMessage(message) || !message.memoryOriginKey || !message.memoryScope || scopeId(message.memoryScope) !== scopeId(scope) || !store.sources.hasOrigin(scope, message.memoryOriginKey)) continue;
|
|
16668
|
+
const source = store.sources.getByOrigin(scope, message.memoryOriginKey, message.memorySourceVersion ?? 1);
|
|
16669
|
+
if (source && store.socialSources.retained(scope, source.sourceId)) continue;
|
|
16670
|
+
withholdSource(message);
|
|
16671
|
+
}
|
|
16672
|
+
}
|
|
16673
|
+
var withheldSourceBody;
|
|
16674
|
+
var init_assistant_context = __esm({
|
|
16675
|
+
"src/mem7/assistant-context.ts"() {
|
|
16676
|
+
"use strict";
|
|
16677
|
+
init_types();
|
|
16678
|
+
init_scope();
|
|
16679
|
+
init_temporal();
|
|
16680
|
+
init_read_budget();
|
|
16681
|
+
withheldSourceBody = "[\u5BF9\u5E94\u8BB0\u5FC6\u6765\u6E90\u672C\u8F6E\u672A\u901A\u8FC7\u6821\u9A8C\uFF0C\u539F\u6587\u6682\u4E0D\u63D0\u4F9B\u3002]";
|
|
16682
|
+
}
|
|
16683
|
+
});
|
|
16684
|
+
|
|
16518
16685
|
// src/memory/memdir/memoryAge.ts
|
|
16519
16686
|
function memoryAgeDays(mtimeMs) {
|
|
16520
16687
|
return Math.max(0, Math.floor((Date.now() - mtimeMs) / 864e5));
|
|
@@ -19502,6 +19669,7 @@ var init_query = __esm({
|
|
|
19502
19669
|
"use strict";
|
|
19503
19670
|
init_executor2();
|
|
19504
19671
|
init_host_turn();
|
|
19672
|
+
init_assistant_context();
|
|
19505
19673
|
init_external_effect();
|
|
19506
19674
|
init_attachments();
|
|
19507
19675
|
init_context_dump();
|
|
@@ -19952,6 +20120,10 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
19952
20120
|
return;
|
|
19953
20121
|
}
|
|
19954
20122
|
if (toolCalls.length === 0) {
|
|
20123
|
+
if (emittedWithheldPlaceholder(textContent)) {
|
|
20124
|
+
console.warn(`${this.logPrefix} Turn ${turnCount}: \u6A21\u578B\u8F93\u51FA\u7CFB\u7EDF\u5360\u4F4D\u7B26\uFF0C\u6309\u7A7A\u54CD\u5E94\u91CD\u8BD5\uFF08\u4E0D\u5165\u5386\u53F2\u3001\u4E0D\u51FA\u7AD9\uFF09`);
|
|
20125
|
+
textContent = "";
|
|
20126
|
+
}
|
|
19955
20127
|
if (!textContent.trim()) {
|
|
19956
20128
|
const thinkingAteBudget = turnThinking.length > 0;
|
|
19957
20129
|
console.log(`${this.logPrefix} Turn ${turnCount}: API returned empty (no text, no tool_call).${thinkingAteBudget ? ` ${turnThinking.length}ch thinking \u5403\u5149\u8F93\u51FA\u9884\u7B97 \u2192 retry with thinking off` : " Retrying..."} messages=${currentMessages.length}`);
|
|
@@ -30684,133 +30856,6 @@ var init_active_query_engine = __esm({
|
|
|
30684
30856
|
}
|
|
30685
30857
|
});
|
|
30686
30858
|
|
|
30687
|
-
// src/mem7/assistant-context.ts
|
|
30688
|
-
function withholdSource(message) {
|
|
30689
|
-
message.content = withheldSourceBody;
|
|
30690
|
-
delete message.memoryOriginalText;
|
|
30691
|
-
delete message.reasoning_content;
|
|
30692
|
-
delete message.thinking_signature;
|
|
30693
|
-
delete message.responses_reasoning;
|
|
30694
|
-
}
|
|
30695
|
-
function withholdUncheckedMemory(messages, currentMessage) {
|
|
30696
|
-
const safeMessages = [];
|
|
30697
|
-
for (const message of messages) {
|
|
30698
|
-
if (isAttachmentMessage(message)) {
|
|
30699
|
-
if (message.attachment.type !== "relevant_memories") safeMessages.push(message);
|
|
30700
|
-
continue;
|
|
30701
|
-
}
|
|
30702
|
-
if (!message.memoryOriginKey || message === currentMessage) {
|
|
30703
|
-
safeMessages.push(message);
|
|
30704
|
-
continue;
|
|
30705
|
-
}
|
|
30706
|
-
const safe = { ...message };
|
|
30707
|
-
withholdSource(safe);
|
|
30708
|
-
safeMessages.push(safe);
|
|
30709
|
-
}
|
|
30710
|
-
return safeMessages;
|
|
30711
|
-
}
|
|
30712
|
-
function memoryContextRefs(store, scope, value) {
|
|
30713
|
-
if (!value || typeof value !== "object") return [];
|
|
30714
|
-
const input = value;
|
|
30715
|
-
if (input.scopeId !== void 0 && input.scopeId !== scopeId(scope)) return [];
|
|
30716
|
-
const refs = /* @__PURE__ */ new Map();
|
|
30717
|
-
const add = (candidate) => {
|
|
30718
|
-
checkMemoryReadBudget();
|
|
30719
|
-
if (!candidate || typeof candidate.sourceId !== "string") return;
|
|
30720
|
-
const source = store.sources.get(scope, candidate.sourceId);
|
|
30721
|
-
if (!source || !store.socialSources.retained(scope, source.sourceId)) return;
|
|
30722
|
-
if (candidate.scopeId !== void 0 && candidate.scopeId !== scopeId(scope)) return;
|
|
30723
|
-
if (candidate.sourceVersion !== void 0 && candidate.sourceVersion !== source.sourceVersion) return;
|
|
30724
|
-
const ref = { scopeId: scopeId(scope), sourceId: source.sourceId, sourceVersion: source.sourceVersion };
|
|
30725
|
-
if (candidate.relationshipId !== void 0 || candidate.semanticVersion !== void 0) {
|
|
30726
|
-
if (typeof candidate.relationshipId !== "string" || !Number.isSafeInteger(candidate.semanticVersion) || candidate.semanticVersion < 1) return;
|
|
30727
|
-
ref.relationshipId = candidate.relationshipId;
|
|
30728
|
-
ref.semanticVersion = candidate.semanticVersion;
|
|
30729
|
-
}
|
|
30730
|
-
if (candidate.purpose !== void 0) {
|
|
30731
|
-
if (!["evidence", "context", "historical"].includes(candidate.purpose)) return;
|
|
30732
|
-
ref.purpose = candidate.purpose;
|
|
30733
|
-
}
|
|
30734
|
-
if (store.socialSources.referenceRetained(scope, ref)) refs.set(canonicalJson(ref), ref);
|
|
30735
|
-
};
|
|
30736
|
-
for (const list2 of [input.contextRefs, input.relationships?.contextRefs, input.citations, input.pendingSources]) {
|
|
30737
|
-
if (Array.isArray(list2)) for (const ref of list2) add(ref);
|
|
30738
|
-
}
|
|
30739
|
-
const relationships = Array.isArray(input.relationships) ? input.relationships : input.relationships?.relationships;
|
|
30740
|
-
if (Array.isArray(relationships)) for (const relationship of relationships) {
|
|
30741
|
-
if (!relationship || typeof relationship.relationshipId !== "string" || !Number.isSafeInteger(relationship.semanticVersion)) continue;
|
|
30742
|
-
for (const list2 of [relationship.evidenceSources, relationship.basisSources]) {
|
|
30743
|
-
if (Array.isArray(list2)) for (const source of list2) add({
|
|
30744
|
-
sourceId: source.sourceId,
|
|
30745
|
-
sourceVersion: source.sourceVersion,
|
|
30746
|
-
relationshipId: relationship.relationshipId,
|
|
30747
|
-
semanticVersion: relationship.semanticVersion,
|
|
30748
|
-
purpose: relationship.current === false ? "historical" : "context"
|
|
30749
|
-
});
|
|
30750
|
-
}
|
|
30751
|
-
}
|
|
30752
|
-
for (const list2 of [input.historicalEvidence, input.episodes, input.entries]) {
|
|
30753
|
-
if (Array.isArray(list2)) {
|
|
30754
|
-
for (const item of list2) if (Array.isArray(item.sourceIds)) for (const sourceId of item.sourceIds) add({ sourceId });
|
|
30755
|
-
}
|
|
30756
|
-
}
|
|
30757
|
-
if (typeof input.sourceId === "string" && Number.isSafeInteger(input.sourceVersion)) add(input);
|
|
30758
|
-
return [...refs.values()];
|
|
30759
|
-
}
|
|
30760
|
-
function assistantContextRefs(store, scope, messages) {
|
|
30761
|
-
const refs = /* @__PURE__ */ new Map();
|
|
30762
|
-
const add = (ref) => refs.set(canonicalJson(ref), ref);
|
|
30763
|
-
for (const message of messages) {
|
|
30764
|
-
checkMemoryReadBudget();
|
|
30765
|
-
if (isAttachmentMessage(message)) {
|
|
30766
|
-
if (message.attachment.type !== "relevant_memories") continue;
|
|
30767
|
-
for (const memory of message.attachment.memories) {
|
|
30768
|
-
if (memory.mem7 && scopeId(memory.mem7.scope) === scopeId(scope)) {
|
|
30769
|
-
for (const sourceId of memory.mem7.sourceIds) {
|
|
30770
|
-
const source = store.sources.get(scope, sourceId);
|
|
30771
|
-
if (source && store.socialSources.retained(scope, sourceId)) add({ scopeId: scopeId(scope), sourceId, sourceVersion: source.sourceVersion });
|
|
30772
|
-
}
|
|
30773
|
-
}
|
|
30774
|
-
if (memory.path.startsWith("mem7-context://")) {
|
|
30775
|
-
let value;
|
|
30776
|
-
try {
|
|
30777
|
-
value = JSON.parse(memory.content);
|
|
30778
|
-
} catch (error) {
|
|
30779
|
-
if (!(error instanceof SyntaxError)) throw error;
|
|
30780
|
-
continue;
|
|
30781
|
-
}
|
|
30782
|
-
for (const ref of memoryContextRefs(store, scope, value)) add(ref);
|
|
30783
|
-
}
|
|
30784
|
-
}
|
|
30785
|
-
} else if (message.content !== withheldSourceBody && message.memoryOriginKey && message.memoryScope && scopeId(message.memoryScope) === scopeId(scope)) {
|
|
30786
|
-
const source = store.sources.getByOrigin(scope, message.memoryOriginKey, message.memorySourceVersion ?? 1);
|
|
30787
|
-
if (source && source.role === message.role && store.socialSources.retained(scope, source.sourceId))
|
|
30788
|
-
add({ scopeId: scopeId(scope), sourceId: source.sourceId, sourceVersion: source.sourceVersion });
|
|
30789
|
-
}
|
|
30790
|
-
}
|
|
30791
|
-
return [...refs.values()];
|
|
30792
|
-
}
|
|
30793
|
-
function scrubUnavailableSourceMessages(store, scope, messages) {
|
|
30794
|
-
for (const message of messages) {
|
|
30795
|
-
checkMemoryReadBudget();
|
|
30796
|
-
if (isAttachmentMessage(message) || !message.memoryOriginKey || !message.memoryScope || scopeId(message.memoryScope) !== scopeId(scope) || !store.sources.hasOrigin(scope, message.memoryOriginKey)) continue;
|
|
30797
|
-
const source = store.sources.getByOrigin(scope, message.memoryOriginKey, message.memorySourceVersion ?? 1);
|
|
30798
|
-
if (source && store.socialSources.retained(scope, source.sourceId)) continue;
|
|
30799
|
-
withholdSource(message);
|
|
30800
|
-
}
|
|
30801
|
-
}
|
|
30802
|
-
var withheldSourceBody;
|
|
30803
|
-
var init_assistant_context = __esm({
|
|
30804
|
-
"src/mem7/assistant-context.ts"() {
|
|
30805
|
-
"use strict";
|
|
30806
|
-
init_types();
|
|
30807
|
-
init_scope();
|
|
30808
|
-
init_temporal();
|
|
30809
|
-
init_read_budget();
|
|
30810
|
-
withheldSourceBody = "[\u5BF9\u5E94\u8BB0\u5FC6\u6765\u6E90\u672C\u8F6E\u672A\u901A\u8FC7\u6821\u9A8C\uFF0C\u539F\u6587\u6682\u4E0D\u63D0\u4F9B\u3002]";
|
|
30811
|
-
}
|
|
30812
|
-
});
|
|
30813
|
-
|
|
30814
30859
|
// src/memory/memdir/memoryScan.ts
|
|
30815
30860
|
import { readdir, stat as stat2, readFile as readFile3 } from "node:fs/promises";
|
|
30816
30861
|
import { basename as basename6, join as join37, sep as sep6 } from "node:path";
|
|
@@ -39120,8 +39165,21 @@ async function handleQueryInner(text, sessionId, channelName, cb, deps, channelT
|
|
|
39120
39165
|
const memoryContextRefs2 = [];
|
|
39121
39166
|
const memoryStateDir = memoryIntake?.stateDir ?? String(liveConfig.get("stateDir") ?? deps.stateDir ?? "");
|
|
39122
39167
|
const memoryReadBudget = new MemoryReadBudget({
|
|
39123
|
-
|
|
39124
|
-
|
|
39168
|
+
// 1013:时间闸默认 1500ms 同样低于合法工作集——1012 为步数闸写下的原则(「闸只防无进展的
|
|
39169
|
+
// 死循环,不该拦合法工作」)当时没套用到时间闸上,它的 447ms 依据只测了 scrub+strip+refs,
|
|
39170
|
+
// 漏掉最贵的 buildMemoryContext。实测妹妹 182MB 库:三阶段累计 1196–1474ms,1500ms 下余量
|
|
39171
|
+
// 只剩 26–304ms,正常聊天即耗尽(1013 占位符事故,reason=time)。抬到 4000ms(小柯线上
|
|
39172
|
+
// 已跑这个值);闸仍兜 1009 式事件循环冻结,只是不再切合法工作。
|
|
39173
|
+
// 真正的成本在 a75d3804 的 outbox 覆盖索引:当前上下文装配 2617ms → ~1100ms。
|
|
39174
|
+
maxMs: liveConfig.get("mem7.turnReadBudgetMs") ?? 4e3,
|
|
39175
|
+
// 1012:步数闸默认 5 万被证低于合法工作集——忙 scope 单轮两遍冷走(:438 prompt 前 + :1042 query 循环内,
|
|
39176
|
+
// 中间 worker 落盘会失效快照)≈ 5 万步,正常聊天即触发全量扣原文(占位符刷屏事故)。真安全线是时间闸
|
|
39177
|
+
// 1500ms(防 1009 式事件循环冻结),步数闸只防无进展的死循环,抬到 25 万。实测妹妹 151MB 库全轮 447ms。
|
|
39178
|
+
// ⚠️ 1013 更正:上面「真安全线是时间闸 1500ms」已被证伪——那次 447ms 只测了
|
|
39179
|
+
// scrub+strip+refs(见 scripts/_probe-scrub-steps-1012.mts),漏掉最贵的 buildMemoryContext
|
|
39180
|
+
// (同库实测 2617ms),所以 1500ms 当时就已经不可达。步数闸的结论仍然成立(实测
|
|
39181
|
+
// 三阶段 102150 步,25 万合适)。
|
|
39182
|
+
maxSteps: liveConfig.get("mem7.turnReadMaxSteps") ?? 25e4
|
|
39125
39183
|
});
|
|
39126
39184
|
let memoryReadDegraded = false;
|
|
39127
39185
|
let currentPromptMessage;
|
|
@@ -39176,7 +39234,7 @@ async function handleQueryInner(text, sessionId, channelName, cb, deps, channelT
|
|
|
39176
39234
|
Promise.resolve().then(() => (init_historical_recall(), historical_recall_exports))
|
|
39177
39235
|
]);
|
|
39178
39236
|
revalidateRecall = (items) => {
|
|
39179
|
-
if (memoryReadDegraded) return
|
|
39237
|
+
if (memoryReadDegraded) return degradeUncheckedMemory(items);
|
|
39180
39238
|
const invalidPaths = /* @__PURE__ */ new Set();
|
|
39181
39239
|
const checked = items.map((item) => isAttachmentMessage(item) || item === currentPromptMessage ? item : { ...item });
|
|
39182
39240
|
try {
|
|
@@ -39196,7 +39254,7 @@ async function handleQueryInner(text, sessionId, channelName, cb, deps, channelT
|
|
|
39196
39254
|
} catch (error) {
|
|
39197
39255
|
if (!isMemoryReadUnavailable(error)) throw error;
|
|
39198
39256
|
degradeMemoryRead(error);
|
|
39199
|
-
return
|
|
39257
|
+
return degradeUncheckedMemory(items);
|
|
39200
39258
|
}
|
|
39201
39259
|
if (invalidPaths.size) {
|
|
39202
39260
|
stripRecalledMemories(history, (path52) => invalidPaths.has(normalizeMemoryPath(path52)));
|
|
@@ -39721,7 +39779,7 @@ ${evidence}
|
|
|
39721
39779
|
} catch (error) {
|
|
39722
39780
|
if (isMemoryReadUnavailable(error)) {
|
|
39723
39781
|
degradeMemoryRead(error);
|
|
39724
|
-
messages =
|
|
39782
|
+
messages = degradeUncheckedMemory(messages);
|
|
39725
39783
|
}
|
|
39726
39784
|
console.warn(`[handle-query] mem7 current context failed: ${error?.message ?? error}`);
|
|
39727
39785
|
}
|
|
@@ -39745,7 +39803,7 @@ ${evidence}
|
|
|
39745
39803
|
} catch (error) {
|
|
39746
39804
|
if (!isMemoryReadUnavailable(error)) throw error;
|
|
39747
39805
|
degradeMemoryRead(error);
|
|
39748
|
-
messages =
|
|
39806
|
+
messages = degradeUncheckedMemory(messages);
|
|
39749
39807
|
}
|
|
39750
39808
|
}
|
|
39751
39809
|
if (memoryHostSourceId && !memoryContextRefs2.some((ref) => ref.sourceId === memoryHostSourceId)) {
|
|
@@ -39894,7 +39952,12 @@ ${evidence}
|
|
|
39894
39952
|
const rawContent = chunk.content ?? "";
|
|
39895
39953
|
const inputTokens = chunk.inputTokens ?? 0;
|
|
39896
39954
|
const outputTokens = chunk.outputTokens ?? 0;
|
|
39897
|
-
const
|
|
39955
|
+
const placeholderLeak = emittedWithheldPlaceholder(rawContent);
|
|
39956
|
+
if (placeholderLeak) {
|
|
39957
|
+
console.warn("[handle-query] \u26A0\uFE0F \u6A21\u578B\u91CD\u8BD5\u540E\u4ECD\u8F93\u51FA\u7CFB\u7EDF\u5360\u4F4D\u7B26\u2014\u2014\u62D2\u7EDD\u5165\u5386\u53F2\u4E0E\u51FA\u7AD9");
|
|
39958
|
+
}
|
|
39959
|
+
const usableContent = placeholderLeak ? "" : rawContent;
|
|
39960
|
+
const resultContent = usableContent.trim() || fullResponse.trim() || "(\u65E0\u56DE\u590D)";
|
|
39898
39961
|
if (!rawContent.trim()) {
|
|
39899
39962
|
console.log(`[handle-query] \u26A0\uFE0F EMPTY RESULT after ${toolCount} tools, falling back to ${fullResponse.length} chars accumulated`);
|
|
39900
39963
|
}
|
|
@@ -40267,7 +40330,9 @@ function startStdinHandler() {
|
|
|
40267
40330
|
}
|
|
40268
40331
|
};
|
|
40269
40332
|
const rl = readline2.createInterface({ input: process.stdin, terminal: false });
|
|
40270
|
-
const respond = (obj) =>
|
|
40333
|
+
const respond = (obj) => {
|
|
40334
|
+
void writeStdout(JSON.stringify(obj) + "\n");
|
|
40335
|
+
};
|
|
40271
40336
|
rl.on("line", (line) => {
|
|
40272
40337
|
const s = line.trim();
|
|
40273
40338
|
if (!s) return;
|
|
@@ -40539,9 +40604,9 @@ async function doCcRun(argv) {
|
|
|
40539
40604
|
if (mid) models.push(`${pid}/${mid}`);
|
|
40540
40605
|
}
|
|
40541
40606
|
}
|
|
40542
|
-
|
|
40607
|
+
await writeStdout(JSON.stringify(models, null, 2) + "\n");
|
|
40543
40608
|
} catch (e) {
|
|
40544
|
-
|
|
40609
|
+
await writeStdout("[]\n");
|
|
40545
40610
|
process.stderr.write(`[cc-run] --list-models failed: ${e?.message}
|
|
40546
40611
|
`);
|
|
40547
40612
|
}
|
|
@@ -40626,21 +40691,20 @@ async function doCcRun(argv) {
|
|
|
40626
40691
|
emitTurn(result, model);
|
|
40627
40692
|
await flushStdout();
|
|
40628
40693
|
} else {
|
|
40629
|
-
|
|
40630
|
-
await flushStdout();
|
|
40694
|
+
await writeStdout(result.text.endsWith("\n") ? result.text : result.text + "\n");
|
|
40631
40695
|
}
|
|
40632
40696
|
return 0;
|
|
40633
40697
|
}
|
|
40634
|
-
function flushStdout() {
|
|
40635
|
-
return new Promise((resolve20) => process.stdout.write("", () => resolve20()));
|
|
40636
|
-
}
|
|
40637
40698
|
var CCRUN_VERSION, writeLine;
|
|
40638
40699
|
var init_cli_ccrun = __esm({
|
|
40639
40700
|
"src/cli-ccrun.ts"() {
|
|
40640
40701
|
"use strict";
|
|
40641
40702
|
init_secrets_env();
|
|
40703
|
+
init_cli_stdout();
|
|
40642
40704
|
CCRUN_VERSION = "7.1.57-ccrun";
|
|
40643
|
-
writeLine = (obj) =>
|
|
40705
|
+
writeLine = (obj) => {
|
|
40706
|
+
void writeStdout(JSON.stringify(obj) + "\n");
|
|
40707
|
+
};
|
|
40644
40708
|
}
|
|
40645
40709
|
});
|
|
40646
40710
|
|
|
@@ -41554,8 +41618,8 @@ function parseArgs(args) {
|
|
|
41554
41618
|
const configName = CONFIG_NAME;
|
|
41555
41619
|
return { stateDir, configPath: path40.join(stateDir, "configs", `${configName}.json`), configName, file: file2, badArgs };
|
|
41556
41620
|
}
|
|
41557
|
-
function emit2(obj) {
|
|
41558
|
-
|
|
41621
|
+
async function emit2(obj) {
|
|
41622
|
+
await writeStdout(JSON.stringify(obj) + "\n");
|
|
41559
41623
|
}
|
|
41560
41624
|
function put(obj, dotPath, val) {
|
|
41561
41625
|
const keys = dotPath.split(".");
|
|
@@ -41677,7 +41741,7 @@ async function runConfigCommand(args) {
|
|
|
41677
41741
|
return 2;
|
|
41678
41742
|
}
|
|
41679
41743
|
if (sub === "schema") {
|
|
41680
|
-
emit2({ version: 1, fields: listSchemaFields() });
|
|
41744
|
+
await emit2({ version: 1, fields: listSchemaFields() });
|
|
41681
41745
|
return 0;
|
|
41682
41746
|
}
|
|
41683
41747
|
if (sub === "get") {
|
|
@@ -41688,7 +41752,7 @@ async function runConfigCommand(args) {
|
|
|
41688
41752
|
for (const f of listFields()) {
|
|
41689
41753
|
if (f.type === "secret") names.add(secretEnvName(f.path, raw));
|
|
41690
41754
|
}
|
|
41691
|
-
emit2({
|
|
41755
|
+
await emit2({
|
|
41692
41756
|
values: raw,
|
|
41693
41757
|
secrets: readSecretStatus(p.stateDir, p.configName, [...names]),
|
|
41694
41758
|
// 与上面的状态**同源**(都取"第一个存在的候选")。绝不把写路径(恒为候选 #1)
|
|
@@ -41770,14 +41834,14 @@ async function runConfigCommand(args) {
|
|
|
41770
41834
|
flat[dotPath] = c.value;
|
|
41771
41835
|
}
|
|
41772
41836
|
if (errors.length > 0) {
|
|
41773
|
-
emit2({ ok: false, ineffective, errors });
|
|
41837
|
+
await emit2({ ok: false, ineffective, errors });
|
|
41774
41838
|
return 1;
|
|
41775
41839
|
}
|
|
41776
41840
|
const nested = {};
|
|
41777
41841
|
for (const [dotPath, v] of Object.entries(flat)) put(nested, dotPath, v);
|
|
41778
41842
|
const errs = validateAll(nested, current);
|
|
41779
41843
|
if (errs.length > 0) {
|
|
41780
|
-
emit2({ ok: false, ineffective: [], errors: errs });
|
|
41844
|
+
await emit2({ ok: false, ineffective: [], errors: errs });
|
|
41781
41845
|
return 1;
|
|
41782
41846
|
}
|
|
41783
41847
|
const merged = JSON.parse(JSON.stringify(current));
|
|
@@ -41827,7 +41891,7 @@ async function runConfigCommand(args) {
|
|
|
41827
41891
|
try {
|
|
41828
41892
|
writeConfigAtomic(p.configPath, merged);
|
|
41829
41893
|
} catch (e) {
|
|
41830
|
-
emit2({ ok: false, ineffective: [], errors: [{ path: p.configPath, error: e?.message || String(e) }] });
|
|
41894
|
+
await emit2({ ok: false, ineffective: [], errors: [{ path: p.configPath, error: e?.message || String(e) }] });
|
|
41831
41895
|
return 1;
|
|
41832
41896
|
}
|
|
41833
41897
|
for (const s of secretWrites) {
|
|
@@ -41856,7 +41920,7 @@ async function runConfigCommand(args) {
|
|
|
41856
41920
|
}
|
|
41857
41921
|
const changedDedup = [...new Set(changed)];
|
|
41858
41922
|
if (failed.length > 0) {
|
|
41859
|
-
emit2({
|
|
41923
|
+
await emit2({
|
|
41860
41924
|
ok: false,
|
|
41861
41925
|
ineffective: [],
|
|
41862
41926
|
failed: failed.map((f) => f.path),
|
|
@@ -41870,7 +41934,7 @@ async function runConfigCommand(args) {
|
|
|
41870
41934
|
});
|
|
41871
41935
|
return 1;
|
|
41872
41936
|
}
|
|
41873
|
-
emit2({
|
|
41937
|
+
await emit2({
|
|
41874
41938
|
ok: true,
|
|
41875
41939
|
changed: changedDedup,
|
|
41876
41940
|
needsRestart: needsRestart(changedDedup),
|
|
@@ -41881,7 +41945,7 @@ async function runConfigCommand(args) {
|
|
|
41881
41945
|
if (sub === "migrate") {
|
|
41882
41946
|
try {
|
|
41883
41947
|
const r = migrateChannelSecrets(p.configPath);
|
|
41884
|
-
emit2({
|
|
41948
|
+
await emit2({
|
|
41885
41949
|
ok: true,
|
|
41886
41950
|
changed: r.changed,
|
|
41887
41951
|
backup: r.backup,
|
|
@@ -41890,7 +41954,7 @@ async function runConfigCommand(args) {
|
|
|
41890
41954
|
});
|
|
41891
41955
|
return 0;
|
|
41892
41956
|
} catch (e) {
|
|
41893
|
-
emit2({
|
|
41957
|
+
await emit2({
|
|
41894
41958
|
ok: false,
|
|
41895
41959
|
changed: [],
|
|
41896
41960
|
errors: [{ path: p.configPath, error: e?.message || String(e) }]
|
|
@@ -41911,6 +41975,7 @@ var init_cli_config = __esm({
|
|
|
41911
41975
|
init_secrets_io();
|
|
41912
41976
|
init_secrets_env();
|
|
41913
41977
|
init_migrations2();
|
|
41978
|
+
init_cli_stdout();
|
|
41914
41979
|
init_persona();
|
|
41915
41980
|
init_channel_secrets();
|
|
41916
41981
|
CONFIG_NAME = "main7";
|
|
@@ -45288,6 +45353,7 @@ init_feishu_quick_register();
|
|
|
45288
45353
|
init_wechat();
|
|
45289
45354
|
init_qr_render();
|
|
45290
45355
|
init_cli_events();
|
|
45356
|
+
init_cli_stdout();
|
|
45291
45357
|
import * as readline3 from "node:readline";
|
|
45292
45358
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
45293
45359
|
|
|
@@ -46313,12 +46379,12 @@ async function main() {
|
|
|
46313
46379
|
if (subcommand === "doctor") {
|
|
46314
46380
|
const { runDoctor: runDoctor2, resolveStateDirFromArgs: resolveStateDirFromArgs2 } = await Promise.resolve().then(() => (init_cli_doctor(), cli_doctor_exports));
|
|
46315
46381
|
const stateDir = resolveStateDirFromArgs2(args.slice(1));
|
|
46316
|
-
|
|
46317
|
-
|
|
46382
|
+
await writeStdout(JSON.stringify(await runDoctor2(stateDir), null, 2) + "\n");
|
|
46383
|
+
await exitCli(0);
|
|
46318
46384
|
}
|
|
46319
46385
|
if (subcommand === "config") {
|
|
46320
46386
|
const { runConfigCommand: runConfigCommand2 } = await Promise.resolve().then(() => (init_cli_config(), cli_config_exports));
|
|
46321
|
-
|
|
46387
|
+
await exitCli(await runConfigCommand2(args.slice(1)));
|
|
46322
46388
|
}
|
|
46323
46389
|
if (subcommand === "mem-serve") {
|
|
46324
46390
|
const { runMemServe: runMemServe2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
|
|
@@ -46346,8 +46412,8 @@ async function main() {
|
|
|
46346
46412
|
// 和 init 写 config 的路径一致(cli-init.ts 里 configPath 就是这么拼的)
|
|
46347
46413
|
configPath: path51.join(stateDir, "configs", "main7.json")
|
|
46348
46414
|
});
|
|
46349
|
-
|
|
46350
|
-
|
|
46415
|
+
await writeStdout(JSON.stringify(result, null, 2) + "\n");
|
|
46416
|
+
await exitCli(0);
|
|
46351
46417
|
} catch (e) {
|
|
46352
46418
|
console.error(`\u9886\u53F7\u5931\u8D25\uFF1A${e?.message || e}`);
|
|
46353
46419
|
process.exit(1);
|
|
@@ -46470,7 +46536,7 @@ async function main() {
|
|
|
46470
46536
|
console.log(" \u4E0D\u91CD\u542F\u5F15\u64CE\u4F1A\u628A\u5B57\u9762\u91CF env:7YI_API_KEY \u5F53 key \u53D1\u51FA\u53BB \u2192 401\u3002");
|
|
46471
46537
|
console.log(" engine7 restart");
|
|
46472
46538
|
}
|
|
46473
|
-
|
|
46539
|
+
await exitCli(0);
|
|
46474
46540
|
}
|
|
46475
46541
|
if (channel === "discord") {
|
|
46476
46542
|
console.log("\u{1F527} Discord \u91CD\u914D\uFF08\u5F00\u53D1\u4E2D\uFF09");
|
|
@@ -46482,28 +46548,28 @@ async function main() {
|
|
|
46482
46548
|
const { createEmitter: createEmitter2 } = await Promise.resolve().then(() => (init_cli_events(), cli_events_exports));
|
|
46483
46549
|
if (events) redirectConsoleToStderr();
|
|
46484
46550
|
const code = await doReconfigFeishu2({ stateDir, configName, events, emit: events ? createEmitter2() : void 0 });
|
|
46485
|
-
|
|
46551
|
+
await exitCli(code);
|
|
46486
46552
|
}
|
|
46487
46553
|
if (channel === "wechat") {
|
|
46488
46554
|
const { doReconfigWechat: doReconfigWechat2 } = await Promise.resolve().then(() => (init_cli_reconfig(), cli_reconfig_exports));
|
|
46489
46555
|
const { createEmitter: createEmitter2 } = await Promise.resolve().then(() => (init_cli_events(), cli_events_exports));
|
|
46490
46556
|
if (events) redirectConsoleToStderr();
|
|
46491
46557
|
const code = await doReconfigWechat2({ stateDir, configName, events, emit: events ? createEmitter2() : void 0 });
|
|
46492
|
-
|
|
46558
|
+
await exitCli(code);
|
|
46493
46559
|
}
|
|
46494
46560
|
if (channel === "dingtalk") {
|
|
46495
46561
|
const { doReconfigDingtalk: doReconfigDingtalk2 } = await Promise.resolve().then(() => (init_cli_dingtalk_auth(), cli_dingtalk_auth_exports));
|
|
46496
46562
|
const { createEmitter: createEmitter2 } = await Promise.resolve().then(() => (init_cli_events(), cli_events_exports));
|
|
46497
46563
|
if (events) redirectConsoleToStderr();
|
|
46498
46564
|
const code = await doReconfigDingtalk2({ stateDir, configName, events, emit: events ? createEmitter2() : void 0 });
|
|
46499
|
-
|
|
46565
|
+
await exitCli(code);
|
|
46500
46566
|
}
|
|
46501
46567
|
if (channel === "wecom") {
|
|
46502
46568
|
const { doReconfigWecom: doReconfigWecom2 } = await Promise.resolve().then(() => (init_cli_wecom_auth(), cli_wecom_auth_exports));
|
|
46503
46569
|
const { createEmitter: createEmitter2 } = await Promise.resolve().then(() => (init_cli_events(), cli_events_exports));
|
|
46504
46570
|
if (events) redirectConsoleToStderr();
|
|
46505
46571
|
const code = await doReconfigWecom2({ stateDir, configName, events, emit: events ? createEmitter2() : void 0 });
|
|
46506
|
-
|
|
46572
|
+
await exitCli(code);
|
|
46507
46573
|
}
|
|
46508
46574
|
console.error(`\u672A\u77E5\u76EE\u6807: ${channel || "(\u7A7A)"}\u3002\u652F\u6301: wechat / feishu / dingtalk / wecom / discord / llm / channels`);
|
|
46509
46575
|
console.error("\u7528\u6CD5: engine7 reconfig <\u76EE\u6807> [--state-dir <path>] [--config <file>]");
|
|
@@ -46512,7 +46578,7 @@ async function main() {
|
|
|
46512
46578
|
if (subcommand === "cc-run") {
|
|
46513
46579
|
const { doCcRun: doCcRun2 } = await Promise.resolve().then(() => (init_cli_ccrun(), cli_ccrun_exports));
|
|
46514
46580
|
const code = await doCcRun2(args.slice(1));
|
|
46515
|
-
|
|
46581
|
+
await exitCli(code);
|
|
46516
46582
|
}
|
|
46517
46583
|
if (subcommand === "export") {
|
|
46518
46584
|
const { doExport: doExport2 } = await Promise.resolve().then(() => (init_cli_travel(), cli_travel_exports));
|
|
@@ -47380,10 +47446,10 @@ function readHomePointer() {
|
|
|
47380
47446
|
return null;
|
|
47381
47447
|
}
|
|
47382
47448
|
}
|
|
47383
|
-
main().catch((err) => {
|
|
47449
|
+
main().catch(async (err) => {
|
|
47384
47450
|
if (headlessEmit) headlessEmit({ event: "error", message: err.message });
|
|
47385
47451
|
console.error(`
|
|
47386
47452
|
\u274C \u5931\u8D25: ${err.message}`);
|
|
47387
47453
|
console.error(err.stack);
|
|
47388
|
-
|
|
47454
|
+
await exitCli(1);
|
|
47389
47455
|
});
|