palmier 0.2.6 → 0.2.8

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 (46) hide show
  1. package/.github/workflows/publish.yml +24 -0
  2. package/CLAUDE.md +9 -9
  3. package/README.md +288 -288
  4. package/dist/agents/shared-prompt.js +16 -16
  5. package/dist/commands/info.js +0 -22
  6. package/dist/commands/init.js +27 -123
  7. package/dist/commands/lan.d.ts +8 -0
  8. package/dist/commands/lan.js +51 -0
  9. package/dist/commands/mcpserver.js +2 -7
  10. package/dist/commands/pair.d.ts +1 -1
  11. package/dist/commands/pair.js +52 -56
  12. package/dist/commands/run.js +36 -41
  13. package/dist/commands/serve.d.ts +1 -1
  14. package/dist/commands/serve.js +14 -33
  15. package/dist/config.js +3 -17
  16. package/dist/events.d.ts +3 -4
  17. package/dist/events.js +25 -8
  18. package/dist/index.js +8 -0
  19. package/dist/rpc-handler.js +5 -29
  20. package/dist/transports/http-transport.d.ts +1 -1
  21. package/dist/transports/http-transport.js +103 -18
  22. package/dist/types.d.ts +1 -3
  23. package/package.json +44 -36
  24. package/src/agents/claude.ts +44 -44
  25. package/src/agents/shared-prompt.ts +28 -28
  26. package/src/commands/info.ts +0 -24
  27. package/src/commands/init.ts +29 -150
  28. package/src/commands/lan.ts +58 -0
  29. package/src/commands/mcpserver.ts +2 -10
  30. package/src/commands/pair.ts +50 -63
  31. package/src/commands/run.ts +619 -633
  32. package/src/commands/serve.ts +14 -31
  33. package/src/config.ts +3 -18
  34. package/src/events.ts +23 -10
  35. package/src/index.ts +9 -0
  36. package/src/nats-client.ts +15 -15
  37. package/src/rpc-handler.ts +388 -414
  38. package/src/transports/http-transport.ts +123 -19
  39. package/src/types.ts +62 -66
  40. package/dist/commands/hook.d.ts +0 -7
  41. package/dist/commands/hook.js +0 -208
  42. package/dist/commands/task-cleanup.d.ts +0 -14
  43. package/dist/commands/task-cleanup.js +0 -84
  44. package/dist/commands/task-generation.md +0 -28
  45. package/dist/systemd.d.ts +0 -20
  46. package/dist/systemd.js +0 -145
