@zhushanwen/pi-pending-notifications 0.3.3 → 0.3.5

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.
Files changed (2) hide show
  1. package/package.json +8 -2
  2. package/src/index.ts +6 -3
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-pending-notifications",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Cross-extension async operation registration/query mechanism for Pi — prevents message injection during long-running operations.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
+ "xyz-agent": {
8
+ "role": "universal"
9
+ },
7
10
  "pi": {
8
11
  "extensions": [
9
12
  "./index.ts"
@@ -26,9 +29,12 @@
26
29
  "vitest": "^4.1.8"
27
30
  },
28
31
  "peerDependencies": {
29
- "@earendil-works/pi-coding-agent": "*",
32
+ "@earendil-works/pi-coding-agent": "^0.84.1",
30
33
  "typebox": "*"
31
34
  },
35
+ "dependencies": {
36
+ "@zhushanwen/pi-extension-logger": "0.3.0"
37
+ },
32
38
  "scripts": {
33
39
  "typecheck": "npx tsc --noEmit",
34
40
  "test": "vitest run"
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
26
+ import { getLogger } from "@zhushanwen/pi-extension-logger";
26
27
  import { Type } from "typebox";
27
28
 
28
29
  import {
@@ -56,6 +57,8 @@ export {
56
57
  unregister,
57
58
  } from "./state.ts";
58
59
 
60
+ const logger = getLogger("pending-notifications");
61
+
59
62
  /** 工具参数 schema */
60
63
  const PendingNotificationsParams = Type.Object({
61
64
  action: Type.Union([
@@ -94,7 +97,7 @@ export default function pendingNotificationsExtension(pi: ExtensionAPI): void {
94
97
  unsub();
95
98
  } catch (err) {
96
99
  // unsubscribe 失败不阻断初始化(监听器可能已被 EventBus 内部清理)
97
- console.debug("[pending-notifications] unsubscribe failed during cleanup", err);
100
+ logger.debug("unsubscribe failed during cleanup", { error: String(err) });
98
101
  }
99
102
  }
100
103
  unsubscribers = [];
@@ -116,14 +119,14 @@ export default function pendingNotificationsExtension(pi: ExtensionAPI): void {
116
119
  }
117
120
  }
118
121
 
119
- // debug 日志:环境变量 XYZ_AGENT_DEBUG=1 时输出到 console.debug。
122
+ // debug 日志:环境变量 XYZ_AGENT_DEBUG=1 时经共享 logger 写文件日志(默认 no-op)。
120
123
  // 不再写入 session entry(pending:log)——session entries 是 append-only 无法 GC,
121
124
  // 12 处 debug 日志会让长 session 的 entries 线性膨胀,而 goal before-agent-start
122
125
  // 每 turn 全量扫描 getEntries()。状态数据(pending:register/unregister)仍写 entry。
123
126
  const debugEnabled = process.env.XYZ_AGENT_DEBUG === "1";
124
127
  function debugLog(level: string, message: string, data?: unknown): void {
125
128
  if (!debugEnabled) return;
126
- console.debug(`[pending-notifications:${level}] ${message}`, data ?? "");
129
+ logger.debug(`${level}: ${message}`, data ?? "");
127
130
  }
128
131
 
129
132
  // ── EventBus 监听:pending:register ─────────────────────