pi-pocket 0.27.0 → 0.28.0-beta.2

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 (93) hide show
  1. package/README.md +11 -8
  2. package/docs/architecture.md +9 -1
  3. package/docs/customizing.md +16 -2
  4. package/docs/docker.md +2 -0
  5. package/docs/examples/quiet-note.js +21 -0
  6. package/docs/examples/quiet-note.ts +73 -0
  7. package/docs/extensions/app.md +1 -0
  8. package/docs/extensions/policies/api-stability.md +3 -0
  9. package/docs/extensions/reference/limits.md +11 -0
  10. package/docs/extensions/reference/pocket.md +22 -1
  11. package/docs/extensions/reference/theme-surface.md +12 -0
  12. package/docs/extensions/reference/web.md +36 -2
  13. package/docs/extensions.md +2 -0
  14. package/docs/features.md +20 -16
  15. package/docs/map.md +24 -12
  16. package/docs/systemd.md +1 -1
  17. package/npm-shrinkwrap.json +3163 -0
  18. package/package.json +3 -2
  19. package/src/launcher/access.ts +75 -4
  20. package/src/launcher/main.ts +303 -60
  21. package/src/launcher/options.ts +8 -5
  22. package/src/launcher/serve.ts +677 -0
  23. package/src/server/app.ts +223 -14
  24. package/src/server/avatars.ts +54 -0
  25. package/src/server/background.ts +214 -42
  26. package/src/server/build.ts +53 -0
  27. package/src/server/commands.ts +28 -33
  28. package/src/server/config.ts +9 -1
  29. package/src/server/docs.ts +8 -1
  30. package/src/server/entry-presentation.ts +275 -0
  31. package/src/server/export.ts +26 -3
  32. package/src/server/extension-web.ts +113 -8
  33. package/src/server/extensions/pip.ts +57 -2
  34. package/src/server/host.ts +21 -3
  35. package/src/server/http/api.ts +106 -6
  36. package/src/server/http/assets.ts +9 -1
  37. package/src/server/http/conversation-routes.ts +61 -0
  38. package/src/server/http/events.ts +19 -0
  39. package/src/server/http/icon-route.ts +196 -0
  40. package/src/server/http.ts +41 -2
  41. package/src/server/icon-mask.ts +33 -0
  42. package/src/server/icon-render.ts +149 -0
  43. package/src/server/icon-store.ts +57 -0
  44. package/src/server/model-images.ts +124 -0
  45. package/src/server/pip.ts +30 -6
  46. package/src/server/projection.ts +127 -32
  47. package/src/server/room.ts +171 -8
  48. package/src/server/running.ts +307 -2
  49. package/src/server/schedules.ts +5 -0
  50. package/src/server/skills.ts +99 -8
  51. package/src/server/spend.ts +5 -0
  52. package/src/server/transcripts.ts +28 -3
  53. package/src/server/when.ts +25 -11
  54. package/types/pocket.d.ts +53 -2
  55. package/web/app-icon.js +149 -0
  56. package/web/app.js +12 -8
  57. package/web/avatar.js +46 -2
  58. package/web/composer.js +107 -15
  59. package/web/entry-presentation.js +264 -0
  60. package/web/extension-ui.js +18 -0
  61. package/web/fingerprint.d.ts +2 -0
  62. package/web/fingerprint.js +21 -0
  63. package/web/launcher.js +15 -3
  64. package/web/model-favorites.js +27 -0
  65. package/web/peeks.js +11 -3
  66. package/web/pip.js +7 -1
  67. package/web/running-board.js +1197 -0
  68. package/web/session-cache.js +144 -0
  69. package/web/session-tabs.js +58 -0
  70. package/web/sessions.js +51 -12
  71. package/web/sheets/all-artifacts.js +104 -0
  72. package/web/sheets/appearance.js +45 -0
  73. package/web/sheets/background.js +228 -0
  74. package/web/sheets/find.js +61 -7
  75. package/web/sheets/folder.js +43 -4
  76. package/web/sheets/menu.js +3 -1
  77. package/web/sheets/message.js +80 -15
  78. package/web/sheets/model.js +39 -3
  79. package/web/sheets/people.js +35 -1
  80. package/web/sheets/providers.js +80 -26
  81. package/web/sheets/schedules.js +4 -1
  82. package/web/sheets/shortcuts.js +1 -0
  83. package/web/sheets/text.js +2 -0
  84. package/web/sheets.js +11 -4
  85. package/web/store.js +837 -27
  86. package/web/style.css +1928 -166
  87. package/web/subagents-board.js +3 -2
  88. package/web/tab-order.js +34 -0
  89. package/web/theme-surface.js +7 -0
  90. package/web/theme.js +15 -0
  91. package/web/transcript.js +588 -57
  92. package/web/user-search.js +6 -0
  93. package/web/sheets/running.js +0 -130
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-pocket",
3
- "version": "0.27.0",
3
+ "version": "0.28.0-beta.2",
4
4
  "description": "A durable, multiplayer, mobile-first web app for Pi agents, built on Pi Durable",
