@synap-core/cli 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -6,19 +6,12 @@ Connect [OpenClaw](https://github.com/openclaw/openclaw) to your Synap pod — s
6
6
  npx @synap-core/cli init
7
7
  ```
8
8
 
9
- ---
10
-
11
- ## What it does
12
-
13
- `synap init` walks you through three paths depending on your setup:
14
-
15
- | Path | When to use |
16
- |------|-------------|
17
- | **A** — Existing OpenClaw | OpenClaw is already running, just connect it to Synap |
18
- | **B** — Fresh install | No OpenClaw yet — generates config, you run `openclaw --config synap.json` |
19
- | **C** — Managed pod | Point to your Synap cloud pod, CLI handles everything |
20
-
21
- After init, your AI agent gets structured memory (entities, relationships, full-text search, knowledge graph) via the `synap` OpenClaw skill.
9
+ After `synap init` + `synap finish`, you get:
10
+ - A running Synap pod with the `synap` skill installed in OpenClaw
11
+ - OpenClaw connected to Synap's structured memory, entities, documents, and governance layer
12
+ - An AI provider key configured inside OpenClaw
13
+ - A public HTTPS dashboard URL (managed pods) no SSH tunnel needed
14
+ - MCP client configs (Claude Desktop / Cursor / Windsurf) ready to paste
22
15
 
23
16
  ---
24
17
 
@@ -35,161 +28,215 @@ synap init
35
28
 
36
29
  **Requirements**: Node.js 20+
37
30
 
38
- > Detailed setup for Linux servers, Docker, SSH environments, and permission issues: [docs/INSTALL.md](docs/INSTALL.md)
31
+ Detailed environment setup: [docs/INSTALL.md](docs/INSTALL.md)
39
32
 
40
33
  ---
41
34
 
42
- ## Commands
35
+ ## The two-command flow
43
36
 
44
- ### `synap init`
37
+ `synap init` + `synap finish` is the full path. `init` handles detection and provisioning; `finish` wires everything up.
45
38
 
46
- Full setup wizard. Detects OpenClaw, connects to a pod, installs the skill, seeds the Agent OS workspace.
39
+ ### `synap init`
47
40
 
48
- ```bash
49
- synap init
50
- ```
41
+ Detects your environment and picks one of three paths:
51
42
 
52
- If OpenClaw is being provisioned on a managed server, setup may take a few minutes. Run `synap finish` once it's ready.
43
+ | Path | When |
44
+ |---|---|
45
+ | **A** — Existing OpenClaw | OpenClaw is already running locally |
46
+ | **B** — Fresh server | No OpenClaw — starts pod + OpenClaw via Docker |
47
+ | **C** — Desktop / managed pod | Connects to a Synap-hosted pod |
53
48
 
54
- ---
49
+ On a fresh server, OpenClaw's first boot takes a few minutes (image pull + init). Run `synap finish` once it's up.
55
50
 
56
51
  ### `synap finish`
57
52
 
58
- Complete the setup after OpenClaw has started (managed pod path). Installs the skill, seeds entities, configures the intelligence service.
53
+ One-shot completion. Runs:
54
+ 1. **Skill install** — `openclaw skills install synap` (from ClawHub)
55
+ 2. **Workspace seed** — creates Agent OS entities
56
+ 3. **AI provider setup** — prompts you for a key if OpenClaw doesn't have one, writes it via `openclaw config set env.ANTHROPIC_API_KEY …`
57
+ 4. **Public dashboard** (managed pods) — offers to expose `openclaw.yourpod.synap.live` via the CP, with Synap-session-based auth (no extra password)
58
+ 5. **Intelligence Service** — optional, routes AI through your pod
59
+
60
+ After this, everything is ready. No follow-up commands.
59
61
 
62
+ Flags:
60
63
  ```bash
61
- synap finish
64
+ synap finish --skip-ai-key # Don't prompt for AI key
65
+ synap finish --skip-domain # Don't offer public domain
66
+ synap finish --skip-is # Don't configure IS
62
67
  ```
63
68
 
64
- Run this after `synap init` if prompted — it's the second half of the managed pod flow.
65
-
66
69
  ---
67
70
 
68
- ### `synap status`
71
+ ## `synap openclaw` — everything OpenClaw
69
72
 
70
- Show the health of your entire stack at a glance.
73
+ Wraps the things you actually need after install.
71
74
 
72
- ```bash
73
- synap status
74
- ```
75
+ ### `synap openclaw`
75
76
 
76
- Output covers:
77
- - **Account** — login state, token expiry
78
- - **OpenClaw** — local running state, or remote provisioning state on your pod
79
- - **Synap Pod** — URL, health, version
80
- - **Workspace Config** — workspace ID, agent user, when config was saved
81
- - **Intelligence Service** — whether AI is provisioned
82
- - **Synap Skill** — whether the skill is installed in OpenClaw
83
- - **Next Steps** — what to do next
77
+ Overview: gateway status, AI provider, skill, dashboard URL, next steps.
84
78
 
85
- ---
79
+ ### `synap openclaw dashboard`
86
80
 
87
- ### `synap login`
81
+ Opens the OpenClaw web UI. If a public domain is configured, opens it directly. Otherwise opens `http://localhost:18789` or — on a remote Linux server — prints an SSH tunnel command.
88
82
 
89
- Sign in to your Synap account. Required for managed pod flows.
83
+ ### `synap openclaw connect`
84
+
85
+ Generates MCP client configs for Claude Desktop, Cursor, Windsurf — **with the gateway token pre-filled** so remote setups work without manual editing.
90
86
 
91
87
  ```bash
92
- synap login # Opens browser
93
- synap login --token <token> # Headless / server environments
88
+ synap openclaw connect # All three clients
89
+ synap openclaw connect --client claude # Just Claude Desktop
94
90
  ```
95
91
 
96
- For servers without a browser, generate a token at [synap.live/account/tokens](https://synap.live/account/tokens) and use `--token`.
92
+ ### `synap openclaw configure`
97
93
 
98
- Your session is kept alive automatically as long as `synap status` or `synap init` succeeds at least once every 7 days, you won't need to re-login.
94
+ Sets OpenClaw's AI provider via its own config system (`openclaw config set env.ANTHROPIC_API_KEY …`). No `.env` hacking the real OpenClaw config layer.
99
95
 
100
- ---
96
+ ```bash
97
+ # Interactive (in CLI)
98
+ synap openclaw configure
101
99
 
102
- ### `synap logout`
100
+ # Interactive (hand off to OpenClaw's own wizard)
101
+ synap openclaw configure --interactive
102
+
103
+ # Scripted
104
+ synap openclaw configure --provider anthropic --key sk-ant-... --model anthropic/claude-sonnet-4-6
103
105
 
104
- Remove stored credentials.
106
+ # Read current config
107
+ synap openclaw configure --show
108
+ ```
109
+
110
+ ### `synap openclaw token`
111
+
112
+ Reads the OpenClaw gateway token from the container. You need this to connect MCP clients to a remote gateway.
105
113
 
106
114
  ```bash
107
- synap logout
115
+ synap openclaw token # Print it
116
+ synap openclaw token --copy # Copy to clipboard
117
+ synap openclaw token --for claude # Print a ready-to-paste Claude Desktop config
108
118
  ```
109
119
 
110
- ---
120
+ ### `synap openclaw setup-domain`
111
121
 
112
- ### `synap connect`
122
+ Expose the OpenClaw dashboard at a public HTTPS URL.
123
+
124
+ - **Managed pods** (`*.synap.live`): calls the CP to create a DNS A record automatically (`openclaw.yourpod.synap.live`), wires Caddy's `forward_auth` to validate your existing Synap session cookie. Zero manual auth.
125
+ - **Self-hosted**: prompts for a subdomain, tells you which DNS A record to add, generates a random 32-char password, and writes a Caddy basic-auth gate. Hashes via `caddy hash-password` — no bcrypt dependency.
126
+
127
+ Both modes forge `X-Real-IP: 127.0.0.1` at the Caddy layer so OpenClaw treats requests as loopback and skips device pairing. Auth is enforced at the Caddy layer.
128
+
129
+ ### `synap openclaw doctor`
113
130
 
114
- Connect to a pod that was already provisioned (skip the full init wizard).
131
+ Thin wrapper around OpenClaw's own diagnostic. Use `--fix` to auto-repair known issues.
115
132
 
116
133
  ```bash
117
- synap connect
134
+ synap openclaw doctor
135
+ synap openclaw doctor --fix
118
136
  ```
119
137
 
138
+ ### `synap openclaw logs`
139
+
140
+ ```bash
141
+ synap openclaw logs # Last 50 lines
142
+ synap openclaw logs -n 200 # More
143
+ synap openclaw logs -f # Follow
144
+ ```
145
+
146
+ ### `synap openclaw restart`
147
+
148
+ Restart the container. Handy after config changes.
149
+
120
150
  ---
121
151
 
122
- ### `synap security-audit`
152
+ ## Top-level commands
153
+
154
+ ### `synap status`
155
+
156
+ Health check across the stack: pod, OpenClaw, auth, skill, Intelligence Service.
123
157
 
124
- Check your OpenClaw + Synap config for common security issues (API key exposure, outdated versions, HTTPS enforcement, etc.).
158
+ ### `synap login`
125
159
 
126
160
  ```bash
127
- synap security-audit
128
- synap security-audit --fix # Auto-fix what's fixable
161
+ synap login # Opens browser
162
+ synap login --token <token> # Headless / server
129
163
  ```
130
164
 
131
- Example output:
165
+ Token: [synap.live/account/tokens](https://synap.live/account/tokens). Your session auto-refreshes for 7 days.
132
166
 
133
- ```
134
- ✓ Gateway bound to loopback
135
- ✓ Token authentication enabled
136
- ✗ OpenClaw version 2026.2.x — CRITICAL (9.9 CVSS)
137
- ✓ No plaintext credentials
138
- ✗ ~/.openclaw world-readable
139
- ✓ WebSocket origin validation
140
- ✓ Dangerous skill scanner
141
- ✓ Workspace filesystem access
142
- ✓ Exec approval gates
143
-
144
- Score: B (2 issues, 1 critical)
145
- ```
167
+ ### `synap logout`
146
168
 
147
- ---
169
+ ### `synap connect`
170
+
171
+ Re-connect to an existing pod without running the full init wizard.
148
172
 
149
173
  ### `synap update`
150
174
 
151
- Update the Synap skill in your OpenClaw installation to the latest version.
175
+ Update the synap skill in OpenClaw to the latest version.
176
+
177
+ ### `synap security-audit`
178
+
179
+ Check OpenClaw + Synap config for known security issues. `--fix` auto-repairs fixable ones.
180
+
181
+ ---
182
+
183
+ ## Why split `synap openclaw configure` from `openclaw configure`?
152
184
 
185
+ We delegate to OpenClaw's own config system for the actual write (`openclaw config set env.ANTHROPIC_API_KEY …`) but wrap it for:
186
+
187
+ 1. **Docker exec** — handles the `docker exec openclaw …` for you
188
+ 2. **Restart** — auto-restarts the container (Docker mode has no hot-reload)
189
+ 3. **Scripted mode** — `--provider` / `--key` flags for automation
190
+ 4. **Integration with `synap finish`** — part of the one-shot flow
191
+
192
+ For anything we don't wrap, use OpenClaw directly:
153
193
  ```bash
154
- synap update
194
+ docker exec -it openclaw openclaw configure # Interactive wizard
195
+ docker exec openclaw openclaw config get <key>
196
+ docker exec openclaw openclaw skills list
197
+ docker exec openclaw openclaw channels add --channel telegram --token ...
155
198
  ```
156
199
 
200
+ `synap` owns: Synap pod connection, skill install, Caddy proxy auth, CP DNS provisioning.
201
+ `openclaw` owns: models, skills, channels, daemon, gateway config.
202
+
157
203
  ---
158
204
 
159
- ## Configuration
205
+ ## Configuration files
160
206
 
161
- The CLI stores config in `~/.synap/` (user-only, `chmod 600`):
207
+ Stored in `~/.synap/` (user-only, `chmod 600`):
162
208
 
163
209
  | File | Contents |
164
- |------|----------|
210
+ |---|---|
165
211
  | `credentials.json` | CP auth token |
166
212
  | `pod-config.json` | Pod URL, workspace ID, agent user ID, Hub API key |
167
213
 
168
- Never commit these files.
214
+ Never commit these.
169
215
 
170
216
  ### Environment variables
171
217
 
172
218
  | Variable | Default | Description |
173
- |----------|---------|-------------|
174
- | `SYNAP_CP_URL` | `https://api.synap.live` | Control plane API URL |
175
- | `SYNAP_LANDING_URL` | `https://synap.live` | Landing page URL (for OAuth callback) |
219
+ |---|---|---|
220
+ | `SYNAP_CP_URL` | `https://api.synap.live` | Control plane URL |
221
+ | `SYNAP_LANDING_URL` | `https://synap.live` | Landing page (OAuth callback) |
176
222
 
177
223
  ---
178
224
 
179
- ## How the skill works
225
+ ## What the `synap` skill gives your agent
180
226
 
181
- The `synap` OpenClaw skill gives your AI agents access to Synap's Hub Protocol:
227
+ The skill is published on [ClawHub](https://clawhub.ai) as `synap`. Once installed, your agent gains access to Synap's Hub Protocol:
182
228
 
183
- | What | How the agent uses it |
184
- |------|----------------------|
185
- | Store a memory | Save a fact keyword or semantic search |
186
- | Search memories | Find relevant facts across everything stored |
229
+ | Capability | How the agent uses it |
230
+ |---|---|
231
+ | Store a memory | Save atomic facts, keyword or semantic search |
187
232
  | Create an entity | Structured object (person, task, note, project, …) |
188
- | Search entities | Find by name, type, or content |
189
- | Send a message | Post to any channel |
190
- | Create a proposal | Propose a change for human review |
233
+ | Search entities | By name, type, content, relationships |
234
+ | Relation graph | Link entities, traverse |
235
+ | Documents | Long-form markdown with governance |
236
+ | Channels | Post messages to any Synap channel |
237
+ | Proposals | Request changes for human review |
191
238
 
192
- Agents self-discover available entity types and views at runtime — no hardcoding.
239
+ Agents self-discover entity types and views at runtime — no hardcoding.
193
240
 
194
241
  ---
195
242
 
@@ -199,51 +246,47 @@ Agents self-discover available entity types and views at runtime — no hardcodi
199
246
 
200
247
  ```bash
201
248
  git clone https://github.com/synap-core/synap-backend
202
- cd synap-backend
249
+ cd synap-backend/deploy
203
250
  docker compose --profile openclaw up -d
204
- # then:
205
- synap init # → "Connect to existing pod" → http://localhost:4000
251
+ synap init # → "Connect to existing pod" → http://localhost:4000
206
252
  ```
207
253
 
208
254
  ### Managed pod ($15–20/mo)
209
255
 
210
256
  1. Create a pod at [synap.live](https://synap.live)
211
- 2. Run `synap init` → "Connect to my Synap cloud pod"
212
- 3. Select your pod — CLI handles provisioning
257
+ 2. `synap init` → "Connect to Synap cloud pod"
258
+ 3. Select your pod — CLI handles everything
259
+ 4. `synap finish` — offers public domain automatically
213
260
 
214
261
  ---
215
262
 
216
263
  ## Troubleshooting
217
264
 
218
265
  **"Could not reach pod"**
219
- Check that your pod URL is reachable. For self-hosted, make sure Docker Compose is up and port 4000 is accessible.
266
+ Pod unreachable. Check `synap status` and docker compose.
220
267
 
221
- **"No workspace found on this pod"**
222
- The CLI auto-creates an Agent OS workspace on first connect. Re-run `synap init` — it's idempotent.
268
+ **"OpenClaw is not running yet"**
269
+ First boot takes 1–2 minutes. Wait, then `synap finish`.
223
270
 
224
- **"OpenClaw provisioning error"** (managed pod, `serverIp null`)
225
- Your managed pod doesn't have a registered server IP (trial pods). Install OpenClaw locally instead:
226
- ```bash
227
- npm i -g openclaw
228
- synap init # → Path A
229
- ```
271
+ **"AI provider not configured"**
272
+ Run `synap openclaw configure` or use `synap openclaw configure --interactive` to hand off to OpenClaw's own wizard.
230
273
 
231
- **Login on a remote server (no browser)**
232
- ```bash
233
- synap login --token <your-token>
234
- # Generate token at: https://synap.live/account/tokens
235
- ```
274
+ **MCP client doesn't show tools**
275
+ Run `synap openclaw token --for claude` to get a ready-to-paste config with the token pre-filled. Restart your AI client.
276
+
277
+ **Dashboard: "device approval required"**
278
+ Shouldn't happen — `synap openclaw setup-domain` forges `X-Real-IP: 127.0.0.1` so OpenClaw treats Caddy traffic as loopback. If it does, run `synap openclaw doctor --fix`.
236
279
 
237
280
  **"Session expired" in synap status**
238
- Run `synap login` again. In normal use the session auto-refreshes and you should only need to login once.
281
+ Run `synap login --token <token>` on the server.
239
282
 
240
283
  ---
241
284
 
242
285
  ## Why Synap
243
286
 
244
- - **Structured memory**: OpenClaw's `MEMORY.md` is flat files. Synap gives you PostgreSQL + pgvector + Typesense — entities, relationships, full-text + semantic search.
245
- - **Governance**: AI agent mutations go through proposals — reviewable, reversible, auditable.
246
- - **Sovereign**: Self-host for free. Your data stays on your infrastructure.
287
+ - **Structured memory**: not flat files. PostgreSQL + pgvector + Typesense. Entities, relationships, full-text + semantic search.
288
+ - **Governance**: AI mutations go through reviewable proposals.
289
+ - **Sovereign**: self-host for free, your data stays yours.
247
290
 
248
291
  ---
249
292
 
@@ -1,18 +1,25 @@
1
1
  /**
2
2
  * synap finish
3
3
  *
4
- * Complete setup after OpenClaw has been provisioned.
5
- * Run this once OpenClaw is running (a few minutes after synap init).
4
+ * Complete setup after OpenClaw has been provisioned. One-shot: after this
5
+ * command, everything the user needs is ready AI key, skill, IS, and public
6
+ * dashboard URL.
6
7
  *
7
8
  * Steps:
8
- * 1. Verify pod connection (reads ~/.synap/pod-config.json)
9
+ * 1. Verify pod connection (~/.synap/pod-config.json)
9
10
  * 2. Check pod health
10
11
  * 3. Check OpenClaw is running
11
- * 4. Security audit
12
- * 5. Install synap skill
12
+ * 4. Security audit (local-install only)
13
+ * 5. Install synap skill (via openclaw skills install)
13
14
  * 6. Seed workspace entities
14
- * 7. Optionally configure IS as AI provider
15
+ * 7. Configure AI provider prompt if missing (via openclaw config set)
16
+ * 8. Expose dashboard — offer if managed pod + OPENCLAW_DOMAIN unset
17
+ * 9. Configure Synap IS as AI provider (optional)
15
18
  */
16
- export declare function finish(opts?: {
19
+ interface FinishOpts {
17
20
  skipIs?: boolean;
18
- }): Promise<void>;
21
+ skipAiKey?: boolean;
22
+ skipDomain?: boolean;
23
+ }
24
+ export declare function finish(opts?: FinishOpts): Promise<void>;
25
+ export {};