engine7 7.1.145 → 7.1.146

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/main.mjs CHANGED
@@ -1801,19 +1801,19 @@ import { dirname as dirname2, join as join3, resolve as resolve3 } from "node:pa
1801
1801
  import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
1802
1802
  function assertPath(root, rel) {
1803
1803
  if (!safeRel(rel)) throw Error("TRAVEL_UNSAFE_PATH");
1804
- let path119 = root;
1804
+ let path120 = root;
1805
1805
  for (const part of rel.split("/")) {
1806
- path119 = join3(path119, part);
1806
+ path120 = join3(path120, part);
1807
1807
  try {
1808
- if (lstatSync(path119).isSymbolicLink()) throw Error("TRAVEL_UNSAFE_PATH");
1808
+ if (lstatSync(path120).isSymbolicLink()) throw Error("TRAVEL_UNSAFE_PATH");
1809
1809
  } catch (e) {
1810
1810
  if (e.code !== "ENOENT") throw e;
1811
1811
  }
1812
1812
  }
1813
- return path119;
1813
+ return path120;
1814
1814
  }
1815
- function atomic(path119, body2) {
1816
- const temp = path119 + "." + randomUUID2() + ".tmp";
1815
+ function atomic(path120, body2) {
1816
+ const temp = path120 + "." + randomUUID2() + ".tmp";
1817
1817
  let fd;
1818
1818
  try {
1819
1819
  fd = openSync2(temp, "wx", 384);
@@ -1821,7 +1821,7 @@ function atomic(path119, body2) {
1821
1821
  fsyncSync2(fd);
1822
1822
  closeSync2(fd);
1823
1823
  fd = void 0;
1824
- renameSync2(temp, path119);
1824
+ renameSync2(temp, path120);
1825
1825
  } finally {
1826
1826
  if (fd !== void 0) closeSync2(fd);
1827
1827
  rmSync(temp, { force: true });
@@ -1833,9 +1833,9 @@ function read(root) {
1833
1833
  if (value.version !== 1 || value.root !== resolve3(root) || !Number.isSafeInteger(value.pid) || value.pid < 1 || !/^[a-f0-9-]{36}$/.test(value.token) || typeof value.committed !== "boolean" || digest8 !== hash(JSON.stringify(body2)) || !Array.isArray(value.entries) || value.entries.some((e) => !safeRel(e.rel) || e.oldSha !== void 0 && !/^[a-f0-9]{64}$/.test(e.oldSha) || e.newSha !== void 0 && !/^[a-f0-9]{64}$/.test(e.newSha))) throw Error("TRAVEL_APPLY_RECOVERY_INVALID");
1834
1834
  return value;
1835
1835
  }
1836
- function matches(path119, sha3) {
1837
- if (!existsSync4(path119)) return false;
1838
- const fd = openSync2(path119, "r"), digest8 = createHash4("sha256"), buffer = Buffer.alloc(1048576);
1836
+ function matches(path120, sha3) {
1837
+ if (!existsSync4(path120)) return false;
1838
+ const fd = openSync2(path120, "r"), digest8 = createHash4("sha256"), buffer = Buffer.alloc(1048576);
1839
1839
  try {
1840
1840
  for (; ; ) {
1841
1841
  const n = readSync(fd, buffer, 0, buffer.length, null);
@@ -1905,14 +1905,14 @@ var init_apply_transaction = __esm({
1905
1905
  import { randomUUID as randomUUID3, verify } from "node:crypto";
1906
1906
  import { constants, closeSync as closeSync3, existsSync as existsSync5, fstatSync, fsyncSync as fsyncSync3, lstatSync as lstatSync2, mkdirSync as mkdirSync3, openSync as openSync3, readFileSync as readFileSync5, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
1907
1907
  import { basename as basename2, dirname as dirname3, join as join4, resolve as resolve4 } from "node:path";
1908
- function assertPrivateDirectory(path119) {
1909
- const stat4 = lstatSync2(path119);
1908
+ function assertPrivateDirectory(path120) {
1909
+ const stat4 = lstatSync2(path120);
1910
1910
  if (!stat4.isDirectory() || stat4.isSymbolicLink() || process.platform !== "win32" && (stat4.uid !== process.getuid() || stat4.mode & 63)) throw new Error("TRAVEL_PRIVATE_CONTROL_REQUIRED");
1911
1911
  }
1912
- function readPrivateFile(path119, maximum) {
1913
- const before = lstatSync2(path119);
1912
+ function readPrivateFile(path120, maximum) {
1913
+ const before = lstatSync2(path120);
1914
1914
  if (!before.isFile() || before.isSymbolicLink() || process.platform !== "win32" && (before.uid !== process.getuid() || before.mode & 63)) throw new Error("TRAVEL_PRIVATE_CONTROL_REQUIRED");
1915
- const fd = openSync3(path119, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
1915
+ const fd = openSync3(path120, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
1916
1916
  try {
1917
1917
  if (fstatSync(fd).size > maximum) throw new Error("TRAVEL_INVALID_CONTROL");
1918
1918
  return readFileSync5(fd);
@@ -1920,12 +1920,12 @@ function readPrivateFile(path119, maximum) {
1920
1920
  closeSync3(fd);
1921
1921
  }
1922
1922
  }
1923
- function writeControl(path119, value) {
1924
- const temporary = path119 + "." + randomUUID3() + ".tmp";
1923
+ function writeControl(path120, value) {
1924
+ const temporary = path120 + "." + randomUUID3() + ".tmp";
1925
1925
  writeFileSync4(temporary, JSON.stringify(value), { mode: 384, flag: "wx", flush: true });
1926
- renameSync3(temporary, path119);
1926
+ renameSync3(temporary, path120);
1927
1927
  if (process.platform !== "win32") {
1928
- const fd = openSync3(dirname3(path119), "r");
1928
+ const fd = openSync3(dirname3(path120), "r");
1929
1929
  try {
1930
1930
  fsyncSync3(fd);
1931
1931
  } finally {
@@ -2794,9 +2794,9 @@ function normalize2(input) {
2794
2794
  if (!input || !/^[a-f0-9]{64}$/.test(input.schemaHash)) throw new Error("REPLICATION_REGISTRATION_INVALID");
2795
2795
  return Object.freeze({ binding: normalizeBinding(input.binding), schemaHash: input.schemaHash });
2796
2796
  }
2797
- function directory(path119) {
2798
- const info = lstatSync3(path119);
2799
- if (!info.isDirectory() || info.isSymbolicLink() || realpathSync(path119) !== resolve5(path119) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid()))
2797
+ function directory(path120) {
2798
+ const info = lstatSync3(path120);
2799
+ if (!info.isDirectory() || info.isSymbolicLink() || realpathSync(path120) !== resolve5(path120) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid()))
2800
2800
  throw new Error("REPLICATION_REGISTRATION_INVALID");
2801
2801
  }
2802
2802
  function readRuntimeReplicationRegistration(stateDir, component, key6) {
@@ -5907,8 +5907,8 @@ var init_recovery_deletion = __esm({
5907
5907
  const { owners, parents } = this.links(table, row);
5908
5908
  for (const parent of parents) for (const owner of owners) this.edge(parent, owner);
5909
5909
  if (table === "memory_artifact_publications") {
5910
- const medium = text(row, "medium"), path119 = text(row, "path"), physicalId = text(row, "physical_id"), kind = text(row, "kind");
5911
- const identity3 = medium === "markdown" && path119 ? "file:mem7/" + path119 : medium === "vector" && physicalId && kind ? "vector:" + kind + "/rows/" + createHash12("sha256").update(physicalId).digest("hex") + ".arrow" : void 0;
5910
+ const medium = text(row, "medium"), path120 = text(row, "path"), physicalId = text(row, "physical_id"), kind = text(row, "kind");
5911
+ const identity3 = medium === "markdown" && path120 ? "file:mem7/" + path120 : medium === "vector" && physicalId && kind ? "vector:" + kind + "/rows/" + createHash12("sha256").update(physicalId).digest("hex") + ".arrow" : void 0;
5912
5912
  if (identity3) {
5913
5913
  const rows = this.artifactPaths.get(identity3) ?? [];
5914
5914
  rows.push(row);
@@ -5916,8 +5916,8 @@ var init_recovery_deletion = __esm({
5916
5916
  }
5917
5917
  }
5918
5918
  }
5919
- blocksArtifactPath(kind, path119) {
5920
- const rows = this.artifactPaths.get(kind + ":" + path119);
5919
+ blocksArtifactPath(kind, path120) {
5920
+ const rows = this.artifactPaths.get(kind + ":" + path120);
5921
5921
  return rows?.some((row) => this.blocks("memory_artifact_publications", row));
5922
5922
  }
5923
5923
  blocks(table, row) {
@@ -6558,9 +6558,9 @@ function assertPrivateStat(stat4, directory2) {
6558
6558
  if ((directory2 ? !stat4.isDirectory() : !stat4.isFile()) || process.platform !== "win32" && ((stat4.mode & 63) !== 0 || stat4.uid !== process.getuid?.()))
6559
6559
  throw new Error("KEY_SERVICE_PRIVATE_PATH_REQUIRED");
6560
6560
  }
6561
- function readPrivateFile2(path119, maximumBytes = 65536) {
6562
- assertPrivateStat(lstatSync6(path119), false);
6563
- const fd = openSync6(path119, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
6561
+ function readPrivateFile2(path120, maximumBytes = 65536) {
6562
+ assertPrivateStat(lstatSync6(path120), false);
6563
+ const fd = openSync6(path120, constants4.O_RDONLY | (constants4.O_NOFOLLOW ?? 0));
6564
6564
  try {
6565
6565
  const stat4 = fstatSync3(fd);
6566
6566
  assertPrivateStat(stat4, false);
@@ -6590,23 +6590,23 @@ import {
6590
6590
  mkdirSync as mkdirSync8
6591
6591
  } from "node:fs";
6592
6592
  import { join as join8, dirname as dirname5, resolve as resolve6 } from "node:path";
6593
- function assertPrivateDirectory2(path119) {
6594
- const info = lstatSync7(path119);
6595
- if (!info.isDirectory() || info.isSymbolicLink() || realpathSync3(path119) !== resolve6(path119) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid()))
6593
+ function assertPrivateDirectory2(path120) {
6594
+ const info = lstatSync7(path120);
6595
+ if (!info.isDirectory() || info.isSymbolicLink() || realpathSync3(path120) !== resolve6(path120) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid()))
6596
6596
  throw new Error("PUBLICATION_PRIVATE_DIRECTORY_REQUIRED");
6597
6597
  }
6598
- function syncDir(path119) {
6598
+ function syncDir(path120) {
6599
6599
  if (process.platform === "win32") return;
6600
- const fd = openSync7(path119, constants5.O_RDONLY);
6600
+ const fd = openSync7(path120, constants5.O_RDONLY);
6601
6601
  try {
6602
6602
  fsyncSync6(fd);
6603
6603
  } finally {
6604
6604
  closeSync7(fd);
6605
6605
  }
6606
6606
  }
6607
- function preparePrivateDirectory(path119) {
6607
+ function preparePrivateDirectory(path120) {
6608
6608
  const missing = [];
6609
- let parent = resolve6(path119);
6609
+ let parent = resolve6(path120);
6610
6610
  for (; ; ) {
6611
6611
  try {
6612
6612
  lstatSync7(parent);
@@ -6627,10 +6627,10 @@ function preparePrivateDirectory(path119) {
6627
6627
  assertPrivateDirectory2(directory2);
6628
6628
  syncDir(dirname5(directory2));
6629
6629
  }
6630
- assertPrivateDirectory2(path119);
6630
+ assertPrivateDirectory2(path120);
6631
6631
  }
6632
- function preparePrivateDatabase(path119) {
6633
- for (const file3 of [path119, path119 + "-journal", path119 + "-wal", path119 + "-shm"]) {
6632
+ function preparePrivateDatabase(path120) {
6633
+ for (const file3 of [path120, path120 + "-journal", path120 + "-wal", path120 + "-shm"]) {
6634
6634
  try {
6635
6635
  const info2 = lstatSync7(file3);
6636
6636
  if (!info2.isFile() || info2.isSymbolicLink() || process.platform !== "win32" && (info2.mode & 63 || info2.uid !== process.getuid()))
@@ -6640,15 +6640,15 @@ function preparePrivateDatabase(path119) {
6640
6640
  }
6641
6641
  }
6642
6642
  try {
6643
- const fd = openSync7(path119, "wx", 384);
6643
+ const fd = openSync7(path120, "wx", 384);
6644
6644
  closeSync7(fd);
6645
6645
  } catch (error) {
6646
6646
  if (error.code !== "EEXIST") throw error;
6647
6647
  }
6648
- const info = lstatSync7(path119);
6648
+ const info = lstatSync7(path120);
6649
6649
  if (!info.isFile() || info.isSymbolicLink() || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid()))
6650
6650
  throw new Error("PUBLICATION_PRIVATE_FILE_REQUIRED");
6651
- syncDir(dirname5(path119));
6651
+ syncDir(dirname5(path120));
6652
6652
  }
6653
6653
  var PUBLICATION_CHUNK_BYTES, MAGIC, INLINE_BYTES, noFollow;
6654
6654
  var init_publication_objects = __esm({
@@ -8809,23 +8809,23 @@ var init_facts = __esm({
8809
8809
  if ((exception || proposal.changeKind === "exception") && (!exception || schedule.frequency !== "once")) throw new Error("OCCURRENCE_EXCEPTION_REQUIRED");
8810
8810
  }
8811
8811
  for (const [index, evidence] of proposal.evidence.entries()) {
8812
- const path119 = `evidence[${index}]`;
8813
- if (!evidence || typeof evidence !== "object") throw new Error(`INVALID_EVIDENCE_SPAN: ${path119} \u2014 \u6BCF\u6761\u8BC1\u636E\u987B\u662F\u5BF9\u8C61 {sourceId, quote, relation}`);
8812
+ const path120 = `evidence[${index}]`;
8813
+ if (!evidence || typeof evidence !== "object") throw new Error(`INVALID_EVIDENCE_SPAN: ${path120} \u2014 \u6BCF\u6761\u8BC1\u636E\u987B\u662F\u5BF9\u8C61 {sourceId, quote, relation}`);
8814
8814
  const source = this.db.prepare(`SELECT text,role,origin_class,interpretation_status FROM memory_sources s WHERE scope_id=? AND source_id=?
8815
8815
  AND NOT EXISTS (SELECT 1 FROM memory_sources newer WHERE newer.scope_id=s.scope_id
8816
8816
  AND newer.origin_key=s.origin_key AND newer.source_version>s.source_version)`).get(scopeId(scope), evidence.sourceId ?? null);
8817
- if (!source || source.interpretation_status === "deleted") throw new Error(`INVALID_EVIDENCE_SPAN: ${path119}.sourceId \u2014 \u672C\u6C60\u8BFB\u4E0D\u5230\u8FD9\u6761\u6765\u6E90\uFF08\u4E0D\u5B58\u5728\u3001\u5DF2\u5220\u9664\u6216\u5DF2\u6709\u65B0\u7248\u672C\uFF09\uFF1B\u7528 memory_get({source_id}) \u6838\u5BF9\u5E76\u590D\u5236\u771F\u5B9E\u6765\u6E90 ID`);
8818
- if (typeof evidence.quote !== "string" || !evidence.quote) throw new Error(`INVALID_EVIDENCE_SPAN: ${path119}.quote \u2014 quote \u5FC5\u586B\uFF0C\u9010\u5B57\u51FA\u81EA\u6765\u6E90\u539F\u6587`);
8817
+ if (!source || source.interpretation_status === "deleted") throw new Error(`INVALID_EVIDENCE_SPAN: ${path120}.sourceId \u2014 \u672C\u6C60\u8BFB\u4E0D\u5230\u8FD9\u6761\u6765\u6E90\uFF08\u4E0D\u5B58\u5728\u3001\u5DF2\u5220\u9664\u6216\u5DF2\u6709\u65B0\u7248\u672C\uFF09\uFF1B\u7528 memory_get({source_id}) \u6838\u5BF9\u5E76\u590D\u5236\u771F\u5B9E\u6765\u6E90 ID`);
8818
+ if (typeof evidence.quote !== "string" || !evidence.quote) throw new Error(`INVALID_EVIDENCE_SPAN: ${path120}.quote \u2014 quote \u5FC5\u586B\uFF0C\u9010\u5B57\u51FA\u81EA\u6765\u6E90\u539F\u6587`);
8819
8819
  if (!Number.isSafeInteger(evidence.start) || !Number.isSafeInteger(evidence.end) || evidence.start < 0 || evidence.end <= evidence.start || evidence.end > source.text.length || source.text.slice(evidence.start, evidence.end) !== evidence.quote) {
8820
8820
  const count = occurrences(source.text, evidence.quote);
8821
- throw new Error(count === 0 ? `INVALID_EVIDENCE_SPAN: ${path119}.quote \u2014 \u5F15\u6587\u5FC5\u987B\u9010\u5B57\u51FA\u81EA\u6765\u6E90\u539F\u6587\uFF08\u539F\u6587\u957F ${source.text.length}\uFF09\uFF1B\u7528 memory_get({source_id}) \u590D\u5236\u539F\u53E5\uFF0C\u4E0D\u8981\u6539\u5199` : `INVALID_EVIDENCE_SPAN: ${path119} \u2014 \u5F15\u6587\u5728\u539F\u6587\u4E2D\u51FA\u73B0 ${count} \u6B21\uFF0C\u8BF7\u7ED9\u51C6\u786E\u7684\u90A3\u4E00\u5904 start/end\uFF08UTF-16 \u4E0B\u6807\uFF0C\u539F\u6587\u957F ${source.text.length}\uFF09`);
8821
+ throw new Error(count === 0 ? `INVALID_EVIDENCE_SPAN: ${path120}.quote \u2014 \u5F15\u6587\u5FC5\u987B\u9010\u5B57\u51FA\u81EA\u6765\u6E90\u539F\u6587\uFF08\u539F\u6587\u957F ${source.text.length}\uFF09\uFF1B\u7528 memory_get({source_id}) \u590D\u5236\u539F\u53E5\uFF0C\u4E0D\u8981\u6539\u5199` : `INVALID_EVIDENCE_SPAN: ${path120} \u2014 \u5F15\u6587\u5728\u539F\u6587\u4E2D\u51FA\u73B0 ${count} \u6B21\uFF0C\u8BF7\u7ED9\u51C6\u786E\u7684\u90A3\u4E00\u5904 start/end\uFF08UTF-16 \u4E0B\u6807\uFF0C\u539F\u6587\u957F ${source.text.length}\uFF09`);
8822
8822
  }
8823
- if (!["supports", "refutes"].includes(evidence.relation)) throw new Error(`INVALID_EVIDENCE_SPAN: ${path119}.relation \u2014 \u53EA\u80FD\u662F supports\uFF08\u652F\u6301\uFF09\u6216 refutes\uFF08\u53CD\u9A73\uFF09`);
8823
+ if (!["supports", "refutes"].includes(evidence.relation)) throw new Error(`INVALID_EVIDENCE_SPAN: ${path120}.relation \u2014 \u53EA\u80FD\u662F supports\uFF08\u652F\u6301\uFF09\u6216 refutes\uFF08\u53CD\u9A73\uFF09`);
8824
8824
  const relationValue = proposal.value;
8825
8825
  if (proposal.predicate === "relation.open" && relationValue?.attribution === "reported" && (proposal.claimKind !== "reported_statement" || !hasReportedAttribution(source.text, relationValue, this.entities.sourceMentions(scope, evidence.sourceId)))) {
8826
8826
  throw new Error("EVIDENCE_REPORTED_ATTRIBUTION_UNGROUNDED: attribution=reported \u65F6 claimKind \u987B\u4E3A reported_statement\uFF0C\u4E14 attributionQuote \u5FC5\u987B\u662F\u539F\u8BDD\u91CC\u9010\u5B57\u7684\u8F6C\u8FF0\u53E5\uFF08\u5982\u300C\u67D0\u67D0\u8BF4\uFF1A\u300D\uFF09");
8827
8827
  }
8828
- const roleMismatch = () => new Error(`EVIDENCE_ROLE_MISMATCH: ${path119} \u7684\u4F5C\u8005/\u89D2\u8272\u4E0E claimKind=${proposal.claimKind} \u4E0D\u7B26\uFF08\u6765\u6E90 role=${source.role}, originClass=${source.origin_class}\uFF09 \u2014 \u7528\u6237\u539F\u8BDD\u914D user_statement\u3001\u5DE5\u5177\u7ED3\u679C\u914D tool_observation\u3001\u8F6C\u8FF0\u4ED6\u4EBA\u914D reported_statement\u3001\u4F60\u81EA\u5DF1\u8BF4\u7684\u8BDD\u914D agent_statement\uFF1B\u6362\u5339\u914D\u7684\u6765\u6E90\u6216\u6539 claimKind`);
8828
+ const roleMismatch = () => new Error(`EVIDENCE_ROLE_MISMATCH: ${path120} \u7684\u4F5C\u8005/\u89D2\u8272\u4E0E claimKind=${proposal.claimKind} \u4E0D\u7B26\uFF08\u6765\u6E90 role=${source.role}, originClass=${source.origin_class}\uFF09 \u2014 \u7528\u6237\u539F\u8BDD\u914D user_statement\u3001\u5DE5\u5177\u7ED3\u679C\u914D tool_observation\u3001\u8F6C\u8FF0\u4ED6\u4EBA\u914D reported_statement\u3001\u4F60\u81EA\u5DF1\u8BF4\u7684\u8BDD\u914D agent_statement\uFF1B\u6362\u5339\u914D\u7684\u6765\u6E90\u6216\u6539 claimKind`);
8829
8829
  if (proposal.claimKind !== "inference") {
8830
8830
  if (proposal.claimKind === "user_statement" && (source.role !== "user" || !["host_user", "client_reported_user"].includes(source.origin_class))) throw roleMismatch();
8831
8831
  if (proposal.claimKind === "tool_observation" && (source.role !== "tool" || source.origin_class !== "tool_observation")) throw roleMismatch();
@@ -10680,11 +10680,11 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10680
10680
  const covers = (evidence, mention) => evidence.sourceId === mention.sourceId && evidence.start <= mention.start && evidence.end >= mention.end;
10681
10681
  const entitySnapshot = store.entities.list(scope);
10682
10682
  for (const mention of ordered) {
10683
- const path119 = mentionPath(mention);
10683
+ const path120 = mentionPath(mention);
10684
10684
  const source = store.sources.get(scope, mention.sourceId);
10685
10685
  if (!source || !captured.sourceIds.includes(mention.sourceId) || !Number.isSafeInteger(mention.start) || !Number.isSafeInteger(mention.end) || mention.start < 0 || mention.end <= mention.start || mention.end > source.text.length || source.text.slice(mention.start, mention.end) !== mention.quote || typeof mention.key !== "string" || ids.has(mention.key) || typeof mention.actual !== "boolean") {
10686
- if (typeof mention.actual !== "boolean") fail2("INVALID_SOCIAL_MENTION", `${path119}.actual`, "\u5FC5\u586B\u5E03\u5C14\u503C\uFF1B\u771F\u5B9E\u4EBA\u7269\u63D0\u53CA\u586B true\uFF0C\u5047\u8BBE\u4EBA\u7269\u586B false\u3002");
10687
- fail2("INVALID_SOCIAL_MENTION", `${path119}.quote/sourceId/start/end`, "quote \u5FC5\u987B\u9010\u5B57\u51FA\u73B0\u5728 sourceId \u5BF9\u5E94\u7684\u539F\u8BDD\u4E2D\uFF1B\u5148 memory_get({source_id:\u8BE5\u6765\u6E90}) \u6838\u5BF9\u3002mention.quote \u53EA\u622A\u4EBA\u540D/\u79F0\u547C\uFF0C\u5B8C\u6574\u540C\u4EBA\u8BF4\u660E\u653E identity.evidence.quote\uFF1B\u552F\u4E00\u5F15\u6587\u53EF\u7701\u7565 start/end\u3002");
10686
+ if (typeof mention.actual !== "boolean") fail2("INVALID_SOCIAL_MENTION", `${path120}.actual`, "\u5FC5\u586B\u5E03\u5C14\u503C\uFF1B\u771F\u5B9E\u4EBA\u7269\u63D0\u53CA\u586B true\uFF0C\u5047\u8BBE\u4EBA\u7269\u586B false\u3002");
10687
+ fail2("INVALID_SOCIAL_MENTION", `${path120}.quote/sourceId/start/end`, "quote \u5FC5\u987B\u9010\u5B57\u51FA\u73B0\u5728 sourceId \u5BF9\u5E94\u7684\u539F\u8BDD\u4E2D\uFF1B\u5148 memory_get({source_id:\u8BE5\u6765\u6E90}) \u6838\u5BF9\u3002mention.quote \u53EA\u622A\u4EBA\u540D/\u79F0\u547C\uFF0C\u5B8C\u6574\u540C\u4EBA\u8BF4\u660E\u653E identity.evidence.quote\uFF1B\u552F\u4E00\u5F15\u6587\u53EF\u7701\u7565 start/end\u3002");
10688
10688
  }
10689
10689
  if (!mention.actual || isAssistantDraft(source)) {
10690
10690
  ids.set(mention.key, null);
@@ -10694,12 +10694,12 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10694
10694
  if (!["existing", "new", "unresolved"].includes(mention.disposition)) throw new Error("INVALID_SOCIAL_DISPOSITION");
10695
10695
  if (!["name", "description", "reference"].includes(mention.mentionKind)) throw new Error("INVALID_SOCIAL_MENTION_KIND");
10696
10696
  let entity = null;
10697
- const basisRefs = references(mention.basisSourceIds, source.sourceId, `${path119}.basisSourceIds`);
10697
+ const basisRefs = references(mention.basisSourceIds, source.sourceId, `${path120}.basisSourceIds`);
10698
10698
  let identityEntity = null;
10699
10699
  if (mention.identity !== void 0) {
10700
10700
  const identity3 = mention.identity;
10701
10701
  if (!identity3 || !["same_person", "different_person", "uncertain"].includes(identity3.relation)) throw new Error("INVALID_SOCIAL_IDENTITY");
10702
- const evidenceSource = literalSpan(identity3.evidence, `${path119}.identity.evidence`);
10702
+ const evidenceSource = literalSpan(identity3.evidence, `${path120}.identity.evidence`);
10703
10703
  if (evidenceSource.sourceId !== source.sourceId && !captured.contextRefs?.some((ref) => ref.sourceId === evidenceSource.sourceId)) {
10704
10704
  throw new Error("INVALID_SOCIAL_IDENTITY_EVIDENCE");
10705
10705
  }
@@ -10711,7 +10711,7 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10711
10711
  anchorEntityId = store.entities.speaker(scope, source.sourceId)?.entityId;
10712
10712
  } else {
10713
10713
  const supplied = mentionsByKey.get(identity3.anchor);
10714
- if (!supplied || supplied.sourceId !== source.sourceId || supplied.key === mention.key) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path119}.identity.anchor`, anchorCorrection);
10714
+ if (!supplied || supplied.sourceId !== source.sourceId || supplied.key === mention.key) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path120}.identity.anchor`, anchorCorrection);
10715
10715
  const anchor = supplied;
10716
10716
  if (!covers(identity3.evidence, mention) || mention.mentionKind !== "reference" && !covers(identity3.evidence, anchor)) throw new Error("INVALID_SOCIAL_IDENTITY_EVIDENCE");
10717
10717
  anchorEntityId = ids.get(supplied.key);
@@ -10720,25 +10720,25 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10720
10720
  } else {
10721
10721
  const anchor = identity3.anchor;
10722
10722
  const authorAnchor = anchor && "author" in anchor;
10723
- const anchorSource = authorAnchor ? store.sources.get(scope, anchor.sourceId) : literalSpan(anchor, `${path119}.identity.anchor`);
10723
+ const anchorSource = authorAnchor ? store.sources.get(scope, anchor.sourceId) : literalSpan(anchor, `${path120}.identity.anchor`);
10724
10724
  if (!anchorSource || !captured.sourceRefs.some((ref) => ref.sourceId === anchorSource.sourceId && ref.sourceVersion === anchorSource.sourceVersion)) {
10725
- fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path119}.identity.anchor`, anchorCorrection);
10725
+ fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path120}.identity.anchor`, anchorCorrection);
10726
10726
  }
10727
10727
  const supplied = authorAnchor ? void 0 : captured.identityMentions?.find((item) => item.sourceId === anchor.sourceId && item.start === anchor.start && item.end === anchor.end && item.quote === anchor.quote);
10728
10728
  const author = ["host_user", "client_reported_user", "assistant"].includes(anchorSource.originClass) ? store.entities.speaker(scope, anchor.sourceId) : null;
10729
10729
  const selected = mention.entityId ? store.entities.resolve(scope, mention.entityId) : null;
10730
10730
  if (authorAnchor || !supplied && author && selected?.entityId === store.entities.resolve(scope, author.entityId)?.entityId) {
10731
- if (!author || "author" in anchor && anchor.author !== true) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path119}.identity.anchor`, anchorCorrection);
10731
+ if (!author || "author" in anchor && anchor.author !== true) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path120}.identity.anchor`, anchorCorrection);
10732
10732
  if (selected && selected.entityId !== store.entities.resolve(scope, author.entityId)?.entityId) {
10733
- fail2("SOCIAL_IDENTITY_CONFLICT", `${path119}.identity.anchor`, `\u6765\u6E90\u4F5C\u8005\u4E3A ${author.canonicalName}\uFF0CentityId=${author.entityId}\uFF0C\u4E0E mentions.entityId=${mention.entityId} \u4E0D\u540C\uFF1B\u8BF7\u6838\u5BF9\u76EE\u6807\u4EBA\u7269\uFF0C\u5F15\u7528\u6B63\u786E\u4F5C\u8005\u6216\u6B63\u6587 confirmedMentions\u3002`);
10733
+ fail2("SOCIAL_IDENTITY_CONFLICT", `${path120}.identity.anchor`, `\u6765\u6E90\u4F5C\u8005\u4E3A ${author.canonicalName}\uFF0CentityId=${author.entityId}\uFF0C\u4E0E mentions.entityId=${mention.entityId} \u4E0D\u540C\uFF1B\u8BF7\u6838\u5BF9\u76EE\u6807\u4EBA\u7269\uFF0C\u5F15\u7528\u6B63\u786E\u4F5C\u8005\u6216\u6B63\u6587 confirmedMentions\u3002`);
10734
10734
  }
10735
10735
  if (evidenceSource.sourceId !== source.sourceId || !covers(identity3.evidence, mention)) {
10736
- fail2("INVALID_SOCIAL_IDENTITY_EVIDENCE", `${path119}.identity.evidence`, "\u5F15\u7528\u6765\u6E90\u4F5C\u8005\u65F6\uFF0Cevidence \u5E94\u5F15\u7528\u5F53\u524D\u539F\u8BDD\u4E2D\u8BF4\u660E\u8BE5\u4EBA\u7269\u7684\u5B8C\u6574\u53E5\u5B50\uFF0C\u5E76\u5305\u542B mention.quote\u3002");
10736
+ fail2("INVALID_SOCIAL_IDENTITY_EVIDENCE", `${path120}.identity.evidence`, "\u5F15\u7528\u6765\u6E90\u4F5C\u8005\u65F6\uFF0Cevidence \u5E94\u5F15\u7528\u5F53\u524D\u539F\u8BDD\u4E2D\u8BF4\u660E\u8BE5\u4EBA\u7269\u7684\u5B8C\u6574\u53E5\u5B50\uFF0C\u5E76\u5305\u542B mention.quote\u3002");
10737
10737
  }
10738
10738
  anchorEntityId = author.entityId;
10739
10739
  anchorBasis = references([anchor.sourceId], source.sourceId);
10740
10740
  } else {
10741
- if (!supplied || authorAnchor || anchor.sourceId === source.sourceId && anchor.start === mention.start && anchor.end === mention.end) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path119}.identity.anchor`, anchorCorrection);
10741
+ if (!supplied || authorAnchor || anchor.sourceId === source.sourceId && anchor.start === mention.start && anchor.end === mention.end) fail2("INVALID_SOCIAL_IDENTITY_ANCHOR", `${path120}.identity.anchor`, anchorCorrection);
10742
10742
  if (evidenceSource.sourceId === source.sourceId ? !covers(identity3.evidence, mention) : !covers(identity3.evidence, anchor)) {
10743
10743
  throw new Error("INVALID_SOCIAL_IDENTITY_EVIDENCE");
10744
10744
  }
@@ -10816,8 +10816,8 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10816
10816
  if (entity) entityBasis.set(entity.entityId, distinctRefs([...entityBasis.get(entity.entityId) || [], ...grounds]));
10817
10817
  }
10818
10818
  for (const [ordinal, relation] of result2.relationships.entries()) {
10819
- const path119 = `relationships[${ordinal}]`;
10820
- if (typeof relation?.actual !== "boolean") fail2("INVALID_SOCIAL_RELATION", `${path119}.actual`, "\u5FC5\u586B\u5E03\u5C14\u503C\uFF1B\u7528\u6237\u5B9E\u9645\u8BF4\u660E\u7684\u5173\u7CFB\u586B true\u3002label \u662F\u5F00\u653E\u6587\u672C\uFF0C\u201C\u7236\u5B50\u201D\u53EF\u7528\u3002");
10819
+ const path120 = `relationships[${ordinal}]`;
10820
+ if (typeof relation?.actual !== "boolean") fail2("INVALID_SOCIAL_RELATION", `${path120}.actual`, "\u5FC5\u586B\u5E03\u5C14\u503C\uFF1B\u7528\u6237\u5B9E\u9645\u8BF4\u660E\u7684\u5173\u7CFB\u586B true\u3002label \u662F\u5F00\u653E\u6587\u672C\uFF0C\u201C\u7236\u5B50\u201D\u53EF\u7528\u3002");
10821
10821
  if (!relation.actual) {
10822
10822
  applied.relationships.push({ index: ordinal, label: relation.label, state: "ignored" });
10823
10823
  continue;
@@ -10826,7 +10826,7 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10826
10826
  if (!source || !captured.sourceIds.includes(source.sourceId)) {
10827
10827
  fail2(
10828
10828
  "SOCIAL_SOURCE_NOT_PROVIDED",
10829
- `${path119}.sourceId=${relation.sourceId}`,
10829
+ `${path120}.sourceId=${relation.sourceId}`,
10830
10830
  `${source ? "\u8BE5\u6765\u6E90\u672A\u5217\u5165\u672C\u6B21 sources\uFF1B\u4EC5\u653E context_sources \u53EA\u4F9B\u53C2\u7167\uFF0C\u4E0D\u7528\u4E8E\u63D0\u53D6\u5173\u7CFB\u3002" : "\u672C\u6C60\u8BFB\u4E0D\u5230\u8BE5\u6765\u6E90\u3002"}\u5148 memory_get \u6838\u5BF9\u5173\u7CFB\u539F\u8BDD\uFF0C\u518D\u628A\u539F\u8BDD\u7684 ID \u548C\u7248\u672C\u5217\u5165 sources\uFF1B\u4E0D\u8981\u66FF\u6362\u4E3A\u4E0D\u542B\u8BE5\u4E8B\u5B9E\u7684\u672C\u8F6E\u56DE\u7B54\u3002`
10831
10831
  );
10832
10832
  }
@@ -10836,20 +10836,20 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10836
10836
  }
10837
10837
  for (const field of ["validFrom", "validTo"]) {
10838
10838
  const value = relation[field];
10839
- if (value === void 0) fail2("INVALID_SOCIAL_TIME", `${path119}.${field}`, "\u6B64\u5B57\u6BB5\u5FC5\u586B\uFF1B\u539F\u8BDD\u6CA1\u6709\u8BF4\u660E\u5173\u7CFB\u8D77\u6B62\u65F6\u523B\u65F6\u586B null\uFF0C\u4E0D\u8981\u586B\u8BF4\u8BDD\u65F6\u95F4\u3002");
10839
+ if (value === void 0) fail2("INVALID_SOCIAL_TIME", `${path120}.${field}`, "\u6B64\u5B57\u6BB5\u5FC5\u586B\uFF1B\u539F\u8BDD\u6CA1\u6709\u8BF4\u660E\u5173\u7CFB\u8D77\u6B62\u65F6\u523B\u65F6\u586B null\uFF0C\u4E0D\u8981\u586B\u8BF4\u8BDD\u65F6\u95F4\u3002");
10840
10840
  if (value !== null) {
10841
10841
  try {
10842
10842
  if (typeof value !== "string") throw new Error("INVALID_TIME");
10843
10843
  instant(value);
10844
10844
  } catch {
10845
- fail2("INVALID_SOCIAL_TIME", `${path119}.${field}`, "\u975E null \u65F6\u95F4\u987B\u4E3A\u5B8C\u6574 ISO \u65F6\u523B\uFF0C\u5E26 Z \u6216 +08:00 \u7B49\u660E\u786E UTC \u504F\u79FB\uFF1B\u672A\u77E5\u65F6\u523B\u586B null\uFF0C\u4E0D\u8981\u731C\u6D4B\u3002");
10845
+ fail2("INVALID_SOCIAL_TIME", `${path120}.${field}`, "\u975E null \u65F6\u95F4\u987B\u4E3A\u5B8C\u6574 ISO \u65F6\u523B\uFF0C\u5E26 Z \u6216 +08:00 \u7B49\u660E\u786E UTC \u504F\u79FB\uFF1B\u672A\u77E5\u65F6\u523B\u586B null\uFF0C\u4E0D\u8981\u731C\u6D4B\u3002");
10846
10846
  }
10847
10847
  }
10848
10848
  }
10849
10849
  if (relation.validFrom !== null && relation.validFrom !== void 0) {
10850
10850
  const quote2 = relation.validFromQuote;
10851
10851
  if (!quote2 || !Number.isSafeInteger(quote2.start) || !Number.isSafeInteger(quote2.end) || quote2.start < 0 || quote2.end <= quote2.start || quote2.end > source.text.length || source.text.slice(quote2.start, quote2.end) !== quote2.quote) {
10852
- fail2("INVALID_SOCIAL_VALID_FROM", `${path119}.validFrom/validFromQuote`, "\u5173\u7CFB\u8D77\u59CB\u65F6\u95F4\u9700\u8981\u539F\u8BDD\u4E2D\u7684\u65F6\u95F4\u4F9D\u636E\uFF1B\u53EA\u77E5\u9053\u4ECA\u5929\u8BF4\u4E86\u8FD9\u4EF6\u4E8B\u65F6\uFF0CvalidFrom \u586B null\uFF0C\u4E0D\u8981\u586B\u8BF4\u8BDD\u65F6\u95F4\u3002");
10852
+ fail2("INVALID_SOCIAL_VALID_FROM", `${path120}.validFrom/validFromQuote`, "\u5173\u7CFB\u8D77\u59CB\u65F6\u95F4\u9700\u8981\u539F\u8BDD\u4E2D\u7684\u65F6\u95F4\u4F9D\u636E\uFF1B\u53EA\u77E5\u9053\u4ECA\u5929\u8BF4\u4E86\u8FD9\u4EF6\u4E8B\u65F6\uFF0CvalidFrom \u586B null\uFF0C\u4E0D\u8981\u586B\u8BF4\u8BDD\u65F6\u95F4\u3002");
10853
10853
  }
10854
10854
  }
10855
10855
  const speaker = store.entities.speaker(scope, source.sourceId);
@@ -10870,7 +10870,7 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10870
10870
  if (["attitude", "feeling"].includes(relation.contentKind) && relation.direction !== "directed") throw new Error("INVALID_SOCIAL_RECIPROCITY");
10871
10871
  if (relation.attribution !== void 0 && !["direct", "reported"].includes(relation.attribution)) throw new Error("INVALID_SOCIAL_ATTRIBUTION");
10872
10872
  if (relation.attributionQuote !== void 0 && relation.attribution !== "reported") {
10873
- fail2("INVALID_SOCIAL_ATTRIBUTION", `${path119}.attributionQuote`, "attribution=direct\uFF08\u5305\u62EC\u9ED8\u8BA4\u76F4\u63A5\u9648\u8FF0\uFF09\u65F6\u5220\u9664 attributionQuote\uFF1B\u53EA\u6709\u539F\u8BDD\u660E\u786E\u8F6C\u8FF0\u53E6\u4E00\u4EBA\u7269\u89C2\u70B9\u65F6\u624D\u7528 reported\uFF0C\u5E76\u63D0\u4F9B\u8BE5\u4EBA\u7269\u7684 perspective \u548C\u8F6C\u8FF0\u5F15\u6587\u3002\u4E0D\u8981\u4E3A\u901A\u8FC7\u6821\u9A8C\u6539\u6210\u8F6C\u8FF0\u3002");
10873
+ fail2("INVALID_SOCIAL_ATTRIBUTION", `${path120}.attributionQuote`, "attribution=direct\uFF08\u5305\u62EC\u9ED8\u8BA4\u76F4\u63A5\u9648\u8FF0\uFF09\u65F6\u5220\u9664 attributionQuote\uFF1B\u53EA\u6709\u539F\u8BDD\u660E\u786E\u8F6C\u8FF0\u53E6\u4E00\u4EBA\u7269\u89C2\u70B9\u65F6\u624D\u7528 reported\uFF0C\u5E76\u63D0\u4F9B\u8BE5\u4EBA\u7269\u7684 perspective \u548C\u8F6C\u8FF0\u5F15\u6587\u3002\u4E0D\u8981\u4E3A\u901A\u8FC7\u6821\u9A8C\u6539\u6210\u8F6C\u8FF0\u3002");
10874
10874
  }
10875
10875
  if (relation.realm !== void 0 && !["real", "roleplay", "hypothetical"].includes(relation.realm)) throw new Error("INVALID_SOCIAL_REALM");
10876
10876
  if (relation.sensitivity !== void 0 && !["normal", "sensitive"].includes(relation.sensitivity)) throw new Error("INVALID_SOCIAL_SENSITIVITY");
@@ -10895,7 +10895,7 @@ function applySocialInterpretation(store, scope, result2, captured, requestKey,
10895
10895
  basisRefs: distinctRefs([
10896
10896
  ...metadata2?.basisRefs || [],
10897
10897
  ...store.socialSources.identityRefs(scope, source.sourceId),
10898
- ...references(relation.basisSourceIds, source.sourceId, `${path119}.basisSourceIds`),
10898
+ ...references(relation.basisSourceIds, source.sourceId, `${path120}.basisSourceIds`),
10899
10899
  ...[relation.perspective, relation.subject, relation.object].flatMap((ref) => [...mentionBasis.get(ref) || [], ...entityBasis.get(resolve42(ref)) || []])
10900
10900
  ])
10901
10901
  };
@@ -11273,11 +11273,11 @@ function checkSeal(value) {
11273
11273
  const { digest: actual, ...body2 } = value ?? {};
11274
11274
  if (actual !== digest3(canonical(body2))) throw new Error("MANIFEST_DIGEST_MISMATCH");
11275
11275
  }
11276
- function safeRelative(path119) {
11277
- return typeof path119 === "string" && !!path119 && !isAbsolute(path119) && !/[:\\\x00-\x1f]/.test(path119) && path119.split("/").every((p) => p && p !== "." && p !== "..");
11276
+ function safeRelative(path120) {
11277
+ return typeof path120 === "string" && !!path120 && !isAbsolute(path120) && !/[:\\\x00-\x1f]/.test(path120) && path120.split("/").every((p) => p && p !== "." && p !== "..");
11278
11278
  }
11279
- function unlinked(path119) {
11280
- let cursor2 = resolve7(path119);
11279
+ function unlinked(path120) {
11280
+ let cursor2 = resolve7(path120);
11281
11281
  for (; ; ) {
11282
11282
  try {
11283
11283
  if (lstatSync9(cursor2).isSymbolicLink()) throw new Error("SYMLINK_PATH");
@@ -11285,7 +11285,7 @@ function unlinked(path119) {
11285
11285
  if (e.code !== "ENOENT") throw e;
11286
11286
  }
11287
11287
  const parent = dirname8(cursor2);
11288
- if (parent === cursor2) return resolve7(path119);
11288
+ if (parent === cursor2) return resolve7(path120);
11289
11289
  cursor2 = parent;
11290
11290
  }
11291
11291
  }
@@ -11298,8 +11298,8 @@ function disjoint(...paths) {
11298
11298
  for (let i = 0; i < p.length; i++) for (let j = i + 1; j < p.length; j++)
11299
11299
  if (contains(p[i], p[j]) || contains(p[j], p[i])) throw new Error("PATH_OVERLAP");
11300
11300
  }
11301
- function readJson(path119) {
11302
- return JSON.parse(readFileSync11(unlinked(path119), "utf8").replace(/^\uFEFF/, ""));
11301
+ function readJson(path120) {
11302
+ return JSON.parse(readFileSync11(unlinked(path120), "utf8").replace(/^\uFEFF/, ""));
11303
11303
  }
11304
11304
  function rawBytes(snapshot, record) {
11305
11305
  if (!/^[a-f0-9]{64}$/.test(record.sha256)) throw new Error("INVALID_OBJECT_REFERENCE");
@@ -12290,10 +12290,10 @@ function topicMatchesYear(dates, year) {
12290
12290
  function topicsHistoryRoot(b) {
12291
12291
  return unlinked(join16(b.stateDir, "topics-history", key3(b)));
12292
12292
  }
12293
- function parseTopicHistoryPath(path119) {
12294
- if (!path119.startsWith("topics-history://") || path119.length > 1e4) throw new Error("INVALID_HISTORY_REFERENCE");
12293
+ function parseTopicHistoryPath(path120) {
12294
+ if (!path120.startsWith("topics-history://") || path120.length > 1e4) throw new Error("INVALID_HISTORY_REFERENCE");
12295
12295
  try {
12296
- return JSON.parse(Buffer.from(path119.slice(17), "base64url").toString("utf8"));
12296
+ return JSON.parse(Buffer.from(path120.slice(17), "base64url").toString("utf8"));
12297
12297
  } catch {
12298
12298
  throw new Error("INVALID_HISTORY_REFERENCE");
12299
12299
  }
@@ -12320,19 +12320,19 @@ async function topicHistoryReadRevision(b, refs) {
12320
12320
  paths.add(join16(resolve9(b.topicsDir), ref.sourcePath));
12321
12321
  paths.add(join16(root, "forgotten", `${digest3(ref.sourcePath)}.json`));
12322
12322
  }
12323
- const stats2 = await Promise.all([...paths].sort().map(async (path119) => {
12323
+ const stats2 = await Promise.all([...paths].sort().map(async (path120) => {
12324
12324
  try {
12325
- const stat4 = await fs7.lstat(path119, { bigint: true });
12326
- return [path119, ...[stat4.dev, stat4.ino, stat4.mode, stat4.size, stat4.mtimeNs, stat4.ctimeNs].map(String)];
12325
+ const stat4 = await fs7.lstat(path120, { bigint: true });
12326
+ return [path120, ...[stat4.dev, stat4.ino, stat4.mode, stat4.size, stat4.mtimeNs, stat4.ctimeNs].map(String)];
12327
12327
  } catch (error) {
12328
- if (error.code === "ENOENT") return [path119, null];
12328
+ if (error.code === "ENOENT") return [path120, null];
12329
12329
  throw error;
12330
12330
  }
12331
12331
  }));
12332
12332
  return JSON.stringify([current2, stats2]);
12333
12333
  }
12334
- function forgotten(b, path119) {
12335
- return existsSync10(unlinked(join16(topicsHistoryRoot(b), "forgotten", `${digest3(path119)}.json`)));
12334
+ function forgotten(b, path120) {
12335
+ return existsSync10(unlinked(join16(topicsHistoryRoot(b), "forgotten", `${digest3(path120)}.json`)));
12336
12336
  }
12337
12337
  function openIndex(b, version2) {
12338
12338
  if (!b.stateDir || !b.topicsDir) return null;
@@ -12372,16 +12372,16 @@ async function walkTopicsNeedsFallback(b) {
12372
12372
  const visit = async (rel) => {
12373
12373
  const entries2 = await fs7.readdir(unlinked(join16(b.topicsDir, rel)), { withFileTypes: true });
12374
12374
  for (const entry of entries2) {
12375
- const path119 = rel ? `${rel}/${entry.name}` : entry.name;
12375
+ const path120 = rel ? `${rel}/${entry.name}` : entry.name;
12376
12376
  if (entry.isSymbolicLink()) continue;
12377
12377
  if (entry.isDirectory()) {
12378
- if (await visit(path119)) return true;
12378
+ if (await visit(path120)) return true;
12379
12379
  continue;
12380
12380
  }
12381
- if (!entry.isFile() || !/\.md$/i.test(path119) || path119.toUpperCase() === "MEMORY.MD" || forgotten(b, path119)) continue;
12382
- const source = sources.get(path119);
12381
+ if (!entry.isFile() || !/\.md$/i.test(path120) || path120.toUpperCase() === "MEMORY.MD" || forgotten(b, path120)) continue;
12382
+ const source = sources.get(path120);
12383
12383
  if (!source) return true;
12384
- const stat4 = await fs7.stat(unlinked(join16(b.topicsDir, path119)));
12384
+ const stat4 = await fs7.stat(unlinked(join16(b.topicsDir, path120)));
12385
12385
  if (stat4.size !== source.bytes || stat4.mtimeMs !== source.mtime_ms) return true;
12386
12386
  }
12387
12387
  return false;
@@ -13368,7 +13368,7 @@ function readRelationshipContext(store, scope, request3, clock = () => (/* @__PU
13368
13368
  for (const entity of (request3.graphEntityIds ?? []).flatMap((id3) => resolve42(id3) || []).filter((entity2) => !selected.has(entity2.entityId)).slice(0, 4)) {
13369
13369
  if (!context.people.some((person) => person.entityId === entity.entityId)) add("people", entity);
13370
13370
  }
13371
- for (const path119 of (request3.graphPaths ?? []).slice(0, 40)) add("paths", path119, [path119.source, path119.target]);
13371
+ for (const path120 of (request3.graphPaths ?? []).slice(0, 40)) add("paths", path120, [path120.source, path120.target]);
13372
13372
  const linkedIds = store.entities.list(scope, cutoff).filter((entity) => selected.has(resolve42(entity.entityId)?.entityId || entity.entityId)).map((entity) => entity.entityId);
13373
13373
  const views = recall.entitySources(linkedIds, maxRecords);
13374
13374
  const sourceIds = [.../* @__PURE__ */ new Set([
@@ -14965,13 +14965,13 @@ CREATE TABLE IF NOT EXISTS cluster_members (
14965
14965
  const version2 = expectedVersion ?? this.dependencies.version(scope, kind, id3);
14966
14966
  this.dependencies.assertCurrent(scope, kind, id3, version2);
14967
14967
  const digest8 = createHash23("sha256").update(content.trim()).digest("hex");
14968
- const path119 = relative2(this.root, file3).replace(/\\/g, "/");
14968
+ const path120 = relative2(this.root, file3).replace(/\\/g, "/");
14969
14969
  const previous = this.db.prepare("SELECT version,digest,path FROM memory_projection_entries WHERE scope_id=? AND kind=? AND entry_id=?").get(scopeId(scope), kind, id3);
14970
- if (previous?.version === version2 && (previous.digest !== digest8 || previous.path !== path119)) throw new Error("PROJECTION_PUBLICATION_VERSION_CONFLICT");
14970
+ if (previous?.version === version2 && (previous.digest !== digest8 || previous.path !== path120)) throw new Error("PROJECTION_PUBLICATION_VERSION_CONFLICT");
14971
14971
  this.db.prepare(`INSERT INTO memory_projection_entries VALUES (?,?,?,?,?,?)
14972
14972
  ON CONFLICT(scope_id,kind,entry_id) DO UPDATE SET path=excluded.path,version=excluded.version,digest=excluded.digest
14973
- WHERE excluded.version>=memory_projection_entries.version`).run(scopeId(scope), kind, id3, path119, version2, digest8);
14974
- this.artifacts.publish(scope, { ...body2, kind, id: id3, version: version2, medium: "markdown", path: path119, markdown: content.trim() });
14973
+ WHERE excluded.version>=memory_projection_entries.version`).run(scopeId(scope), kind, id3, path120, version2, digest8);
14974
+ this.artifacts.publish(scope, { ...body2, kind, id: id3, version: version2, medium: "markdown", path: path120, markdown: content.trim() });
14975
14975
  });
14976
14976
  }
14977
14977
  projectionMatches(scope, kind, id3, file3, content) {
@@ -15168,8 +15168,8 @@ CREATE TABLE IF NOT EXISTS cluster_members (
15168
15168
  };
15169
15169
  }
15170
15170
  unscopedProjectionMatches(ownerId, kind, id3, file3, content) {
15171
- const path119 = relative2(this.root, file3).replace(/\\/g, "/");
15172
- const mappings = this.db.prepare("SELECT scope_id FROM memory_projection_entries WHERE kind=? AND entry_id=? AND path=?").all(kind, id3, path119);
15171
+ const path120 = relative2(this.root, file3).replace(/\\/g, "/");
15172
+ const mappings = this.db.prepare("SELECT scope_id FROM memory_projection_entries WHERE kind=? AND entry_id=? AND path=?").all(kind, id3, path120);
15173
15173
  if (mappings.length) {
15174
15174
  if (mappings.length !== 1) return false;
15175
15175
  const scope = this.sources.scope(mappings[0].scope_id);
@@ -16323,7 +16323,7 @@ function recoverLegacyProjections(db2, store, input, apply = false) {
16323
16323
  };
16324
16324
  const candidates2 = [];
16325
16325
  const duplicateIds = /* @__PURE__ */ new Set();
16326
- const inside3 = (path119) => path119 && !isAbsolute2(path119) && path119 !== ".." && !path119.startsWith(`..${sep2}`);
16326
+ const inside3 = (path120) => path120 && !isAbsolute2(path120) && path120 !== ".." && !path120.startsWith(`..${sep2}`);
16327
16327
  for (const relativePath of input.files) {
16328
16328
  const logical = resolve10(root, relativePath);
16329
16329
  let canonical6;
@@ -16337,10 +16337,10 @@ function recoverLegacyProjections(db2, store, input, apply = false) {
16337
16337
  gap("projection_path_unverified");
16338
16338
  continue;
16339
16339
  }
16340
- const path119 = relative3(root, canonical6).replace(/\\/g, "/");
16340
+ const path120 = relative3(root, canonical6).replace(/\\/g, "/");
16341
16341
  const user = `users/${input.scope.ownerId}/`;
16342
16342
  const agent = store.ownerProjectionPath("agents", input.scope.ownerId, input.scope).replace(/\\/g, "/") + "/";
16343
- const kind = path119.startsWith(`${user}episodes/`) && /\/episode-\d{4}-\d{2}-\d{2}\.md$/.test(path119) ? "episode" : path119.startsWith(`${user}.atomic_facts/`) && /\/atomic_fact-\d{4}-\d{2}-\d{2}\.md$/.test(path119) ? "atomic_fact" : path119.startsWith(`${user}.foresights/`) && /\/foresight-\d{4}-\d{2}-\d{2}\.md$/.test(path119) ? "foresight" : path119.startsWith(`${agent}.cases/`) && /\/agent_case-\d{4}-\d{2}-\d{2}\.md$/.test(path119) ? "agent_case" : void 0;
16343
+ const kind = path120.startsWith(`${user}episodes/`) && /\/episode-\d{4}-\d{2}-\d{2}\.md$/.test(path120) ? "episode" : path120.startsWith(`${user}.atomic_facts/`) && /\/atomic_fact-\d{4}-\d{2}-\d{2}\.md$/.test(path120) ? "atomic_fact" : path120.startsWith(`${user}.foresights/`) && /\/foresight-\d{4}-\d{2}-\d{2}\.md$/.test(path120) ? "foresight" : path120.startsWith(`${agent}.cases/`) && /\/agent_case-\d{4}-\d{2}-\d{2}\.md$/.test(path120) ? "agent_case" : void 0;
16344
16344
  if (!kind) {
16345
16345
  gap("projection_kind_or_owner_unverified");
16346
16346
  continue;
@@ -16377,9 +16377,9 @@ function recoverLegacyProjections(db2, store, input, apply = false) {
16377
16377
  continue;
16378
16378
  }
16379
16379
  const previous = db2.prepare("SELECT * FROM memory_legacy_projection_maps WHERE scope_id=? AND kind=? AND entry_id=?").get(key6, kind, match[1]);
16380
- const target = join18(store.mem7RootPath(), path119);
16380
+ const target = join18(store.mem7RootPath(), path120);
16381
16381
  if (previous) {
16382
- if (previous.source_file_hash !== fileHash || previous.parent_id !== parent || previous.source_relative_path !== path119 || !store.projectionMatches(input.scope, kind, match[1], target, block)) {
16382
+ if (previous.source_file_hash !== fileHash || previous.parent_id !== parent || previous.source_relative_path !== path120 || !store.projectionMatches(input.scope, kind, match[1], target, block)) {
16383
16383
  gap("projection_mapping_conflict");
16384
16384
  continue;
16385
16385
  }
@@ -16395,7 +16395,7 @@ function recoverLegacyProjections(db2, store, input, apply = false) {
16395
16395
  candidates2.push({
16396
16396
  file: canonical6,
16397
16397
  fileHash,
16398
- relativePath: path119,
16398
+ relativePath: path120,
16399
16399
  id: match[1],
16400
16400
  kind,
16401
16401
  parent,
@@ -20717,8 +20717,8 @@ function notificationStateChange(route, queueStateDir) {
20717
20717
  function createNotificationStateReader() {
20718
20718
  const databases = /* @__PURE__ */ new Map();
20719
20719
  const checkers = /* @__PURE__ */ new Map();
20720
- const open6 = (path119) => {
20721
- const key6 = resolve13(path119);
20720
+ const open6 = (path120) => {
20721
+ const key6 = resolve13(path120);
20722
20722
  let db2 = databases.get(key6);
20723
20723
  if (!db2) {
20724
20724
  db2 = new DatabaseSync(key6, { readOnly: true });
@@ -20935,10 +20935,10 @@ function isCorruption(error) {
20935
20935
  if (code === 11 || code === 26) return true;
20936
20936
  return /database disk image is malformed|file is not a database/i.test(String(error?.message ?? error));
20937
20937
  }
20938
- function healthyDatabase(path119) {
20938
+ function healthyDatabase(path120) {
20939
20939
  let db2;
20940
20940
  try {
20941
- db2 = new DatabaseSync12(path119);
20941
+ db2 = new DatabaseSync12(path120);
20942
20942
  const check = db2.prepare("PRAGMA quick_check").get();
20943
20943
  return check?.quick_check === "ok";
20944
20944
  } catch {
@@ -30417,8 +30417,8 @@ import { cp, readdir, rm } from "node:fs/promises";
30417
30417
  import { basename as basename8, dirname as dirname13, join as join33, resolve as resolve17 } from "node:path";
30418
30418
  import { fileURLToPath as fileURLToPath5 } from "node:url";
30419
30419
  import { execFile } from "node:child_process";
30420
- function atomicJson(path119, value) {
30421
- const target = unlinked(path119), temp = unlinked(`${target}.${randomUUID19()}.tmp`);
30420
+ function atomicJson(path120, value) {
30421
+ const target = unlinked(path120), temp = unlinked(`${target}.${randomUUID19()}.tmp`);
30422
30422
  try {
30423
30423
  writeFileSync15(temp, JSON.stringify(seal(value)) + "\n", { flag: "wx" });
30424
30424
  renameSync11(temp, target);
@@ -30436,10 +30436,10 @@ function alive2(pid) {
30436
30436
  }
30437
30437
  }
30438
30438
  function importerActive(historyRoot2) {
30439
- const path119 = join33(historyRoot2, ".topics-import.lock");
30440
- if (!existsSync17(path119)) return false;
30439
+ const path120 = join33(historyRoot2, ".topics-import.lock");
30440
+ if (!existsSync17(path120)) return false;
30441
30441
  try {
30442
- return alive2(readJson(path119).pid);
30442
+ return alive2(readJson(path120).pid);
30443
30443
  } catch {
30444
30444
  return true;
30445
30445
  }
@@ -30447,13 +30447,13 @@ function importerActive(historyRoot2) {
30447
30447
  async function withTopicsImportLock(historyRoot2, action) {
30448
30448
  const root = unlinked(historyRoot2);
30449
30449
  mkdirSync18(root, { recursive: true });
30450
- const path119 = unlinked(join33(root, ".topics-import.lock")), token = randomUUID19();
30450
+ const path120 = unlinked(join33(root, ".topics-import.lock")), token = randomUUID19();
30451
30451
  const body2 = JSON.stringify({ pid: process.pid, token });
30452
30452
  try {
30453
- writeFileSync15(path119, body2, { flag: "wx" });
30453
+ writeFileSync15(path120, body2, { flag: "wx" });
30454
30454
  } catch (error) {
30455
30455
  if (error.code !== "EEXIST") throw error;
30456
- const original = readFileSync24(path119, "utf8");
30456
+ const original = readFileSync24(path120, "utf8");
30457
30457
  let owner;
30458
30458
  try {
30459
30459
  owner = JSON.parse(original);
@@ -30461,23 +30461,23 @@ async function withTopicsImportLock(historyRoot2, action) {
30461
30461
  throw new Error("TOPICS_IMPORT_BUSY: invalid lock");
30462
30462
  }
30463
30463
  if (alive2(owner.pid)) throw new Error("TOPICS_IMPORT_BUSY");
30464
- if (readFileSync24(path119, "utf8") !== original) throw new Error("TOPICS_IMPORT_BUSY");
30465
- unlinkSync7(path119);
30466
- writeFileSync15(path119, body2, { flag: "wx" });
30464
+ if (readFileSync24(path120, "utf8") !== original) throw new Error("TOPICS_IMPORT_BUSY");
30465
+ unlinkSync7(path120);
30466
+ writeFileSync15(path120, body2, { flag: "wx" });
30467
30467
  }
30468
30468
  try {
30469
30469
  return await action();
30470
30470
  } finally {
30471
- if (existsSync17(path119) && readFileSync24(path119, "utf8") === body2) unlinkSync7(path119);
30471
+ if (existsSync17(path120) && readFileSync24(path120, "utf8") === body2) unlinkSync7(path120);
30472
30472
  }
30473
30473
  }
30474
30474
  function registryPath(stateDir) {
30475
30475
  return join33(stateDir, "mem7", ".topics-backup-roots.json");
30476
30476
  }
30477
30477
  function backupRoots(stateDir) {
30478
- const path119 = registryPath(stateDir);
30479
- if (!existsSync17(path119)) return [join33(stateDir, "mem7")];
30480
- const value = readJson(path119);
30478
+ const path120 = registryPath(stateDir);
30479
+ if (!existsSync17(path120)) return [join33(stateDir, "mem7")];
30480
+ const value = readJson(path120);
30481
30481
  checkSeal(value);
30482
30482
  if (value.version !== 1 || value.stateDir !== stateDir || !Array.isArray(value.roots) || value.roots.some((r) => typeof r !== "string" || resolve17(r) !== r)) throw new Error("INVALID_BACKUP_ROOT_REGISTRY");
30483
30483
  return [.../* @__PURE__ */ new Set([join33(stateDir, "mem7"), ...value.roots])];
@@ -30637,8 +30637,8 @@ async function adoptLegacyBackups(state2, root, allowed) {
30637
30637
  const history = unlinked(join33(histories, entry.name));
30638
30638
  if (importerActive(history) || existsSync17(join33(history, pointerName))) continue;
30639
30639
  try {
30640
- const marker = readJson(join33(history, "topics-import.json")), path119 = unlinked(marker.report?.backupPath ?? "");
30641
- if (marker.report?.failed === 0 && Number.isFinite(Date.parse(marker.completedAt)) && dirname13(path119) === root && backupName.test(basename8(path119)) && existsSync17(path119))
30640
+ const marker = readJson(join33(history, "topics-import.json")), path120 = unlinked(marker.report?.backupPath ?? "");
30641
+ if (marker.report?.failed === 0 && Number.isFinite(Date.parse(marker.completedAt)) && dirname13(path120) === root && backupName.test(basename8(path120)) && existsSync17(path120))
30642
30642
  markers.push({ history, marker, hash: digest3(canonical(marker)) });
30643
30643
  } catch {
30644
30644
  }
@@ -30690,10 +30690,10 @@ async function legacyCompletionRoots(state2) {
30690
30690
  try {
30691
30691
  const marker = readJson(join33(histories, entry.name, "topics-import.json"));
30692
30692
  if (marker.report?.failed !== 0 || !Number.isFinite(Date.parse(marker.completedAt)) || typeof marker.report.backupPath !== "string") continue;
30693
- const path119 = unlinked(marker.report.backupPath);
30694
- if (!backupName.test(basename8(path119)) || !existsSync17(path119)) continue;
30695
- disjoint(join33(state2, "mem7", "index"), join33(state2, "mem7", "users"), path119);
30696
- roots.add(dirname13(path119));
30693
+ const path120 = unlinked(marker.report.backupPath);
30694
+ if (!backupName.test(basename8(path120)) || !existsSync17(path120)) continue;
30695
+ disjoint(join33(state2, "mem7", "index"), join33(state2, "mem7", "users"), path120);
30696
+ roots.add(dirname13(path120));
30697
30697
  } catch {
30698
30698
  }
30699
30699
  }
@@ -33282,8 +33282,8 @@ function modelRefListError(v) {
33282
33282
  function listFields() {
33283
33283
  return FIELDS.slice();
33284
33284
  }
33285
- function getField(path119) {
33286
- return FIELDS.find((f) => f.path === path119);
33285
+ function getField(path120) {
33286
+ return FIELDS.find((f) => f.path === path120);
33287
33287
  }
33288
33288
  var VALID_PERSONAS, FIELDS;
33289
33289
  var init_registry2 = __esm({
@@ -35213,7 +35213,7 @@ function needsFreeTierNortFixup(cfg) {
35213
35213
  if (!provider) return false;
35214
35214
  const lanes = free || readPath(cfg, "topics.clean.model") === void 0 ? LANE_MODELS : [FREE_TIER_NORT_MODEL];
35215
35215
  if (lanes.some((id3) => !(provider.models || []).some((m) => m?.id === id3))) return true;
35216
- return free && Object.keys(FIELD_REFS).some((path119) => readPath(cfg, path119) === void 0) || legacyDefaultExtract(cfg);
35216
+ return free && Object.keys(FIELD_REFS).some((path120) => readPath(cfg, path120) === void 0) || legacyDefaultExtract(cfg);
35217
35217
  }
35218
35218
  function readPath(obj, dotPath) {
35219
35219
  return dotPath.split(".").reduce((acc, k) => acc == null ? void 0 : acc[k], obj);
@@ -35234,8 +35234,8 @@ async function applyFreeTierNortFixup(io) {
35234
35234
  const pCopy = cfg.providers?.[FREE_TIER_PROVIDER_ID];
35235
35235
  if (pCopy && pCopy !== provider) pCopy.models = newModels;
35236
35236
  }
35237
- for (const [path119, ref] of Object.entries(FIELD_REFS)) {
35238
- if (free && readPath(cfg, path119) === void 0) writes.push([path119, ref]);
35237
+ for (const [path120, ref] of Object.entries(FIELD_REFS)) {
35238
+ if (free && readPath(cfg, path120) === void 0) writes.push([path120, ref]);
35239
35239
  }
35240
35240
  if (!free && readPath(cfg, "topics.clean.model") === void 0) {
35241
35241
  writes.push(["topics.clean.model", FREE_TIER_FAST_REF]);
@@ -35247,8 +35247,8 @@ async function applyFreeTierNortFixup(io) {
35247
35247
  }
35248
35248
  if (!writes.length) return false;
35249
35249
  let persisted = true;
35250
- for (const [path119, value] of writes) {
35251
- if (await io.set(path119, value) === false) persisted = false;
35250
+ for (const [path120, value] of writes) {
35251
+ if (await io.set(path120, value) === false) persisted = false;
35252
35252
  }
35253
35253
  if (!persisted) {
35254
35254
  console.error("[startup] \u540E\u53F0\u6A21\u578B\u8865\u9F50 **\u672A\u5168\u90E8\u843D\u76D8**\uFF08\u672C\u6B21\u8FD0\u884C\u5185\u5B58\u91CC\u5DF2\u751F\u6548\uFF0C\u914D\u7F6E\u6587\u4EF6\u4ECD\u662F\u65E7\u7684\u2014\u2014\u4E0B\u6B21\u542F\u52A8\u4F1A\u91CD\u653E\uFF09\u3002\u4E0A\u9762 [liveConfig] \u90A3\u51E0\u884C\u662F\u539F\u56E0\u3002");
@@ -42050,9 +42050,9 @@ function buildPlanningContext(calDb, workspace, memory) {
42050
42050
  function captureScanPlanningContext(workspace, memory, calDb) {
42051
42051
  const read3 = () => {
42052
42052
  if (calDb !== void 0) return buildPlanningContext(calDb, workspace, memory);
42053
- const path119 = join45(workspace, ".calendar", "calendar.db");
42054
- if (!existsSync26(path119)) return buildPlanningContext(null, workspace, memory);
42055
- const db2 = new DatabaseSync16(path119, { readOnly: true });
42053
+ const path120 = join45(workspace, ".calendar", "calendar.db");
42054
+ if (!existsSync26(path120)) return buildPlanningContext(null, workspace, memory);
42055
+ const db2 = new DatabaseSync16(path120, { readOnly: true });
42056
42056
  try {
42057
42057
  return buildPlanningContext(db2, workspace, memory);
42058
42058
  } finally {
@@ -42493,11 +42493,11 @@ var init_verdict_parse = __esm({
42493
42493
  // src/memory/proactive/relationship-snapshot.ts
42494
42494
  import { existsSync as existsSync28 } from "node:fs";
42495
42495
  import { DatabaseSync as DatabaseSync17 } from "node:sqlite";
42496
- function readRelationshipGraphSnapshot(path119) {
42497
- if (!path119 || !existsSync28(path119)) return void 0;
42496
+ function readRelationshipGraphSnapshot(path120) {
42497
+ if (!path120 || !existsSync28(path120)) return void 0;
42498
42498
  let db2;
42499
42499
  try {
42500
- db2 = new DatabaseSync17(path119, { readOnly: true });
42500
+ db2 = new DatabaseSync17(path120, { readOnly: true });
42501
42501
  db2.exec("BEGIN");
42502
42502
  const version2 = readSchemaVersion(db2);
42503
42503
  if (version2?.component !== "proactive" || version2.version !== PROACTIVE_SCHEMA_VERSION) return void 0;
@@ -43315,11 +43315,11 @@ function updatePeople(store, scope, input, _provided) {
43315
43315
  }
43316
43316
  const requestHash = createHash39("sha256").update(canonicalJson(input)).digest("hex");
43317
43317
  return store.transaction(() => new MemoryReadBudget().run(() => {
43318
- const load = (ref, path119) => {
43318
+ const load = (ref, path120) => {
43319
43319
  const source = ref && store.sources.get(scope, ref.source_id);
43320
- if (!source) throw new Error(`SOCIAL_SOURCE_NOT_CURRENT: ${path119}.source_id \u2014 \u672C\u6C60\u6682\u65F6\u8BFB\u4E0D\u5230\u6765\u6E90 ${ref?.source_id}\uFF1B\u53EF\u80FD\u5C1A\u5728\u5165\u5E93\u961F\u5217\u6216\u5DF2\u5220\u9664\u3002\u7528 memory_get({source_id:\u8BE5\u6765\u6E90}) \u6838\u5BF9\uFF1B\u4E0D\u8981\u731C source_version\uFF0C\u4E5F\u4E0D\u8981\u6362\u6210\u53E6\u4E00\u6761\u56DE\u7B54\u7684\u6765\u6E90 ID\u3002`);
43320
+ if (!source) throw new Error(`SOCIAL_SOURCE_NOT_CURRENT: ${path120}.source_id \u2014 \u672C\u6C60\u6682\u65F6\u8BFB\u4E0D\u5230\u6765\u6E90 ${ref?.source_id}\uFF1B\u53EF\u80FD\u5C1A\u5728\u5165\u5E93\u961F\u5217\u6216\u5DF2\u5220\u9664\u3002\u7528 memory_get({source_id:\u8BE5\u6765\u6E90}) \u6838\u5BF9\uFF1B\u4E0D\u8981\u731C source_version\uFF0C\u4E5F\u4E0D\u8981\u6362\u6210\u53E6\u4E00\u6761\u56DE\u7B54\u7684\u6765\u6E90 ID\u3002`);
43321
43321
  if (ref.source_version !== void 0 && source.sourceVersion !== ref.source_version || !store.socialSources.readable(scope, source.sourceId)) {
43322
- throw new Error(`SOCIAL_SOURCE_NOT_CURRENT: ${path119}.source_version \u2014 \u8BE5\u6765\u6E90\u8BB0\u5F55 sourceVersion=${source.sourceVersion}, state=${source.state}\uFF1B\u7528 memory_get({source_id:\u8BE5\u6765\u6E90}) \u91CD\u65B0\u8BFB\u53D6\u539F\u8BDD\u548C\u7248\u672C\u3002\u5F53\u524D\u7248\u672C\u6216\u4F9D\u636E\u53EF\u80FD\u5DF2\u5931\u6548\uFF1B\u65E0\u9700\u7B49\u5F85\u666E\u901A\u4E8B\u5B9E\u89E3\u91CA\u5B8C\u6210\u3002`);
43322
+ throw new Error(`SOCIAL_SOURCE_NOT_CURRENT: ${path120}.source_version \u2014 \u8BE5\u6765\u6E90\u8BB0\u5F55 sourceVersion=${source.sourceVersion}, state=${source.state}\uFF1B\u7528 memory_get({source_id:\u8BE5\u6765\u6E90}) \u91CD\u65B0\u8BFB\u53D6\u539F\u8BDD\u548C\u7248\u672C\u3002\u5F53\u524D\u7248\u672C\u6216\u4F9D\u636E\u53EF\u80FD\u5DF2\u5931\u6548\uFF1B\u65E0\u9700\u7B49\u5F85\u666E\u901A\u4E8B\u5B9E\u89E3\u91CA\u5B8C\u6210\u3002`);
43323
43323
  }
43324
43324
  return source;
43325
43325
  };
@@ -43334,17 +43334,17 @@ function updatePeople(store, scope, input, _provided) {
43334
43334
  }
43335
43335
  const contexts2 = (input.context_sources || []).map((ref, index) => load(ref, `context_sources[${index}]`));
43336
43336
  const visible = new Set([...sources, ...contexts2].map((source) => source.sourceId));
43337
- const addContext = (id3, path119) => {
43337
+ const addContext = (id3, path120) => {
43338
43338
  if (typeof id3 !== "string" || visible.has(id3)) return;
43339
- contexts2.push(load({ source_id: id3 }, path119));
43339
+ contexts2.push(load({ source_id: id3 }, path120));
43340
43340
  visible.add(id3);
43341
43341
  };
43342
43342
  for (const [index, item] of [...input.mentions, ...input.relationships].entries()) {
43343
- const path119 = index < input.mentions.length ? `mentions[${index}]` : `relationships[${index - input.mentions.length}]`;
43344
- if (Array.isArray(item?.basisSourceIds)) for (const id3 of item.basisSourceIds) addContext(id3, `${path119}.basisSourceIds`);
43343
+ const path120 = index < input.mentions.length ? `mentions[${index}]` : `relationships[${index - input.mentions.length}]`;
43344
+ if (Array.isArray(item?.basisSourceIds)) for (const id3 of item.basisSourceIds) addContext(id3, `${path120}.basisSourceIds`);
43345
43345
  if (item && "identity" in item && item.identity) {
43346
- if (typeof item.identity.anchor === "object") addContext(item.identity.anchor?.sourceId, `${path119}.identity.anchor`);
43347
- addContext(item.identity.evidence?.sourceId, `${path119}.identity.evidence`);
43346
+ if (typeof item.identity.anchor === "object") addContext(item.identity.anchor?.sourceId, `${path120}.identity.anchor`);
43347
+ addContext(item.identity.evidence?.sourceId, `${path120}.identity.evidence`);
43348
43348
  }
43349
43349
  }
43350
43350
  for (const mention of input.mentions) {
@@ -43654,10 +43654,10 @@ var init_atomic_facts = __esm({
43654
43654
  import { existsSync as existsSync30, readFileSync as readFileSync37, writeFileSync as writeFileSync19, mkdirSync as mkdirSync23, renameSync as renameSync14 } from "node:fs";
43655
43655
  import { join as join49, dirname as dirname19 } from "node:path";
43656
43656
  function readStatusDoc(root, sid) {
43657
- const path119 = docPath(root, sid);
43658
- if (!existsSync30(path119)) return null;
43657
+ const path120 = docPath(root, sid);
43658
+ if (!existsSync30(path120)) return null;
43659
43659
  try {
43660
- const parsed = JSON.parse(readFileSync37(path119, "utf-8"));
43660
+ const parsed = JSON.parse(readFileSync37(path120, "utf-8"));
43661
43661
  if (!parsed || parsed.doc !== null && !validDoc(parsed.doc) || parsed.sourceSeq !== null && (!Number.isSafeInteger(parsed.sourceSeq) || parsed.sourceSeq < 0) || typeof parsed.updatedAt !== "string" || !Number.isFinite(Date.parse(parsed.updatedAt)) || parsed.failedAt !== void 0 && !Number.isFinite(Date.parse(parsed.failedAt))) return null;
43662
43662
  return parsed;
43663
43663
  } catch {
@@ -43735,11 +43735,11 @@ Merge into the status document per the system contract. Return only the JSON obj
43735
43735
  }
43736
43736
  }
43737
43737
  function writeDoc(root, sid, file3) {
43738
- const path119 = docPath(root, sid);
43739
- mkdirSync23(dirname19(path119), { recursive: true });
43740
- const tmp = path119 + ".tmp";
43738
+ const path120 = docPath(root, sid);
43739
+ mkdirSync23(dirname19(path120), { recursive: true });
43740
+ const tmp = path120 + ".tmp";
43741
43741
  writeFileSync19(tmp, JSON.stringify(file3), "utf-8");
43742
- renameSync14(tmp, path119);
43742
+ renameSync14(tmp, path120);
43743
43743
  }
43744
43744
  var MERGE_MIN_INTERVAL_SEQ, MERGE_FAIL_COOLDOWN_MS, dirPath, docPath, MERGE_SYSTEM;
43745
43745
  var init_status_doc = __esm({
@@ -44298,9 +44298,9 @@ function snapshotFiles(store, request3) {
44298
44298
  return { path: relative6(root, file3).replace(/\\/g, "/"), digest: digest8 };
44299
44299
  }).sort((a, b) => a.path.localeCompare(b.path));
44300
44300
  }
44301
- function ownFilePublication(store, request3, path119, version2) {
44301
+ function ownFilePublication(store, request3, path120, version2) {
44302
44302
  if (request3.kind !== "skills" && request3.kind !== "profile") return false;
44303
- const file3 = join55(store.mem7RootPath(), path119);
44303
+ const file3 = join55(store.mem7RootPath(), path120);
44304
44304
  let text5;
44305
44305
  try {
44306
44306
  text5 = readFileSync43(file3, "utf8");
@@ -44330,9 +44330,9 @@ function assertArtifactFileInputs(store, inputs, publicationVersion) {
44330
44330
  const current2 = currentInput(store, input.request);
44331
44331
  const oldFiles = new Map(input.files.map((file3) => [file3.path, file3.digest]));
44332
44332
  const newFiles = new Map(current2.files.map((file3) => [file3.path, file3.digest]));
44333
- for (const path119 of /* @__PURE__ */ new Set([...oldFiles.keys(), ...newFiles.keys()])) {
44334
- if (oldFiles.get(path119) === newFiles.get(path119)) continue;
44335
- if (publicationVersion !== void 0 && ownFilePublication(store, input.request, path119, publicationVersion)) continue;
44333
+ for (const path120 of /* @__PURE__ */ new Set([...oldFiles.keys(), ...newFiles.keys()])) {
44334
+ if (oldFiles.get(path120) === newFiles.get(path120)) continue;
44335
+ if (publicationVersion !== void 0 && ownFilePublication(store, input.request, path120, publicationVersion)) continue;
44336
44336
  throw new SupersededJobError("ARTIFACT_FILE_INPUT_CHANGED");
44337
44337
  }
44338
44338
  const expected = new Map(input.entries.map((entry) => [entry.id, entry.digest]));
@@ -45797,9 +45797,9 @@ var init_pipeline = __esm({
45797
45797
  import { appendFileSync as appendFileSync4, existsSync as existsSync31, readFileSync as readFileSync44, readSync as readSync5, writeFileSync as writeFileSync20, writeSync as writeSync2, mkdirSync as mkdirSync24, renameSync as renameSync15, unlinkSync as unlinkSync8, openSync as openSync13, closeSync as closeSync13, fstatSync as fstatSync6, statSync as statSync10, statfsSync } from "node:fs";
45798
45798
  import { createHash as createHash43 } from "node:crypto";
45799
45799
  import { join as join56, dirname as dirname25 } from "node:path";
45800
- function fileBytes(path119) {
45800
+ function fileBytes(path120) {
45801
45801
  try {
45802
- return statSync10(path119).size;
45802
+ return statSync10(path120).size;
45803
45803
  } catch (error) {
45804
45804
  if (error?.code !== "ENOENT") throw error;
45805
45805
  return 0;
@@ -45883,11 +45883,11 @@ function warnIntake(stateDir, message) {
45883
45883
  }
45884
45884
  warnings.set(key6, { at: now2, suppressed: 0 });
45885
45885
  }
45886
- function lockOwnerState(path119) {
45886
+ function lockOwnerState(path120) {
45887
45887
  let pid;
45888
45888
  try {
45889
- if (fileBytes(path119) > 32) return "alive";
45890
- pid = Number(readFileSync44(path119, "utf8").trim());
45889
+ if (fileBytes(path120) > 32) return "alive";
45890
+ pid = Number(readFileSync44(path120, "utf8").trim());
45891
45891
  } catch (error) {
45892
45892
  if (error?.code === "ENOENT") return "missing";
45893
45893
  throw error;
@@ -45901,15 +45901,15 @@ function lockOwnerState(path119) {
45901
45901
  }
45902
45902
  }
45903
45903
  function withSpoolWriteLock(stateDir, operation) {
45904
- const path119 = writeLockPath(stateDir);
45905
- mkdirSync24(dirname25(path119), { recursive: true });
45904
+ const path120 = writeLockPath(stateDir);
45905
+ mkdirSync24(dirname25(path120), { recursive: true });
45906
45906
  let fd;
45907
45907
  try {
45908
- fd = openSync13(path119, "wx");
45908
+ fd = openSync13(path120, "wx");
45909
45909
  } catch (error) {
45910
45910
  if (error?.code !== "EEXIST") throw error;
45911
- if (lockOwnerState(path119) === "alive") throw Error("INTAKE_WRITER_BUSY: \u5199\u5165\u8005\u6B63\u5728\u64CD\u4F5C\uFF0C\u672A\u5165\u961F\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
45912
- const reaperPath = path119 + ".reap";
45911
+ if (lockOwnerState(path120) === "alive") throw Error("INTAKE_WRITER_BUSY: \u5199\u5165\u8005\u6B63\u5728\u64CD\u4F5C\uFF0C\u672A\u5165\u961F\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
45912
+ const reaperPath = path120 + ".reap";
45913
45913
  let reaper;
45914
45914
  try {
45915
45915
  reaper = openSync13(reaperPath, "wx");
@@ -45918,9 +45918,9 @@ function withSpoolWriteLock(stateDir, operation) {
45918
45918
  throw Error("INTAKE_WRITER_BUSY: \u5199\u9501\u6062\u590D\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
45919
45919
  }
45920
45920
  try {
45921
- if (lockOwnerState(path119) === "dead") unlinkSync8(path119);
45921
+ if (lockOwnerState(path120) === "dead") unlinkSync8(path120);
45922
45922
  try {
45923
- fd = openSync13(path119, "wx");
45923
+ fd = openSync13(path120, "wx");
45924
45924
  } catch (error2) {
45925
45925
  if (error2?.code !== "EEXIST") throw error2;
45926
45926
  throw Error("INTAKE_WRITER_BUSY: \u5199\u5165\u8005\u6B63\u5728\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
@@ -45935,11 +45935,11 @@ function withSpoolWriteLock(stateDir, operation) {
45935
45935
  return operation();
45936
45936
  } finally {
45937
45937
  closeSync13(fd);
45938
- unlinkSync8(path119);
45938
+ unlinkSync8(path120);
45939
45939
  }
45940
45940
  }
45941
45941
  function enqueueIntake(stateDir, entry) {
45942
- const path119 = spoolPath(stateDir);
45942
+ const path120 = spoolPath(stateDir);
45943
45943
  const operationId = `${process.pid}:${++operationSequence}`, started = performance.now();
45944
45944
  const metrics = producerMetrics.get(stateDir) ?? {
45945
45945
  callsTotal: 0,
@@ -45967,7 +45967,7 @@ function enqueueIntake(stateDir, entry) {
45967
45967
  for (let attempt = 0; attempt < 3; attempt++) {
45968
45968
  if (intakeSpoolStatus(stateDir).pendingBytes + bytes3 > INTAKE_MAX_BYTES)
45969
45969
  throw Error("INTAKE_SPOOL_FULL: \u5F85\u6D88\u8D39\u961F\u5217\u8FBE\u523064 MiB\u4E0A\u9650\uFF0C\u505C\u6B62\u8FFD\u52A0\uFF0C\u672C\u6761\u539F\u8BDD\u672A\u5165\u961F\uFF1B\u8BF7\u68C0\u67E5worker\u6D88\u8D39\u72B6\u6001");
45970
- const fd = openSync13(path119, "a");
45970
+ const fd = openSync13(path120, "a");
45971
45971
  try {
45972
45972
  const opened = fstatSync6(fd, { bigint: true });
45973
45973
  appendAttempts++;
@@ -45977,7 +45977,7 @@ function enqueueIntake(stateDir, entry) {
45977
45977
  let currentFd;
45978
45978
  let currentIdentity = null;
45979
45979
  try {
45980
- currentFd = openSync13(path119, "r");
45980
+ currentFd = openSync13(path120, "r");
45981
45981
  const current2 = fstatSync6(currentFd, { bigint: true });
45982
45982
  currentIdentity = fileIdentity(current2);
45983
45983
  if (current2.dev === opened.dev && current2.ino === opened.ino) return true;
@@ -46055,10 +46055,10 @@ function* spoolLines(fd, offset, maxEntries) {
46055
46055
  position += bytes3;
46056
46056
  }
46057
46057
  }
46058
- function readCursor(stateDir, path119, identity3, size2) {
46058
+ function readCursor(stateDir, path120, identity3, size2) {
46059
46059
  try {
46060
- if (fileBytes(path119) > 4096) throw Error("INTAKE_CURSOR_INVALID_SIZE");
46061
- const cursor2 = JSON.parse(readFileSync44(path119, "utf8"));
46060
+ if (fileBytes(path120) > 4096) throw Error("INTAKE_CURSOR_INVALID_SIZE");
46061
+ const cursor2 = JSON.parse(readFileSync44(path120, "utf8"));
46062
46062
  if (cursor2.dev === identity3.dev && cursor2.ino === identity3.ino && cursor2.birthtimeNs === identity3.birthtimeNs && Number.isSafeInteger(cursor2.offset) && cursor2.offset >= 0 && cursor2.offset <= size2) return cursor2.offset;
46063
46063
  intakeDiagnostic(stateDir, "cursor.replay", { reason: cursor2.dev !== identity3.dev || cursor2.ino !== identity3.ino || cursor2.birthtimeNs !== identity3.birthtimeNs ? "identity_mismatch" : "invalid_offset", batchBytes: size2, identity: identity3 });
46064
46064
  } catch (error) {
@@ -46093,21 +46093,21 @@ function drainIntakeSpool(stateDir, store, maxEntries = 50) {
46093
46093
  } : {},
46094
46094
  elapsedMs: Math.round(performance.now() - started)
46095
46095
  });
46096
- const path119 = spoolPath(stateDir);
46096
+ const path120 = spoolPath(stateDir);
46097
46097
  const processing = processingPath(stateDir);
46098
46098
  const cursorPath = processing + ".cursor";
46099
46099
  try {
46100
46100
  withSpoolWriteLock(stateDir, () => {
46101
46101
  if (!existsSync31(processing)) {
46102
- if (!existsSync31(path119) || statSync10(path119).size === 0) return;
46102
+ if (!existsSync31(path120) || statSync10(path120).size === 0) return;
46103
46103
  try {
46104
46104
  unlinkSync8(cursorPath);
46105
46105
  } catch (error) {
46106
46106
  if (error?.code !== "ENOENT") throw error;
46107
46107
  }
46108
- renameSync15(path119, processing);
46108
+ renameSync15(path120, processing);
46109
46109
  }
46110
- appendFileSync4(path119, "", "utf8");
46110
+ appendFileSync4(path120, "", "utf8");
46111
46111
  });
46112
46112
  if (!existsSync31(processing)) return 0;
46113
46113
  } catch (error) {
@@ -51308,11 +51308,11 @@ async function readLastConsolidatedAt(memoryDir) {
51308
51308
  }
51309
51309
  }
51310
51310
  async function tryAcquireConsolidationLock(memoryDir) {
51311
- const path119 = lockPath(memoryDir);
51311
+ const path120 = lockPath(memoryDir);
51312
51312
  let mtimeMs;
51313
51313
  let holderPid;
51314
51314
  try {
51315
- const [s, raw] = await Promise.all([stat2(path119), readFile4(path119, "utf8")]);
51315
+ const [s, raw] = await Promise.all([stat2(path120), readFile4(path120, "utf8")]);
51316
51316
  mtimeMs = s.mtimeMs;
51317
51317
  const parsed = parseInt(raw.trim(), 10);
51318
51318
  holderPid = Number.isFinite(parsed) ? parsed : void 0;
@@ -51325,10 +51325,10 @@ async function tryAcquireConsolidationLock(memoryDir) {
51325
51325
  }
51326
51326
  }
51327
51327
  await mkdir4(memoryDir, { recursive: true });
51328
- await writeFile4(path119, String(process.pid));
51328
+ await writeFile4(path120, String(process.pid));
51329
51329
  let verify4;
51330
51330
  try {
51331
- verify4 = await readFile4(path119, "utf8");
51331
+ verify4 = await readFile4(path120, "utf8");
51332
51332
  } catch {
51333
51333
  return null;
51334
51334
  }
@@ -51336,15 +51336,15 @@ async function tryAcquireConsolidationLock(memoryDir) {
51336
51336
  return mtimeMs ?? 0;
51337
51337
  }
51338
51338
  async function rollbackConsolidationLock(memoryDir, priorMtime) {
51339
- const path119 = lockPath(memoryDir);
51339
+ const path120 = lockPath(memoryDir);
51340
51340
  try {
51341
51341
  if (priorMtime === 0) {
51342
- await unlink2(path119);
51342
+ await unlink2(path120);
51343
51343
  return;
51344
51344
  }
51345
- await writeFile4(path119, "");
51345
+ await writeFile4(path120, "");
51346
51346
  const t = priorMtime / 1e3;
51347
- await utimes(path119, t, t);
51347
+ await utimes(path120, t, t);
51348
51348
  } catch (e) {
51349
51349
  console.log(`[autoDream] rollback failed: ${e.message} \u2014 next trigger delayed to minHours`);
51350
51350
  }
@@ -51703,7 +51703,7 @@ var require_email_config = __commonJS({
51703
51703
  "templates/skills/email/scripts/email-config.js"(exports, module) {
51704
51704
  "use strict";
51705
51705
  var fs111 = __require("node:fs");
51706
- var path119 = __require("node:path");
51706
+ var path120 = __require("node:path");
51707
51707
  var PROVIDER_MAP = {
51708
51708
  "qq.com": { imap: ["imap.qq.com", 993], smtp: ["smtp.qq.com", 465, true] },
51709
51709
  "foxmail.com": { imap: ["imap.qq.com", 993], smtp: ["smtp.qq.com", 465, true] },
@@ -51731,7 +51731,7 @@ var require_email_config = __commonJS({
51731
51731
  function resolveEmailConfig(opts = {}) {
51732
51732
  const stateDir = opts.stateDir || process.env.ENGINE_STATE_DIR || process.env.ENGINE7_STATE_DIR || null;
51733
51733
  const configFilePath = opts.configFilePath || process.env.ENGINE7_CONFIG_FILE || process.env.ENGINE_CONFIG;
51734
- const configFiles = configFilePath ? [path119.resolve(configFilePath)] : stateDir ? [path119.join(stateDir, "configs", "main.json")] : [];
51734
+ const configFiles = configFilePath ? [path120.resolve(configFilePath)] : stateDir ? [path120.join(stateDir, "configs", "main.json")] : [];
51735
51735
  if (configFiles.length) {
51736
51736
  for (const p of configFiles) {
51737
51737
  try {
@@ -51766,7 +51766,7 @@ var require_email_config = __commonJS({
51766
51766
  }
51767
51767
  }
51768
51768
  }
51769
- const envFile = opts.envFile || path119.join(__dirname, "..", ".env");
51769
+ const envFile = opts.envFile || path120.join(__dirname, "..", ".env");
51770
51770
  if (fs111.existsSync(envFile)) {
51771
51771
  const parsed = {};
51772
51772
  for (const line of fs111.readFileSync(envFile, "utf8").split(/\r?\n/)) {
@@ -56264,9 +56264,9 @@ async function executeAndDeliver(task, now2, deps) {
56264
56264
  let filePath2 = promptText.slice(1).trim();
56265
56265
  try {
56266
56266
  const fs111 = await import("fs");
56267
- const path119 = await import("path");
56268
- if (!path119.isAbsolute(filePath2)) {
56269
- filePath2 = path119.join(deps.sessions["config"].stateDir, filePath2);
56267
+ const path120 = await import("path");
56268
+ if (!path120.isAbsolute(filePath2)) {
56269
+ filePath2 = path120.join(deps.sessions["config"].stateDir, filePath2);
56270
56270
  }
56271
56271
  promptText = fs111.readFileSync(filePath2, "utf-8");
56272
56272
  console.log(`[cron] Loaded prompt from ${filePath2} (${promptText.length} chars)`);
@@ -56329,15 +56329,15 @@ async function executeAndDeliver(task, now2, deps) {
56329
56329
  let finalResult = result2;
56330
56330
  if (task.postProcess) {
56331
56331
  try {
56332
- const path119 = await import("path");
56332
+ const path120 = await import("path");
56333
56333
  const fs111 = await import("fs");
56334
56334
  let scriptPath = task.postProcess;
56335
- if (!path119.isAbsolute(scriptPath)) {
56336
- scriptPath = path119.join(deps.sessions["config"].stateDir, scriptPath);
56335
+ if (!path120.isAbsolute(scriptPath)) {
56336
+ scriptPath = path120.join(deps.sessions["config"].stateDir, scriptPath);
56337
56337
  }
56338
- const resultsDirTmp = path119.join(getStorageDir(), "results");
56338
+ const resultsDirTmp = path120.join(getStorageDir(), "results");
56339
56339
  fs111.mkdirSync(resultsDirTmp, { recursive: true });
56340
- const inputFile = path119.join(resultsDirTmp, `${task.id}.input.txt`);
56340
+ const inputFile = path120.join(resultsDirTmp, `${task.id}.input.txt`);
56341
56341
  fs111.writeFileSync(inputFile, result2, "utf-8");
56342
56342
  const { execFile: execFile9 } = await import("child_process");
56343
56343
  await new Promise((resolve42) => {
@@ -56366,10 +56366,10 @@ async function executeAndDeliver(task, now2, deps) {
56366
56366
  }
56367
56367
  try {
56368
56368
  const fs111 = await import("fs");
56369
- const path119 = await import("path");
56370
- const resultsDir = path119.join(getStorageDir(), "results");
56369
+ const path120 = await import("path");
56370
+ const resultsDir = path120.join(getStorageDir(), "results");
56371
56371
  fs111.mkdirSync(resultsDir, { recursive: true });
56372
- const resultFile = path119.join(resultsDir, `${task.id}.json`);
56372
+ const resultFile = path120.join(resultsDir, `${task.id}.json`);
56373
56373
  fs111.writeFileSync(resultFile, JSON.stringify({
56374
56374
  taskId: task.id,
56375
56375
  description: task.description,
@@ -56703,13 +56703,13 @@ TTL: ${task.expiresAt || "\u6C38\u751F"}` };
56703
56703
  },
56704
56704
  handler: async (args2) => {
56705
56705
  const fs111 = await import("fs");
56706
- const path119 = await import("path");
56707
- const resultsDir = path119.join(getStorageDir(), "results");
56706
+ const path120 = await import("path");
56707
+ const resultsDir = path120.join(getStorageDir(), "results");
56708
56708
  if (!fs111.existsSync(resultsDir)) {
56709
56709
  return { content: "\u6682\u65E0cron\u6267\u884C\u7ED3\u679C" };
56710
56710
  }
56711
56711
  if (args2.task_id) {
56712
- const file3 = path119.join(resultsDir, `${args2.task_id}.json`);
56712
+ const file3 = path120.join(resultsDir, `${args2.task_id}.json`);
56713
56713
  if (!fs111.existsSync(file3)) {
56714
56714
  return { content: `\u4EFB\u52A1 ${args2.task_id} \u6682\u65E0\u6267\u884C\u7ED3\u679C`, isError: true };
56715
56715
  }
@@ -56725,7 +56725,7 @@ ${data.result}` };
56725
56725
  return { content: "\u6682\u65E0cron\u6267\u884C\u7ED3\u679C" };
56726
56726
  }
56727
56727
  const results = files.map((f) => {
56728
- const data = JSON.parse(fs111.readFileSync(path119.join(resultsDir, f), "utf-8"));
56728
+ const data = JSON.parse(fs111.readFileSync(path120.join(resultsDir, f), "utf-8"));
56729
56729
  return `### ${data.description} (${data.taskId.slice(0, 8)})
56730
56730
  \u6267\u884C: ${data.executedAt} | \u7B2C${data.runCount}\u6B21
56731
56731
  ${data.result.slice(0, 500)}${data.result.length > 500 ? "..." : ""}`;
@@ -58545,10 +58545,10 @@ async function validateLegacyTopicsBackup(state2, directory2, history) {
58545
58545
  }
58546
58546
  const readTree = async (root) => {
58547
58547
  for (const entry of await readdir2(unlinked(root), { withFileTypes: true })) {
58548
- const path119 = unlinked(join96(root, entry.name));
58549
- if (entry.isDirectory()) await readTree(path119);
58548
+ const path120 = unlinked(join96(root, entry.name));
58549
+ if (entry.isDirectory()) await readTree(path120);
58550
58550
  else if (entry.isFile()) {
58551
- const file3 = await open2(path119, "r");
58551
+ const file3 = await open2(path120, "r");
58552
58552
  try {
58553
58553
  const buffer = Buffer.allocUnsafe(64 * 1024);
58554
58554
  while ((await file3.read(buffer)).bytesRead > 0) {
@@ -58617,9 +58617,9 @@ async function validateCompletedTopicsImport(state2, history) {
58617
58617
  db2.close();
58618
58618
  }
58619
58619
  const prose = /* @__PURE__ */ new Map(), idsByHash = /* @__PURE__ */ new Map();
58620
- const scan = async (path120) => {
58621
- for (const entry of await readdir3(unlinked(path120), { withFileTypes: true })) {
58622
- const file3 = unlinked(join97(path120, entry.name));
58620
+ const scan = async (path121) => {
58621
+ for (const entry of await readdir3(unlinked(path121), { withFileTypes: true })) {
58622
+ const file3 = unlinked(join97(path121, entry.name));
58623
58623
  if (entry.isDirectory()) await scan(file3);
58624
58624
  else if (entry.isFile() && entry.name.endsWith(".md")) {
58625
58625
  const text5 = await readFile5(file3, "utf8");
@@ -58655,9 +58655,9 @@ async function validateCompletedTopicsImport(state2, history) {
58655
58655
  }
58656
58656
  }
58657
58657
  const loaded2 = await import(lanceSpecifierFor(process.platform, process.arch)), lance = loaded2.connect ? loaded2 : loaded2.default;
58658
- const path119 = unlinked(join97(root, "index", "lancedb"));
58659
- if (!existsSync56(path119)) throw new Error("TOPICS_IMPORT_LIVE_VECTORS_MISSING");
58660
- const connection = await lance.connect(path119), vectorIds = /* @__PURE__ */ new Set();
58658
+ const path120 = unlinked(join97(root, "index", "lancedb"));
58659
+ if (!existsSync56(path120)) throw new Error("TOPICS_IMPORT_LIVE_VECTORS_MISSING");
58660
+ const connection = await lance.connect(path120), vectorIds = /* @__PURE__ */ new Set();
58661
58661
  try {
58662
58662
  for (const name of await connection.tableNames()) {
58663
58663
  const table = await connection.openTable(name);
@@ -58796,10 +58796,10 @@ function ensureLoaded(workspace, configIds) {
58796
58796
  if (!state.blockedUserIds.includes(id3)) state.blockedUserIds.push(id3);
58797
58797
  }
58798
58798
  }
58799
- const path119 = join101(workspace, ".reply-blocklist.json");
58799
+ const path120 = join101(workspace, ".reply-blocklist.json");
58800
58800
  try {
58801
- if (existsSync59(path119)) {
58802
- const raw = readFileSync76(path119, "utf-8");
58801
+ if (existsSync59(path120)) {
58802
+ const raw = readFileSync76(path120, "utf-8");
58803
58803
  const parsed = JSON.parse(raw);
58804
58804
  if (parsed.blockedUserIds) {
58805
58805
  for (const id3 of parsed.blockedUserIds) {
@@ -58815,9 +58815,9 @@ function ensureLoaded(workspace, configIds) {
58815
58815
  loaded = true;
58816
58816
  }
58817
58817
  function save2(workspace) {
58818
- const path119 = join101(workspace, ".reply-blocklist.json");
58818
+ const path120 = join101(workspace, ".reply-blocklist.json");
58819
58819
  try {
58820
- writeFileSync39(path119, JSON.stringify(state, null, 2), "utf-8");
58820
+ writeFileSync39(path120, JSON.stringify(state, null, 2), "utf-8");
58821
58821
  } catch (err) {
58822
58822
  console.warn(`[reply-blocklist] Failed to save: ${err.message}`);
58823
58823
  }
@@ -64052,6 +64052,78 @@ var init_features2 = __esm({
64052
64052
  }
64053
64053
  });
64054
64054
 
64055
+ // src/mcp/bundled-npx.ts
64056
+ import { existsSync as existsSync76, readFileSync as readFileSync92 } from "node:fs";
64057
+ import { createRequire as createRequire12 } from "node:module";
64058
+ import * as path116 from "node:path";
64059
+ function defaultDeps() {
64060
+ const req = createRequire12(import.meta.url);
64061
+ return {
64062
+ execPath: process.execPath,
64063
+ electron: !!process.versions.electron,
64064
+ resolvePackageJson: (name) => {
64065
+ try {
64066
+ return req.resolve(`${name}/package.json`);
64067
+ } catch {
64068
+ return null;
64069
+ }
64070
+ },
64071
+ exists: existsSync76,
64072
+ readFile: (p) => readFileSync92(p, "utf-8")
64073
+ };
64074
+ }
64075
+ function parseNpxArgs(args2) {
64076
+ let i = 0;
64077
+ while (i < args2.length && args2[i].startsWith("-")) {
64078
+ if (!VALUELESS_FLAGS.has(args2[i])) return null;
64079
+ i++;
64080
+ }
64081
+ if (i >= args2.length) return null;
64082
+ return { spec: args2[i], passthrough: args2.slice(i + 1) };
64083
+ }
64084
+ function splitSpec(spec) {
64085
+ const at2 = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
64086
+ return at2 > 0 ? { name: spec.slice(0, at2), version: spec.slice(at2 + 1) } : { name: spec, version: "" };
64087
+ }
64088
+ function resolveStdioSpawn(c, deps = defaultDeps()) {
64089
+ const asConfigured = { command: c.command, args: c.args ?? [], env: c.env, bundled: null };
64090
+ if (c.type && c.type !== "stdio") return asConfigured;
64091
+ if (!NPX.has(path116.basename(c.command).toLowerCase())) return asConfigured;
64092
+ const parsed = parseNpxArgs(c.args ?? []);
64093
+ if (!parsed) return asConfigured;
64094
+ const { name, version: version2 } = splitSpec(parsed.spec);
64095
+ if (!ANY_VERSION.has(version2)) return asConfigured;
64096
+ const pkgJson = deps.resolvePackageJson(name);
64097
+ if (!pkgJson) return asConfigured;
64098
+ let pkg;
64099
+ try {
64100
+ pkg = JSON.parse(deps.readFile(pkgJson));
64101
+ } catch {
64102
+ return asConfigured;
64103
+ }
64104
+ const bins = pkg.bin;
64105
+ const bin = typeof bins === "string" ? bins : bins && typeof bins === "object" && Object.keys(bins).length === 1 ? Object.values(bins)[0] : void 0;
64106
+ if (typeof bin !== "string" || typeof pkg.version !== "string") return asConfigured;
64107
+ const cli = path116.join(path116.dirname(pkgJson), bin);
64108
+ if (!deps.exists(cli)) return asConfigured;
64109
+ const env = { ...deps.electron ? { ELECTRON_RUN_AS_NODE: "1" } : {}, ...c.env ?? {} };
64110
+ return {
64111
+ command: deps.execPath,
64112
+ args: [cli, ...parsed.passthrough],
64113
+ env: Object.keys(env).length ? env : void 0,
64114
+ bundled: `${name}@${pkg.version}`
64115
+ };
64116
+ }
64117
+ var NPX, VALUELESS_FLAGS, ANY_VERSION;
64118
+ var init_bundled_npx = __esm({
64119
+ "src/mcp/bundled-npx.ts"() {
64120
+ "use strict";
64121
+ NPX = /* @__PURE__ */ new Set(["npx", "npx.cmd"]);
64122
+ VALUELESS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "-q", "--quiet", "--no-install"]);
64123
+ ANY_VERSION = /* @__PURE__ */ new Set(["", "latest", "*", "x"]);
64124
+ }
64125
+ });
64126
+
64055
64127
  // src/mcp/manager.ts
64056
64128
  var manager_exports = {};
64057
64129
  __export(manager_exports, {
@@ -64059,7 +64131,7 @@ __export(manager_exports, {
64059
64131
  convertInputSchema: () => convertInputSchema
64060
64132
  });
64061
64133
  import * as fs110 from "node:fs";
64062
- import * as path116 from "node:path";
64134
+ import * as path117 from "node:path";
64063
64135
  import { Client as Client4 } from "@modelcontextprotocol/sdk/client/index.js";
64064
64136
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
64065
64137
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
@@ -64100,9 +64172,9 @@ function convertInputSchema(inputSchema) {
64100
64172
  }
64101
64173
  function persistBinary(base64Data, mimeType, persistId) {
64102
64174
  const ext = mimeType?.split("/")[1] || "bin";
64103
- const dir = path116.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
64175
+ const dir = path117.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
64104
64176
  fs110.mkdirSync(dir, { recursive: true });
64105
- const filepath = path116.join(dir, `${persistId}.${ext}`);
64177
+ const filepath = path117.join(dir, `${persistId}.${ext}`);
64106
64178
  try {
64107
64179
  const buf = Buffer.from(base64Data, "base64");
64108
64180
  fs110.writeFileSync(filepath, buf);
@@ -64154,6 +64226,7 @@ var init_manager2 = __esm({
64154
64226
  "src/mcp/manager.ts"() {
64155
64227
  "use strict";
64156
64228
  init_registry();
64229
+ init_bundled_npx();
64157
64230
  CONNECT_TIMEOUT_MS = 3e4;
64158
64231
  MAX_RESULT_CHARS = 1e5;
64159
64232
  McpManager = class {
@@ -64377,7 +64450,9 @@ var init_manager2 = __esm({
64377
64450
  return;
64378
64451
  } else {
64379
64452
  const c = config2;
64380
- transport = new StdioClientTransport({ command: c.command, args: c.args ?? [], env: c.env ?? void 0, stderr: c.stderr ?? "inherit" });
64453
+ const spawn9 = resolveStdioSpawn(c);
64454
+ if (spawn9.bundled) console.log(`[mcp] ${serverName}: \u5F15\u64CE\u81EA\u5E26 ${spawn9.bundled}\uFF0C\u7528\u81EA\u5DF1\u7684 node \u76F4\u63A5\u542F\u52A8\uFF08\u4E0D\u8D70 npx\uFF09`);
64455
+ transport = new StdioClientTransport({ command: spawn9.command, args: spawn9.args, env: spawn9.env, stderr: c.stderr ?? "inherit" });
64381
64456
  }
64382
64457
  const client2 = new Client4({ name: "openclaw-engine", version: "0.1.0" }, { capabilities: {} });
64383
64458
  const timeoutMs = config2.connectTimeoutMs ?? CONNECT_TIMEOUT_MS;
@@ -64438,7 +64513,7 @@ __export(resources_exports, {
64438
64513
  registerMcpResourceTools: () => registerMcpResourceTools,
64439
64514
  unregisterMcpResourceTools: () => unregisterMcpResourceTools
64440
64515
  });
64441
- import * as path117 from "node:path";
64516
+ import * as path118 from "node:path";
64442
64517
  function registerMcpResourceTools(manager) {
64443
64518
  mcpManagerRef = manager;
64444
64519
  registry.register(listResourcesTool);
@@ -64456,7 +64531,7 @@ var init_resources = __esm({
64456
64531
  "use strict";
64457
64532
  init_registry();
64458
64533
  MAX_RESULT_CHARS2 = 1e5;
64459
- MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path117.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
64534
+ MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path118.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
64460
64535
  MCP_LIST_RESOURCES_TOOL = "mcp__list_resources";
64461
64536
  MCP_READ_RESOURCE_TOOL = "mcp__read_resource";
64462
64537
  mcpManagerRef = null;
@@ -64675,7 +64750,7 @@ function installTravelEngineControl(options) {
64675
64750
  }
64676
64751
 
64677
64752
  // src/engine-startup.ts
64678
- import * as path118 from "node:path";
64753
+ import * as path119 from "node:path";
64679
64754
 
64680
64755
  // src/tools/notification-receipts.ts
64681
64756
  init_execution_guard();
@@ -64984,9 +65059,9 @@ function relationshipNotifications(store, scope, includeQueued = false) {
64984
65059
  }
64985
65060
  async function appendGroupNoticeIntercept(workspace, entry) {
64986
65061
  const { appendFile, mkdir: mkdir8 } = await import("node:fs/promises");
64987
- const path119 = await import("node:path");
64988
- const file3 = path119.join(workspace, "memory", "group-routed-notices.md");
64989
- await mkdir8(path119.dirname(file3), { recursive: true });
65062
+ const path120 = await import("node:path");
65063
+ const file3 = path120.join(workspace, "memory", "group-routed-notices.md");
65064
+ await mkdir8(path120.dirname(file3), { recursive: true });
64990
65065
  await appendFile(file3, `## ${(/* @__PURE__ */ new Date()).toISOString()} ${entry.noticeId}
64991
65066
  - \u6765\u6E90\uFF1A${entry.scopeKey}
64992
65067
  - \u60F3\u6295\u5F80\uFF1A${entry.channel} \u7FA4 ${entry.target}
@@ -67304,7 +67379,7 @@ function syncLiveProviderCopy(cfg, change) {
67304
67379
  cfg.providers[match[1]].baseUrl = change.after;
67305
67380
  }
67306
67381
  function residualFromEnv(cfg, migrated) {
67307
- return planRelayEndpointMigration(cfg).map((change) => change.path).filter((path119) => !migrated.has(path119) && !/^providers?\./.test(path119));
67382
+ return planRelayEndpointMigration(cfg).map((change) => change.path).filter((path120) => !migrated.has(path120) && !/^providers?\./.test(path120));
67308
67383
  }
67309
67384
  async function applyRelayEndpointMigration(io) {
67310
67385
  const cfg = io.all();
@@ -67594,13 +67669,13 @@ function sessionStateDir(fileOrDirectory) {
67594
67669
  return ["sessions", "sessions-cron"].includes(basename14(directory2)) && basename14(dirname30(dirname30(directory2))) === "agents" ? dirname30(dirname30(dirname30(directory2))) : null;
67595
67670
  }
67596
67671
  function sessionFilePath(stateDir, file3) {
67597
- const path119 = relative8(stateDir, resolve25(file3)).replace(/\\/g, "/");
67598
- const match = /^agents\/([A-Za-z0-9][A-Za-z0-9_.-]{0,127})\/(sessions|sessions-cron)\/([^/]+)$/.exec(path119);
67599
- if (!match || /[\x00-\x1f<>:"|?*\\]/.test(path119) || match[3] === "." || match[3] === ".." || path119.split("/").some((part) => /[. ]$/.test(part) || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(part)))
67672
+ const path120 = relative8(stateDir, resolve25(file3)).replace(/\\/g, "/");
67673
+ const match = /^agents\/([A-Za-z0-9][A-Za-z0-9_.-]{0,127})\/(sessions|sessions-cron)\/([^/]+)$/.exec(path120);
67674
+ if (!match || /[\x00-\x1f<>:"|?*\\]/.test(path120) || match[3] === "." || match[3] === ".." || path120.split("/").some((part) => /[. ]$/.test(part) || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(part)))
67600
67675
  throw new Error("SESSION_PATH_UNSUPPORTED");
67601
67676
  const kind = /\.jsonl(?:\.|$)/.test(match[3]) ? "jsonl" : "blob";
67602
67677
  const id3 = kind === "jsonl" ? match[3].replace(/\.jsonl(?:\..*)?$/, "") : match[3];
67603
- return { path: path119, key: `agents/${match[1]}/${match[2] === "sessions-cron" ? "cron/" : ""}${id3}`, kind };
67678
+ return { path: path120, key: `agents/${match[1]}/${match[2] === "sessions-cron" ? "cron/" : ""}${id3}`, kind };
67604
67679
  }
67605
67680
  function syncSessionDirectory(directory2) {
67606
67681
  if (process.platform === "win32") return;
@@ -67625,14 +67700,14 @@ function prepareSessionDirectory(directory2) {
67625
67700
  parent = dirname30(parent);
67626
67701
  }
67627
67702
  if (realpathSync9(parent) !== parent || !lstatSync12(parent).isDirectory()) throw new Error("SESSION_SYMLINK_REFUSED");
67628
- for (const path119 of missing.reverse()) {
67703
+ for (const path120 of missing.reverse()) {
67629
67704
  try {
67630
- mkdirSync29(path119, { mode: 448 });
67705
+ mkdirSync29(path120, { mode: 448 });
67631
67706
  } catch (error) {
67632
67707
  if (error.code !== "EEXIST") throw error;
67633
67708
  }
67634
- if (!lstatSync12(path119).isDirectory() || realpathSync9(path119) !== path119) throw new Error("SESSION_SYMLINK_REFUSED");
67635
- syncSessionDirectory(dirname30(path119));
67709
+ if (!lstatSync12(path120).isDirectory() || realpathSync9(path120) !== path120) throw new Error("SESSION_SYMLINK_REFUSED");
67710
+ syncSessionDirectory(dirname30(path120));
67636
67711
  }
67637
67712
  }
67638
67713
  function sessionFileSignature(file3) {
@@ -67651,8 +67726,8 @@ function frameBytes(row) {
67651
67726
  if (createHash46("sha256").update(bytes3).digest("hex") !== row.digest) throw new Error("SESSION_EVENT_CORRUPT");
67652
67727
  return bytes3;
67653
67728
  }
67654
- function mapSessionIndex(bytes3, _db, path119, stateDir, sourceRoot, targetRoot) {
67655
- if (basename14(path119) !== "session-index.json") return bytes3;
67729
+ function mapSessionIndex(bytes3, _db, path120, stateDir, sourceRoot, targetRoot) {
67730
+ if (basename14(path120) !== "session-index.json") return bytes3;
67656
67731
  let index;
67657
67732
  try {
67658
67733
  index = JSON.parse(bytes3.toString("utf8"));
@@ -67671,30 +67746,30 @@ function mapSessionIndex(bytes3, _db, path119, stateDir, sourceRoot, targetRoot)
67671
67746
  }
67672
67747
  return Buffer.from(JSON.stringify(index, null, 2));
67673
67748
  }
67674
- function canonicalSessionIndex(bytes3, db2, path119, sourceRoot, stateDir) {
67675
- return mapSessionIndex(bytes3, db2, path119, stateDir, sourceRoot, sourceRoot);
67749
+ function canonicalSessionIndex(bytes3, db2, path120, sourceRoot, stateDir) {
67750
+ return mapSessionIndex(bytes3, db2, path120, stateDir, sourceRoot, sourceRoot);
67676
67751
  }
67677
- function portableIndex(bytes3, db2, path119, sourceRoot, destination) {
67752
+ function portableIndex(bytes3, db2, path120, sourceRoot, destination) {
67678
67753
  if (sourceRoot === destination) return bytes3;
67679
- return mapSessionIndex(bytes3, db2, path119, destination, sourceRoot, destination);
67754
+ return mapSessionIndex(bytes3, db2, path120, destination, sourceRoot, destination);
67680
67755
  }
67681
- function projectSessionFile(db2, cursors, stateDir, path119, sourceRoot) {
67682
- sessionFilePath(stateDir, join66(stateDir, path119));
67683
- const record = db2.prepare("SELECT * FROM session_files WHERE path=?").get(path119);
67756
+ function projectSessionFile(db2, cursors, stateDir, path120, sourceRoot) {
67757
+ sessionFilePath(stateDir, join66(stateDir, path120));
67758
+ const record = db2.prepare("SELECT * FROM session_files WHERE path=?").get(path120);
67684
67759
  if (!record) throw new Error("SESSION_FILE_NOT_REGISTERED");
67685
- const file3 = join66(stateDir, path119), signature2 = sessionFileSignature(file3);
67760
+ const file3 = join66(stateDir, path120), signature2 = sessionFileSignature(file3);
67686
67761
  prepareSessionDirectory(dirname30(file3));
67687
67762
  if (record.state === "removed") {
67688
67763
  if (signature2 !== null) {
67689
67764
  unlinkSync10(file3);
67690
67765
  syncSessionDirectory(dirname30(file3));
67691
67766
  }
67692
- cursors.prepare("DELETE FROM cursors WHERE path=?").run(path119);
67767
+ cursors.prepare("DELETE FROM cursors WHERE path=?").run(path120);
67693
67768
  return;
67694
67769
  }
67695
67770
  if (record.state !== "active" || !["jsonl", "blob"].includes(String(record.kind))) throw new Error("SESSION_FILE_CORRUPT");
67696
- const count = Number(db2.prepare("SELECT count(*) n FROM session_file_events WHERE path=?").get(path119).n);
67697
- const cursor2 = cursors.prepare("SELECT * FROM cursors WHERE path=?").get(path119);
67771
+ const count = Number(db2.prepare("SELECT count(*) n FROM session_file_events WHERE path=?").get(path120).n);
67772
+ const cursor2 = cursors.prepare("SELECT * FROM cursors WHERE path=?").get(path120);
67698
67773
  const incremental = record.kind === "jsonl" && cursor2 && cursor2.generation === record.generation && cursor2.signature === signature2 && Number(cursor2.frames) <= count;
67699
67774
  if (incremental && cursor2.revision === record.revision && Number(cursor2.frames) === count) return;
67700
67775
  const temp = join66(dirname30(file3), ".session-" + randomUUID24() + ".partial");
@@ -67704,13 +67779,13 @@ function projectSessionFile(db2, cursors, stateDir, path119, sourceRoot) {
67704
67779
  fd = openSync15(target, (incremental ? constants6.O_WRONLY | constants6.O_APPEND : constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL) | (constants6.O_NOFOLLOW ?? 0), 384);
67705
67780
  let frames2 = start;
67706
67781
  const rows = db2.prepare(`SELECT f.ordinal,e.body,e.digest FROM session_file_events f JOIN session_events e ON e.sequence=f.event_sequence
67707
- WHERE f.path=? AND f.ordinal>? ORDER BY f.ordinal`).iterate(path119, start);
67782
+ WHERE f.path=? AND f.ordinal>? ORDER BY f.ordinal`).iterate(path120, start);
67708
67783
  for (const row of rows) {
67709
67784
  if (Number(row.ordinal) !== ++frames2) throw new Error("SESSION_FILE_EVENT_GAP");
67710
67785
  let body2 = frameBytes(row);
67711
67786
  if (record.kind === "blob") {
67712
67787
  if (count !== 1) throw new Error("SESSION_FILE_CORRUPT");
67713
- body2 = portableIndex(body2, db2, path119, sourceRoot, stateDir);
67788
+ body2 = portableIndex(body2, db2, path120, sourceRoot, stateDir);
67714
67789
  }
67715
67790
  appendFileSync5(fd, body2);
67716
67791
  }
@@ -67724,7 +67799,7 @@ function projectSessionFile(db2, cursors, stateDir, path119, sourceRoot) {
67724
67799
  if (after === null || !after.startsWith(`${info.dev}:${info.ino}:${info.size}:`)) throw new Error("SESSION_PROJECTION_CHANGED");
67725
67800
  syncSessionDirectory(dirname30(file3));
67726
67801
  cursors.prepare(`INSERT INTO cursors VALUES(?,?,?,?,?) ON CONFLICT(path) DO UPDATE SET generation=excluded.generation,
67727
- revision=excluded.revision,frames=excluded.frames,signature=excluded.signature`).run(path119, record.generation, record.revision, count, after);
67802
+ revision=excluded.revision,frames=excluded.frames,signature=excluded.signature`).run(path120, record.generation, record.revision, count, after);
67728
67803
  complete = true;
67729
67804
  } finally {
67730
67805
  if (fd !== void 0) closeSync15(fd);
@@ -67758,10 +67833,10 @@ function privateDatabase(file3, create) {
67758
67833
  prepareSessionDirectory(dirname31(file3));
67759
67834
  const directory2 = lstatSync13(dirname31(file3));
67760
67835
  if (process.platform !== "win32" && (directory2.mode & 63 || directory2.uid !== process.getuid())) throw new Error("SESSION_PRIVATE_CONTROL_REQUIRED");
67761
- for (const path119 of [file3, file3 + "-journal", file3 + "-wal", file3 + "-shm"]) {
67836
+ for (const path120 of [file3, file3 + "-journal", file3 + "-wal", file3 + "-shm"]) {
67762
67837
  try {
67763
- const info = lstatSync13(path119);
67764
- if (!info.isFile() || info.isSymbolicLink() || realpathSync10(path119) !== resolve26(path119) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid())) throw new Error("SESSION_PRIVATE_CONTROL_REQUIRED");
67838
+ const info = lstatSync13(path120);
67839
+ if (!info.isFile() || info.isSymbolicLink() || realpathSync10(path120) !== resolve26(path120) || process.platform !== "win32" && (info.mode & 63 || info.uid !== process.getuid())) throw new Error("SESSION_PRIVATE_CONTROL_REQUIRED");
67765
67840
  } catch (error) {
67766
67841
  if (error.code !== "ENOENT") throw error;
67767
67842
  }
@@ -67905,8 +67980,8 @@ var SessionEventStore = class {
67905
67980
  }
67906
67981
  return null;
67907
67982
  }
67908
- projectPath(path119) {
67909
- projectSessionFile(this.db, this.cursors, this.stateDir, path119, this.sourceRoot);
67983
+ projectPath(path120) {
67984
+ projectSessionFile(this.db, this.cursors, this.stateDir, path120, this.sourceRoot);
67910
67985
  }
67911
67986
  project(file3) {
67912
67987
  this.locked(() => this.projectPath(sessionFilePath(this.stateDir, file3).path));
@@ -69970,18 +70045,18 @@ var queryModeWatchers = /* @__PURE__ */ new Map();
69970
70045
  var backgroundRecalls = /* @__PURE__ */ new Map();
69971
70046
  var externalChanRulesCache = null;
69972
70047
  function loadExternalChanRules(workspace) {
69973
- const path119 = join80(workspace, "prompts", "external-chan-rules.md");
69974
- if (externalChanRulesCache && externalChanRulesCache.path === path119) return externalChanRulesCache;
70048
+ const path120 = join80(workspace, "prompts", "external-chan-rules.md");
70049
+ if (externalChanRulesCache && externalChanRulesCache.path === path120) return externalChanRulesCache;
69975
70050
  let content = "";
69976
- if (existsSync48(path119)) {
70051
+ if (existsSync48(path120)) {
69977
70052
  try {
69978
- content = readFileSync63(path119, "utf-8").trim();
70053
+ content = readFileSync63(path120, "utf-8").trim();
69979
70054
  } catch (e) {
69980
70055
  console.warn(`[external-chan-rules] Failed to load: ${e}`);
69981
70056
  }
69982
70057
  }
69983
- externalChanRulesCache = { path: path119, content };
69984
- console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path119}`);
70058
+ externalChanRulesCache = { path: path120, content };
70059
+ console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path120}`);
69985
70060
  return externalChanRulesCache;
69986
70061
  }
69987
70062
  function getExternalChanRulesBlock(inboundMeta, workspace) {
@@ -70148,7 +70223,7 @@ async function handleQueryInner(text5, sessionId, channelName, cb, deps, channel
70148
70223
  );
70149
70224
  console.log(`[query-prep] steer inputs restored (${Date.now() - prepT0}ms)`);
70150
70225
  const preserveSnapshots = liveConfig.get("mem7.enabled") === true;
70151
- const removedRecall = stripRecalledMemories(history, (path119, memory) => isCurrentMemoryContextPath(path119) && (!preserveSnapshots || !memory.snapshotProof));
70226
+ const removedRecall = stripRecalledMemories(history, (path120, memory) => isCurrentMemoryContextPath(path120) && (!preserveSnapshots || !memory.snapshotProof));
70152
70227
  if (removedRecall > 0) console.log(`[handle-query] Removed ${removedRecall} cached recall entries before this round`);
70153
70228
  for (const p of sessions2.getRestoredRecallPaths(sessionId)) {
70154
70229
  if (isCurrentMemoryContextPath(p)) sessions2.getRestoredRecallPaths(sessionId).delete(p);
@@ -77694,23 +77769,23 @@ function coerceFieldValue(field, value) {
77694
77769
  async function applyConfigValues(values) {
77695
77770
  const applied = [];
77696
77771
  const rejected = [];
77697
- for (const [path119, value] of Object.entries(values)) {
77772
+ for (const [path120, value] of Object.entries(values)) {
77698
77773
  if (value === null || value === void 0) continue;
77699
- const field = getField(path119);
77774
+ const field = getField(path120);
77700
77775
  if (!field) {
77701
- rejected.push({ path: path119, error: "\u672A\u6CE8\u518C\u7684\u914D\u7F6E\u9879\uFF08\u53EA\u80FD\u5199 registry \u58F0\u660E\u8FC7\u7684\u5B57\u6BB5\uFF09" });
77776
+ rejected.push({ path: path120, error: "\u672A\u6CE8\u518C\u7684\u914D\u7F6E\u9879\uFF08\u53EA\u80FD\u5199 registry \u58F0\u660E\u8FC7\u7684\u5B57\u6BB5\uFF09" });
77702
77777
  continue;
77703
77778
  }
77704
77779
  const c = coerceFieldValue(field, value);
77705
77780
  if (c.error) {
77706
- rejected.push({ path: path119, error: c.error });
77781
+ rejected.push({ path: path120, error: c.error });
77707
77782
  continue;
77708
77783
  }
77709
77784
  try {
77710
- await liveConfig.set(path119, c.value);
77711
- applied.push({ path: path119, effect: field.effect });
77785
+ await liveConfig.set(path120, c.value);
77786
+ applied.push({ path: path120, effect: field.effect });
77712
77787
  } catch (e) {
77713
- rejected.push({ path: path119, error: e.message });
77788
+ rejected.push({ path: path120, error: e.message });
77714
77789
  }
77715
77790
  }
77716
77791
  return { applied, rejected };
@@ -78515,12 +78590,12 @@ async function startHttpApi(ctx) {
78515
78590
  if (!consoleAllowed(req)) return deny(res);
78516
78591
  try {
78517
78592
  const fs111 = await import("node:fs");
78518
- const path119 = await import("node:path");
78519
- const logsDir = path119.join(String(config2.stateDir ?? ""), "logs");
78593
+ const path120 = await import("node:path");
78594
+ const logsDir = path120.join(String(config2.stateDir ?? ""), "logs");
78520
78595
  const files = fs111.existsSync(logsDir) ? fs111.readdirSync(logsDir).filter((f) => /^engine-\d{4}-\d{2}-\d{2}\.log$/.test(f)).sort() : [];
78521
78596
  const lines = [];
78522
78597
  if (files.length) {
78523
- const raw = fs111.readFileSync(path119.join(logsDir, files[files.length - 1]), "utf-8").split(/\r?\n/).filter((l) => l.length > 0);
78598
+ const raw = fs111.readFileSync(path120.join(logsDir, files[files.length - 1]), "utf-8").split(/\r?\n/).filter((l) => l.length > 0);
78524
78599
  lines.push(...raw.slice(-300));
78525
78600
  }
78526
78601
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -80222,8 +80297,8 @@ function openPhysicalMaintenanceDatabase(file3, stateDir) {
80222
80297
  }
80223
80298
 
80224
80299
  // src/mem7/sqlite-maintenance-worker.ts
80225
- function intakePendingForDatabase(path119) {
80226
- const spool = join98(dirname40(dirname40(path119)), "spool");
80300
+ function intakePendingForDatabase(path120) {
80301
+ const spool = join98(dirname40(dirname40(path120)), "spool");
80227
80302
  return ["intake.jsonl", "intake.processing.jsonl"].some((name) => {
80228
80303
  try {
80229
80304
  return statSync21(join98(spool, name)).size > 0;
@@ -80233,22 +80308,22 @@ function intakePendingForDatabase(path119) {
80233
80308
  }
80234
80309
  });
80235
80310
  }
80236
- var bytes = (path119) => {
80311
+ var bytes = (path120) => {
80237
80312
  try {
80238
- return statSync21(path119).size;
80313
+ return statSync21(path120).size;
80239
80314
  } catch (e) {
80240
80315
  if (e.code !== "ENOENT") throw e;
80241
80316
  return 0;
80242
80317
  }
80243
80318
  };
80244
- async function runSqlitePhysicalMaintenance(path119, options = {}) {
80319
+ async function runSqlitePhysicalMaintenance(path120, options = {}) {
80245
80320
  const minimum = options.minFreeBytes ?? 32 * 1024 * 1024, ratio = options.minFreeRatio ?? 0.05;
80246
80321
  if (!Number.isFinite(minimum) || minimum < 0 || !Number.isFinite(ratio) || ratio < 0 || ratio > 1) throw new Error("INVALID_SQLITE_RETENTION_THRESHOLD");
80247
- const before = bytes(path119) + bytes(path119 + "-wal"), started = performance.now();
80248
- const allowed = () => options.shouldRun?.() !== false && !intakePendingForDatabase(path119);
80249
- const db2 = openPhysicalMaintenanceDatabase(path119, options.stateDir);
80322
+ const before = bytes(path120) + bytes(path120 + "-wal"), started = performance.now();
80323
+ const allowed = () => options.shouldRun?.() !== false && !intakePendingForDatabase(path120);
80324
+ const db2 = openPhysicalMaintenanceDatabase(path120, options.stateDir);
80250
80325
  let mode = "bootstrap";
80251
- const report = (state2) => ({ state: state2, mode, reclaimedBytes: Math.max(0, before - bytes(path119) - bytes(path119 + "-wal")) });
80326
+ const report = (state2) => ({ state: state2, mode, reclaimedBytes: Math.max(0, before - bytes(path120) - bytes(path120 + "-wal")) });
80252
80327
  try {
80253
80328
  db2.exec("PRAGMA busy_timeout=0");
80254
80329
  mode = Number(db2.prepare("PRAGMA auto_vacuum").get().auto_vacuum) === 2 ? "incremental" : "bootstrap";
@@ -80258,10 +80333,10 @@ async function runSqlitePhysicalMaintenance(path119, options = {}) {
80258
80333
  const pageSize = Number(db2.prepare("PRAGMA page_size").get().page_size);
80259
80334
  const pages = Number(db2.prepare("PRAGMA page_count").get().page_count);
80260
80335
  const free = Number(db2.prepare("PRAGMA freelist_count").get().freelist_count);
80261
- const oversized = bytes(path119) > pages * pageSize + 1024 * 1024;
80336
+ const oversized = bytes(path120) > pages * pageSize + 1024 * 1024;
80262
80337
  if (!oversized && (free * pageSize < minimum || free / Math.max(1, pages) < ratio)) return report("idle");
80263
80338
  if (mode === "bootstrap" || oversized) {
80264
- const disk = statfsSync2(dirname40(path119));
80339
+ const disk = statfsSync2(dirname40(path120));
80265
80340
  if (disk.bavail * disk.bsize < (pages - free) * pageSize * 2 + 64 * 1024 * 1024) return report("deferred");
80266
80341
  if (!allowed()) return report("deferred");
80267
80342
  options.onPhase?.("vacuum");
@@ -80280,7 +80355,7 @@ async function runSqlitePhysicalMaintenance(path119, options = {}) {
80280
80355
  }
80281
80356
  const finalCheckpoint = db2.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get();
80282
80357
  const finalPages = Number(db2.prepare("PRAGMA page_count").get().page_count);
80283
- if (finalCheckpoint.busy || bytes(path119) > finalPages * pageSize + 1024 * 1024) return report("deferred");
80358
+ if (finalCheckpoint.busy || bytes(path120) > finalPages * pageSize + 1024 * 1024) return report("deferred");
80284
80359
  return report("complete");
80285
80360
  } catch (error) {
80286
80361
  if (/database is locked|SQLITE_BUSY|SQLITE_LOCKED/i.test(String(error))) return report("deferred");
@@ -80291,9 +80366,9 @@ async function runSqlitePhysicalMaintenance(path119, options = {}) {
80291
80366
  }
80292
80367
  if (process.argv.includes("--sqlite-checkpoint")) {
80293
80368
  const flag = process.argv.indexOf("--sqlite-checkpoint");
80294
- const path119 = process.argv[flag + 1], stateDir = process.argv[flag + 2];
80369
+ const path120 = process.argv[flag + 1], stateDir = process.argv[flag + 2];
80295
80370
  registerRuntimeWriter(stateDir, "sqlite-checkpoint");
80296
- const db2 = openPhysicalMaintenanceDatabase(path119, stateDir);
80371
+ const db2 = openPhysicalMaintenanceDatabase(path120, stateDir);
80297
80372
  try {
80298
80373
  db2.exec("PRAGMA busy_timeout=15000");
80299
80374
  console.log("wal checkpoint " + JSON.stringify(db2.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get()));
@@ -80305,7 +80380,7 @@ if (process.argv.includes("--sqlite-checkpoint")) {
80305
80380
  }
80306
80381
  }
80307
80382
  if (process.argv.includes("--sqlite-maintenance")) {
80308
- const flag = process.argv.indexOf("--sqlite-maintenance"), path119 = resolve36(process.argv[flag + 1] ?? "");
80383
+ const flag = process.argv.indexOf("--sqlite-maintenance"), path120 = resolve36(process.argv[flag + 1] ?? "");
80309
80384
  if (!process.argv[flag + 1]) throw new Error("SQLITE_MAINTENANCE_PATH_REQUIRED");
80310
80385
  const config2 = process.argv[flag + 2] ? JSON.parse(process.argv[flag + 2]) : {};
80311
80386
  if (!config2.stateDir) throw new Error("SQLITE_MAINTENANCE_STATE_DIR_REQUIRED");
@@ -80325,9 +80400,9 @@ if (process.argv.includes("--sqlite-maintenance")) {
80325
80400
  }
80326
80401
  if (cancel) process.kill(process.pid, 'SIGTERM')
80327
80402
  }, 100)
80328
- `, { eval: true, workerData: { path: path119, ownerPid: process.connected ? process.ppid : null } });
80403
+ `, { eval: true, workerData: { path: path120, ownerPid: process.connected ? process.ppid : null } });
80329
80404
  try {
80330
- console.log(JSON.stringify(await runSqlitePhysicalMaintenance(path119, {
80405
+ console.log(JSON.stringify(await runSqlitePhysicalMaintenance(path120, {
80331
80406
  ...config2,
80332
80407
  onPhase: (phase) => {
80333
80408
  if (process.connected) process.send?.({ type: "sqliteMaintenancePhase", phase });
@@ -80369,9 +80444,9 @@ if (process.argv.includes("--validate-topics-import-live")) {
80369
80444
  }
80370
80445
 
80371
80446
  // src/bg/sqlite-maintenance.ts
80372
- var size = (path119) => {
80447
+ var size = (path120) => {
80373
80448
  try {
80374
- return statSync22(path119).size;
80449
+ return statSync22(path120).size;
80375
80450
  } catch (error) {
80376
80451
  if (error.code !== "ENOENT") throw error;
80377
80452
  return 0;
@@ -80386,7 +80461,7 @@ function live2(pid) {
80386
80461
  }
80387
80462
  }
80388
80463
  function createSqliteMaintenance(stateDir, options = {}) {
80389
- const path119 = join99(stateDir, "mem7", "index", "mem7.db"), marker = join99(stateDir, "mem7", "index", ".sqlite-maintenance.json");
80464
+ const path120 = join99(stateDir, "mem7", "index", "mem7.db"), marker = join99(stateDir, "mem7", "index", ".sqlite-maintenance.json");
80390
80465
  let child, completion, timer;
80391
80466
  let nextCheck = Date.now() + (options.firstRunDelayMs ?? 18e4), stopped = false;
80392
80467
  const idle = options.idleMs ?? 6e4;
@@ -80408,12 +80483,12 @@ function createSqliteMaintenance(stateDir, options = {}) {
80408
80483
  const poll = () => {
80409
80484
  try {
80410
80485
  if (child) {
80411
- if (stopped || intakePendingForDatabase(path119) || options.shouldRun?.() === false) void interrupt();
80486
+ if (stopped || intakePendingForDatabase(path120) || options.shouldRun?.() === false) void interrupt();
80412
80487
  return;
80413
80488
  }
80414
80489
  if (stopped || Date.now() < nextCheck || options.shouldRun?.() === false) return;
80415
80490
  nextCheck = Date.now() + (options.checkIntervalMs ?? 6e4);
80416
- if (!existsSync57(path119) || intakePendingForDatabase(path119)) return;
80491
+ if (!existsSync57(path120) || intakePendingForDatabase(path120)) return;
80417
80492
  if (Date.now() - lastRequest < idle) return;
80418
80493
  if (existsSync57(marker)) {
80419
80494
  let previous;
@@ -80424,14 +80499,14 @@ function createSqliteMaintenance(stateDir, options = {}) {
80424
80499
  if (Number.isSafeInteger(previous?.pid) && previous.pid > 0 && live2(previous.pid) && Number.isSafeInteger(previous.startedAt) && Date.now() - previous.startedAt < 24e4) return;
80425
80500
  unlinkSync17(marker);
80426
80501
  }
80427
- const db2 = new DatabaseSync21(path119, { readOnly: true });
80502
+ const db2 = new DatabaseSync21(path120, { readOnly: true });
80428
80503
  let eligible = false;
80429
80504
  try {
80430
80505
  db2.exec("PRAGMA query_only=ON");
80431
80506
  const pageSize = Number(db2.prepare("PRAGMA page_size").get().page_size);
80432
80507
  const pages = Number(db2.prepare("PRAGMA page_count").get().page_count);
80433
80508
  const free = Number(db2.prepare("PRAGMA freelist_count").get().freelist_count);
80434
- eligible = free * pageSize >= (options.minFreeBytes ?? 32 * 1024 * 1024) && free / Math.max(1, pages) >= 0.05 || size(path119) > pages * pageSize + 1024 * 1024 || size(path119 + "-wal") >= 32 * 1024 * 1024;
80509
+ eligible = free * pageSize >= (options.minFreeBytes ?? 32 * 1024 * 1024) && free / Math.max(1, pages) >= 0.05 || size(path120) > pages * pageSize + 1024 * 1024 || size(path120 + "-wal") >= 32 * 1024 * 1024;
80435
80510
  } finally {
80436
80511
  db2.close();
80437
80512
  }
@@ -80444,7 +80519,7 @@ function createSqliteMaintenance(stateDir, options = {}) {
80444
80519
  windowsHide: true,
80445
80520
  execArgv: entry.endsWith(".ts") ? ["--import", "tsx"] : []
80446
80521
  };
80447
- child = fork3(entry, ["--sqlite-maintenance", path119, JSON.stringify({ stateDir, minFreeBytes: options.minFreeBytes })], launchOptions);
80522
+ child = fork3(entry, ["--sqlite-maintenance", path120, JSON.stringify({ stateDir, minFreeBytes: options.minFreeBytes })], launchOptions);
80448
80523
  console.log("[bg-worker] SQLite physical reclaim started");
80449
80524
  const current2 = child;
80450
80525
  let output = "", errors = "";
@@ -84020,11 +84095,11 @@ var DiscordAdapter = class _DiscordAdapter {
84020
84095
  /** 发送媒体附件(图片/文件/音频)— discord.js channel.send({ files }) */
84021
84096
  async sendFile(target, message, attachment) {
84022
84097
  const fs111 = await import("node:fs");
84023
- const path119 = await import("node:path");
84098
+ const path120 = await import("node:path");
84024
84099
  if (!fs111.existsSync(attachment.path)) {
84025
84100
  throw new Error(`File not found: ${attachment.path}`);
84026
84101
  }
84027
- const filename = attachment.filename || path119.basename(attachment.path);
84102
+ const filename = attachment.filename || path120.basename(attachment.path);
84028
84103
  const fileBuffer = fs111.readFileSync(attachment.path);
84029
84104
  const filePayload = {
84030
84105
  attachment: fileBuffer,
@@ -84641,11 +84716,11 @@ var FeishuAdapter = class _FeishuAdapter {
84641
84716
  /** 发送媒体附件(图片/文件) */
84642
84717
  async sendFile(target, message, attachment) {
84643
84718
  const fs111 = await import("node:fs");
84644
- const path119 = await import("node:path");
84719
+ const path120 = await import("node:path");
84645
84720
  if (!fs111.existsSync(attachment.path)) {
84646
84721
  throw new Error(`File not found: ${attachment.path}`);
84647
84722
  }
84648
- const filename = attachment.filename || path119.basename(attachment.path);
84723
+ const filename = attachment.filename || path120.basename(attachment.path);
84649
84724
  const fileBuffer = fs111.readFileSync(attachment.path);
84650
84725
  const safeTarget = target || this.config.defaultTarget || "";
84651
84726
  if (!safeTarget) throw new Error("Feishu sendFile: no target (\u4E3B\u52A8\u53D1\u9001\u9700\u914D\u7F6E defaultTarget \u6216\u4F20\u5165 target)");
@@ -87034,10 +87109,10 @@ var DeskBuddyAdapter = class {
87034
87109
  if (!this.historyFile) {
87035
87110
  const os15 = __require("os");
87036
87111
  const fs112 = __require("fs");
87037
- const path119 = __require("path");
87038
- const dir = path119.join(os15.homedir(), "xiaowen", "workspace", ".desktopBuddy");
87112
+ const path120 = __require("path");
87113
+ const dir = path120.join(os15.homedir(), "xiaowen", "workspace", ".desktopBuddy");
87039
87114
  fs112.mkdirSync(dir, { recursive: true });
87040
- this.historyFile = path119.join(dir, "history.json");
87115
+ this.historyFile = path120.join(dir, "history.json");
87041
87116
  this._fs = fs112;
87042
87117
  }
87043
87118
  const fs111 = this._fs;
@@ -94437,8 +94512,8 @@ var SessionManager = class {
94437
94512
  let fixed = 0;
94438
94513
  for (const [key6, entry] of this.index) {
94439
94514
  if (fs92.existsSync(entry.file)) continue;
94440
- const basename29 = path94.basename(entry.file);
94441
- const localPath = path94.join(this.sessionsDir, basename29);
94515
+ const basename30 = path94.basename(entry.file);
94516
+ const localPath = path94.join(this.sessionsDir, basename30);
94442
94517
  if (fs92.existsSync(localPath)) {
94443
94518
  entry.file = localPath;
94444
94519
  fixed++;
@@ -97343,9 +97418,9 @@ function registerPortrait(relPath, name) {
97343
97418
  const cur = cfg?.tools?.my_selfie?.references || cfg?.my_selfie?.references || [];
97344
97419
  const next = Array.isArray(cur) ? cur.filter((r) => r?.name !== name) : [];
97345
97420
  next.unshift({ name, path: relPath });
97346
- const path119 = cfg?.tools?.my_selfie ? "tools.my_selfie.references" : "my_selfie.references";
97347
- void liveConfig.set(path119, next);
97348
- console.log(`[my-selfie] \u5F62\u8C61\u5DF2\u767B\u8BB0\uFF1A${path119}[0] = ${relPath}`);
97421
+ const path120 = cfg?.tools?.my_selfie ? "tools.my_selfie.references" : "my_selfie.references";
97422
+ void liveConfig.set(path120, next);
97423
+ console.log(`[my-selfie] \u5F62\u8C61\u5DF2\u767B\u8BB0\uFF1A${path120}[0] = ${relPath}`);
97349
97424
  } catch (e) {
97350
97425
  console.warn(`[my-selfie] \u5199\u5165 references \u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u672C\u6B21\u51FA\u56FE\uFF09: ${e.message}`);
97351
97426
  }
@@ -101601,7 +101676,7 @@ async function startEngine(config2, opts) {
101601
101676
  const { initSessionMemory: initSessionMemory2 } = await Promise.resolve().then(() => (init_sessionMemory(), sessionMemory_exports));
101602
101677
  initSessionMemory2({
101603
101678
  workspace: config2.workspace,
101604
- stateDir: path118.join(config2.stateDir, "session-memory"),
101679
+ stateDir: path119.join(config2.stateDir, "session-memory"),
101605
101680
  provider,
101606
101681
  model: config2.provider.modelId || config2.model || "deepseek-v4-flash",
101607
101682
  features: config2.profile.features
@@ -101885,7 +101960,7 @@ async function startEngine(config2, opts) {
101885
101960
  let failed = false;
101886
101961
  const finishHostDelivery = (state2, reason) => {
101887
101962
  if (!route?.hostDelivery) return;
101888
- const persist2 = new Persistence(path118.join(route.hostDelivery.workspace, ".proactive", "proactive.db"));
101963
+ const persist2 = new Persistence(path119.join(route.hostDelivery.workspace, ".proactive", "proactive.db"));
101889
101964
  try {
101890
101965
  persist2.hostDeliveries.finish(route.hostDelivery.key, state2, reason);
101891
101966
  } finally {
@@ -102271,8 +102346,8 @@ async function startEngine(config2, opts) {
102271
102346
  // src/main.ts
102272
102347
  init_version();
102273
102348
  init_key_service_store();
102274
- import { existsSync as existsSync76 } from "node:fs";
102275
- import { join as join126 } from "node:path";
102349
+ import { existsSync as existsSync77 } from "node:fs";
102350
+ import { join as join127 } from "node:path";
102276
102351
  var epipeSeen = false;
102277
102352
  process.on("uncaughtException", (err) => {
102278
102353
  const code = err?.code ?? "";
@@ -102348,13 +102423,13 @@ var config = loadConfig(configPath);
102348
102423
  console.log(`=== Engine 7 v${readEngineVersion2()} ===`);
102349
102424
  console.log(`PID: ${process.pid}`);
102350
102425
  console.log(configSummary(config));
102351
- var managedFile = join126(config.stateDir, ".continuity/travel-managed.json");
102352
- if (existsSync76(managedFile)) {
102426
+ var managedFile = join127(config.stateDir, ".continuity/travel-managed.json");
102427
+ if (existsSync77(managedFile)) {
102353
102428
  const binding = JSON.parse(readPrivateFile2(managedFile, 65536).toString());
102354
102429
  const { startPairingHost, readManagedPairingHostConfig } = await import(new URL("./travel-host.mjs", import.meta.url).href);
102355
102430
  const hostConfig = readManagedPairingHostConfig(config.stateDir, binding);
102356
- const readyFile = join126(hostConfig.directory, "host-ready.json");
102357
- const ready = existsSync76(readyFile) ? JSON.parse(readPrivateFile2(readyFile, 65536).toString()) : void 0;
102431
+ const readyFile = join127(hostConfig.directory, "host-ready.json");
102432
+ const ready = existsSync77(readyFile) ? JSON.parse(readPrivateFile2(readyFile, 65536).toString()) : void 0;
102358
102433
  if (ready && JSON.stringify(ready.identity) === JSON.stringify(binding.identity) && Number.isSafeInteger(ready.pid) && isPidAlive(ready.pid)) {
102359
102434
  console.log("[travel] \u968F\u884C\u7BA1\u7406\u5DF2\u5728\u539F\u63A7\u5236\u53F0\u8FD0\u884C");
102360
102435
  process.exit(0);