@pi-unipi/background-tasks 2.20.1 → 2.20.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/package.json +2 -2
- package/src/index.ts +13 -1
- package/src/tools.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/background-tasks",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.3",
|
|
4
4
|
"description": "Background tasks for UniPi — durable shell jobs and delegated background agents with a footer dock",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@earendil-works/pi-ai": "^0.84.0",
|
|
13
|
-
"@pi-unipi/core": "2.20.
|
|
13
|
+
"@pi-unipi/core": "2.20.3",
|
|
14
14
|
"turndown": "^7.2.4"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
13
|
-
import { createSpinnerLine } from "@pi-unipi/core";
|
|
13
|
+
import { createSpinnerLine, setHerdrWorking } from "@pi-unipi/core";
|
|
14
14
|
import { loadBackgroundTasksConfig } from "./config.js";
|
|
15
15
|
import { BackgroundTaskRegistry } from "./registry.js";
|
|
16
16
|
import {
|
|
@@ -134,9 +134,21 @@ export default function backgroundTasksExtension(pi: ExtensionAPI): void {
|
|
|
134
134
|
{ placement: "aboveEditor" },
|
|
135
135
|
);
|
|
136
136
|
wakeLineInstalled = true;
|
|
137
|
+
// The pane is not done: a running task will re-invoke the agent. Keep
|
|
138
|
+
// herdr at `working` instead of `idle` for exactly as long as the wake
|
|
139
|
+
// line is up (one claim transition per widget install, not per tick).
|
|
140
|
+
const wakeCount = registry
|
|
141
|
+
.allTasks()
|
|
142
|
+
.filter((task) => task.status === "running" && task.triggerOnCompletion).length;
|
|
143
|
+
setHerdrWorking(
|
|
144
|
+
pi,
|
|
145
|
+
"bg-wake",
|
|
146
|
+
`${wakeCount === 1 ? "1 bg task" : `${String(wakeCount)} bg tasks`} will resume agent`,
|
|
147
|
+
);
|
|
137
148
|
} else if (!wantWakeLine && wakeLineInstalled) {
|
|
138
149
|
target.ui.setWidget("background-tasks", undefined);
|
|
139
150
|
wakeLineInstalled = false;
|
|
151
|
+
setHerdrWorking(pi, "bg-wake", null);
|
|
140
152
|
}
|
|
141
153
|
if (running.length === 0 && unseenFinishedCount === 0) {
|
|
142
154
|
target.ui.setStatus("background-tasks", undefined);
|
package/src/tools.ts
CHANGED
|
@@ -52,13 +52,13 @@ export const BgRunParams = Type.Object({
|
|
|
52
52
|
notifyOnCompletion: Type.Optional(
|
|
53
53
|
Type.Boolean({
|
|
54
54
|
description:
|
|
55
|
-
"Deliver a durable terminal notification when the task finishes. Default true.
|
|
55
|
+
"Deliver a durable terminal notification when the task finishes. Default true for finite tasks. Set false or pair with triggerOnCompletion:false for persistent servers/daemons/watchers.",
|
|
56
56
|
}),
|
|
57
57
|
),
|
|
58
58
|
triggerOnCompletion: Type.Optional(
|
|
59
59
|
Type.Boolean({
|
|
60
60
|
description:
|
|
61
|
-
"Start a follow-up agent turn on terminal notification. Default true for
|
|
61
|
+
"Start a follow-up agent turn on terminal notification. Default true for finite tasks (tests, builds, exports). MUST set false for persistent background services/servers (e.g. dev servers, watchers) so the harness and subagents do not wait indefinitely for the server to finish. Requires notifyOnCompletion.",
|
|
62
62
|
}),
|
|
63
63
|
),
|
|
64
64
|
});
|
|
@@ -185,14 +185,14 @@ export function registerToolsAndCommands(options: RegisterSurfaceOptions): void
|
|
|
185
185
|
promptSnippet:
|
|
186
186
|
"Start a named long-running shell command; default terminal notification wakes a follow-up turn, so yield instead of polling",
|
|
187
187
|
promptGuidelines: [
|
|
188
|
-
"Use bg_run instead of bash for commands expected to run
|
|
188
|
+
"Use bg_run instead of bash for commands expected to run in the background (test suites, builds, dev servers, watchers).",
|
|
189
|
+
"For FINITE tasks (tests, builds, exports, scripts): leave triggerOnCompletion:true and notifyOnCompletion:true (defaults) to automatically wake the agent when finished.",
|
|
190
|
+
"For PERSISTENT servers/daemons/watchers (e.g. 'npm run dev', vite, live dev servers, background listeners): MUST set triggerOnCompletion:false (and optionally notifyOnCompletion:false) so the agent and sidekick do not wait for the server to exit.",
|
|
189
191
|
"Set isAgent:true only when the background task launches an LLM/agent process; false for scripts, tests, dev servers, sleeps.",
|
|
190
192
|
"Always set name to a concise 2-6 word human-readable label; do not use the raw command as the name.",
|
|
191
|
-
"bg_run returns immediately.
|
|
192
|
-
"After a default bg_run launch, continue only independent useful work that does not merely wait for the task; otherwise briefly acknowledge it if useful, then end the current turn. Do not call sleep, bg_status, or bg_logs merely to wait; the terminal notification will wake you.",
|
|
193
|
+
"bg_run returns immediately. For finite tasks with default wake-up, continue only independent useful work that does not merely wait for the task; otherwise end the current turn. Do not call sleep, bg_status, or bg_logs merely to wait; the terminal notification will wake you.",
|
|
193
194
|
"A running result is not an instruction to poll again.",
|
|
194
195
|
"Treat <background-task-notification> as durable terminal truth. Do not call bg_status to reconfirm it.",
|
|
195
|
-
"Do not set notifyOnCompletion:false or triggerOnCompletion:false unless intentionally opting out.",
|
|
196
196
|
],
|
|
197
197
|
parameters: BgRunParams,
|
|
198
198
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|