@astrofoundry/astrogate 0.1.9 → 0.1.10
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/cli/astrogate.sh +24 -1
- package/cli/astrogate.test.ts +8 -1
- package/cli/workspace.sh +213 -5
- package/cli/workspace.test.ts +49 -2
- package/package.json +1 -1
- package/release.sha256 +5 -5
- package/release.sha256.sig +2 -2
package/cli/astrogate.sh
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
# and gate files, and the keys user's Vaultwarden login (asked once)
|
|
14
14
|
# astrogate workspace list the workspaces on this host
|
|
15
15
|
# sudo astrogate pack update <ws> <x.y.z> the workspace's signed pack from /private/var/tmp/astrogate-packs
|
|
16
|
+
# sudo astrogate bridge install <ws> the workspace bridge's launchd service, not started
|
|
17
|
+
# sudo astrogate bridge config <ws> --from <folder>
|
|
18
|
+
# copies config.json and the tokens from a bridge folder
|
|
19
|
+
# sudo astrogate bridge start|stop|restart <ws>
|
|
16
20
|
# astrogate doctor read-only checks; exits 1 when one fails
|
|
17
21
|
#
|
|
18
22
|
# The first install runs this script from a tarball the owner checked with the repo's
|
|
@@ -35,7 +39,7 @@ REGISTRY=https://registry.npmjs.org
|
|
|
35
39
|
TOOL_NAMES="node jq bw python gcloud"
|
|
36
40
|
|
|
37
41
|
usage() {
|
|
38
|
-
echo "usage: astrogate core [status] | core update [<x.y.z>] [--signers <allowed_signers>] | core rollback | tools | workspace create <ws> | workspace list | pack update <ws> <x.y.z> | doctor" >&2
|
|
42
|
+
echo "usage: astrogate core [status] | core update [<x.y.z>] [--signers <allowed_signers>] | core rollback | tools | workspace create <ws> | workspace list | pack update <ws> <x.y.z> | bridge install|start|stop|restart <ws> | bridge config <ws> --from <folder> | doctor" >&2
|
|
39
43
|
exit 2
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -73,6 +77,7 @@ action=""
|
|
|
73
77
|
version=""
|
|
74
78
|
signers_arg=""
|
|
75
79
|
ws=""
|
|
80
|
+
from=""
|
|
76
81
|
invocation="$*"
|
|
77
82
|
case "${1:-}" in
|
|
78
83
|
core)
|
|
@@ -120,6 +125,18 @@ case "${1:-}" in
|
|
|
120
125
|
ws=$3
|
|
121
126
|
version=$4
|
|
122
127
|
;;
|
|
128
|
+
bridge)
|
|
129
|
+
case "${2:-}" in
|
|
130
|
+
install | start | stop | restart) [ $# -eq 3 ] || usage ;;
|
|
131
|
+
config)
|
|
132
|
+
[ $# -eq 5 ] && [ "$4" = --from ] && [ -n "$5" ] || usage
|
|
133
|
+
from=$5
|
|
134
|
+
;;
|
|
135
|
+
*) usage ;;
|
|
136
|
+
esac
|
|
137
|
+
action=bridge-$2
|
|
138
|
+
ws=$3
|
|
139
|
+
;;
|
|
123
140
|
*) usage ;;
|
|
124
141
|
esac
|
|
125
142
|
|
|
@@ -475,6 +492,7 @@ core_activate() {
|
|
|
475
492
|
echo "linked $ENTRY"
|
|
476
493
|
fi
|
|
477
494
|
echo "core ${current:-none} -> $version${current:+; astrogate core rollback goes back to $current}"
|
|
495
|
+
for w in $(workspaces); do restart_bridge_when_idle "$w" 1800; done
|
|
478
496
|
}
|
|
479
497
|
|
|
480
498
|
core_rollback() {
|
|
@@ -487,6 +505,7 @@ core_rollback() {
|
|
|
487
505
|
switch_to "$previous"
|
|
488
506
|
link_tools "$BASE/current"
|
|
489
507
|
echo "core $current -> $previous; astrogate core rollback again goes forward"
|
|
508
|
+
for w in $(workspaces); do restart_bridge_when_idle "$w" 1800; done
|
|
490
509
|
}
|
|
491
510
|
|
|
492
511
|
# --- doctor ---------------------------------------------------------------
|
|
@@ -565,6 +584,7 @@ doctor() {
|
|
|
565
584
|
if [ -n "$previous" ] && [ -d "$BASE/versions/$previous" ]; then ok "previous core $previous kept for rollback"; else warn "no previous core to roll back to"; fi
|
|
566
585
|
if [ "$(/usr/bin/readlink "$COMMAND" 2>/dev/null || true)" = "$BASE/current/cli/astrogate.sh" ]; then ok "$COMMAND"; else bad "$COMMAND does not link to $BASE/current/cli/astrogate.sh"; fi
|
|
567
586
|
doctor_tools
|
|
587
|
+
doctor_workspaces
|
|
568
588
|
[ "$failed" = 0 ] || exit 1
|
|
569
589
|
}
|
|
570
590
|
|
|
@@ -577,5 +597,8 @@ case "$action" in
|
|
|
577
597
|
workspace-create) workspace_create ;;
|
|
578
598
|
workspace-list) workspace_list ;;
|
|
579
599
|
pack-update) pack_update ;;
|
|
600
|
+
bridge-install) bridge_install ;;
|
|
601
|
+
bridge-config) bridge_config ;;
|
|
602
|
+
bridge-start | bridge-stop | bridge-restart) bridge_control ;;
|
|
580
603
|
doctor) doctor ;;
|
|
581
604
|
esac
|
package/cli/astrogate.test.ts
CHANGED
|
@@ -57,6 +57,13 @@ describe("astrogate", () => {
|
|
|
57
57
|
[["pack", "update", "homelab"]],
|
|
58
58
|
[["pack", "update", "homelab", "1.2"]],
|
|
59
59
|
[["pack", "rollback", "homelab"]],
|
|
60
|
+
[["bridge"]],
|
|
61
|
+
[["bridge", "start"]],
|
|
62
|
+
[["bridge", "start", "a", "b"]],
|
|
63
|
+
[["bridge", "config", "homelab"]],
|
|
64
|
+
[["bridge", "config", "homelab", "--into", "x"]],
|
|
65
|
+
[["bridge", "config", "homelab", "--from", ""]],
|
|
66
|
+
[["bridge", "remove", "homelab"]],
|
|
60
67
|
[["update"]],
|
|
61
68
|
])("refuses %j with a usage error before anything else", (args) => {
|
|
62
69
|
const result = astrogate(...args);
|
|
@@ -64,7 +71,7 @@ describe("astrogate", () => {
|
|
|
64
71
|
expect(result.stderr).toMatch(/^usage: astrogate/);
|
|
65
72
|
});
|
|
66
73
|
|
|
67
|
-
it.runIf(isMac && !isRoot).each([["core", "update"], ["core", "update", "1.2.3", "--signers", "x"], ["core", "rollback"], ["core", "activate", "1.2.3"], ["workspace", "create", "work"], ["pack", "update", "work", "1.2.3"]])("refuses %s without root", (...args) => {
|
|
74
|
+
it.runIf(isMac && !isRoot).each([["core", "update"], ["core", "update", "1.2.3", "--signers", "x"], ["core", "rollback"], ["core", "activate", "1.2.3"], ["workspace", "create", "work"], ["pack", "update", "work", "1.2.3"], ["bridge", "install", "work"], ["bridge", "restart", "work"], ["bridge", "config", "work", "--from", "/x"]])("refuses %s without root", (...args) => {
|
|
68
75
|
const result = astrogate(...args);
|
|
69
76
|
expect(result.status).toBe(1);
|
|
70
77
|
expect(result.stderr).toContain(`run it as root: sudo astrogate ${args.join(" ")}`);
|
package/cli/workspace.sh
CHANGED
|
@@ -176,11 +176,11 @@ workspace_create() {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
workspace_list() {
|
|
179
|
-
for
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
echo "$name${pack:+ pack $pack}"
|
|
179
|
+
for name in $(workspaces); do
|
|
180
|
+
pack=$(/bin/cat "/Users/astrogate-$name/.pi/agent/pack/pack.json" 2>/dev/null | /usr/bin/sed -n 's/^ "version": "\([0-9][0-9.]*\)",\{0,1\}$/\1/p' || true)
|
|
181
|
+
bridge=stopped
|
|
182
|
+
! bridge_loaded "$name" || bridge=running
|
|
183
|
+
echo "$name${pack:+ pack $pack}, bridge $bridge"
|
|
184
184
|
done
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -441,4 +441,212 @@ pack_update() {
|
|
|
441
441
|
as_user "$agent" "$SWAP_AGENT_PACK" "$JQ" "$agent_pack" || fail "the agent side of pack $version failed; the wrappers are in, run the update again"
|
|
442
442
|
as_user "$agent" "$CLAUDE_FILES" "$NODE" "$BASE/current/dist/claude.js" >/dev/null || fail "the Claude Code files of $agent failed; run the update again"
|
|
443
443
|
echo "pack $version in workspace $ws: wrappers, config, tools, secrets, agents, skills, bridge plugin, gate, Claude Code agents${installed:+; previous $installed}"
|
|
444
|
+
restart_bridge_when_idle "$ws" 1800
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
# --- bridge -------------------------------------------------------------------
|
|
448
|
+
|
|
449
|
+
# A workspace's Discord bridge runs as its agent user under a launchd system service, so it
|
|
450
|
+
# needs no login session. The service runs the core's bridge on the core's Node; the bridge
|
|
451
|
+
# starts Pi or Claude Code from Homebrew for each task.
|
|
452
|
+
bridge_label() {
|
|
453
|
+
printf 'com.astrofoundry.astrogate.%s' "$1"
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
bridge_plist() {
|
|
457
|
+
printf '/Library/LaunchDaemons/%s.plist' "$(bridge_label "$1")"
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
bridge_loaded() {
|
|
461
|
+
/bin/launchctl print "system/$(bridge_label "$1")" >/dev/null 2>&1
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
# The service definition for workspace $1 with home $2.
|
|
465
|
+
bridge_plist_text() {
|
|
466
|
+
cat <<PLIST
|
|
467
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
468
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
469
|
+
<plist version="1.0">
|
|
470
|
+
<dict>
|
|
471
|
+
<key>Label</key><string>$(bridge_label "$1")</string>
|
|
472
|
+
<key>UserName</key><string>astrogate-$1</string>
|
|
473
|
+
<key>GroupName</key><string>staff</string>
|
|
474
|
+
<key>ProgramArguments</key>
|
|
475
|
+
<array>
|
|
476
|
+
<string>$NODE</string>
|
|
477
|
+
<string>$BASE/current/dist/bridge.js</string>
|
|
478
|
+
</array>
|
|
479
|
+
<key>WorkingDirectory</key><string>$2</string>
|
|
480
|
+
<key>EnvironmentVariables</key>
|
|
481
|
+
<dict>
|
|
482
|
+
<key>HOME</key><string>$2</string>
|
|
483
|
+
<key>USER</key><string>astrogate-$1</string>
|
|
484
|
+
<key>PATH</key><string>/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
485
|
+
</dict>
|
|
486
|
+
<key>RunAtLoad</key><true/>
|
|
487
|
+
<key>KeepAlive</key><true/>
|
|
488
|
+
<key>ThrottleInterval</key><integer>30</integer>
|
|
489
|
+
<key>ProcessType</key><string>Background</string>
|
|
490
|
+
<key>StandardOutPath</key><string>$2/Library/Logs/astro-discord.log</string>
|
|
491
|
+
<key>StandardErrorPath</key><string>$2/Library/Logs/astro-discord.log</string>
|
|
492
|
+
</dict>
|
|
493
|
+
</plist>
|
|
494
|
+
PLIST
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
# Restarts workspace $1's bridge once it has no open work, waiting up to $2 seconds; a stopped bridge stays stopped.
|
|
498
|
+
restart_bridge_when_idle() {
|
|
499
|
+
bridge_loaded "$1" || return 0
|
|
500
|
+
busy=/Users/astrogate-$1/.config/astro-discord/busy.json
|
|
501
|
+
waited=0
|
|
502
|
+
while [ -f "$busy" ]; do
|
|
503
|
+
if [ "$waited" -ge "$2" ]; then
|
|
504
|
+
echo "the $1 bridge still has open work; restart it later: sudo astrogate bridge restart $1"
|
|
505
|
+
return 0
|
|
506
|
+
fi
|
|
507
|
+
[ "$waited" -gt 0 ] || echo "the $1 bridge has open work; waiting until it finishes"
|
|
508
|
+
/bin/sleep 10
|
|
509
|
+
waited=$((waited + 10))
|
|
510
|
+
done
|
|
511
|
+
/bin/launchctl kickstart -k "system/$(bridge_label "$1")"
|
|
512
|
+
echo "the $1 bridge restarted"
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
# Every workspace on this host, one name per line.
|
|
516
|
+
workspaces() {
|
|
517
|
+
for user in $(/usr/bin/dscl . -list /Users | /usr/bin/grep -E '^astrogate-[a-z][a-z0-9]{1,15}$'); do
|
|
518
|
+
name=${user#astrogate-}
|
|
519
|
+
! valid_workspace "$name" || printf '%s\n' "$name"
|
|
520
|
+
done
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
COPY_BRIDGE_FILES='stage=$1
|
|
524
|
+
dir="$HOME/.config/astro-discord"
|
|
525
|
+
mkdir -p "$dir" "$HOME/Library/Logs"
|
|
526
|
+
chmod 0700 "$dir"
|
|
527
|
+
for f in "$stage"/*; do
|
|
528
|
+
n=${f##*/}
|
|
529
|
+
cp "$f" "$dir/.new-$n"
|
|
530
|
+
chmod 0600 "$dir/.new-$n"
|
|
531
|
+
mv "$dir/.new-$n" "$dir/$n"
|
|
532
|
+
echo "wrote $dir/$n"
|
|
533
|
+
done'
|
|
534
|
+
|
|
535
|
+
# Copies the bridge's config.json and bot token, and Claude Code's token when present, from
|
|
536
|
+
# folder $from (such as the old bridge's ~/.config/astro-discord) into the agent user's bridge
|
|
537
|
+
# folder. Root reads them, so no one handles the token.
|
|
538
|
+
bridge_config() {
|
|
539
|
+
require_root
|
|
540
|
+
valid_workspace "$ws" || fail "no valid workspace name: $ws"
|
|
541
|
+
require_workspace
|
|
542
|
+
[ -d "$from" ] && [ ! -L "$from" ] || fail "$from is not a folder"
|
|
543
|
+
for f in config.json token; do
|
|
544
|
+
[ -f "$from/$f" ] && [ ! -L "$from/$f" ] || fail "$from/$f is missing"
|
|
545
|
+
done
|
|
546
|
+
make_work
|
|
547
|
+
files=$(user_stage "$agent")
|
|
548
|
+
for f in config.json token claude-token; do
|
|
549
|
+
[ ! -f "$from/$f" ] || [ -L "$from/$f" ] || /bin/cp "$from/$f" "$files/$f"
|
|
550
|
+
done
|
|
551
|
+
hand_stage "$agent" "$files"
|
|
552
|
+
as_user "$agent" "$COPY_BRIDGE_FILES" "$files"
|
|
553
|
+
bridge_loaded "$ws" && echo "the $ws bridge reads the config on every message; restart it for a new token: sudo astrogate bridge restart $ws" || true
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
bridge_install() {
|
|
557
|
+
require_root
|
|
558
|
+
valid_workspace "$ws" || fail "no valid workspace name: $ws"
|
|
559
|
+
require_workspace
|
|
560
|
+
require_tools
|
|
561
|
+
make_work
|
|
562
|
+
as_user "$agent" '/bin/mkdir -p "$HOME/Library/Logs"'
|
|
563
|
+
bridge_plist_text "$ws" "/Users/$agent" >"$work/bridge.plist"
|
|
564
|
+
/usr/bin/plutil -lint -s "$work/bridge.plist" || fail "the service definition does not parse"
|
|
565
|
+
plist=$(bridge_plist "$ws")
|
|
566
|
+
if [ -f "$plist" ] && /usr/bin/cmp -s "$work/bridge.plist" "$plist"; then
|
|
567
|
+
echo "$plist is current"
|
|
568
|
+
else
|
|
569
|
+
/usr/bin/install -m 0644 -o root -g wheel "$work/bridge.plist" "$plist"
|
|
570
|
+
echo "wrote $plist; the bridge starts with: sudo astrogate bridge start $ws"
|
|
571
|
+
fi
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
bridge_control() {
|
|
575
|
+
require_root
|
|
576
|
+
valid_workspace "$ws" || fail "no valid workspace name: $ws"
|
|
577
|
+
require_workspace
|
|
578
|
+
plist=$(bridge_plist "$ws")
|
|
579
|
+
[ -f "$plist" ] || fail "no bridge service for $ws: sudo astrogate bridge install $ws"
|
|
580
|
+
case "$action" in
|
|
581
|
+
bridge-start)
|
|
582
|
+
[ -f "/Users/$agent/.config/astro-discord/token" ] || fail "the $ws bridge has no token: sudo astrogate bridge config $ws --from <folder>"
|
|
583
|
+
if bridge_loaded "$ws"; then echo "the $ws bridge runs already"; else /bin/launchctl bootstrap system "$plist" && echo "the $ws bridge started"; fi
|
|
584
|
+
;;
|
|
585
|
+
bridge-stop)
|
|
586
|
+
if bridge_loaded "$ws"; then /bin/launchctl bootout "system/$(bridge_label "$ws")" && echo "the $ws bridge stopped"; else echo "the $ws bridge is not running"; fi
|
|
587
|
+
;;
|
|
588
|
+
bridge-restart)
|
|
589
|
+
bridge_loaded "$ws" || fail "the $ws bridge is not running: sudo astrogate bridge start $ws"
|
|
590
|
+
restart_bridge_when_idle "$ws" 1800
|
|
591
|
+
;;
|
|
592
|
+
esac
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
# --- doctor -------------------------------------------------------------------
|
|
596
|
+
|
|
597
|
+
# Runs as the agent user: every installed specialist answers --help through the sudo rule and the
|
|
598
|
+
# entry point, which proves the whole chain without reaching a service.
|
|
599
|
+
WRAPPERS_ANSWER='keys=$1; shift
|
|
600
|
+
failed=""
|
|
601
|
+
for s in "$@"; do
|
|
602
|
+
/usr/bin/sudo -n -u "$keys" -H /usr/local/bin/astrogate-run "$s" --caller astrogate-doctor -- --help >/dev/null 2>&1 || failed="$failed $s"
|
|
603
|
+
done
|
|
604
|
+
printf "%s" "${failed# }"'
|
|
605
|
+
|
|
606
|
+
# Checks every workspace; the details inside the homes need root.
|
|
607
|
+
doctor_workspaces() {
|
|
608
|
+
names=$(workspaces)
|
|
609
|
+
if [ -z "$names" ]; then
|
|
610
|
+
warn "no workspaces on this host"
|
|
611
|
+
return 0
|
|
612
|
+
fi
|
|
613
|
+
is_root=no
|
|
614
|
+
[ "$(/usr/bin/id -u)" != 0 ] || is_root=yes
|
|
615
|
+
for ws in $names; do
|
|
616
|
+
agent=astrogate-$ws
|
|
617
|
+
keys=astrogate-$ws-keys
|
|
618
|
+
problems=""
|
|
619
|
+
for user in "$agent" "$keys"; do
|
|
620
|
+
/usr/bin/id -u "$user" >/dev/null 2>&1 || { problems="$problems; no user $user"; continue; }
|
|
621
|
+
set -- $(/usr/bin/stat -f '%Su %Lp' "/Users/$user" 2>/dev/null || echo missing)
|
|
622
|
+
[ "$1 ${2:-}" = "$user 700" ] || problems="$problems; /Users/$user is ${1} ${2:-}, not $user 700"
|
|
623
|
+
done
|
|
624
|
+
[ -f "/etc/sudoers.d/zz-astrogate-$ws" ] || problems="$problems; no /etc/sudoers.d/zz-astrogate-$ws"
|
|
625
|
+
if [ -n "$problems" ]; then bad "workspace $ws${problems}"; continue; fi
|
|
626
|
+
bridge=stopped
|
|
627
|
+
! bridge_loaded "$ws" || bridge=running
|
|
628
|
+
[ -f "$(bridge_plist "$ws")" ] || bridge="not installed"
|
|
629
|
+
if [ "$is_root" = no ]; then
|
|
630
|
+
ok "workspace $ws: users and sudo rule, bridge $bridge (sudo astrogate doctor checks the pack and the specialists)"
|
|
631
|
+
continue
|
|
632
|
+
fi
|
|
633
|
+
gate=/Users/$agent/.pi/agent/specialists.json
|
|
634
|
+
pack=$(/usr/bin/sed -n 's/^ "version": "\([0-9][0-9.]*\)",\{0,1\}$/\1/p' "/Users/$agent/.pi/agent/pack/pack.json" 2>/dev/null || true)
|
|
635
|
+
wrappers=$(/bin/cat "/Users/$keys/.specialists/bin/VERSION" 2>/dev/null || true)
|
|
636
|
+
if [ -z "$pack" ] || [ "$pack" != "$wrappers" ]; then
|
|
637
|
+
bad "workspace $ws: the agent side has pack ${pack:-none}, the wrappers ${wrappers:-none} (astrogate pack update $ws <version>)"
|
|
638
|
+
continue
|
|
639
|
+
fi
|
|
640
|
+
services=$("$JQ" -r '.specialists[].service' "$gate" 2>/dev/null | /usr/bin/tr '\n' ' ' || true)
|
|
641
|
+
[ -n "$services" ] || { bad "workspace $ws: $gate names no specialists"; continue; }
|
|
642
|
+
secrets=$(/bin/ls "/Users/$keys/.specialists/secrets" 2>/dev/null | /usr/bin/wc -l | /usr/bin/tr -d ' ')
|
|
643
|
+
failed=$(as_user "$agent" "$WRAPPERS_ANSWER" "$keys" $services)
|
|
644
|
+
if [ -n "$failed" ]; then
|
|
645
|
+
bad "workspace $ws: pack $pack; failing --help through astrogate-run: $failed"
|
|
646
|
+
elif [ "$secrets" -eq 0 ]; then
|
|
647
|
+
bad "workspace $ws: pack $pack, but no secrets are provisioned (astrogate pack update $ws $pack)"
|
|
648
|
+
else
|
|
649
|
+
ok "workspace $ws: pack $pack, $(printf '%s' "$services" | /usr/bin/wc -w | /usr/bin/tr -d ' ') specialists answer, secrets of $secrets notes, bridge $bridge"
|
|
650
|
+
fi
|
|
651
|
+
done
|
|
444
652
|
}
|
package/cli/workspace.test.ts
CHANGED
|
@@ -32,9 +32,10 @@ function runAs(home: string, name: string, ...args: string[]) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
describe("workspace.sh", () => {
|
|
35
|
-
it("parses as POSIX sh and never runs Homebrew binaries", () => {
|
|
35
|
+
it("parses as POSIX sh, and root never runs Homebrew binaries: only the bridge, as the agent user, finds Pi there", () => {
|
|
36
36
|
expect(spawnSync("/bin/sh", ["-n", SCRIPT]).status).toBe(0);
|
|
37
|
-
|
|
37
|
+
const homebrew = readFileSync(SCRIPT, "utf-8").split("\n").filter((line) => line.includes("/opt/homebrew"));
|
|
38
|
+
expect(homebrew).toEqual([" <key>PATH</key><string>/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"]);
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
it.each([
|
|
@@ -240,3 +241,49 @@ describe("pack tools", () => {
|
|
|
240
241
|
expect(text).toContain("PACK_TOOL_HOSTS='github[.]com|registry[.]npmjs[.]org'");
|
|
241
242
|
});
|
|
242
243
|
});
|
|
244
|
+
|
|
245
|
+
describe("bridge service", () => {
|
|
246
|
+
it.runIf(isMac)("runs the core's bridge on the core's Node as the workspace's agent user, with Homebrew on PATH", () => {
|
|
247
|
+
const dir = mkdtempSync(join(tmpdir(), "bridge-plist-"));
|
|
248
|
+
try {
|
|
249
|
+
const plist = join(dir, "bridge.plist");
|
|
250
|
+
const made = shellFunctions(["bridge_label", "bridge_plist_text"], `BASE=/usr/local/libexec/astrogate; NODE=/usr/local/libexec/astrogate/tools/node/current/bin/node\nbridge_plist_text homelab /Users/astrogate-homelab >'${plist}'`);
|
|
251
|
+
expect(made.stderr).toBe("");
|
|
252
|
+
const json = spawnSync("/usr/bin/plutil", ["-convert", "json", "-o", "-", plist], { encoding: "utf-8" });
|
|
253
|
+
expect(json.status).toBe(0);
|
|
254
|
+
expect(JSON.parse(json.stdout)).toMatchObject({
|
|
255
|
+
Label: "com.astrofoundry.astrogate.homelab",
|
|
256
|
+
UserName: "astrogate-homelab",
|
|
257
|
+
ProgramArguments: ["/usr/local/libexec/astrogate/tools/node/current/bin/node", "/usr/local/libexec/astrogate/current/dist/bridge.js"],
|
|
258
|
+
WorkingDirectory: "/Users/astrogate-homelab",
|
|
259
|
+
EnvironmentVariables: { HOME: "/Users/astrogate-homelab", USER: "astrogate-homelab", PATH: "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin" },
|
|
260
|
+
RunAtLoad: true,
|
|
261
|
+
KeepAlive: true,
|
|
262
|
+
StandardErrorPath: "/Users/astrogate-homelab/Library/Logs/astro-discord.log",
|
|
263
|
+
});
|
|
264
|
+
} finally {
|
|
265
|
+
rmSync(dir, { recursive: true, force: true });
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("copies the bridge files into a private folder, each readable by its owner only", () => {
|
|
270
|
+
const dir = mkdtempSync(join(tmpdir(), "bridge-files-"));
|
|
271
|
+
try {
|
|
272
|
+
const home = join(dir, "home");
|
|
273
|
+
const stage = join(dir, "stage");
|
|
274
|
+
mkdirSync(home);
|
|
275
|
+
mkdirSync(stage);
|
|
276
|
+
writeFileSync(join(stage, "config.json"), "{}");
|
|
277
|
+
writeFileSync(join(stage, "token"), "x");
|
|
278
|
+
const result = runAs(home, "COPY_BRIDGE_FILES", stage);
|
|
279
|
+
expect(result.stderr).toBe("");
|
|
280
|
+
const bridgeDir = join(home, ".config", "astro-discord");
|
|
281
|
+
expect(statSync(bridgeDir).mode & 0o777).toBe(0o700);
|
|
282
|
+
expect(readdirSync(bridgeDir).sort()).toEqual(["config.json", "token"]);
|
|
283
|
+
expect(statSync(join(bridgeDir, "token")).mode & 0o777).toBe(0o600);
|
|
284
|
+
expect(existsSync(join(home, "Library", "Logs"))).toBe(true);
|
|
285
|
+
} finally {
|
|
286
|
+
rmSync(dir, { recursive: true, force: true });
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrofoundry/astrogate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Astrogate core: isolated agent workspaces with specialists, a foreman, and chat bridges, for the pi coding agent and Claude Code.",
|
|
5
5
|
"packageManager": "pnpm@12.23.0",
|
|
6
6
|
"scripts": {
|
package/release.sha256
CHANGED
|
@@ -3,12 +3,12 @@ b9b0f9fa90b9a230157de1fefef1aa5a624bfd7b50527b67ad86ecc62414aadb agents/foreman
|
|
|
3
3
|
4091f50a5a9ff72e2f1571c6de054d9c891dbe294aa58e6a55ad9a1bff2f766a cli/astro-install.sh
|
|
4
4
|
9f371247fdaea09e1551f940fd91eacb7d242baea343fce66f12fc8e22ba064b cli/astro.sh
|
|
5
5
|
8e054f8286876b77e0887d0b0e2a62d4a048fd41bfa0048d126e0c9171869cf6 cli/astro.test.ts
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
6476101dde839eb5fc71bc0f6849404a5c8cf4b439ee4247e2e0a2fcaecf2935 cli/astrogate.sh
|
|
7
|
+
47f5046469cf020e1290671a8078af5d88d1f60b63370b13f01eeb09a4b17e55 cli/astrogate.test.ts
|
|
8
8
|
07b9aef7e5d0ee43959e0c16e00ec3a202769c94faea4167257513bf15b9383c cli/verify-release.sh
|
|
9
9
|
29614fd0eb1ad08215baf827b00ee2b98ccb73ca0ccf770bc5a0084c71da5926 cli/verify-release.test.ts
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
eed16dfe98ea4df22abd3db6bdb53f3fcd65362dadce8712f927f5f8704ce28b cli/workspace.sh
|
|
11
|
+
24ab77d10385588f40c481fc23801efad49e3a4b7ae2051056c02f05a7baee1b cli/workspace.test.ts
|
|
12
12
|
87077122362031c7496ad6c191c00bd3ab90e39d8901286f78462ddbb7c76bae dist/bridge.js
|
|
13
13
|
06d6ce0f4763fe1552573336ad32e5dff23fc5e1e8a2b4243c974b6f7e439840 dist/claude.js
|
|
14
14
|
04ed58933a8ff2c05d92df0068038a6003c8b2fbc2f323a377fa530a16a3a867 dist/extensions/bridge/index.js
|
|
@@ -72,7 +72,7 @@ e6a327ff2e489bb9f3ed72d4e7eed207f9f2532e1da9b1d520ccf74aeaf594b5 harness/claude
|
|
|
72
72
|
e1d07bd981bd4ff6385246b6c1ad41349718c1e490b2bff675291dc7b568cd69 harness/claude/mcp.ts
|
|
73
73
|
194b623038d56a2565ad42d30d1db72ca453e654bfc84996800362e8a972282b harness/claude/settings.ts
|
|
74
74
|
987ae3b35d82ae3212cc70d12cff6913ac3f91a803fe7056ccd8010a8f960d2f pack_signers
|
|
75
|
-
|
|
75
|
+
0b9b78d899066c80e4793e390de476553f21826d59c595eb92775e86823b7f4b package.json
|
|
76
76
|
642383b14db5dbfb7caa6a185591263e4294a73323bf4c78606f7b85f0817fd0 specialists/AGENTS.md
|
|
77
77
|
a385cf5e3b59de30b5ed9b0840d6cf6198b577668f18dfd5de13a714fb047c3e specialists/README.md
|
|
78
78
|
270cf6cf3b4df6246d0aa8714ed02bd505e5a78c00f35fded4d20a6ac0382f30 specialists/entry/astrogate-run.sh
|
package/release.sha256.sig
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-----BEGIN SSH SIGNATURE-----
|
|
2
2
|
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUteIwPdKqPwfNc4vHQPUE+JWMC
|
|
3
3
|
nmuMUwttLeX5wtyIoAAAAOYXN0cm9nYXRlLWNvcmUAAAAAAAAABnNoYTUxMgAAAFMAAAAL
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
c3NoLWVkMjU1MTkAAABAPOph9MmmqoigYxYDTdzzshrFFnnZvx9jLnGoP6/JiwvLqnlyyg
|
|
5
|
+
a5GFdkz9uatAHY5auUcZe5FLx+1fRYNEmuDg==
|
|
6
6
|
-----END SSH SIGNATURE-----
|