agent-message 0.1.3 → 0.1.4

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
@@ -31,7 +31,10 @@ Default ports:
31
31
  - API: `127.0.0.1:45180`
32
32
  - Web: `127.0.0.1:45788`
33
33
 
34
+ For self-hosted local use, `agent-message start` creates and uses a local SQLite database by default.
35
+ Managed cloud deployments should run the server with `DB_DRIVER=postgres` and `POSTGRES_DSN`.
34
36
  After `agent-message start`, open `http://127.0.0.1:45788` in your browser.
37
+ The bundled CLI uses `https://am.namjaeyoun.com` by default unless you override `server_url` for self-hosting.
35
38
  The bundled CLI continues to work from the same command:
36
39
 
37
40
  ```bash
@@ -42,6 +45,12 @@ agent-message open bob
42
45
  agent-message send bob "hello"
43
46
  ```
44
47
 
48
+ Port conventions:
49
+ - `8080`: source server default (`cd server && go run .`) and server container port
50
+ - `45180`: local API port used by `agent-message start`
51
+ - `45788`: local web gateway port used by `agent-message start`, `--with-tunnel`, and the containerized gateway
52
+ - `5173`: Vite dev server only
53
+
45
54
  You can override the runtime location and ports when needed:
46
55
 
47
56
  ```bash
@@ -50,6 +59,12 @@ agent-message status --runtime-dir /tmp/agent-message --api-port 28080 --web-por
50
59
  agent-message stop --runtime-dir /tmp/agent-message
51
60
  ```
52
61
 
62
+ Web Push for installed PWA notifications:
63
+ - `agent-message start` automatically creates and reuses a local VAPID keypair.
64
+ - The generated config is stored in `<runtime-dir>/web-push.json`.
65
+ - To override it, set `WEB_PUSH_VAPID_PUBLIC_KEY`, `WEB_PUSH_VAPID_PRIVATE_KEY`, and optionally `WEB_PUSH_SUBJECT` before `agent-message start`.
66
+ - 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.
67
+
53
68
  PWA install:
54
69
  - Open the deployed web app in Safari on iPhone.
55
70
  - Use `Share -> Add to Home Screen`.
@@ -59,6 +74,14 @@ PWA install:
59
74
 
60
75
  This section covers local development and local production-like testing from a checked-out repository.
61
76
 
77
+ To expose the checked-out repository on your `PATH` as `agent-message`, run:
78
+
79
+ ```bash
80
+ npm link
81
+ ```
82
+
83
+ That symlinks this checkout's `npm/bin/agent-message.mjs`, so `agent-message ...` uses your local source tree.
84
+
62
85
  ## Prerequisites
63
86
 
64
87
  - Go `1.26+`
@@ -80,15 +103,20 @@ Default server settings:
80
103
  - `SQLITE_DSN=./agent_message.sqlite`
81
104
  - `UPLOAD_DIR=./uploads`
82
105
  - `CORS_ALLOWED_ORIGINS=*`
106
+ - `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
107
 
84
108
  Example override:
85
109
 
86
110
  ```bash
87
111
  cd server
88
- DB_DRIVER=sqlite SQLITE_DSN=./dev.sqlite UPLOAD_DIR=./uploads go run .
112
+ DB_DRIVER=sqlite SQLITE_DSN=./dev.sqlite UPLOAD_DIR=./uploads \
113
+ WEB_PUSH_VAPID_PUBLIC_KEY=... \
114
+ WEB_PUSH_VAPID_PRIVATE_KEY=... \
115
+ WEB_PUSH_SUBJECT=mailto:you@example.com \
116
+ go run .
89
117
  ```
90
118
 
91
- ### Option B: Local production-like stack (Server + PostgreSQL)
119
+ ### Local production-like stack (Server + PostgreSQL)
92
120
 
93
121
  ```bash
94
122
  docker compose up --build
@@ -112,6 +140,47 @@ To also remove persisted DB/uploads volumes:
112
140
  docker compose down -v
