engine7 7.1.130 → 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.
package/dist/cli.mjs CHANGED
@@ -42778,8 +42778,12 @@ ${conversationText}`
42778
42778
  let result = "";
42779
42779
  let completed = false;
42780
42780
  let hadError = false;
42781
+ let completionReason;
42781
42782
  for await (const chunk of extractEngine.query(extractMessages, void 0, toolContext)) {
42782
- if (chunk.type === "result") completed = chunk.completionReason === "completed";
42783
+ if (chunk.type === "result") {
42784
+ completionReason = chunk.completionReason;
42785
+ completed = completionReason === "completed";
42786
+ }
42783
42787
  if (chunk.type === "error" || chunk.type === "tool_result" && chunk.isError) hadError = true;
42784
42788
  if (chunk.type === "text" && chunk.text) {
42785
42789
  result += chunk.text;
@@ -42789,7 +42793,7 @@ ${conversationText}`
42789
42793
  }
42790
42794
  }
42791
42795
  if (!completed || hadError || generation !== (state2.generations.get(sessionId) ?? 0)) {
42792
- 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)}`);
42793
42797
  return;
42794
42798
  }
42795
42799
  if (maxNewTs > 0) state2.lastTs.set(sessionId, maxNewTs);
@@ -42816,11 +42820,15 @@ ${conversationText}`
42816
42820
  },
42817
42821
  execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
42818
42822
  if (!enabled) return Promise.resolve();
42823
+ const generation = state2.generations.get(sessionId) ?? 0;
42819
42824
  const previous = state2.tail;
42820
42825
  const lastTime = state2.lastExtractTime.get(sessionId);
42821
42826
  const alreadyCoolingDown = Boolean(intervalMinutes && intervalMinutes > 0 && lastTime && Date.now() - lastTime < intervalMinutes * 6e4);
42822
42827
  const snapshot = structuredClone(messages);
42823
- 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
+ });
42824
42832
  const tail2 = task.finally(() => {
42825
42833
  if (state2.tail === tail2) state2.tail = void 0;
42826
42834
  });
@@ -51039,7 +51047,25 @@ function isEngineImage(text) {
51039
51047
  function isPidAlive(pid) {
51040
51048
  try {
51041
51049
  process.kill(pid, 0);
51042
- 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;
51043
51069
  } catch {
51044
51070
  return false;
51045
51071
  }
@@ -52436,7 +52462,10 @@ engine7 session \u2014 \u4F1A\u8BDD\u7BA1\u7406\u5DE5\u5177
52436
52462
  if (killed !== null) {
52437
52463
  console.log(`
52438
52464
  Killing engine (PID: ${killed})...`);
52439
- 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
+ }
52440
52469
  }
52441
52470
  } catch (err) {
52442
52471
  console.warn(`[session] \u6740\u65E7\u8FDB\u7A0B\u5931\u8D25\uFF08\u4E0D\u6321\u91CD\u7F6E\uFF09\uFF1A${err.message}`);