feat(extensions): ui prompt events (#8355)

* feat(extensions): ui prompt events

* fix: handlers should not delay the prompt
This commit is contained in:
Cristina Poncela Cubeiro 2026-08-27 11:28:05 +02:00 • committed by GitHub
parent e86823096c
commit ccfe79ed23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 104 additions and 2 deletions

View file

@ -580,6 +580,24 @@ pi.on("agent_settled", async (_event, ctx) => {
});
```
#### ui_prompt_start / ui_prompt_end
Notification-only lifecycle events for blocking user-facing extension UI prompts. They fire around `ctx.ui.select()`, `ctx.ui.confirm()`, `ctx.ui.input()`, `ctx.ui.editor()`, and `ctx.ui.custom()` so host/status integrations can report "waiting for user" instead of just "running".
Nested or overlapping prompts are coalesced into one outer waiting span. Handlers are invoked best-effort and are not awaited before showing or closing the prompt.
```typescript
pi.on("ui_prompt_start", async (event, ctx) => {
// event.reason === "ui_prompt"
// event.kind: "select" | "confirm" | "input" | "editor" | "custom"
// event.title: prompt title when available
});
pi.on("ui_prompt_end", async (event, ctx) => {
// Pi is no longer waiting on that UI prompt span.
});
```
#### turn_start / turn_end
Fired for each turn (one LLM response + tool calls).