agent-message 0.1.3 → 0.2.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.
package/README.md CHANGED
@@ -15,6 +15,8 @@ Agent Message is a direct-message stack with three clients:
15
15
  - Web app (`web/`)
16
16
  - CLI (`cli/`)
17
17
 
18
+ The public deployment is available at `https://am.namjaeyoun.com`.
19
+
18
20
  ## Install With npm (macOS)
19
21
 
20
22
  Install the packaged app from npm on macOS (`arm64` and `x64`).
@@ -31,17 +33,29 @@ Default ports:
31
33
  - API: `127.0.0.1:45180`
32
34
  - Web: `127.0.0.1:45788`
33
35
 
36
+ For self-hosted local use, `agent-message start` creates and uses a local SQLite database by default.
37
+ Managed cloud deployments should run the server with `DB_DRIVER=postgres` and `POSTGRES_DSN`.
34
38
  After `agent-message start`, open `http://127.0.0.1:45788` in your browser.
39
+ The bundled CLI uses `https://am.namjaeyoun.com` by default unless you override `server_url` for self-hosting, which matches the public deployment web app.
40
+ Starting the local stack does not silently rewrite CLI traffic; regular commands still follow `server_url` in config unless you pass `--server-url`.
35
41
  The bundled CLI continues to work from the same command:
36
42
 
37
43
  ```bash
38
- agent-message register alice 1234
39
- agent-message login alice 1234
44
+ agent-message register alice secret123
45
+ agent-message login alice secret123
46
+ agent-message config set master jay
40
47
  agent-message ls
41
48
  agent-message open bob
42
49
  agent-message send bob "hello"
50
+ agent-message send "status update for master"
43
51
  ```
44
52
 
53
+ Port conventions:
54
+ - `8080`: source server default (`cd server && go run .`) and server container port
55
+ - `45180`: local API port used by `agent-message start`
56
+ - `45788`: local web gateway port used by `agent-message start`, `--with-tunnel`, and the containerized gateway
57
+ - `5173`: Vite dev server only
58
+
45
59
  You can override the runtime location and ports when needed:
46
60
 
47
61
  ```bash
@@ -50,6 +64,12 @@ agent-message status --runtime-dir /tmp/agent-message --api-port 28080 --web-por
50
64
  agent-message stop --runtime-dir /tmp/agent-message
51
65
  ```
52
66
 
67
+ Web Push for installed PWA notifications:
68
+ - `agent-message start` automatically creates and reuses a local VAPID keypair.
69
+ - The generated config is stored in `<runtime-dir>/web-push.json`.
70
+ - To override it, set `WEB_PUSH_VAPID_PUBLIC_KEY`, `WEB_PUSH_VAPID_PRIVATE_KEY`, and optionally `WEB_PUSH_SUBJECT` before `agent-message start`.
71
+ - iPhone web push needs the app to be installed from a public HTTPS origin. For local development, use `agent-message start --with-tunnel`; otherwise use a deployed HTTPS host.
72
+
53
73
  PWA install:
54
74
  - Open the deployed web app in Safari on iPhone.
55
75
  - Use `Share -> Add to Home Screen`.
@@ -59,6 +79,14 @@ PWA install:
59
79
 
60
80
  This section covers local development and local production-like testing from a checked-out repository.
61
81
 
82
+ To expose the checked-out repository on your `PATH` as `agent-message`, run:
83
+
84
+ ```bash
85
+ npm link
86
+ ```
87
+
88
+ That symlinks this checkout's `npm/bin/agent-message.mjs`, so `agent-message ...` uses your local source tree.
89
+
62
90
  ## Prerequisites
63
91
 
64
92
  - Go `1.26+`
@@ -80,15 +108,20 @@ Default server settings:
80
108
  - `SQLITE_DSN=./agent_message.sqlite`
81
109
  - `UPLOAD_DIR=./uploads`
82
110
  - `CORS_ALLOWED_ORIGINS=*`
111
+ - `WEB_PUSH_VAPID_PUBLIC_KEY`, `WEB_PUSH_VAPID_PRIVATE_KEY`, `WEB_PUSH_SUBJECT` are optional, but required if you want push notifications when running `go run .` directly
83
112
 
84
113
  Example override:
85
114
 
86
115
  ```bash
87
116
  cd server
88
- DB_DRIVER=sqlite SQLITE_DSN=./dev.sqlite UPLOAD_DIR=./uploads go run .
117
+ DB_DRIVER=sqlite SQLITE_DSN=./dev.sqlite UPLOAD_DIR=./uploads \
118
+ WEB_PUSH_VAPID_PUBLIC_KEY=... \
119
+ WEB_PUSH_VAPID_PRIVATE_KEY=... \
120
+ WEB_PUSH_SUBJECT=mailto:you@example.com \
121
+ go run .
89
122
  ```
