pisha-server 0.0.0-stage → 0.0.12

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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/accounts/accounts.js +754 -0
  4. package/accounts/index.js +1 -0
  5. package/accounts/passwords.js +41 -0
  6. package/accounts/totp.js +54 -0
  7. package/boards/boards.js +1087 -0
  8. package/boards/github.js +212 -0
  9. package/boards/index.js +1 -0
  10. package/boards/sync.js +980 -0
  11. package/companies.js +294 -0
  12. package/company-export.js +101 -0
  13. package/company.js +82 -0
  14. package/dashboard/dashboard.js +408 -0
  15. package/dashboard/index.js +1 -0
  16. package/data-upgrade.js +69 -0
  17. package/install/linux.sh +181 -0
  18. package/install/macos.sh +121 -0
  19. package/install/windows.bat +54 -0
  20. package/machines/index.js +3 -0
  21. package/machines/machines.js +910 -0
  22. package/messaging/inbox.js +252 -0
  23. package/messaging/index.js +3 -0
  24. package/messaging/messaging.js +551 -0
  25. package/messaging/plans.js +67 -0
  26. package/observation/index.js +1 -0
  27. package/observation/observation.js +231 -0
  28. package/organization/index.js +1 -0
  29. package/organization/organization.js +218 -0
  30. package/package.json +55 -4
  31. package/permissions/index.js +1 -0
  32. package/permissions/permissions.js +211 -0
  33. package/pisha-host.mjs +3303 -0
  34. package/pisha-host.mjs.sig +1 -0
  35. package/platform/acme.js +207 -0
  36. package/platform/basics.js +14 -0
  37. package/platform/config.js +154 -0
  38. package/platform/control.js +93 -0
  39. package/platform/credentials.js +151 -0
  40. package/platform/database.js +251 -0
  41. package/platform/errors.js +13 -0
  42. package/platform/files.js +50 -0
  43. package/platform/http.js +207 -0
  44. package/platform/index.js +58 -0
  45. package/platform/limits.js +122 -0
  46. package/platform/listen.js +183 -0
  47. package/platform/roles.js +6 -0
  48. package/platform/stream.js +19 -0
  49. package/platform/text.js +83 -0
  50. package/platform/ws.js +186 -0
  51. package/routes.js +405 -0
  52. package/server.js +65 -0
  53. package/sessions/index.js +1 -0
  54. package/sessions/sessions.js +533 -0
  55. package/ui/LICENSE-affectui.txt +26 -0
  56. package/ui/addmachine.js +151 -0
  57. package/ui/api.js +20 -0
  58. package/ui/app.js +143 -0
  59. package/ui/attention.js +78 -0
  60. package/ui/back.js +168 -0
  61. package/ui/boards.js +958 -0
  62. package/ui/chat.js +388 -0
  63. package/ui/content.js +157 -0
  64. package/ui/dialogs.js +135 -0
  65. package/ui/doing.js +112 -0
  66. package/ui/dom.js +6 -0
  67. package/ui/ds-base.css +146 -0
  68. package/ui/ds-components.css +229 -0
  69. package/ui/fonts/LICENSE-space-grotesk.txt +93 -0
  70. package/ui/fonts/space-grotesk-latin-700-normal.woff2 +0 -0
  71. package/ui/fonts/space-grotesk-latin-ext-700-normal.woff2 +0 -0
  72. package/ui/format.js +25 -0
  73. package/ui/i18n.js +2145 -0
  74. package/ui/icons/apple-touch-icon.png +0 -0
  75. package/ui/icons/icon-192.png +0 -0
  76. package/ui/icons/icon-512.png +0 -0
  77. package/ui/icons/maskable-512.png +0 -0
  78. package/ui/icons.js +41 -0
  79. package/ui/inbox.js +535 -0
  80. package/ui/index.html +105 -0
  81. package/ui/machines.js +261 -0
  82. package/ui/manifest.webmanifest +16 -0
  83. package/ui/mosaic.js +189 -0
  84. package/ui/nav.js +142 -0
  85. package/ui/newteam.js +223 -0
  86. package/ui/org.js +669 -0
  87. package/ui/overlays.css +126 -0
  88. package/ui/palette.js +180 -0
  89. package/ui/people.js +371 -0
  90. package/ui/permissions.js +202 -0
  91. package/ui/qr.js +158 -0
  92. package/ui/router.js +173 -0
  93. package/ui/routes.js +47 -0
  94. package/ui/screen-boards.css +241 -0
  95. package/ui/screen-inbox.css +201 -0
  96. package/ui/screen-machines.css +76 -0
  97. package/ui/screen-mosaic.css +26 -0
  98. package/ui/screen-newteam.css +90 -0
  99. package/ui/screen-org.css +119 -0
  100. package/ui/screen-session.css +99 -0
  101. package/ui/screen-signin.css +28 -0
  102. package/ui/screen-team.css +80 -0
  103. package/ui/screen-teams.css +41 -0
  104. package/ui/screen-usage.css +60 -0
  105. package/ui/session.js +42 -0
  106. package/ui/shell.css +122 -0
  107. package/ui/signin.js +120 -0
  108. package/ui/squads.js +371 -0
  109. package/ui/state.js +59 -0
  110. package/ui/stream.js +269 -0
  111. package/ui/styles.css +343 -0
  112. package/ui/team.js +115 -0
  113. package/ui/teams.js +58 -0
  114. package/ui/terminal.js +261 -0
  115. package/ui/theme.js +32 -0
  116. package/ui/timeline.js +163 -0
  117. package/ui/topbar.js +211 -0
  118. package/ui/usage.js +175 -0
  119. package/ui/voice-parse.js +98 -0
  120. package/ui/voice.js +320 -0
  121. package/usage/index.js +1 -0
  122. package/usage/usage.js +127 -0
  123. package/vendor/InterVariable.woff2 +0 -0
  124. package/vendor/LICENSE-inter +92 -0
  125. package/vendor/LICENSE-xterm +21 -0
  126. package/vendor/README.md +8 -0
  127. package/vendor/addon-fit.js +2 -0
  128. package/vendor/xterm.css +218 -0
  129. package/vendor/xterm.js +2 -0
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env bash
2
+ # Pisha: prepare this machine (Linux, or Ubuntu on WSL) and join it to a
3
+ # Pisha server. The dashboard gives you the exact command, with your code. It
4
+ # downloads this script, checks it, and leaves the code in a file for it:
5
+ #
6
+ # bash install.sh https://your-server --code-file code [options]
7
+ #
8
+ # It installs what is missing (tmux, Node.js 22, and the agents chosen: Claude
9
+ # Code unless --no-claude, Codex CLI with --codex, Grok CLI with --grok), then
10
+ # pisha-host, which joins the machine, sets Pisha up in each agent, and
11
+ # installs the "pisha-host" command and a service that keeps it running.
12
+ # Options are passed to pisha-host: --allow-home, --insecure, --no-service.
13
+ # --allow-root: install and run it as root (sessions then have full control
14
+ # of this machine, to change the operating system).
15
+ set -eu
16
+
17
+ SELF="$0"
18
+
19
+ # (All in a function: piped into bash, the whole script is read before anything runs.)
20
+ main() {
21
+ SERVER="${1:-}"; [ $# -gt 0 ] && shift
22
+ # The code comes in a file, so it is in no program's arguments, which anyone
23
+ # on this machine can read (or after the URL, as older commands gave it).
24
+ CODE=""; CODE_FILE=""
25
+ case "${1:-}" in ""|-*) ;; *) CODE="$1"; shift ;; esac
26
+ SHA=""
27
+ ROOT_OK=""
28
+ OS_USER=""
29
+ WANT_CLAUDE=1; WANT_CODEX=""; WANT_GROK=""
30
+ AGENT_ARGS=()
31
+ ARGS=()
32
+ while [ $# -gt 0 ]; do
33
+ case "$1" in
34
+ --sha256) [ $# -ge 2 ] || { echo "--sha256 needs a value" >&2; exit 2; }; SHA="$2"; shift 2 ;;
35
+ --code-file) [ $# -ge 2 ] || { echo "--code-file needs a path" >&2; exit 2; }; CODE_FILE="$2"; shift 2 ;;
36
+ --server-key) ARGS+=("--server-key=${2:-}"); shift 2 ;; # (from windows.bat: no "=" there)
37
+ --company) ARGS+=("--company=${2:-}"); shift 2 ;;
38
+ --os-user) [ $# -ge 2 ] || { echo "--os-user needs a name" >&2; exit 2; }; OS_USER="$2"; shift 2 ;;
39
+ --os-user=*) OS_USER="${1#--os-user=}"; [ -n "$OS_USER" ] || { echo "--os-user needs a name" >&2; exit 2; }; shift ;;
40
+ --allow-root) ROOT_OK=1; shift ;;
41
+ # The agents to install (each kept for the run as another user, below).
42
+ --no-claude) WANT_CLAUDE=""; AGENT_ARGS+=("$1"); shift ;;
43
+ --codex) WANT_CODEX=1; AGENT_ARGS+=("$1"); shift ;;
44
+ --grok) WANT_GROK=1; AGENT_ARGS+=("$1"); shift ;;
45
+ *) ARGS+=("$1"); shift ;;
46
+ esac
47
+ done
48
+ if [ -n "$CODE_FILE" ]; then
49
+ [ -f "$CODE_FILE" ] || { echo "--code-file: $CODE_FILE is not there" >&2; exit 2; }
50
+ CODE="$(cat "$CODE_FILE")"
51
+ rm -f "$CODE_FILE"
52
+ fi
53
+ if [ -z "$SERVER" ] || [ -z "$CODE" ]; then
54
+ echo "usage: linux.sh <server-url> --code-file <file> [--allow-home] [--insecure] [--no-service] [--company <id>] [--os-user <name>]" >&2
55
+ exit 2
56
+ fi
57
+
58
+ say() { printf '\n\033[1m==> %s\033[0m\n' "$*"; }
59
+ as_root() { if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi }
60
+ install_pkg() {
61
+ if command -v apt-get >/dev/null 2>&1; then { as_root apt-get update -qq || true; } && as_root apt-get install -y "$@"
62
+ elif command -v dnf >/dev/null 2>&1; then as_root dnf install -y "$@"
63
+ elif command -v pacman >/dev/null 2>&1; then as_root pacman -S --needed --noconfirm "$@"
64
+ elif command -v zypper >/dev/null 2>&1; then as_root zypper install -y "$@"
65
+ else echo "Install $* with your package manager, then run this command again." >&2; exit 1
66
+ fi
67
+ }
68
+
69
+ # Another system user for this company's sessions, created if needed: what
70
+ # really keeps companies apart on one machine. The rest runs again as that user.
71
+ if [ -n "$OS_USER" ]; then
72
+ case "$OS_USER" in
73
+ ""|root|*[!a-z0-9_-]*|[!a-z_]*) echo "--os-user: \"$OS_USER\" is not a name for a new user (lowercase letters, digits, - and _)" >&2; exit 2 ;;
74
+ esac
75
+ [ "$(id -u)" -eq 0 ] || { echo "--os-user needs root: run this with sudo." >&2; exit 1; }
76
+ if ! id "$OS_USER" >/dev/null 2>&1; then
77
+ say "Creating the system user $OS_USER"
78
+ useradd -m -s /bin/bash "$OS_USER"
79
+ # (Many systems leave a new home readable by everyone: that isn't apart.)
80
+ chmod 700 "$(getent passwd "$OS_USER" | cut -d: -f6)"
81
+ elif [ "$(id -u "$OS_USER")" -lt 1000 ]; then
82
+ # (A system account: its sessions would have whatever rights it has.)
83
+ echo "--os-user: $OS_USER is an account of the system, not a person's or a company's: choose another name." >&2
84
+ exit 2
85
+ fi
86
+ if ! command -v tmux >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then install_pkg tmux curl; fi
87
+ # (So its service keeps running without anyone logged in as it.)
88
+ loginctl enable-linger "$OS_USER" 2>/dev/null || true
89
+ AS_USER_ENV=("HOME=$(getent passwd "$OS_USER" | cut -d: -f6)" "XDG_RUNTIME_DIR=/run/user/$(id -u "$OS_USER")" "PATH=$PATH")
90
+ SWITCH=(runuser -u "$OS_USER" --)
91
+ command -v runuser >/dev/null 2>&1 || SWITCH=(sudo -H -u "$OS_USER")
92
+ # This same script, already checked, and the code, in a folder of that user.
93
+ WORK="$(mktemp -d)"
94
+ if [ -f "$SELF" ] && [ "${BASH_SOURCE[0]:-}" = "$SELF" ]; then cp "$SELF" "$WORK/install.sh"
95
+ else curl -fsSLo "$WORK/install.sh" "${SERVER%/}/install/linux.sh" # (Piped in, as older commands did: there is no file to copy.)
96
+ fi
97
+ printf %s "$CODE" > "$WORK/code"
98
+ chown -R "$OS_USER" "$WORK"
99
+ RC=0
100
+ ( cd "$WORK" && "${SWITCH[@]}" env "${AS_USER_ENV[@]}" bash install.sh "$SERVER" --code-file code ${SHA:+--sha256 "$SHA"} ${AGENT_ARGS[@]+"${AGENT_ARGS[@]}"} ${ARGS[@]+"${ARGS[@]}"} ) || RC=$?
101
+ rm -rf "$WORK"
102
+ exit $RC
103
+ fi
104
+
105
+ if [ "$(id -u)" -eq 0 ] && [ -z "$ROOT_OK" ]; then
106
+ echo "This is root: sessions run as the user who installs them, so they would have full control of this machine." >&2
107
+ echo "Run it as your own user, or add --allow-root to the command if that is what you want (to let Claude change the system)." >&2
108
+ exit 1
109
+ fi
110
+ if [ "$(id -u)" -eq 0 ]; then
111
+ say "Installing as root: sessions will have full control of this machine"
112
+ fi
113
+
114
+ # 1. tmux (and curl, for what follows)
115
+ if ! command -v tmux >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then
116
+ say "Installing tmux (it may ask for your password)"
117
+ install_pkg tmux curl
118
+ fi
119
+
120
+ # 2. Node.js 22.13 or later (with nvm, in your home, if missing or older)
121
+ # (On WSL, what Windows installed isn't usable here: /mnt/c/…)
122
+ native() {
123
+ p="$(command -v "$1" 2>/dev/null)" || return 1
124
+ case "$(uname -r)" in *[Mm]icrosoft*) case "$p" in /mnt/*) return 1 ;; esac ;; esac
125
+ }
126
+ node_ok() { native node && node -e 'const [a,b]=process.versions.node.split(".").map(Number);process.exit(a>22||(a===22&&b>=13)?0:1)'; }
127
+ if ! node_ok; then
128
+ say "Installing Node.js 22 (with nvm, in your home folder)"
129
+ export NVM_DIR="$HOME/.nvm"
130
+ [ -s "$NVM_DIR/nvm.sh" ] || curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
131
+ set +eu; . "$NVM_DIR/nvm.sh"; nvm install 22 && nvm alias default 22; set -eu
132
+ node_ok || { echo "Node.js 22 could not be installed: install Node.js 22.13 or later, then run this command again." >&2; exit 1; }
133
+ fi
134
+
135
+ # 3. The agents chosen, each in this user's home (no sudo), each from its
136
+ # maker: Claude Code and Grok CLI with their own installers, Codex CLI from npm.
137
+ export PATH="$HOME/.local/bin:$PATH"
138
+ if [ -n "$WANT_CLAUDE" ] && ! native claude; then
139
+ say "Installing Claude Code"
140
+ curl -fsSL https://claude.ai/install.sh | bash
141
+ fi
142
+ if [ -n "$WANT_CODEX" ] && ! native codex; then
143
+ say "Installing Codex CLI"
144
+ npm install -g --prefix "$HOME/.local" @openai/codex
145
+ fi
146
+ if [ -n "$WANT_GROK" ] && ! native grok; then
147
+ say "Installing Grok CLI"
148
+ curl -fsSL https://x.ai/cli/install.sh | bash
149
+ fi
150
+
151
+ # New terminals find the agents and "pisha-host" in ~/.local/bin.
152
+ for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do
153
+ if [ -f "$rc" ] && ! grep -q '\.local/bin' "$rc"; then
154
+ # (Managed elsewhere and read-only, as with home-manager: not worth stopping for.)
155
+ { printf '\n# Added by the Pisha installer\nexport PATH="$HOME/.local/bin:$PATH"\n' >> "$rc"; } 2>/dev/null || echo "Could not add ~/.local/bin to $rc: add it to your PATH yourself." >&2
156
+ fi
157
+ done
158
+
159
+ # 4. pisha-host: downloaded into a new private folder, checked, and run.
160
+ say "Joining this machine to $SERVER"
161
+ DIR="$(mktemp -d)"
162
+ cd "$DIR"
163
+ curl -fsSLo pisha-host.mjs "${SERVER%/}/host/pisha-host.mjs"
164
+ if [ -n "$SHA" ]; then
165
+ echo "$SHA pisha-host.mjs" | sha256sum -c - >/dev/null || { echo "pisha-host.mjs does not match the dashboard's checksum: stopped." >&2; exit 1; }
166
+ fi
167
+ printf %s "$CODE" > code
168
+ node pisha-host.mjs enroll "$SERVER" --code-file=code ${ARGS[@]+"${ARGS[@]}"}
169
+
170
+ say "Done"
171
+ case " ${ARGS[*]-} " in
172
+ *" --company="*) ;; # (It has said how: this company has its own login.)
173
+ *)
174
+ echo "If you haven't yet, sign in to each agent once in a terminal, so its sessions can start:"
175
+ [ -z "$WANT_CLAUDE" ] || echo " claude (then /login if it asks)"
176
+ [ -z "$WANT_CODEX" ] || echo " codex login"
177
+ [ -z "$WANT_GROK" ] || echo " grok login" ;;
178
+ esac
179
+ }
180
+
181
+ main "$@"
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env bash
2
+ # Pisha: prepare this Mac and join it to a Pisha server. The dashboard
3
+ # gives you the exact command, with your code. It downloads this script, checks
4
+ # it, and leaves the code in a file for it:
5
+ #
6
+ # bash install.sh https://your-server --code-file code [options]
7
+ #
8
+ # It installs what is missing (tmux with Homebrew, Node.js 22, and the agents
9
+ # chosen: Claude Code unless --no-claude, Codex CLI with --codex, Grok CLI with --grok),
10
+ # then pisha-host, which joins the machine, installs the Pisha plugin, the
11
+ # "pisha-host" command and a service that keeps it running.
12
+ # Options are passed to pisha-host: --allow-home, --insecure, --no-service.
13
+ set -eu
14
+
15
+ # (All in a function: piped into bash, the whole script is read before anything runs.)
16
+ main() {
17
+ SERVER="${1:-}"; [ $# -gt 0 ] && shift
18
+ # The code comes in a file, so it is in no program's arguments, which anyone
19
+ # on this machine can read (or after the URL, as older commands gave it).
20
+ CODE=""; CODE_FILE=""
21
+ case "${1:-}" in ""|-*) ;; *) CODE="$1"; shift ;; esac
22
+ SHA=""
23
+ WANT_CLAUDE=1; WANT_CODEX=""; WANT_GROK=""
24
+ ARGS=()
25
+ while [ $# -gt 0 ]; do
26
+ case "$1" in
27
+ --sha256) [ $# -ge 2 ] || { echo "--sha256 needs a value" >&2; exit 2; }; SHA="$2"; shift 2 ;;
28
+ --code-file) [ $# -ge 2 ] || { echo "--code-file needs a path" >&2; exit 2; }; CODE_FILE="$2"; shift 2 ;;
29
+ --os-user*) echo "--os-user is for Linux. On macOS: create the user, log in as it, and run this command there." >&2; exit 2 ;;
30
+ # The agents to install.
31
+ --no-claude) WANT_CLAUDE=""; shift ;;
32
+ --codex) WANT_CODEX=1; shift ;;
33
+ --grok) WANT_GROK=1; shift ;;
34
+ *) ARGS+=("$1"); shift ;;
35
+ esac
36
+ done
37
+ if [ -n "$CODE_FILE" ]; then
38
+ [ -f "$CODE_FILE" ] || { echo "--code-file: $CODE_FILE is not there" >&2; exit 2; }
39
+ CODE="$(cat "$CODE_FILE")"
40
+ rm -f "$CODE_FILE"
41
+ fi
42
+ if [ -z "$SERVER" ] || [ -z "$CODE" ]; then
43
+ echo "usage: macos.sh <server-url> --code-file <file> [--allow-home] [--insecure] [--no-service]" >&2
44
+ exit 2
45
+ fi
46
+
47
+ say() { printf '\n\033[1m==> %s\033[0m\n' "$*"; }
48
+
49
+ if [ "$(id -u)" -eq 0 ]; then
50
+ echo "Run this as your own user, not as root." >&2
51
+ exit 1
52
+ fi
53
+
54
+ # 1. tmux, with Homebrew
55
+ for b in /opt/homebrew/bin/brew /usr/local/bin/brew; do
56
+ [ -x "$b" ] && eval "$("$b" shellenv)" && break
57
+ done
58
+ if ! command -v tmux >/dev/null 2>&1; then
59
+ if ! command -v brew >/dev/null 2>&1; then
60
+ echo "tmux is needed, and it is installed with Homebrew. Install Homebrew first (https://brew.sh):" >&2
61
+ echo ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' >&2
62
+ echo "then run this command again." >&2
63
+ exit 1
64
+ fi
65
+ say "Installing tmux"
66
+ brew install tmux
67
+ fi
68
+
69
+ # 2. Node.js 22.13 or later (with nvm, in your home, if missing or older)
70
+ node_ok() { command -v node >/dev/null 2>&1 && node -e 'const [a,b]=process.versions.node.split(".").map(Number);process.exit(a>22||(a===22&&b>=13)?0:1)'; }
71
+ if ! node_ok; then
72
+ say "Installing Node.js 22 (with nvm, in your home folder)"
73
+ export NVM_DIR="$HOME/.nvm"
74
+ [ -s "$NVM_DIR/nvm.sh" ] || curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
75
+ set +eu; . "$NVM_DIR/nvm.sh"; nvm install 22 && nvm alias default 22; set -eu
76
+ node_ok || { echo "Node.js 22 could not be installed: install Node.js 22.13 or later, then run this command again." >&2; exit 1; }
77
+ fi
78
+
79
+ # 3. The agents chosen, each in this user's home, each from its maker:
80
+ # Claude Code and Grok CLI with their own installers, Codex CLI from npm.
81
+ export PATH="$HOME/.local/bin:$PATH"
82
+ if [ -n "$WANT_CLAUDE" ] && ! command -v claude >/dev/null 2>&1; then
83
+ say "Installing Claude Code"
84
+ curl -fsSL https://claude.ai/install.sh | bash
85
+ fi
86
+ if [ -n "$WANT_CODEX" ] && ! command -v codex >/dev/null 2>&1; then
87
+ say "Installing Codex CLI"
88
+ npm install -g --prefix "$HOME/.local" @openai/codex
89
+ fi
90
+ if [ -n "$WANT_GROK" ] && ! command -v grok >/dev/null 2>&1; then
91
+ say "Installing Grok CLI"
92
+ curl -fsSL https://x.ai/cli/install.sh | bash
93
+ fi
94
+
95
+ # New terminals find the agents and "pisha-host" in ~/.local/bin.
96
+ for rc in "$HOME/.zshrc" "$HOME/.bash_profile"; do
97
+ if [ "$rc" = "$HOME/.zshrc" ] || [ -f "$rc" ]; then
98
+ # (Managed elsewhere and read-only, as with home-manager: not worth stopping for.)
99
+ { touch "$rc" && { grep -q '\.local/bin' "$rc" || printf '\n# Added by the Pisha installer\nexport PATH="$HOME/.local/bin:$PATH"\n' >> "$rc"; }; } 2>/dev/null || echo "Could not add ~/.local/bin to $rc: add it to your PATH yourself." >&2
100
+ fi
101
+ done
102
+
103
+ # 4. pisha-host: downloaded into a new private folder, checked, and run.
104
+ say "Joining this Mac to $SERVER"
105
+ DIR="$(mktemp -d)"
106
+ cd "$DIR"
107
+ curl -fsSLo pisha-host.mjs "${SERVER%/}/host/pisha-host.mjs"
108
+ if [ -n "$SHA" ]; then
109
+ echo "$SHA pisha-host.mjs" | shasum -a 256 -c - >/dev/null || { echo "pisha-host.mjs does not match the dashboard's checksum: stopped." >&2; exit 1; }
110
+ fi
111
+ printf %s "$CODE" > code
112
+ node pisha-host.mjs enroll "$SERVER" --code-file=code ${ARGS[@]+"${ARGS[@]}"}
113
+
114
+ say "Done"
115
+ echo "If you haven't yet, sign in to each agent once in a terminal, so its sessions can start:"
116
+ [ -z "$WANT_CLAUDE" ] || echo " claude (then /login if it asks)"
117
+ [ -z "$WANT_CODEX" ] || echo " codex login"
118
+ [ -z "$WANT_GROK" ] || echo " grok login"
119
+ }
120
+
121
+ main "$@"
@@ -0,0 +1,54 @@
1
+ @echo off
2
+ rem Pisha: prepare this Windows machine and join it to a Pisha server.
3
+ rem Pisha runs inside WSL (Ubuntu), together with Claude Code: this checks
4
+ rem that WSL is there and runs the Linux installer inside it.
5
+ rem The dashboard gives you the exact command, with your code:
6
+ rem
7
+ rem windows.bat https://your-server --linux-sha256 X [--sha256 X] [--server-key X] [--company X] [--allow-home] [--insecure]
8
+ rem
9
+ rem The code comes in PISHA_ENROLL_CODE, so it is in no program's arguments.
10
+ setlocal
11
+
12
+ if "%~1"=="" goto usage
13
+ if not defined PISHA_ENROLL_CODE goto usage
14
+
15
+ where wsl >nul 2>nul
16
+ if errorlevel 1 goto nowsl
17
+ wsl -e true >nul 2>nul
18
+ if errorlevel 1 goto nowsl
19
+
20
+ echo.
21
+ echo ==^> Setting up Pisha inside WSL (it may ask for your Ubuntu password)
22
+ set "URL=%~1"
23
+ set "LINUX_SHA="
24
+ set "REST="
25
+ shift
26
+ :more
27
+ if "%~1"=="" goto go
28
+ if "%~1"=="--linux-sha256" (
29
+ set "LINUX_SHA=%~2"
30
+ shift
31
+ shift
32
+ goto more
33
+ )
34
+ set "REST=%REST% %1"
35
+ shift
36
+ goto more
37
+ :go
38
+ if not defined LINUX_SHA goto usage
39
+ set "WSLENV=PISHA_ENROLL_CODE:%WSLENV%"
40
+ rem Downloaded and checked inside WSL, as the Linux command does.
41
+ wsl -e bash -c "d=$(mktemp -d) && cd $d && curl -fsSLo install.sh '%URL%/install/linux.sh' && echo '%LINUX_SHA% install.sh' | sha256sum -c - >/dev/null && printf %%s $PISHA_ENROLL_CODE > code && bash install.sh '%URL%' --code-file code%REST%"
42
+ exit /b %errorlevel%
43
+
44
+ :usage
45
+ echo usage: set PISHA_ENROLL_CODE=^<code^> and run: windows.bat ^<server-url^> --linux-sha256 X [--sha256 X] [--server-key X] [--allow-home] [--insecure]
46
+ exit /b 2
47
+
48
+ :nowsl
49
+ echo.
50
+ echo Pisha runs on Windows inside WSL (Ubuntu), and WSL is not installed yet.
51
+ echo 1. Open PowerShell as administrator and run: wsl --install -d Ubuntu
52
+ echo 2. Restart Windows, open "Ubuntu" from the Start menu once and create your user.
53
+ echo 3. Run this command again.
54
+ exit /b 1
@@ -0,0 +1,3 @@
1
+ export {
2
+ createMachines, INSTALLERS, installer, hostScript, hostSignature, checkEnrollRate, enrollmentKey, offeredCredential,
3
+ } from './machines.js'