Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(skills): add wrapper-level timeout control

cyh0afed15b44eb
diff --git a/skills/background-watch-hook/SKILL.md b/skills/background-watch-hook/SKILL.md
index c8f2df4d3..e526ecd20 100644
--- a/skills/background-watch-hook/SKILL.md
+++ b/skills/background-watch-hook/SKILL.md
@@ -74,6 +74,7 @@ The wrapper interface is:
scripts/watch_then_hook.sh \
--session-key "<session-key>" \
[--prefix "<hook prefix>"] \
+ [--timeout 21600] \
[--log-file "/tmp/watch.log"] \
[--foreground] \
[--post-to channel] \
@@ -88,6 +89,8 @@ scripts/watch_then_hook.sh \
Required. Delivery target for the follow-up hook.
- `--prefix`
Optional. Prepended to the waiter output inside the generated prompt file.
+- `--timeout`
+ Optional. Overall wait timeout in seconds. Default is `21600` (6 hours). Use `0` for no timeout.
- `--log-file`
Optional. Background log destination. If omitted, the wrapper picks a file under `/tmp/`.
- `--foreground`
@@ -121,6 +124,8 @@ That command returns immediately, leaves the watcher running in the background,
If you need the old low-level synchronous primitive, add `--foreground`.
+If the waiter does not finish within the wrapper timeout, the wrapper still sends a hook with a timeout summary instead of failing silently.
+
When running inside the Vibe Remote repo or worktree, the wrapper will auto-fallback to `uv run python -m vibe` if the `vibe` executable on `PATH` is not the real CLI.
Use a thin convenience wrapper like `watch_github_pr_then_hook.sh` only when it materially shortens a common case.
@@ -170,6 +175,8 @@ Design waiters to follow this contract:
- `exit 0`: event detected; final summary printed to `stdout`
- `exit 124`: timeout; the wrapper sends a timeout hook with an error summary
+- wrapper timeout:
+ by default the wrapper itself times out the waiter after 6 hours and emits the same timeout hook path
- any other non-zero exit: failure; wrapper should exit without sending a hook
Good waiter output is compact and already useful to the next turn, for example:
diff --git a/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh b/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh
index 03fd2e208..b2f32b118 100755
--- a/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh
+++ b/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh
@@ -170,6 +170,9 @@ fi
wrapper_args=("$WRAPPER" --session-key "$session_key" --prefix "$prefix")
+if [[ -n "$timeout" ]]; then
+ wrapper_args+=(--timeout "$timeout")
+fi
if [[ -n "$log_file" ]]; then
wrapper_args+=(--log-file "$log_file")
fi
diff --git a/skills/background-watch-hook/scripts/watch_then_hook.sh b/skills/background-watch-hook/scripts/watch_then_hook.sh
index 0cc0dd1f6..0a236ab26 100755
--- a/skills/background-watch-hook/scripts/watch_then_hook.sh
+++ b/skills/background-watch-hook/scripts/watch_then_hook.sh
@@ -9,6 +9,7 @@ Usage:
Options:
--session-key <value> Required. Target session key for vibe hook send.
--prefix <value> Optional. Text prepended before waiter stdout.
+ --timeout <seconds> Optional. Overall waiter timeout. Default: 21600 (6 hours), 0 means forever.
--post-to <value> Optional. Passed through to vibe hook send.
--deliver-key <value> Optional. Explicit delivery target key for vibe hook send.
--log-file <path> Optional. Background log file path when detaching.
@@ -30,6 +31,7 @@ EOF
session_key=""
prefix=""
+timeout_seconds="21600"
post_to=""
deliver_key=""
log_file=""
@@ -48,6 +50,10 @@ while [[ $# -gt 0 ]]; do
prefix="${2:-}"
shift 2
;;
+ --timeout)
+ timeout_seconds="${2:-21600}"
+ shift 2
+ ;;
--post-to)
post_to="${2:-}"
shift 2
@@ -207,6 +213,7 @@ if [[ "$foreground" -ne 1 ]]; then
--foreground
--session-key "$session_key"
--hook-cmd "$hook_runner"
+ --timeout "$timeout_seconds"
--timeout-exit-code "$timeout_exit_code"
)
@@ -236,8 +243,29 @@ started_at_epoch="$(date +%s)"
timed_out=0
set +e
-"$@" >"$output_file"
-waiter_status=$?
+if [[ "$timeout_seconds" == "0" ]]; then
+ "$@" >"$output_file"
+ waiter_status=$?
+else
+ python3 - "$output_file" "$timeout_seconds" "$timeout_exit_code" "$@" <<'PY'
+import subprocess
+import sys
+
+output_path = sys.argv[1]
+timeout_seconds = float(sys.argv[2])
+timeout_exit_code = int(sys.argv[3])
+command = sys.argv[4:]
+
+with open(output_path, "wb") as output_file:
+ try:
+ result = subprocess.run(command, stdout=output_file, timeout=timeout_seconds, check=False)
+ except subprocess.TimeoutExpired:
+ sys.exit(timeout_exit_code)
+
+sys.exit(result.returncode)
+PY
+ waiter_status=$?
+fi
set -e
if [[ "$waiter_status" -eq "$timeout_exit_code" ]]; then