90
123
 
91
- ### Option B: Local production-like stack (Server + PostgreSQL)
124
+ ### Local production-like stack (Server + PostgreSQL)
92
125
 
93
126
  ```bash
94
127
  docker compose up --build
@@ -112,6 +145,47 @@ To also remove persisted DB/uploads volumes:
112
145
  docker compose down -v
113
146
  ```
114
147
 
148
+ ## Home Server Container Deploy
149
+
150
+ For a home Mac server, you can run the managed-cloud stack entirely with containers. The `gateway` image builds `web/dist` during `docker compose build`, so you do not need to run `npm run build` on the host first.
151
+
152
+ 1. Copy the example env file and fill in your values:
153
+
154
+ ```bash
155
+ cp .env.home.example .env.home
156
+ ```
157
+
158
+ Required values:
159
+ - `APP_HOSTNAME`
160
+ - `POSTGRES_PASSWORD`
161
+ - `CLOUDFLARE_TUNNEL_TOKEN`
162
+
163
+ Web push keys are optional in `.env.home`.
164
+ - If `WEB_PUSH_VAPID_PUBLIC_KEY` / `WEB_PUSH_VAPID_PRIVATE_KEY` are blank, the server container generates them on first boot and stores them in the `web_push_data` volume.
165
+ - If `WEB_PUSH_SUBJECT` is blank, it defaults to `https://<APP_HOSTNAME>`.
166
+ - On startup, the server container normalizes ownership for the `uploads` and `web_push_data` volumes before dropping privileges to the unprivileged `app` user.
167
+
168
+ 2. Start the stack:
169
+
170
+ ```bash
171
+ docker compose --env-file .env.home -f docker-compose.home.yml up -d --build
172
+ ```
173
+
174
+ 3. Check status:
175
+
176
+ ```bash
177
+ docker compose --env-file .env.home -f docker-compose.home.yml ps
178
+ docker compose --env-file .env.home -f docker-compose.home.yml logs -f
179
+ ```
180
+
181
+ The home-server stack includes:
182
+ - `postgres`
183
+ - `server`
184
+ - `gateway`
185
+ - `cloudflared`
186
+
187
+ No host port needs to be exposed on the Mac. Public traffic should come through Cloudflare Tunnel.
188
+
115
189
  ## Web Quickstart
116
190
 
117
191
  ```bash
@@ -137,33 +211,36 @@ cd web
137
211
  npm run build
138
212
  ```
139
213
 
140
- ## Local Bundle Commands
214
+ ## Local Lifecycle Commands
141
215
 
142
- From the project root, you can start the SQLite-backed API server and the production-like local web gateway together:
216
+ From a checked-out repo, use the same lifecycle command as the packaged app, but add `--dev` to build from the local source tree before launch:
143
217
 
144
218
  ```bash
145
- ./dev-up
219
+ agent-message start --dev
146
220
  ```
147
221
 
148
222
  This will:
149
223
  - build `web/dist`
150
224
  - build the Go server binary into `~/.agent-message/bin`
151
- - start the API on `127.0.0.1:18080`
152
- - start the local web gateway on `127.0.0.1:8788`
225
+ - start the API on `127.0.0.1:45180`
226
+ - start the local web gateway on `127.0.0.1:45788`
153
227
 
154
228
  To stop both processes:
155
229
 
156
230
  ```bash
157
- ./dev-stop
231
+ agent-message stop --dev
158
232
  ```
159
233
 
160
234
  If you also want to start or stop the named tunnel that serves `https://agent.namjaeyoun.com`, use:
161
235
 
162
236
  ```bash
163
- ./dev-up --with-tunnel
164
- ./dev-stop --with-tunnel
237
+ agent-message start --dev --with-tunnel
238
+ agent-message stop --dev
165
239
  ```
166
240
 
241
+ `--with-tunnel` assumes the default web listener `127.0.0.1:45788`, because the checked-in Cloudflare config points there.
242
+ Use `--with-tunnel` when testing iPhone push notifications from a local checkout; without a public HTTPS origin, Safari-installed PWAs will not receive web push reliably.
243
+
167
244
  When publishing from the repo, `npm pack` / `npm publish` will run the package `prepack` hook, which:
168
245
  - builds `web/dist`
169
246
  - bundles `deploy/agent_gateway.mjs`
@@ -183,14 +260,51 @@ Install the Agent Message CLI skill to give Claude Code full knowledge of this p
183
260
  npx skills add https://github.com/siisee11/agent-message --skill agent-message-cli