113
141
  ```
114
142
 
143
+ ## Home Server Container Deploy
144
+
145
+ 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.
146
+
147
+ 1. Copy the example env file and fill in your values:
148
+
149
+ ```bash
150
+ cp .env.home.example .env.home
151
+ ```
152
+
153
+ Required values:
154
+ - `APP_HOSTNAME`
155
+ - `POSTGRES_PASSWORD`
156
+ - `CLOUDFLARE_TUNNEL_TOKEN`
157
+
158
+ Web push keys are optional in `.env.home`.
159
+ - 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.
160
+ - If `WEB_PUSH_SUBJECT` is blank, it defaults to `https://<APP_HOSTNAME>`.
161
+ - On startup, the server container normalizes ownership for the `uploads` and `web_push_data` volumes before dropping privileges to the unprivileged `app` user.
162
+
163
+ 2. Start the stack:
164
+
165
+ ```bash
166
+ docker compose --env-file .env.home -f docker-compose.home.yml up -d --build
167
+ ```
168
+
169
+ 3. Check status:
170
+
171
+ ```bash
172
+ docker compose --env-file .env.home -f docker-compose.home.yml ps
173
+ docker compose --env-file .env.home -f docker-compose.home.yml logs -f
174
+ ```
175
+
176
+ The home-server stack includes:
177
+ - `postgres`
178
+ - `server`
179
+ - `gateway`
180
+ - `cloudflared`
181
+
182
+ No host port needs to be exposed on the Mac. Public traffic should come through Cloudflare Tunnel.
183
+
115
184
  ## Web Quickstart
116
185
 
117
186
  ```bash
@@ -137,33 +206,36 @@ cd web
137
206
  npm run build
138
207
  ```
139
208
 
140
- ## Local Bundle Commands
209
+ ## Local Lifecycle Commands
141
210
 
142
- From the project root, you can start the SQLite-backed API server and the production-like local web gateway together:
211
+ 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
212
 
144
213
  ```bash
145
- ./dev-up
214
+ agent-message start --dev
146
215
  ```
147
216
 
148
217
  This will:
149
218
  - build `web/dist`
150
219
  - 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`
220
+ - start the API on `127.0.0.1:45180`
221
+ - start the local web gateway on `127.0.0.1:45788`
153
222
 
154
223
  To stop both processes:
155
224
 
156
225
  ```bash
157
- ./dev-stop
226
+ agent-message stop --dev
158
227
  ```
159
228
 
160
229
  If you also want to start or stop the named tunnel that serves `https://agent.namjaeyoun.com`, use:
161
230
 
162
231
  ```bash
163
- ./dev-up --with-tunnel
164
- ./dev-stop --with-tunnel
232
+ agent-message start --dev --with-tunnel
233
+ agent-message stop --dev
165
234
  ```
166
235
 
236
+ `--with-tunnel` assumes the default web listener `127.0.0.1:45788`, because the checked-in Cloudflare config points there.
237
+ 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.
238
+
167
239
  When publishing from the repo, `npm pack` / `npm publish` will run the package `prepack` hook, which:
168
240
  - builds `web/dist`
169
241
  - bundles `deploy/agent_gateway.mjs`
@@ -185,12 +257,12 @@ npx skills add https://github.com/siisee11/agent-message --skill agent-message-c
185
257
 
186
258
  ## CLI Quickstart
187
259
 
188
- Run from `cli/` with optional `--server-url` override.
260
+ 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
261
 
190
262
  ```bash
191
263
  cd cli
192
- go run . --server-url http://localhost:8080 register alice 1234
193
- go run . --server-url http://localhost:8080 login alice 1234
264
+ go run . register alice 1234
265
+ go run . login alice 1234
194
266
  go run . profile list
195
267
  go run . profile switch alice
196
268
  ```
@@ -199,25 +271,28 @@ Common commands:
199
271
 
200
272
  ```bash
201
273
  # Conversations
202
- go run . --server-url http://localhost:8080 ls
203
- go run . --server-url http://localhost:8080 open bob
274
+ go run . ls
275
+ go run . open bob
204
276
 
205
277
  # 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
278
+ go run . send bob "hello"
279
+ go run . send bob --attach ./screenshot.png
280
+ go run . send bob "see attached" --attach ./screenshot.png
281
+ go run . read bob --n 20
282
+ go run . edit 1 "edited text"
283
+ go run . delete 1
210
284
 
211
285
  # Reactions
212
- go run . --server-url http://localhost:8080 react 1 👍
213
- go run . --server-url http://localhost:8080 unreact 1 👍
286
+ go run . react 1 👍
287
+ go run . unreact 1 👍
214
288
 
215
289
  # Realtime watch
216
- go run . --server-url http://localhost:8080 watch bob
290
+ go run . watch bob
217
291
  ```
218
292
 
219
293
  CLI config is stored at `~/.agent-message/config` by default.
220
294
  Each successful `login` or `register` also saves a named profile, and `go run . profile switch <username>` swaps the active account locally.
295
+ 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.
221
296
 
222
297
  ## Validation and Constraints (Phase 7)
223
298