@zhushanwen/pi-session-manager 0.3.1 → 0.3.3

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/README.md CHANGED
@@ -29,6 +29,10 @@ agent-managed session pi extension:把 session 的创建/发送/读取/列表/
29
29
  pi install npm:@zhushanwen/pi-session-manager
30
30
  ```
31
31
 
32
+ ## 工具激活(deferred)
33
+
34
+ 上表 6 个工具均为 `exposure: "deferred"`——不占常驻工具声明,由 pi 内置 `tool_search` 工具检索命中后按需激活。taiji 宿主内开箱即用(宿主启动时已激活 `tool_search`);独立 pi 使用需在 `<agentDir>/settings.json`(默认 `~/.pi/agent/settings.json`)加 `"defaultTools": ["+tool_search"]`(`+` 前缀是增量修饰,保留 read/bash/edit/write 默认集)。注意独立 pi 下即便激活,工具功能仍依赖 taiji runtime handler(见上节「运行要求」)。
35
+
32
36
  ## 测试
33
37
 
34
38
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-session-manager",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Pi extension for managing agent-managed sessions — create, send, read history, list, status, abort via ctx.ui.select channel.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -30,11 +30,11 @@
30
30
  "README.md"
31
31
  ],
32
32
  "dependencies": {
33
- "@zhushanwen/extension-protocol": "0.19.0",
34
- "@zhushanwen/pi-ext-guards": "0.4.3",
33
+ "@zhushanwen/pi-ext-guards": "0.4.4",
35
34
  "@zhushanwen/pi-extension-logger": "0.6.2",
36
- "@zhushanwen/pi-notify-ledger-host": "0.3.1",
37
- "@zhushanwen/subagent-core": "1.4.0"
35
+ "@zhushanwen/pi-notify-ledger-host": "0.3.3",
36
+ "@zhushanwen/subagent-core": "1.5.1",
37
+ "@zhushanwen/extension-protocol": "0.20.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^24.0.0",
package/src/index.ts CHANGED
@@ -177,6 +177,9 @@ function registerSessionTool<S extends TObject>(pi: ExtensionAPI, cfg: SessionTo
177
177
  pi.registerTool({
178
178
  name: cfg.name,
179
179
  label: cfg.label,
180
+ // deferred(tool-declaration-slimming D4):六件套整体不常驻声明,tool_search
181
+ // 命中即激活;迁移写入的 +tool_search 条目(runtime pi-codemode-settings)承载检索入口
182
+ exposure: "deferred",
180
183
  description: cfg.description,
181
184
  parameters: cfg.parameters,
182
185
  async execute(
@@ -222,7 +225,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
222
225
  name: "create_managed_session",
223
226
  label: "Create Managed Session",
224
227
  description:
225
- "Create a new agent-managed session in the specified working directory. Optionally provide an initial prompt, which is sent immediately (new sessions are always idle, so it is delivered directly). Returns a session ID, initial status and willNotify: when a prompt is provided, exactly one completion notification is delivered to this session after that run finishes (see pending_notifications, type 'session'); without a prompt willNotify is false and no completion notification is sent. Terminal session death is notified once regardless. Requires the taiji desktop runtime; standalone pi CLI will time out.",
228
+ "Create a new agent-managed session in a working directory. An optional initial prompt is delivered immediately (new sessions are always idle). Returns session ID, initial status, and willNotify: with a prompt, exactly one completion notification is delivered to this session when that run finishes (see pending_notifications, type 'session'); without a prompt, no completion notification. Terminal session death is notified once regardless. Requires the taiji desktop runtime (times out in standalone pi).",
226
229
  parameters: CreateManagedSessionParams,
227
230
  action: "create",
228
231
  toParams: (p) => ({
@@ -253,7 +256,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
253
256
  name: "send_to_session",
254
257
  label: "Send to Session",
255
258
  description:
256
- "Send a prompt/message to an existing managed session. The message is asynchronously queued: if the target session is busy (generating/compacting/running bash) it is delivered at its next turn boundary, and {queued: true} is returned immediately. Returns willNotify: exactly one completion notification is delivered to this session when the queued message is consumed and that run finishes (several queued messages merge into a single notification with a count). On synchronous failure the tool call fails with an error (check get_session_status, then retry). Requires the taiji desktop runtime; standalone pi CLI will time out.",
259
+ "Send a prompt/message to an existing managed session. The message is queued asynchronously: if the target session is busy (generating/compacting/running bash) it is delivered at its next turn boundary and {queued: true} returns immediately. willNotify: exactly one completion notification is delivered to this session when the queued message is consumed and that run finishes (several queued messages merge into a single notification with a count). On synchronous failure the tool call errors (check get_session_status, then retry). Requires the taiji desktop runtime (times out in standalone pi).",
257
260
  parameters: SendToSessionParams,
258
261
  action: "send",
259
262
  toParams: (p) => ({ sessionId: p.sessionId, prompt: p.prompt, notifyId: newNotifyId() }),
@@ -270,7 +273,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
270
273
  registerSessionTool(pi, {
271
274
  name: "read_session_history",
272
275
  label: "Read Session History",
273
- description: "Read the conversation history of a managed session. Optionally limit to the last N turns. Requires the taiji desktop runtime; standalone pi CLI will time out.",
276
+ description: "Read the conversation history of a managed session. Optionally limit to the last N turns. Requires the taiji desktop runtime (times out in standalone pi).",
274
277
  parameters: ReadSessionHistoryParams,
275
278
  action: "history",
276
279
  toParams: (p) => ({ sessionId: p.sessionId, tailTurns: p.tailTurns }),
@@ -279,7 +282,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
279
282
  registerSessionTool(pi, {
280
283
  name: "list_my_sessions",
281
284
  label: "List My Sessions",
282
- description: "List all sessions managed by the current agent. Returns session IDs, labels, and statuses. Requires the taiji desktop runtime; standalone pi CLI will time out.",
285
+ description: "List all sessions managed by the current agent. Returns session IDs, labels, and statuses. Requires the taiji desktop runtime (times out in standalone pi).",
283
286
  parameters: ListMySessionsParams,
284
287
  action: "list",
285
288
  toParams: () => ({}),
@@ -302,7 +305,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
302
305
  registerSessionTool(pi, {
303
306
  name: "get_session_status",
304
307
  label: "Get Session Status",
305
- description: "Get the current status of a managed session (active, idle, error, etc.) and its model info. Requires the taiji desktop runtime; standalone pi CLI will time out.",
308
+ description: "Get the current status of a managed session (active, idle, error, etc.) and its model info. Requires the taiji desktop runtime (times out in standalone pi).",
306
309
  parameters: GetSessionStatusParams,
307
310
  action: "status",
308
311
  toParams: (p) => ({ sessionId: p.sessionId }),
@@ -311,7 +314,7 @@ export default function sessionManagerExtension(pi: ExtensionAPI): void {
311
314
  registerSessionTool(pi, {
312
315
  name: "abort_session",
313
316
  label: "Abort Session",
314
- description: "Abort a running managed session. The session stops processing; its final status will be 'stopped'. Requires the taiji desktop runtime; standalone pi CLI will time out.",
317
+ description: "Abort a running managed session. The session stops processing; its final status will be 'stopped'. Requires the taiji desktop runtime (times out in standalone pi).",
315
318
  parameters: AbortSessionParams,
316
319
  action: "abort",
317
320
  toParams: (p) => ({ sessionId: p.sessionId }),