@@ -0,0 +1,24 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ id-token: write
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+ - uses: actions/setup-node@v6
16
+ with:
17
+ node-version: 24
18
+ cache: npm
19
+ registry-url: https://registry.npmjs.org
20
+ - run: npm ci
21
+ - run: npm run build
22
+ - run: npm publish --provenance --access public
23
+ env:
24
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CLAUDE.md CHANGED
@@ -1,9 +1,9 @@
1
- # CLAUDE.md
2
-
3
- ## Getting Started
4
-
5
- Always read `README.md` first before starting any task. For the full platform architecture spec (NATS protocol, data model, execution flow), see `spec.md` in the [palmier-server](../palmier-server) repo.
6
-
7
- ## Documentation
8
-
9
- When making architectural changes, update `README.md` and the server repo's `spec.md` to reflect the new state.
1
+ # CLAUDE.md
2
+
3
+ ## Getting Started
4
+
5
+ Always read `README.md` first before starting any task. For the full platform architecture spec (NATS protocol, data model, execution flow), see `spec.md` in the [palmier-server](../palmier-server) repo.
6
+
7
+ ## Documentation
8
+
9
+ When making architectural changes, update `README.md` and the server repo's `spec.md` to reflect the new state.
package/README.md CHANGED
@@ -1,288 +1,288 @@
1
- # Palmier
2
-
3
- ![CI](https://github.com/caihongxu/palmier/actions/workflows/ci.yml/badge.svg)
4
-
5
- A Node.js CLI that runs on your machine as a persistent daemon. It manages tasks, communicates with the Palmier app via NATS and/or direct HTTP, and executes tasks on schedule or demand using CLI tools.
6
-
7
- > **Important:** By using Palmier, you agree to the [Terms of Service](https://www.palmier.me/terms) and [Privacy Policy](https://www.palmier.me/privacy). See the [Disclaimer](#disclaimer) section below.
8
-
9
- ## Connection Modes
10
-
11
- The host supports three connection modes:
12
-
13
- | Mode | Transport | Setup | Features |
14
- |------|-----------|-------|----------|
15
- | **`nats`** | NATS only | `palmier init` → Full access, skip LAN | All features |
16
- | **`auto`** | Both NATS + HTTP | `palmier init` → Full access + LAN | All features. PWA auto-detects best route. |
17
- | **`lan`** | HTTP only | `palmier init` → LAN only | No push notifications. No server needed. |
18
-
19
- In **auto** mode, the PWA connects directly to the host via HTTP when on the same LAN (lower latency), and falls back to NATS when the host is unreachable. Push notifications always flow through NATS/server, so no features are lost.
20
-
21
- In **lan** mode, the host runs a standalone HTTP server. Multiple PWA clients can connect using session tokens. No Palmier web server or NATS broker is needed.
22
-
23
- ## Prerequisites
24
-
25
- - **Node.js 24+**
26
- - An agent CLI tool for task execution (e.g., Claude Code, Gemini CLI, OpenAI Codex)
27
- - **Linux with systemd** or **Windows 10/11**
28
-
29
- ## Installation
30
-
31
- ```bash
32
- npm install -g palmier
33
- ```
34
-
35
- ## CLI Commands
36
-
37
- | Command | Description |
38
- |---|---|
39
- | `palmier init` | Interactive setup wizard (full access or LAN only) |
40
- | `palmier pair` | Generate an OTP code to pair a new device |
41
- | `palmier sessions list` | List active session tokens |
42
- | `palmier sessions revoke <token>` | Revoke a specific session token |
43
- | `palmier sessions revoke-all` | Revoke all session tokens |
44
- | `palmier info` | Show host connection info (address, mode) |
45
- | `palmier serve` | Run the persistent RPC handler (default command) |
46
- | `palmier restart` | Restart the palmier serve daemon |
47
- | `palmier run <task-id>` | Execute a specific task |
48
- | `palmier mcpserver` | Start an MCP server exposing Palmier tools (stdio transport) |
49
- | `palmier agents` | Re-detect installed agent CLIs and update config |
50
-
51
- ## Setup
52
-
53
- ### Quick Start
54
-
55
- 1. Install the host: `npm install -g palmier`
56
- 2. Run `palmier init` in your project directory.
57
- 3. The wizard walks you through:
58
- - **Full access** or **LAN only** mode
59
- - Server URL (for full access, used for registration only not stored in config)
60
- - Optional LAN access (for full access auto-detects best route when enabled)
61
- 4. The host saves config, installs a background daemon (systemd on Linux, Registry Run key on Windows), and generates a pairing code.
62
- 5. Enter the pairing code in the Palmier PWA to connect your device.
63
-
64
- ### Pairing additional devices
65
-
66
- Run `palmier pair` on the host to generate a new OTP code. Each paired device gets its own session token.
67
-
68
- ### Managing sessions
69
-
70
- ```bash
71
- # List all paired devices
72
- palmier sessions list
73
-
74
- # Revoke a specific device's access
75
- palmier sessions revoke <token>
76
-
77
- # Revoke all sessions (unpair all devices)
78
- palmier sessions revoke-all
79
- ```
80
-
81
- The `init` command:
82
- - Detects installed agent CLIs (Claude Code, Gemini CLI, Codex CLI) and caches the result
83
- - Saves host configuration to `~/.config/palmier/host.json`
84
- - Installs a background daemon (systemd user service on Linux, Registry Run key on Windows)
85
- - Auto-enters pair mode to connect your first device
86
-
87
- To re-detect agents after installing or removing a CLI, run `palmier agents`.
88
-
89
- ### Verifying the Service
90
-
91
- After `palmier init`, verify the host is running:
92
-
93
- **Linux:**
94
-
95
- ```bash
96
- # Check service status
97
- systemctl --user status palmier.service
98
-
99
- # View recent logs
100
- journalctl --user -u palmier.service -n 50 --no-pager
101
-
102
- # Follow logs in real time
103
- journalctl --user -u palmier.service -f
104
- ```
105
-
106
- **Windows (PowerShell):**
107
-
108
- ```powershell
109
- # Check if the daemon is running
110
- Get-Process -Name node -ErrorAction SilentlyContinue | Where-Object { $_.CommandLine -like '*palmier*serve*' }
111
- ```
112
-
113
- **Restarting the daemon (both platforms):**
114
-
115
- ```bash
116
- palmier restart
117
- ```
118
-
119
- ## How It Works
120
-
121
- - The host runs as a **background daemon** (systemd user service on Linux, Registry Run key on Windows), staying alive via `palmier serve`.
122
- - **Paired devices** communicate with the host via NATS (cloud-routed) and/or direct HTTP (LAN), depending on the connection mode. Each paired device gets a session token that authenticates all requests.
123
- - **Tasks** are stored locally as Markdown files in a `tasks/` directory. Each task has a name, prompt, execution plan, and optional triggers (cron schedules or one-time dates).
124
- - **Plan generation** is automatic — when you create or update a task, the host invokes your chosen agent CLI to generate an execution plan and name.
125
- - **Triggers** are backed by systemd timers (Linux) or Task Scheduler (Windows). You can enable/disable them without deleting the task, and any task can still be run manually at any time.
126
- - **Task execution** uses the system scheduler on both platforms — `systemctl --user start` on Linux, `schtasks /run` on Windows. The daemon polls every 30 seconds to detect crashed tasks (processes that exited without updating status) and marks them as failed, broadcasting the failure to connected clients.
127
- - **Command-triggered tasks** — optionally specify a shell command (e.g., `tail -f /var/log/app.log`). Palmier runs the command continuously and invokes the agent for each line of stdout, passing it alongside your prompt. Useful for log monitoring, event-driven automation, and reactive workflows.
128
- - **Task confirmation** — tasks can optionally require your approval before running. You'll get a push notification (NATS mode) or a prompt in the PWA to confirm or abort.
129
- - **Run history** — each run produces a timestamped result file. You can view results and reports from the PWA.
130
- - **Real-time updates** — task status changes (started, finished, failed) are pushed to connected PWA clients via NATS pub/sub or SSE. A shared events module handles broadcasting across both transports.
131
- - **MCP server** (`palmier mcpserver`) exposes platform tools (e.g., `send-push-notification`) to AI agents like Claude Code over stdio.
132
-
133
- ## Project Structure
134
-
135
- ```
136
- src/
137
- index.ts # CLI entrypoint (commander setup)
138
- config.ts # Host configuration (read/write ~/.config/palmier)
139
- rpc-handler.ts # Transport-agnostic RPC handler (with session validation)
140
- session-store.ts # Session token management (~/.config/palmier/sessions.json)
141
- nats-client.ts # NATS connection helper
142
- spawn-command.ts # Shared helper for spawning CLI tools
143
- task.ts # Task file management
144
- types.ts # Shared type definitions
145
- agents/
146
- agent.ts # AgentTool interface, registry, and agent detection
147
- claude.ts # Claude Code agent implementation
148
- gemini.ts # Gemini CLI agent implementation
149
- codex.ts # Codex CLI agent implementation
150
- openclaw.ts # OpenClaw agent implementation
151
- events.ts # Shared event broadcasting (NATS pub/sub and HTTP SSE)
152
- commands/
153
- init.ts # Interactive setup wizard (auto-pair)
154
- pair.ts # OTP code generation and pairing handler
155
- sessions.ts # Session token management CLI (list, revoke, revoke-all)
156
- info.ts # Print host connection info
157
- agents.ts # Re-detect installed agent CLIs
158
- serve.ts # Transport selection, startup, and crash detection polling
159
- restart.ts # Daemon restart (cross-platform)
160
- run.ts # Single task execution
161
- mcpserver.ts # MCP server with platform tools (send-push-notification)
162
- platform/
163
- platform.ts # PlatformService interface
164
- index.ts # Platform factory (Linux vs Windows)
165
- linux.ts # Linux: systemd daemon, timers, systemctl task control
166
- windows.ts # Windows: Registry Run key, Task Scheduler, schtasks-based task control
167
- transports/
168
- nats-transport.ts # NATS subscription loop (host.<hostId>.rpc.>)
169
- http-transport.ts # HTTP server with RPC, SSE, and internal event endpoints
170
- ```
171
-
172
- ## MCP Server
173
-
174
- The host includes an MCP server that exposes Palmier platform tools to AI agents like Claude Code.
175
-
176
- ### Setup
177
-
178
- Add to your Claude Code MCP settings:
179
-
180
- ```json
181
- {
182
- "mcpServers": {
183
- "palmier": {
184
- "command": "palmier",
185
- "args": ["mcpserver"]
186
- }
187
- }
188
- }
189
- ```
190
-
191
- Requires a provisioned host (`palmier init`). In NATS/auto mode, uses NATS relay. Not available in LAN-only mode.
192
-
193
- ### Available Tools
194
-
195
- | Tool | Inputs | Description |
196
- |---|---|---|
197
- | `send-push-notification` | `title`, `body` (required) | Send a push notification to all paired devices |
198
-
199
- ## Removing a Host
200
-
201
- To fully remove a host from a machine:
202
-
203
- 1. **Unpair the host from the PWA** (via the host menu).
204
-
205
- 2. **Stop and remove the daemon:**
206
-
207
- **Linux:**
208
- ```bash
209
- systemctl --user stop palmier.service
210
- systemctl --user disable palmier.service
211
- rm ~/.config/systemd/user/palmier.service
212
- ```
213
-
214
- **Windows (PowerShell):**
215
- ```powershell
216
- # Kill the daemon process
217
- Get-Content "$env:USERPROFILE\.config\palmier\daemon.pid" | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
218
- # Remove the Registry Run key
219
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "PalmierDaemon" -ErrorAction SilentlyContinue
220
- ```
221
-
222
- 3. **Remove any task timers:**
223
-
224
- **Linux:**
225
- ```bash
226
- systemctl --user stop palmier-task-*.timer palmier-task-*.service 2>/dev/null
227
- systemctl --user disable palmier-task-*.timer 2>/dev/null
228
- rm -f ~/.config/systemd/user/palmier-task-*.timer ~/.config/systemd/user/palmier-task-*.service
229
- systemctl --user daemon-reload
230
- ```
231
-
232
- **Windows (PowerShell):**
233
- ```powershell
234
- schtasks /delete /tn "PalmierTask-*" /f 2>$null
235
- ```
236
-
237
- 4. **Remove the host configuration:**
238
-
239
- ```bash
240
- rm -rf ~/.config/palmier
241
- ```
242
-
243
- 5. **Remove the tasks directory** from your project root:
244
-
245
- ```bash
246
- rm -rf tasks/
247
- ```
248
-
249
- ## Disclaimer
250
-
251
- **USE AT YOUR OWN RISK.** Palmier is provided on an "AS IS" and "AS AVAILABLE" basis, without warranties of any kind, either express or implied.
252
-
253
- ### AI Agent Execution
254
-
255
- Palmier spawns third-party AI agent CLIs (such as Claude Code, Gemini CLI, and Codex CLI) that can:
256
-
257
- - **Read, create, modify, and delete files** on your machine
258
- - **Execute arbitrary shell commands** with your user permissions
259
- - **Make network requests** and interact with external services
260
-
261
- AI agents may produce unexpected, incorrect, or harmful outputs. **You are solely responsible for reviewing and approving all actions taken by AI agents on your system.** The authors of Palmier have no control over the behavior of third-party AI agents and accept no liability for their actions.
262
-
263
- ### Unattended and Scheduled Execution
264
-
265
- Tasks can be configured to run on schedules (cron) or in response to events without active supervision. You should:
266
-
267
- - Use the **confirmation** feature for sensitive tasks
268
- - Restrict **permissions** granted to agents to the minimum necessary
269
- - Regularly review **task history and results**
270
- - Maintain **backups** of any important data in directories where agents operate
271
-
272
- ### Third-Party Services
273
-
274
- Task prompts and execution data may be transmitted to third-party AI service providers (Anthropic, Google, OpenAI, etc.) according to their respective terms and privacy policies. Palmier does not control how these services process your data.
275
-
276
- When using NATS or auto mode, communication between your device and the host is relayed through the Palmier server. See the [Privacy Policy](https://www.palmier.me/privacy) for details on what data is collected.
277
-
278
- ### Limitation of Liability
279
-
280
- To the maximum extent permitted by applicable law, the authors and contributors of Palmier shall not be liable for any direct, indirect, incidental, special, consequential, or exemplary damages arising from the use of this software, including but not limited to damages for loss of data, loss of profits, business interruption, or any other commercial damages or losses.
281
-
282
- ### No Professional Advice
283
-
284
- Palmier is a developer tool, not a substitute for professional advice. Do not rely on AI-generated outputs for critical decisions without independent verification.
285
-
286
- ## License
287
-
288
- This project is licensed under the Apache License 2.0. See [LICENSE](LICENSE) for the full text.
1
+ # Palmier
2
+
3
+ [![CI](https://github.com/caihongxu/palmier/actions/workflows/ci.yml/badge.svg)](https://github.com/caihongxu/palmier/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/palmier)](https://www.npmjs.com/package/palmier)
5
+ [![license](https://img.shields.io/npm/l/palmier)](https://github.com/caihongxu/palmier/blob/master/LICENSE)
6
+
7
+ A Node.js CLI that runs on your machine as a persistent daemon. It manages tasks, communicates with the Palmier app via NATS and/or direct HTTP, and executes tasks on schedule or demand using CLI tools.
8
+
9
+ > **Important:** By using Palmier, you agree to the [Terms of Service](https://www.palmier.me/terms) and [Privacy Policy](https://www.palmier.me/privacy). See the [Disclaimer](#disclaimer) section below.
10
+
11
+ ## Connection Modes
12
+
13
+ The host supports two independent connection modes, enabled during `palmier init`. Both can be active at the same time.
14
+
15
+ | Mode | Transport | PWA URL | Features |
16
+ |------|-----------|---------|----------|
17
+ | **Server** | NATS (cloud relay) | `https://app.palmier.me` | Push notifications, remote access |
18
+ | **LAN** | HTTP (direct, on-demand) | `http://<host-ip>:7400` | Low-latency, no external server needed |
19
+
20
+ **Server mode** relays communication through the Palmier server via NATS. All features including push notifications are available. The PWA is served over HTTPS.
21
+
22
+ **LAN mode** is started on-demand via `palmier lan`. It runs a local HTTP server that reverse-proxies PWA assets from `app.palmier.me` and serves API endpoints locally. The browser accesses everything at `http://<host-ip>:<port>` (same-origin). Push notifications are not available in LAN mode.
23
+
24
+ ## Prerequisites
25
+
26
+ - **Node.js 24+**
27
+ - An agent CLI tool for task execution (e.g., Claude Code, Gemini CLI, OpenAI Codex)
28
+ - **Linux with systemd** or **Windows 10/11**
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install -g palmier
34
+ ```
35
+
36
+ ## CLI Commands
37
+
38
+ | Command | Description |
39
+ |---|---|
40
+ | `palmier init` | Interactive setup wizard |
41
+ | `palmier pair` | Generate an OTP code to pair a new device (server mode) |
42
+ | `palmier lan` | Start an on-demand LAN server with built-in pairing |
43
+ | `palmier sessions list` | List active session tokens |
44
+ | `palmier sessions revoke <token>` | Revoke a specific session token |
45
+ | `palmier sessions revoke-all` | Revoke all session tokens |
46
+ | `palmier info` | Show host connection info (address, mode) |
47
+ | `palmier serve` | Run the persistent RPC handler (default command) |
48
+ | `palmier restart` | Restart the palmier serve daemon |
49
+ | `palmier run <task-id>` | Execute a specific task |
50
+ | `palmier mcpserver` | Start an MCP server exposing Palmier tools (stdio transport) |
51
+ | `palmier agents` | Re-detect installed agent CLIs and update config |
52
+
53
+ ## Setup
54
+
55
+ ### Quick Start
56
+
57
+ 1. Install the host: `npm install -g palmier`
58
+ 2. Run `palmier init` in your project directory.
59
+ 3. The wizard detects installed agents, registers with the Palmier server, installs a background daemon, and generates a pairing code.
60
+ 4. Enter the pairing code in the Palmier PWA to connect your device.
61
+
62
+ ### Pairing additional devices
63
+
64
+ **Server mode:** Run `palmier pair` on the host to generate a new OTP code. Enter it in the PWA at `https://app.palmier.me`.
65
+
66
+ **LAN mode:** Run `palmier lan` it displays both the URL and a pairing code. Open the URL on your device and enter the code.
67
+
68
+ ### Managing sessions
69
+
70
+ ```bash
71
+ # List all paired devices
72
+ palmier sessions list
73
+
74
+ # Revoke a specific device's access
75
+ palmier sessions revoke <token>
76
+
77
+ # Revoke all sessions (unpair all devices)
78
+ palmier sessions revoke-all
79
+ ```
80
+
81
+ The `init` command:
82
+ - Detects installed agent CLIs (Claude Code, Gemini CLI, Codex CLI) and caches the result
83
+ - Saves host configuration to `~/.config/palmier/host.json`
84
+ - Installs a background daemon (systemd user service on Linux, Registry Run key on Windows)
85
+ - Auto-enters pair mode to connect your first device
86
+
87
+ To re-detect agents after installing or removing a CLI, run `palmier agents`.
88
+
89
+ ### Verifying the Service
90
+
91
+ After `palmier init`, verify the host is running:
92
+
93
+ **Linux:**
94
+
95
+ ```bash
96
+ # Check service status
97
+ systemctl --user status palmier.service
98
+
99
+ # View recent logs
100
+ journalctl --user -u palmier.service -n 50 --no-pager
101
+
102
+ # Follow logs in real time
103
+ journalctl --user -u palmier.service -f
104
+ ```
105
+
106
+ **Windows (PowerShell):**
107
+
108
+ ```powershell
109
+ # Check if the daemon is running
110
+ Get-Process -Name node -ErrorAction SilentlyContinue | Where-Object { $_.CommandLine -like '*palmier*serve*' }
111
+ ```
112
+
113
+ **Restarting the daemon (both platforms):**
114
+
115
+ ```bash
116
+ palmier restart
117
+ ```
118
+
119
+ ## How It Works
120
+
121
+ - The host runs as a **background daemon** (systemd user service on Linux, Registry Run key on Windows), staying alive via `palmier serve`.
122
+ - **Paired devices** communicate with the host via NATS (server mode) and/or direct HTTP (LAN mode). Each paired device gets a session token that authenticates all requests.
123
+ - **Tasks** are stored locally as Markdown files in a `tasks/` directory. Each task has a name, prompt, execution plan, and optional schedules (cron schedules or one-time dates).
124
+ - **Plan generation** is automatic — when you create or update a task, the host invokes your chosen agent CLI to generate an execution plan and name.
125
+ - **Schedules** are backed by systemd timers (Linux) or Task Scheduler (Windows). You can enable/disable them without deleting the task, and any task can still be run manually at any time.
126
+ - **Task execution** uses the system scheduler on both platforms — `systemctl --user start` on Linux, `schtasks /run` on Windows. The daemon polls every 30 seconds to detect crashed tasks (processes that exited without updating status) and marks them as failed, broadcasting the failure to connected clients.
127
+ - **Command-triggered tasks** — optionally specify a shell command (e.g., `tail -f /var/log/app.log`). Palmier runs the command continuously and invokes the agent for each line of stdout, passing it alongside your prompt. Useful for log monitoring, event-driven automation, and reactive workflows.
128
+ - **Task confirmation** — tasks can optionally require your approval before running. You'll get a push notification (server mode) or a prompt in the PWA to confirm or abort.
129
+ - **Run history** — each run produces a timestamped result file. You can view results and reports from the PWA.
130
+ - **Real-time updates** — task status changes (started, finished, failed) are pushed to connected PWA clients via NATS pub/sub (server mode) and/or SSE (LAN mode).
131
+ - **MCP server** (`palmier mcpserver`) exposes platform tools (e.g., `send-push-notification`) to AI agents like Claude Code over stdio.
132
+
133
+ ## Project Structure
134
+
135
+ ```
136
+ src/
137
+ index.ts # CLI entrypoint (commander setup)
138
+ config.ts # Host configuration (read/write ~/.config/palmier)
139
+ rpc-handler.ts # Transport-agnostic RPC handler (with session validation)
140
+ session-store.ts # Session token management (~/.config/palmier/sessions.json)
141
+ nats-client.ts # NATS connection helper
142
+ spawn-command.ts # Shared helper for spawning CLI tools
143
+ task.ts # Task file management
144
+ types.ts # Shared type definitions
145
+ agents/
146
+ agent.ts # AgentTool interface, registry, and agent detection
147
+ claude.ts # Claude Code agent implementation
148
+ gemini.ts # Gemini CLI agent implementation
149
+ codex.ts # Codex CLI agent implementation
150
+ openclaw.ts # OpenClaw agent implementation
151
+ events.ts # Event broadcasting (NATS pub/sub or HTTP SSE)
152
+ commands/
153
+ init.ts # Interactive setup wizard (auto-pair)
154
+ pair.ts # OTP code generation and pairing handler
155
+ sessions.ts # Session token management CLI (list, revoke, revoke-all)
156
+ info.ts # Print host connection info
157
+ agents.ts # Re-detect installed agent CLIs
158
+ serve.ts # Transport selection, startup, and crash detection polling
159
+ restart.ts # Daemon restart (cross-platform)
160
+ run.ts # Single task execution
161
+ mcpserver.ts # MCP server with platform tools (send-push-notification)
162
+ platform/
163
+ platform.ts # PlatformService interface
164
+ index.ts # Platform factory (Linux vs Windows)
165
+ linux.ts # Linux: systemd daemon, timers, systemctl task control
166
+ windows.ts # Windows: Registry Run key, Task Scheduler, schtasks-based task control
167
+ transports/
168
+ nats-transport.ts # NATS subscription loop (host.<hostId>.rpc.>)
169
+ http-transport.ts # HTTP server with RPC, SSE, PWA reverse proxy, and internal event endpoints
170
+ ```
171
+
172
+ ## MCP Server
173
+
174
+ The host includes an MCP server that exposes Palmier platform tools to AI agents like Claude Code.
175
+
176
+ ### Setup
177
+
178
+ Add to your Claude Code MCP settings:
179
+
180
+ ```json
181
+ {
182
+ "mcpServers": {
183
+ "palmier": {
184
+ "command": "palmier",
185
+ "args": ["mcpserver"]
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ Requires a provisioned host (`palmier init`) with server mode enabled.
192
+
193
+ ### Available Tools
194
+
195
+ | Tool | Inputs | Description |
196
+ |---|---|---|
197
+ | `send-push-notification` | `title`, `body` (required) | Send a push notification to all paired devices |
198
+
199
+ ## Removing a Host
200
+
201
+ To fully remove a host from a machine:
202
+
203
+ 1. **Unpair the host from the PWA** (via the host menu).
204
+
205
+ 2. **Stop and remove the daemon:**
206
+
207
+ **Linux:**
208
+ ```bash
209
+ systemctl --user stop palmier.service
210
+ systemctl --user disable palmier.service
211
+ rm ~/.config/systemd/user/palmier.service
212
+ ```
213
+
214
+ **Windows (PowerShell):**
215
+ ```powershell
216
+ # Kill the daemon process
217
+ Get-Content "$env:USERPROFILE\.config\palmier\daemon.pid" | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
218
+ # Remove the Registry Run key
219
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "PalmierDaemon" -ErrorAction SilentlyContinue
220
+ ```
221
+
222
+ 3. **Remove any task timers:**
223
+
224
+ **Linux:**
225
+ ```bash
226
+ systemctl --user stop palmier-task-*.timer palmier-task-*.service 2>/dev/null
227
+ systemctl --user disable palmier-task-*.timer 2>/dev/null
228
+ rm -f ~/.config/systemd/user/palmier-task-*.timer ~/.config/systemd/user/palmier-task-*.service
229
+ systemctl --user daemon-reload
230
+ ```
231
+
232
+ **Windows (PowerShell):**
233
+ ```powershell
234
+ schtasks /delete /tn "PalmierTask-*" /f 2>$null
235
+ ```
236
+
237
+ 4. **Remove the host configuration:**
238
+
239
+ ```bash
240
+ rm -rf ~/.config/palmier
241
+ ```
242
+
243
+ 5. **Remove the tasks directory** from your project root:
244
+
245
+ ```bash
246
+ rm -rf tasks/
247
+ ```
248
+
249
+ ## Disclaimer
250
+
251
+ **USE AT YOUR OWN RISK.** Palmier is provided on an "AS IS" and "AS AVAILABLE" basis, without warranties of any kind, either express or implied.
252
+
253
+ ### AI Agent Execution
254
+
255
+ Palmier spawns third-party AI agent CLIs (such as Claude Code, Gemini CLI, and Codex CLI) that can:
256
+
257
+ - **Read, create, modify, and delete files** on your machine
258
+ - **Execute arbitrary shell commands** with your user permissions
259
+ - **Make network requests** and interact with external services
260
+
261
+ AI agents may produce unexpected, incorrect, or harmful outputs. **You are solely responsible for reviewing and approving all actions taken by AI agents on your system.** The authors of Palmier have no control over the behavior of third-party AI agents and accept no liability for their actions.
262
+
263
+ ### Unattended and Scheduled Execution
264
+
265
+ Tasks can be configured to run on schedules (cron) or in response to events without active supervision. You should:
266
+
267
+ - Use the **confirmation** feature for sensitive tasks
268
+ - Restrict **permissions** granted to agents to the minimum necessary
269
+ - Regularly review **task history and results**
270
+ - Maintain **backups** of any important data in directories where agents operate
271
+
272
+ ### Third-Party Services
273
+
274
+ Task prompts and execution data may be transmitted to third-party AI service providers (Anthropic, Google, OpenAI, etc.) according to their respective terms and privacy policies. Palmier does not control how these services process your data.
275
+
276
+ When using server mode, communication between your device and the host is relayed through the Palmier server. See the [Privacy Policy](https://www.palmier.me/privacy) for details on what data is collected.
277
+
278
+ ### Limitation of Liability
279
+
280
+ To the maximum extent permitted by applicable law, the authors and contributors of Palmier shall not be liable for any direct, indirect, incidental, special, consequential, or exemplary damages arising from the use of this software, including but not limited to damages for loss of data, loss of profits, business interruption, or any other commercial damages or losses.
281
+
282
+ ### No Professional Advice
283
+
284
+ Palmier is a developer tool, not a substitute for professional advice. Do not rely on AI-generated outputs for critical decisions without independent verification.
285
+
286
+ ## License
287
+
288
+ This project is licensed under the Apache License 2.0. See [LICENSE](LICENSE) for the full text.