@astralyn/pi 1.4.1 → 1.4.3
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 +14 -0
- package/dist/bundle/chunks/{chunk-N77PYEXG.js → chunk-ISXCH6TG.js} +1 -1
- package/dist/bundle/chunks/{chunk-KSKBY3VV.js → chunk-Z2YN4E74.js} +117 -111
- package/dist/bundle/chunks/{virtual-modules-XNEYDLXF.js → virtual-modules-QX6D3D7X.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +15 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/distribution-api.d.ts +1 -1
- package/dist/core/extensions/distribution-api.d.ts.map +1 -1
- package/dist/core/extensions/distribution-api.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- 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.map +1 -1
- package/dist/core/extensions/runner.js +3 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +29 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybinding-registry.d.ts +16 -1
- package/dist/core/keybinding-registry.d.ts.map +1 -1
- package/dist/core/keybinding-registry.js +20 -0
- package/dist/core/keybinding-registry.js.map +1 -1
- package/dist/core/keybindings-schema.d.ts.map +1 -1
- package/dist/core/keybindings-schema.js +2 -1
- package/dist/core/keybindings-schema.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -106
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -13
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/format.d.ts.map +1 -1
- package/dist/core/tasks/format.js +10 -4
- package/dist/core/tasks/format.js.map +1 -1
- package/dist/core/tasks/limits.d.ts +5 -0
- package/dist/core/tasks/limits.d.ts.map +1 -0
- package/dist/core/tasks/limits.js +5 -0
- package/dist/core/tasks/limits.js.map +1 -0
- package/dist/core/tasks/runtime.d.ts +1 -0
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +7 -3
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +1 -1
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +10 -2
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/types.d.ts +13 -0
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tools/bash.d.ts +98 -9
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +308 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +5 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +3 -11
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +2 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +2 -1
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js +7 -5
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/shell-execution.d.ts +2 -2
- package/dist/core/tools/shell-execution.d.ts.map +1 -1
- package/dist/core/tools/shell-execution.js +0 -21
- package/dist/core/tools/shell-execution.js.map +1 -1
- package/dist/core/tools/shell-operations.d.ts +12 -0
- package/dist/core/tools/shell-operations.d.ts.map +1 -0
- package/dist/core/tools/shell-operations.js +38 -0
- package/dist/core/tools/shell-operations.js.map +1 -0
- package/dist/core/tools/shell-tool.d.ts +8 -64
- package/dist/core/tools/shell-tool.d.ts.map +1 -1
- package/dist/core/tools/shell-tool.js +27 -125
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/keybindings.d.ts +6 -0
- package/dist/extensions/keybindings.d.ts.map +1 -0
- package/dist/extensions/keybindings.js +6 -0
- package/dist/extensions/keybindings.js.map +1 -0
- package/dist/extensions/tasks/index.d.ts +5 -0
- package/dist/extensions/tasks/index.d.ts.map +1 -0
- package/dist/extensions/tasks/index.js +42 -0
- package/dist/extensions/tasks/index.js.map +1 -0
- package/dist/extensions/tasks/keybindings.d.ts +19 -0
- package/dist/extensions/tasks/keybindings.d.ts.map +1 -0
- package/dist/extensions/tasks/keybindings.js +30 -0
- package/dist/extensions/tasks/keybindings.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/actions.d.ts +2 -2
- package/dist/extensions/tasks/tool/actions.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/actions.js +4 -4
- package/dist/extensions/tasks/tool/actions.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/constants.d.ts +1 -3
- package/dist/extensions/tasks/tool/constants.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/constants.js +1 -3
- package/dist/extensions/tasks/tool/constants.js.map +1 -0
- package/dist/extensions/tasks/tool/schema.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/schema.js +5 -4
- package/dist/extensions/tasks/tool/schema.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/types.d.ts +1 -1
- package/dist/extensions/tasks/tool/types.d.ts.map +1 -0
- package/dist/extensions/tasks/tool/types.js.map +1 -0
- package/dist/extensions/tasks/tool.d.ts +6 -0
- package/dist/extensions/tasks/tool.d.ts.map +1 -0
- package/dist/{core/tools/tasks.js → extensions/tasks/tool.js} +6 -10
- package/dist/extensions/tasks/tool.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/completion-render.d.ts +1 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/completion-render.js +2 -2
- package/dist/extensions/tasks/ui/completion-render.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/index.d.ts +1 -1
- package/dist/extensions/tasks/ui/index.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/index.js +4 -4
- package/dist/extensions/tasks/ui/index.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/inspector.d.ts +1 -1
- package/dist/extensions/tasks/ui/inspector.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/inspector.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/layout.d.ts +1 -1
- package/dist/extensions/tasks/ui/layout.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/layout.js +1 -1
- package/dist/extensions/tasks/ui/layout.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/list.d.ts +1 -1
- package/dist/extensions/tasks/ui/list.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/list.js +1 -1
- package/dist/extensions/tasks/ui/list.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/manager.d.ts +2 -1
- package/dist/extensions/tasks/ui/manager.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/manager.js +2 -1
- package/dist/extensions/tasks/ui/manager.js.map +1 -0
- package/dist/extensions/tasks/ui/model.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/model.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/render.d.ts +3 -3
- package/dist/extensions/tasks/ui/render.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/render.js +2 -2
- package/dist/extensions/tasks/ui/render.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/task-view.d.ts +1 -1
- package/dist/extensions/tasks/ui/task-view.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/task-view.js +1 -1
- package/dist/extensions/tasks/ui/task-view.js.map +1 -0
- package/dist/extensions/tasks/ui/text.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/text.js.map +1 -0
- package/dist/extensions/tasks/ui/tree.d.ts +7 -0
- package/dist/extensions/tasks/ui/tree.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks/host-hooks.js → extensions/tasks/ui/tree.js} +1 -18
- package/dist/extensions/tasks/ui/tree.js.map +1 -0
- package/dist/extensions/tasks/ui/viewport.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/viewport.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/views.d.ts +1 -1
- package/dist/extensions/tasks/ui/views.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/views.js +1 -1
- package/dist/extensions/tasks/ui/views.js.map +1 -0
- package/dist/extensions/tool-presentation/index.d.ts +7 -0
- package/dist/extensions/tool-presentation/index.d.ts.map +1 -0
- package/dist/extensions/tool-presentation/index.js +9 -0
- package/dist/extensions/tool-presentation/index.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +65 -18
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -3
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +85 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +362 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +5 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +14 -29
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/chat.js +2 -3
- package/dist/modes/interactive/tool-view/chat.js.map +1 -1
- package/dist/modes/interactive/tool-view/shell.d.ts +15 -0
- package/dist/modes/interactive/tool-view/shell.d.ts.map +1 -0
- package/dist/modes/interactive/tool-view/shell.js +51 -0
- package/dist/modes/interactive/tool-view/shell.js.map +1 -0
- package/dist/modes/interactive/tool-view/tool-execution.d.ts +10 -79
- package/dist/modes/interactive/tool-view/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/tool-execution.js +7 -298
- package/dist/modes/interactive/tool-view/tool-execution.js.map +1 -1
- package/docs/bundled/README.md +1 -4
- package/docs/bundled/tasks.md +3 -3
- package/docs/bundled/tool-presentation.md +9 -7
- package/docs/extensions.md +9 -4
- package/docs/settings.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/keybindings.schema.json +84 -52
- package/dist/core/tools/tasks/actions.d.ts.map +0 -1
- package/dist/core/tools/tasks/actions.js.map +0 -1
- package/dist/core/tools/tasks/constants.d.ts.map +0 -1
- package/dist/core/tools/tasks/constants.js.map +0 -1
- package/dist/core/tools/tasks/schema.d.ts.map +0 -1
- package/dist/core/tools/tasks/schema.js.map +0 -1
- package/dist/core/tools/tasks/types.d.ts.map +0 -1
- package/dist/core/tools/tasks/types.js.map +0 -1
- package/dist/core/tools/tasks.d.ts +0 -14
- package/dist/core/tools/tasks.d.ts.map +0 -1
- package/dist/core/tools/tasks.js.map +0 -1
- package/dist/modes/interactive/tasks/completion-render.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/completion-render.js.map +0 -1
- package/dist/modes/interactive/tasks/host-hooks.d.ts +0 -14
- package/dist/modes/interactive/tasks/host-hooks.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/host-hooks.js.map +0 -1
- package/dist/modes/interactive/tasks/index.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/index.js.map +0 -1
- package/dist/modes/interactive/tasks/inspector.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/inspector.js.map +0 -1
- package/dist/modes/interactive/tasks/layout.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/layout.js.map +0 -1
- package/dist/modes/interactive/tasks/list.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/list.js.map +0 -1
- package/dist/modes/interactive/tasks/manager.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/manager.js.map +0 -1
- package/dist/modes/interactive/tasks/model.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/model.js.map +0 -1
- package/dist/modes/interactive/tasks/render.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/render.js.map +0 -1
- package/dist/modes/interactive/tasks/task-view.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/task-view.js.map +0 -1
- package/dist/modes/interactive/tasks/text.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/text.js.map +0 -1
- package/dist/modes/interactive/tasks/viewport.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/viewport.js.map +0 -1
- package/dist/modes/interactive/tasks/views.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/views.js.map +0 -1
- /package/dist/{core/tools/tasks → extensions/tasks/tool}/schema.d.ts +0 -0
- /package/dist/{core/tools/tasks → extensions/tasks/tool}/types.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/inspector.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/model.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/model.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/text.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/text.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/viewport.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/viewport.js +0 -0
package/docs/bundled/tasks.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tasks
|
|
2
2
|
|
|
3
|
-
Tasks
|
|
3
|
+
Tasks pairs a session-owned execution capability with the bundled `tasks` extension. The core owns execution, retained results, journaling, usage accounting, and exactly-once completion delivery. The extension owns the `tasks` tool, `/tasks` panel, status and detach controls, completion cards, and tree-navigation confirmation for native Bash, PowerShell, and extension-owned work. Disabling `builtin:tasks` removes that management surface; it does not turn the core session lifecycle into an extension concern.
|
|
4
4
|
|
|
5
5
|
## Start or detach work
|
|
6
6
|
|
|
@@ -49,7 +49,7 @@ Wait for any task already running at call time by omitting the ID:
|
|
|
49
49
|
{ "action": "wait", "waitMs": 20000 }
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
`waitMs` defaults to 20 seconds and clamps between 1 and
|
|
52
|
+
`waitMs` defaults to 20 seconds and clamps between 1 second and 10 minutes. A task that reaches a terminal state produces a `settled` outcome; expiry produces `timed_out` and leaves execution running. New steering input produces `interrupted` and ends only the wait, so the new input can proceed without cancelling the task; follow-up input does not interrupt it. A background completion steered into the run can interrupt a wait on another task the same way.
|
|
53
53
|
|
|
54
54
|
Wait output is limited to 32KB. With `taskId`, it can start after `sinceBytes`; when more than 32KB was written after that offset, the wait returns the newest 32KB and reports how many bytes it skipped. `sinceBytes` is rejected without `taskId` because offsets belong to one task. Interrupted waits do not read output. A settled waitAny reads the winning task and lists initial cohort members still running. Continue independent work instead of sleep-polling or repeatedly reading; wait when the next step genuinely depends on a result.
|
|
55
55
|
|
|
@@ -63,7 +63,7 @@ All model-facing management responses, including listings and error messages, ar
|
|
|
63
63
|
|
|
64
64
|
## `/tasks` panel
|
|
65
65
|
|
|
66
|
-
The fullscreen panel has one scrollable list. **Active** groups queued, running and stopping work; **Finished** groups all retained results on the selected branch, including foreground shell results, newest first. Empty groups are hidden. Task summaries show status and elapsed time; foreground/background mode is available in Details. The background action is offered only when the selected task can move.
|
|
66
|
+
The fullscreen panel has one scrollable list. **Active** groups queued, running and stopping work; **Finished** groups all retained results on the selected branch, including foreground shell results, newest first. Empty groups are hidden. Task summaries show status and elapsed time; foreground/background mode is available in Details. Durations omit zero components and separate remaining units (`8s`, `1m`, `1m 5s`, `1h 5m`). The background action is offered only when the selected task can move.
|
|
67
67
|
|
|
68
68
|
Selection follows the task when it finishes; new work does not steal focus or replace browsed output. The list preserves the selected row's screen position where space permits. Reopening remembers the selected ID and right-hand tab while the runtime remains available. Runtime replacement resets these preferences, and branch navigation removes results outside the visible branch. History remains bounded by the retention limits below.
|
|
69
69
|
|
|
@@ -39,23 +39,25 @@ The `Ctrl+B` background hint is not part of a tool row. Once a foreground manage
|
|
|
39
39
|
|
|
40
40
|
The look is defined in one place, `src/modes/interactive/tool-view/style.ts`: the marker and rail glyphs, their colors, the spacing between blocks, and which tools fold their result. `FramedComponent` in the same file hangs a component's lines off the marker or the rail and derives the gutter width from the glyphs.
|
|
41
41
|
|
|
42
|
-
`
|
|
42
|
+
The upstream `components/tool-execution.ts` owns one call's lifecycle: pending, success and error states, expansion, image placement and Kitty conversion, and renderer disposal. The bundled `tool-presentation` extension attaches a TUI-only shell through the existing tool renderer resolver; `tool-view/shell.ts` maps the visual policy to that shell. The old `tool-view/tool-execution.ts` path is only a compatibility adapter for direct source imports, not a second lifecycle implementation.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
`tool-view/chat.ts` owns the chat container that measures tool blocks for spacing and disposes rows when the chat clears. It reads each row's gap policy: upstream rows keep one blank line, while the distribution shell uses the compact policy above. Extension tools and built-in tools use the same shell unless they explicitly own a self shell.
|
|
45
|
+
|
|
46
|
+
Built-in renderers remain responsible for semantic content such as file paths, syntax highlighting, search results, Diff previews, and command output. They return plain components; the native component passes them to the shell without wrapping their renderer functions. HTML export uses only those renderers and ignores the TUI shell, so it retains its existing output. Disable `builtin:tool-presentation` (for example with `-builtin:tool-presentation` in extension settings) to use the upstream Box presentation instead.
|
|
45
47
|
|
|
46
48
|
## Renderer inheritance
|
|
47
49
|
|
|
48
50
|
| Tool definition | Behavior |
|
|
49
51
|
|---|---|
|
|
50
|
-
| No `renderCall`/`renderResult` | Uses the
|
|
51
|
-
| Custom renderer with the default shell | Uses the
|
|
52
|
-
| `renderShell: "self"` | Keeps complete ownership of the tool's layout. |
|
|
52
|
+
| No `renderCall`/`renderResult` | Uses the active shell's call and result fallback. |
|
|
53
|
+
| Custom renderer with the default shell | Uses the distribution shell around the custom content, or upstream Box when the extension is disabled. |
|
|
54
|
+
| `renderShell: "self"` | Keeps complete ownership of the tool's layout; no distribution shell is attached. |
|
|
53
55
|
|
|
54
56
|
Built-in tool definitions are also used when an extension overrides only one renderer slot. A custom call renderer can inherit the built-in result renderer, and vice versa. An extension that overrides a built-in tool with its own result renderer controls what that row shows, including when it is collapsed.
|
|
55
57
|
|
|
56
58
|
The inherited Bash result renderer keeps its elapsed time even with a custom call renderer. Call and result renderers share `state`; a renderer that adds a `dispose()` callback must also call the previous callback so both renderers can release their resources.
|
|
57
59
|
|
|
58
|
-
Renderer failures fall back to
|
|
60
|
+
Renderer failures fall back to the active shell's generic output rather than breaking the transcript; without a distribution shell, the upstream generic fallback is used.
|
|
59
61
|
|
|
60
62
|
## Generic fallback
|
|
61
63
|
|
|
@@ -89,7 +91,7 @@ The package does not use:
|
|
|
89
91
|
|
|
90
92
|
- prototype patching of `ToolExecutionComponent` from an extension;
|
|
91
93
|
- same-name re-registration to replace built-in tools;
|
|
92
|
-
- a global renderer registry exposed through Extension API;
|
|
94
|
+
- a second global renderer registry exposed through Extension API;
|
|
93
95
|
- a restored `tools-view` extension;
|
|
94
96
|
- forced decoration of third-party tools that explicitly own their shell;
|
|
95
97
|
- merging consecutive calls into a collapsed group, or a shell-level progress row.
|
package/docs/extensions.md
CHANGED
|
@@ -1282,7 +1282,9 @@ if (outcome.kind === "result") return outcome.result;
|
|
|
1282
1282
|
return { content: [{ type: "text", text: `Task ${outcome.task.id} continues in the background.` }], details: undefined };
|
|
1283
1283
|
```
|
|
1284
1284
|
|
|
1285
|
-
|
|
1285
|
+
When Pi attaches the runtime to its durable session lifecycle, `ctx.tasks.session` exposes the small host integration used by management products: `waitInterruptSignal`, `prepareWait(toolCallId, taskId)`, and `stoppedByTreeNavigation(targetId)`. Standalone runtimes omit it, leaving waits observational. This bridge lets the bundled `tasks` extension coordinate persisted wait receipts and branch confirmations without importing `TaskSession` or interactive internals.
|
|
1286
|
+
|
|
1287
|
+
`TaskRuntime`, `TaskRuntimeOptions`, and the public `Task*`/`TasksContext`/`TasksSessionContext` types are exported from `@astralyn/pi`. Captured capabilities close with their runtime; obtain the replacement from the new session context after reload or session replacement.
|
|
1286
1288
|
|
|
1287
1289
|
### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
|
|
1288
1290
|
|
|
@@ -2531,7 +2533,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2531
2533
|
|
|
2532
2534
|
Tools can provide `renderCall` and `renderResult` for custom TUI display. See [tui.md](tui.md) for the full component API.
|
|
2533
2535
|
|
|
2534
|
-
By default, tool output is wrapped in
|
|
2536
|
+
By default, tool output is wrapped in the active call/result shell, which owns the status dot, result rail, spacing between consecutive tool rows, and fallback rendering. The bundled `tool-presentation` extension supplies the distribution's compact shell; disabling `builtin:tool-presentation` restores the upstream Box shell. A defined `renderCall` or `renderResult` must return a `Component`. If a slot renderer is not defined, the shell uses fallback rendering for that slot. Return content without leading padding: the compact shell trims leading blank result lines and adds no blank line between consecutive single-line tool rows.
|
|
2535
2537
|
|
|
2536
2538
|
Set `renderShell: "self"` when the tool should render its own shell instead of using the native shell. This is useful for tools that need complete control over framing or background behavior, for example large previews that must stay visually stable after the tool settles.
|
|
2537
2539
|
|
|
@@ -2971,9 +2973,10 @@ ctx.ui.setFooter(undefined); // Restore built-in footer
|
|
|
2971
2973
|
ctx.ui.setHeader((_tui, theme) => new Text(theme.fg("accent", "Project ready"), 0, 0));
|
|
2972
2974
|
ctx.ui.setHeader(undefined); // Restore built-in header
|
|
2973
2975
|
|
|
2974
|
-
// Label
|
|
2976
|
+
// Label for collapsed thinking blocks while they are actively streaming.
|
|
2977
|
+
// Settled blocks use the built-in "Thoughts" label.
|
|
2975
2978
|
ctx.ui.setHiddenThinkingLabel("Reasoning");
|
|
2976
|
-
ctx.ui.setHiddenThinkingLabel(); // Restore default label
|
|
2979
|
+
ctx.ui.setHiddenThinkingLabel(); // Restore default active label
|
|
2977
2980
|
|
|
2978
2981
|
// Terminal title
|
|
2979
2982
|
ctx.ui.setTitle("pi - my-project");
|
|
@@ -3345,6 +3348,8 @@ A tool that reaches other tools declares which ones a call may reach with `reach
|
|
|
3345
3348
|
|
|
3346
3349
|
`pi.registerToolRenderer((toolName, next) => renderers)` chooses `renderCall`, `renderResult`, and `renderShell` for calls to any tool, including tools that are not registered yet, such as MCP tools in a resumed session. Resolvers run in extension load order. `next()` returns the remaining resolvers' result or the registered tool's renderers, so `next() ?? mine` supplies a fallback. Interactive transcripts and HTML exports both use these resolvers.
|
|
3347
3350
|
|
|
3351
|
+
A resolver can also attach an optional `shell` (`ToolExecutionShell`) for TUI-only framing, fallbacks, and row spacing. The native tool component consumes it after the renderers return their components, so `lastComponent` reuse and renderer ownership are preserved. HTML export ignores `shell`; it never changes tool execution or the model-facing tool declaration. An explicit `renderShell: "self"` always remains tool-owned and is not wrapped by a distribution shell.
|
|
3352
|
+
|
|
3348
3353
|
### MCP servers
|
|
3349
3354
|
|
|
3350
3355
|
`pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `description`, `enabled`, and `timeout`.
|
package/docs/settings.md
CHANGED
|
@@ -31,7 +31,7 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
|
|
|
31
31
|
| `defaultModel` | string | - | Default model ID |
|
|
32
32
|
| `defaultThinkingLevel` | string | - | Global fallback: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, or `"max"` |
|
|
33
33
|
| `modelThinkingLevels` | object | - | Per-model default thinking levels keyed by `provider/modelId`; set through `/thinking` Ctrl+S or `/settings` |
|
|
34
|
-
| `hideThinkingBlock` | boolean | `false` |
|
|
34
|
+
| `hideThinkingBlock` | boolean | `false` | Show up to three live preview lines for collapsed thinking while streaming, then settle to `Thoughts`; click to expand |
|
|
35
35
|
| `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses, successful cache-warming usage, compaction or branch-summary usage, and provider recovery diagnostics such as dropped Anthropic thinking blocks |
|
|
36
36
|
| `thinkingBudgets` | object | - | Custom token budgets per thinking level. Anthropic, Google, and Bedrock use these natively. OpenAI-compatible models use them when `compat.thinkingTokenBudgetField` (or `supportsThinkingTokenBudget`) is set. |
|
|
37
37
|
| `cacheWarming` | string | `"streaming"` | Prompt cache-warming mode: `"off"`, `"streaming"`, or `"idle"`. Global setting only. |
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralyn/pi",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@astralyn/pi",
|
|
9
|
-
"version": "1.4.
|
|
9
|
+
"version": "1.4.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@earendil-works/pi-agent-core": "1.4.0",
|
package/package.json
CHANGED
|
@@ -195,58 +195,6 @@
|
|
|
195
195
|
"$ref": "#/$defs/KeybindingValue",
|
|
196
196
|
"description": "Scroll viewport to bottom"
|
|
197
197
|
},
|
|
198
|
-
"app.tasks.detach": {
|
|
199
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
200
|
-
"description": "Move foreground tasks to the background"
|
|
201
|
-
},
|
|
202
|
-
"app.tasks.previousTab": {
|
|
203
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
204
|
-
"description": "Show Output in the focused task inspector"
|
|
205
|
-
},
|
|
206
|
-
"app.tasks.nextTab": {
|
|
207
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
208
|
-
"description": "Show Details in the focused task inspector"
|
|
209
|
-
},
|
|
210
|
-
"app.tasks.kill": {
|
|
211
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
212
|
-
"description": "Stop the selected task"
|
|
213
|
-
},
|
|
214
|
-
"app.tasks.confirmStop": {
|
|
215
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
216
|
-
"description": "Confirm stopping the selected task"
|
|
217
|
-
},
|
|
218
|
-
"app.tasks.detachSelected": {
|
|
219
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
220
|
-
"description": "Move the selected task to the background"
|
|
221
|
-
},
|
|
222
|
-
"app.tasks.search": {
|
|
223
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
224
|
-
"description": "Search retained task identities and labels"
|
|
225
|
-
},
|
|
226
|
-
"app.tasks.follow": {
|
|
227
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
228
|
-
"description": "Follow the selected task's output"
|
|
229
|
-
},
|
|
230
|
-
"app.tasks.top": {
|
|
231
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
232
|
-
"description": "Go to the top of the task list or preview"
|
|
233
|
-
},
|
|
234
|
-
"app.tasks.bottom": {
|
|
235
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
236
|
-
"description": "Go to the bottom of the task list or preview"
|
|
237
|
-
},
|
|
238
|
-
"app.tasks.nextFocus": {
|
|
239
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
240
|
-
"description": "Switch between task list and inspector"
|
|
241
|
-
},
|
|
242
|
-
"app.tasks.previousFocus": {
|
|
243
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
244
|
-
"description": "Switch between task inspector and list"
|
|
245
|
-
},
|
|
246
|
-
"app.tasks.help": {
|
|
247
|
-
"$ref": "#/$defs/KeybindingValue",
|
|
248
|
-
"description": "Show task controls"
|
|
249
|
-
},
|
|
250
198
|
"app.interrupt": {
|
|
251
199
|
"$ref": "#/$defs/KeybindingValue",
|
|
252
200
|
"description": "Cancel or abort"
|
|
@@ -426,6 +374,90 @@
|
|
|
426
374
|
"app.tree.filter.cycleBackward": {
|
|
427
375
|
"$ref": "#/$defs/KeybindingValue",
|
|
428
376
|
"description": "Tree filter: cycle backward"
|
|
377
|
+
},
|
|
378
|
+
"app.btw.close": {
|
|
379
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
380
|
+
"description": "Close the BTW conversation"
|
|
381
|
+
},
|
|
382
|
+
"app.btw.cancel": {
|
|
383
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
384
|
+
"description": "Stop the BTW answer, or close when idle"
|
|
385
|
+
},
|
|
386
|
+
"app.btw.scrollUp": {
|
|
387
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
388
|
+
"description": "Scroll BTW up when the editor is empty"
|
|
389
|
+
},
|
|
390
|
+
"app.btw.scrollDown": {
|
|
391
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
392
|
+
"description": "Scroll BTW down when the editor is empty"
|
|
393
|
+
},
|
|
394
|
+
"app.list.toggle": {
|
|
395
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
396
|
+
"description": "Toggle selected list item"
|
|
397
|
+
},
|
|
398
|
+
"app.provider.switchPaneLeft": {
|
|
399
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
400
|
+
"description": "/provider: focus the left pane"
|
|
401
|
+
},
|
|
402
|
+
"app.provider.switchPaneRight": {
|
|
403
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
404
|
+
"description": "/provider: focus the right pane"
|
|
405
|
+
},
|
|
406
|
+
"app.provider.removeEntry": {
|
|
407
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
408
|
+
"description": "/provider: remove the selected compat or dictionary entry"
|
|
409
|
+
},
|
|
410
|
+
"app.tasks.detach": {
|
|
411
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
412
|
+
"description": "Move foreground tasks to the background"
|
|
413
|
+
},
|
|
414
|
+
"app.tasks.previousTab": {
|
|
415
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
416
|
+
"description": "Show Output in the focused task inspector"
|
|
417
|
+
},
|
|
418
|
+
"app.tasks.nextTab": {
|
|
419
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
420
|
+
"description": "Show Details in the focused task inspector"
|
|
421
|
+
},
|
|
422
|
+
"app.tasks.kill": {
|
|
423
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
424
|
+
"description": "Stop the selected task"
|
|
425
|
+
},
|
|
426
|
+
"app.tasks.confirmStop": {
|
|
427
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
428
|
+
"description": "Confirm stopping the selected task"
|
|
429
|
+
},
|
|
430
|
+
"app.tasks.detachSelected": {
|
|
431
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
432
|
+
"description": "Move the selected task to the background"
|
|
433
|
+
},
|
|
434
|
+
"app.tasks.search": {
|
|
435
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
436
|
+
"description": "Search retained task identities and labels"
|
|
437
|
+
},
|
|
438
|
+
"app.tasks.follow": {
|
|
439
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
440
|
+
"description": "Follow the selected task's output"
|
|
441
|
+
},
|
|
442
|
+
"app.tasks.top": {
|
|
443
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
444
|
+
"description": "Go to the top of the task list or preview"
|
|
445
|
+
},
|
|
446
|
+
"app.tasks.bottom": {
|
|
447
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
448
|
+
"description": "Go to the bottom of the task list or preview"
|
|
449
|
+
},
|
|
450
|
+
"app.tasks.nextFocus": {
|
|
451
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
452
|
+
"description": "Switch between task list and inspector"
|
|
453
|
+
},
|
|
454
|
+
"app.tasks.previousFocus": {
|
|
455
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
456
|
+
"description": "Switch between task inspector and list"
|
|
457
|
+
},
|
|
458
|
+
"app.tasks.help": {
|
|
459
|
+
"$ref": "#/$defs/KeybindingValue",
|
|
460
|
+
"description": "Show task controls"
|
|
429
461
|
}
|
|
430
462
|
},
|
|
431
463
|
"additionalProperties": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA+D,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,KAAK,EAAgB,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvH,wBAAgB,WAAW,CAAC,IAAI,EA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,MAAM;QACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,GAAG,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CACD,CAAC;AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session task runtime. */\n\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport type { AgentToolResult } from \"../../extensions/types.ts\";\nimport { runtimeLabel } from \"../../tasks/format.ts\";\nimport { boundText } from \"../../tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n} from \"../../tasks/types.ts\";\nimport { truncateHead } from \"../truncate.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampReadBytes, clampSinceBytes, clampWaitMs, requireTaskId, type TasksInput } from \"./schema.ts\";\nimport type { TasksDetails, TasksKillDetails, TasksListDetails, TasksReadDetails, TasksWaitDetails } from \"./types.ts\";\n\nexport function boundedText(text: string): string {\n\treturn truncateHead(sanitizeBinaryOutput(text), { maxBytes: 50 * 1024, maxLines: 2000 }).content;\n}\nfunction result<T extends TasksDetails>(text: string, details: T): AgentToolResult<T> {\n\treturn { content: [{ type: \"text\", text: boundedText(text) }], details };\n}\nexport function describeTaskLine(task: TaskSnapshot, now = Date.now()): string {\n\treturn `${task.id} ${task.kind} ${task.status} (${task.mode}) ${runtimeLabel(task, now)} ${task.title.slice(0, 200)}`;\n}\n\nconst LOOKUP_LIST_LIMIT = 10;\n\n/**\n * Finished rows sort most-recent first. list() is creation-ordered, so an\n * unsorted slice would surface the oldest completions rather than the recent\n * finishes a caller is most likely looking for.\n */\nfunction recentFinishedFirst(tasks: TaskSnapshot[]): TaskSnapshot[] {\n\treturn tasks.sort((left, right) => (right.endedAt ?? 0) - (left.endedAt ?? 0));\n}\n\n/**\n * Listings cover backgrounded work only; foreground executions deliver inline\n * in the transcript, so they are counted rather than shown. Every listing\n * (tasks list output and lookup-failure messages) shares this scope.\n */\nfunction listedTasks(background: TasksContext): { tasks: TaskSnapshot[]; foregroundOmitted: number } {\n\tconst all = background.list();\n\tconst tasks = all.filter((task) => task.mode === \"background\");\n\treturn { tasks, foregroundOmitted: all.length - tasks.length };\n}\n\nfunction foregroundOmissionNote(omitted: number): string {\n\treturn omitted > 0\n\t\t? `\\n${omitted} foreground ${omitted === 1 ? \"execution\" : \"executions\"} omitted — foreground work is delivered inline in the transcript.`\n\t\t: \"\";\n}\n\n/**\n * Rewrite the service's bare lookup failure into an actionable one: an\n * unknown id gets the session's current tasks (active first, then recent\n * finishes) so the next call can use a real id without a separate list call,\n * and an ambiguous prefix gets exactly the tasks it matched — including\n * records outside the current branch, which listings hide but the prefix\n * still collides with.\n */\nfunction lookupFailure(background: TasksContext, id: string, error: unknown): Error {\n\tif (!(error instanceof TaskLookupError)) return error instanceof Error ? error : new Error(String(error));\n\tif (error.kind === \"ambiguous\") {\n\t\tconst lines = error.matches.map((task) => describeTaskLine(task)).join(\"\\n\");\n\t\treturn new Error(`Ambiguous task ID \"${id}\" matches ${error.matches.length} tasks:\\n${lines}`);\n\t}\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);\n\tif (shown.length === 0) {\n\t\treturn new Error(`No task \"${id}\" in this session. No background tasks in this session.`);\n\t}\n\tconst lines = shown.map((task) => describeTaskLine(task)).join(\"\\n\");\n\treturn new Error(\n\t\t`No task \"${id}\" in this session. IDs from other sessions are not valid here.\\nCurrent background tasks:\\n${lines}${foregroundOmissionNote(foregroundOmitted)}`,\n\t);\n}\n\n/**\n * Where this slice sits in the output, so the next wait can continue from it.\n * A wait whose new output exceeds its budget returns the newest bytes and says what it skipped.\n */\nfunction rangeText(slice: TaskRead, sinceBytes?: number): string {\n\tconst from = slice.fromByte ?? 0;\n\tconst to = from + Buffer.byteLength(slice.text);\n\tconst floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;\n\treturn [\n\t\t`bytes ${from}–${to} of ${slice.totalBytes}`,\n\t\tsinceBytes !== undefined && from > floor ? `skipped ${from - floor} bytes after sinceBytes ${floor}` : \"\",\n\t\t`next sinceBytes ${to}`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" · \");\n}\n\n/** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */\nfunction readText(header: string, slice: TaskRead): string {\n\tconst boundedField = (text: string, maxBytes: number) =>\n\t\ttruncateHead(boundText(sanitizeBinaryOutput(text), maxBytes), { maxBytes, maxLines: 100 }).content;\n\treturn [\n\t\tboundedField(header, 4096),\n\t\tslice.task.error ? `Task error: ${boundedField(slice.task.error, 4096)}` : \"\",\n\t\tslice.readError ? `Output read error: ${boundedField(slice.readError, 4096)}` : \"\",\n\t\tboundedField(slice.task.outputPath ?? \"\", 8192),\n\t\tslice.text || \"(no output yet)\",\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\nexport async function runRead(background: TasksContext, input: TasksInput): Promise<AgentToolResult<TasksReadDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst mode = input.mode ?? \"tail\";\n\t\tconst slice = await background.read(id, { mode, bytes: clampReadBytes(input.bytes) });\n\t\treturn result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {\n\t\t\taction: \"read\",\n\t\t\ttaskId: slice.task.id,\n\t\t\tmode,\n\t\t\tsliceBytes: Buffer.byteLength(slice.text),\n\t\t\ttotalBytes: slice.totalBytes,\n\t\t\toutputPath: slice.task.outputPath ?? \"\",\n\t\t\tkind: slice.task.kind,\n\t\t\tstatus: slice.task.status,\n\t\t});\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nfunction activeBackgroundTasks(background: TasksContext): TaskSnapshot[] {\n\treturn background.list().filter((task) => task.mode === \"background\" && !isTaskTerminal(task.status));\n}\n\nfunction stillRunningText(tasks: TaskSnapshot[]): string {\n\treturn tasks.length > 0 ? `\\n\\n[still_running]\\n${tasks.map((task) => describeTaskLine(task)).join(\"\\n\")}` : \"\";\n}\n\nfunction emptyWaitDetails(\n\toutcome: \"interrupted\" | \"timed_out\" | \"no_tasks\",\n\twaitedMs: number,\n\trunning: number,\n): TasksWaitDetails {\n\treturn {\n\t\taction: \"wait\",\n\t\toutcome,\n\t\ttimedOut: outcome === \"timed_out\",\n\t\texitCode: undefined,\n\t\twaitedMs,\n\t\tdeltaBytes: 0,\n\t\ttotalBytes: 0,\n\t\tdeltaTruncated: false,\n\t\toutputPath: \"\",\n\t\trunning,\n\t};\n}\n\nasync function runWaitAny(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n\tinterruptSignal?: AbortSignal,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst candidates = activeBackgroundTasks(background);\n\tif (candidates.length === 0) {\n\t\treturn result(\n\t\t\t\"No background tasks are running, so there is nothing to wait for. Finished tasks report back via automatic notification.\",\n\t\t\temptyWaitDetails(\"no_tasks\", 0, 0),\n\t\t);\n\t}\n\t// Holds cover the whole initial cohort until the winning result is ready for\n\t// persistence. Other completed tasks resume ordinary notification delivery on release.\n\tconst releases = candidates.map((task) => background.holdDelivery(task.id));\n\tconst start = Date.now();\n\ttry {\n\t\tconst task = await background.waitAny(clampWaitMs(input.waitMs), signal, interruptSignal);\n\t\tconst ids = new Set(candidates.map((candidate) => candidate.id));\n\t\tconst running = activeBackgroundTasks(background).filter((candidate) => ids.has(candidate.id));\n\t\tif (!task) {\n\t\t\tconst interrupted = !background.closed && interruptSignal?.aborted === true;\n\t\t\tconst outcome = interrupted ? \"interrupted\" : \"timed_out\";\n\t\t\tconst note = background.closed\n\t\t\t\t? \"The host closed; execution state is unconfirmed.\"\n\t\t\t\t: interrupted\n\t\t\t\t\t? \"New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped.\"\n\t\t\t\t\t: \"The wait window expired; running tasks continue. Prefer other work over waiting again.\";\n\t\t\treturn result(\n\t\t\t\t`${note}${stillRunningText(running)}`,\n\t\t\t\temptyWaitDetails(outcome, Date.now() - start, running.length),\n\t\t\t);\n\t\t}\n\t\tconst slice = await background.read(task.id, { bytes: TASKS_WAIT_DELTA_BYTES });\n\t\tsignal?.throwIfAborted();\n\t\tonReady?.(task.id);\n\t\treturn result(\n\t\t\t`${readText(`[${describeTaskLine(task)} · waitAny settled · ${rangeText(slice)}]`, slice)}${stillRunningText(running)}`,\n\t\t\t{\n\t\t\t\taction: \"wait\",\n\t\t\t\toutcome: \"settled\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tstatus: task.status,\n\t\t\t\tkind: task.kind,\n\t\t\t\ttimedOut: false,\n\t\t\t\texitCode: task.exitCode,\n\t\t\t\twaitedMs: Date.now() - start,\n\t\t\t\tdeltaBytes: Buffer.byteLength(slice.text),\n\t\t\t\ttotalBytes: slice.totalBytes,\n\t\t\t\tdeltaTruncated: slice.truncated,\n\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t\trunning: running.length,\n\t\t\t},\n\t\t);\n\t} finally {\n\t\tfor (const release of releases) release();\n\t}\n}\n\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n\tinterruptSignal?: AbortSignal,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tif (!input.taskId?.trim()) {\n\t\tif (input.sinceBytes !== undefined)\n\t\t\tthrow new Error(\"action 'wait' without 'taskId' does not accept 'sinceBytes'; offsets belong to one task.\");\n\t\treturn runWaitAny(background, input, signal, onReady, interruptSignal);\n\t}\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst release = background.holdDelivery(id);\n\t\ttry {\n\t\t\tconst start = Date.now();\n\t\t\tconst task = await background.wait(id, clampWaitMs(input.waitMs), signal, interruptSignal);\n\t\t\tconst settled = isTaskTerminal(task.status);\n\t\t\tconst interrupted = !settled && !background.closed && interruptSignal?.aborted === true;\n\t\t\tconst timedOut = !settled && !interrupted;\n\t\t\tconst outcome = settled ? \"settled\" : interrupted ? \"interrupted\" : \"timed_out\";\n\t\t\tconst waitedMs = Date.now() - start;\n\t\t\tif (interrupted) {\n\t\t\t\treturn result(\n\t\t\t\t\t`[${describeTaskLine(task)} · interrupted by steering; execution continues]\\nRead the new input before deciding whether to wait again; the task was not stopped.`,\n\t\t\t\t\t{\n\t\t\t\t\t\taction: \"wait\",\n\t\t\t\t\t\toutcome,\n\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\tstatus: task.status,\n\t\t\t\t\t\tkind: task.kind,\n\t\t\t\t\t\ttimedOut: false,\n\t\t\t\t\t\texitCode: task.exitCode,\n\t\t\t\t\t\twaitedMs,\n\t\t\t\t\t\tdeltaBytes: 0,\n\t\t\t\t\t\ttotalBytes: 0,\n\t\t\t\t\t\tdeltaTruncated: false,\n\t\t\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A closed host resolves waits early without settling anything; do not claim\n\t\t\t// the execution merely outlived the wait window.\n\t\t\tconst windowNote = background.closed\n\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t: timedOut\n\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t: \"\";\n\t\t\tconst sinceBytes = clampSinceBytes(input.sinceBytes);\n\t\t\tconst slice = await background.read(id, { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes });\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (settled) onReady?.(task.id);\n\t\t\treturn result(readText(`[${describeTaskLine(task)}${windowNote} · ${rangeText(slice, sinceBytes)}]`, slice), {\n\t\t\t\taction: \"wait\",\n\t\t\t\toutcome,\n\t\t\t\ttaskId: task.id,\n\t\t\t\tstatus: task.status,\n\t\t\t\tkind: task.kind,\n\t\t\t\ttimedOut,\n\t\t\t\texitCode: task.exitCode,\n\t\t\t\twaitedMs,\n\t\t\t\tdeltaBytes: Buffer.byteLength(slice.text),\n\t\t\t\ttotalBytes: slice.totalBytes,\n\t\t\t\tdeltaTruncated: slice.truncated,\n\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t});\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runKill(background: TasksContext, input: TasksInput): AgentToolResult<TasksKillDetails> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst task = background.get(id);\n\t\tconst requested = background.kill(task.id);\n\t\treturn result(\n\t\t\trequested\n\t\t\t\t? `Cancellation requested for ${task.id}. The task or whole group is stopping; cleanup may still be in progress.`\n\t\t\t\t: `No new cancellation requested for ${task.id} (${background.get(task.id).status}).`,\n\t\t\t{\n\t\t\t\taction: \"kill\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tcommand: task.command ?? task.title,\n\t\t\t\trequested,\n\t\t\t\tstatus: background.get(task.id).status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runList(background: TasksContext): AgentToolResult<TasksListDetails> {\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished.slice(0, TASKS_LIST_FINISHED_SHOWN)].slice(0, 100);\n\tconst hidden = tasks.length - shown.length;\n\treturn result(\n\t\tshown.length\n\t\t\t? `${shown.map((task) => describeTaskLine(task)).join(\"\\n\")}${hidden > 0 ? `\\n${hidden} more records not shown.` : \"\"}${foregroundOmissionNote(foregroundOmitted)}`\n\t\t\t: `No background tasks. Start work through its owning tool with background: true.${foregroundOmissionNote(foregroundOmitted)}`,\n\t\t{\n\t\t\taction: \"list\",\n\t\t\trunning: active.length,\n\t\t\tfinished: finished.length,\n\t\t\tshown: shown.length,\n\t\t\thidden,\n\t\t\t...(foregroundOmitted > 0 ? { foregroundOmitted } : {}),\n\t\t},\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,QAAW,CAAC;AACjD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AACvC,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,0BAA0B,QAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC","sourcesContent":["/**\n * Shared limits of the `tasks` tool.\n *\n * Numbers that more than one module needs live here so a change lands in one\n * place; execution and retention limits belong to the core service.\n */\n\n/** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */\nexport const TASKS_LOGS_DEFAULT_BYTES = 8 * 1024;\nexport const TASKS_LOGS_MIN_BYTES = 256;\n\n/** Finished tasks shown by `list` before the rest fold into a count. */\nexport const TASKS_LIST_FINISHED_SHOWN = 5;\n\n/** Bounded output delta returned by a successful wait. */\nexport const TASKS_WAIT_DELTA_BYTES = 32 * 1024;\n\n/** Wait-window bounds shared by execution and the pending-call renderer. */\nexport const TASKS_WAIT_DEFAULT_MS = 20_000;\nexport const TASKS_WAIT_MIN_MS = 1_000;\nexport const TASKS_WAIT_MAX_MS = 60_000;\n\n/** How long a foreground execution runs before the statusline advertises the detach key. */\nexport const TASKS_DETACH_HINT_DELAY_MS = 10_000;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAW5C,eAAO,MAAM,WAAW;;;;;;;EAiCtB,CAAC;AAEH,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAOpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM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AAS,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAC/F,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAA8B;IAC7D,OAAO,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAClC,8EAA8E;IAC9E,+EAA+E;IAC/E,8DAA8D;IAC9D,oDAAoD;IACpD,4OAA4O;IAC5O,8CAA8C;IAC9C,qUAAqU,CAAC;AACvU,MAAM,CAAC,MAAM,oBAAoB,GAAG,uEAAuE,CAAC;AAC5G,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,+GAA+G;IAC/G,qPAAqP;IACrP,gKAAgK;CAChK,CAAC","sourcesContent":["/**\n * The `tasks` tool's wire contract: one flat schema whose `action`\n * selects which of the remaining fields apply, plus the model-facing copy.\n *\n * The schema stays flat deliberately: a single tool keeps the model's tool list\n * short. Execution creation belongs to the native tools. Narrowing happens\n * inside actions.ts, not here.\n */\n\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { TASK_RESULT_BYTES } from \"../../tasks/output.ts\";\nimport { formatSize } from \"../truncate.ts\";\nimport {\n\tTASKS_LOGS_DEFAULT_BYTES,\n\tTASKS_LOGS_MIN_BYTES,\n\tTASKS_WAIT_DEFAULT_MS,\n\tTASKS_WAIT_MAX_MS,\n\tTASKS_WAIT_MIN_MS,\n} from \"./constants.ts\";\n\nexport const tasksSchema = Type.Object({\n\taction: StringEnum([\"read\", \"wait\", \"kill\", \"list\"] as const, {\n\t\tdescription: \"Which task operation to perform\",\n\t}),\n\t// — read / wait / kill —\n\ttaskId: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Task execution id (read/wait/kill). Omit for wait to wait for any task running at call time.\",\n\t\t}),\n\t),\n\t// — read —\n\tmode: Type.Optional(\n\t\tStringEnum([\"tail\", \"head\"] as const, {\n\t\t\tdescription: \"Read from the end (default) or the start of the output (read)\",\n\t\t}),\n\t),\n\tbytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(TASK_RESULT_BYTES)})`,\n\t\t}),\n\t),\n\t// — wait —\n\twaitMs: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max time to wait in ms, default ${TASKS_WAIT_DEFAULT_MS}, max ${TASKS_WAIT_MAX_MS} (wait)`,\n\t\t}),\n\t),\n\tsinceBytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription:\n\t\t\t\t\"Only return output written after this byte offset — use the 'next sinceBytes' value from a previous read or wait (wait with taskId only)\",\n\t\t}),\n\t),\n});\n\n/** Raw tool arguments. Every per-action field is optional here; actions.ts narrows. */\nexport type TasksInput = Static<typeof tasksSchema>;\n\n// ── reading the contract ──────────────────────────────────────────────────\n// One place per field: required fields throw a message that names the next\n// step, optional ones clamp to their documented range. Callers get plain\n// values, so no action handler needs a cast.\n\nexport function requireTaskId(input: TasksInput): string {\n\tconst taskId = input.taskId;\n\tif (!taskId || taskId.trim().length === 0) {\n\t\tthrow new Error(`action '${input.action}' requires 'taskId' — use action list to find the execution id.`);\n\t}\n\treturn taskId;\n}\n\nexport function clampReadBytes(bytes: number | undefined): number {\n\tconst value = bytes !== undefined && Number.isFinite(bytes) ? bytes : TASKS_LOGS_DEFAULT_BYTES;\n\treturn Math.min(TASK_RESULT_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));\n}\n\n/** Shared with the pending-call renderer so the window it shows is the one that runs. */\nexport function clampWaitMs(waitMs: number | undefined): number {\n\tconst value = waitMs !== undefined && Number.isFinite(waitMs) ? waitMs : TASKS_WAIT_DEFAULT_MS;\n\treturn Math.min(TASKS_WAIT_MAX_MS, Math.max(TASKS_WAIT_MIN_MS, Math.floor(value)));\n}\n\nexport function clampSinceBytes(sinceBytes: number | undefined): number | undefined {\n\treturn sinceBytes === undefined || !Number.isFinite(sinceBytes) ? undefined : Math.max(0, Math.floor(sinceBytes));\n}\n\nexport const TASKS_TOOL_DESCRIPTION =\n\t\"Inspect and control background tasks started by native tools or extensions. \" +\n\t\"Completion is delivered to you automatically as a notification — never poll. \" +\n\t\"list: bounded activity/history listing; find task IDs here. \" +\n\t\"read: bounded output or report slice (head/tail). \" +\n\t\"wait: block up to waitMs for one task to settle, or omit taskId to wait for any task running at call time; no running tasks returns immediately. New steering input ends only the wait with outcome interrupted; it never stops the task. \" +\n\t\"kill: request cancellation of a whole task. \" +\n\t\"tasks cannot start work; submit background work through its owning tool. A wait ends as settled, interrupted, timed_out, or no_tasks. Timeout or cancellation ends only the wait, never execution. Reads and settled waits report byte ranges; use next sinceBytes only with that task's ID. Output is capped at 50KB per response.\";\nexport const TASKS_PROMPT_SNIPPET = \"Manage background tasks; wait for a specific task or any running task\";\nexport const TASKS_PROMPT_GUIDELINES = [\n\t\"Start background work through its owning tool with background: true; continue independent work while it runs.\",\n\t\"A finished background task delivers its result automatically as a notification. Use tasks wait only when your next step is blocked: provide taskId for one task or omit it for any task running at call time; never sleep-poll with repeated reads.\",\n\t\"A new steering message interrupts only an active tasks wait so you can read the new input; it does not cancel execution. A wait timeout is not a task failure.\",\n];\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/types.ts"],"names":[],"mappings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IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG","sourcesContent":["/**\n * The `tasks` tool's structured `details` payloads.\n *\n * Every shape here is JSON-serialized verbatim into the session file and read back\n * by the renderers on `/reload`, `/tree`, and session resume. Adding an optional\n * field is free; renaming or repurposing an existing one degrades historical\n * transcripts.\n *\n * `exitCode` is three-state: `null` for signal-reaped tasks.\n */\n\nimport type { TaskKind, TaskStatus } from \"../../tasks/types.ts\";\n\nexport interface TasksReadDetails {\n\tkind?: TaskKind;\n\tstatus?: TaskStatus;\n\taction: \"read\";\n\ttaskId: string;\n\tmode: \"head\" | \"tail\";\n\tsliceBytes: number;\n\ttotalBytes: number;\n\toutputPath: string;\n}\n\nexport type TasksWaitOutcome = \"settled\" | \"interrupted\" | \"timed_out\" | \"no_tasks\";\n\nexport interface TasksWaitDetails {\n\tkind?: TaskKind;\n\taction: \"wait\";\n\t/** Absent only in historical results; new calls always record the reason the wait ended. */\n\toutcome?: TasksWaitOutcome;\n\t/** Undefined for waitAny with no selected task, or when no tasks were running. */\n\ttaskId?: string;\n\t/** Retained for compatibility with historical details; true only for a wait-window expiry. */\n\ttimedOut: boolean;\n\tstatus?: TaskStatus;\n\texitCode: number | null | undefined;\n\twaitedMs: number;\n\tdeltaBytes: number;\n\ttotalBytes: number;\n\tdeltaTruncated: boolean;\n\toutputPath: string;\n\t/** Initial waitAny cohort members still running when the wait ended. */\n\trunning?: number;\n}\n\nexport interface TasksKillDetails {\n\trequested?: boolean;\n\tstatus?: TaskStatus;\n\taction: \"kill\";\n\ttaskId: string;\n\tcommand: string;\n}\n\nexport interface TasksListDetails {\n\taction: \"list\";\n\trunning: number;\n\tfinished: number;\n\tshown: number;\n\thidden: number;\n\t/** Foreground executions omitted from the listing; they deliver inline in the transcript. */\n\tforegroundOmitted?: number;\n}\n\nexport type TasksDetails = TasksReadDetails | TasksKillDetails | TasksListDetails | TasksWaitDetails;\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type TasksRenderState } from "../../modes/interactive/tasks/render.ts";
|
|
2
|
-
import type { ToolDefinition } from "../extensions/types.ts";
|
|
3
|
-
import { tasksSchema } from "./tasks/schema.ts";
|
|
4
|
-
import type { TasksDetails } from "./tasks/types.ts";
|
|
5
|
-
export declare function createTasksToolDefinition(onWaitResult?: (toolCallId: string, taskId: string) => void, waitInterruptSignal?: () => AbortSignal | undefined): ToolDefinition<typeof tasksSchema, TasksDetails, TasksRenderState>;
|
|
6
|
-
export declare function createTasksTool(): import("@earendil-works/pi-agent-core").AgentTool<import("typebox").TObject<{
|
|
7
|
-
action: import("typebox").TUnsafe<"read" | "list" | "wait" | "kill">;
|
|
8
|
-
taskId: import("typebox").TOptional<import("typebox").TString>;
|
|
9
|
-
mode: import("typebox").TOptional<import("typebox").TUnsafe<"head" | "tail">>;
|
|
10
|
-
bytes: import("typebox").TOptional<import("typebox").TNumber>;
|
|
11
|
-
waitMs: import("typebox").TOptional<import("typebox").TNumber>;
|
|
12
|
-
sinceBytes: import("typebox").TOptional<import("typebox").TNumber>;
|
|
13
|
-
}>, TasksDetails>;
|
|
14
|
-
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,g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EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;YAChD,IAAI,CAAC;gBACJ,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;oBACvB,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACzC,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CACnB,GAAG,CAAC,KAAK,EACT,MAAM,EACN,MAAM,EACN,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EACvC,mBAAmB,EAAE,EAAE,CACvB,CAAC;oBACH,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACnC,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,uEAAuE;gBACvE,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;QACD,UAAU,EAAE,eAAe;QAC3B,YAAY,EAAE,iBAAiB;KAC/B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC9B,OAAO,kBAAkB,CAAC,yBAAyB,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { renderTasksCall, renderTasksResult, type TasksRenderState } from \"../../modes/interactive/tasks/render.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { boundedText, runKill, runList, runRead, runWait } from \"./tasks/actions.ts\";\nimport { TASKS_PROMPT_GUIDELINES, TASKS_PROMPT_SNIPPET, TASKS_TOOL_DESCRIPTION, tasksSchema } from \"./tasks/schema.ts\";\nimport type { TasksDetails } from \"./tasks/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nexport function createTasksToolDefinition(\n\tonWaitResult?: (toolCallId: string, taskId: string) => void,\n\twaitInterruptSignal?: () => AbortSignal | undefined,\n): ToolDefinition<typeof tasksSchema, TasksDetails, TasksRenderState> {\n\treturn {\n\t\tname: \"tasks\",\n\t\tlabel: \"tasks\",\n\t\tdescription: TASKS_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TASKS_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TASKS_PROMPT_GUIDELINES,\n\t\tparameters: tasksSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(_id, params, signal, _onUpdate, ctx) {\n\t\t\ttry {\n\t\t\t\tswitch (params.action) {\n\t\t\t\t\tcase \"read\":\n\t\t\t\t\t\treturn await runRead(ctx.tasks, params);\n\t\t\t\t\tcase \"wait\":\n\t\t\t\t\t\treturn await runWait(\n\t\t\t\t\t\t\tctx.tasks,\n\t\t\t\t\t\t\tparams,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t(taskId) => onWaitResult?.(_id, taskId),\n\t\t\t\t\t\t\twaitInterruptSignal?.(),\n\t\t\t\t\t\t);\n\t\t\t\t\tcase \"kill\":\n\t\t\t\t\t\treturn runKill(ctx.tasks, params);\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\treturn runList(ctx.tasks);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Lookup failures already carry the current task list from actions.ts.\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(boundedText(message));\n\t\t\t}\n\t\t},\n\t\trenderCall: renderTasksCall,\n\t\trenderResult: renderTasksResult,\n\t};\n}\n\nexport function createTasksTool() {\n\treturn wrapToolDefinition(createTasksToolDefinition());\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion-render.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAE,KAAK,SAAS,EAA6D,MAAM,wBAAwB,CAAC;AACnH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAkL/C,gGAAgG;AAChG,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,KAAK,GACV,SAAS,CAWX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion-render.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAkB,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGnH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAA0B,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/B,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,WAAW,GAA2B,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAmBvF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Y,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YACxG,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,OAAO,GACZ,KAAK,CAAC,MAAM,GAAG,SAAS;YACvB,CAAC,CAAC;gBACA,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC;gBAChC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,sDAAsD,CAAC;aACvE;YACF,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7G,CAAC;CACD;AAED,gGAAgG;AAChG,MAAM,UAAU,oBAAoB,CACnC,OAA+B,EAC/B,OAA6B,EAC7B,KAAY;IAEZ,IAAI,IAAoB,CAAC;IACzB,IAAI,CAAC;QACJ,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,IAAI,GAAG;YACN,IAAI,EAAE,mGAAmG;YACzG,SAAS,EAAE,KAAK;SAChB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/** Human-facing completion cards. The persisted context message remains untouched. */\nimport { type Component, stripTerminalSequences, truncateToWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { MessageRenderOptions } from \"../../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../../core/messages.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport { readTaskCompletion } from \"../../../core/tasks/presentation.ts\";\nimport type { TaskTerminalStatus } from \"../../../core/tasks/types.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { type StatusMarkerColor, statusMarker } from \"../components/status-marker.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\nimport { FramedComponent } from \"../tool-view/style.ts\";\nimport { statusName } from \"./task-view.ts\";\n\nconst SOURCE_LIMIT = 64 * 1024;\nconst CARD_ROWS = 128;\nconst OUTPUT_ROWS = 20;\nconst SHELL_NAMES: Record<string, string> = { bash: \"Bash\", powershell: \"PowerShell\" };\n\ninterface CompletionView {\n\ttitle?: string;\n\tduration?: string;\n\texitCode?: number | null;\n\tkind?: string;\n\tstatus?: TaskTerminalStatus;\n\tid?: string;\n\tcommand?: string;\n\tcwd?: string;\n\tpath?: string;\n\tdiagnostic?: string;\n\t/** Undefined for an unreadable message, whose saved content is shown instead. */\n\toutput?: string;\n\tbody: string;\n\ttruncated: boolean;\n}\n\nfunction clean(text: string): string {\n\treturn sanitizeBinaryOutput(stripTerminalSequences(text)).replace(/\\r\\n?/g, \"\\n\");\n}\n\nfunction savedText(message: CustomMessage<unknown>): { text: string; clipped: boolean } {\n\t// 64K is a UTF-16 code-unit display budget, not a UTF-8 byte promise; the block\n\t// cap bounds iteration itself so many empty/non-text blocks cannot spin here.\n\tconst MAX_SOURCE_BLOCKS = 256;\n\tconst content = message.content;\n\tlet text = \"\";\n\tlet clipped = false;\n\tif (typeof content === \"string\") {\n\t\ttext = content.slice(0, SOURCE_LIMIT);\n\t\tclipped = content.length > SOURCE_LIMIT;\n\t} else if (Array.isArray(content)) {\n\t\tlet visited = 0;\n\t\tfor (const block of content) {\n\t\t\tif (++visited > MAX_SOURCE_BLOCKS) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!block || block.type !== \"text\" || typeof block.text !== \"string\") continue;\n\t\t\tconst next = `${text ? \"\\n\" : \"\"}${block.text.slice(0, SOURCE_LIMIT + 1)}`;\n\t\t\tconst remaining = SOURCE_LIMIT - text.length;\n\t\t\ttext += next.slice(0, remaining);\n\t\t\tif (next.length > remaining || block.text.length > SOURCE_LIMIT) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn { text: clean(text), clipped };\n}\n\nfunction completionView(message: CustomMessage<unknown>): CompletionView {\n\tconst snapshot = readTaskCompletion(message.details);\n\tif (!snapshot) {\n\t\tconst { text, clipped } = savedText(message);\n\t\treturn { body: text, truncated: clipped };\n\t}\n\treturn {\n\t\ttitle: clean(snapshot.title),\n\t\tduration: runtimeLabel(snapshot),\n\t\tkind: snapshot.kind,\n\t\tstatus: snapshot.status,\n\t\tid: clean(snapshot.taskId),\n\t\texitCode: snapshot.exitCode,\n\t\tcommand: snapshot.command === undefined ? undefined : clean(snapshot.command.text),\n\t\tcwd: snapshot.cwd === undefined ? undefined : clean(snapshot.cwd),\n\t\tpath: snapshot.outputPath === undefined ? undefined : clean(snapshot.outputPath),\n\t\tdiagnostic: snapshot.error === undefined ? undefined : clean(snapshot.error),\n\t\toutput: clean(snapshot.output.text),\n\t\tbody: \"\",\n\t\ttruncated: snapshot.output.truncated || snapshot.command?.truncated === true,\n\t};\n}\n\nfunction color(status: string | undefined): StatusMarkerColor {\n\treturn status === undefined ? \"muted\" : statusMarker(status).color;\n}\nfunction shortId(id: string): string {\n\treturn id.replace(/^(.+)-([0-9a-f]{8})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, \"$1-$2\");\n}\n\nclass CompletionCard implements Component {\n\tprivate readonly view: CompletionView;\n\tprivate readonly options: MessageRenderOptions;\n\tprivate readonly theme: Theme;\n\tconstructor(view: CompletionView, options: MessageRenderOptions, theme: Theme) {\n\t\tthis.view = view;\n\t\tthis.options = options;\n\t\tthis.theme = theme;\n\t}\n\tinvalidate(): void {}\n\trender(width: number): string[] {\n\t\tif (width < 1) return [];\n\t\tconst chrome = new FramedComponent(\n\t\t\t{ render: (contentWidth) => this.renderContent(contentWidth), invalidate() {} },\n\t\t\t\"header\",\n\t\t\t() => color(this.view.status),\n\t\t);\n\t\t// The gutter reserves its own cells; clip defensively for one-cell terminals.\n\t\treturn chrome.render(width).map((line) => truncateToWidth(line, width, \"\"));\n\t}\n\tprivate renderContent(width: number): string[] {\n\t\t// The chrome clamps to ≥1 already; keep the padding arithmetic safe regardless.\n\t\tif (!Number.isFinite(width) || width < 1) return [];\n\t\tconst view = this.view;\n\t\tconst theme = this.theme;\n\t\tconst options = this.options;\n\t\t// The native dot/rail replaces the default one-cell custom-message inset.\n\t\t// Additional configured padding stays inside the chrome, never shifting the dot.\n\t\tconst padding = Math.min(Math.max(0, Math.floor(options.outputPad || 0) - 1), Math.floor((width - 1) / 2));\n\t\tconst inner = width - padding * 2;\n\t\tconst indent = inner >= 3 ? \" \" : \"\";\n\t\tconst bodyWidth = Math.max(1, inner - indent.length);\n\t\tconst lines: string[] = [];\n\t\tconst status = view.status ? statusName(view.status) : \"Result received\";\n\t\tconst kind = view.kind === undefined ? \"Notification\" : (SHELL_NAMES[view.kind] ?? view.kind);\n\t\tlines.push(\n\t\t\t`${theme.fg(\"toolTitle\", theme.bold(kind))}${theme.fg(\"muted\", ` · Background ${status.toLowerCase()}${view.duration ? ` · ${view.duration}` : \"\"}`)}${view.id ? theme.fg(\"dim\", ` · ${shortId(view.id)}`) : \"\"}`,\n\t\t);\n\t\tconst summary = view.command ? `$ ${view.command.split(\"\\n\")[0]}` : view.title;\n\t\tif (!options.expanded) {\n\t\t\tif (summary) lines.push(theme.fg(\"toolOutput\", summary));\n\t\t\tif (view.diagnostic) lines.push(theme.fg(color(view.status), view.diagnostic));\n\t\t} else {\n\t\t\tif (view.truncated) {\n\t\t\t\tlines.push(theme.fg(\"warning\", \"The saved result is truncated; this is not the complete original output.\"));\n\t\t\t}\n\t\t\tconst section = (title: string, text: string, limit: number, tail = false, error = false) => {\n\t\t\t\tlines.push(\"\", theme.fg(\"muted\", theme.bold(title)));\n\t\t\t\tconst rendered = wrapTextWithAnsi(text, bodyWidth).map((line) =>\n\t\t\t\t\ttheme.fg(error ? \"error\" : \"toolOutput\", line),\n\t\t\t\t);\n\t\t\t\tconst omitted = Math.max(0, rendered.length - limit);\n\t\t\t\tconst selected = tail ? rendered.slice(-limit) : rendered.slice(0, limit);\n\t\t\t\tif (tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} earlier display lines omitted`));\n\t\t\t\tfor (const line of selected) lines.push(indent + line);\n\t\t\t\tif (!tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} more display lines omitted`));\n\t\t\t};\n\t\t\tif (view.output === undefined) section(\"Details\", view.body || \"No text result.\", 36);\n\t\t\telse {\n\t\t\t\tif (view.command) section(\"Command\", view.command, 8);\n\t\t\t\telse if (view.title) section(\"Task\", view.title, 4);\n\t\t\t\tif (view.cwd) section(\"Directory\", view.cwd, 2);\n\t\t\t\tsection(\n\t\t\t\t\tview.status === \"failed\" || view.status === \"timeout\" ? \"Error\" : \"Result\",\n\t\t\t\t\t`${view.diagnostic ?? status}${view.exitCode !== undefined ? ` · ${view.exitCode === null ? \"terminated by signal\" : `exit ${view.exitCode}`}` : \"\"}`,\n\t\t\t\t\t4,\n\t\t\t\t\tfalse,\n\t\t\t\t\tview.status === \"failed\",\n\t\t\t\t);\n\t\t\t\tsection(\"Output\", !view.output.trim() ? \"No output.\" : view.output, OUTPUT_ROWS, true);\n\t\t\t\tif (view.path) section(\"Log\", view.path, 4);\n\t\t\t}\n\t\t\tif (view.id) {\n\t\t\t\tlines.push(\"\", ...wrapTextWithAnsi(`Task ID: ${view.id}`, inner).map((line) => theme.fg(\"dim\", line)));\n\t\t\t}\n\t\t\tlines.push(theme.fg(\"dim\", \"Preview of the saved result.\"));\n\t\t}\n\t\tconst bounded =\n\t\t\tlines.length > CARD_ROWS\n\t\t\t\t? [\n\t\t\t\t\t\t...lines.slice(0, CARD_ROWS - 1),\n\t\t\t\t\t\ttheme.fg(\"dim\", \"… card shortened; use tasks read for retained output\"),\n\t\t\t\t\t]\n\t\t\t\t: lines;\n\t\treturn bounded.map((line) => \" \".repeat(padding) + truncateToWidth(line, inner, \"…\") + \" \".repeat(padding));\n\t}\n}\n\n/** Always return a compact, replay-safe component, including for unknown historical formats. */\nexport function renderTaskCompletion(\n\tmessage: CustomMessage<unknown>,\n\toptions: MessageRenderOptions,\n\ttheme: Theme,\n): Component {\n\tlet view: CompletionView;\n\ttry {\n\t\tview = completionView(message);\n\t} catch {\n\t\tview = {\n\t\t\tbody: \"The saved notification could not be interpreted. Its original message remains in session history.\",\n\t\t\ttruncated: false,\n\t\t};\n\t}\n\treturn new CompletionCard(view, options, theme);\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type AppKeybinding } from "../../../core/keybindings.ts";
|
|
2
|
-
import type { TaskSnapshot } from "../../../core/tasks/types.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Task rows for `/hotkeys`. Task keybindings act outside the editor, so they never showed up in
|
|
5
|
-
* the editor-driven sections; labels come from KEYBINDINGS so the table cannot drift from the
|
|
6
|
-
* binding registry.
|
|
7
|
-
*/
|
|
8
|
-
export declare function hotkeysTaskSection(display: (action: AppKeybinding) => string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Ask before tree navigation cancels running tasks: results are saved on their launch branch,
|
|
11
|
-
* so leaving it stops them. Resolves true when navigation may continue.
|
|
12
|
-
*/
|
|
13
|
-
export declare function confirmStopBranchTasks(stopped: readonly TaskSnapshot[], confirm: (title: string, message: string) => Promise<boolean>): Promise<boolean>;
|
|
14
|
-
//# sourceMappingURL=host-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-hooks.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/host-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,GAAG,MAAM,CAUrF;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC3D,OAAO,CAAC,OAAO,CAAC,CAQlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-hooks.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/host-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0C;IAC5E,MAAM,MAAM,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,WAAW,CAAC,0BAA0B,CAAC,CAAC;IAC/D,OAAO;;;;MAIF,OAAO,CAAC,kBAAkB,CAAC,QAAQ,MAAM,CAAC,WAAW;MACrD,OAAO,CAAC,0BAA0B,CAAC,QAAQ,cAAc,CAAC,WAAW;CAC1E,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,OAAgC,EAChC,OAA6D;IAE7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACpH,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC;IAC9F,OAAO,OAAO,CACb,QAAQ,OAAO,CAAC,MAAM,gBAAgB,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,EACxE,2EAA2E,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7F,CAAC;AACH,CAAC","sourcesContent":["import { type AppKeybinding, KEYBINDINGS } from \"../../../core/keybindings.ts\";\nimport type { TaskSnapshot } from \"../../../core/tasks/types.ts\";\nimport { cleanTaskText, firstCommandLine } from \"./text.ts\";\n\n/**\n * Task rows for `/hotkeys`. Task keybindings act outside the editor, so they never showed up in\n * the editor-driven sections; labels come from KEYBINDINGS so the table cannot drift from the\n * binding registry.\n */\nexport function hotkeysTaskSection(display: (action: AppKeybinding) => string): string {\n\tconst detach = KEYBINDINGS[\"app.tasks.detach\"];\n\tconst detachSelected = KEYBINDINGS[\"app.tasks.detachSelected\"];\n\treturn `\n**Tasks**\n| Key | Action |\n|-----|--------|\n| \\`${display(\"app.tasks.detach\")}\\` | ${detach.description} |\n| \\`${display(\"app.tasks.detachSelected\")}\\` | ${detachSelected.description} (while /tasks is open) |\n`;\n}\n\n/**\n * Ask before tree navigation cancels running tasks: results are saved on their launch branch,\n * so leaving it stops them. Resolves true when navigation may continue.\n */\nexport async function confirmStopBranchTasks(\n\tstopped: readonly TaskSnapshot[],\n\tconfirm: (title: string, message: string) => Promise<boolean>,\n): Promise<boolean> {\n\tif (stopped.length === 0) return true;\n\tconst shown = stopped.slice(0, 5).map((task) => ` ${cleanTaskText(firstCommandLine(task.command ?? task.title))}`);\n\tif (stopped.length > shown.length) shown.push(` …and ${stopped.length - shown.length} more`);\n\treturn confirm(\n\t\t`Stop ${stopped.length} running task${stopped.length === 1 ? \"\" : \"s\"}?`,\n\t\t`They were started on the branch you are leaving and will be cancelled:\\n${shown.join(\"\\n\")}`,\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOjF,MAAM,WAAW,OAAO;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,GAAG,EAAE;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,kBAAkB,CAAA;CAAE,GAAG,OAAO,CA8FzF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAqB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC,wEAAwE;AACxE,MA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AAS,EAAE,EAAE,CAAC;YACd,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAClB,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,GAAG,EAAE;oBAClB,IAAI,SAAS,KAAK,KAAK;wBAAE,SAAS,GAAG,SAAS,CAAC;oBAC/C,IAAI,EAAE,CAAC;gBACR,CAAC,CAAC;gBACF,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO,IAAI,SAAS,CAAC;oBACpB,KAAK;oBACL,GAAG;oBACH,KAAK;oBACL,WAAW;oBACX,IAAI,EAAE,GAAG,CAAC,KAAK;oBACf,OAAO,EAAE,KAAK;iBACd,CAAC,CAAC;YACJ,CAAC,EACD,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CACzF,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { getKeybindings } from \"@earendil-works/pi-tui\";\nimport type { ExtensionUIContext } from \"../../../core/extensions/types.ts\";\nimport { isTaskTerminal, type TasksContext } from \"../../../core/tasks/types.ts\";\nimport { TASKS_DETACH_HINT_DELAY_MS } from \"../../../core/tools/tasks/constants.ts\";\nimport { keyLabel } from \"../components/keybinding-hints.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { TasksMenu } from \"./manager.ts\";\nimport type { TasksPanelState } from \"./model.ts\";\n\nexport interface TasksUI {\n\topen(): Promise<void>;\n\tdispose(): void;\n}\n\n/** Host-owned task UI; it is available without loading an extension. */\nexport function bindTasksUI(ctx: { tasks: TasksContext; ui: ExtensionUIContext }): TasksUI {\n\tconst state: TasksPanelState = { tab: \"output\" };\n\tlet unsubscribe: (() => void) | undefined;\n\tlet unsubscribeDetachKey: (() => void) | undefined;\n\tlet closeMenu: (() => void) | undefined;\n\tlet hintTimer: ReturnType<typeof setTimeout> | undefined;\n\tconst start = () => {\n\t\tunsubscribe?.();\n\t\tunsubscribeDetachKey?.();\n\t\tconst update = () => {\n\t\t\tclearTimeout(hintTimer);\n\t\t\thintTimer = undefined;\n\t\t\tconst all = ctx.tasks.list();\n\t\t\tconst background = all.filter((task) => task.mode === \"background\" && !isTaskTerminal(task.status)).length;\n\t\t\tconst parts: string[] = [];\n\t\t\tif (background) {\n\t\t\t\tparts.push(theme.fg(\"text\", `${background} background task${background === 1 ? \"\" : \"s\"}`));\n\t\t\t\tparts.push(theme.fg(\"accent\", \"/tasks\") + theme.fg(\"muted\", \" to view\"));\n\t\t\t}\n\t\t\t// Teach the detach key once something has run long enough to be worth moving, and\n\t\t\t// only while it can move, independently of the background task summary.\n\t\t\tconst detachKey = keyLabel(\"app.tasks.detach\");\n\t\t\tconst now = Date.now();\n\t\t\tconst movable = all.filter((task) => ctx.tasks.canDetach(task.id));\n\t\t\tconst waits = movable\n\t\t\t\t.map((task) => task.startedAt + TASKS_DETACH_HINT_DELAY_MS - now)\n\t\t\t\t.filter((wait) => wait > 0);\n\t\t\tif (detachKey && movable.length > waits.length)\n\t\t\t\tparts.push(theme.fg(\"accent\", detachKey) + theme.fg(\"muted\", \" to run in background\"));\n\t\t\tif (detachKey && waits.length > 0) {\n\t\t\t\t// The service notifies on state changes, not on time, so wake up when the next\n\t\t\t\t// execution crosses the threshold.\n\t\t\t\thintTimer = setTimeout(update, Math.min(...waits));\n\t\t\t\thintTimer.unref?.();\n\t\t\t}\n\t\t\tctx.ui.setStatus(\"background\", parts.length ? parts.join(theme.fg(\"dim\", \" · \")) : undefined);\n\t\t};\n\t\tunsubscribe = ctx.tasks.subscribe(update);\n\t\tunsubscribeDetachKey = ctx.ui.onTerminalInput((data) => {\n\t\t\tif (!getKeybindings().matches(data, \"app.tasks.detach\")) return undefined;\n\t\t\tlet count: number;\n\t\t\ttry {\n\t\t\t\tcount = ctx.tasks.detachForeground();\n\t\t\t} catch (error) {\n\t\t\t\t// Work could move, but every background slot is taken.\n\t\t\t\tctx.ui.notify(error instanceof Error ? error.message : String(error), \"warning\");\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\t// Nothing can move: let the key fall through to editor bindings instead of\n\t\t\t// spending it on a \"nothing happened\" status line.\n\t\t\tif (count === 0) return undefined;\n\t\t\tctx.ui.notify(\n\t\t\t\t`Moved ${count} execution${count === 1 ? \"\" : \"s\"} to the background. Use /tasks to manage tasks.`,\n\t\t\t);\n\t\t\treturn { consume: true };\n\t\t});\n\t\tupdate();\n\t};\n\tconst dispose = () => {\n\t\tunsubscribe?.();\n\t\tunsubscribe = undefined;\n\t\tunsubscribeDetachKey?.();\n\t\tunsubscribeDetachKey = undefined;\n\t\tclearTimeout(hintTimer);\n\t\thintTimer = undefined;\n\t\tcloseMenu?.();\n\t\tcloseMenu = undefined;\n\t\tctx.ui.setStatus(\"background\", undefined);\n\t};\n\tstart();\n\treturn {\n\t\tdispose,\n\t\topen: async () => {\n\t\t\tcloseMenu?.();\n\t\t\tawait ctx.ui.custom<void>(\n\t\t\t\t(tui, theme, keybindings, done) => {\n\t\t\t\t\tconst close = () => {\n\t\t\t\t\t\tif (closeMenu === close) closeMenu = undefined;\n\t\t\t\t\t\tdone();\n\t\t\t\t\t};\n\t\t\t\t\tcloseMenu = close;\n\t\t\t\t\treturn new TasksMenu({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\ttui,\n\t\t\t\t\t\ttheme,\n\t\t\t\t\t\tkeybindings,\n\t\t\t\t\t\thost: ctx.tasks,\n\t\t\t\t\t\tonClose: close,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t{ overlay: true, overlayOptions: { anchor: \"center\", width: \"100%\", maxHeight: \"100%\" } },\n\t\t\t);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tasks/inspector.ts"],"names":[],"mappings":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EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO;QACN,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import type { TaskRead, TaskSnapshot, TasksContext } from \"../../../core/tasks/types.ts\";\nimport { isTaskTerminal } from \"../../../core/tasks/types.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\nimport type { TasksTab } from \"./model.ts\";\nimport { cleanTaskText } from \"./text.ts\";\nimport { TaskViewport } from \"./viewport.ts\";\nimport { type TaskLines, taskLines } from \"./views.ts\";\n\ninterface ReadingPosition {\n\tinfo: TaskViewport;\n\toutput: TaskViewport;\n\tread?: TaskRead;\n}\ninterface InspectorOptions {\n\thost: Pick<TasksContext, \"read\" | \"retain\">;\n\ttheme: Theme;\n\trequestRender(): void;\n}\n\n/** Owns the selected task's bounded reads. Reading never acknowledges completion delivery. */\nexport class TaskInspector {\n\ttask?: TaskSnapshot;\n\tprivate readonly options: InspectorOptions;\n\tprivate readonly positions = new Map<string, ReadingPosition>();\n\tprivate release?: () => void;\n\tprivate reading = false;\n\tprivate disposed = false;\n\t/** Snapshots are immutable, so identity tells when the lines must be rebuilt. */\n\tprivate cache?: { task: TaskSnapshot; read?: TaskRead; lines: TaskLines };\n\tconstructor(options: InspectorOptions) {\n\t\tthis.options = options;\n\t}\n\tget position(): ReadingPosition {\n\t\tconst id = this.task?.id;\n\t\tlet position = id ? this.positions.get(id) : undefined;\n\t\tif (!position) {\n\t\t\tposition = { info: new TaskViewport(), output: new TaskViewport(true) };\n\t\t\tif (id) this.positions.set(id, position);\n\t\t}\n\t\treturn position;\n\t}\n\tselect(task: TaskSnapshot | undefined): void {\n\t\tif (this.disposed) return;\n\t\tif (this.task?.id !== task?.id) {\n\t\t\tconst release = task ? this.options.host.retain(task.id) : undefined;\n\t\t\tconst previous = this.release;\n\t\t\tthis.release = release;\n\t\t\tprevious?.();\n\t\t}\n\t\tthis.task = task;\n\t}\n\tprune(ids: ReadonlySet<string>): void {\n\t\tfor (const id of this.positions.keys()) if (!ids.has(id)) this.positions.delete(id);\n\t}\n\tinvalidate(): void {\n\t\tthis.cache = undefined;\n\t}\n\tasync refresh(): Promise<void> {\n\t\tconst task = this.task;\n\t\tif (this.disposed || !task || this.reading) return;\n\t\tconst position = this.position;\n\t\tif (position.read && (!position.output.follow || isTaskTerminal(position.read.task.status))) return;\n\t\tthis.reading = true;\n\t\ttry {\n\t\t\tconst read = await this.options.host.read(task.id, { mode: \"tail\", bytes: 48 * 1024 });\n\t\t\tif (this.disposed || this.task?.id !== task.id || (!position.output.follow && position.read)) return;\n\t\t\tposition.read = read;\n\t\t} catch (error) {\n\t\t\tif (!this.disposed && this.task?.id === task.id && (position.output.follow || !position.read)) {\n\t\t\t\tposition.read = {\n\t\t\t\t\ttask,\n\t\t\t\t\ttext: \"\",\n\t\t\t\t\treadError: `Cannot read output: ${cleanTaskText(String(error))}`,\n\t\t\t\t\ttotalBytes: 0,\n\t\t\t\t\ttruncated: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.reading = false;\n\t\t\tif (!this.disposed) this.options.requestRender();\n\t\t\tif (!this.disposed && this.task?.id !== task.id) await this.refresh();\n\t\t}\n\t}\n\tlines(tab: TasksTab): string[] {\n\t\tconst task = this.task;\n\t\tif (!task) return [];\n\t\tconst read = this.position.read;\n\t\tif (this.cache?.task !== task || this.cache.read !== read)\n\t\t\tthis.cache = { task, read, lines: taskLines(task, read, this.options.theme) };\n\t\treturn this.cache.lines[tab];\n\t}\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.release?.();\n\t\tthis.release = undefined;\n\t\tthis.positions.clear();\n\t}\n}\n"]}
|