engine7 7.1.105 → 7.1.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -19965,17 +19965,46 @@ var init_filters = __esm({
19965
19965
  });
19966
19966
 
19967
19967
  // src/mem7/core/vector-store.ts
19968
- import * as lancedb from "@lancedb/lancedb";
19969
19968
  import { Schema, Field, Utf8, Float32, Int64, FixedSizeList, TimestampMicrosecond, List } from "apache-arrow";
19970
19969
  import { mkdirSync as mkdirSync14 } from "node:fs";
19971
19970
  import { join as join32 } from "node:path";
19972
- var VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
19971
+ function lanceSpecifierFor(platform2, arch) {
19972
+ return platform2 === "darwin" && arch === "x64" ? "@engine7/lancedb-intel" : "@lancedb/lancedb";
19973
+ }
19974
+ function loadLance() {
19975
+ if (!lancePromise) {
19976
+ const spec = lanceSpecifierFor(process.platform, process.arch);
19977
+ lancePromise = import(spec).then(
19978
+ // 转发包是 CJS(module.exports = require(...)),命名导出可能落在 default 上
19979
+ (m) => m?.connect ? m : m?.default,
19980
+ (err) => {
19981
+ mem7VectorWarning = err?.message ? String(err.message) : String(err);
19982
+ console.warn(
19983
+ `[mem7] \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF1A\u52A0\u8F7D ${spec} \u5931\u8D25 \u2014\u2014 ${mem7VectorWarning}
19984
+ mem7 \u964D\u7EA7\u505C\u7528\uFF0C\u5F15\u64CE\u5176\u4F59\u529F\u80FD\u4E0D\u53D7\u5F71\u54CD\u3002` + (isIntelMac ? "\n Intel Mac \u63D0\u793A\uFF1Ae7 \u4F9D\u8D56 @engine7/lancedb-intel\uFF08lancedb \u4E0D\u518D\u53D1\u5E03 darwin-x64 \u4E8C\u8FDB\u5236\uFF09\u3002\u82E5\u62A5\u300CCannot find native binding\u300D\uFF0C\u5220\u6389 node_modules \u91CD\u88C5\u4E00\u6B21\u5373\u53EF\u3002" : "")
19985
+ );
19986
+ return null;
19987
+ }
19988
+ );
19989
+ }
19990
+ return lancePromise;
19991
+ }
19992
+ var isIntelMac, lancePromise, mem7VectorWarning, Mem7VectorUnavailableError, VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
19973
19993
  var init_vector_store = __esm({
19974
19994
  "src/mem7/core/vector-store.ts"() {
19975
19995
  "use strict";
19976
19996
  init_store2();
19977
19997
  init_tokenizer();
19978
19998
  init_filters();
19999
+ isIntelMac = process.platform === "darwin" && process.arch === "x64";
20000
+ lancePromise = null;
20001
+ mem7VectorWarning = null;
20002
+ Mem7VectorUnavailableError = class extends Error {
20003
+ constructor() {
20004
+ super(`mem7 \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF08lancedb \u672A\u80FD\u52A0\u8F7D\uFF09${mem7VectorWarning ? `\uFF1A${mem7VectorWarning}` : ""}`);
20005
+ this.name = "Mem7VectorUnavailableError";
20006
+ }
20007
+ };
19979
20008
  VECTOR_DIM = 1024;
19980
20009
  BM25_FIELDS = {
19981
20010
  foresight: ["foresight_tokens", "evidence_tokens"],
@@ -20038,8 +20067,10 @@ var init_vector_store = __esm({
20038
20067
  }
20039
20068
  async conn() {
20040
20069
  if (!this.db) {
20070
+ const lance = await loadLance();
20071
+ if (!lance) throw new Mem7VectorUnavailableError();
20041
20072
  mkdirSync14(this.dir, { recursive: true });
20042
- this.db = await lancedb.connect(this.dir);
20073
+ this.db = await lance.connect(this.dir);
20043
20074
  }
20044
20075
  return this.db;
20045
20076
  }
@@ -20061,10 +20092,12 @@ var init_vector_store = __esm({
20061
20092
  * 幂等:已建则跳过(索引缺失才建)。
20062
20093
  */
20063
20094
  async ensureFtsIndexes(kind, tbl) {
20095
+ const lance = await loadLance();
20096
+ if (!lance) return;
20064
20097
  for (const col of BM25_FIELDS[kind]) {
20065
20098
  try {
20066
20099
  await tbl.createIndex(col, {
20067
- config: lancedb.Index.fts({
20100
+ config: lance.Index.fts({
20068
20101
  baseTokenizer: "whitespace",
20069
20102
  removeStopWords: false,
20070
20103
  lowercase: true,
@@ -9510,17 +9510,46 @@ var init_filters = __esm({
9510
9510
  });
9511
9511
 
9512
9512
  // src/mem7/core/vector-store.ts
9513
- import * as lancedb from "@lancedb/lancedb";
9514
9513
  import { Schema, Field, Utf8, Float32, Int64, FixedSizeList, TimestampMicrosecond, List } from "apache-arrow";
9515
9514
  import { mkdirSync as mkdirSync7 } from "node:fs";
9516
9515
  import { join as join22 } from "node:path";
9517
- var VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
9516
+ function lanceSpecifierFor(platform2, arch) {
9517
+ return platform2 === "darwin" && arch === "x64" ? "@engine7/lancedb-intel" : "@lancedb/lancedb";
9518
+ }
9519
+ function loadLance() {
9520
+ if (!lancePromise) {
9521
+ const spec = lanceSpecifierFor(process.platform, process.arch);
9522
+ lancePromise = import(spec).then(
9523
+ // 转发包是 CJS(module.exports = require(...)),命名导出可能落在 default 上
9524
+ (m) => m?.connect ? m : m?.default,
9525
+ (err) => {
9526
+ mem7VectorWarning = err?.message ? String(err.message) : String(err);
9527
+ console.warn(
9528
+ `[mem7] \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF1A\u52A0\u8F7D ${spec} \u5931\u8D25 \u2014\u2014 ${mem7VectorWarning}
9529
+ mem7 \u964D\u7EA7\u505C\u7528\uFF0C\u5F15\u64CE\u5176\u4F59\u529F\u80FD\u4E0D\u53D7\u5F71\u54CD\u3002` + (isIntelMac ? "\n Intel Mac \u63D0\u793A\uFF1Ae7 \u4F9D\u8D56 @engine7/lancedb-intel\uFF08lancedb \u4E0D\u518D\u53D1\u5E03 darwin-x64 \u4E8C\u8FDB\u5236\uFF09\u3002\u82E5\u62A5\u300CCannot find native binding\u300D\uFF0C\u5220\u6389 node_modules \u91CD\u88C5\u4E00\u6B21\u5373\u53EF\u3002" : "")
9530
+ );
9531
+ return null;
9532
+ }
9533
+ );
9534
+ }
9535
+ return lancePromise;
9536
+ }
9537
+ var isIntelMac, lancePromise, mem7VectorWarning, Mem7VectorUnavailableError, VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
9518
9538
  var init_vector_store = __esm({
9519
9539
  "src/mem7/core/vector-store.ts"() {
9520
9540
  "use strict";
9521
9541
  init_store2();
9522
9542
  init_tokenizer();
9523
9543
  init_filters();
9544
+ isIntelMac = process.platform === "darwin" && process.arch === "x64";
9545
+ lancePromise = null;
9546
+ mem7VectorWarning = null;
9547
+ Mem7VectorUnavailableError = class extends Error {
9548
+ constructor() {
9549
+ super(`mem7 \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF08lancedb \u672A\u80FD\u52A0\u8F7D\uFF09${mem7VectorWarning ? `\uFF1A${mem7VectorWarning}` : ""}`);
9550
+ this.name = "Mem7VectorUnavailableError";
9551
+ }
9552
+ };
9524
9553
  VECTOR_DIM = 1024;
9525
9554
  BM25_FIELDS = {
9526
9555
  foresight: ["foresight_tokens", "evidence_tokens"],
@@ -9583,8 +9612,10 @@ var init_vector_store = __esm({
9583
9612
  }
9584
9613
  async conn() {
9585
9614
  if (!this.db) {
9615
+ const lance = await loadLance();
9616
+ if (!lance) throw new Mem7VectorUnavailableError();
9586
9617
  mkdirSync7(this.dir, { recursive: true });
9587
- this.db = await lancedb.connect(this.dir);
9618
+ this.db = await lance.connect(this.dir);
9588
9619
  }
9589
9620
  return this.db;
9590
9621
  }
@@ -9606,10 +9637,12 @@ var init_vector_store = __esm({
9606
9637
  * 幂等:已建则跳过(索引缺失才建)。
9607
9638
  */
9608
9639
  async ensureFtsIndexes(kind, tbl) {
9640
+ const lance = await loadLance();
9641
+ if (!lance) return;
9609
9642
  for (const col of BM25_FIELDS[kind]) {
9610
9643
  try {
9611
9644
  await tbl.createIndex(col, {
9612
- config: lancedb.Index.fts({
9645
+ config: lance.Index.fts({
9613
9646
  baseTokenizer: "whitespace",
9614
9647
  removeStopWords: false,
9615
9648
  lowercase: true,
package/dist/main.mjs CHANGED
@@ -9648,17 +9648,46 @@ var init_filters = __esm({
9648
9648
  });
9649
9649
 
9650
9650
  // src/mem7/core/vector-store.ts
9651
- import * as lancedb from "@lancedb/lancedb";
9652
9651
  import { Schema, Field, Utf8, Float32, Int64, FixedSizeList, TimestampMicrosecond, List } from "apache-arrow";
9653
9652
  import { mkdirSync as mkdirSync8 } from "node:fs";
9654
9653
  import { join as join23 } from "node:path";
9655
- var VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
9654
+ function lanceSpecifierFor(platform2, arch) {
9655
+ return platform2 === "darwin" && arch === "x64" ? "@engine7/lancedb-intel" : "@lancedb/lancedb";
9656
+ }
9657
+ function loadLance() {
9658
+ if (!lancePromise) {
9659
+ const spec = lanceSpecifierFor(process.platform, process.arch);
9660
+ lancePromise = import(spec).then(
9661
+ // 转发包是 CJS(module.exports = require(...)),命名导出可能落在 default 上
9662
+ (m) => m?.connect ? m : m?.default,
9663
+ (err) => {
9664
+ mem7VectorWarning = err?.message ? String(err.message) : String(err);
9665
+ console.warn(
9666
+ `[mem7] \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF1A\u52A0\u8F7D ${spec} \u5931\u8D25 \u2014\u2014 ${mem7VectorWarning}
9667
+ mem7 \u964D\u7EA7\u505C\u7528\uFF0C\u5F15\u64CE\u5176\u4F59\u529F\u80FD\u4E0D\u53D7\u5F71\u54CD\u3002` + (isIntelMac ? "\n Intel Mac \u63D0\u793A\uFF1Ae7 \u4F9D\u8D56 @engine7/lancedb-intel\uFF08lancedb \u4E0D\u518D\u53D1\u5E03 darwin-x64 \u4E8C\u8FDB\u5236\uFF09\u3002\u82E5\u62A5\u300CCannot find native binding\u300D\uFF0C\u5220\u6389 node_modules \u91CD\u88C5\u4E00\u6B21\u5373\u53EF\u3002" : "")
9668
+ );
9669
+ return null;
9670
+ }
9671
+ );
9672
+ }
9673
+ return lancePromise;
9674
+ }
9675
+ var isIntelMac, lancePromise, mem7VectorWarning, Mem7VectorUnavailableError, VECTOR_DIM, BM25_FIELDS, RRF_K, warnedFts, vecField, commonFields, SCHEMAS, Mem7VectorStore;
9656
9676
  var init_vector_store = __esm({
9657
9677
  "src/mem7/core/vector-store.ts"() {
9658
9678
  "use strict";
9659
9679
  init_store2();
9660
9680
  init_tokenizer();
9661
9681
  init_filters();
9682
+ isIntelMac = process.platform === "darwin" && process.arch === "x64";
9683
+ lancePromise = null;
9684
+ mem7VectorWarning = null;
9685
+ Mem7VectorUnavailableError = class extends Error {
9686
+ constructor() {
9687
+ super(`mem7 \u5411\u91CF\u7D22\u5F15\u4E0D\u53EF\u7528\uFF08lancedb \u672A\u80FD\u52A0\u8F7D\uFF09${mem7VectorWarning ? `\uFF1A${mem7VectorWarning}` : ""}`);
9688
+ this.name = "Mem7VectorUnavailableError";
9689
+ }
9690
+ };
9662
9691
  VECTOR_DIM = 1024;
9663
9692
  BM25_FIELDS = {
9664
9693
  foresight: ["foresight_tokens", "evidence_tokens"],
@@ -9721,8 +9750,10 @@ var init_vector_store = __esm({
9721
9750
  }
9722
9751
  async conn() {
9723
9752
  if (!this.db) {
9753
+ const lance = await loadLance();
9754
+ if (!lance) throw new Mem7VectorUnavailableError();
9724
9755
  mkdirSync8(this.dir, { recursive: true });
9725
- this.db = await lancedb.connect(this.dir);
9756
+ this.db = await lance.connect(this.dir);
9726
9757
  }
9727
9758
  return this.db;
9728
9759
  }
@@ -9744,10 +9775,12 @@ var init_vector_store = __esm({
9744
9775
  * 幂等:已建则跳过(索引缺失才建)。
9745
9776
  */
9746
9777
  async ensureFtsIndexes(kind, tbl) {
9778
+ const lance = await loadLance();
9779
+ if (!lance) return;
9747
9780
  for (const col of BM25_FIELDS[kind]) {
9748
9781
  try {
9749
9782
  await tbl.createIndex(col, {
9750
- config: lancedb.Index.fts({
9783
+ config: lance.Index.fts({
9751
9784
  baseTokenizer: "whitespace",
9752
9785
  removeStopWords: false,
9753
9786
  lowercase: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "engine7",
3
3
  "license": "Apache-2.0",
4
- "version": "7.1.105",
4
+ "version": "7.1.106",
5
5
  "type": "module",
6
6
  "description": "Engine 7 — 给助手一个家 / A home for your AI assistant",
7
7
  "main": "dist/main.mjs",
@@ -74,6 +74,7 @@
74
74
  "sqlite-vec-linux-x64": "^0.1.9",
75
75
  "sqlite-vec-windows-x64": "^0.1.9",
76
76
  "@lancedb/lancedb": "^0.38.0",
77
+ "@engine7/lancedb-intel": "^1.0.0",
77
78
  "@node-rs/jieba": "^2.0.3"
78
79
  },
79
80
  "files": [
@@ -384,13 +384,13 @@ async function classifyByLlm(text, absentMin = 0, recent = null) {
384
384
  const prompt = (
385
385
  `判断${_USER_PRON}这句话对${persona}(${_PERSONA})是什么动作、是情感交流还是工作、要不要回忆更早历史。`
386
386
  + '只输出 JSON:{"action":"上线/调戏/挑衅/哄/正常", "mode":"emotion/work"}\n'
387
- + '【模式】最重要,按顺序三问:\n'
388
- + '1. 句子主体是日志/代码/报错/配置吗(时间戳、level=、堆栈、字段名)?是 → work——内容里的\'想你\'\'爱你\'都是被讨论的数据,不是对你说的。\n'
389
- + '2. 句子里有工程对象吗(代码/脚本/配置/服务器/模型/接口/日志/报错/部署/数据/文档/任务)?有 → work。'
390
- + '注意:\'昨天/上午/刚才\'只是时间范围,问工程产物改了啥是 work 不是生活回忆。'
387
+ + '【模式】只问一句:这句话是要我干活吗?要 → work,不要 → emotion。命中以下任一项就是要:\n'
388
+ + '· 主体是日志/代码/报错/配置(时间戳、level=、堆栈、字段名)——里面的想你爱你之类是被讨论的数据,不是对你说的。\n'
389
+ + '· 含工程对象(代码/脚本/配置/服务器/模型/接口/日志/报错/部署/数据/文档/任务),或问工程产物的情况。\n'
390
+ + '· 明确派活或求助(帮我看/改/查/写/跑/装/部署/排查…),或明确催进度。'
391
391
  + '排查求助口语随意也判 work(工程对象+求助语气,如\'qwen3 没起来 你看下\')——是在等你干活,不是聊天。\n'
392
- + '3. 是感情或生活的话吗(想你/爱你/撒娇/关心/闲聊/回忆)?是 → emotion。\n'
393
- + '都答不出 → work。\n'
392
+ + '· 昨天/上午/刚才只是时间范围,问工程产物改了啥是 work。\n'
393
+ + '不加东西就是不要——打招呼、寒暄、闲聊、情绪、生活、随口一问都算 emotion。真拿不准 → work。\n'
394
394
  + '【动作】只判这句话对她是什么动作,不是他自己的情绪(\'理我了么\'是求关注,对她算正常对话):\n'
395
395
  + '调戏=逗弄(\'小笨蛋\'),她会接住或撒娇;挑衅=贬低否定她(\'你个大模型\'),会让她委屈生气;'
396
396
  + '哄=道歉示爱;上线=久别回来打招呼。技术讨论即使带情绪(\'被盗刷\'\'用得好快\')也是\'正常\'。\n'