Skip to content
Python

CLI: openworker machine commands, real help and version; package publishes as openworker

Rohit C Prasada5ed9c893709
diff --git a/coworker/cli.py b/coworker/cli.py
index f73fc68d..bbafb3d5 100644
--- a/coworker/cli.py
+++ b/coworker/cli.py
@@ -1,4 +1,11 @@
-"""CLI entry point. `coworker` launches the TUI; `coworker code` boots the code skill."""
+"""CLI entry point.
+
+Public surface: `openworker machine <command>` (run headless, joined to a controller),
+`openworker version`, and help. Everything else is unlisted until it has been tested as a
+product surface: the terminal UI (`openworker tui`, or a skill name as before) and the
+older top-level spellings of the machine commands (`openworker join …`), which enrolled
+boxes and their service units still use.
+"""
from __future__ import annotations
@@ -15,23 +22,57 @@ from .permissions import Mode
from .secrets import state_dir
-REMOTE_COMMANDS = ("join", "auth", "up", "status", "leave", "secrets", "service")
+REMOTE_COMMANDS = ("join", "auth", "up", "status", "leave", "secrets", "keys", "service")
+
+HELP = """\
+usage: openworker <command>
+
+OpenWorker — an open-source AI coworker you govern.
+
+commands:
+ machine run this computer as a headless OpenWorker machine
+ join <link> enroll with the join link from the app, then serve
+ auth join <url> enroll by approving a code in the app, then serve
+ up serve again with the stored identity
+ status show enrollment and the sealing-key fingerprint
+ keys manage provider keys stored on this machine
+ service run `up` as a background service
+ leave forget this machine's enrollment and identity
+ version print the version
+
+Run `openworker machine <command> --help` for details.
+Desktop app and docs: https://openworker.com
+"""
def main(argv: Optional[list[str]] = None) -> None:
import sys
- # Remote-home verbs run headless (no TUI) and must win over the positional
- # `skill` argument — `openworker join <url>` is a command, not a skill.
- args = sys.argv[1:] if argv is None else argv
- if args and args[0] in REMOTE_COMMANDS:
+ args = list(sys.argv[1:] if argv is None else argv)
+ if not args or args[0] in ("-h", "--help", "help"):
+ print(HELP, end="")
+ return
+ if args[0] in ("version", "--version", "-V"):
+ from .remote.channel import app_version
+
+ print(f"openworker {app_version()}")
+ return
+ if args[0] == "machine":
+ from .remote.joiner import cli as remote_cli
+
+ raise SystemExit(remote_cli(args[1:] or ["--help"]))
+ # The older top-level spellings (`openworker join <url>`, `openworker up`): unlisted, kept
+ # working — they must win over the terminal UI's positional `skill` argument.
+ if args[0] in REMOTE_COMMANDS:
from .remote.joiner import cli as remote_cli
raise SystemExit(remote_cli(args))
+ if args[0] == "tui":
+ args = args[1:]
cfg = load_config()
parser = argparse.ArgumentParser(
- prog="openworker", description="Agent coworker (TUI)."
+ prog="openworker tui", description="Terminal UI (unlisted)."
)
parser.add_argument(
"skill", nargs="?", default="code", help="skill to launch (default: code)"
@@ -47,7 +88,7 @@ def main(argv: Optional[list[str]] = None) -> None:
help="permission mode",
)
parser.add_argument("--resume", default=None, help="resume a session id")
- args = parser.parse_args(argv)
+ args = parser.parse_args(args)
workspace = Path(args.cwd).expanduser().resolve()
# Unified global store shared with the GUI/server (one place for all conversations).
diff --git a/coworker/connectors/adapters.py b/coworker/connectors/adapters.py
index b823039a..ca89a7fb 100644
--- a/coworker/connectors/adapters.py
+++ b/coworker/connectors/adapters.py
@@ -107,7 +107,7 @@ class TelegramAdapter(BasePlatformAdapter):
from telegram.ext import Application, MessageHandler, filters
except ImportError:
logger.warning(
- "python-telegram-bot not installed — `pip install coworker[messaging]`"
+ "python-telegram-bot not installed — `pip install 'openworker[messaging]'`"
)
return False
@@ -195,7 +195,7 @@ class SlackAdapter(BasePlatformAdapter):
from slack_sdk.web.async_client import AsyncWebClient
except ImportError:
logger.warning(
- "slack-bolt not installed — `pip install coworker[messaging]`"
+ "slack-bolt not installed — `pip install 'openworker[messaging]'`"
)
return False
diff --git a/coworker/remote/acceptor.py b/coworker/remote/acceptor.py
index 624fe6f1..90acaa95 100644
--- a/coworker/remote/acceptor.py
+++ b/coworker/remote/acceptor.py
@@ -41,7 +41,7 @@ from .stores import Ephemera, InMemoryEphemera, Registry
TOKEN_TTL_SECONDS = 600.0
_CHALLENGE_BYTES = 32
-# Device-authorization flow (`openworker auth join`): the box asks, the user
+# Device-authorization flow (`openworker machine auth join`): the box asks, the user
# approves in the controller UI, approval mints the one join token.
DEVICE_TTL_SECONDS = 900.0
DEVICE_POLL_SECONDS = 5
@@ -137,7 +137,7 @@ class RemoteAcceptor:
"connected": live is not None,
# Public halves only. The sealing key lets a BROWSER seal
# deploys to this machine (OPE-149); its fingerprint is
- # what the user checks against `openworker status`.
+ # what the user checks against `openworker machine status`.
"seal_pubkey": row.get("seal_pubkey") or "",
"seal_fingerprint": (
_fingerprint(row["seal_pubkey"])
@@ -289,7 +289,7 @@ def mount_acceptor(
# whether a token is valid to an unauthenticated caller.
return PlainTextResponse(
"This is an OpenWorker join URL. On the machine you want to add, run:\n"
- " openworker join <this URL> [--name=my-box]\n"
+ " openworker machine join <this URL> [--name=my-box]\n"
)
@app.post("/v1/remote/arm")
@@ -314,7 +314,7 @@ def mount_acceptor(
acceptor.disarm()
return {"armed": False}
- # -- device-authorization flow (`openworker auth join`) --------------------
+ # -- device-authorization flow (`openworker machine auth join`) --------------------
# start/poll are machine-facing and tokenless (like /j/ and /ws/machine);
# listing and approve/deny ride the GUI's sidecar-token middleware. The
# approval MINTS the one join token, bound to the requesting identity —
diff --git a/coworker/remote/channel.py b/coworker/remote/channel.py
index fccfc0f8..576570a8 100644
--- a/coworker/remote/channel.py
+++ b/coworker/remote/channel.py
@@ -48,12 +48,17 @@ RPC_TIMEOUT_SECONDS = 60.0
def app_version() -> str:
- try:
- from importlib.metadata import version
+ from importlib.metadata import PackageNotFoundError, version
- return version("coworker")
- except Exception:
- return "0.0.0"
+ # "coworker" = the distribution's name before it was published as "openworker".
+ for dist in ("openworker", "coworker"):
+ try:
+ return version(dist)
+ except PackageNotFoundError:
+ continue
+ except Exception:
+ break
+ return "0.0.0"
def encode_body(body: bytes | None) -> str:
diff --git a/coworker/remote/joiner.py b/coworker/remote/joiner.py
index 14d245f0..3a56a14c 100644
--- a/coworker/remote/joiner.py
+++ b/coworker/remote/joiner.py
@@ -546,12 +546,16 @@ def _lifespan(app):
# -- CLI ----------------------------------------------------------------------
-def cli(argv: Optional[list[str]] = None) -> int:
+def cli(argv: Optional[list[str]] = None, prog: str = "openworker machine") -> int:
from ..secrets import state_dir
+ argv = list(sys.argv[1:] if argv is None else argv)
+ # `keys` is the public name; `secrets` is the older spelling and keeps working.
+ if argv and argv[0] == "secrets":
+ argv[0] = "keys"
parser = argparse.ArgumentParser(
- prog="openworker",
- description="Remote-home commands: run this OpenWorker headless, joined to a controller.",
+ prog=prog,
+ description="Run this OpenWorker headless, joined to a controller (the desktop app or OpenWorker Cloud).",
)
sub = parser.add_subparsers(dest="command", required=True)
@@ -573,7 +577,7 @@ def cli(argv: Optional[list[str]] = None) -> int:
sub.add_parser("status", help="show this machine's remote-home state")
# Box-side provisioning (remote-home-design.md §Keys wallet, door 2): write
# secrets straight into THIS machine's store — the wallet never in the path.
- p_secrets = sub.add_parser("secrets", help="manage this machine's local secrets")
+ p_secrets = sub.add_parser("keys", help="manage provider keys stored on this machine")
secrets_sub = p_secrets.add_subparsers(dest="secrets_command", required=True)
p_set = secrets_sub.add_parser("set", help="write one profile: NAME key=value …")
p_set.add_argument("profile")
@@ -585,7 +589,7 @@ def cli(argv: Optional[list[str]] = None) -> int:
p_service = sub.add_parser("service", help="run this joined machine under systemd")
service_sub = p_service.add_subparsers(dest="service_command", required=True)
p_install = service_sub.add_parser(
- "install", help="write + enable a user unit running `openworker up`"
+ "install", help="write + enable a user unit that keeps this machine serving"
)
p_install.add_argument(
"--force", action="store_true", help="replace another unit already pinned to this state dir"
@@ -608,7 +612,7 @@ def cli(argv: Optional[list[str]] = None) -> int:
return _cmd_status(state)
if args.command == "leave":
return _cmd_leave(state, args.yes)
- if args.command == "secrets":
+ if args.command == "keys":
return _cmd_secrets(state, args)
if args.command == "service":
return _cmd_service(state, args)
@@ -699,7 +703,7 @@ def _cmd_up(state: Path) -> int:
cfg = load_remote_config(state)
if cfg is None:
print(
- "error: this machine has not joined a controller (run `openworker join <url>`)",
+ "error: this machine has not joined a controller (run `openworker machine join <link>`)",
file=sys.stderr,
)
return 2
@@ -827,7 +831,7 @@ def _cmd_service(state: Path, args, platform: Optional[str] = None, home: Option
if platform != "linux":
print(
"error: `service install` targets Linux/systemd (the VM/server the box "
- "runs on). On macOS just run `openworker up` in a terminal or via launchd.",
+ "runs on). On macOS just run `openworker machine up` in a terminal or via launchd.",
file=sys.stderr,
)
return 2
@@ -854,7 +858,7 @@ def _cmd_service(state: Path, args, platform: Optional[str] = None, home: Option
if cfg is None:
print(
"error: this machine has not joined a controller yet — run "
- "`openworker join <url>` first, then install the service.",
+ "`openworker machine join <link>` first, then install the service.",
file=sys.stderr,
)
return 2
@@ -868,8 +872,8 @@ def _cmd_service(state: Path, args, platform: Optional[str] = None, home: Option
if same and not getattr(args, "force", False):
for r in same:
print(
- f"error: {r['unit']} already runs `openworker up` on this state dir "
- f"({state}). Remove it first (`openworker service uninstall --unit "
+ f"error: {r['unit']} already runs on this state dir "
+ f"({state}). Remove it first (`openworker machine service uninstall --unit "
f"{r['unit']}`) or pass --force to replace it.",
file=sys.stderr,
)
diff --git a/coworker/server/run.py b/coworker/server/run.py
index 40cd9ac9..5eba5f6a 100644
--- a/coworker/server/run.py
+++ b/coworker/server/run.py
@@ -142,7 +142,7 @@ _ENGINE_LOCK = None
def _warn_if_state_shared() -> None:
"""The desktop sidecar runs on a random port precisely so it can coexist with
a hand-run `openworker-server` on the same state dir, so this entrypoint only
- WARNS about a second engine (statelock.py). `openworker up` refuses outright;
+ WARNS about a second engine (statelock.py). `openworker machine up` refuses outright;
set COWORKER_STATE_LOCK=strict to make this server refuse too."""
global _ENGINE_LOCK
from ..statelock import EngineBusy, acquire
diff --git a/docs/remote-machines.md b/docs/remote-machines.md
index 6e58c400..a1718b26 100644
--- a/docs/remote-machines.md
+++ b/docs/remote-machines.md
@@ -44,7 +44,7 @@ echo 'export PATH=$HOME/ow-venv/bin:$PATH' >> ~/.bashrc && source ~/.bashrc
Check it:
```bash
-openworker status
+openworker machine status
```
You should see `controller: not joined` — a fresh, unenrolled machine.
@@ -81,11 +81,11 @@ supervisor to keep it up unattended.
3. Copy the one-line command from the card and run it on the machine:
```bash
-openworker join http://127.0.0.1:8765/j/<token> --name=my-box
+openworker machine join http://127.0.0.1:8765/j/<token> --name=my-box
```
The card flips to **“✓ my-box joined”** and shows the machine's key
-fingerprint. Verify it matches `openworker status` on the machine — that
+fingerprint. Verify it matches `openworker machine status` on the machine — that
fingerprint is the machine's permanent identity. The token is single-use and
already dead; reconnects authenticate with the machine's own keypair, so you
never enroll twice.
@@ -103,7 +103,7 @@ your desktop is not in the loop at runtime). Three ways:
- **On the machine itself**, if you'd rather keys never transit anywhere:
```bash
-openworker secrets set provider:openai api_key=sk-...
+openworker machine keys set provider:openai api_key=sk-...
```
(Or inject via environment/secret-manager — the machine's store resolves
@@ -136,17 +136,17 @@ Slack, …) are *not* copied between machines — each machine connects its own.
To keep the machine serving across logouts and reboots, on the machine:
```bash
-openworker service install
+openworker machine service install
```
-This writes and enables a systemd user unit running `openworker up`
+This writes and enables a systemd user unit running `openworker machine up`
(auto-restart, 5s backoff). To also run without anyone logged in:
```bash
sudo loginctl enable-linger $USER
```
-`openworker service uninstall` reverses it. (If you used the SSH-tunnel
+`openworker machine service uninstall` reverses it. (If you used the SSH-tunnel
option, remember the tunnel on your desktop needs the same treatment —
`autossh` or a LaunchAgent — or the machine will wait patiently for a tunnel
that isn't there.)
@@ -179,6 +179,6 @@ and cloud features on top, and signing out hides only those.
| Turn fails with a key error | The machine resolves models with **its** keys — deploy one (§3) or check the machine's model settings via the session's model picker. |
State on the machine lives in `~/.config/coworker` (identity keys, secrets,
-conversations). `openworker leave` forgets the enrollment *and* the identity —
+conversations). `openworker machine leave` forgets the enrollment *and* the identity —
re-joining afterwards needs a fresh join URL, and the old entry can be removed
from the desktop's Machines page.
diff --git a/pyproject.toml b/pyproject.toml
index 3c18c63a..10144b3b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,9 +3,11 @@ requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"
[project]
-name = "coworker"
-version = "0.0.0"
-description = "Agent coworker platform — provider-agnostic agentic coworker runtime"
+name = "openworker"
+version = "0.2.3"
+description = "OpenWorker — an open-source AI coworker you govern. The headless runtime and CLI."
+readme = "README.md"
+license = { text = "MIT" }
requires-python = ">=3.10"
dependencies = [
"openai>=1.0",
@@ -15,9 +17,8 @@ dependencies = [
"textual>=1.0",
"fastapi>=0.110",
"uvicorn[standard]>=0.27",
- # aisuite (toolkits/tracing), pinned to the commit this repo was imported from;
- # swap for a PyPI pin ("aisuite>=x.y") once the next aisuite release ships.
- "aisuite @ git+https://github.com/andrewyng/aisuite.git@1b4bbf303ec21968230b1ec869a144d054e9b3c4",
+ # aisuite (tool metadata, toolkits, tracing). 0.2.0 is the first PyPI release with those modules.
+ "aisuite>=0.2.0",
"docstring_parser",
"pyyaml>=6", # persona manifest frontmatter (YAML)
"pydantic>=2",
@@ -39,6 +40,10 @@ dependencies = [
"tomli>=2; python_version < '3.11'",
]
+[project.urls]
+Homepage = "https://openworker.com"
+Source = "https://github.com/andrewyng/openworker"
+
[project.optional-dependencies]
dev = ["pytest>=8", "pytest-asyncio", "pytest-cov>=5", "httpx", "httpx2"]
# Inbound messaging listeners (outbound send_message needs only httpx, already a core dep).
diff --git a/surfaces/gui/e2e/machines.spec.ts b/surfaces/gui/e2e/machines.spec.ts
index 3011ca50..91c2b8d2 100644
--- a/surfaces/gui/e2e/machines.spec.ts
+++ b/surfaces/gui/e2e/machines.spec.ts
@@ -68,7 +68,7 @@ test("enrollment: arming shows the one-liner, a joining box flips the card", asy
await page.getByText("Add a machine…").click();
await expect(page.getByTestId("join-command")).toContainText(
- "openworker join http://127.0.0.1:9787/j/e2e-token",
+ "openworker machine join http://127.0.0.1:9787/j/e2e-token",
);
await expect(page.getByText(/Waiting for the machine/)).toBeVisible();
await expect(page.getByTestId("token-countdown")).toContainText("token expires in");
diff --git a/surfaces/gui/src/api.ts b/surfaces/gui/src/api.ts
index dda3fc10..9f2ac3b3 100644
--- a/surfaces/gui/src/api.ts
+++ b/surfaces/gui/src/api.ts
@@ -2957,7 +2957,7 @@ export interface Machine {
last_seen: number | null;
connected: boolean;
// Public halves only (older backends omit them): what a browser seals key
- // deploys to, and the fingerprint the user checks with `openworker status`.
+ // deploys to, and the fingerprint the user checks with `openworker machine status`.
seal_pubkey?: string;
seal_fingerprint?: string;
// Union view: where this row lives. Absent = the local registry; "cloud"
@@ -3208,7 +3208,7 @@ export async function getMe(): Promise<MeInfo> {
return r.json();
}
-// -- device-flow approval (`openworker auth join` — typed-code, GitHub-style) --
+// -- device-flow approval (`openworker machine auth join` — typed-code, GitHub-style) --
export interface DeviceRequestDetail {
user_code: string;
diff --git a/surfaces/gui/src/components/MachinesSection.test.tsx b/surfaces/gui/src/components/MachinesSection.test.tsx
index 08b02f5b..32de836f 100644
--- a/surfaces/gui/src/components/MachinesSection.test.tsx
+++ b/surfaces/gui/src/components/MachinesSection.test.tsx
@@ -76,7 +76,7 @@ describe("MachinesSection", () => {
fireEvent.click(screen.getByText("Add a machine…"));
await waitFor(() =>
expect(screen.getByTestId("join-command").textContent).toContain(
- "openworker join http://127.0.0.1:9787/j/tok123",
+ "openworker machine join http://127.0.0.1:9787/j/tok123",
),
);
expect(armCalls).toBe(1);
diff --git a/surfaces/gui/src/components/MachinesSection.tsx b/surfaces/gui/src/components/MachinesSection.tsx
index a9ea82d7..0267a5bd 100644
--- a/surfaces/gui/src/components/MachinesSection.tsx
+++ b/surfaces/gui/src/components/MachinesSection.tsx
@@ -453,7 +453,7 @@ export function MachinesSection() {
// The signed-in identity + org switcher moved to Settings ▸ Account
// (UX-046 tail, 2026-08-30) — this page is the fleet list only.
-// Typed-code approval for `openworker auth join` (GitHub device-flow style).
+// Typed-code approval for `openworker machine auth join` (GitHub device-flow style).
// The machine printed a code; the user types it here, checks the fingerprint
// against what the machine printed, and decides. Approval mints the one join
// token, bound to that machine's identity — a mistyped code shows a stranger's
@@ -561,7 +561,7 @@ function ApproveMachineCard({
components={{
cmd: (
<span className="font-mono text-ink">
- {`openworker auth join <${t("machines.approve.this_url")}>`}
+ {`openworker machine auth join <${t("machines.approve.this_url")}>`}
</span>
),
}}
@@ -690,7 +690,7 @@ function AddMachineCard({
return "9787";
}
})();
- const command = joinUrl ? `openworker join ${joinUrl} --name=my-box` : "…";
+ const command = joinUrl ? `openworker machine join ${joinUrl} --name=my-box` : "…";
const copy = async () => {
if (!joinUrl) return;
@@ -835,7 +835,7 @@ function AddMachineCard({
// Per-machine key deploy for wallet-less backends (OPE-149). The value is
// sealed IN THIS TAB to the machine's attested sealing key; the backend
// relays ciphertext and records only names. The fingerprint shown here is
-// the user's verification anchor: `openworker status` on the box prints the
+// the user's verification anchor: `openworker machine status` on the box prints the
// same sixteen characters.
const KEY_PROVIDERS = [
{ id: "anthropic", label: "Anthropic" },
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index 7e6013a4..2e88223b 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -1991,7 +1991,7 @@
"title": "Keys on {{name}}",
"no_seal_key": "This machine has no sealing key pinned yet — reconnect it once on current OpenWorker code, then reopen this card.",
"sealed_note": "The key is sealed in this browser tab to this machine's key and passes through the server as ciphertext — it is never stored here.",
- "fingerprint_line": "Machine sealing key <fp/> — verify with <cmd>openworker status</cmd> on the box.",
+ "fingerprint_line": "Machine sealing key <fp/> — verify with <cmd>openworker machine status</cmd> on the box.",
"deployed_on": "deployed {{date}}",
"custom_profile": "Custom profile…",
"profile_placeholder": "profile name",
@@ -2004,7 +2004,7 @@
"models": {
"title": "Models & Keys",
"sub": "On ⌂ {{name}}",
- "sub_sealed": "On ⌂ {{name}} · sealing key {{fingerprint}} — verify with `openworker status` on the machine.",
+ "sub_sealed": "On ⌂ {{name}} · sealing key {{fingerprint}} — verify with `openworker machine status` on the machine.",
"active_heading": "Active on this machine",
"loading": "Loading from the machine…",
"offline": "Machine is offline — its models can't be read right now.",
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 439fed47..7d16c883 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -1952,7 +1952,7 @@
"title": "{{name}} 上的密钥",
"no_seal_key": "此机器尚未固定密封密钥 —— 请用当前版本的 OpenWorker 重新连接一次,然后重新打开此卡片。",
"sealed_note": "密钥在此浏览器标签页中用该机器的密钥密封,并以密文形式经过服务器 —— 绝不会存储在这里。",
- "fingerprint_line": "机器密封密钥 <fp/> —— 在机器上运行 <cmd>openworker status</cmd> 进行核对。",
+ "fingerprint_line": "机器密封密钥 <fp/> —— 在机器上运行 <cmd>openworker machine status</cmd> 进行核对。",
"deployed_on": "部署于 {{date}}",
"custom_profile": "自定义配置…",
"profile_placeholder": "配置名称",
@@ -1965,7 +1965,7 @@
"models": {
"title": "模型与密钥",
"sub": "位于 ⌂ {{name}}",
- "sub_sealed": "位于 ⌂ {{name}} · 密封密钥 {{fingerprint}} —— 在机器上运行 `openworker status` 进行核对。",
+ "sub_sealed": "位于 ⌂ {{name}} · 密封密钥 {{fingerprint}} —— 在机器上运行 `openworker machine status` 进行核对。",
"active_heading": "此机器上已启用",
"loading": "正在从机器加载…",
"offline": "机器离线 —— 目前无法读取其模型。",
diff --git a/surfaces/gui/src/routes.ts b/surfaces/gui/src/routes.ts
index ba76409b..4db09bfe 100644
--- a/surfaces/gui/src/routes.ts
+++ b/surfaces/gui/src/routes.ts
@@ -4,7 +4,7 @@
// before the first rewrite.
//
// #/approve/XXXX-XXXX → open Settings ▸ Machines with the code prefilled
-// (what `openworker auth join` prints on hosted)
+// (what `openworker machine auth join` prints on hosted)
// #/s/{sessionId} → land on that session (bookmark/refresh)
// #/settings/{page}?m={id} → open that Settings page; ?m= is the machine
// scope for machine-scoped pages (UX-046)
diff --git a/tests/test_cli_surface.py b/tests/test_cli_surface.py
new file mode 100644
index 00000000..62adf547
--- /dev/null
+++ b/tests/test_cli_surface.py
@@ -0,0 +1,62 @@
+"""The public CLI surface: `openworker machine …`, `version`, and help that lists them.
+Older top-level spellings stay working (enrolled boxes and their service units use them)."""
+
+import pytest
+
+from coworker import cli as ow_cli
+from coworker.remote import joiner
+
+
+def test_no_arguments_prints_help_that_lists_the_machine_commands(capsys):
+ ow_cli.main([])
+ out = capsys.readouterr().out
+ assert "usage: openworker <command>" in out
+ for verb in ("machine", "join", "up", "status", "keys", "service", "leave", "version"):
+ assert verb in out
+ # Unlisted until tested as a product surface.
+ for hidden in ("tui", "sessions", "inbox", "doctor"):
+ assert hidden not in out
+
+
[email protected]("flag", ["-h", "--help", "help"])
+def test_help_flags_print_the_same_help(flag, capsys):
+ ow_cli.main([flag])
+ assert "usage: openworker <command>" in capsys.readouterr().out
+
+
[email protected]("flag", ["version", "--version", "-V"])
+def test_version(flag, capsys):
+ ow_cli.main([flag])
+ out = capsys.readouterr().out.strip()
+ assert out.startswith("openworker ") and out.split()[1][0].isdigit()
+
+
+def test_machine_group_runs_the_headless_commands(tmp_path, monkeypatch, capsys):
+ monkeypatch.setenv("COWORKER_STATE_DIR", str(tmp_path))
+ with pytest.raises(SystemExit) as exc:
+ ow_cli.main(["machine", "status"])
+ assert exc.value.code == 0
+ assert "not joined" in capsys.readouterr().out
+
+
+def test_machine_with_no_command_shows_its_help(capsys):
+ with pytest.raises(SystemExit) as exc:
+ ow_cli.main(["machine"])
+ assert exc.value.code == 0
+ assert "usage: openworker machine" in capsys.readouterr().out
+
+
+def test_older_top_level_spelling_still_works(tmp_path, monkeypatch, capsys):
+ monkeypatch.setenv("COWORKER_STATE_DIR", str(tmp_path))
+ with pytest.raises(SystemExit) as exc:
+ ow_cli.main(["status"])
+ assert exc.value.code == 0
+ assert "not joined" in capsys.readouterr().out
+
+
+def test_keys_is_the_public_name_and_secrets_still_works(tmp_path, monkeypatch, capsys):
+ monkeypatch.setenv("COWORKER_STATE_DIR", str(tmp_path))
+ assert joiner.cli(["keys", "set", "openai", "api_key=sk-local"]) == 0
+ assert joiner.cli(["secrets", "list"]) == 0
+ out = capsys.readouterr().out
+ assert "openai" in out and "sk-local" not in out