aihabitat-cli 2026.625.0 → 2026.625.1

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