engine7 7.1.129 → 7.1.131

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.
@@ -6563,12 +6563,16 @@ function applySocialInterpretation(store, scope, result, captured, requestKey, r
6563
6563
  applied.relationships.push({ index: ordinal, label: relation.label, state: "ignored" });
6564
6564
  continue;
6565
6565
  }
6566
- for (const value of [relation.validFrom, relation.validTo]) if (value !== null && value !== void 0) {
6567
- try {
6568
- if (typeof value !== "string") throw new Error("INVALID_TIME");
6569
- instant(value);
6570
- } catch {
6571
- throw new Error("INVALID_SOCIAL_TIME");
6566
+ for (const field of ["validFrom", "validTo"]) {
6567
+ const value = relation[field];
6568
+ if (value === void 0) fail2("INVALID_SOCIAL_TIME", `${path8}.${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");
6569
+ if (value !== null) {
6570
+ try {
6571
+ if (typeof value !== "string") throw new Error("INVALID_TIME");
6572
+ instant(value);
6573
+ } catch {
6574
+ fail2("INVALID_SOCIAL_TIME", `${path8}.${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");
6575
+ }
6572
6576
  }
6573
6577
  }
6574
6578
  if (relation.validFrom !== null && relation.validFrom !== void 0) {
@@ -6594,6 +6598,9 @@ function applySocialInterpretation(store, scope, result, captured, requestKey, r
6594
6598
  if (!perspectiveEntityId || !subjectId || !objectId) throw new Error(captured.providedSourceIds ? "SOCIAL_ENTITY_NOT_PROVIDED: relationships \u7684 perspective/subject/object \u53EA\u80FD\u586B\u672C\u6279 mentions.key \u6216 speaker\uFF1B\u5DF2\u6709\u5B9E\u4F53 ID \u586B mentions.entityId\uFF0C\u5148\u7528 memory_get \u7684 confirmedMentions \u63D0\u4F9B\u8EAB\u4EFD anchor\u3002\u7528\u6237\u539F\u8BDD\u5F52\u5C5E speaker\uFF1B\u81EA\u5DF1\u7684\u5224\u65AD\u5148 memory_write role=assistant\u3002\u65E0\u9700\u67E5\u627E\u6216\u521B\u5EFA owner\u3002" : "SOCIAL_ENTITY_NOT_PROVIDED");
6595
6599
  if (["attitude", "feeling"].includes(relation.contentKind) && relation.direction !== "directed") throw new Error("INVALID_SOCIAL_RECIPROCITY");
6596
6600
  if (relation.attribution !== void 0 && !["direct", "reported"].includes(relation.attribution)) throw new Error("INVALID_SOCIAL_ATTRIBUTION");
6601
+ if (relation.attributionQuote !== void 0 && relation.attribution !== "reported") {
6602
+ fail2("INVALID_SOCIAL_ATTRIBUTION", `${path8}.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");
6603
+ }
6597
6604
  if (relation.realm !== void 0 && !["real", "roleplay", "hypothetical"].includes(relation.realm)) throw new Error("INVALID_SOCIAL_REALM");
6598
6605
  if (relation.sensitivity !== void 0 && !["normal", "sensitive"].includes(relation.sensitivity)) throw new Error("INVALID_SOCIAL_SENSITIVITY");
6599
6606
  const reported = relation.attribution === "reported";
package/dist/cli.mjs CHANGED
@@ -7025,12 +7025,16 @@ function applySocialInterpretation(store, scope, result, captured, requestKey, r
7025
7025
  applied.relationships.push({ index: ordinal, label: relation.label, state: "ignored" });
7026
7026
  continue;
7027
7027
  }
7028
- for (const value of [relation.validFrom, relation.validTo]) if (value !== null && value !== void 0) {
7029
- try {
7030
- if (typeof value !== "string") throw new Error("INVALID_TIME");
7031
- instant(value);
7032
- } catch {
7033
- throw new Error("INVALID_SOCIAL_TIME");
7028
+ for (const field of ["validFrom", "validTo"]) {
7029
+ const value = relation[field];
7030
+ if (value === void 0) fail2("INVALID_SOCIAL_TIME", `${path57}.${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");
7031
+ if (value !== null) {
7032
+ try {
7033
+ if (typeof value !== "string") throw new Error("INVALID_TIME");
7034
+ instant(value);
7035
+ } catch {
7036
+ fail2("INVALID_SOCIAL_TIME", `${path57}.${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");
7037
+ }
7034
7038
  }
7035
7039
  }
7036
7040
  if (relation.validFrom !== null && relation.validFrom !== void 0) {
@@ -7056,6 +7060,9 @@ function applySocialInterpretation(store, scope, result, captured, requestKey, r
7056
7060
  if (!perspectiveEntityId || !subjectId || !objectId) throw new Error(captured.providedSourceIds ? "SOCIAL_ENTITY_NOT_PROVIDED: relationships \u7684 perspective/subject/object \u53EA\u80FD\u586B\u672C\u6279 mentions.key \u6216 speaker\uFF1B\u5DF2\u6709\u5B9E\u4F53 ID \u586B mentions.entityId\uFF0C\u5148\u7528 memory_get \u7684 confirmedMentions \u63D0\u4F9B\u8EAB\u4EFD anchor\u3002\u7528\u6237\u539F\u8BDD\u5F52\u5C5E speaker\uFF1B\u81EA\u5DF1\u7684\u5224\u65AD\u5148 memory_write role=assistant\u3002\u65E0\u9700\u67E5\u627E\u6216\u521B\u5EFA owner\u3002" : "SOCIAL_ENTITY_NOT_PROVIDED");
7057
7061
  if (["attitude", "feeling"].includes(relation.contentKind) && relation.direction !== "directed") throw new Error("INVALID_SOCIAL_RECIPROCITY");
7058
7062
  if (relation.attribution !== void 0 && !["direct", "reported"].includes(relation.attribution)) throw new Error("INVALID_SOCIAL_ATTRIBUTION");
7063
+ if (relation.attributionQuote !== void 0 && relation.attribution !== "reported") {
7064
+ fail2("INVALID_SOCIAL_ATTRIBUTION", `${path57}.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");
7065
+ }
7059
7066
  if (relation.realm !== void 0 && !["real", "roleplay", "hypothetical"].includes(relation.realm)) throw new Error("INVALID_SOCIAL_REALM");
7060
7067
  if (relation.sensitivity !== void 0 && !["normal", "sensitive"].includes(relation.sensitivity)) throw new Error("INVALID_SOCIAL_SENSITIVITY");
7061
7068
  const reported = relation.attribution === "reported";
@@ -11690,6 +11697,13 @@ var init_external_effect = __esm({
11690
11697
  }
11691
11698
  });
11692
11699
 
11700
+ // src/onboarding/state.ts
11701
+ var init_state = __esm({
11702
+ "src/onboarding/state.ts"() {
11703
+ "use strict";
11704
+ }
11705
+ });
11706
+
11693
11707
  // src/qr-render.ts
11694
11708
  var qr_render_exports = {};
11695
11709
  __export(qr_render_exports, {
@@ -11861,6 +11875,7 @@ var init_wechat = __esm({
11861
11875
  "use strict";
11862
11876
  init_bubble_split();
11863
11877
  init_external_effect();
11878
+ init_state();
11864
11879
  ILINK_BASE_URL = "https://ilinkai.weixin.qq.com";
11865
11880
  ILINK_APP_CLIENT_VERSION = 2 << 16 | 2 << 8 | 0;
11866
11881
  EP_GET_BOT_QR = "ilink/bot/get_bot_qrcode";
@@ -13207,6 +13222,13 @@ function secretRef(envKey, value) {
13207
13222
  function isFreeTier(v) {
13208
13223
  return v.freeTier === true || v.primaryProvider === "7yi";
13209
13224
  }
13225
+ function mem7ServiceDefaults(mem7, legacyRerank) {
13226
+ if (mem7?.enabled === false) return {};
13227
+ return {
13228
+ ...mem7?.embedding == null ? { embedding: { model: FREE_TIER_EMB_REF } } : {},
13229
+ ...mem7?.rerank == null && legacyRerank == null ? { rerank: { model: MEM7_RERANK_REF } } : {}
13230
+ };
13231
+ }
13210
13232
  function freeTierVoiceConfig(existing) {
13211
13233
  const mv = existing && typeof existing === "object" ? existing : {};
13212
13234
  return {
@@ -13377,7 +13399,7 @@ function generateConfig(v) {
13377
13399
  // topics 导入全零向量、语义检索空转(testengine2 实弹 51/51 零向量)。enabled 不写
13378
13400
  // (引擎默认开);只在免费档写 embedding(引用必须落在本次真实写出的 7yi provider
13379
13401
  // 里,同 topics.model 纪律)。
13380
- ...isFreeTier(v) ? { mem7: { embedding: { model: FREE_TIER_EMB_REF } } } : {},
13402
+ ...isFreeTier(v) ? { mem7: mem7ServiceDefaults(void 0) } : {},
13381
13403
  channels: {
13382
13404
  // ⚠️ 三个凭据格写的是 `env:` 引用,**不是明文**(T12,0926)。值落
13383
13405
  // ~/.engine7-secrets/<cfg>.env(0600),由 cli-init 在 config 落盘后写入。
@@ -13567,7 +13589,7 @@ function generateConfig(v) {
13567
13589
  }
13568
13590
  return config;
13569
13591
  }
13570
- var SCHEMA_VERSION, FREE_TIER_RELAY_URL, FREE_TIER_PROVIDER_ID, FREE_TIER_NORT_MODEL, FREE_TIER_NORT_REF, FREE_TIER_FAST_MODEL, FREE_TIER_FAST_REF, FREE_TIER_EMB_MODEL, FREE_TIER_EMB_REF, EXTRACT_COOLDOWN_MINUTES, DEFAULT_FREE_VOICE, DEFAULT_PRIMARY_MODEL, VISION_CAPABLE, PROVIDER_DEFS, MODEL_CHOICES, CUSTOM_DEFAULT_INPUT, TEMPLATE_VALUES;
13592
+ var SCHEMA_VERSION, FREE_TIER_RELAY_URL, FREE_TIER_PROVIDER_ID, FREE_TIER_NORT_MODEL, FREE_TIER_NORT_REF, FREE_TIER_FAST_MODEL, FREE_TIER_FAST_REF, FREE_TIER_EMB_MODEL, FREE_TIER_EMB_REF, MEM7_RERANK_REF, EXTRACT_COOLDOWN_MINUTES, DEFAULT_FREE_VOICE, DEFAULT_PRIMARY_MODEL, VISION_CAPABLE, PROVIDER_DEFS, MODEL_CHOICES, CUSTOM_DEFAULT_INPUT, TEMPLATE_VALUES;
13571
13593
  var init_cli_init_config = __esm({
13572
13594
  "src/cli-init-config.ts"() {
13573
13595
  "use strict";
@@ -13581,6 +13603,7 @@ var init_cli_init_config = __esm({
13581
13603
  FREE_TIER_FAST_REF = `${FREE_TIER_PROVIDER_ID}/${FREE_TIER_FAST_MODEL}`;
13582
13604
  FREE_TIER_EMB_MODEL = "engine7-emb";
13583
13605
  FREE_TIER_EMB_REF = `${FREE_TIER_PROVIDER_ID}/${FREE_TIER_EMB_MODEL}`;
13606
+ MEM7_RERANK_REF = `${FREE_TIER_PROVIDER_ID}/engine7-rerank`;
13584
13607
  EXTRACT_COOLDOWN_MINUTES = 15;
13585
13608
  DEFAULT_FREE_VOICE = "Chinese (Mandarin)_Warm_Girl";
13586
13609
  DEFAULT_PRIMARY_MODEL = {
@@ -42755,8 +42778,12 @@ ${conversationText}`
42755
42778
  let result = "";
42756
42779
  let completed = false;
42757
42780
  let hadError = false;
42781
+ let completionReason;
42758
42782
  for await (const chunk of extractEngine.query(extractMessages, void 0, toolContext)) {
42759
- if (chunk.type === "result") completed = chunk.completionReason === "completed";
42783
+ if (chunk.type === "result") {
42784
+ completionReason = chunk.completionReason;
42785
+ completed = completionReason === "completed";
42786
+ }
42760
42787
  if (chunk.type === "error" || chunk.type === "tool_result" && chunk.isError) hadError = true;
42761
42788
  if (chunk.type === "text" && chunk.text) {
42762
42789
  result += chunk.text;
@@ -42766,7 +42793,7 @@ ${conversationText}`
42766
42793
  }
42767
42794
  }
42768
42795
  if (!completed || hadError || generation !== (state2.generations.get(sessionId) ?? 0)) {
42769
- console.warn(`[memory] extractMemories incomplete \u2014 input remains eligible, tools=${toolCount}, error=${hadError}`);
42796
+ console.warn(`[memory] extractMemories incomplete \u2014 input remains eligible, tools=${toolCount}, error=${hadError}, reason=${completionReason ?? "unknown"}, reset=${generation !== (state2.generations.get(sessionId) ?? 0)}`);
42770
42797
  return;
42771
42798
  }
42772
42799
  if (maxNewTs > 0) state2.lastTs.set(sessionId, maxNewTs);
@@ -42793,11 +42820,15 @@ ${conversationText}`
42793
42820
  },
42794
42821
  execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
42795
42822
  if (!enabled) return Promise.resolve();
42823
+ const generation = state2.generations.get(sessionId) ?? 0;
42796
42824
  const previous = state2.tail;
42797
42825
  const lastTime = state2.lastExtractTime.get(sessionId);
42798
42826
  const alreadyCoolingDown = Boolean(intervalMinutes && intervalMinutes > 0 && lastTime && Date.now() - lastTime < intervalMinutes * 6e4);
42799
42827
  const snapshot = structuredClone(messages);
42800
- const task = (previous ?? Promise.resolve()).then(() => extract(snapshot, provider, model, sessionId, disableThinking, previous && !alreadyCoolingDown ? 0 : intervalMinutes));
42828
+ const task = (previous ?? Promise.resolve()).then(() => {
42829
+ if (generation !== (state2.generations.get(sessionId) ?? 0)) return;
42830
+ return extract(snapshot, provider, model, sessionId, disableThinking, previous && !alreadyCoolingDown ? 0 : intervalMinutes);
42831
+ });
42801
42832
  const tail2 = task.finally(() => {
42802
42833
  if (state2.tail === tail2) state2.tail = void 0;
42803
42834
  });
@@ -44358,6 +44389,8 @@ ${text}` : text });
44358
44389
  const dynamicPrompt = buildDynamicPrompt({ workspace, channel: channelName, platform: channelName, sessionId, inboundMeta, emotion: chatMode === "emotion" });
44359
44390
  const conversationAnchor = buildConversationAnchor(inboundMeta, channelName, source ?? "user", workspace);
44360
44391
  const memorySourceVersion = memoryIntake?.sourceVersion ?? inboundMeta?.sourceVersion ?? 1;
44392
+ const memorySavingReminder = memoryHostSourceId ? `## \u8BB0
44393
+ \u539F\u8BDD\u5DF2\u8FDB\u5165\u4FDD\u5B58\u961F\u5217 source_id=${memoryHostSourceId}\uFF0Csource_version=${memorySourceVersion}\u3002` : null;
44361
44394
  const volatileParts = [
44362
44395
  // 0901:meta 头已带秒级时间,频道消息不重复;无 meta 的注入路径(cron 等 prompt 不含时间的)才补
44363
44396
  ...metaStr ? [] : [buildVolatileRuntimeContext()],
@@ -44365,8 +44398,7 @@ ${text}` : text });
44365
44398
  ...hookAdditionalContexts,
44366
44399
  // 1010 翀哥拍板瘦身:原 ~240 字里九成是 memory_people_update 的 API 参数说明——
44367
44400
  // 那些已挪进工具 description(模型调工具那一刻才读,读的是新鲜的),注入只留一句时机提示。
44368
- ...memoryHostSourceId ? [`## \u8BB0
44369
- \u539F\u8BDD\u5DF2\u8FDB\u5165\u4FDD\u5B58\u961F\u5217 source_id=${memoryHostSourceId}\uFF0Csource_version=${memorySourceVersion}\uFF1B\u672C\u8F6E\u4EBA\u7269\u767B\u8BB0/\u8EAB\u4EFD\u786E\u8BA4\u5DE5\u5177\u53EF\u76F4\u63A5\u4F7F\u7528\u6B64\u6765\u6E90\u3002\u6309\u5DE5\u5177\u793A\u4F8B\u767B\u8BB0\u5E76\u68C0\u67E5\u9010\u9879\u56DE\u6267\uFF0Capplied \u4E0D\u7B49\u4E8E\u8EAB\u4EFD\u5DF2\u5168\u90E8\u7ED1\u5B9A\u3002`] : []
44401
+ ...memorySavingReminder ? [memorySavingReminder] : []
44370
44402
  // 1010 重构(见 EVIDENCE_RULES 头注):证据段后置——锚点要本轮 recall 数与事实版本,
44371
44403
  // 在 recall 完成后的后置注入点拼(见 query 前 evidenceBlock 调用处)。
44372
44404
  ].filter(Boolean);
@@ -44881,6 +44913,15 @@ ${volatileParts.join("\n\n")}
44881
44913
  console.log(`[mode] ${sessionId} \u2192 ${mode} (${mode === "emotion" ? "\u53EA SOUL, \u5173 tool \u663E\u793A/thinking/stop-hook" : "\u9ED8\u8BA4 stable, tool \u6309\u914D\u7F6E\u663E\u793A"})`);
44882
44914
  const channelToolExclude = resolveToolExclude(channelName);
44883
44915
  const toolExclude = mode === "emotion" ? [.../* @__PURE__ */ new Set([...emotionToolExclude(), ...channelToolExclude])] : channelToolExclude;
44916
+ if (memorySavingReminder && volatileReminderBlock) {
44917
+ const emotionTools = liveConfig.get("channels.emotion.tools");
44918
+ const canUse = (name) => !toolExclude.includes(name) && (mode !== "emotion" || Array.isArray(emotionTools) && emotionTools.includes(name));
44919
+ const people = canUse("memory_people_update");
44920
+ const identity = canUse("memory_identity_resolve");
44921
+ const hint = people ? `\u672C\u8F6E${identity ? "\u4EBA\u7269\u767B\u8BB0/\u8EAB\u4EFD\u786E\u8BA4" : "\u4EBA\u7269\u767B\u8BB0"}\u5DE5\u5177\u53EF\u76F4\u63A5\u4F7F\u7528\u6B64\u6765\u6E90\u3002\u6309\u5DE5\u5177\u793A\u4F8B\u767B\u8BB0\u5E76\u68C0\u67E5\u9010\u9879\u56DE\u6267\uFF0Capplied \u4E0D\u7B49\u4E8E\u8EAB\u4EFD\u5DF2\u5168\u90E8\u7ED1\u5B9A\u3002` : identity ? "\u7528\u6237\u5DF2\u660E\u786E\u56DE\u7B54\u8EAB\u4EFD\u95EE\u9898\u65F6\uFF0C\u672C\u8F6E\u8EAB\u4EFD\u786E\u8BA4\u5DE5\u5177\u53EF\u76F4\u63A5\u4F7F\u7528\u6B64\u6765\u6E90\uFF1B\u6CA1\u6709\u56DE\u7B54\u4E0D\u8981\u8C03\u7528\u3002" : "";
44922
+ if (hint) volatileReminderBlock.text = volatileReminderBlock.text.replace(memorySavingReminder, `${memorySavingReminder}
44923
+ ${hint}`);
44924
+ }
44884
44925
  const modeStable = mode === "emotion" ? buildLightStablePrompt(workspace, "emotion", { toolExclude }) : void 0;
44885
44926
  assertHostTurnCurrent();
44886
44927
  if (memoryUserReceived && memoryStateDir) {
@@ -46037,7 +46078,7 @@ function applyFreeTier(cfg, opts = {}) {
46037
46078
  cfg.innerVoice = cfg.innerVoice || {};
46038
46079
  if (cfg.innerVoice.model === void 0) cfg.innerVoice.model = FREE_TIER_NORT_REF;
46039
46080
  cfg.mem7 = cfg.mem7 || {};
46040
- if (cfg.mem7.embedding === void 0) cfg.mem7.embedding = { model: FREE_TIER_EMB_REF };
46081
+ Object.assign(cfg.mem7, mem7ServiceDefaults(cfg.mem7, cfg.everos?.rerank));
46041
46082
  cfg.tools = cfg.tools || {};
46042
46083
  if (vision) cfg.tools.my_eyes = { ...cfg.tools.my_eyes || {}, model: vision };
46043
46084
  cfg.tools.my_selfie = { ...cfg.tools.my_selfie || {}, provider: "relay" };
@@ -47793,7 +47834,14 @@ function updatePeople(store, scope, input, provided) {
47793
47834
  return source;
47794
47835
  };
47795
47836
  const sources = input.sources.map((ref, index) => load(ref, `sources[${index}]`));
47796
- if (new Set(sources.map((source) => source.sourceId)).size !== sources.length || sources.some((source) => !["host_user", "client_reported_user", "assistant"].includes(source.originClass))) throw new Error("INVALID_SOCIAL_UPDATE_SOURCE");
47837
+ const seenSources = /* @__PURE__ */ new Set();
47838
+ for (const [index, source] of sources.entries()) {
47839
+ if (seenSources.has(source.sourceId)) throw new Error(`INVALID_SOCIAL_UPDATE_SOURCE: sources[${index}].source_id \u2014 \u6765\u6E90\u91CD\u590D\uFF1B\u6BCF\u4E2A\u6765\u6E90\u53EA\u5217\u4E00\u6B21\u3002`);
47840
+ seenSources.add(source.sourceId);
47841
+ if (!["host_user", "client_reported_user", "assistant"].includes(source.originClass)) {
47842
+ throw new Error(`INVALID_SOCIAL_UPDATE_SOURCE: sources[${index}].originClass=${source.originClass} \u2014 \u6B64\u6765\u6E90\u4E0D\u80FD\u7528\u4E8E\u63D0\u53D6\u771F\u4EBA\u5173\u7CFB\uFF1B\u53EA\u63A5\u53D7\u53EF\u4FE1\u7528\u6237\u539F\u8BDD\u6216\u52A9\u624B\u81EA\u5DF1\u7684\u9648\u8FF0\uFF0C\u65E7\u5BFC\u5165/\u7B2C\u4E09\u65B9\u6750\u6599\u4E0D\u80FD\u5F53\u4F5C\u7528\u6237\u539F\u8BDD\u3002memory_retry \u4E0D\u4F1A\u6539\u53D8\u4F5C\u8005\u6743\u5A01\uFF1B\u8BF7\u4F7F\u7528\u786E\u5B9E\u5305\u542B\u8BE5\u9648\u8FF0\u7684\u53EF\u4FE1\u539F\u8BDD\u6765\u6E90\uFF0C\u4E0D\u8981\u6539\u5199\u65E7\u6587\u6216\u66FF\u6362\u4E3A\u65E0\u5173\u56DE\u7B54\u3002`);
47843
+ }
47844
+ }
47797
47845
  const contexts = (input.context_sources || []).map((ref, index) => load(ref, `context_sources[${index}]`));
47798
47846
  const previous = store.socialInterpretations.writeReceipt(scope, input.request_key);
47799
47847
  if (previous) {
@@ -48557,16 +48605,16 @@ var init_tool_contracts = __esm({
48557
48605
  temporalScope: { type: "string", enum: ["moment", "ongoing"] },
48558
48606
  certainty: { type: "string" },
48559
48607
  actual: { type: "boolean", description: "\u6BCF\u6761\u5173\u7CFB\u5FC5\u586B\uFF1B\u5B9E\u9645\u9648\u8FF0=true\uFF0C\u5047\u8BBE\u5173\u7CFB=false" },
48560
- attribution: { type: "string", enum: ["direct", "reported"] },
48561
- validFrom: { description: "\u5173\u7CFB\u5F00\u59CB\u65F6\u95F4\uFF1B\u539F\u8BDD\u6CA1\u6709\u8BF4\u660E\u8D77\u70B9\u65F6\u586B null\uFF0C\u4E0D\u80FD\u586B\u4ECA\u5929\u7684\u8BF4\u8BDD\u65F6\u95F4\uFF1B\u975E null \u9700 validFromQuote", anyOf: [{ type: "string" }, { type: "null" }] },
48562
- validTo: { anyOf: [{ type: "string" }, { type: "null" }] },
48608
+ attribution: { type: "string", enum: ["direct", "reported"], description: "\u76F4\u63A5\u9648\u8FF0\u7528 direct \u5E76\u7701\u7565 attributionQuote\uFF1B\u53EA\u6709\u539F\u8BDD\u660E\u786E\u8F6C\u8FF0\u4ED6\u4EBA\u89C2\u70B9\u624D\u7528 reported\uFF0C\u5E76\u63D0\u4F9B\u8BE5\u4EBA\u7269\u7684 perspective \u4E0E\u8F6C\u8FF0\u5F15\u6587" },
48609
+ validFrom: { description: "\u5FC5\u586B\uFF1B\u5173\u7CFB\u5F00\u59CB\u65F6\u95F4\uFF0C\u539F\u8BDD\u6CA1\u6709\u8BF4\u660E\u8D77\u70B9\u65F6\u586B null\uFF0C\u4E0D\u80FD\u586B\u4ECA\u5929\u7684\u8BF4\u8BDD\u65F6\u95F4\uFF1B\u975E null \u9700 validFromQuote \u548C\u660E\u786E UTC \u504F\u79FB", anyOf: [{ type: "string" }, { type: "null" }] },
48610
+ validTo: { description: "\u5FC5\u586B\uFF1B\u672A\u77E5\u5173\u7CFB\u7ED3\u675F\u65F6\u523B\u586B null\uFF0C\u975E null \u987B\u4E3A\u5E26 Z \u6216 +08:00 \u7B49\u504F\u79FB\u7684\u5B8C\u6574 ISO \u65F6\u523B", anyOf: [{ type: "string" }, { type: "null" }] },
48563
48611
  changeReason: { type: "string" },
48564
48612
  basisSourceIds: { type: "array", items: { type: "string" } },
48565
48613
  relationshipId: { type: "string" },
48566
48614
  expectedRecordVersion: { type: "integer" },
48567
48615
  expectedSemanticVersion: { type: "integer" },
48568
48616
  validFromQuote: { type: "object", properties: { start: { type: "integer" }, end: { type: "integer" }, quote: { type: "string" } }, required: ["start", "end", "quote"] },
48569
- attributionQuote: { type: "object", properties: { start: { type: "integer" }, end: { type: "integer" }, quote: { type: "string" } }, required: ["start", "end", "quote"] }
48617
+ attributionQuote: { type: "object", description: "\u4EC5 attribution=reported \u65F6\u63D0\u4F9B\uFF1Bdirect \u65F6\u7701\u7565\u6574\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u586B null \u6216\u666E\u901A\u4EBA\u7269\u5F15\u6587", properties: { start: { type: "integer" }, end: { type: "integer" }, quote: { type: "string" } }, required: ["start", "end", "quote"] }
48570
48618
  }, required: [
48571
48619
  "operation",
48572
48620
  "sourceId",
@@ -50999,7 +51047,25 @@ function isEngineImage(text) {
50999
51047
  function isPidAlive(pid) {
51000
51048
  try {
51001
51049
  process.kill(pid, 0);
51002
- return true;
51050
+ } catch (err) {
51051
+ return err?.code === "EPERM";
51052
+ }
51053
+ return !isPidZombie(pid);
51054
+ }
51055
+ function statFieldIsZombie(statContent) {
51056
+ const state2 = statContent.slice(statContent.lastIndexOf(")") + 2).trim().charAt(0);
51057
+ return state2 === "Z";
51058
+ }
51059
+ function isPidZombie(pid) {
51060
+ try {
51061
+ if (process.platform === "linux") {
51062
+ return statFieldIsZombie(fs6.readFileSync(`/proc/${pid}/stat`, "utf-8"));
51063
+ }
51064
+ if (process.platform === "darwin") {
51065
+ const st = execSync(`ps -p ${pid} -o stat=`, { encoding: "utf-8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] });
51066
+ return st.trim().startsWith("Z");
51067
+ }
51068
+ return false;
51003
51069
  } catch {
51004
51070
  return false;
51005
51071
  }
@@ -52396,7 +52462,10 @@ engine7 session \u2014 \u4F1A\u8BDD\u7BA1\u7406\u5DE5\u5177
52396
52462
  if (killed !== null) {
52397
52463
  console.log(`
52398
52464
  Killing engine (PID: ${killed})...`);
52399
- await waitForPidGone(killed);
52465
+ if (!await waitForPidGone(killed)) {
52466
+ console.error(`\u274C \u65E7\u5F15\u64CE\uFF08PID ${killed}\uFF09\u6CA1\u80FD\u505C\u6389\uFF0C\u4F1A\u8BDD\u91CD\u7F6E\u4E2D\u6B62\u2014\u2014\u5148\u624B\u52A8\u7ED3\u675F\u8BE5\u8FDB\u7A0B\u518D\u91CD\u8BD5\u3002`);
52467
+ process.exit(1);
52468
+ }
52400
52469
  }
52401
52470
  } catch (err) {
52402
52471
  console.warn(`[session] \u6740\u65E7\u8FDB\u7A0B\u5931\u8D25\uFF08\u4E0D\u6321\u91CD\u7F6E\uFF09\uFF1A${err.message}`);