@pi-unipi/ask-user 2.19.3 → 2.20.0

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 +2 -2
  2. package/tools.ts +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/ask-user",
3
- "version": "2.19.3",
3
+ "version": "2.20.0",
4
4
  "description": "Structured user input tool for Pi coding agent — single-select, multi-select, freeform",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -40,7 +40,7 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@pi-unipi/core": "2.19.3"
43
+ "@pi-unipi/core": "2.20.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@earendil-works/pi-coding-agent": "^0.84.0",
package/tools.ts CHANGED
@@ -19,6 +19,14 @@ import { renderLauncherUI } from "./launcher-ui.js";
19
19
  import { getAskUserSettings } from "./config.js";
20
20
  import { queueCompactHandoff, queueDirectHandoff } from "./handoff.js";
21
21
 
22
+ /**
23
+ * Whether this process is a subagent child (subagents package or fusion sidekick).
24
+ * Subagent children never talk to the user directly — their lead owns ambiguity.
25
+ */
26
+ export function isSubagentChild(env: Record<string, string | undefined> = process.env): boolean {
27
+ return env.UNIPI_SUBAGENT_CHILD === "1";
28
+ }
29
+
22
30
  /**
23
31
  * Register ask-user tools.
24
32
  */
@@ -130,6 +138,28 @@ export function registerAskUserTools(pi: ExtensionAPI): void {
130
138
  timeout?: number;
131
139
  };
132
140
 
141
+ // Subagent children have no user to talk to. Refuse loudly so the
142
+ // subagent surfaces the question to its lead instead of guessing.
143
+ if (isSubagentChild()) {
144
+ return {
145
+ content: [
146
+ {
147
+ type: "text",
148
+ text:
149
+ "ask_user is not available inside a subagent. You cannot talk to the user directly — only your lead can. Do not guess or assume an answer. Stop and state the question, the options you considered, and your recommendation in your report so your lead can decide.",
150
+ },
151
+ ],
152
+ isError: true,
153
+ details: {
154
+ question,
155
+ response: {
156
+ kind: "cancelled",
157
+ comment: "ask_user is not available inside a subagent",
158
+ } as AskUserResponse,
159
+ },
160
+ };
161
+ }
162
+
133
163
  // Check settings
134
164
  const settings = getAskUserSettings();
135
165
  if (!settings.enabled) {