@yandy0725/pi-subagents 0.11.5 → 0.11.6

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
@@ -194,7 +194,7 @@ Settings set via `/subagents:settings` persist in `<cwd>/.pi/subagents.json` (pr
194
194
 
195
195
  ## Events
196
196
 
197
- Lifecycle events emitted via `pi.events` for other extensions to consume:
197
+ Events emitted via `pi.events` for other extensions to consume:
198
198
 
199
199
  | Event | When |
200
200
  |-------|------|
@@ -206,6 +206,7 @@ Lifecycle events emitted via `pi.events` for other extensions to consume:
206
206
  | `subagents:compacted` | Agent session compacted |
207
207
  | `subagents:settings_loaded` | Persisted settings applied |
208
208
  | `subagents:settings_changed` | Settings mutation applied |
209
+ | `notify:non-blocking-prompt` | Immediately before a TUI sessions/settings UI call that does not block the agent loop |
209
210
 
210
211
  ## Development
211
212
 
@@ -231,6 +232,8 @@ Both slash commands and the running-agents widget call host UI primitives direct
231
232
  | `select` (`/subagents:sessions`) | none | Forwarded; no timeout |
232
233
  | `custom` (transcript overlay) | none | RPC returns `undefined` immediately: picking a session shows nothing. Same in print / json |
233
234
 
235
+ The sessions picker, read-only transcript overlay, and every settings menu/input are operator-driven and do not block the agent loop. In TUI, each of these UI calls is immediately preceded by a `notify:non-blocking-prompt` declaration. RPC/print/json do not declare: nested or overlapping dialogs have no separate outermost prompt start, so an undeclared default is safer than leaving an unmatched declaration.
236
+
234
237
  ## License
235
238
 
236
239
  MIT
package/README.zh.md CHANGED
@@ -186,7 +186,7 @@ timeout: 300
186
186
 
187
187
  ## 事件
188
188
 
189
- 通过 `pi.events` 发出的生命周期事件,供其他扩展消费:
189
+ 通过 `pi.events` 发出的事件,供其他扩展消费:
190
190
 
191
191
  | 事件 | 触发时机 |
192
192
  |------|----------|
@@ -198,6 +198,7 @@ timeout: 300
198
198
  | `subagents:compacted` | 代理会话已压缩 |
199
199
  | `subagents:settings_loaded` | 持久化设置已应用 |
200
200
  | `subagents:settings_changed` | 设置变更已生效 |
201
+ | `notify:non-blocking-prompt` | 即将打开不阻塞 agent loop 的 TUI sessions/settings UI |
201
202
 
202
203
  ## 开发
203
204
 
@@ -223,6 +224,8 @@ npm test # vitest run
223
224
  | `select`(`/subagents:sessions`) | 无 | 会转发;没有超时 |
224
225
  | `custom`(会话记录浮层) | 无 | RPC 直接返回 `undefined`:选中一个会话后什么都不显示;print / json 同理 |
225
226
 
227
+ 会话 picker、只读会话浮层以及每级 settings 菜单/输入都由操作员主动打开,不会阻塞 agent loop。TUI 中,每次调用这些 UI 前都会同步发出 `notify:non-blocking-prompt` 声明。RPC/print/json 不声明:嵌套或重叠对话框没有各自的最外层 start,保留未声明的默认行为比留下未配对声明更安全。
228
+
226
229
  ## 许可证
227
230
 
228
231
  MIT
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.11.5",
6
+ "version": "0.11.6",
7
7
  "description": "Focused, in-process sub-agent core for pi — autonomous agents plus a typed API and lifecycle events",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -40,13 +40,13 @@
40
40
  "typebox": "*"
41
41
  },
42
42
  "devDependencies": {
43
- "@biomejs/biome": "^2.6.6",
43
+ "@biomejs/biome": "^2.6.8",
44
44
  "@earendil-works/pi-ai": "1.5.0",
45
45
  "@earendil-works/pi-coding-agent": "1.5.0",
46
46
  "@earendil-works/pi-tui": "1.5.0",
47
47
  "@types/node": "^26.6.6",
48
- "typebox": "^1.4.6",
48
+ "typebox": "^1.4.7",
49
49
  "typescript": "~7.0.2",
50
- "vitest": "^5.1.0"
50
+ "vitest": "^5.1.1"
51
51
  }
52
52
  }
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  createAgentSession,
16
16
  DefaultResourceLoader,
17
17
  type ExtensionAPI,
18
+ type ExtensionCommandContext,
18
19
  getAgentDir,
19
20
  SettingsManager as SdkSettingsManager,
20
21
  SessionManager,
