@timqi/pier 0.0.4 → 0.0.6

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 (43) hide show
  1. package/README.md +9 -6
  2. package/dist/agent/events.js +6 -1
  3. package/dist/agent/pi.js +28 -3
  4. package/dist/channels/chunk.js +34 -0
  5. package/dist/channels/control.js +6 -12
  6. package/dist/channels/dedup.js +45 -0
  7. package/dist/channels/lark-api.js +233 -0
  8. package/dist/channels/lark-outbound.js +101 -0
  9. package/dist/channels/lark-panel.js +95 -0
  10. package/dist/channels/lark-render.js +107 -0
  11. package/dist/channels/lark.js +501 -0
  12. package/dist/channels/lines.js +19 -0
  13. package/dist/channels/panel.js +4 -0
  14. package/dist/channels/receipts.js +15 -0
  15. package/dist/channels/routes.js +0 -1
  16. package/dist/channels/runtime.js +5 -1
  17. package/dist/channels/slack-api.js +4 -2
  18. package/dist/channels/slack-panel.js +3 -6
  19. package/dist/channels/slack-render.js +3 -23
  20. package/dist/channels/slack.js +39 -72
  21. package/dist/channels/telegram-api.js +4 -2
  22. package/dist/channels/telegram-panel.js +3 -3
  23. package/dist/channels/telegram.js +55 -51
  24. package/dist/channels/types.js +9 -0
  25. package/dist/cli.js +3 -1
  26. package/dist/core/inbox.js +67 -1
  27. package/dist/core/types.js +4 -0
  28. package/dist/db.js +83 -20
  29. package/dist/main.js +5 -0
  30. package/dist/service.js +1 -1
  31. package/dist/web/auth.js +36 -9
  32. package/dist/web/public/assets/__vite-browser-external-2447137e-BvRk9kiK.js +0 -0
  33. package/dist/web/public/assets/ghostty-web-ODXT71Ln.js +13 -0
  34. package/dist/web/public/assets/index-BUNGxtMe.css +2 -0
  35. package/dist/web/public/assets/index-QPYgeBhQ.js +90 -0
  36. package/dist/web/public/index.html +10 -2
  37. package/dist/web/server.js +86 -19
  38. package/dist/web/session-state.js +59 -25
  39. package/dist/web/terminal.js +334 -0
  40. package/docs/deploy.md +33 -21
  41. package/package.json +10 -2
  42. package/dist/web/public/assets/index-B3MvJUJP.js +0 -90
  43. package/dist/web/public/assets/index-CwBoxtXP.css +0 -2
package/docs/deploy.md CHANGED
@@ -24,6 +24,8 @@ you want the unit to say something different.
24
24
  ## Prerequisites
25
25
 
26
26
  - Node 24 or newer (`node:sqlite` is used unflagged).
27
+ - Python 3, `make` and a C/C++ compiler for Microsoft's `node-pty`; its npm
28
+ package has no Linux prebuild (`apt install python3 build-essential` on Debian/Ubuntu).
27
29
  - A user-writable global npm prefix. The updater runs as you, so an initial
28
30
  install that needed `sudo npm install -g` cannot later update itself.
29
31
  - The `sqlite3` CLI is optional, for the off-machine backup and password steps
@@ -265,10 +267,10 @@ pier update # installs the latest release; hard-stops/restarts Pier
265
267
  pier update --check # only says whether one exists
266
268
  ```
267
269
 
268
- The workbench footer says the same thing without being asked: the server checks
269
- `registry.npmjs.org` every six hours in the background, and the version turns
270
- into `v0.0.1 → 0.0.2` when there is something newer. A failed check is silent
271
- by design — an offline box is not a broken one.
270
+ The workbench footer says the same thing without being asked: the server asks
271
+ `registry.npmjs.org` at boot and at most every 30 minutes after that, and the
272
+ version turns into `v0.0.1 → 0.0.2` when there is something newer. A failed
273
+ check is silent by design — an offline box is not a broken one.
272
274
 
273
275
  From a checkout instead, stop and back up before replacing the build:
274
276
 
@@ -287,10 +289,12 @@ path do: both drain (new work refused, running turns finished, the rest
287
289
  ledgered for the next boot to report) before the updater unit is started.
288
290
 
289
291
  Either way the updater snapshots the database to
290
- `~/.pier/db/pier.db.release.bak` before npm touches the package. This happens for
291
- every release, including releases with no schema change. If installation or
292
- backup fails, the updater unit still tries to start the previously installed
293
- service and reports the failure in its journal.
292
+ `~/.pier/db/backups/pier.db.release-<version>.bak` before npm touches the
293
+ package `<version>` being the Pier that is being replaced, i.e. the release to
294
+ reinstall if that copy is ever restored. This happens for every release,
295
+ including releases with no schema change. If installation or backup fails, the
296
+ updater unit still tries to start the previously installed service and reports
297
+ the failure in its journal.
294
298
 
295
299
  ### Automatic updates
296
300
 
@@ -313,22 +317,27 @@ pier service install --force # re-records the current node and npm
313
317
  A newer Pier brings its own schema up on the next start: the migrations run in
314
318
  one transaction before the port opens, and the version they leave behind is
315
319
  stamped in the database. It also snapshots the immediately preceding schema to
316
- `~/.pier/db/pier.db.v<N>.bak` (`N` = the schema it was at). **Upgrades only.**
317
- Start an older Pier on a database a newer one has migrated and it refuses to run
318
- rather than write tables it does not understand — the way back down is either
319
- the release backup or that schema snapshot:
320
+ `~/.pier/db/backups/pier.db.v<N>.bak` (`N` = the schema it was at). **Upgrades
321
+ only.** Start an older Pier on a database a newer one has migrated and it
322
+ refuses to run rather than write tables it does not understand — the way back
323
+ down is either a release backup or that schema snapshot:
320
324
 
321
325
  ```sh