5
5
  "keywords": [
6
6
  "pi",
@@ -64,12 +64,13 @@
64
64
  "htm": "^3.1.1",
65
65
  "jiti": "2.7.0",
66
66
  "marked": "^18.1.1",
67
+ "minimatch": "10.2.6",
67
68
  "preact": "^11.0.2",
68
69
  "qrcode": "^1.5.4",
69
70
  "undici": "8.12.3"
70
71
  },
71
72
  "overrides": {
72
- "undici": "8.12.3"
73
+ "undici": "$undici"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@stylistic/eslint-plugin": "5.10.0",
@@ -1,4 +1,5 @@
1
- // How other devices reach Pi Pocket: this device only, the local network, a Cloudflare quick tunnel, or Tailscale.
1
+ // How other devices reach Pi Pocket: this device only, the local network, a Cloudflare quick tunnel,
2
+ // Tailscale, or Tailscale Serve.
2
3
  import { type ChildProcess, spawn, spawnSync } from "node:child_process";
3
4
  import { once } from "node:events";
4
5
  import {
@@ -15,14 +16,21 @@ import { networkInterfaces } from "node:os";
15
16
  import { delimiter, join } from "node:path";
16
17
  import { createInterface } from "node:readline";
17
18
 
18
- export type AccessMode = "local" | "lan" | "cloudflare" | "tailscale";
19
- export const ACCESS_MODES: readonly AccessMode[] = ["local", "lan", "cloudflare", "tailscale"];
19
+ export type AccessMode = "local" | "lan" | "cloudflare" | "tailscale" | "tailscale-serve";
20
+ export const ACCESS_MODES: readonly AccessMode[] = [
21
+ "local",
22
+ "lan",
23
+ "cloudflare",
24
+ "tailscale",
25
+ "tailscale-serve",
26
+ ];
20
27
 
21
28
  export const ACCESS_LABELS: Record<AccessMode, string> = {
22
29
  local: "This device only",
23
30
  lan: "Local network",
24
31
  cloudflare: "Cloudflare Tunnel",
25
32
  tailscale: "Tailscale",
33
+ "tailscale-serve": "Tailscale Serve",
26
34
  };
27
35
 
28
36
  export function isAccessMode(value: string | undefined): value is AccessMode {
@@ -61,7 +69,8 @@ export function tailscaleAddress(): string | undefined {
61
69
 
62
70
  /**
63
71
  * The address the server listens on. A tunnel reaches it on this machine, so only the local network mode opens it to
64
- * other machines directly, and Tailscale opens it to the tailnet only.
72
+ * other machines directly, and Tailscale opens it to the tailnet only. Tailscale Serve is a tunnel as well: tailscaled
73
+ * proxies the tailnet to loopback, so nothing binds the tailnet address for it as Tailscale mode does.
65
74
  */
66
75
  export function bindHost(mode: AccessMode): string {
67
76
  if (mode === "lan") {
@@ -75,6 +84,11 @@ export function bindHost(mode: AccessMode): string {
75
84
  return "127.0.0.1";
76
85
  }
77
86
 
87
+ /** Where the server listens: `--host` when it is given, with any mode, as in 0.27; else the mode's own address. */
88
+ export function listenHost(mode: AccessMode | "custom", host: string | undefined): string {
89
+ return host ?? (mode === "custom" ? "127.0.0.1" : bindHost(mode));
90
+ }
91
+
78
92
  // ─── Choosing a mode ────────────────────────────────────────────────────
79
93
 
80
94
  export interface AccessChoice {
@@ -156,6 +170,63 @@ export function findCloudflared(dataDir: string): string | undefined {
156
170
  return findExecutable("cloudflared", [join(dataDir, "bin")]);
157
171
  }
158
172
 
173
+ // ─── Tailscale Serve ────────────────────────────────────────────────────
174
+
175
+ /**
176
+ * tailscale from PATH. Pi Pocket neither ships nor downloads Tailscale, so it has to be installed already, and only
177
+ * PATH is searched: the data folder never holds a copy.
178
+ */
179
+ export function findTailscale(): string | undefined {
180
+ return findExecutable("tailscale", []);
181
+ }
182
+
183
+ export const TAILSCALE_MISSING_MESSAGE =
184
+ 'Tailscale Serve needs the tailscale command, and it is not on PATH.\nInstall it: macOS "brew install tailscale" (the App Store app keeps its command in the bundle, not on PATH) · Linux "curl -fsSL https://tailscale.com/install.sh | sh" · Windows "winget install Tailscale.Tailscale".\nOr pick another access mode: --access local|lan|cloudflare|tailscale.';
185
+
186
+ /**
187
+ * Whether the start has to stop because `tailscale-serve` needs the missing tailscale and nobody is there to choose
188
+ * another mode: `--access tailscale-serve` or PI_POCKET_ACCESS asked for it, or it is the saved choice and no terminal
189
+ * can ask. It never falls back to `local` on its own, because the user would believe they are on their tailnet while
190
+ * they are not, and it leaves the saved choice alone so the next start works once Tailscale is installed.
191
+ */
192
+ export function serveWithoutTailscale(request: {
193
+ given: AccessMode | undefined;
194
+ saved: AccessMode | undefined;
195
+ ask: boolean;
196
+ }): boolean {
197
+ if (request.given === "tailscale-serve") {
198
+ return true;
199
+ }
200
+
201
+ return request.given === undefined && request.saved === "tailscale-serve" && !request.ask;
202
+ }
203
+
204
+ /**
205
+ * Whether the start stops for the missing `tailscale-serve` tailscale, `--host` aside: `--host` means the launcher
206
+ * listens where it is told and never uses serve, so a saved serve choice must not refuse to start there. An explicit
207
+ * `--access tailscale-serve` together with `--host` never arrives here; `main` refuses that pair before choosing.
208
+ */
209
+ export function serveBailOut(request: {
210
+ access: AccessMode | undefined;
211
+ saved: AccessMode | undefined;
212
+ host: string | undefined;
213
+ ask: boolean;
214
+ }): boolean {
215
+ return (
216
+ request.host === undefined &&
217
+ serveWithoutTailscale({ given: request.access, saved: request.saved, ask: request.ask })
218
+ );
219
+ }
220
+
221
+ /**
222
+ * The loopback ports that a mount left by an earlier run of this launcher could point at: the port its receipt names.
223
+ * None without a receipt, and none for `tailscale-serve` itself, whose mount prepareServe() mounted or adopted for this
224
+ * run's port.
225
+ */
226
+ export function staleServePorts(mode: AccessMode | "custom", owned: number | undefined): number[] {
227
+ return mode === "tailscale-serve" || owned === undefined ? [] : [owned];
228
+ }
229
+
159
230
  /** Where to get cloudflared on this platform: a release binary the launcher can download, or how to install it. */
160
231
  export function cloudflaredSource(): { url: string } | { install: string } {
161
232
  const arch = (