paseo-follow-up 1.4.0-beta.36 → 1.4.0-beta.39

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/README.md CHANGED
@@ -238,7 +238,7 @@ This replaces the separate **Wait** plugin (`paseo-wait`). While that plugin is
238
238
  Install the beta:
239
239
 
240
240
  ```sh
241
- paseo plugin update follow-through --version 1.4.0-beta.36
241
+ paseo plugin update follow-through --version 1.4.0-beta.39
242
242
  # or, for a fresh install:
243
243
  paseo plugin install npm:paseo-follow-up@beta
244
244
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "1.4.0-beta.36",
4
+ "version": "1.4.0-beta.39",
5
5
  "description": "Follow every workspace PR stack in Paseo, answer agent questions, batch repairs for the main agent, and see what needs you.",
6
6
  "type": "module",
7
7
  "files": [
@@ -18,15 +18,24 @@ import { runnerSource } from "./wait-runner-source";
18
18
  */
19
19
  export const DEFAULT_WAIT_SECONDS = 30;
20
20
  export const HARD_MAX_WAIT_SECONDS = 60;
21
+ /** A prepared job's time limit: 3 h unless the agent asks for another, at most 12 h. The runner stops it after that. */
22
+ export const DEFAULT_JOB_TIMEOUT_SECONDS = 3 * 3600;
23
+ export const MAX_JOB_TIMEOUT_SECONDS = 12 * 3600;
24
+ export const prepareInput = z.object({
25
+ description: z.string().min(1).max(240),
26
+ command: z.string().min(1).max(32000),
27
+ timeoutSeconds: z.number().int().min(1).max(MAX_JOB_TIMEOUT_SECONDS).optional(),
28
+ }).strict();
21
29
  export const waitInput = z.object({
22
30
  jobId: z.string().uuid(),
23
31
  max_wait_seconds: z.number().int().min(1).max(HARD_MAX_WAIT_SECONDS).default(DEFAULT_WAIT_SECONDS),
24
32
  }).strict();
25
33
  const metadataSchema = z.object({ version: z.literal(1), id: z.string().uuid(), agentId: z.string(), cwd: z.string(), description: z.string(), createdAt: z.string() }).strict();
26
- const resultSchema = z.object({ exitCode: z.number().int().min(0).max(255) }).strict();
34
+ const resultSchema = z.object({ exitCode: z.number().int().min(0).max(255), timedOut: z.literal(true).optional() }).strict();
27
35
 
28
36
  export interface Owner { id: string; cwd: string }
29
- export interface JobStatus { jobId: string; status: "prepared" | "running" | "completed" | "failed"; description: string; createdAt: string; exitCode?: number }
37
+ /** `timedOut`: the runner stopped the command at its time limit (exit 124). */
38
+ export interface JobStatus { jobId: string; status: "prepared" | "running" | "completed" | "failed"; description: string; createdAt: string; exitCode?: number; timedOut?: true }
30
39
  export type WaitResult = JobStatus & { outcome: "completed" | "failed" | "still_pending" | "new_message"; waitedSeconds: number; instruction: string };
31
40
 
32
41
  const quote = (value: string) => "'" + value.replaceAll("'", "'\\''") + "'";
@@ -50,7 +59,8 @@ export class WaitJobs {
50
59
  }
51
60
 
52
61
  /** Writes the job record and returns the exact command to run. Runs nothing. */
53
- async prepare(owner: Owner, input: { description: string; command: string }) {
62
+ async prepare(owner: Owner, raw: z.input<typeof prepareInput>) {
63
+ const input = prepareInput.parse(raw);
54
64
  if (this.closed) throw new Error("Wait tools are stopping");
55
65
  const id = randomUUID();
56
66
  const path = this.path(owner, id);
@@ -61,6 +71,8 @@ export class WaitJobs {
61
71
  await rename(temporary, runner);
62
72
  const record = { version: 1, id, agentId: owner.id, cwd: owner.cwd, description: input.description, createdAt: new Date().toISOString() };
63
73
  await writeFile(join(path, "job.json"), JSON.stringify(record), { mode: 0o600, flag: "wx" });
74
+ const limit = input.timeoutSeconds ?? DEFAULT_JOB_TIMEOUT_SECONDS;
75
+ await writeFile(join(path, "timeout"), String(limit), { mode: 0o600, flag: "wx" });
64
76
  return {
65
77
  jobId: id,
66
78
  bashCommand: ["sh", runner, path, owner.cwd, input.command].map(quote).join(" "),
@@ -76,8 +88,8 @@ export class WaitJobs {
76
88
  if (record.agentId !== owner.id || record.id !== jobId || record.cwd !== owner.cwd) throw new Error("Job ownership does not match this agent and working directory");
77
89
  const base = { jobId, description: record.description, createdAt: record.createdAt };
78
90
  try {
79
- const { exitCode } = resultSchema.parse(await jsonFile(join(path, "result.json")));
80
- return { ...base, status: exitCode === 0 ? "completed" : "failed", exitCode };
91
+ const { exitCode, timedOut } = resultSchema.parse(await jsonFile(join(path, "result.json")));
92
+ return { ...base, status: exitCode === 0 ? "completed" : "failed", exitCode, ...(timedOut ? { timedOut } : {}) };
81
93
  } catch (error) { if (!missing(error)) throw error; }
82
94
  try {
83
95
  const started = await lstat(join(path, "started"));
@@ -119,6 +131,7 @@ export class WaitJobs {
119
131
  ...current, outcome, waitedSeconds: (Date.now() - started) / 1000,
120
132
  instruction: outcome === "still_pending" ? "The wait ceiling was reached. Inspect the job and its output now. If it is healthy and still needed, call wait_for_job again. Do not treat this as completion."
121
133
  : outcome === "new_message" ? "A new message arrived. Handle it before deciding whether to wait again. The underlying job was not stopped."
134
+ : current.timedOut ? "The command hit its time limit and was stopped (exit 124); it did not finish. Inspect its output, then decide whether to run it again with a longer timeoutSeconds or change it."
122
135
  : "The command exited. Inspect its output and exit code before continuing.",
123
136
  });
124
137
  };
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/build.mjs from server/wait-runner.sh.
2
- export const runnerSource = "#!/bin/sh\n# Wait (folded in from paseo-wait 0.0.1). Invoked by the agent's native Bash tool, never by the plugin worker.\n# It records \"started\" once and writes an atomic exit receipt (result.json), the only proof of completion.\nset -u\numask 077\njob_directory=$1\nworking_directory=$2\njob_command=$3\nif ! mkdir \"$job_directory/started\" 2>/dev/null; then\n echo 'This prepared job has already started; prepare a new job to run it again.' >&2\n exit 125\nfi\nfinish() {\n job_status=$?\n trap - EXIT\n printf '{\"exitCode\":%s}\\n' \"$job_status\" > \"$job_directory/result.tmp\"\n mv \"$job_directory/result.tmp\" \"$job_directory/result.json\"\n exit \"$job_status\"\n}\ntrap finish EXIT\ntrap 'exit 130' INT\ntrap 'exit 143' TERM\ncd \"$working_directory\" || exit 126\nbash -c \"$job_command\"\nexit $?\n";
2
+ export const runnerSource = "#!/bin/sh\n# Wait (folded in from paseo-wait 0.0.1). Invoked by the agent's native Bash tool, never by the plugin worker.\n# It records \"started\" once and writes an atomic exit receipt (result.json), the only proof of completion.\nset -u\numask 077\njob_directory=$1\nworking_directory=$2\njob_command=$3\nif ! mkdir \"$job_directory/started\" 2>/dev/null; then\n echo 'This prepared job has already started; prepare a new job to run it again.' >&2\n exit 125\nfi\nfinish() {\n job_status=$?\n trap - EXIT\n if [ -e \"$job_directory/timed-out\" ]; then\n printf '{\"exitCode\":%s,\"timedOut\":true}\\n' \"$job_status\" > \"$job_directory/result.tmp\"\n else\n printf '{\"exitCode\":%s}\\n' \"$job_status\" > \"$job_directory/result.tmp\"\n fi\n mv \"$job_directory/result.tmp\" \"$job_directory/result.json\"\n exit \"$job_status\"\n}\ntrap finish EXIT\ntrap 'exit 130' INT\ntrap 'exit 143' TERM\ncd \"$working_directory\" || exit 126\n# A time limit (seconds) written at prepare: the command is stopped after it (TERM, then KILL 30 s later), so a\n# job that never finishes (an unbounded poll loop) can't keep the machine busy forever. Exit 124 means it hit the\n# limit; the receipt records that. Without timeout(1) (macOS) the command runs unbounded, as before.\n#\n# GNU timeout puts itself and the command in a new process group, so a TERM sent to this runner's group (Stop,\n# Claude Code killing the background task) wouldn't reach the job, and a foreground child would hold this shell's\n# TERM trap until it exited. So timeout runs in the background and every TERM, INT or HUP is forwarded to it; timeout\n# passes it on to the command's group (and KILLs it 30 s later if it's still there). The job's stdin is /dev/null\n# (an asynchronous command's default), which a Wait job never reads.\njob_limit=$(cat \"$job_directory/timeout\" 2>/dev/null || true)\nif [ -n \"$job_limit\" ] && command -v timeout >/dev/null 2>&1; then\n # The trap is set first, so a signal that lands before timeout has started is passed on once it has.\n job_pid= job_stop=\n trap 'job_stop=1; [ -n \"$job_pid\" ] && kill -TERM \"$job_pid\" 2>/dev/null' TERM INT HUP\n timeout -k 30 \"$job_limit\" bash -c \"$job_command\" &\n job_pid=$!\n if [ -n \"$job_stop\" ]; then kill -TERM \"$job_pid\" 2>/dev/null; fi\n wait \"$job_pid\"\n job_status=$?\n # A forwarded signal interrupts wait; keep waiting until timeout itself has exited, for its real status.\n while kill -0 \"$job_pid\" 2>/dev/null; do wait \"$job_pid\"; job_status=$?; done\n # Some coreutils versions also exit 124 when timeout itself is signalled, so 124 means the limit only when nobody\n # stopped the job; a stopped job reports 143 (TERM), like the unbounded path.\n if [ -n \"$job_stop\" ]; then\n if [ \"$job_status\" -eq 124 ]; then job_status=143; fi\n elif [ \"$job_status\" -eq 124 ]; then\n : > \"$job_directory/timed-out\"\n fi\n exit \"$job_status\"\nfi\nbash -c \"$job_command\"\nexit $?\n";
@@ -13,7 +13,11 @@ fi
13
13
  finish() {
14
14
  job_status=$?
15
15
  trap - EXIT
16
- printf '{"exitCode":%s}\n' "$job_status" > "$job_directory/result.tmp"
16
+ if [ -e "$job_directory/timed-out" ]; then
17
+ printf '{"exitCode":%s,"timedOut":true}\n' "$job_status" > "$job_directory/result.tmp"
18
+ else
19
+ printf '{"exitCode":%s}\n' "$job_status" > "$job_directory/result.tmp"
20
+ fi
17
21
  mv "$job_directory/result.tmp" "$job_directory/result.json"
18
22
  exit "$job_status"
19
23
  }
@@ -21,5 +25,35 @@ trap finish EXIT
21
25
  trap 'exit 130' INT
22
26
  trap 'exit 143' TERM
23
27
  cd "$working_directory" || exit 126
28
+ # A time limit (seconds) written at prepare: the command is stopped after it (TERM, then KILL 30 s later), so a
29
+ # job that never finishes (an unbounded poll loop) can't keep the machine busy forever. Exit 124 means it hit the
30
+ # limit; the receipt records that. Without timeout(1) (macOS) the command runs unbounded, as before.
31
+ #
32
+ # GNU timeout puts itself and the command in a new process group, so a TERM sent to this runner's group (Stop,
33
+ # Claude Code killing the background task) wouldn't reach the job, and a foreground child would hold this shell's
34
+ # TERM trap until it exited. So timeout runs in the background and every TERM, INT or HUP is forwarded to it; timeout
35
+ # passes it on to the command's group (and KILLs it 30 s later if it's still there). The job's stdin is /dev/null
36
+ # (an asynchronous command's default), which a Wait job never reads.
37
+ job_limit=$(cat "$job_directory/timeout" 2>/dev/null || true)
38
+ if [ -n "$job_limit" ] && command -v timeout >/dev/null 2>&1; then
39
+ # The trap is set first, so a signal that lands before timeout has started is passed on once it has.
40
+ job_pid= job_stop=
41
+ trap 'job_stop=1; [ -n "$job_pid" ] && kill -TERM "$job_pid" 2>/dev/null' TERM INT HUP
42
+ timeout -k 30 "$job_limit" bash -c "$job_command" &
43
+ job_pid=$!
44
+ if [ -n "$job_stop" ]; then kill -TERM "$job_pid" 2>/dev/null; fi
45
+ wait "$job_pid"
46
+ job_status=$?
47
+ # A forwarded signal interrupts wait; keep waiting until timeout itself has exited, for its real status.
48
+ while kill -0 "$job_pid" 2>/dev/null; do wait "$job_pid"; job_status=$?; done
49
+ # Some coreutils versions also exit 124 when timeout itself is signalled, so 124 means the limit only when nobody
50
+ # stopped the job; a stopped job reports 143 (TERM), like the unbounded path.
51
+ if [ -n "$job_stop" ]; then
52
+ if [ "$job_status" -eq 124 ]; then job_status=143; fi
53
+ elif [ "$job_status" -eq 124 ]; then
54
+ : > "$job_directory/timed-out"
55
+ fi
56
+ exit "$job_status"
57
+ fi
24
58
  bash -c "$job_command"
25
59
  exit $?
package/server/wait.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import type { AgentToolDefinition, AgentToolContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
3
- import { WaitJobs, waitInput } from "./wait-jobs";
3
+ import { WaitJobs, waitInput, prepareInput } from "./wait-jobs";
4
4
  import type { WaitStatus } from "../shared/wait";
5
5
 
6
6
  /**
@@ -61,9 +61,9 @@ export class Wait {
61
61
  this.tools = [
62
62
  {
63
63
  name: "wait_prepare_job",
64
- description: "For a finite shell command that may take a while and whose result you need before finishing (tests, builds, installs, deploy checks): prepare it here instead of running it directly. Returns jobId and bashCommand and runs nothing. Run that exact bashCommand with native Bash run_in_background=true, then call wait_for_job instead of ending your turn.",
65
- input: z.object({ description: z.string().min(1).max(240), command: z.string().min(1).max(32000) }).strict(),
66
- execute: async (input, context) => { guard(context); return json(await this.jobs.prepare(owner(context), input as { description: string; command: string })); },
64
+ description: "For a finite shell command that may take a while and whose result you need before finishing (tests, builds, installs, deploy checks): prepare it here instead of running it directly. Returns jobId and bashCommand and runs nothing. Run that exact bashCommand with native Bash run_in_background=true, then call wait_for_job instead of ending your turn. The command is stopped after timeoutSeconds (default 3 hours, at most 12); a stopped job reports timedOut.",
65
+ input: prepareInput,
66
+ execute: async (input, context) => { guard(context); return json(await this.jobs.prepare(owner(context), input as z.input<typeof prepareInput>)); },
67
67
  },
68
68
  {
69
69
  name: "wait_get_job",