322
326
  systemctl --user stop pier
323
- cd ~/.pier/db && rm -f pier.db pier.db-wal pier.db-shm && cp pier.db.release.bak pier.db
324
- # then reinstall the Pier release that created that backup
327
+ ls -t ~/.pier/db/backups/ # newest first
328
+ cd ~/.pier/db && rm -f pier.db pier.db-wal pier.db-shm
329
+ cp backups/pier.db.release-0.0.4.bak pier.db # the version in the name
330
+ # then reinstall that Pier release: npm install -g @timqi/pier@0.0.4
325
331
  ```
326
332
 
327
- The release backup is replaced atomically on each update. The three newest
328
- schema snapshots are also kept and older ones removed as later migrations
329
- supersede them. Each is a full copy of the database. They sit next to the
330
- database and therefore protect against a bad upgrade, not against a lost disk
331
- an off-machine copy is still yours to take.
333
+ Every copy lives in `~/.pier/db/backups/`, written under a temporary name and
334
+ renamed into place, so a `.bak` name only ever refers to a finished copy. The
335
+ three newest of **each kind** are kept three release backups and three schema
336
+ snapshots, counted separately so a run of releases cannot evict the copies taken
337
+ before a migration. Backing up twice at the same version replaces that version's
338
+ copy. Each is a full copy of the database, one directory below it, and therefore
339
+ protects against a bad upgrade, not against a lost disk — an off-machine copy is
340
+ still yours to take.
332
341
 
333
342
  ### Can it update itself?
334
343
 
@@ -382,7 +391,9 @@ elsewhere, pick a tunnel rather than a wider bind:
382
391
  there, preserve the external `Host` (or pass `X-Forwarded-Host`), and pass
383
392
  `X-Forwarded-For`; Pier uses the external host for write-origin checks and
384
393
  counts login failures per forwarded client. Its session cookie is marked
385
- `Secure` when the proxy reports `X-Forwarded-Proto: https`.
394
+ `Secure` when the proxy reports `X-Forwarded-Proto: https`. The proxy must
395
+ pass WebSocket upgrades for `/api/terminal` (Caddy does automatically;
396
+ nginx needs its usual HTTP/1.1 `Upgrade`/`Connection` forwarding).
386
397
 
387
398
  ## Backups
388
399
 
@@ -390,7 +401,8 @@ Three paths hold everything: `~/.pier/db/pier.db` (tasks, channels, the chat →
390
401
  session map, workbench state, settings, the password hash, and the sealed
391
402
  provider credentials and channel tokens), `~/.pier/master.key` (the key that
392
403
  seals them — without it the database's sealed values are unreadable), and
393
- `~/.pier/boards/`. `pier.db.release.bak` is the latest automatic pre-update copy.
404
+ `~/.pier/boards/`. `~/.pier/db/backups/` holds the automatic pre-update and
405
+ pre-migration copies, named for the release or schema they came from.
394
406
  For off-machine backups, use `sqlite3 ... "VACUUM INTO '…'"` rather than `cp`,
395
407
  which under WAL can miss the most recent commits. Pi's own session history lives
396
408
  under `~/.pier/pi` (Pier sets `PI_CODING_AGENT_DIR` there unless the environment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timqi/pier",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A self-hosted workspace for coding agents: web workbench and IM channels in front of Pi sessions",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": "github:timqi/pier",
@@ -35,6 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@tailwindcss/typography": "^0.5.20",
37
37
  "@tailwindcss/vite": "^4.3.3",
38
+ "@types/ws": "^8.18.1",
38
39
  "oxlint": "^1.79.0",
39
40
  "tailwindcss": "^4.3.3",
40
41
  "tsx": "^4.23.12",
@@ -45,11 +46,18 @@
45
46
  "dependencies": {
46
47
  "@earendil-works/pi-coding-agent": "^0.84.2",
47
48
  "@hono/node-server": "^2.1.1",
49
+ "@larksuiteoapi/node-sdk": "^1.73.0",
48
50
  "croner": "^10.0.1",
49
51
  "dompurify": "^3.4.14",
52
+ "ghostty-web": "^0.4.0",
50
53
  "highlight.js": "^11.12.0",
51
54
  "hono": "^4.13.3",
52
55
  "marked": "^18.0.10",
53
- "typebox": "^1.3.7"
56
+ "node-pty": "^1.1.0",
57
+ "typebox": "^1.3.7",
58
+ "ws": "^8.21.3"
59
+ },
60
+ "allowScripts": {
61
+ "node-pty@1.1.0": true
54
62
  }
55
63
  }