184
261
  ```
185
262
 
263
+ ## claude-message
264
+
265
+ `claude-message` is a companion wrapper for Claude Code, similar to `codex-message`, but it runs Claude through `claude -p --output-format json` and relays results over `agent-message`.
266
+
267
+ Behavior:
268
+ - Starts a fresh `agent-{chatId}` account with a generated password.
269
+ - Sends the `--to` user a startup message with the generated credentials.
270
+ - Reuses the returned Claude `session_id` and resumes later turns with `--resume`.
271
+ - Watches the DM thread for plain-text prompts, adds `👀` when a request is picked up, and posts the Claude result back as `json_render`.
272
+ - Replaces the inbound `👀` reaction with `✅` after a successful Claude turn.
273
+
274
+ Example:
275
+
276
+ ```bash
277
+ claude-message --to jay --model sonnet --permission-mode accept-edits
278
+ ```
279
+
280
+ Build from source:
281
+
282
+ ```bash
283
+ make claude-message-build
284
+ ./claude-message/target/debug/claude-message --to jay --model sonnet
285
+ ```
286
+
287
+ Useful flags:
288
+ - `--to jay`
289
+ - `--cwd /path/to/worktree`
290
+ - `--model sonnet`
291
+ - `--permission-mode accept-edits`
292
+ - `--allowed-tools Read,Edit`
293
+ - `--bare`
294
+
295
+ Notes:
296
+ - `claude-message` depends on a working local `claude` install and authentication.
297
+ - `claude-message` always runs Claude with `--dangerously-skip-permissions`.
298
+ - `--permission-mode` and `--allowed-tools` can still be used to shape tool behavior, but the wrapper no longer waits on Claude permission prompts.
299
+
186
300
  ## CLI Quickstart
187
301
 
188
- Run from `cli/` with optional `--server-url` override.
302
+ Run from `cli/`. By default the CLI talks to `https://am.namjaeyoun.com`. For self-hosting, pass `--server-url` or set `server_url` in config.
189
303
 
190
304
  ```bash
191
305
  cd cli
192
- go run . --server-url http://localhost:8080 register alice 1234
193
- go run . --server-url http://localhost:8080 login alice 1234
306
+ go run . register alice secret123
307
+ go run . login alice secret123
194
308
  go run . profile list
195
309
  go run . profile switch alice
196
310
  ```
@@ -199,30 +313,34 @@ Common commands:
199
313
 
200
314
  ```bash
201
315
  # Conversations
202
- go run . --server-url http://localhost:8080 ls
203
- go run . --server-url http://localhost:8080 open bob
316
+ go run . ls
317
+ go run . open bob
204
318
 
205
319
  # Messaging
206
- go run . --server-url http://localhost:8080 send bob "hello"
207
- go run . --server-url http://localhost:8080 read bob --n 20
208
- go run . --server-url http://localhost:8080 edit 1 "edited text"
209
- go run . --server-url http://localhost:8080 delete 1
320
+ go run . send bob "hello"
321
+ go run . send bob --attach ./screenshot.png
322
+ go run . send bob "see attached" --attach ./screenshot.png
323
+ go run . read bob --n 20
324
+ go run . edit 1 "edited text"
325
+ go run . delete 1
210
326
 
211
327
  # Reactions
212
- go run . --server-url http://localhost:8080 react 1 👍
213
- go run . --server-url http://localhost:8080 unreact 1 👍
328
+ go run . react <message-id> 👍
329
+ go run . unreact <message-id> 👍
214
330
 
215
331
  # Realtime watch
216
- go run . --server-url http://localhost:8080 watch bob
332
+ go run . watch bob
217
333
  ```
218
334
 
219
335
  CLI config is stored at `~/.agent-message/config` by default.
220
336
  Each successful `login` or `register` also saves a named profile, and `go run . profile switch <username>` swaps the active account locally.
337
+ For a self-hosted server, set `server_url` once with `go run . config set server_url http://localhost:8080` or use `--server-url` per command.
338
+ To set a default recipient for agent reports, run `go run . config set master jay`; after that, `go run . send "done"` sends to `jay`, and `go run . send --to bob "done"` overrides it for one command.
221
339
 
222
340
  ## Validation and Constraints (Phase 7)
223
341
 
224
342
  - Username identity fields: `3-32` chars, allowed `[A-Za-z0-9._-]`
225
- - PIN: `4-6` numeric digits
343
+ - Password: `4-72` characters
226
344
  - Uploads:
227
345
  - max file size: `20 MB`
228
346
  - unsupported file types are rejected