aihabitat-cli 2026.625.0

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 (3) hide show
  1. package/README.md +125 -0
  2. package/dist/cli.js +9342 -0
  3. package/package.json +33 -0
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # `@habitat/cli` — Habitat for Linux
2
+
3
+ A headless command-line client for [Habitat](https://aihabitat.live). Log in, run
4
+ your agents (Codex / Claude Code) routed through Habitat, manage your wallet, and
5
+ invoke managed capabilities — all from a terminal or SSH session. No GUI, no
6
+ Electron.
7
+
8
+ ```bash
9
+ npm i -g @habitat/cli
10
+ habitat login
11
+ habitat agent install claude
12
+ habitat agent run claude
13
+ ```
14
+
15
+ ## What it does
16
+
17
+ - **Account** — password login with refresh-token rotation; the session and your
18
+ default API key are stored `0600` under `~/.config/habitat`.
19
+ - **Agents** — installs the official `@openai/codex` and `@anthropic-ai/claude-code`
20
+ CLIs into a managed dir (`~/.openclaw/agent-clis`), points them at the Habitat
21
+ gateway, and runs them in your current terminal.
22
+ - **Wallet** — balance, vitals (burn rate / runway), recharge-code redemption,
23
+ ledger and recharge history.
24
+ - **Skills** — invoke Habitat's managed capabilities (image generation, audio
25
+ transcription, wallet vitals) with just your API key.
26
+
27
+ ## Commands
28
+
29
+ ```
30
+ Account
31
+ login [-i <email|phone>] [-p <password>] Log in
32
+ logout Clear local session + key
33
+ whoami Show the logged-in account
34
+
35
+ Agents
36
+ agent ls List agents + install status
37
+ agent install <codex|claude> Install an agent CLI
38
+ agent update [<codex|claude>|--all] Update agent CLI(s)
39
+ agent uninstall <codex|claude> Remove an agent CLI
40
+ agent bind <codex|claude> [-m <model>] Point an agent at Habitat
41
+ agent run <codex|claude> [-m <model>] [-- <args>] Run an agent in this terminal
42
+ agent doctor Diagnose runtime + routing
43
+
44
+ Wallet
45
+ wallet balance Wallet balance
46
+ wallet vitals Balance / burn rate / runway
47
+ wallet ledger [-n <limit>] Recent ledger entries
48
+ wallet history [-n <limit>] Recharge history
49
+ redeem <code> Redeem a recharge code
50
+
51
+ Skills
52
+ skill ls List managed capabilities
53
+ skill invoke <id> [--arg k=v]... [-m <model>] [--json]
54
+
55
+ Config
56
+ config Show config
57
+ config set api-base-url <url> Set the API base URL
58
+ config --profile <prod|local> Switch base-URL profile
59
+ config set-model <agent> <model> Set an agent's default model
60
+ ```
61
+
62
+ ### Examples
63
+
64
+ ```bash
65
+ # First run on a fresh server
66
+ npm i -g @habitat/cli
67
+ habitat login -i alice@example.com
68
+ habitat agent install claude
69
+ habitat agent run claude # Claude Code, routed through Habitat, in this TTY
70
+
71
+ # Top up with a recharge code, then check vitals
72
+ habitat redeem HABITAT-7Q4K-9XZP
73
+ habitat wallet vitals
74
+
75
+ # Generate an image via a managed capability (just needs your API key)
76
+ habitat skill invoke habitat.image.generate --arg prompt="a red panda" --arg size=1024x1024
77
+
78
+ # Pass flags through to the underlying agent
79
+ habitat agent run codex -- --help
80
+ ```
81
+
82
+ ## How routing works
83
+
84
+ - **Codex** — `bind`/`run` writes `~/.codex/config.toml` (`model_provider = "habitat"`,
85
+ provider `base_url = <api>/v1`, `wire_api = "responses"`) and your real
86
+ `sk-habitat-` key into `~/.codex/auth.json`. Codex talks directly to Habitat; it
87
+ keeps working after the CLI exits. Existing config keys are preserved.
88
+ - **Claude Code** — `run` launches `claude` with `ANTHROPIC_BASE_URL` +
89
+ `ANTHROPIC_AUTH_TOKEN` injected into the process environment (any ambient
90
+ `ANTHROPIC_*` is stripped so Habitat's routing wins). No file is written and your
91
+ `~/.claude` config is untouched.
92
+
93
+ ## Environment
94
+
95
+ | Variable | Purpose |
96
+ |---|---|
97
+ | `CLAW_HABITAT_API_BASE_URL` | Override the API base URL (default `https://api.aihabitat.live`) |
98
+ | `HABITAT_CLI_CONFIG_DIR` | Override the config/secret dir (default `$XDG_CONFIG_HOME/habitat`) |
99
+ | `OPENCLAW_STATE_DIR` | Override the managed-agent install dir (default `~/.openclaw`) |
100
+ | `OPENCLAW_NPM_REGISTRY` | Pin the npm registry used to install agents |
101
+ | `HTTPS_PROXY` / `HTTP_PROXY` | Forwarded to npm when installing agents |
102
+ | `NO_COLOR` | Disable colored output |
103
+
104
+ ## Security
105
+
106
+ Credentials are stored in `~/.config/habitat/secrets.json` with `0600`
107
+ permissions (the same posture as `gh`, `aws`, and the codex CLI's own
108
+ `auth.json`). This is a deliberate, documented downgrade from the desktop app,
109
+ which encrypts secrets with the OS keychain. A keyring backend is planned.
110
+
111
+ ## Development
112
+
113
+ ```bash
114
+ npm run typecheck # tsc --noEmit
115
+ npm run test # node --test (no network)
116
+ npm run build # tsup → dist/cli.js (self-contained, bundles @habitat/shared)
117
+ npm run dev -- <args>
118
+ ```
119
+
120
+ ## Scope
121
+
122
+ MVP: password login, agent install/run (Codex + Claude, direct-key), wallet
123
+ balance/vitals/redeem, and capability invoke. Planned: card recharge
124
+ (Alipay/Stripe order + poll), verification-code login, an opt-in loopback proxy,
125
+ and version-policy-gated self-update.