@@ -157,6 +158,13 @@ export default function (pi: ExtensionAPI) {
157
158
 
158
159
  pi.registerTool(new SteerTool(manager, pi.events).toToolDefinition());
159
160
 
161
+ // TUI serializes operator prompts, so each declaration has an outermost start.
162
+ // RPC clients can nest or overlap dialogs, while the host emits only the outermost
163
+ // start; declaring there could leave a count that silences a later blocking prompt.
164
+ const announceNonBlockingPrompt = (ctx: ExtensionCommandContext): void => {
165
+ if (ctx.mode === "tui") pi.events.emit("notify:non-blocking-prompt", {});
166
+ };
167
+
160
168
  // ---- /subagents:settings command ----
161
169
 
162
170
  const subagentsSettings = new SubagentsSettingsHandler(settings);
@@ -164,7 +172,10 @@ export default function (pi: ExtensionAPI) {
164
172
  pi.registerCommand("subagents:settings", {
165
173
  description: "Configure subagent settings (concurrency, turn limits, timeouts)",
166
174
  handler: async (_args, ctx) => {
167
- await subagentsSettings.handle({ ui: ctx.ui });
175
+ await subagentsSettings.handle({
176
+ ui: ctx.ui,
177
+ announceNonBlockingPrompt: () => announceNonBlockingPrompt(ctx),
178
+ });
168
179
  },
169
180
  });
170
181
 
@@ -182,6 +193,7 @@ export default function (pi: ExtensionAPI) {
182
193
  registry,
183
194
  cwd: ctx.cwd,
184
195
  readFile: (path) => readFileSync(path, "utf8"),
196
+ announceNonBlockingPrompt: () => announceNonBlockingPrompt(ctx),
185
197
  });
186
198
  },
187
199
  });
@@ -70,6 +70,8 @@ export interface SessionNavigatorParams {
70
70
  cwd: string;
71
71
  /** Reads a persisted session file for the file-snapshot source. */
72
72
  readFile: (path: string) => string;
73
+ /** Declares operator-driven UI as non-blocking immediately before it opens. */
74
+ announceNonBlockingPrompt: () => void;
73
75
  }
74
76
 
75
77
  /** Options for the read-only transcript overlay. */
@@ -96,13 +98,22 @@ export interface TranscriptOverlayOptions {
96
98
  * manager, so it stays a reactive consumer with no inbound call into the core.
97
99
  */
98
100
  export class SessionNavigatorHandler {
99
- async handle({ ui, agents, evicted, registry, cwd, readFile }: SessionNavigatorParams): Promise<void> {
101
+ async handle({
102
+ ui,
103
+ agents,
104
+ evicted,
105
+ registry,
106
+ cwd,
107
+ readFile,
108
+ announceNonBlockingPrompt,
109
+ }: SessionNavigatorParams): Promise<void> {
100
110
  const entries = listNavigableAgents(agents, evicted, registry);
101
111
  if (entries.length === 0) {
102
112
  ui.notify("No subagent sessions to view.", "info");
103
113
  return;
104
114
  }
105
115
 
116
+ announceNonBlockingPrompt();
106
117
  const choice = await ui.select(
107
118
  "Subagent sessions",
108
119
  entries.map((entry) => entry.label),
@@ -128,6 +139,7 @@ export class SessionNavigatorHandler {
128
139
  return;
129
140
  }
130
141
  const markdownTheme = getMarkdownTheme();
142
+ announceNonBlockingPrompt();
131
143
  await ui.custom<undefined>(
132
144
  (tui, theme, _keybindings, done) =>
133
145
  new TranscriptOverlay({
@@ -30,7 +30,14 @@ export interface SubagentsSettingsUI {
30
30
  export class SubagentsSettingsHandler {
31
31
  constructor(private readonly settings: SubagentsSettingsManager) {}
32
32
 
33
- async handle({ ui }: { ui: SubagentsSettingsUI }): Promise<void> {
33
+ async handle({
34
+ ui,
35
+ announceNonBlockingPrompt,
36
+ }: {
37
+ ui: SubagentsSettingsUI;
38
+ announceNonBlockingPrompt: () => void;
39
+ }): Promise<void> {
40
+ announceNonBlockingPrompt();
34
41
  const choice = await ui.select("Settings", [
35
42
  `Max concurrency (current: ${this.settings.maxConcurrent})`,
36
43
  `Default max turns (current: ${this.settings.defaultMaxTurns ?? "unlimited"})`,
@@ -40,6 +47,7 @@ export class SubagentsSettingsHandler {
40
47
  if (!choice) return;
41
48
 
42
49
  if (choice.startsWith("Max concurrency")) {
50
+ announceNonBlockingPrompt();
43
51
  const val = await ui.input("Max concurrent background agents", String(this.settings.maxConcurrent));
44
52
  if (val) {
45
53
  const n = parseInt(val, 10);
@@ -51,6 +59,7 @@ export class SubagentsSettingsHandler {
51
59
  }
52
60
  }
53
61
  } else if (choice.startsWith("Default max turns")) {
62
+ announceNonBlockingPrompt();
54
63
  const val = await ui.input(
55
64
  "Default max turns before wrap-up (0 = unlimited)",
56
65
  String(this.settings.defaultMaxTurns ?? 0),
@@ -65,6 +74,7 @@ export class SubagentsSettingsHandler {
65
74
  }
66
75
  }
67
76
  } else if (choice.startsWith("Default timeout")) {
77
+ announceNonBlockingPrompt();
68
78
  const val = await ui.input(
69
79
  "Default timeout in seconds (0 = unlimited)",
70
80
  String(this.settings.defaultTimeoutSeconds ?? 0),
@@ -79,6 +89,7 @@ export class SubagentsSettingsHandler {
79
89
  }
80
90
  }
81
91
  } else if (choice.startsWith("Grace turns")) {
92
+ announceNonBlockingPrompt();
82
93
  const val = await ui.input("Grace turns after wrap-up steer", String(this.settings.graceTurns));
83
94
  if (val) {
84
95
  const n = parseInt(val, 10);