#!/usr/bin/env bash
# Run from each installed checkout with its isolated dev server running.
# Usage: bash reproduce.sh seed <empty-project-directory>
# Then open the printed thread in the web client, stop the initial goal turn
# while the goal remains active, before starting the delegated child, hide the
# thread details panel and sidebar, and start a browser recording at 1280x800, light theme.
# Usage: bash reproduce.sh delegate <thread-id>
# Record until the child finishes and the parent wakes; do not intervene.
# Fresh dev server: T3CODE_DEV_SEED=0 vp run dev
# Enable the Claude provider in Settings > Providers before seeding.
# Both captures use Linux Chromium, 1280x800 CSS pixels, light theme.
# The background flag below is required by Claude Code's standalone-sleep guard.
set -euo pipefail
case "$1" in
seed)
  node apps/server/src/bin.ts project add --base-dir .t3 --title 'Delegated goal proof' "$2"
  node apps/server/src/bin.ts thread start --base-dir .t3 --title 'Goal completion wake' --provider claudeAgent --model claude-haiku-5-5 --json "$2" '/goal The delegated child has completed and reported DONE'
  ;;
delegate)
  node apps/server/src/bin.ts thread send --base-dir .t3 --json "$2" - <<'PROMPT'
Ignore other Claude sessions on this machine; do not use ListAgents or SendMessage. Use the T3 Code delegate_task MCP tool to start ONE asynchronous child task on Claude Haiku 5.5. The child's task: run `sleep 100` using its native Bash tool with run_in_background:true (required by this environment's sleep policy), then use TaskOutput with block:true to wait for that command to finish, then reply with exactly DONE. After starting the child, end your parent turn right away. Do not poll, wait, inspect task status, or run any shell command yourself. T3 Code will wake this thread when the child completes. Do not mark the goal complete before that wake.
PROMPT
  ;;
esac
