pi-better-background-tasks 0.2.11 → 0.2.12

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 +1 -1
  2. package/src/tools.ts +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-background-tasks",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Pi extension for durable background shell tasks, watchers, logs, and status inspection.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/tools.ts CHANGED
@@ -103,6 +103,12 @@ const StatusActionParams = Type.Object({
103
103
  verbose: Type.Optional(Type.Boolean()),
104
104
  });
105
105
 
106
+ const BACKGROUND_ORCHESTRATION_GUIDELINES = [
107
+ "Use background tasks for genuinely long-running processes or repeated checks. Run short commands in the foreground.",
108
+ "When a structured plan is active, keep it as the coordinator ledger: launch relevant background work early, continue unblocked foreground work without polling, and update the plan after inspecting each terminal result or failure.",
109
+ "Do not treat launch as completion of the parent milestone; relevant background work must be terminal, inspected, and integrated before verification or completion.",
110
+ ];
111
+
106
112
  export function registerTools(pi: ExtensionAPI): void {
107
113
  let activeSession: BackgroundTaskCallbackOrigin | undefined;
108
114
  const getActiveSession = () => activeSession;
@@ -125,6 +131,7 @@ export function registerTools(pi: ExtensionAPI): void {
125
131
  name: "bg_task_spawn",
126
132
  label: "BG Spawn",
127
133
  description: "Start a long-running background process and return immediately with its task id. For remote work, prefer structured ssh: pass ssh:{host,user} and put the remote command in command; spawn defaults to a remote tmux session with durable local logs and real remote stop. For short synchronous remote commands that should return output now, use remote_bash from pi-better-ssh. If tmux is missing, the preset attempts to install tmux non-interactively and fails closed with operator guidance when setup cannot proceed. Explicit remote.session=direct skips tmux, but direct mode has weaker stop semantics and may leave the remote process running. Never wait or poll in the foreground.",
134
+ promptGuidelines: BACKGROUND_ORCHESTRATION_GUIDELINES,
128
135
  parameters: SpawnParams,
129
136
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
130
137
  activeSession = getCallbackOrigin(ctx);
@@ -138,6 +145,7 @@ export function registerTools(pi: ExtensionAPI): void {
138
145
  name: "bg_task_watch",
139
146
  label: "BG Watch",
140
147
  description: "Poll a command in the background until success_when, failure_when, or timeout matches. For remote work, prefer structured ssh: pass ssh:{host,user} and provide the remote command in command; each interval opens a direct one-shot SSH poll without tmux installation. For short synchronous remote commands that should return output now, use remote_bash from pi-better-ssh. Returns immediately with its task id. Default timeout 900 seconds; pass timeout_seconds:0 to disable.",
148
+ promptGuidelines: BACKGROUND_ORCHESTRATION_GUIDELINES,
141
149
  parameters: WatchParams,
142
150
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
143
151
  activeSession = getCallbackOrigin(ctx);
@@ -198,6 +206,7 @@ export function registerTools(pi: ExtensionAPI): void {
198
206
  name: "bg_task",
199
207
  label: "BG Task",
200
208
  description: "Action wrapper for background tasks: spawn, watch, list, status, log, stop, or clear. For remote work, prefer structured ssh: pass ssh:{host,user} and provide the remote command in command. For short synchronous remote commands that should return output now, use remote_bash from pi-better-ssh. SSH spawn defaults to durable tmux; SSH watches use direct one-shot polls without tmux installation; remote.session=direct is a weaker-stop spawn escape hatch. Spawn/watch return immediately; do not poll in foreground. For action:status, default compact output and use verbose:true only for full metadata. For action:log, default compact tail and use tail_lines:0 only for explicit full logs.",
209
+ promptGuidelines: BACKGROUND_ORCHESTRATION_GUIDELINES,
201
210
  parameters: ActionParams,
202
211
  renderResult(result: unknown, options: unknown, theme: unknown) {
203
212
  return renderBackgroundTaskLogDisplay(result, options, theme);