Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
docs(desktop): correct desktop, Docker and GCP runbook docs and comments
trohitg8d0a6e19da88
diff --git a/desktop/src/main/backend.ts b/desktop/src/main/backend.tsindex 7a652784..a0f4c735 100644--- a/desktop/src/main/backend.ts+++ b/desktop/src/main/backend.ts@@ -29,7 +29,7 @@ export interface SpawnBackendOptions {* renderer's WebSocket died with a reset rather than a clean close, the* handler task lingered and uvicorn never reached the lifespan, so the* shell's 30 s budget expired and the backend had to be tree-killed. Bound- * it; the lifespan teardown (which reaps Temporal / node / edgymeow) is what+ * it; the lifespan teardown (which reaps Temporal / the bun sidecar / edgymeow) is what* actually matters and still runs after this window.*/export const GRACEFUL_SHUTDOWN_SECONDS = 5;diff --git a/desktop/src/main/env.ts b/desktop/src/main/env.tsindex 9729fdfe..4168fa3a 100644--- a/desktop/src/main/env.ts+++ b/desktop/src/main/env.ts@@ -2,11 +2,12 @@* The environment the backend is spawned with — the shell's half of* docs-internal/desktop_host_contract.md.*- * Precedence (low -> high): the shell's contract values below, then the- * operator's `desktop.env` lines, then the shell's own process env for the- * handful of pass-through keys. The backend then layers .env.template <- * OPENCOMPANY_ENV_FILE under all of that with setdefault semantics, so a- * key set here always wins over the template.+ * Precedence (low -> high): the shell's own process env (minus a few Python /+ * Electron keys), then the contract values below, then the operator's+ * `desktop.env` lines for every key outside LOCKED_KEYS. PATH is computed+ * last from the inherited PATH, so desktop.env cannot replace it. The backend+ * then layers .env.template < OPENCOMPANY_ENV_FILE under all of that with+ * setdefault semantics, so a key set here always wins over the template.** Pure (no Electron imports) so it is unit-testable.*/@@ -21,7 +22,7 @@ export interface BackendEnvOptions {port: number;token: string;parentPid: number;- /** The interpreter's venv dir; only used for UV_PROJECT_ENVIRONMENT. */+ /** The environment to inherit (default: `process.env`); tests pass their own. */baseEnv?: NodeJS.ProcessEnv;}diff --git a/desktop/src/main/paths.ts b/desktop/src/main/paths.tsindex 9437cc05..2bf02673 100644--- a/desktop/src/main/paths.ts+++ b/desktop/src/main/paths.ts@@ -10,7 +10,7 @@* pyenv/venv UV_PROJECT_ENVIRONMENT (the backend interpreter)* pyenv/python UV_PYTHON_INSTALL_DIR (fallback path only)* pyenv/cache UV_CACHE_DIR- * pyenv/tools UV_TOOL_DIR / bin (browser-harness etc.)+ * pyenv/tools UV_TOOL_DIR / bin (the browser-use CLI)* pycache/ PYTHONPYCACHEPREFIX (the bundle is read-only)* bun/ BUN_INSTALL (bun's package cache for the plugin CLIs)* logs/diff --git a/desktop/src/main/shutdown.ts b/desktop/src/main/shutdown.tsindex 809f68db..90579f80 100644--- a/desktop/src/main/shutdown.ts+++ b/desktop/src/main/shutdown.ts@@ -2,7 +2,7 @@* Stop the backend the contract way (docs-internal/desktop_host_contract.md §5):** 1. POST /api/desktop/shutdown with the per-launch token -> lifespan- * teardown reaps Temporal / node / WhatsApp.+ * teardown reaps Temporal / the bun sidecar / WhatsApp.* 2. Close our end of stdin (the backend's fast parent-gone signal).* 3. Wait up to `timeoutMs` for exit.* 4. Fallback: tree-kill (taskkill /T on Windows, SIGKILL to the processdiff --git a/docs-internal/desktop_app.md b/docs-internal/desktop_app.mdindex 10e3c10d..17c39530 100644--- a/docs-internal/desktop_app.md+++ b/docs-internal/desktop_app.md@@ -80,7 +80,7 @@ shell reads it directly (`stage/runtime/<os>-<arch>/`), in a packaged app4. `choosePort`: persisted port, else 5678, else scan 5679-5699. If thepreferred port is busy and `/health` says an OpenCompany backend is there(a `company serve` the user left running), attach instead of spawning.-5. `spawnBackend`: `<venv>/python -m uvicorn main:app --host 127.0.0.1 --port N --timeout-graceful-shutdown 5`+5. `spawnBackend`: `<venv>/python -m uvicorn main:app --host 127.0.0.1 --port N --log-level warning --timeout-graceful-shutdown 5`with the contract env (`desktop/src/main/env.ts`), stdin kept as a pipe,stdout/stderr to `logs/backend.stdout.log`, detached on POSIX. Thegraceful-shutdown bound is load-bearing: uvicorn otherwise waits forever@@ -187,8 +187,12 @@ bundled Python. Then remove the macOS notify-only branch indiffers from the tag (the build ships the committed desktop version, notthe tag's), stages, runs typecheck + unit + invariant tests, then`electron-builder --publish always` into that draft; a `finalize` job- undrafts it once all legs pass. Separate from `release.yml` so the- registry publish (`bun publish`) is never blocked and its locked strings are untouched.+ undrafts it once all legs pass. A manual dispatch has no tag, so there is+ no `prepare` draft and no `finalize`: the legs upload (into a draft+ electron-builder creates itself) only when its `publish` input is ticked,+ and otherwise build with `--publish never` and keep the artifacts.+ Separate from `release.yml` so the registry publish (`bun publish`) is+ never blocked and its locked strings are untouched.The step-by-step is in [ci_cd.md -> Cutting a release](./ci_cd.md#cutting-a-release).- `desktop-ci.yml` on PRs touching `desktop/**` or the backend contractfiles: typecheck, unit, invariants, build, and the Playwright Electrondiff --git a/docs-internal/desktop_host_contract.md b/docs-internal/desktop_host_contract.mdindex a98b4710..18a0250e 100644--- a/docs-internal/desktop_host_contract.md+++ b/docs-internal/desktop_host_contract.md@@ -91,19 +91,32 @@ OPENCOMPANY_PARENT_PID=<shell pid>OPENCOMPANY_DESKTOP_TOKEN=<random per launch>OPENCOMPANY_DESKTOP_STDIN=1 # shell keeps stdin as an open pipeOPENCOMPANY_APP_ROOT=<bundle>/app-root+OPENCOMPANY_CLIENT_DIST=<bundle>/app-root/client/distOPENCOMPANY_ENV_FILE=<data dir>/desktop.env-OPENCOMPANY_BUN_BIN=<bundle>/bun/bun[.exe] # the bundled bun (core/js_runtime.py); PATH prefix also works-BUN_INSTALL=<data dir>/bun # bun's global state, kept out of a dev install's ~/.bun+OPENCOMPANY_BUN_BIN=<bundle>/runtime/bun/bun[.exe] # when the bundled bun exists (core/js_runtime.py)+BUN_INSTALL=<data dir>/bun # same condition; bun's global state, kept out of a dev install's ~/.bunBUN_INSTALL_CACHE_DIR=<data dir>/bun/install/cache-OPENCOMPANY_UV_BIN=<bundle>/uv/uv # optional; PATH prefix also works+OPENCOMPANY_UV_BIN=<bundle>/runtime/uv/uv[.exe] # when the bundled uv existsPORT=<PORT> PYTHON_BACKEND_PORT=<PORT> HOST=127.0.0.1SERVE_STATIC_CLIENT=1 PYTHONUTF8=1 PYTHONUNBUFFERED=1PYTHONPYCACHEPREFIX=<data dir>/pycache # bundle is read-onlyLOG_FILE=<data dir>/logs/backend.log LOG_FORMAT=jsonTEMPORAL_GRACEFUL_SHUTDOWN_SECONDS=10-PATH=<bundle>/bun:<bundle>/uv:$PATH # bun (JS runtime + package installs), uv; no Node, no npm+UV_PROJECT_ENVIRONMENT=<data dir>/pyenv/venv # the backend's venv+UV_PYTHON_INSTALL_DIR=<data dir>/pyenv/python UV_CACHE_DIR=<data dir>/pyenv/cache+UV_TOOL_DIR=<data dir>/pyenv/tools UV_TOOL_BIN_DIR=<data dir>/pyenv/tools/bin+UV_NO_CONFIG=1 UV_SYSTEM_CERTS=1+PATH=<bundle>/runtime/bun:<bundle>/runtime/uv:<data dir>/pyenv/tools/bin:$PATH # bun and uv only when bundled; no Node, no npm```+The shell starts from its own environment (minus `VIRTUAL_ENV`, `PYTHONHOME`,+`PYTHONPATH` and `ELECTRON_RUN_AS_NODE`), lays the values above over it, then+applies `<data dir>/desktop.env` on top for every key except those in+`LOCKED_KEYS` (`desktop/src/main/env.ts`: the desktop identity and token keys,+the app-root / client-dist / env-file paths, the port and host keys,+`SERVE_STATIC_CLIENT` and `UV_PROJECT_ENVIRONMENT`). `PATH` is computed last+from the inherited `PATH`, so `desktop.env` cannot replace it.+`DATA_DIR` is left at its default (`~/.opencompany`) so the desktop app anda CLI install share workflows, credentials, and downloaded binaries.@@ -135,9 +148,10 @@ raises the signal uvicorn already handles (SIGINT on Windows, SIGTERMelsewhere). The lifespan teardown then runs: plugin shutdown hooks, theprocess manager, every registered supervisor (Temporal dev server, the JSexecutor sidecar on bun, WhatsApp bridge) through `terminate_then_kill`, then database-close. The route exists only under `OPENCOMPANY_DESKTOP=1` and refuses every-request when the token is unset. Locked by-`tests/test_desktop_shutdown_endpoint.py`.+close. Plugin hooks run one after another, each capped at `HOOK_TIMEOUT_SECONDS`+(10 s, `services/plugin/shutdown_hooks.py`). The route exists only under+`OPENCOMPANY_DESKTOP=1` and refuses every request when the token is unset.+Locked by `tests/test_desktop_shutdown_endpoint.py`.Also acceptable on POSIX: SIGTERM to the process. Do not `TerminateProcess`first on Windows; that skips the lifespan.@@ -146,6 +160,12 @@ Shell should wait up to 30 s, then tree-kill as a fallback (Windows:`taskkill /PID <pid> /T /F`; POSIX: SIGKILL to the process group, so spawnthe backend detached in its own group).+**Known gap:** nothing keeps the backend's teardown inside that 30 s. Plugin+hooks can take up to 10 s each, one after another, and the Temporal workers+get their own grace period (`TEMPORAL_GRACEFUL_SHUTDOWN_SECONDS=10` under the+shell), so a slow teardown can outlast the wait and end in the tree-kill+instead of a clean exit.+## 6. Parent deathArmed by `start_desktop_mode()` at lifespan start:diff --git a/docs-internal/docker.md b/docs-internal/docker.mdindex 06a5aabf..0d9b1a08 100644--- a/docs-internal/docker.md+++ b/docs-internal/docker.md@@ -72,7 +72,7 @@ The image sets these on top of the template:| `BROWSER_HEADLESS` | `true` | Render inside the workspace without a desktop window || `PYTHONUNBUFFERED` | `1` | Log lines reach `docker compose logs` as they are written |-**Browser runtime configuration:** the Dockerfile sets `BROWSER_RUNTIME=system`, `BROWSER_FAMILY=chromium` and `BROWSER_HEADLESS=true` for the browser extra. These are already the image defaults; compose `environment:` can override them. The headless image setting matches the application default: render in the workspace without a desktop window. Chromium is resolved through PATH at startup; the image does not pin an executable path. The former `AGENT_BROWSER_EXECUTABLE_PATH` has been removed from the Dockerfile and is not read by this runtime. `BROWSER_RUNTIME=testing` is the only mode that downloads pinned Chrome for Testing; it is never a missing-browser fallback. Validate the built image and Linux libraries before deployment.+**Browser runtime configuration:** the Dockerfile sets `BROWSER_RUNTIME=system`, `BROWSER_FAMILY=chromium` and `BROWSER_HEADLESS=true` in every image, not only with the browser extra; without that extra there is no Chromium, so a Browser node fails clearly instead of downloading one. These are the image defaults; compose `environment:` can override them. The headless image setting matches the application default: render in the workspace without a desktop window. Chromium is resolved through PATH at startup; the image does not pin an executable path. The former `AGENT_BROWSER_EXECUTABLE_PATH` has been removed from the Dockerfile and is not read by this runtime. `BROWSER_RUNTIME=testing` is the only mode that downloads pinned Chrome for Testing; it is never a missing-browser fallback. Validate the built image and Linux libraries before deployment.The image has no Node. It links `/usr/local/bin/node` to bun, so the plugin CLIs whose entry scripts start `#!/usr/bin/env node` (vercel, cf) run on bun, as in the official oven/bun images. Browser automation installs browser-use through uv instead.@@ -128,10 +128,10 @@ No CI job builds the image. What keeps it in step with the rest of the repo:- **The port.** `EXPOSE` and the container side of the compose mapping repeat `PORT` from `.env.template`; `test_docker_port_matches_the_template_port` in the same file fails when the template changes without them.- **Line endings.** `.gitattributes` pins LF for `*.sh` and `docker/Dockerfile`, so a Windows checkout builds the same image. A CRLF entrypoint fails under `sh` at the first line.- **The build context.** Docker does not read `.gitignore`. When you add a local state directory or a secret file pattern to `.gitignore`, add it to `.dockerignore` too, or `COPY . .` bakes it into the image.-- **Build steps.** The build stage runs the same two commands as CI (`bun install --frozen-lockfile`, `bun run build`), then a `uv sync --no-dev` that drops the contributor tools. A new build step belongs in `company build`, not in the Dockerfile, so every channel gets it. Step `[6/6]` fetches the Temporal CLI into `DATA_DIR`, which is why a new named volume starts with it.+- **Build steps.** The build stage runs the same two commands as CI (`bun install --frozen-lockfile`, `bun run build`), then `uv sync --frozen --no-dev --extra docs`: the committed `server/uv.lock`, without the contributor tools, with the `docs` extra `company build` also installs. A new build step belongs in `company build`, not in the Dockerfile, so every channel gets it. Step `[6/6]` fetches the Temporal CLI into `DATA_DIR`, which is why a new named volume starts with it.- **The runtime file list.** The runtime stage copies only what `core/approot.py` reads: `server/`, `client/dist`, `.env.template`, `package.json`, `.opencompany/workflows` and the entrypoint. A new path the backend reads outside `server/` needs a `COPY` line there.- **Optional tools.** A system package that only some nodes need goes into an `EXTRAS` entry, not the default image.## Why the container doesn't run `company serve`-`company serve` needs the CLI's own venv and the root `node_modules`, reads only `<app>/.env` (it ignores `OPENCOMPANY_ENV_FILE`), and its supervisor kills the backend 5 seconds after SIGTERM, which can cut the lifespan shutdown short before the clean-shutdown record is written. The entrypoint runs the uvicorn command the desktop shell uses instead; see [desktop_host_contract.md](./desktop_host_contract.md) for the backend's side of that contract.+`company serve` needs the CLI's own venv and the root `node_modules`, and reads only `<app>/.env` (it ignores `OPENCOMPANY_ENV_FILE`). Its supervisor would also add a second shutdown deadline: it tree-kills the backend after `backend_shutdown_grace_seconds` (`cli/_common.py`; 125 s with the template's Temporal settings), independently of compose's `stop_grace_period`. The entrypoint runs the uvicorn command the desktop shell uses instead; see [desktop_host_contract.md](./desktop_host_contract.md) for the backend's side of that contract.diff --git a/docs-internal/gcp_vm_deploy_runbook.md b/docs-internal/gcp_vm_deploy_runbook.mdindex 5eb11560..801240fc 100644--- a/docs-internal/gcp_vm_deploy_runbook.md+++ b/docs-internal/gcp_vm_deploy_runbook.md@@ -9,7 +9,8 @@ This is the manual path — it does NOT use `company deploy` / Terraform`demo.opencompany.sh` (June 2026, before the scoped-package cutover) and encodes every pitfall hit on the way.Re-validated July 2026 against `0.0.95` with an **IP-only variant** (no Cloudflare /domain — skip step 4): pitfalls 2 and 3 are fixed in `>= 0.0.95` (annotated below),-and pitfalls 11-13 were added from that run.+and pitfalls 11-13 were added from that run. Pitfall 14 is an open issue in 0.2.0+and 0.2.1.The unscoped `opencompany` package belongs to a different publisher. Do not installor remove it while following this runbook.@@ -59,16 +60,16 @@ print('ENC='+secrets.token_hex(24))"in `ubuntu-os-cloud`), which ships Python 3.12.2. **`company serve` exists only in `>= 0.0.95`.** Releases up to 0.0.88 shipped only`start | dev | stop | build | clean | doctor | help | version`; 0.0.95 added the- single-port `serve` (API + WS + SPA, used by the Terraform path). This runbook's- tested shape remains `company start` (static client on **:3000**, backend uvicorn- on **:3010**) plus an nginx reverse proxy on :80/:443 — it works on every release.- **Releases after 0.0.95**: `company start` became single-port itself (uvicorn- serves the SPA; no :3000 static server) AND the default ports moved to the- ports named in `.env.template`: `PYTHON_BACKEND_PORT` (backend), `TEMPORAL_UI_PORT`,- `TEMPORAL_FRONTEND_GRPC_PORT`, `NODEJS_EXECUTOR_PORT`, `WHATSAPP_RPC_PORT`.- When upgrading a VM past 0.0.95, point EVERY nginx `proxy_pass` in step 2- (`/api/`, `/ws/`, `/webhook/`, `/health`, and `location /`) at- `http://127.0.0.1:$PYTHON_BACKEND_PORT;` and reload nginx.+ single-port `serve` (API + WS + SPA, used by the Terraform path). This runbook+ runs `company start` behind an nginx reverse proxy on :80/:443. Up to 0.0.95,+ `company start` served the static client on **:3000** and the backend on+ **:3010**. After 0.0.95 it is single-port itself (uvicorn serves the SPA) and+ the ports moved to the ones named in `.env.template`: `PYTHON_BACKEND_PORT`+ (the app), `TEMPORAL_UI_PORT`, `TEMPORAL_FRONTEND_GRPC_PORT`,+ `NODEJS_EXECUTOR_PORT`, `WHATSAPP_RPC_PORT`. Step 2 reads `PYTHON_BACKEND_PORT`+ from the installed package and points every nginx `proxy_pass` at it. On a+ 0.0.95-or-older release, use :3010 for `/api/`, `/ws/`, `/webhook/` and+ `/health`, and :3000 for `location /`.3. **Owner env seeding requires `>= 0.0.95`.** 0.0.88 ignored `MACHINA_OWNER_*`entirely. Since 0.0.95 the backend seeds the owner at startup from`OPENCOMPANY_OWNER_EMAIL` + `OPENCOMPANY_OWNER_PASSWORD` (>= 8 chars;@@ -76,8 +77,11 @@ print('ENC='+secrets.token_hex(24))"package. You can add those two keys to the env file in step 2 instead of racing toregister. The manual `POST /api/auth/register` in step 6 remains the fallback forolder releases and still works as first-user-becomes-owner either way.-4. **Unknown env vars are fine, but don't set `PORT=80`.** The released backend does- not read `PORT`; nginx owns :80. Keep the env file to the keys listed in step 2.+4. **Unknown env vars are fine, but don't set `PORT=80`.** The backend requires+ `PORT` between 1024 and 65535 (`Settings.port`), so `PORT=80` stops it at+ startup; nginx owns :80. Leave `PORT` at the template value: `company start`+ binds `PYTHON_BACKEND_PORT` while the backend dials itself on `PORT`, so the two+ must match. Keep the env file to the keys listed in step 2.5. **Cloudflare proxied + "Full" SSL mode → 521 without origin TLS.** If the zoneforces HTTPS and SSL mode is Full, Cloudflare connects to origin :443. Fix: nginxlistens on 443 with a **self-signed** cert (Full mode accepts it; only@@ -115,6 +119,11 @@ print('ENC='+secrets.token_hex(24))"root-owned chmod 600: an unprivileged `grep`/`cat` on it fails and short-circuitsany `cmd1 && cmd2` chain (e.g. skipping a trailing `systemctl restart`). Use`sudo` on every command touching it, or chain with `;` and verify state after.+14. **0.2.0 and 0.2.1: `company start` stops with `Project not built. Run "company build" first.`**+ ([errors.md #25 and #26](./errors.md)). The service then fails and restarts in a+ loop, and the package also lacks the JS executor sidecar bundle. Until the fix+ ships, run `sudo company build` once after step 2 (it fixes both), then+ `sudo systemctl restart opencompany`.## Step 1 — Reserve a static IP@@ -158,6 +167,11 @@ bun add -g @zeenie-ai/opencompany@latest# side now so the service's first start is warm. The shim lives in bun's# global bin dir ($BUN_INSTALL/bin) and knows its own package root."$BUN_INSTALL/bin/company" provision+OPENCOMPANY_BIN=$(command -v company)+# The shim is a symlink into the package (bun keeps global packages wherever it+# likes); resolve it rather than spelling that directory.+OPENCOMPANY_PACKAGE_DIR="$(cd "$(dirname "$(readlink -f "$OPENCOMPANY_BIN")")/.." && pwd)"+test -f "$OPENCOMPANY_PACKAGE_DIR/package.json"echo "[opencompany] writing login-gate env..."mkdir -p /etc/opencompany@@ -197,7 +211,12 @@ if [ ! -f /etc/nginx/certs/origin.crt ]; then-subj "/CN=<DOMAIN>"fi-echo "[opencompany] nginx reverse proxy (SPA :3000, backend :3010)..."+echo "[opencompany] nginx reverse proxy (everything to the app port)..."+# company start serves API + WS + SPA on one port: PYTHON_BACKEND_PORT in the+# installed package's .env.template. The heredoc stays quoted so nginx's own+# $variables are not expanded; APP_PORT is filled in with sed below.+APP_PORT=$(grep -E '^PYTHON_BACKEND_PORT=' "$OPENCOMPANY_PACKAGE_DIR/.env.template" | cut -d= -f2)+test -n "$APP_PORT"cat > /etc/nginx/sites-available/opencompany <<'NGINX_EOF'server {listen 80 default_server;@@ -208,14 +227,14 @@ server {client_max_body_size 50m;location /api/ {- proxy_pass http://127.0.0.1:3010;+ proxy_pass http://127.0.0.1:APP_PORT;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_read_timeout 300s;}location /ws/ {- proxy_pass http://127.0.0.1:3010;+ proxy_pass http://127.0.0.1:APP_PORT;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";@@ -225,20 +244,21 @@ server {proxy_send_timeout 3600s;}location /webhook/ {- proxy_pass http://127.0.0.1:3010;+ proxy_pass http://127.0.0.1:APP_PORT;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}location = /health {- proxy_pass http://127.0.0.1:3010;+ proxy_pass http://127.0.0.1:APP_PORT;}location / {- proxy_pass http://127.0.0.1:3000;+ proxy_pass http://127.0.0.1:APP_PORT;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}NGINX_EOF+sed -i "s/APP_PORT/$APP_PORT/g" /etc/nginx/sites-available/opencompanyrm -f /etc/nginx/sites-enabled/defaultln -sf /etc/nginx/sites-available/opencompany /etc/nginx/sites-enabled/opencompanynginx -t@@ -246,11 +266,6 @@ systemctl enable --now nginxsystemctl reload nginxecho "[opencompany] installing systemd service (README usage: company start)..."-OPENCOMPANY_BIN=$(command -v company)-# The shim is a symlink into the package (bun keeps global packages wherever it-# likes); resolve it rather than spelling that directory.-OPENCOMPANY_PACKAGE_DIR="$(cd "$(dirname "$(readlink -f "$OPENCOMPANY_BIN")")/.." && pwd)"-test -f "$OPENCOMPANY_PACKAGE_DIR/package.json"cat > /etc/systemd/system/opencompany.service <<SERVICE_EOF[Unit]Description=OpenCompany (released, company start)diff --git a/server/core/desktop.py b/server/core/desktop.pyindex 5fe65011..0ee0f206 100644--- a/server/core/desktop.py+++ b/server/core/desktop.py@@ -16,12 +16,12 @@ three things the CLI supervisor used to provide:``OPENCOMPANY_DESKTOP_TOKEN``) calls :func:`request_shutdown`, whichraises the signal uvicorn already handles. The normal lifespan teardownthen runs: shutdown hooks, process service, every registered supervisor- (Temporal dev server, Node sidecar, WhatsApp bridge) via+ (Temporal dev server, JS executor sidecar on bun, WhatsApp bridge) via``terminate_then_kill``.3. **No orphans when the backend dies hard.** On Windows the backend puts*itself* into a Job Object with ``KILL_ON_JOB_CLOSE``; children inheritmembership, so if this process is terminated by any means the kernel- kills Temporal / node / edgymeow with it. Done with ``ctypes`` because+ kills Temporal / the bun sidecar / edgymeow with it. Done with ``ctypes`` becausethe server venv deliberately has no ``pywin32`` (that is a CLI-sidedependency).diff --git a/server/services/plugin/shutdown_hooks.py b/server/services/plugin/shutdown_hooks.pyindex 92d205fe..3f73f76d 100644--- a/server/services/plugin/shutdown_hooks.py+++ b/server/services/plugin/shutdown_hooks.py@@ -43,11 +43,14 @@ logger = get_logger(__name__)ShutdownHook = Callable[[], Awaitable[None]]# Per-hook ceiling. A hook that never returns used to wedge the whole-# lifespan teardown: under ``company serve`` the CLI's 5 s grace + tree-kill-# masked it, but a desktop shell waiting for a clean exit (so Temporal / the-# Node sidecar / the WhatsApp bridge are reaped, not orphaned) saw the-# backend hang until the 45 s desktop deadline killed it. Each hook now gets-# this long, then teardown moves on and names the offender at WARNING.+# lifespan teardown: under ``company serve`` the CLI's tree-kill (then 5 s+# after SIGTERM) masked it, but a desktop shell waiting for a clean exit (so+# Temporal / the JS executor sidecar / the WhatsApp bridge are reaped, not+# orphaned) saw the backend hang until the 45 s desktop deadline killed it.+# Each hook now gets this long, then teardown moves on and names the offender+# at WARNING. Hooks run one after another, so the worst case grows with the+# number of hooks, while the desktop shell waits only 30 s before its own+# tree-kill (docs-internal/desktop_host_contract.md).HOOK_TIMEOUT_SECONDS = 10.0