@astralyn/pi 0.84.4 → 0.84.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/CHANGELOG.md +57 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +5 -4
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +11 -6
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/experimental.d.ts +4 -0
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +10 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +19 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +29 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +1 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/project-trust.js +2 -2
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/sdk.d.ts +5 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.js +2 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +12 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +7 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +4 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +2 -0
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/background/index.d.ts +149 -0
- package/dist/extensions/background/index.d.ts.map +1 -0
- package/dist/extensions/background/index.js +666 -0
- package/dist/extensions/background/index.js.map +1 -0
- package/dist/extensions/background/manager.d.ts +95 -0
- package/dist/extensions/background/manager.d.ts.map +1 -0
- package/dist/extensions/background/manager.js +421 -0
- package/dist/extensions/background/manager.js.map +1 -0
- package/dist/extensions/background/registry.d.ts +220 -0
- package/dist/extensions/background/registry.d.ts.map +1 -0
- package/dist/extensions/background/registry.js +589 -0
- package/dist/extensions/background/registry.js.map +1 -0
- package/dist/extensions/background/render.d.ts +50 -0
- package/dist/extensions/background/render.d.ts.map +1 -0
- package/dist/extensions/background/render.js +260 -0
- package/dist/extensions/background/render.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/subagent/activity.d.ts +3 -6
- package/dist/extensions/subagent/activity.d.ts.map +1 -1
- package/dist/extensions/subagent/activity.js +9 -93
- package/dist/extensions/subagent/activity.js.map +1 -1
- package/dist/extensions/subagent/agents-command.d.ts.map +1 -1
- package/dist/extensions/subagent/agents-command.js +270 -169
- package/dist/extensions/subagent/agents-command.js.map +1 -1
- package/dist/extensions/subagent/agents.d.ts +5 -6
- package/dist/extensions/subagent/agents.d.ts.map +1 -1
- package/dist/extensions/subagent/agents.js +28 -192
- package/dist/extensions/subagent/agents.js.map +1 -1
- package/dist/extensions/subagent/budget.d.ts +15 -0
- package/dist/extensions/subagent/budget.d.ts.map +1 -0
- package/dist/extensions/subagent/budget.js +96 -0
- package/dist/extensions/subagent/budget.js.map +1 -0
- package/dist/extensions/subagent/cancellation.d.ts +29 -0
- package/dist/extensions/subagent/cancellation.d.ts.map +1 -0
- package/dist/extensions/subagent/cancellation.js +73 -0
- package/dist/extensions/subagent/cancellation.js.map +1 -0
- package/dist/extensions/subagent/constants.d.ts +4 -5
- package/dist/extensions/subagent/constants.d.ts.map +1 -1
- package/dist/extensions/subagent/constants.js +11 -7
- package/dist/extensions/subagent/constants.js.map +1 -1
- package/dist/extensions/subagent/index.d.ts +0 -3
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +59 -208
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/subagent/model-selection.d.ts +16 -0
- package/dist/extensions/subagent/model-selection.d.ts.map +1 -0
- package/dist/extensions/subagent/model-selection.js +51 -0
- package/dist/extensions/subagent/model-selection.js.map +1 -0
- package/dist/extensions/subagent/render.d.ts +7 -2
- package/dist/extensions/subagent/render.d.ts.map +1 -1
- package/dist/extensions/subagent/render.js +219 -576
- package/dist/extensions/subagent/render.js.map +1 -1
- package/dist/extensions/subagent/resolve.d.ts +2 -2
- package/dist/extensions/subagent/resolve.d.ts.map +1 -1
- package/dist/extensions/subagent/resolve.js +24 -35
- package/dist/extensions/subagent/resolve.js.map +1 -1
- package/dist/extensions/subagent/runner.d.ts +4 -6
- package/dist/extensions/subagent/runner.d.ts.map +1 -1
- package/dist/extensions/subagent/runner.js +101 -316
- package/dist/extensions/subagent/runner.js.map +1 -1
- package/dist/extensions/subagent/schema.d.ts +4 -10
- package/dist/extensions/subagent/schema.d.ts.map +1 -1
- package/dist/extensions/subagent/schema.js +8 -13
- package/dist/extensions/subagent/schema.js.map +1 -1
- package/dist/extensions/subagent/sdk-runner.d.ts +13 -11
- package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -1
- package/dist/extensions/subagent/sdk-runner.js +169 -161
- package/dist/extensions/subagent/sdk-runner.js.map +1 -1
- package/dist/extensions/subagent/settings.d.ts +2 -2
- package/dist/extensions/subagent/settings.d.ts.map +1 -1
- package/dist/extensions/subagent/settings.js +27 -14
- package/dist/extensions/subagent/settings.js.map +1 -1
- package/dist/extensions/subagent/state.d.ts +89 -0
- package/dist/extensions/subagent/state.d.ts.map +1 -0
- package/dist/extensions/subagent/state.js +294 -0
- package/dist/extensions/subagent/state.js.map +1 -0
- package/dist/extensions/subagent/text.d.ts +7 -0
- package/dist/extensions/subagent/text.d.ts.map +1 -0
- package/dist/extensions/subagent/text.js +91 -0
- package/dist/extensions/subagent/text.js.map +1 -0
- package/dist/extensions/subagent/types.d.ts +16 -43
- package/dist/extensions/subagent/types.d.ts.map +1 -1
- package/dist/extensions/subagent/types.js.map +1 -1
- package/dist/extensions/subagent/ui/choices.d.ts +36 -0
- package/dist/extensions/subagent/ui/choices.d.ts.map +1 -0
- package/dist/extensions/subagent/ui/choices.js +54 -0
- package/dist/extensions/subagent/ui/choices.js.map +1 -0
- package/dist/extensions/subagent/ui/model-list.d.ts +4 -3
- package/dist/extensions/subagent/ui/model-list.d.ts.map +1 -1
- package/dist/extensions/subagent/ui/model-list.js +20 -22
- package/dist/extensions/subagent/ui/model-list.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +77 -25
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +36 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +2 -0
- package/dist/modes/interactive/theme/light.json +2 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +23 -10
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +5 -3
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +12 -2
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +4 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +5 -2
- package/dist/modes/json-event.js.map +1 -1
- package/dist/package-manager-cli.js +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/server/create-harness.d.ts.map +1 -1
- package/dist/server/create-harness.js +2 -0
- package/dist/server/create-harness.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +10 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +14 -19
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/bundled/README.md +1 -0
- package/docs/bundled/extensions/background.md +99 -0
- package/docs/bundled/extensions/subagent.md +83 -71
- package/docs/compaction.md +6 -6
- package/docs/custom-provider.md +1 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +8 -2
- package/docs/extensions.md +19 -2
- package/docs/json.md +6 -4
- package/docs/keybindings.md +9 -2
- package/docs/rpc.md +15 -4
- package/docs/sdk.md +9 -0
- package/docs/settings.md +31 -0
- package/docs/terminal-setup.md +23 -2
- package/docs/themes.md +24 -3
- package/docs/tui.md +2 -2
- package/docs/usage.md +4 -3
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +170 -221
- package/package.json +6 -6
- package/dist/extensions/subagent/display-name.d.ts +0 -6
- package/dist/extensions/subagent/display-name.d.ts.map +0 -1
- package/dist/extensions/subagent/display-name.js +0 -13
- package/dist/extensions/subagent/display-name.js.map +0 -1
- package/dist/extensions/subagent/retry.d.ts +0 -17
- package/dist/extensions/subagent/retry.d.ts.map +0 -1
- package/dist/extensions/subagent/retry.js +0 -41
- package/dist/extensions/subagent/retry.js.map +0 -1
- package/dist/extensions/subagent/ui/profile-editor.d.ts +0 -54
- package/dist/extensions/subagent/ui/profile-editor.d.ts.map +0 -1
- package/dist/extensions/subagent/ui/profile-editor.js +0 -154
- package/dist/extensions/subagent/ui/profile-editor.js.map +0 -1
- package/dist/extensions/subagent/ui/profile-picker.d.ts +0 -32
- package/dist/extensions/subagent/ui/profile-picker.d.ts.map +0 -1
- package/dist/extensions/subagent/ui/profile-picker.js +0 -149
- package/dist/extensions/subagent/ui/profile-picker.js.map +0 -1
- package/examples/extensions/subagent/README.md +0 -175
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -1009
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# background — background bash tasks
|
|
2
|
+
|
|
3
|
+
Adds the `bg` tool (actions: `create`, `read`, `wait`, `kill`, `list`) plus the `/bg` command. Long-running commands (dev servers, watch builds, slow tests) run in the background while the agent keeps working; when a task ends, its status, exit code, and a tail of its output arrive automatically as a notification.
|
|
4
|
+
|
|
5
|
+
## Tool
|
|
6
|
+
|
|
7
|
+
All five operations share one tool. Every call sets `action`; the remaining parameters belong to that action.
|
|
8
|
+
|
|
9
|
+
### create
|
|
10
|
+
|
|
11
|
+
Starts a command in the background and returns immediately with a task id and an output file path:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{ "action": "create", "command": "npm run build", "description": "build", "timeout": 300 }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `description` is a short model-written label (e.g. `dev server`) shown in `/bg`, task listings, and the completion notification.
|
|
18
|
+
- `timeout` is in seconds; on expiry the task is killed and reported as `timeout`.
|
|
19
|
+
- The command runs detached — appending `&` is never needed and would lose exit-code tracking.
|
|
20
|
+
|
|
21
|
+
The tool result only reports the start. The completion notification is the single source of truth for the outcome, so there is never a need to poll with sleep loops or repeated reads.
|
|
22
|
+
|
|
23
|
+
### read
|
|
24
|
+
|
|
25
|
+
Reads a bounded slice of a task's output file while it runs or after it ends:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{ "action": "read", "taskId": "bg-3f2a91", "mode": "tail", "bytes": 8192 }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`mode` defaults to `tail`; `bytes` defaults to 8KB and clamps between 256 bytes and 50KB. Truncated reads state the omission up front and always include the full output path; reads of a running task say `still running`. The output file is a plain file — the built-in read tool also works on it for line-based paging.
|
|
32
|
+
|
|
33
|
+
### wait
|
|
34
|
+
|
|
35
|
+
Blocks until a task finishes, within a bound:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{ "action": "wait", "taskId": "bg-3f2a91", "waitMs": 20000, "sinceBytes": 4096 }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `waitMs` defaults to 20000 and clamps between 1000 and 60000.
|
|
42
|
+
- `sinceBytes` (taken from a previous read/wait result) restricts the returned output to what was written after that offset; without it the last 32KB is returned. Offsets past EOF (for example after output truncation) fall back to the tail and say so.
|
|
43
|
+
|
|
44
|
+
If the task finishes within the window, the result is delivered inline — status, exit code, runtime, and the bounded output delta — and the followUp notification is suppressed, so the completion is delivered exactly once. If the window expires, the result says the task is still running, includes a small tail peek so progress stays visible, and the notification fires later as usual. This is the only sanctioned way to wait; sleeping to emulate it is never correct.
|
|
45
|
+
|
|
46
|
+
### kill
|
|
47
|
+
|
|
48
|
+
Stops a single running task by killing its whole process tree:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "action": "kill", "taskId": "bg-3f2a91" }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Killing does not bypass the normal pipeline: the task still finalizes as `killed` and its completion is delivered wherever it was awaited — inline via `wait`, or as the notification otherwise.
|
|
55
|
+
|
|
56
|
+
### list
|
|
57
|
+
|
|
58
|
+
Lists currently known tasks — running tasks first, then the five most recently finished, with any overflow folded into a trailing note:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{ "action": "list" }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Task ids accept a unique prefix (with or without the `bg-` part); an ambiguous prefix is an error listing the candidates.
|
|
65
|
+
|
|
66
|
+
## Completion delivery
|
|
67
|
+
|
|
68
|
+
When a task ends, the extension sends a `background-task` notification: a small XML message carrying the task id, terminal status, exit code, runtime, output file path, the optional description, and the sanitized last ~4KB of output. While the agent is streaming, the notification queues behind the current run and is delivered when the run settles; when the agent is idle, it wakes a new turn so the result is acted on immediately.
|
|
69
|
+
|
|
70
|
+
The transcript renders this notification as a one-line summary (`✓ bg-3f2a91 npm run build — completed, exit 0 in 34s`; with a description: `✓ bg-3f2a91 dev server (npm run build) — completed, exit 0 in 34s`) with the output file's name below; expanding it shows the full output path and the embedded output tail.
|
|
71
|
+
|
|
72
|
+
## /bg
|
|
73
|
+
|
|
74
|
+
`/bg` opens an inline task menu in the editor slot (like `/model`); the chat transcript stays visible above it. The list shows each task's status glyph, id, duration, and label (the description over the first command line); `Enter` opens the selected task's live output view, which replaces the menu.
|
|
75
|
+
|
|
76
|
+
| Key | In the task list | In the output view |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `↑` / `↓` | Select task | Scroll one line (freezes following) |
|
|
79
|
+
| `Enter` | Open the selected task's output | — |
|
|
80
|
+
| `k` | Kill the selected running task | Kill the viewed task |
|
|
81
|
+
| `PgUp` / `PgDn` | — | Scroll a page; `PgUp` freezes following, scrolling back to the bottom resumes it |
|
|
82
|
+
| `Esc` | Close the menu | Back to the task list |
|
|
83
|
+
|
|
84
|
+
While a `bg wait` call is pending, its transcript row refreshes once per second (`bg wait bg-3f · waiting 12s/20s · +3.2KB new output`) until the result settles. The task list separates running tasks from finished ones with a `── finished ──` divider and adapts its visible rows to short terminal windows. The output view polls the output file once per second and only ever reads the last 128KB — and only when the task's output actually grew; a finished task's output is read once. Outside an interactive TUI, `/bg` prints a bounded task summary instead.
|
|
85
|
+
|
|
86
|
+
## Statusline
|
|
87
|
+
|
|
88
|
+
Running and finished counts appear in the footer as `bg 2 running · 1 done`; tasks the stall watchdog has flagged are reported separately as `bg 2 running · 1 waiting for input · 1 done` (flagged tasks are running tasks, so the counts add up); the segment disappears when no tasks exist.
|
|
89
|
+
|
|
90
|
+
## Limits and lifecycle
|
|
91
|
+
|
|
92
|
+
- Background tasks inherit the session's `PI_*` environment variables (`PI_SESSION_ID`, `PI_MODEL`, …) just like the built-in bash tool, snapshotted when the task starts.
|
|
93
|
+
- Tasks run through the session's configured shell (`shellPath`) and honor `shellCommandPrefix`, matching the built-in bash tool. The prefix is applied at execution time only — it never appears in task labels or notifications.
|
|
94
|
+
- Output streams directly to a system-temp file (`pi-bg-<id>.log`), never into the project or into memory. Memory holds only a byte counter.
|
|
95
|
+
- Output is capped at 20MB. Hitting the cap kills the task and marks it `failed` rather than silently truncating.
|
|
96
|
+
- At most 8 tasks may run concurrently; `create` reports the running tasks when the limit is reached.
|
|
97
|
+
- Aborting the current turn (Esc) does not kill background tasks — that is what `kill` and `/bg` are for.
|
|
98
|
+
- Session shutdown, `/reload`, new sessions, and session switches kill all running tasks; those kills are silent (no notification flood). There is no restart reattachment: finished-task records live only for the current session.
|
|
99
|
+
- Output files outlive the session for later inspection (the `read` action and notifications keep pointing at them); Pi never deletes them automatically — the system temp directory's own cleanup policy applies.
|
|
@@ -1,111 +1,123 @@
|
|
|
1
1
|
# subagent — isolated foreground delegation
|
|
2
2
|
|
|
3
|
-
Adds the `subagent` tool and `/agents`
|
|
3
|
+
Adds the `subagent` tool and `/agents` settings command. It delegates bounded work to isolated in-process `AgentSession` workers; it is not a background-worker or fleet-management system.
|
|
4
|
+
|
|
5
|
+
## Tool contract
|
|
6
|
+
|
|
7
|
+
Every call supplies one ordered `tasks` array with 1–8 items:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"tasks": [
|
|
12
|
+
{
|
|
13
|
+
"prompt": "Locate the provider retry implementation and report exact symbols.",
|
|
14
|
+
"agent": "explorer",
|
|
15
|
+
"cwd": "src/core"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
```
|
|
4
20
|
|
|
5
|
-
|
|
21
|
+
Each item has:
|
|
6
22
|
|
|
7
|
-
|
|
23
|
+
```text
|
|
24
|
+
prompt Required self-contained worker briefing
|
|
25
|
+
agent? explorer or general; defaults to explorer
|
|
26
|
+
cwd? Directory inside the parent working directory
|
|
27
|
+
```
|
|
8
28
|
|
|
9
|
-
-
|
|
10
|
-
- **Parallel**: `tasks`, an array of independent task objects.
|
|
29
|
+
There is no separate single-task or parallel mode. One item launches one worker; multiple items launch concurrent workers. A session-scoped gate permits at most five active workers across all sibling `subagent` calls, so additional items wait for a slot. Results always follow input order, regardless of completion order.
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
All tasks are preflighted before any worker starts. Profile, working-directory, model, thinking-level, or authentication failure in one item rejects the entire call without launching the other workers. Once execution begins, one worker failing does not cancel independent siblings.
|
|
13
32
|
|
|
14
|
-
|
|
33
|
+
Sequential work uses another `subagent` call after the parent has read the previous report and written the next briefing.
|
|
15
34
|
|
|
16
|
-
|
|
17
|
-
agent? Agent profile name; defaults to general
|
|
18
|
-
description Short UI label
|
|
19
|
-
prompt Self-contained worker briefing
|
|
20
|
-
cwd? Relative or absolute directory inside the parent working directory
|
|
21
|
-
```
|
|
35
|
+
## Built-in profiles
|
|
22
36
|
|
|
23
|
-
|
|
37
|
+
There are exactly two profiles:
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
- **Explorer** (`explorer`, default): read-only investigation with `read`, `grep`, `find`, `ls`, and `bash`. Bash remains available for Git history and inspection commands such as `git log`, `git diff`, `git blame`, `git show`, `git status`, `wc`, `head`, and `tail`. Its system prompt forbids redirects, heredoc writes, temporary files, state-changing Git commands, installs, and network access.
|
|
40
|
+
- **General** (`general`): implementation, file changes, and stateful verification with `read`, `bash`, `edit`, and `write`.
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
There are no user or project profile files. Child sessions load no extensions, skills, prompt templates, or themes, so workers cannot recursively call `subagent` or inherit unrelated extension capabilities. Explorer continues to skip project context files such as `AGENTS.md`; General loads trusted project context normally.
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
name: reviewer
|
|
32
|
-
description: Read-only implementation reviewer
|
|
33
|
-
tools: read, grep, find, ls
|
|
34
|
-
model: anthropic/claude-sonnet-4-5
|
|
35
|
-
thinking: medium
|
|
36
|
-
backend: sdk
|
|
37
|
-
---
|
|
44
|
+
Worker contexts are isolated, but workers share the parent's checkout. Concurrent tasks therefore must be independent and must not perform overlapping writes.
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
```
|
|
46
|
+
## Model and thinking selection
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
Model and thinking resolution has two layers:
|
|
43
49
|
|
|
44
50
|
```text
|
|
45
|
-
|
|
51
|
+
saved /agents override > current parent session
|
|
46
52
|
```
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
Callers cannot select model or thinking per task. Run `/agents` to configure Explorer or General:
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
1. Select **Explorer** or **General**.
|
|
57
|
+
2. Select **Model** or **Thinking**.
|
|
58
|
+
3. Choose a concrete value or **inherit**.
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
- `explorer`: `read`, `grep`, `find`, and `ls`, plus `bash` constrained by its system prompt to read-only inspection (git history, counting, and similar).
|
|
60
|
+
Each confirmed choice is saved immediately; there is no draft, Apply, or Save step. Choosing **inherit** immediately removes that override. Escape only navigates back and never rolls back choices already confirmed.
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## Model and thinking selection
|
|
62
|
+
The TUI model picker supports search, scoped/all models, unavailable saved models, and catalog refresh. Thinking choices are limited to levels supported by the effective model.
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
Overrides are saved atomically in:
|
|
60
65
|
|
|
61
66
|
```text
|
|
62
|
-
|
|
67
|
+
~/.pi/agent/subagent.json
|
|
63
68
|
```
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
frontmatter is intentionally ignored: agent files travel across machines, so a
|
|
67
|
-
pinned model rarely exists in the reader's environment.
|
|
70
|
+
Only `explorer` and `general` keys are valid. A stale or invalid `subagent.json` (older formats, unknown profiles, or malformed JSON) is reset to an empty, fully inheriting config the first time it is loaded, so an old file never blocks the tool or `/agents`. Overrides affect future workers and never change the parent session's model or thinking level.
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
(`explorer` becomes `Explorer`, `code-reviewer` becomes `Code Reviewer`) in
|
|
71
|
-
identifier order, while tool calls, profile files, and saved configuration keep
|
|
72
|
-
the lowercase identifier. The selected profile's human-facing description
|
|
73
|
-
appears below the list in full and wraps to the terminal width; built-in
|
|
74
|
-
profiles keep longer delegation guidance out of this UI copy.
|
|
72
|
+
## Lifecycle and retry
|
|
75
73
|
|
|
76
|
-
The
|
|
74
|
+
- The parent call waits until every worker reaches a terminal state.
|
|
75
|
+
- Parent abort, `/reload`, `/new`, `/resume`, `/fork`, and session shutdown abort active and queued workers.
|
|
76
|
+
- Provider auto-retry remains visible as `Retrying (n/m) in Xs`.
|
|
77
|
+
- A retryable failure that produced no turns or tool use may be retried at task level up to two more times. Runs with partial work are never restarted.
|
|
78
|
+
- Retry backoff does not hold a concurrency slot; another queued worker can run while the failed task waits.
|
|
79
|
+
- A parent abort or session shutdown interrupts queued and retrying workers immediately.
|
|
77
80
|
|
|
78
|
-
-
|
|
79
|
-
- use `Tab` to switch between scoped and all models when a scope exists;
|
|
80
|
-
- use the configured thinking-cycle key (`Shift+Tab` by default) to choose
|
|
81
|
-
**inherit** or a level supported by the highlighted model;
|
|
82
|
-
- use `Enter` to save the model and thinking choice together, or `Esc` to return
|
|
83
|
-
without saving.
|
|
81
|
+
Child sessions share the parent's canonical model/authentication runtime, so extension-registered providers and current credentials do not need to be mirrored into a second runtime.
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
explicit model is stored as `provider/model`; an explicit thinking override is
|
|
87
|
-
stored as its supported level.
|
|
83
|
+
## Transcript UI
|
|
88
84
|
|
|
89
|
-
|
|
85
|
+
While running, the collapsed view shows a progress header followed by one
|
|
86
|
+
row per task in original input order:
|
|
90
87
|
|
|
91
88
|
```text
|
|
92
|
-
|
|
89
|
+
› 2/4 done · 12s
|
|
90
|
+
› Explorer · Locate retry scheduling — Run git log
|
|
91
|
+
✓ Explorer · Map provider registration
|
|
92
|
+
○ Explorer · Find related tests
|
|
93
|
+
○ General · Apply focused fix
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Every task is always listed: there is no row cap, no active-first
|
|
97
|
+
reordering, and no `+N more` truncation. Live rows append the current
|
|
98
|
+
activity, failure reason, or retry countdown.
|
|
99
|
+
|
|
100
|
+
Expanded running calls show profile/model/thinking/cwd metrics, retry state, and the bounded Activity history for each task. Streaming assistant text is not copied into the parent transcript.
|
|
101
|
+
|
|
102
|
+
Once settled, the collapsed view keeps the same one-row-per-task layout under an aggregate line with the batch outcome, counts, cost, and duration:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
✓ 3 completed · 1 failed · 24s · $0.031
|
|
106
|
+
✓ Explorer · Locate retry scheduling · 12s
|
|
107
|
+
✓ Explorer · Map provider registration · 8.4s
|
|
108
|
+
× General · Apply focused fix · 1m 3s
|
|
109
|
+
✓ Explorer · Find related tests · 21s
|
|
93
110
|
```
|
|
94
111
|
|
|
95
|
-
|
|
112
|
+
The expanded settled view shows, for each task:
|
|
96
113
|
|
|
97
|
-
|
|
114
|
+
- the complete original Prompt from the tool call;
|
|
115
|
+
- model, thinking, cwd, usage, cost, and duration;
|
|
116
|
+
- Error when present;
|
|
117
|
+
- the final Report, or `Report · partial` when a failed/aborted worker produced useful output.
|
|
98
118
|
|
|
99
|
-
-
|
|
100
|
-
- Parent abort, `/reload`, `/new`, `/resume`, `/fork`, and session shutdown abort active child sessions. Queued workers do not survive the call.
|
|
101
|
-
- Parallel worker failures do not cancel other independent workers.
|
|
102
|
-
- Transient provider errors auto-retry: the worker session retries retryable stream errors with backoff (visible as a live `Retrying (n/m) in Xs…` countdown), and a failure that produced no work (for example a preflight auth throw) is rerun at the task level up to two more times. Provider and task retries share one absolute-deadline state; at zero it reads `Retrying now…`, and parent abort/session shutdown interrupts backoff immediately. Runs with partial work behind them are never rerun.
|
|
103
|
-
- Progress is rendered in Pi's native tool transcript. While a call is running, the Subagent renderer re-schedules its own repaint once per second, independently of worker output and the main Working spinner. Silent single and parallel runs therefore keep advancing their own elapsed clocks in collapsed and expanded views, and queued retries keep counting down. Once settled, the final duration is fixed and refresh stops.
|
|
104
|
-
- The collapsed view stays lean in both phases: while running, one bounded intent line (for example `Verifying changes`) carries tool uses, the `ctx:` context watermark, cost, and elapsed time above the current tool marked with `›` and the live output tail; once settled, the sentence-aware result excerpt is followed by a single metrics line (`tok · $ · duration`, plus tool uses and `ctx:` for single runs) and the configured expand hint. Live lines never quote token totals — mid-run totals are cache-inflated. The call-level status dot belongs to the tool shell; run and activity rows only use `›`, `○`, `✓`, `×`, and `■`, and parallel run rows carry stable dim ordinals that match the expanded section numbers. `Ctrl+O` expands each run into a report cover sheet: a status line, a metrics line, a fixed two-line `Prompt` preview (`… continues, N more lines`, honest about the 1KB bound), an `Activity · last n of N` digest whose successful rows are quiet aligned one-liners, a `Working` tail while streaming, and the full `Report` (or `Error`, with `Report · partial` for salvaged output) rendered as Markdown. Expanded batches start with a numbered contents list whose numbers match the `── N · ✓ Agent` section headers.
|
|
105
|
-
- Failed and aborted batch runs place their bounded reason on a separate error-colored line below the run headline instead of cutting it into the status row. Reasons are capped at 200 characters and keep their hanging indent when wrapped; successful settled excerpts prefer complete leading sentences within their 96-character budget. Rounded durations switch to minute form at 60 seconds without producing `1m 60s`.
|
|
106
|
-
- Full child transcripts are not stored separately. Bounded run details remain in the parent tool result, so completed calls restore naturally in the parent session tree.
|
|
107
|
-
- Nested usage is returned with the tool result and included in parent session accounting.
|
|
119
|
+
Activity is intentionally a running-state view; settled transparency comes from the original Prompt and final Report. Full child transcripts are not stored separately. Activity, errors, reports, usage, and model-facing output remain bounded, and completed calls restore through the parent session tree.
|
|
108
120
|
|
|
109
121
|
## Deliberate non-features
|
|
110
122
|
|
|
111
|
-
There are no background agents, persistent worker IDs, unread state, fleet panel, statusline widget, send/stop/resume control plane, completion notifications, swarm/coordinator, worktree isolation, nested agents, MCP, hooks, or agent memory.
|
|
123
|
+
There are no custom profiles, background agents, persistent worker IDs, unread state, fleet panel, statusline widget, send/stop/resume control plane, completion notifications, chain mode, swarm/coordinator, worktree isolation, nested agents, MCP, hooks, or agent memory.
|
package/docs/compaction.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Compaction & Branch Summarization
|
|
2
2
|
|
|
3
|
-
LLMs have limited context windows. When conversations grow too long,
|
|
3
|
+
LLMs have limited context windows. When conversations grow too long, Pi uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
|
|
4
4
|
|
|
5
5
|
## Public API
|
|
6
6
|
|
|
@@ -51,7 +51,7 @@ You can also trigger manually with `/compact [instructions]`, where optional ins
|
|
|
51
51
|
Before compaction:
|
|
52
52
|
|
|
53
53
|
entry: 0 1 2 3 4 5 6 7 8 9
|
|
54
|
-
|
|
54
|
+
┌─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┐
|
|
55
55
|
│ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│
|
|
56
56
|
└─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┘
|
|
57
57
|
└────────┬───────┘ └──────────────┬──────────────┘
|
|
@@ -62,7 +62,7 @@ Before compaction:
|
|
|
62
62
|
After compaction (new entry appended):
|
|
63
63
|
|
|
64
64
|
entry: 0 1 2 3 4 5 6 7 8 9 10
|
|
65
|
-
|
|
65
|
+
┌─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┬─────┐
|
|
66
66
|
│ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│ cmp │
|
|
67
67
|
└─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┴─────┘
|
|
68
68
|
└──────────┬──────┘ └──────────────────────┬───────────────────┘
|
|
@@ -105,7 +105,7 @@ Split turn (one huge turn exceeds budget):
|
|
|
105
105
|
turnPrefixMessages = [usr, ass, tool, ass, tool, tool]
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
For split turns,
|
|
108
|
+
For split turns, Pi generates two summaries and merges them:
|
|
109
109
|
1. **History summary**: Previous context (if any)
|
|
110
110
|
2. **Turn prefix summary**: The early part of the split turn
|
|
111
111
|
|
|
@@ -152,7 +152,7 @@ Pi uses an internal preparation step before `compact()`. For direct programmatic
|
|
|
152
152
|
|
|
153
153
|
### When It Triggers
|
|
154
154
|
|
|
155
|
-
When you use `/tree` to navigate to a different branch,
|
|
155
|
+
When you use `/tree` to navigate to a different branch, Pi offers to summarize the work you're leaving. This injects context from the left branch into the new branch.
|
|
156
156
|
|
|
157
157
|
### How It Works
|
|
158
158
|
|
|
@@ -181,7 +181,7 @@ After navigation with summary:
|
|
|
181
181
|
|
|
182
182
|
### Cumulative File Tracking
|
|
183
183
|
|
|
184
|
-
Both compaction and branch summarization track files cumulatively. When generating a summary,
|
|
184
|
+
Both compaction and branch summarization track files cumulatively. When generating a summary, Pi extracts file operations from:
|
|
185
185
|
- Tool calls in the messages being summarized
|
|
186
186
|
- Previous compaction or branch summary `details` (if any)
|
|
187
187
|
|
package/docs/custom-provider.md
CHANGED
|
@@ -169,7 +169,7 @@ Set `api` on the provider as the default, or on a model when one provider has mo
|
|
|
169
169
|
| `openai-responses` | OpenAI Responses APIs |
|
|
170
170
|
| `azure-openai-responses` | Azure OpenAI Responses APIs |
|
|
171
171
|
| `openai-codex-responses` | OpenAI Codex Responses APIs |
|
|
172
|
-
| `mistral-conversations` | Mistral
|
|
172
|
+
| `mistral-conversations` | Native Mistral Chat Completions streaming |
|
|
173
173
|
| `google-generative-ai` | Google Generative AI APIs |
|
|
174
174
|
| `google-vertex` | Google Vertex AI APIs |
|
|
175
175
|
| `bedrock-converse-stream` | Amazon Bedrock Converse Stream APIs |
|
package/docs/docs.json
CHANGED
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
Pi uses environment variables in three ways:
|
|
4
4
|
|
|
5
5
|
- Variables such as `PI_OFFLINE` configure the Pi process.
|
|
6
|
-
- Pi sets
|
|
6
|
+
- Pi sets process markers so child processes can identify Pi as the launching agent.
|
|
7
7
|
- Commands run by the LLM-callable bash tool receive `PI_*` variables describing the current session.
|
|
8
8
|
|
|
9
9
|
Provider API-key variables are documented separately in [Providers](providers.md#environment-variables-or-auth-file).
|
|
10
10
|
|
|
11
11
|
## Process Marker
|
|
12
12
|
|
|
13
|
-
The CLI and RPC entry points set
|
|
13
|
+
The CLI and RPC entry points set two process markers:
|
|
14
|
+
|
|
15
|
+
- `AI_AGENT=pi` is a generic marker that lets tooling identify Pi as the agent that launched the process.
|
|
16
|
+
- `PI_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Pi.
|
|
17
|
+
|
|
18
|
+
Child processes inherit both markers. They are not session-specific and are not set automatically when Pi is embedded through the SDK.
|
|
14
19
|
|
|
15
20
|
## Bash Tool Session Environment
|
|
16
21
|
|
|
@@ -82,6 +87,7 @@ These variables are read by Pi itself:
|
|
|
82
87
|
| `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
83
88
|
| `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
84
89
|
| `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
90
|
+
| `PI_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase it if Alt-key input is misread as Escape |
|
|
85
91
|
| `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
|
|
86
92
|
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
87
93
|
|
package/docs/extensions.md
CHANGED
|
@@ -999,9 +999,9 @@ ctx.sessionManager.buildContextEntries() // Active branch entries with compac
|
|
|
999
999
|
ctx.sessionManager.getLeafId() // Current leaf entry ID
|
|
1000
1000
|
```
|
|
1001
1001
|
|
|
1002
|
-
### ctx.modelRegistry / ctx.model / ctx.thinkingLevel / ctx.scopedModels
|
|
1002
|
+
### ctx.modelRegistry / ctx.modelRuntime / ctx.model / ctx.thinkingLevel / ctx.scopedModels
|
|
1003
1003
|
|
|
1004
|
-
Access to models, providers, and resolved authentication. `ctx.modelRegistry.getProvider(id)` returns the effective pi-ai provider, while `getProviderAuth(id)` resolves its current API key, headers, base URL, and provider-scoped environment without requiring a loaded model. `ctx.model` is the active model (or `undefined` when none is active), and `ctx.thinkingLevel` is its current effective thinking level when the session runtime provides one.
|
|
1004
|
+
Access to models, providers, and resolved authentication. `ctx.modelRegistry.getProvider(id)` returns the effective pi-ai provider, while `getProviderAuth(id)` resolves its current API key, headers, base URL, and provider-scoped environment without requiring a loaded model. `ctx.modelRuntime` is the canonical `ModelRuntime` owned by the current session; use it when creating nested SDK sessions so they share the same provider registrations, model catalog, and credentials instead of constructing and synchronizing a mirror runtime. `ctx.model` is the active model (or `undefined` when none is active), and `ctx.thinkingLevel` is its current effective thinking level when the session runtime provides one.
|
|
1005
1005
|
|
|
1006
1006
|
`ctx.scopedModels` is the read-only list of models scoped to the current session—the same set shown by `/scoped-models`. Pi resolves it at session start from `--models` and the `enabledModels` setting, matching `provider/modelId` or bare `modelId` patterns with minimatch. An empty list means no scope is configured and every available model is usable. Each entry is `{ model, thinkingLevel? }`; use this list when a custom model picker should mirror the built-in scope rather than enumerate the full registry.
|
|
1007
1007
|
|
|
@@ -1079,6 +1079,19 @@ ctx.compact({
|
|
|
1079
1079
|
});
|
|
1080
1080
|
```
|
|
1081
1081
|
|
|
1082
|
+
### ctx.getShellSettings()
|
|
1083
|
+
|
|
1084
|
+
Returns the session's shell settings (`shellPath`, `commandPrefix`) exactly as the built-in bash tool uses them. Returns `undefined` on hosts that do not provide shell settings; fall back to reading settings from disk if your extension must. Optional on `ExtensionContext` for the same reason.
|
|
1085
|
+
|
|
1086
|
+
```typescript
|
|
1087
|
+
pi.on("session_start", (_event, ctx) => {
|
|
1088
|
+
const shell = ctx.getShellSettings?.();
|
|
1089
|
+
if (shell?.commandPrefix) {
|
|
1090
|
+
// Commands spawned by this extension should honor the same prefix as bash.
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1082
1095
|
### ctx.getSystemPrompt()
|
|
1083
1096
|
|
|
1084
1097
|
Returns Pi's current system prompt string.
|
|
@@ -1448,12 +1461,16 @@ pi.sendUserMessage([
|
|
|
1448
1461
|
// During streaming - must specify delivery mode
|
|
1449
1462
|
pi.sendUserMessage("Focus on error handling", { deliverAs: "steer" });
|
|
1450
1463
|
pi.sendUserMessage("And then summarize", { deliverAs: "followUp" });
|
|
1464
|
+
|
|
1465
|
+
// Opt in to extension command dispatch and skill/prompt template expansion
|
|
1466
|
+
pi.sendUserMessage("/review src/index.ts", { expandPromptTemplates: true });
|
|
1451
1467
|
```
|
|
1452
1468
|
|
|
1453
1469
|
**Options:**
|
|
1454
1470
|
- `deliverAs` - Required when agent is streaming:
|
|
1455
1471
|
- `"steer"` - Queues the message for delivery after the current assistant turn finishes executing its tool calls
|
|
1456
1472
|
- `"followUp"` - Waits for agent to finish all tools
|
|
1473
|
+
- `expandPromptTemplates` - Dispatch extension commands and expand skill commands and prompt templates. Defaults to `false`.
|
|
1457
1474
|
|
|
1458
1475
|
When not streaming, the message is sent immediately and triggers a new turn. When streaming without `deliverAs`, throws an error.
|
|
1459
1476
|
|
package/docs/json.md
CHANGED
|
@@ -17,6 +17,7 @@ type JsonAgentSessionEvent =
|
|
|
17
17
|
| Exclude<AgentSessionEvent, { type: "message_update" }>
|
|
18
18
|
| {
|
|
19
19
|
type: "message_update";
|
|
20
|
+
usage: Usage;
|
|
20
21
|
assistantMessageEvent: WithoutPartial<AssistantMessageEvent>;
|
|
21
22
|
};
|
|
22
23
|
```
|
|
@@ -93,16 +94,17 @@ Followed by events as they occur:
|
|
|
93
94
|
{"type":"agent_start"}
|
|
94
95
|
{"type":"turn_start"}
|
|
95
96
|
{"type":"message_start","message":{"role":"assistant","content":[],...}}
|
|
96
|
-
{"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
|
|
97
|
+
{"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
|
|
97
98
|
{"type":"message_end","message":{...}}
|
|
98
99
|
{"type":"turn_end","message":{...},"toolResults":[]}
|
|
99
100
|
{"type":"agent_end","messages":[...],"willRetry":false}
|
|
100
101
|
```
|
|
101
102
|
|
|
102
103
|
`message_update` records are delta-only. They omit both the cumulative `message` field and
|
|
103
|
-
`assistantMessageEvent.partial` to keep stream size linear.
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
`assistantMessageEvent.partial` to keep stream size linear. The top-level `usage` field contains
|
|
105
|
+
the latest cumulative provider-reported usage and may remain zero when a provider only reports
|
|
106
|
+
usage at completion. Use `contentIndex` and `delta` to assemble live text, thinking, or tool-call
|
|
107
|
+
arguments if needed. `message_end` contains the final authoritative message.
|
|
106
108
|
|
|
107
109
|
## Example
|
|
108
110
|
|
package/docs/keybindings.md
CHANGED
|
@@ -86,7 +86,7 @@ The dedicated history actions always change history entries, regardless of the c
|
|
|
86
86
|
|
|
87
87
|
### TUI Fullscreen Viewport
|
|
88
88
|
|
|
89
|
-
These actions apply when interactive mode uses `--tui-mode fullscreen` and target the primary transcript scroll region. Two-finger trackpad and mouse-wheel input scroll the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard; holding at the transcript's top or bottom edge auto-scrolls into off-screen content.
|
|
89
|
+
These actions apply when interactive mode uses `--tui-mode fullscreen` and target the primary transcript scroll region. Two-finger trackpad and mouse-wheel input scroll the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard; holding at the transcript's top or bottom edge auto-scrolls into off-screen content. See [Terminal setup](terminal-setup.md) for terminal-specific mouse and trackpad behavior.
|
|
90
90
|
|
|
91
91
|
Fullscreen transcript bindings take precedence over editor bindings. The default unmodified navigation keys therefore control the transcript in fullscreen mode, while their `ctrl` variants continue to control the editor. Outside fullscreen mode, both variants control the editor.
|
|
92
92
|
|
|
@@ -97,7 +97,7 @@ Fullscreen transcript bindings take precedence over editor bindings. The default
|
|
|
97
97
|
| `pageUp`, `pageDown` | Editor | Transcript |
|
|
98
98
|
| `ctrl+pageUp`, `ctrl+pageDown` | Editor | Editor |
|
|
99
99
|
|
|
100
|
-
This routing remains configurable through the ordinary action bindings. For example, `"tui.altScreen.pageUp": "ctrl+pageUp"` makes `pageUp` control the editor and `ctrl+pageUp` control the transcript in fullscreen mode. Bind `tui.altScreen.halfPageUp` and `tui.altScreen.halfPageDown` for
|
|
100
|
+
This routing remains configurable through the ordinary action bindings. For example, `"tui.altScreen.pageUp": "ctrl+pageUp"` makes `pageUp` control the editor and `ctrl+pageUp` control the transcript in fullscreen mode. Bind `tui.altScreen.halfPageUp` and `tui.altScreen.halfPageDown` for half-page steps, or bind `tui.altScreen.lineUp` and `tui.altScreen.lineDown` for single-line steps. Setting `"tui.altScreen.pageUp": []` disables that transcript shortcut entirely. User bindings replace the defaults for that action.
|
|
101
101
|
|
|
102
102
|
| Keybinding id | Default | Description |
|
|
103
103
|
|--------|---------|-------------|
|
|
@@ -105,8 +105,14 @@ This routing remains configurable through the ordinary action bindings. For exam
|
|
|
105
105
|
| `tui.altScreen.pageDown` | `pageDown` | Scroll the transcript down by one page |
|
|
106
106
|
| `tui.altScreen.halfPageUp` | *(none)* | Scroll the transcript up by half a page |
|
|
107
107
|
| `tui.altScreen.halfPageDown` | *(none)* | Scroll the transcript down by half a page |
|
|
108
|
+
| `tui.altScreen.lineUp` | *(none)* | Scroll the transcript up by one line |
|
|
109
|
+
| `tui.altScreen.lineDown` | *(none)* | Scroll the transcript down by one line |
|
|
108
110
|
| `tui.altScreen.previousPrompt` | `ctrl+shift+up` | Jump to the previous marked message |
|
|
109
111
|
| `tui.altScreen.nextPrompt` | `ctrl+shift+down` | Jump to the next marked message |
|
|
112
|
+
| `tui.altScreen.search` | `ctrl+shift+f` | Search the rendered transcript |
|
|
113
|
+
| `tui.altScreen.searchNext` | `enter`, `ctrl+g` | Select the next search match while searching |
|
|
114
|
+
| `tui.altScreen.searchPrevious` | `shift+enter`, `ctrl+shift+g` | Select the previous search match while searching |
|
|
115
|
+
| `tui.altScreen.searchClose` | `escape` | Close transcript search |
|
|
110
116
|
| `tui.altScreen.top` | `home` | Scroll to the beginning of the transcript |
|
|
111
117
|
| `tui.altScreen.bottom` | `end` | Scroll to the transcript end and follow new output |
|
|
112
118
|
|
|
@@ -120,6 +126,7 @@ This routing remains configurable through the ordinary action bindings. For exam
|
|
|
120
126
|
| `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
|
|
121
127
|
| `app.editor.external` | `ctrl+g` | Open in external editor (`externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere) |
|
|
122
128
|
| `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows) | Paste image or text from clipboard |
|
|
129
|
+
| `app.backgroundTasks.kill` | `k` | Stop the selected task in the Background task menu |
|
|
123
130
|
|
|
124
131
|
### Sessions
|
|
125
132
|
|
package/docs/rpc.md
CHANGED
|
@@ -954,6 +954,14 @@ Emitted during streaming of assistant messages. Contains a delta event without a
|
|
|
954
954
|
```json
|
|
955
955
|
{
|
|
956
956
|
"type": "message_update",
|
|
957
|
+
"usage": {
|
|
958
|
+
"input": 100,
|
|
959
|
+
"output": 1,
|
|
960
|
+
"cacheRead": 0,
|
|
961
|
+
"cacheWrite": 0,
|
|
962
|
+
"totalTokens": 101,
|
|
963
|
+
"cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0, "total": 0}
|
|
964
|
+
},
|
|
957
965
|
"assistantMessageEvent": {
|
|
958
966
|
"type": "text_delta",
|
|
959
967
|
"contentIndex": 0,
|
|
@@ -978,12 +986,15 @@ The `assistantMessageEvent` field contains one of these delta types:
|
|
|
978
986
|
|
|
979
987
|
Example streaming a text response:
|
|
980
988
|
```json
|
|
981
|
-
{"type":"message_update","assistantMessageEvent":{"type":"text_start","contentIndex":0}}
|
|
982
|
-
{"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
|
|
983
|
-
{"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world"}}
|
|
984
|
-
{"type":"message_update","assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world"}}
|
|
989
|
+
{"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_start","contentIndex":0}}
|
|
990
|
+
{"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
|
|
991
|
+
{"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world"}}
|
|
992
|
+
{"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world"}}
|
|
985
993
|
```
|
|
986
994
|
|
|
995
|
+
The top-level `usage` field contains the latest cumulative provider-reported usage. It may remain
|
|
996
|
+
zero until completion when a provider does not report usage during streaming.
|
|
997
|
+
|
|
987
998
|
`message_update` intentionally omits the former cumulative `message` field and
|
|
988
999
|
`assistantMessageEvent.partial`. Clients that need a live partial message must assemble it
|
|
989
1000
|
from `message_start` and subsequent events using `contentIndex`. Treat `message_end.message`
|
package/docs/sdk.md
CHANGED
|
@@ -408,6 +408,13 @@ import { createAgentSession, ModelRuntime } from "@astralyn/pi";
|
|
|
408
408
|
|
|
409
409
|
const modelRuntime = await ModelRuntime.create();
|
|
410
410
|
|
|
411
|
+
// create() restores cached catalogs but does not refresh them from pi.dev by default.
|
|
412
|
+
// Opt in to a create-time network refresh and bound how long it may take:
|
|
413
|
+
const refreshedRuntime = await ModelRuntime.create({
|
|
414
|
+
allowModelNetwork: true,
|
|
415
|
+
modelRefreshTimeoutMs: 15_000,
|
|
416
|
+
});
|
|
417
|
+
|
|
411
418
|
// Find specific built-in models (doesn't check whether API keys exist)
|
|
412
419
|
const opus = getModel("anthropic", "claude-opus-4-5");
|
|
413
420
|
const sonnet = getModel("anthropic", "claude-sonnet-4-5");
|
|
@@ -439,6 +446,8 @@ If no model is provided:
|
|
|
439
446
|
2. Uses default from settings
|
|
440
447
|
3. Prefers a known provider default among available models, then falls back to the first available model
|
|
441
448
|
|
|
449
|
+
Remote catalogs are persisted locally so later runtimes can restore them without a network request. The default file is `~/.pi/agent/models-store.json`; set `modelsStorePath` to choose another location, or inject `modelsStore` to control persistence. Network refreshes are throttled to once per provider every four hours unless forced. To force an immediate refresh, call `await modelRuntime.refresh({ allowNetwork: true, force: true, signal })`. Setting `PI_OFFLINE` disables model network access.
|
|
450
|
+
|
|
442
451
|
To match CLI model parsing, use the exported resolver helpers:
|
|
443
452
|
|
|
444
453
|
```typescript
|