run-controller.sh bash
95 lines 2.9 KB
Raw
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e feat(hub): restore integration tile detail modals; add Herm… Human minor ⚠ breaking 15 days ago
1 #!/usr/bin/env bash
2 ######################################################################
3 # run-controller.sh
4 #
5 # Triggers the Paperclip controller agent to produce ONE long-form video
6 # package (script + MP4 + 5 shorts + blog + newsletter + 5 social captions
7 # + thumbnail) PER PROJECT. All three projects run in parallel.
8 #
9 # Usage:
10 # sudo -u paperclip /opt/paperclip/scripts/run-controller.sh \
11 # --bornfree-topic "Why faraday-bag chair safer protects newborns" \
12 # --storefree-topic "How Store Free turns receipts into AI proof" \
13 # --knowtation-topic "Why Markdown beats Notion for agent-readable notes"
14 #
15 # Output: drafts appear in vault/projects/<project>/drafts/<TODAY>-<kind>-*.md
16 # with frontmatter status='pending' for human review.
17 ######################################################################
18
19 set -euo pipefail
20
21 BORNFREE_TOPIC=""
22 STOREFREE_TOPIC=""
23 KNOWTATION_TOPIC=""
24 DRY_RUN=""
25
26 while [[ $# -gt 0 ]]; do
27 case "$1" in
28 --bornfree-topic) BORNFREE_TOPIC="$2"; shift 2 ;;
29 --storefree-topic) STOREFREE_TOPIC="$2"; shift 2 ;;
30 --knowtation-topic) KNOWTATION_TOPIC="$2"; shift 2 ;;
31 --dry-run) DRY_RUN="--dry-run"; shift ;;
32 *) echo "Unknown arg: $1"; exit 1 ;;
33 esac
34 done
35
36 if [[ -z "$BORNFREE_TOPIC" || -z "$STOREFREE_TOPIC" || -z "$KNOWTATION_TOPIC" ]]; then
37 echo "Missing required args. Example:"
38 echo " $0 \\"
39 echo " --bornfree-topic \"Why faraday-bag chair safer protects newborns\" \\"
40 echo " --storefree-topic \"How Store Free turns receipts into AI proof\" \\"
41 echo " --knowtation-topic \"Why Markdown beats Notion\""
42 exit 1
43 fi
44
45 ENV_FILE=/etc/paperclip/env
46 # shellcheck disable=SC1090
47 set -a; source "$ENV_FILE"; set +a
48
49 PAPERCLIP_BASE="${PAPERCLIP_BASE:-http://127.0.0.1:3000}"
50
51 trigger() {
52 local project="$1"
53 local topic="$2"
54 echo "[run-controller] $project → $topic"
55 curl -fsS -X POST "$PAPERCLIP_BASE/api/v1/agents/controller/run" \
56 -H "Content-Type: application/json" \
57 -d "$(cat <<EOF
58 {
59 "project": "$project",
60 "topic": $(echo "$topic" | python3 -c 'import sys,json; print(json.dumps(sys.stdin.read().strip()))'),
61 "dry_run": $([[ -n "$DRY_RUN" ]] && echo true || echo false),
62 "kinds": ["script", "social", "thumbnail", "clip", "blog", "newsletter"]
63 }
64 EOF
65 )" --max-time 60 | python3 -m json.tool || {
66 echo "[run-controller] $project FAILED"
67 return 1
68 }
69 echo ""
70 }
71
72 trigger born-free "$BORNFREE_TOPIC" &
73 PID_BF=$!
74 trigger store-free "$STOREFREE_TOPIC" &
75 PID_SF=$!
76 trigger knowtation "$KNOWTATION_TOPIC" &
77 PID_KW=$!
78
79 ANY_FAIL=0
80 wait $PID_BF || ANY_FAIL=1
81 wait $PID_SF || ANY_FAIL=1
82 wait $PID_KW || ANY_FAIL=1
83
84 if [[ "$ANY_FAIL" -ne 0 ]]; then
85 echo ""
86 echo "[run-controller] One or more projects failed. Check Paperclip logs:"
87 echo " journalctl -u paperclip.service -n 100"
88 exit 1
89 fi
90
91 echo ""
92 echo "[run-controller] All three projects triggered."
93 echo " Drafts will appear in vault/projects/<project>/drafts/ within ~30 minutes."
94 echo " Open the Hub UI to review and approve."
95 exit 0
File History 3 commits
sha256:fd47ab66017e55331b88ba3a59c34c23e4e05c5aec424251d3a404c5a7998c8e feat(hub): restore integration tile detail modals; add Herm… Human minor 15 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 15 days ago