pi-ask-popup 0.2.0 → 0.2.1
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/docs/tool-schema.md +7 -4
- package/package.json +1 -1
- package/src/ask-user-question.ts +4 -1
- package/src/events.ts +8 -2
- package/src/index.ts +1 -0
package/docs/tool-schema.md
CHANGED
|
@@ -106,19 +106,22 @@ When `error` is `timed_out`, the text is `Questionnaire timed out, the user did
|
|
|
106
106
|
|
|
107
107
|
## Events
|
|
108
108
|
|
|
109
|
-
The package emits
|
|
109
|
+
The package emits lifecycle events on Pi's event bus after validation passes. Import their names and payload types from the `./events` subpath:
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
112
|
import {
|
|
113
113
|
ASK_POPUP_PROMPT_EVENT,
|
|
114
114
|
ASK_POPUP_BLOCKED_EVENT,
|
|
115
|
+
HERDR_BLOCKED_EVENT,
|
|
115
116
|
type AskPopupPromptEventPayload,
|
|
116
117
|
type AskPopupBlockedEventPayload,
|
|
117
118
|
} from "pi-ask-popup/events";
|
|
118
119
|
```
|
|
119
120
|
|
|
120
|
-
`ASK_POPUP_PROMPT_EVENT`
|
|
121
|
+
`ASK_POPUP_PROMPT_EVENT` is `pi-ask-popup:prompt`. It fires once before the dialog shows. Its payload is `questions[].{ question, header, multiSelect, options[] }`, where each option is `{ label, description, hasPreview }`. Preview content is not shipped, only `hasPreview: boolean`, so listeners that forward the event stay small.
|
|
121
122
|
|
|
122
|
-
`ASK_POPUP_BLOCKED_EVENT`
|
|
123
|
+
`ASK_POPUP_BLOCKED_EVENT` is `pi-ask-popup:blocked`. Its payload is `{ active: boolean }`. It brackets the wait with `true` when the questionnaire starts and `false` when it resolves, so status or footer extensions can show that the agent is waiting.
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
`HERDR_BLOCKED_EVENT` is `herdr:blocked`. It receives the same blocked payload at the same points. Herdr's Pi integration consumes this channel to mark the agent as waiting for input and issue its configured request notification. Nothing happens when Herdr is absent.
|
|
126
|
+
|
|
127
|
+
The payloads are JSON-safe. Channel names are stable. Changes are append-only and optional, and any breaking change ships as a new channel rather than a version field.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ask-popup",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Pi extension. A tabbed terminal questionnaire the model can put to you when it would otherwise guess, with typed options, markdown previews and notes instead of free-form replies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/ask-user-question.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
ASK_POPUP_BLOCKED_EVENT,
|
|
23
23
|
ASK_POPUP_PROMPT_EVENT,
|
|
24
24
|
buildBlockedPayload,
|
|
25
|
+
HERDR_BLOCKED_EVENT,
|
|
25
26
|
buildPromptPayload,
|
|
26
27
|
} from "./events.js";
|
|
27
28
|
// Static import: the walker pulls only types, none of the render graph the
|
|
@@ -88,7 +89,9 @@ function emitPrompt(pi: ExtensionAPI, params: QuestionParams): void {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
function emitBlocked(pi: ExtensionAPI, active: boolean): void {
|
|
91
|
-
|
|
92
|
+
const payload = buildBlockedPayload(active);
|
|
93
|
+
pi.events.emit(ASK_POPUP_BLOCKED_EVENT, payload);
|
|
94
|
+
pi.events.emit(HERDR_BLOCKED_EVENT, payload);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
/** The backstop for a host with no UI at all; the reconciler normally strips the tool first. */
|
package/src/events.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* This module deliberately imports nothing. A footer, statusline or notifier
|
|
5
5
|
* subscribes to these channels to know what is being asked and whether the
|
|
6
6
|
* agent is waiting on a person; it should not have to load a render graph, or
|
|
7
|
-
* a schema compiler, to read
|
|
7
|
+
* a schema compiler, to read three strings and four interfaces. Adding an import
|
|
8
8
|
* here defeats the reason the `./events` subpath exists, so there is a test
|
|
9
9
|
* that fails if one appears.
|
|
10
10
|
*
|
|
11
|
-
* Stability rules for
|
|
11
|
+
* Stability rules for these channels:
|
|
12
12
|
*
|
|
13
13
|
* 1. Channel names never change once published. Subscribers hardcode them.
|
|
14
14
|
* 2. Payload changes are append-only, and new fields ship optional.
|
|
@@ -29,6 +29,12 @@ export const ASK_POPUP_PROMPT_EVENT = "pi-ask-popup:prompt" as const;
|
|
|
29
29
|
/** Fired true before the wait and false when it ends, however it ends. */
|
|
30
30
|
export const ASK_POPUP_BLOCKED_EVENT = "pi-ask-popup:blocked" as const;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Herdr's Pi integration listens on this shared channel for nested UI that
|
|
34
|
+
* needs a decision. Emitting it is inert when Herdr is not installed.
|
|
35
|
+
*/
|
|
36
|
+
export const HERDR_BLOCKED_EVENT = "herdr:blocked" as const;
|
|
37
|
+
|
|
32
38
|
export interface AskPopupPromptOption {
|
|
33
39
|
label: string;
|
|
34
40
|
description: string;
|
package/src/index.ts
CHANGED