@pi-unipi/background-tasks 2.20.2 → 2.20.4

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. 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.2",
3
+ "version": "2.20.4",
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.2",
13
+ "@pi-unipi/core": "2.20.4",
14
14
  "turndown": "^7.2.4"
15
15
  },
16
16
  "devDependencies": {
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. Do not disable unless opting out of completion handling.",
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 bg_run. Requires notifyOnCompletion.",
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 for a long time, such as test suites, dev servers, watchers, or builds.",
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. With notifyOnCompletion:true and triggerOnCompletion:true (both defaults), completed, failed, or killed terminal state is delivered as <background-task-notification> and automatically starts a follow-up agent turn.",
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) {