engine7 7.1.148 → 7.1.150
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/bg-worker.mjs +263 -67
- package/dist/cc-desktop.mjs +48 -6
- package/dist/cli.mjs +4890 -3323
- package/dist/engine-startup.mjs +7296 -4302
- package/dist/main.mjs +7309 -4306
- package/dist/recall-worker.mjs +183 -42
- package/dist/topics-worker.mjs +185 -54
- package/dist/travel-gateway.mjs +378 -125
- package/dist/travel-host.mjs +944 -472
- package/dist/travel-node.mjs +2 -3
- package/dist/travel-oss-bundle-stream.mjs +13 -1
- package/dist/travel-pairing.mjs +384 -131
- package/dist/travel-sync-worker.mjs +235 -114
- package/dist/web-console.mjs +390 -147
- package/package.json +2 -2
package/dist/bg-worker.mjs
CHANGED
|
@@ -1315,7 +1315,9 @@ var tokenizer_exports = {};
|
|
|
1315
1315
|
__export(tokenizer_exports, {
|
|
1316
1316
|
DEFAULT_STOPWORDS: () => DEFAULT_STOPWORDS,
|
|
1317
1317
|
MIN_TOKEN_LENGTH: () => MIN_TOKEN_LENGTH,
|
|
1318
|
+
cjkBigrams: () => cjkBigrams,
|
|
1318
1319
|
tokenize: () => tokenize,
|
|
1320
|
+
tokenizeCjk: () => tokenizeCjk,
|
|
1319
1321
|
tokenizeToField: () => tokenizeToField
|
|
1320
1322
|
});
|
|
1321
1323
|
import { Jieba } from "@node-rs/jieba";
|
|
@@ -1338,6 +1340,16 @@ function tokenize(text2) {
|
|
|
1338
1340
|
function tokenizeToField(text2) {
|
|
1339
1341
|
return tokenize(text2).join(" ");
|
|
1340
1342
|
}
|
|
1343
|
+
function cjkBigrams(text2) {
|
|
1344
|
+
const out = [];
|
|
1345
|
+
for (const seg of String(text2 ?? "").match(/[\u4e00-\u9fff]{2,}/g) ?? []) {
|
|
1346
|
+
for (let i = 0; i + 1 < seg.length; i++) out.push(seg.slice(i, i + 2));
|
|
1347
|
+
}
|
|
1348
|
+
return out;
|
|
1349
|
+
}
|
|
1350
|
+
function tokenizeCjk(text2) {
|
|
1351
|
+
return [...tokenize(text2), ...cjkBigrams(text2)];
|
|
1352
|
+
}
|
|
1341
1353
|
var DEFAULT_STOPWORDS, MIN_TOKEN_LENGTH, jieba;
|
|
1342
1354
|
var init_tokenizer = __esm({
|
|
1343
1355
|
"src/mem7/core/tokenizer.ts"() {
|
|
@@ -6118,16 +6130,15 @@ function stripInjectedContext(text2) {
|
|
|
6118
6130
|
function escapeRegExp(s) {
|
|
6119
6131
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6120
6132
|
}
|
|
6121
|
-
var
|
|
6133
|
+
var SYSTEM_REMINDER_BLOCK, INJECT_SECTION_HEADS, KNOWN_INJECTED_TEXT, INJECTED_LINE_PREFIXES, XML_BLOCK;
|
|
6122
6134
|
var init_strip_injected = __esm({
|
|
6123
6135
|
"src/messages/strip-injected.ts"() {
|
|
6124
6136
|
"use strict";
|
|
6125
|
-
SKILL_GATE_HINT_PREFIX = "\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1";
|
|
6126
6137
|
SYSTEM_REMINDER_BLOCK = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
6127
6138
|
INJECT_SECTION_HEADS = /^(本轮对话|当前情绪状态|当前模式)/;
|
|
6128
6139
|
KNOWN_INJECTED_TEXT = [
|
|
6129
|
-
|
|
6130
|
-
// skill-gate
|
|
6140
|
+
"\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1",
|
|
6141
|
+
// 旧版 skill-gate 提示前缀,兼容未打标签的历史
|
|
6131
6142
|
"\u5F00\u53D1\u4EFB\u52A1\u8DEF\u6807\uFF0C\u6309\u573A\u666F\u5BF9\u53F7\u5165\u5EA7",
|
|
6132
6143
|
// skill-gate hint(0912 老文案,历史 JSONL 兼容)
|
|
6133
6144
|
"\u3010\u5B9A\u65F6\u5FC3\u8DF3\u3011\u8BF7 read HEARTBEAT.md"
|
|
@@ -9848,10 +9859,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
9848
9859
|
if (db2.isTransaction) throw new Error("REPLICATION_TRANSACTION_ALREADY_OPEN");
|
|
9849
9860
|
const exec = db2.exec, prepare = db2.prepare;
|
|
9850
9861
|
let active, failed = false, closed = false, reading = false;
|
|
9851
|
-
let
|
|
9862
|
+
let direct2;
|
|
9852
9863
|
const check = () => {
|
|
9853
9864
|
if (closed) throw new Error("REPLICATION_TRANSACTION_CLOSED");
|
|
9854
|
-
|
|
9865
|
+
direct2?.assertOpen();
|
|
9855
9866
|
};
|
|
9856
9867
|
const wrappedExec = function(sql) {
|
|
9857
9868
|
check();
|
|
@@ -9922,10 +9933,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
9922
9933
|
db2.prepare = checkedPrepare;
|
|
9923
9934
|
const transaction = (operation) => {
|
|
9924
9935
|
check();
|
|
9925
|
-
if (db2.isTransaction) return
|
|
9936
|
+
if (db2.isTransaction) return direct2.scope(operation);
|
|
9926
9937
|
db2.exec("BEGIN IMMEDIATE");
|
|
9927
9938
|
try {
|
|
9928
|
-
const result =
|
|
9939
|
+
const result = direct2.scope(operation);
|
|
9929
9940
|
if (result && typeof result.then === "function") throw new Error("REPLICATION_ASYNC_TRANSACTION");
|
|
9930
9941
|
db2.exec("COMMIT");
|
|
9931
9942
|
return result;
|
|
@@ -9934,10 +9945,10 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
9934
9945
|
throw error;
|
|
9935
9946
|
}
|
|
9936
9947
|
};
|
|
9937
|
-
|
|
9948
|
+
direct2 = installAutocommitCapture(db2, transaction);
|
|
9938
9949
|
return {
|
|
9939
9950
|
assertOpen: check,
|
|
9940
|
-
scope: (operation) =>
|
|
9951
|
+
scope: (operation) => direct2.scope(operation),
|
|
9941
9952
|
transaction,
|
|
9942
9953
|
close() {
|
|
9943
9954
|
if (closed) return;
|
|
@@ -9946,7 +9957,7 @@ function installSQLiteWriteCapture(db2, source) {
|
|
|
9946
9957
|
source.endCapture(active);
|
|
9947
9958
|
active = void 0;
|
|
9948
9959
|
}
|
|
9949
|
-
|
|
9960
|
+
direct2.close();
|
|
9950
9961
|
db2.prepare = prepare;
|
|
9951
9962
|
db2.exec = exec;
|
|
9952
9963
|
closed = true;
|
|
@@ -10266,18 +10277,31 @@ function forgotten(b, path22) {
|
|
|
10266
10277
|
}
|
|
10267
10278
|
function openIndex(b, version) {
|
|
10268
10279
|
if (!b.stateDir || !b.topicsDir) return null;
|
|
10269
|
-
const root = topicsHistoryRoot(b);
|
|
10280
|
+
const root = topicsHistoryRoot(b), expectedRoot = resolve7(b.topicsDir);
|
|
10281
|
+
let selected = "", actualRoot;
|
|
10270
10282
|
try {
|
|
10271
|
-
|
|
10283
|
+
selected = version ?? readJson(join13(root, "current.json")).version;
|
|
10272
10284
|
if (!/^[a-f0-9-]{36}$/.test(selected)) throw new Error("INVALID_HISTORY_VERSION");
|
|
10273
10285
|
const db2 = new DatabaseSync7(unlinked(join13(root, selected, "history.db")), { readOnly: true });
|
|
10274
10286
|
const meta = db2.prepare("SELECT value FROM metadata WHERE key=?").get("binding");
|
|
10275
|
-
if (meta?.value !== canonical({ scope: topicsScope(b), root:
|
|
10287
|
+
if (meta?.value !== canonical({ scope: topicsScope(b), root: expectedRoot })) {
|
|
10288
|
+
try {
|
|
10289
|
+
actualRoot = String(JSON.parse(meta?.value ?? "{}").root ?? "") || void 0;
|
|
10290
|
+
} catch {
|
|
10291
|
+
actualRoot = meta?.value;
|
|
10292
|
+
}
|
|
10276
10293
|
db2.close();
|
|
10277
10294
|
throw new Error("HISTORY_SCOPE_MISMATCH");
|
|
10278
10295
|
}
|
|
10279
10296
|
return db2;
|
|
10280
|
-
} catch {
|
|
10297
|
+
} catch (error) {
|
|
10298
|
+
if (error instanceof Error && error.message === "HISTORY_SCOPE_MISMATCH") {
|
|
10299
|
+
const signature2 = `${expectedRoot}|${actualRoot ?? ""}`;
|
|
10300
|
+
if (!scopeMismatchWarned.has(signature2)) {
|
|
10301
|
+
scopeMismatchWarned.add(signature2);
|
|
10302
|
+
console.warn(`[topics-history] HISTORY_SCOPE_MISMATCH\uFF1A\u7D22\u5F15\u7ED1\u5B9A\u7684 topics \u6839\u76EE\u5F55\u4E0E\u5F53\u524D\u4E0D\u7B26\uFF0C\u5386\u53F2\u68C0\u7D22\u672C\u6B21\u4E3A\u7A7A\u4E14\u4E0D\u4F1A\u81EA\u6108\uFF08\u9700\u91CD\u5EFA\uFF09\u3002expected root=${expectedRoot} actual root=${actualRoot ?? "(unreadable)"} version=${selected} index=${join13(root, selected, "history.db")}`);
|
|
10303
|
+
}
|
|
10304
|
+
}
|
|
10281
10305
|
return null;
|
|
10282
10306
|
}
|
|
10283
10307
|
}
|
|
@@ -10471,15 +10495,15 @@ async function publishTopicsIndex(bundle, cleaned, b) {
|
|
|
10471
10495
|
const md = /(?:^|-)\d{2}-\d{2}$/.test(d.value) ? d.value.slice(-5) : void 0;
|
|
10472
10496
|
return [d.value, d.year?.toString() ?? "", ...md ? [md, `${Number(md.slice(0, 2))}\u6708${Number(md.slice(-2))}\u65E5`] : []];
|
|
10473
10497
|
});
|
|
10474
|
-
const terms =
|
|
10498
|
+
const terms = tokenizeCjk(`${paragraph}
|
|
10475
10499
|
${aliases.join(" ")}`);
|
|
10476
10500
|
documentTerms.push(...terms);
|
|
10477
|
-
search.run(id, [...
|
|
10501
|
+
search.run(id, [...tokenizeCjk(item.originalMetadata.title), ...terms].join(" "));
|
|
10478
10502
|
}
|
|
10479
10503
|
start = end;
|
|
10480
10504
|
}
|
|
10481
10505
|
}
|
|
10482
|
-
if (documentTerms.length) documentInsert.run(item.path, item.originalHash, [...
|
|
10506
|
+
if (documentTerms.length) documentInsert.run(item.path, item.originalHash, [...tokenizeCjk(item.originalMetadata.title), ...documentTerms].join(" "));
|
|
10483
10507
|
}
|
|
10484
10508
|
db2.exec("COMMIT");
|
|
10485
10509
|
if (db2.prepare("PRAGMA integrity_check").get().integrity_check !== "ok") throw new Error("HISTORY_INDEX_INVALID");
|
|
@@ -10500,7 +10524,7 @@ async function searchTopicsHistory(b, query, options = {}) {
|
|
|
10500
10524
|
const before = mem7StartDate(b);
|
|
10501
10525
|
const year = topicQueryYear(query, options);
|
|
10502
10526
|
const normalized = query.replace(/(?<!\d)(?:19|20)\d{2}\s*年?(?!\d)/g, "").replace(/去年|今年/g, "");
|
|
10503
|
-
const terms = [...new Set(
|
|
10527
|
+
const terms = [...new Set(tokenizeCjk(normalized))].slice(0, 24);
|
|
10504
10528
|
if (!terms.length && year !== void 0) terms.push(String(year));
|
|
10505
10529
|
if (!terms.length) return [];
|
|
10506
10530
|
const match = terms.map((term) => `"${term.replace(/"/g, '""')}"`).join(" OR ");
|
|
@@ -10511,7 +10535,7 @@ async function searchTopicsHistory(b, query, options = {}) {
|
|
|
10511
10535
|
for (const row of rows) {
|
|
10512
10536
|
const ref = JSON.parse(row.ref);
|
|
10513
10537
|
const words = terms.filter((term) => !/^\d+[年月日]?$/.test(term));
|
|
10514
|
-
if (words.length && !words.some((term) =>
|
|
10538
|
+
if (words.length && !words.some((term) => tokenizeCjk(row.body + " " + row.title).includes(term))) continue;
|
|
10515
10539
|
try {
|
|
10516
10540
|
const hit = getTopicHistory(b, ref, before);
|
|
10517
10541
|
if (!topicMatchesYear(hit.dates, year)) continue;
|
|
@@ -10554,7 +10578,7 @@ async function searchTopicsHistory(b, query, options = {}) {
|
|
|
10554
10578
|
db2.close();
|
|
10555
10579
|
}
|
|
10556
10580
|
}
|
|
10557
|
-
var topicsScope, key3, rootKey, refPath, refId, fallbackChecks, credential2;
|
|
10581
|
+
var topicsScope, key3, rootKey, refPath, refId, scopeMismatchWarned, fallbackChecks, credential2;
|
|
10558
10582
|
var init_topics_history = __esm({
|
|
10559
10583
|
"src/memory/topics-history/index.ts"() {
|
|
10560
10584
|
"use strict";
|
|
@@ -10569,6 +10593,7 @@ var init_topics_history = __esm({
|
|
|
10569
10593
|
rootKey = (b) => digest3(resolve7(b.topicsDir));
|
|
10570
10594
|
refPath = (ref) => `topics-history://${Buffer.from(canonical(ref)).toString("base64url")}`;
|
|
10571
10595
|
refId = (ref) => digest3(canonical(ref));
|
|
10596
|
+
scopeMismatchWarned = /* @__PURE__ */ new Set();
|
|
10572
10597
|
fallbackChecks = /* @__PURE__ */ new Map();
|
|
10573
10598
|
credential2 = /(?:api[_-]?key|password|secret|access[_-]?token)["']?\s*[:=]\s*["']?(?!YOUR_|PLACEHOLDER|\*|\[REDACTED\]|env:|\{\{)[\w/+.-]{10,}|-----BEGIN (?:RSA |OPENSSH |EC )?PRIVATE KEY-----|\bsk-[A-Za-z0-9_-]{20,}/i;
|
|
10574
10599
|
}
|
|
@@ -10612,6 +10637,8 @@ function attachmentToMessage(attachment) {
|
|
|
10612
10637
|
${attachment.notifications.join("\n\n")}`
|
|
10613
10638
|
)
|
|
10614
10639
|
};
|
|
10640
|
+
case "coldstart_hint":
|
|
10641
|
+
return { role: "user", content: wrapInSystemReminder(attachment.text) };
|
|
10615
10642
|
case "teammate_messages": {
|
|
10616
10643
|
const lines = attachment.messages.map(
|
|
10617
10644
|
(m) => m.summary ? `[From: ${m.from}] ${m.summary}
|
|
@@ -10808,6 +10835,10 @@ function parseAttachmentFromJsonl(raw) {
|
|
|
10808
10835
|
timestamp: raw.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
10809
10836
|
};
|
|
10810
10837
|
}
|
|
10838
|
+
case "coldstart_hint": {
|
|
10839
|
+
if (typeof attachment.text !== "string" || !attachment.text.trim()) return null;
|
|
10840
|
+
return { type: "attachment", attachment: { type: "coldstart_hint", text: attachment.text }, uuid: raw.uuid || randomUUID7(), timestamp: raw.timestamp || (/* @__PURE__ */ new Date()).toISOString() };
|
|
10841
|
+
}
|
|
10811
10842
|
case "mcp_instructions_delta":
|
|
10812
10843
|
case "task_notification":
|
|
10813
10844
|
case "teammate_messages": {
|
|
@@ -13975,32 +14006,32 @@ CREATE TABLE IF NOT EXISTS cluster_members (
|
|
|
13975
14006
|
return { built: !hasStats, ms: Date.now() - started };
|
|
13976
14007
|
}
|
|
13977
14008
|
async close() {
|
|
13978
|
-
const
|
|
14009
|
+
const errors2 = [];
|
|
13979
14010
|
try {
|
|
13980
14011
|
this.capture?.close();
|
|
13981
14012
|
} catch (error) {
|
|
13982
|
-
|
|
14013
|
+
errors2.push(error);
|
|
13983
14014
|
}
|
|
13984
14015
|
try {
|
|
13985
14016
|
this.db.close();
|
|
13986
14017
|
} catch (error) {
|
|
13987
|
-
|
|
14018
|
+
errors2.push(error);
|
|
13988
14019
|
}
|
|
13989
14020
|
try {
|
|
13990
14021
|
await this.vectors?.close();
|
|
13991
14022
|
} catch (error) {
|
|
13992
|
-
|
|
14023
|
+
errors2.push(error);
|
|
13993
14024
|
} finally {
|
|
13994
14025
|
this.vectors = null;
|
|
13995
14026
|
}
|
|
13996
14027
|
try {
|
|
13997
14028
|
this.releaseRuntimeWriter?.();
|
|
13998
14029
|
} catch (error) {
|
|
13999
|
-
|
|
14030
|
+
errors2.push(error);
|
|
14000
14031
|
} finally {
|
|
14001
14032
|
this.releaseRuntimeWriter = void 0;
|
|
14002
14033
|
}
|
|
14003
|
-
if (
|
|
14034
|
+
if (errors2.length) throw new AggregateError(errors2, "MEM7_CLOSE_FAILED");
|
|
14004
14035
|
}
|
|
14005
14036
|
// ── memcell 账本 ──────────────────────────────────────────
|
|
14006
14037
|
insertMemcell(cell) {
|
|
@@ -15283,7 +15314,7 @@ var init_capture_cache = __esm({
|
|
|
15283
15314
|
});
|
|
15284
15315
|
|
|
15285
15316
|
// src/travel/apply-transaction.ts
|
|
15286
|
-
import { closeSync as closeSync7, existsSync as existsSync8, fsyncSync as fsyncSync6, lstatSync as lstatSync9, mkdirSync as mkdirSync10, openSync as openSync7, readFileSync as readFileSync12, readSync as readSync2, renameSync as renameSync6, rmSync, writeFileSync as writeFileSync8 } from "node:fs";
|
|
15317
|
+
import { closeSync as closeSync7, existsSync as existsSync8, fsyncSync as fsyncSync6, linkSync, lstatSync as lstatSync9, mkdirSync as mkdirSync10, openSync as openSync7, readFileSync as readFileSync12, readSync as readSync2, renameSync as renameSync6, rmSync, writeFileSync as writeFileSync8 } from "node:fs";
|
|
15287
15318
|
import { dirname as dirname7, join as join15, resolve as resolve8 } from "node:path";
|
|
15288
15319
|
import { createHash as createHash21, randomUUID as randomUUID11 } from "node:crypto";
|
|
15289
15320
|
function assertPath(root, rel) {
|
|
@@ -15299,7 +15330,7 @@ function assertPath(root, rel) {
|
|
|
15299
15330
|
}
|
|
15300
15331
|
return path22;
|
|
15301
15332
|
}
|
|
15302
|
-
function atomic(path22, body) {
|
|
15333
|
+
function atomic(path22, body, exclusive = false) {
|
|
15303
15334
|
const temp = path22 + "." + randomUUID11() + ".tmp";
|
|
15304
15335
|
let fd;
|
|
15305
15336
|
try {
|
|
@@ -15308,7 +15339,8 @@ function atomic(path22, body) {
|
|
|
15308
15339
|
fsyncSync6(fd);
|
|
15309
15340
|
closeSync7(fd);
|
|
15310
15341
|
fd = void 0;
|
|
15311
|
-
|
|
15342
|
+
if (exclusive) linkSync(temp, path22);
|
|
15343
|
+
else renameSync6(temp, path22);
|
|
15312
15344
|
} finally {
|
|
15313
15345
|
if (fd !== void 0) closeSync7(fd);
|
|
15314
15346
|
rmSync(temp, { force: true });
|
|
@@ -20899,7 +20931,8 @@ CREATE INDEX IF NOT EXISTS idx_proactive_decisions_created ON proactive_decision
|
|
|
20899
20931
|
this.noteCascade(id);
|
|
20900
20932
|
this.db.prepare(`UPDATE actions SET basis_state='dirty',action_version=action_version+1,
|
|
20901
20933
|
cancel_requested=CASE WHEN status='executing' THEN 1 ELSE cancel_requested END,
|
|
20902
|
-
status=CASE WHEN status='queued' THEN 'cancelled' ELSE status END
|
|
20934
|
+
status=CASE WHEN status='queued' THEN 'cancelled' ELSE status END,
|
|
20935
|
+
cancel_reason=COALESCE(cancel_reason, CASE WHEN status='queued' THEN 'graph_basis_changed' END)
|
|
20903
20936
|
WHERE intent_id=? AND status IN ('queued','executing')`).run(id);
|
|
20904
20937
|
this.db.prepare("UPDATE intent_runs SET state='stale',reason_code='graph_basis_changed',finished_at=? WHERE intent_id=? AND state='running'").run(Date.now(), id);
|
|
20905
20938
|
pending2.push(...this.dependencies.children(scope, [{ kind: "node", id }]));
|
|
@@ -20984,11 +21017,12 @@ CREATE INDEX IF NOT EXISTS idx_proactive_decisions_created ON proactive_decision
|
|
|
20984
21017
|
a.note ?? null
|
|
20985
21018
|
);
|
|
20986
21019
|
}
|
|
20987
|
-
/** status='queued' AND scheduled_time<=now
|
|
20988
|
-
dueActions(now2, limit = 20) {
|
|
21020
|
+
/** status='queued' AND scheduled_time<=now,按时间升序。excludeIds:sweep 翻页绕开已看过的(守卫跳过的) */
|
|
21021
|
+
dueActions(now2, limit = 20, excludeIds = []) {
|
|
20989
21022
|
const rows = this.db.prepare(
|
|
20990
|
-
`SELECT * FROM actions WHERE status='queued' AND scheduled_time <= ?
|
|
20991
|
-
|
|
21023
|
+
`SELECT * FROM actions WHERE status='queued' AND scheduled_time <= ?
|
|
21024
|
+
AND id NOT IN (SELECT value FROM json_each(?)) ORDER BY scheduled_time ASC LIMIT ?`
|
|
21025
|
+
).all(now2, JSON.stringify(excludeIds), limit);
|
|
20992
21026
|
return rows.map(rowToAction);
|
|
20993
21027
|
}
|
|
20994
21028
|
/** queued 状态 action 的 intent_id 集合(去重) */
|
|
@@ -24695,6 +24729,10 @@ function isSameCommitment(a, b) {
|
|
|
24695
24729
|
if (y.length >= 4 && x.includes(y)) return true;
|
|
24696
24730
|
return false;
|
|
24697
24731
|
}
|
|
24732
|
+
function guardVerdict(value) {
|
|
24733
|
+
if (typeof value === "boolean") return { ok: value, reason: value ? "" : "GUARD_REJECTED" };
|
|
24734
|
+
return { ok: value.ok, reason: value.reason ?? (value.ok ? "" : "GUARD_REJECTED") };
|
|
24735
|
+
}
|
|
24698
24736
|
function actionPayload(a, now2, recentEvidence) {
|
|
24699
24737
|
let suggestedTask = null;
|
|
24700
24738
|
let scheduledLocal = null;
|
|
@@ -24740,7 +24778,7 @@ function actionPayload(a, now2, recentEvidence) {
|
|
|
24740
24778
|
_received_at: now2.toISOString()
|
|
24741
24779
|
};
|
|
24742
24780
|
}
|
|
24743
|
-
var BACKLOG_ALERT_RUNS, STALE_HINT_HOURS, DEFAULT_PROMPT, Sweep;
|
|
24781
|
+
var BACKLOG_ALERT_RUNS, STALE_HINT_HOURS, DEFAULT_PROMPT, TRANSIENT_GUARD_REASONS, DUE_PAGE_SIZE, DUE_MAX_PAGES, transientGuardLogged, Sweep;
|
|
24744
24782
|
var init_sweep = __esm({
|
|
24745
24783
|
"src/memory/proactive/sweep.ts"() {
|
|
24746
24784
|
"use strict";
|
|
@@ -24764,6 +24802,10 @@ var init_sweep = __esm({
|
|
|
24764
24802
|
\u62FF \`generated_at_local\` \u8DDF \`_received_at\` \u5BF9\u4E00\u4E0B\uFF1B\u518D\u8DDF calendar/goal \u91CC\u5DF2\u6709\u7684\u5BF9\u4E00\u904D\u3002
|
|
24765
24803
|
6. **urgency \u662F\u53C2\u8003**\uFF08urgent=\u51E0\u5C0F\u65F6/high=24h/medium=48h/low=\u4E00\u5468\uFF09\uFF0C\u6309\u5B9E\u9645\u60C5\u51B5\u5224\u65AD
|
|
24766
24804
|
7. \u51B3\u5B9A\u544A\u8BC9 TA \u65F6\u7528\u4F60\u81EA\u5DF1\u7684\u8BED\u6C14\u2014\u2014\u8FD9\u662F\u4F60\u7684\u4E3B\u52A8\u5173\u6000\uFF0C\u4E0D\u662F\u7CFB\u7EDF\u901A\u77E5`;
|
|
24805
|
+
TRANSIENT_GUARD_REASONS = /* @__PURE__ */ new Set(["MEMORY_GUARD_UNAVAILABLE", "ACTION_DELIVERY_UNKNOWN", "CALENDAR_DELIVERY_UNKNOWN", "MEMORY_SCHEMA_UNSUPPORTED", "EXECUTION_CONTEXT_INVALID"]);
|
|
24806
|
+
DUE_PAGE_SIZE = 20;
|
|
24807
|
+
DUE_MAX_PAGES = 5;
|
|
24808
|
+
transientGuardLogged = /* @__PURE__ */ new Set();
|
|
24767
24809
|
Sweep = class {
|
|
24768
24810
|
constructor(deps, intervalMs = 3e5) {
|
|
24769
24811
|
this.deps = deps;
|
|
@@ -24819,9 +24861,40 @@ var init_sweep = __esm({
|
|
|
24819
24861
|
console.warn(`[proactive] backlog alert failed: ${err.message}`);
|
|
24820
24862
|
}
|
|
24821
24863
|
}
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
|
|
24864
|
+
const nowIso2 = now2.toISOString();
|
|
24865
|
+
const gatedItems = [];
|
|
24866
|
+
const gateOff = (a, reason) => {
|
|
24867
|
+
gatedItems.push({ id: a.id, title: a.title, reason, version: a.actionVersion });
|
|
24868
|
+
return false;
|
|
24869
|
+
};
|
|
24870
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24871
|
+
let due = [];
|
|
24872
|
+
for (let page = 0; page < DUE_MAX_PAGES; page++) {
|
|
24873
|
+
const batch = this.deps.persist.dueActions(nowIso2, DUE_PAGE_SIZE, [...seen]);
|
|
24874
|
+
for (const action of batch) {
|
|
24875
|
+
seen.add(action.id);
|
|
24876
|
+
if (!this.deps.checkAction) {
|
|
24877
|
+
due.push(action);
|
|
24878
|
+
continue;
|
|
24879
|
+
}
|
|
24880
|
+
const verdict = guardVerdict(this.deps.checkAction(action));
|
|
24881
|
+
if (verdict.ok) {
|
|
24882
|
+
due.push(action);
|
|
24883
|
+
continue;
|
|
24884
|
+
}
|
|
24885
|
+
if (TRANSIENT_GUARD_REASONS.has(verdict.reason)) {
|
|
24886
|
+
const signature2 = `${action.id}:${verdict.reason}`;
|
|
24887
|
+
if (!transientGuardLogged.has(signature2)) {
|
|
24888
|
+
transientGuardLogged.add(signature2);
|
|
24889
|
+
console.log(`[proactive] \u6295\u9012\u524D\u5B88\u536B\u6682\u6001\u62D2\u7EDD\uFF0C\u672C\u8F6E\u8DF3\u8FC7\uFF1A\u300C${action.title.slice(0, 24)}\u300D${verdict.reason}`);
|
|
24890
|
+
}
|
|
24891
|
+
continue;
|
|
24892
|
+
}
|
|
24893
|
+
gateOff(action, `\u6295\u9012\u524D\u5B88\u536B\uFF1A${verdict.reason}`);
|
|
24894
|
+
}
|
|
24895
|
+
if (batch.length < DUE_PAGE_SIZE || due.length >= DUE_PAGE_SIZE) break;
|
|
24896
|
+
}
|
|
24897
|
+
if (due.length === 0 && gatedItems.length === 0) return 0;
|
|
24825
24898
|
const opportunityGroups = [];
|
|
24826
24899
|
for (const action of due.filter((item) => item.scopeId && item.provenance?.decisionType === "opportunity")) {
|
|
24827
24900
|
const matches2 = opportunityGroups.filter((group) => group.some((item) => item.scopeId === action.scopeId && isSameCommitment(item.title, action.title)));
|
|
@@ -24857,11 +24930,6 @@ var init_sweep = __esm({
|
|
|
24857
24930
|
}
|
|
24858
24931
|
console.log(`[proactive] R2: ${resolvedActions.length} due action(s) cancelled (intent resolved)`);
|
|
24859
24932
|
}
|
|
24860
|
-
const gatedItems = [];
|
|
24861
|
-
const gateOff = (a, reason) => {
|
|
24862
|
-
gatedItems.push({ id: a.id, title: a.title, reason, version: a.actionVersion });
|
|
24863
|
-
return false;
|
|
24864
|
-
};
|
|
24865
24933
|
const coveredTitles = this.deps.coveredTitles ?? [];
|
|
24866
24934
|
const coveredEvents = this.deps.coveredEvents ?? [];
|
|
24867
24935
|
if (coveredTitles.length > 0 || coveredEvents.length > 0) {
|
|
@@ -25259,6 +25327,19 @@ function findForesightFiles(everosRoot) {
|
|
|
25259
25327
|
walk(everosRoot, 0);
|
|
25260
25328
|
return files;
|
|
25261
25329
|
}
|
|
25330
|
+
function opportunityScheduledTime(now2, concrete) {
|
|
25331
|
+
const nowMs = now2.getTime();
|
|
25332
|
+
let closesAt = Number.POSITIVE_INFINITY;
|
|
25333
|
+
for (const ref of concrete) {
|
|
25334
|
+
if (ref.parentKind !== "scope") continue;
|
|
25335
|
+
const match = ref.parentId.match(/^valid-window:(-?\d+):(-?\d+)$/);
|
|
25336
|
+
if (!match) continue;
|
|
25337
|
+
closesAt = Math.min(closesAt, Number(match[2]));
|
|
25338
|
+
}
|
|
25339
|
+
if (!Number.isFinite(closesAt)) return new Date(nowMs + OPPORTUNITY_DELAY_MS);
|
|
25340
|
+
if (closesAt <= nowMs) return null;
|
|
25341
|
+
return new Date(Math.max(nowMs, Math.min(nowMs + OPPORTUNITY_DELAY_MS, closesAt - OPPORTUNITY_WINDOW_MARGIN_MS)));
|
|
25342
|
+
}
|
|
25262
25343
|
async function runOpportunityScan(deps) {
|
|
25263
25344
|
const { persist, now: now2 } = deps;
|
|
25264
25345
|
const captured = deps.memory && deps.memory.store.readTransaction(() => {
|
|
@@ -25503,7 +25584,7 @@ ${captured ? captured.actionEvidence.get(n.id) ?? `\u4EC5\u80CC\u666F\uFF0C\u4E0
|
|
|
25503
25584
|
intentId: id,
|
|
25504
25585
|
title: opportunity.title,
|
|
25505
25586
|
description: `[\u4E3B\u52A8\u5EFA\u8BAE\uFF0C\u5C5E\u4E8E\u63A8\u65AD] ${opportunity.description}`,
|
|
25506
|
-
scheduledTime: new Date(now2.getTime() +
|
|
25587
|
+
scheduledTime: (opportunityScheduledTime(now2, captured.concrete) ?? new Date(now2.getTime() + OPPORTUNITY_DELAY_MS)).toISOString(),
|
|
25507
25588
|
urgency: "low",
|
|
25508
25589
|
durationMinutes: 10,
|
|
25509
25590
|
calendarId: null,
|
|
@@ -25560,7 +25641,7 @@ ${captured ? captured.actionEvidence.get(n.id) ?? `\u4EC5\u80CC\u666F\uFF0C\u4E0
|
|
|
25560
25641
|
}
|
|
25561
25642
|
return enqueued;
|
|
25562
25643
|
}
|
|
25563
|
-
var OPPORTUNITY_SCAN_INTERVAL_MS, PROFILE_RE, foresightCache, FORESIGHT_CACHE_TTL_MS, FORESIGHT_TEXT_MAX, FS_MATCH_STOP;
|
|
25644
|
+
var OPPORTUNITY_SCAN_INTERVAL_MS, PROFILE_RE, foresightCache, FORESIGHT_CACHE_TTL_MS, FORESIGHT_TEXT_MAX, FS_MATCH_STOP, OPPORTUNITY_DELAY_MS, OPPORTUNITY_WINDOW_MARGIN_MS;
|
|
25564
25645
|
var init_opportunity = __esm({
|
|
25565
25646
|
"src/memory/proactive/opportunity.ts"() {
|
|
25566
25647
|
"use strict";
|
|
@@ -25590,6 +25671,8 @@ var init_opportunity = __esm({
|
|
|
25590
25671
|
FORESIGHT_CACHE_TTL_MS = 30 * 6e4;
|
|
25591
25672
|
FORESIGHT_TEXT_MAX = 150;
|
|
25592
25673
|
FS_MATCH_STOP = /* @__PURE__ */ new Set(["\u65F6\u5019", "\u4E1C\u897F", "\u73B0\u5728", "\u4ECA\u5929", "\u660E\u5929", "\u4EE5\u540E", "\u6700\u8FD1", "\u60C5\u51B5", "\u95EE\u9898", "\u4E8B\u60C5", "\u7EE7\u7EED", "\u5F00\u59CB", "\u51C6\u5907", "\u8FDB\u884C", "\u8003\u8651", "\u5B89\u6392", "\u76F8\u5173", "\u5982\u4E0B", "\u4EE5\u53CA", "\u7136\u540E", "\u6240\u4EE5", "\u4F46\u662F", "\u8FD9\u4E2A", "\u90A3\u4E2A", "\u4E00\u4E2A", "\u4EC0\u4E48", "\u600E\u4E48", "\u54B1\u4EEC", "\u4ED6\u4EEC", "\u81EA\u5DF1", "\u53EF\u4EE5", "\u6CA1\u6709", "\u5C31\u662F", "\u8FD8\u662F", "\u5DF2\u7ECF", "\u5982\u679C", "\u56E0\u4E3A", "\u8FD9\u6837", "\u90A3\u6837", "\u4E00\u4E0B", "\u7684\u8BDD", "\u4E0A\u53BB", "\u4E0B\u6765", "\u51FA\u6765", "\u77E5\u9053", "\u89C9\u5F97", "\u5E94\u8BE5", "\u53EF\u80FD"]);
|
|
25674
|
+
OPPORTUNITY_DELAY_MS = 30 * 6e4;
|
|
25675
|
+
OPPORTUNITY_WINDOW_MARGIN_MS = 10 * 6e4;
|
|
25593
25676
|
}
|
|
25594
25677
|
});
|
|
25595
25678
|
|
|
@@ -25916,13 +25999,15 @@ function beginSkillGate(sessionId) {
|
|
|
25916
25999
|
function isUserChannel(ch) {
|
|
25917
26000
|
return !!ch && USER_CHANNELS.has(ch);
|
|
25918
26001
|
}
|
|
25919
|
-
var USER_CHANNELS, loadedBySession, MAX_TRACKED_SESSIONS;
|
|
26002
|
+
var USER_CHANNELS, SKILL_CHANNELS, loadedBySession, MAX_TRACKED_SESSIONS;
|
|
25920
26003
|
var init_skill_gate = __esm({
|
|
25921
26004
|
"src/skills/skill-gate.ts"() {
|
|
25922
26005
|
"use strict";
|
|
25923
26006
|
init_strip_injected();
|
|
26007
|
+
init_writer();
|
|
25924
26008
|
init_cpu_router_scene();
|
|
25925
26009
|
USER_CHANNELS = /* @__PURE__ */ new Set(["discord", "feishu", "wechat", "telegram", "cli", "console", "voice-chat", "deskBuddy", "ccBridge"]);
|
|
26010
|
+
SKILL_CHANNELS = /* @__PURE__ */ new Set([...USER_CHANNELS, "chan7", "webhook"]);
|
|
25926
26011
|
loadedBySession = /* @__PURE__ */ new Map();
|
|
25927
26012
|
MAX_TRACKED_SESSIONS = 100;
|
|
25928
26013
|
}
|
|
@@ -26710,8 +26795,125 @@ var init_provider = __esm({
|
|
|
26710
26795
|
}
|
|
26711
26796
|
});
|
|
26712
26797
|
|
|
26798
|
+
// src/services/adaptive-proxy.ts
|
|
26799
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
26800
|
+
import { Agent, Client, ProxyAgent, errors } from "undici";
|
|
26801
|
+
function proxyAddress(value) {
|
|
26802
|
+
const bareLoopback = /^(?:localhost\.?|127(?:\.\d{1,3}){3}|\[::1\]):\d+$/i;
|
|
26803
|
+
return new URL(bareLoopback.test(value) ? `http://${value}` : value);
|
|
26804
|
+
}
|
|
26805
|
+
function localProxyKey(url) {
|
|
26806
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
26807
|
+
const host = url.hostname.replace(/\.$/, "");
|
|
26808
|
+
if (host !== "localhost" && host !== "[::1]" && !/^127\./.test(host)) return;
|
|
26809
|
+
return `${host}:${url.port || (url.protocol === "https:" ? 443 : 80)}`;
|
|
26810
|
+
}
|
|
26811
|
+
function proxyUnavailable(key5) {
|
|
26812
|
+
return (unreachableUntil.get(key5) ?? -Infinity) > Date.now();
|
|
26813
|
+
}
|
|
26814
|
+
function markUnavailable(key5) {
|
|
26815
|
+
unreachableUntil.set(key5, Date.now() + RETRY_PROXY_AFTER_MS);
|
|
26816
|
+
}
|
|
26817
|
+
function isTcpDialFailure(error) {
|
|
26818
|
+
if (error instanceof AggregateError) {
|
|
26819
|
+
return error.errors.length > 0 && error.errors.every(isTcpDialFailure);
|
|
26820
|
+
}
|
|
26821
|
+
const err = error;
|
|
26822
|
+
return err?.syscall === "connect" && dialFailureCodes.has(err.code ?? "");
|
|
26823
|
+
}
|
|
26824
|
+
function getProxyDispatcher(value) {
|
|
26825
|
+
const raw = value?.trim();
|
|
26826
|
+
if (!raw) return;
|
|
26827
|
+
const cached = dispatchers.get(raw);
|
|
26828
|
+
if (cached) return cached;
|
|
26829
|
+
const url = proxyAddress(raw);
|
|
26830
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
26831
|
+
throw new Error(
|
|
26832
|
+
`\u4E0D\u652F\u6301\u7684\u4EE3\u7406\u534F\u8BAE ${url.protocol}\uFF08\u4EC5 http/https \u53EF\u76F4\u63A5\u4F7F\u7528\uFF1Bsocks5 \u7B49\u8BF7\u5148\u8F6C\u6210 http \u4EE3\u7406\uFF0C\u5982 gost/privoxy\uFF09\uFF1A${raw}`
|
|
26833
|
+
);
|
|
26834
|
+
}
|
|
26835
|
+
const key5 = localProxyKey(url);
|
|
26836
|
+
const dispatcher = key5 ? new AdaptiveProxyDispatcher(url.href, key5) : new ProxyAgent({ uri: url.href });
|
|
26837
|
+
dispatchers.set(raw, dispatcher);
|
|
26838
|
+
return dispatcher;
|
|
26839
|
+
}
|
|
26840
|
+
var RETRY_PROXY_AFTER_MS, LOCAL_CONNECT_TIMEOUT_MS, unreachableUntil, failedProxyDials, dispatchers, direct, dialFailureCodes, AdaptiveProxyDispatcher;
|
|
26841
|
+
var init_adaptive_proxy = __esm({
|
|
26842
|
+
"src/services/adaptive-proxy.ts"() {
|
|
26843
|
+
"use strict";
|
|
26844
|
+
RETRY_PROXY_AFTER_MS = 5e3;
|
|
26845
|
+
LOCAL_CONNECT_TIMEOUT_MS = 1e3;
|
|
26846
|
+
unreachableUntil = /* @__PURE__ */ new Map();
|
|
26847
|
+
failedProxyDials = /* @__PURE__ */ new WeakSet();
|
|
26848
|
+
dispatchers = /* @__PURE__ */ new Map();
|
|
26849
|
+
direct = new Agent();
|
|
26850
|
+
dialFailureCodes = /* @__PURE__ */ new Set(["ECONNREFUSED", "ETIMEDOUT", "ENETUNREACH", "EHOSTUNREACH", "EADDRNOTAVAIL"]);
|
|
26851
|
+
AdaptiveProxyDispatcher = class extends ProxyAgent {
|
|
26852
|
+
constructor(uri, key5) {
|
|
26853
|
+
super({
|
|
26854
|
+
uri,
|
|
26855
|
+
proxyTls: { timeout: LOCAL_CONNECT_TIMEOUT_MS },
|
|
26856
|
+
clientFactory(origin, opts) {
|
|
26857
|
+
const { connect } = opts;
|
|
26858
|
+
return new Client(origin, {
|
|
26859
|
+
connect(options, callback) {
|
|
26860
|
+
let tcpConnected = false;
|
|
26861
|
+
const socket = connect(options, (...result) => {
|
|
26862
|
+
const [error] = result;
|
|
26863
|
+
if (error && !tcpConnected && (isTcpDialFailure(error) || error.code === "UND_ERR_CONNECT_TIMEOUT")) {
|
|
26864
|
+
markUnavailable(key5);
|
|
26865
|
+
failedProxyDials.add(error);
|
|
26866
|
+
}
|
|
26867
|
+
callback(...result);
|
|
26868
|
+
});
|
|
26869
|
+
socket.once("connect", () => {
|
|
26870
|
+
tcpConnected = true;
|
|
26871
|
+
});
|
|
26872
|
+
return socket;
|
|
26873
|
+
}
|
|
26874
|
+
});
|
|
26875
|
+
}
|
|
26876
|
+
});
|
|
26877
|
+
this.key = key5;
|
|
26878
|
+
}
|
|
26879
|
+
dispatch(options, handler) {
|
|
26880
|
+
if (!this.closed && !this.destroyed && proxyUnavailable(this.key)) {
|
|
26881
|
+
const headers = options.headers;
|
|
26882
|
+
const keys = !headers ? [] : Array.isArray(headers) ? headers.filter((_, index) => index % 2 === 0) : Symbol.iterator in headers ? Array.from(headers, ([name]) => name) : Object.keys(headers);
|
|
26883
|
+
if (keys.some((name) => name.toLowerCase() === "proxy-authorization")) {
|
|
26884
|
+
throw new errors.InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
|
|
26885
|
+
}
|
|
26886
|
+
return direct.dispatch(options, handler);
|
|
26887
|
+
}
|
|
26888
|
+
let connected = false;
|
|
26889
|
+
const extended = handler;
|
|
26890
|
+
const guarded = {
|
|
26891
|
+
onConnect: (abort) => {
|
|
26892
|
+
connected = true;
|
|
26893
|
+
handler.onConnect?.(abort);
|
|
26894
|
+
},
|
|
26895
|
+
onError: (error) => {
|
|
26896
|
+
if (!connected && failedProxyDials.has(error)) {
|
|
26897
|
+
direct.dispatch(options, handler);
|
|
26898
|
+
} else {
|
|
26899
|
+
handler.onError?.(error);
|
|
26900
|
+
}
|
|
26901
|
+
},
|
|
26902
|
+
onHeaders: handler.onHeaders?.bind(handler),
|
|
26903
|
+
onData: handler.onData?.bind(handler),
|
|
26904
|
+
onComplete: handler.onComplete?.bind(handler),
|
|
26905
|
+
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
26906
|
+
onResponseStarted: handler.onResponseStarted?.bind(handler),
|
|
26907
|
+
onBodySent: handler.onBodySent?.bind(handler),
|
|
26908
|
+
onRequestSent: extended.onRequestSent?.bind(handler)
|
|
26909
|
+
};
|
|
26910
|
+
return super.dispatch(options, guarded);
|
|
26911
|
+
}
|
|
26912
|
+
};
|
|
26913
|
+
}
|
|
26914
|
+
});
|
|
26915
|
+
|
|
26713
26916
|
// src/services/withRetry.ts
|
|
26714
|
-
import { ProxyAgent } from "undici";
|
|
26715
26917
|
function sleep(ms, signal) {
|
|
26716
26918
|
return new Promise((resolve26, reject) => {
|
|
26717
26919
|
if (signal?.aborted) {
|
|
@@ -26779,15 +26981,6 @@ function shouldRetry(status, errorBody) {
|
|
|
26779
26981
|
if (errorBody?.includes('"type":"overloaded_error"')) return true;
|
|
26780
26982
|
return false;
|
|
26781
26983
|
}
|
|
26782
|
-
function getProxyDispatcher(proxyUrl) {
|
|
26783
|
-
if (!proxyUrl) return void 0;
|
|
26784
|
-
let agent = proxyAgentCache.get(proxyUrl);
|
|
26785
|
-
if (!agent) {
|
|
26786
|
-
agent = new ProxyAgent({ uri: proxyUrl });
|
|
26787
|
-
proxyAgentCache.set(proxyUrl, agent);
|
|
26788
|
-
}
|
|
26789
|
-
return agent;
|
|
26790
|
-
}
|
|
26791
26984
|
async function* fetchWithRetry(url, init, providerLabel, proxy, beforeRequest, retryPolicy) {
|
|
26792
26985
|
const configuredRetries = getMaxRetries();
|
|
26793
26986
|
const maxRetries = retryPolicy?.maxRetries === void 0 ? configuredRetries : Math.min(configuredRetries, Math.max(0, Math.floor(retryPolicy.maxRetries)));
|
|
@@ -26925,10 +27118,11 @@ function readWithTimeout(reader, timeoutMs, signal) {
|
|
|
26925
27118
|
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
26926
27119
|
});
|
|
26927
27120
|
}
|
|
26928
|
-
var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS
|
|
27121
|
+
var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS;
|
|
26929
27122
|
var init_withRetry = __esm({
|
|
26930
27123
|
"src/services/withRetry.ts"() {
|
|
26931
27124
|
"use strict";
|
|
27125
|
+
init_adaptive_proxy();
|
|
26932
27126
|
DEFAULT_MAX_RETRIES = 10;
|
|
26933
27127
|
BASE_DELAY_MS = 500;
|
|
26934
27128
|
MAX_DELAY_MS = 32e3;
|
|
@@ -26936,7 +27130,6 @@ var init_withRetry = __esm({
|
|
|
26936
27130
|
READ_TIMEOUT_MS = 6e4;
|
|
26937
27131
|
FIRST_READ_TIMEOUT_MS = parseInt(process.env.API_TIMEOUT_MS || "", 10) || 6e5;
|
|
26938
27132
|
NO_PROGRESS_TIMEOUT_MS = parseInt(process.env.STREAM_NO_PROGRESS_TIMEOUT_MS || "", 10) || 3e5;
|
|
26939
|
-
proxyAgentCache = /* @__PURE__ */ new Map();
|
|
26940
27133
|
}
|
|
26941
27134
|
});
|
|
26942
27135
|
|
|
@@ -31477,8 +31670,8 @@ async function warmReadStore(stateDir2) {
|
|
|
31477
31670
|
const t0 = Date.now();
|
|
31478
31671
|
try {
|
|
31479
31672
|
const store = getReadStore(stateDir2);
|
|
31480
|
-
const { tokenize:
|
|
31481
|
-
|
|
31673
|
+
const { tokenize: tokenize3 } = await Promise.resolve().then(() => (init_tokenizer(), tokenizer_exports));
|
|
31674
|
+
tokenize3("");
|
|
31482
31675
|
const vs = store.vectorStore();
|
|
31483
31676
|
for (const kind of ["episode", "atomic_fact", "foresight", "agent_case", "agent_skill"]) {
|
|
31484
31677
|
try {
|
|
@@ -33830,11 +34023,12 @@ ${String(input.tool_output ?? "")}`
|
|
|
33830
34023
|
const pluginCalDb = this.calDb;
|
|
33831
34024
|
this.sweep = new Sweep({
|
|
33832
34025
|
persist: this.persist,
|
|
33833
|
-
|
|
34026
|
+
// 1201(#445):回整个判定(带 reason)——sweep 据此当场 cancelled 带原因,不再静默滤掉
|
|
34027
|
+
checkAction: (action) => !action.scopeId ? true : checkMemoryExecution(String(liveConfig.get("stateDir") ?? ""), workspace2, {
|
|
33834
34028
|
scopeId: action.scopeId,
|
|
33835
34029
|
basisRefs: action.basisRefs ?? [],
|
|
33836
34030
|
actionVersions: { [action.id]: action.actionVersion }
|
|
33837
|
-
})
|
|
34031
|
+
}),
|
|
33838
34032
|
promptFile: join40(workspace2, "prompts", "proactive.md"),
|
|
33839
34033
|
// 三个都走 getter **每轮现读** —— 热加载规则(config 改了立刻生效)+
|
|
33840
34034
|
// calendar 会变,都不能在 start() 时快照。
|
|
@@ -39584,7 +39778,9 @@ var init_tool_loading = __esm({
|
|
|
39584
39778
|
["gmail", ["\u90AE\u7BB1", "\u90AE\u4EF6"]],
|
|
39585
39779
|
["device_data", ["\u8BBE\u5907\u8D44\u6599", "\u65E5\u5386", "\u63D0\u9192\u4E8B\u9879", "\u901A\u8BAF\u5F55", "\u8054\u7CFB\u4EBA", "\u5907\u5FD8\u5F55", "\u7167\u7247", "\u5065\u5EB7"]],
|
|
39586
39780
|
["cc_ask", ["\u5C0FC", "\u684C\u9762CC", "Claude Code"]],
|
|
39587
|
-
["cc_progress", ["\u5C0FC", "\u684C\u9762CC", "Claude Code"]]
|
|
39781
|
+
["cc_progress", ["\u5C0FC", "\u684C\u9762CC", "Claude Code"]],
|
|
39782
|
+
["cc_new", ["\u5C0FC", "\u684C\u9762CC", "Claude Code", "\u65B0\u5EFA CC \u4F1A\u8BDD"]],
|
|
39783
|
+
["cc_stop", ["\u5C0FC", "\u684C\u9762CC", "Claude Code", "\u505C\u6B62 CC \u4EFB\u52A1"]]
|
|
39588
39784
|
]);
|
|
39589
39785
|
}
|
|
39590
39786
|
});
|
|
@@ -44332,12 +44528,12 @@ function createSqliteMaintenance(stateDir2, options = {}) {
|
|
|
44332
44528
|
child = fork(entry, ["--sqlite-maintenance", path22, JSON.stringify({ stateDir: stateDir2, minFreeBytes: options.minFreeBytes })], launchOptions);
|
|
44333
44529
|
console.log("[bg-worker] SQLite physical reclaim started");
|
|
44334
44530
|
const current2 = child;
|
|
44335
|
-
let output = "",
|
|
44531
|
+
let output = "", errors2 = "";
|
|
44336
44532
|
current2.stdout?.on("data", (data) => {
|
|
44337
44533
|
output = (output + String(data)).slice(-4096);
|
|
44338
44534
|
});
|
|
44339
44535
|
current2.stderr?.on("data", (data) => {
|
|
44340
|
-
|
|
44536
|
+
errors2 = (errors2 + String(data)).slice(-4096);
|
|
44341
44537
|
});
|
|
44342
44538
|
current2.on("message", (message) => {
|
|
44343
44539
|
if (message?.type === "sqliteMaintenancePhase") options.onPhase?.(message.phase);
|
|
@@ -44353,7 +44549,7 @@ function createSqliteMaintenance(stateDir2, options = {}) {
|
|
|
44353
44549
|
if (child === current2) child = void 0;
|
|
44354
44550
|
nextCheck = Date.now() + (options.checkIntervalMs ?? 6e4);
|
|
44355
44551
|
if (code === 0 && output.trim()) console.log(`[bg-worker] SQLite physical reclaim ${output.trim()}`);
|
|
44356
|
-
else console.log(`[bg-worker] SQLite physical reclaim deferred${
|
|
44552
|
+
else console.log(`[bg-worker] SQLite physical reclaim deferred${errors2 ? `: ${errors2.trim()}` : " (input or shutdown)"}`);
|
|
44357
44553
|
resolve26();
|
|
44358
44554
|
};
|
|
44359
44555
|
current2.once("close", finish);
|