litepaseo 0.9.2 → 0.11.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.
Files changed (163) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/server/cli.mjs +88 -45
  3. package/dist/server/{worker-Cq2Lf-Zo.mjs → worker-DGJKY8oy.mjs} +3843 -3225
  4. package/dist/web/assets/ChangesPanel-BoK2DoH7.js +2 -0
  5. package/dist/web/assets/ChangesPanel-BoK2DoH7.js.br +0 -0
  6. package/dist/web/assets/ChangesPanel-BoK2DoH7.js.gz +0 -0
  7. package/dist/web/assets/CodeBlockNode-Cc9RfSyt.js +3 -0
  8. package/dist/web/assets/CodeBlockNode-Cc9RfSyt.js.br +0 -0
  9. package/dist/web/assets/CodeBlockNode-Cc9RfSyt.js.gz +0 -0
  10. package/dist/web/assets/ConversationSearch-C6rI4eKl.css +1 -0
  11. package/dist/web/assets/ConversationSearch-C6rI4eKl.css.br +0 -0
  12. package/dist/web/assets/ConversationSearch-C6rI4eKl.css.gz +0 -0
  13. package/dist/web/assets/ConversationSearch-UTLVRA29.js +1 -0
  14. package/dist/web/assets/ConversationSearch-UTLVRA29.js.br +0 -0
  15. package/dist/web/assets/ConversationSearch-UTLVRA29.js.gz +0 -0
  16. package/dist/web/assets/FileViewer-CH2EOqbv.js +2 -0
  17. package/dist/web/assets/FileViewer-CH2EOqbv.js.br +0 -0
  18. package/dist/web/assets/FileViewer-CH2EOqbv.js.gz +0 -0
  19. package/dist/web/assets/FileViewer-DK0Fgglf.css +1 -0
  20. package/dist/web/assets/FileViewer-DK0Fgglf.css.br +0 -0
  21. package/dist/web/assets/FileViewer-DK0Fgglf.css.gz +0 -0
  22. package/dist/web/assets/FilesPanel-DPju0s0J.js +1 -0
  23. package/dist/web/assets/FilesPanel-DPju0s0J.js.br +0 -0
  24. package/dist/web/assets/FilesPanel-DPju0s0J.js.gz +0 -0
  25. package/dist/web/assets/FilesPanel-DmPAJwih.css +1 -0
  26. package/dist/web/assets/FilesPanel-DmPAJwih.css.br +0 -0
  27. package/dist/web/assets/FilesPanel-DmPAJwih.css.gz +0 -0
  28. package/dist/web/assets/HostSettings--0Jl-MlL.css +1 -0
  29. package/dist/web/assets/HostSettings--0Jl-MlL.css.br +0 -0
  30. package/dist/web/assets/HostSettings--0Jl-MlL.css.gz +0 -0
  31. package/dist/web/assets/HostSettings-DaKieQVu.js +5 -0
  32. package/dist/web/assets/HostSettings-DaKieQVu.js.br +0 -0
  33. package/dist/web/assets/HostSettings-DaKieQVu.js.gz +0 -0
  34. package/dist/web/assets/KanbanPage-CMqgoPRS.js +1 -0
  35. package/dist/web/assets/KanbanPage-CMqgoPRS.js.br +0 -0
  36. package/dist/web/assets/KanbanPage-CMqgoPRS.js.gz +0 -0
  37. package/dist/web/assets/{MarkdownMessage-DbSS5ULZ.js → MarkdownMessage-Bu5kpyO8.js} +13 -13
  38. package/dist/web/assets/MarkdownMessage-Bu5kpyO8.js.br +0 -0
  39. package/dist/web/assets/MarkdownMessage-Bu5kpyO8.js.gz +0 -0
  40. package/dist/web/assets/{PreCodeBlock-B-6jTSFa.js → PreCodeBlock-BouSjY25.js} +1 -1
  41. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js → PreCodeBlock.vue_vue_type_style_index_0_lang-CMM-1vYO.js} +1 -1
  42. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CMM-1vYO.js.br +0 -0
  43. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CMM-1vYO.js.gz +0 -0
  44. package/dist/web/assets/SubagentsPanel--Nf3-Pka.js +1 -0
  45. package/dist/web/assets/SubagentsPanel--Nf3-Pka.js.br +0 -0
  46. package/dist/web/assets/SubagentsPanel--Nf3-Pka.js.gz +0 -0
  47. package/dist/web/assets/{SubagentsPanel-iAwY_tlt.css → SubagentsPanel-BwR5tVCn.css} +1 -1
  48. package/dist/web/assets/SubagentsPanel-BwR5tVCn.css.br +0 -0
  49. package/dist/web/assets/SubagentsPanel-BwR5tVCn.css.gz +0 -0
  50. package/dist/web/assets/TerminalPanel-C4mTYDXp.js +3 -0
  51. package/dist/web/assets/TerminalPanel-C4mTYDXp.js.br +0 -0
  52. package/dist/web/assets/TerminalPanel-C4mTYDXp.js.gz +0 -0
  53. package/dist/web/assets/{TerminalPanel-BzfVCEVB.css → TerminalPanel-CgwrWov9.css} +1 -1
  54. package/dist/web/assets/TerminalPanel-CgwrWov9.css.br +0 -0
  55. package/dist/web/assets/TerminalPanel-CgwrWov9.css.gz +0 -0
  56. package/dist/web/assets/Tooltip-MUbA-aNp.js +1 -0
  57. package/dist/web/assets/Tooltip-MUbA-aNp.js.br +0 -0
  58. package/dist/web/assets/Tooltip-MUbA-aNp.js.gz +0 -0
  59. package/dist/web/assets/index-CFtzqoeO.js +36 -0
  60. package/dist/web/assets/index-CFtzqoeO.js.br +0 -0
  61. package/dist/web/assets/index-CFtzqoeO.js.gz +0 -0
  62. package/dist/web/assets/index-DP1jZ3Bw.css +1 -0
  63. package/dist/web/assets/index-DP1jZ3Bw.css.br +0 -0
  64. package/dist/web/assets/index-DP1jZ3Bw.css.gz +0 -0
  65. package/dist/web/assets/index10-BM6euQrz.js +6 -0
  66. package/dist/web/assets/index10-BM6euQrz.js.br +0 -0
  67. package/dist/web/assets/index10-BM6euQrz.js.gz +0 -0
  68. package/dist/web/assets/index3-VcT3f2Ah.js +1 -0
  69. package/dist/web/assets/index4-BeD3bELj.js +1 -0
  70. package/dist/web/assets/{index5-Bp-1tRh4.js → index5-a5MPca78.js} +1 -1
  71. package/dist/web/assets/index5-a5MPca78.js.br +0 -0
  72. package/dist/web/assets/index5-a5MPca78.js.gz +0 -0
  73. package/dist/web/assets/{index6-B8l4-gzx.js → index6-DVfUz1XH.js} +1 -1
  74. package/dist/web/assets/index6-DVfUz1XH.js.br +0 -0
  75. package/dist/web/assets/index6-DVfUz1XH.js.gz +0 -0
  76. package/dist/web/assets/index7-BHUwD_xE.js +2 -0
  77. package/dist/web/assets/index7-BHUwD_xE.js.br +0 -0
  78. package/dist/web/assets/index7-BHUwD_xE.js.gz +0 -0
  79. package/dist/web/assets/index8-Dml5qiIG.js +2 -0
  80. package/dist/web/assets/index8-Dml5qiIG.js.br +0 -0
  81. package/dist/web/assets/index8-Dml5qiIG.js.gz +0 -0
  82. package/dist/web/assets/{index9-B_ZyF9x1.js → index9-Bo-NUtnY.js} +1 -1
  83. package/dist/web/assets/index9-Bo-NUtnY.js.br +0 -0
  84. package/dist/web/assets/index9-Bo-NUtnY.js.gz +0 -0
  85. package/dist/web/assets/{vue.runtime.esm-bundler-4XjPOHMM.js → vue.runtime.esm-bundler-DmQNwI70.js} +1 -1
  86. package/dist/web/assets/vue.runtime.esm-bundler-DmQNwI70.js.br +0 -0
  87. package/dist/web/assets/{vue.runtime.esm-bundler-4XjPOHMM.js.gz → vue.runtime.esm-bundler-DmQNwI70.js.gz} +0 -0
  88. package/dist/web/index.html +8 -6
  89. package/dist/web/index.html.br +0 -0
  90. package/dist/web/index.html.gz +0 -0
  91. package/dist/web/sw.js +9 -2
  92. package/dist/web/sw.js.br +0 -0
  93. package/dist/web/sw.js.gz +0 -0
  94. package/package.json +1 -1
  95. package/dist/web/assets/ChangesPanel-BXtRMTqp.js +0 -2
  96. package/dist/web/assets/ChangesPanel-BXtRMTqp.js.br +0 -0
  97. package/dist/web/assets/ChangesPanel-BXtRMTqp.js.gz +0 -0
  98. package/dist/web/assets/CodeBlockNode-B9X7WZtj.js +0 -3
  99. package/dist/web/assets/CodeBlockNode-B9X7WZtj.js.br +0 -0
  100. package/dist/web/assets/CodeBlockNode-B9X7WZtj.js.gz +0 -0
  101. package/dist/web/assets/ConversationSearch-BD_oQkce.css +0 -1
  102. package/dist/web/assets/ConversationSearch-DgRoYzWP.js +0 -1
  103. package/dist/web/assets/ConversationSearch-DgRoYzWP.js.br +0 -0
  104. package/dist/web/assets/ConversationSearch-DgRoYzWP.js.gz +0 -0
  105. package/dist/web/assets/FileViewer-B-N8t-A2.js +0 -2
  106. package/dist/web/assets/FileViewer-B-N8t-A2.js.br +0 -0
  107. package/dist/web/assets/FileViewer-B-N8t-A2.js.gz +0 -0
  108. package/dist/web/assets/FileViewer-D0xXViyr.css +0 -1
  109. package/dist/web/assets/FileViewer-D0xXViyr.css.br +0 -0
  110. package/dist/web/assets/FileViewer-D0xXViyr.css.gz +0 -0
  111. package/dist/web/assets/FilesPanel-B0AM9mBQ.css +0 -1
  112. package/dist/web/assets/FilesPanel-B0AM9mBQ.css.br +0 -0
  113. package/dist/web/assets/FilesPanel-B0AM9mBQ.css.gz +0 -0
  114. package/dist/web/assets/FilesPanel-By85fwCy.js +0 -1
  115. package/dist/web/assets/FilesPanel-By85fwCy.js.br +0 -0
  116. package/dist/web/assets/FilesPanel-By85fwCy.js.gz +0 -0
  117. package/dist/web/assets/HostSettings-Bzv1FBbL.js +0 -5
  118. package/dist/web/assets/HostSettings-Bzv1FBbL.js.br +0 -0
  119. package/dist/web/assets/HostSettings-Bzv1FBbL.js.gz +0 -0
  120. package/dist/web/assets/HostSettings-DmJrFVbt.css +0 -1
  121. package/dist/web/assets/HostSettings-DmJrFVbt.css.br +0 -0
  122. package/dist/web/assets/HostSettings-DmJrFVbt.css.gz +0 -0
  123. package/dist/web/assets/MarkdownMessage-DbSS5ULZ.js.br +0 -0
  124. package/dist/web/assets/MarkdownMessage-DbSS5ULZ.js.gz +0 -0
  125. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js.br +0 -0
  126. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-CunCuyah.js.gz +0 -0
  127. package/dist/web/assets/SubagentsPanel-CdZce3Xr.js +0 -1
  128. package/dist/web/assets/SubagentsPanel-CdZce3Xr.js.br +0 -0
  129. package/dist/web/assets/SubagentsPanel-CdZce3Xr.js.gz +0 -0
  130. package/dist/web/assets/SubagentsPanel-iAwY_tlt.css.br +0 -0
  131. package/dist/web/assets/SubagentsPanel-iAwY_tlt.css.gz +0 -0
  132. package/dist/web/assets/TerminalPanel-BzfVCEVB.css.br +0 -0
  133. package/dist/web/assets/TerminalPanel-BzfVCEVB.css.gz +0 -0
  134. package/dist/web/assets/TerminalPanel-iBK2wpI0.js +0 -3
  135. package/dist/web/assets/TerminalPanel-iBK2wpI0.js.br +0 -0
  136. package/dist/web/assets/TerminalPanel-iBK2wpI0.js.gz +0 -0
  137. package/dist/web/assets/Tooltip-DLPAOJ1c.js +0 -1
  138. package/dist/web/assets/Tooltip-DLPAOJ1c.js.br +0 -0
  139. package/dist/web/assets/Tooltip-DLPAOJ1c.js.gz +0 -0
  140. package/dist/web/assets/index-CwWokVo4.css +0 -1
  141. package/dist/web/assets/index-CwWokVo4.css.br +0 -0
  142. package/dist/web/assets/index-CwWokVo4.css.gz +0 -0
  143. package/dist/web/assets/index-DV5BdS_U.js +0 -35
  144. package/dist/web/assets/index-DV5BdS_U.js.br +0 -0
  145. package/dist/web/assets/index-DV5BdS_U.js.gz +0 -0
  146. package/dist/web/assets/index10-DgcnbLc5.js +0 -6
  147. package/dist/web/assets/index10-DgcnbLc5.js.br +0 -0
  148. package/dist/web/assets/index10-DgcnbLc5.js.gz +0 -0
  149. package/dist/web/assets/index3-BdNVIlGK.js +0 -1
  150. package/dist/web/assets/index4-DnuPr-1i.js +0 -1
  151. package/dist/web/assets/index5-Bp-1tRh4.js.br +0 -0
  152. package/dist/web/assets/index5-Bp-1tRh4.js.gz +0 -0
  153. package/dist/web/assets/index6-B8l4-gzx.js.br +0 -0
  154. package/dist/web/assets/index6-B8l4-gzx.js.gz +0 -0
  155. package/dist/web/assets/index7-CIxLf3CP.js +0 -2
  156. package/dist/web/assets/index7-CIxLf3CP.js.br +0 -0
  157. package/dist/web/assets/index7-CIxLf3CP.js.gz +0 -0
  158. package/dist/web/assets/index8-CnHhIOzI.js +0 -2
  159. package/dist/web/assets/index8-CnHhIOzI.js.br +0 -0
  160. package/dist/web/assets/index8-CnHhIOzI.js.gz +0 -0
  161. package/dist/web/assets/index9-B_ZyF9x1.js.br +0 -0
  162. package/dist/web/assets/index9-B_ZyF9x1.js.gz +0 -0
  163. package/dist/web/assets/vue.runtime.esm-bundler-4XjPOHMM.js.br +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ - Show projects with zero active workspaces in the sidebar, matching Paseo: daemon `emptyProjects` snapshots, archive transitions, and `project.update` events stream live to the browser, with full support for pinning, host/search filtering, project menus/settings, and starting a new session.
6
+ - Replace the New Session modal with an inline draft conversation view that uses the standard chat composer: pick the agent (harness), model, thinking level, mode, agent profile, worktree, and use voice dictation directly. Leaving or closing without sending creates nothing on the host.
7
+
8
+ ## 0.10.0
9
+
10
+ - Security hardening:
11
+ - Tie stored voice-input API keys to their transcription service's origin so changing the base URL requires entering a key again, and reject credentials, query strings, or fragments in the base URL.
12
+ - Block local, private, and link-local addresses (including across DNS lookups, redirects, and page `<link>` tags) when importing project icons by URL.
13
+ - Prune expired sign-in rate-limit entries so a flood of clients cannot permanently lock new logins into the shared overflow bucket, and trust forwarding headers only from loopback proxies.
14
+ - Guard WebSocket upgrade URL parsing against malformed targets, restrict service-worker notification clicks to same-origin URLs, and protect emitted links/images in the fallback Markdown renderer from formatting corruption.
15
+ - Stability, concurrency & resource cleanup:
16
+ - Fix materialized message images on macOS (where `/tmp` and `tmpdir()` resolve through `/private`), and add a UUIDv4 fallback so plain-HTTP LAN connections work without `crypto.randomUUID`.
17
+ - Fix KeepAlive conversation switching so a late load from a backgrounded conversation never marks the newly opened conversation as read, and fix the tab/app waiting badge tracking the wrong store.
18
+ - Fix race conditions across the terminal (input batches stay with the terminal they were typed into), file browser, file viewer, agent controls, attachment retries, and schedule editor (editing a schedule no longer resets a non-default model).
19
+ - Add byte-based backpressure and cleanup to SSE streams, graceful shutdown and preview-window cancellation to push notifications, a timeout and lower memory footprint to the server send queue, and full cleanup of message images, pins, and queued messages when removing a host.
20
+ - Fix subagent event retry loops, HostMirror paged-snapshot overwrites, TimelineView catch-up edge cases, and frontend menu/KeepAlive listener leaks.
21
+ - UI, accessibility & mobile polish:
22
+ - Replace native browser `confirm()` prompts with a theme-aware confirmation dialog and shared keyboard/focus-trap handling across dialogs and menus.
23
+ - Eliminate theme flash on load with a CSP-hashed inline script, sync the PWA `theme-color` with the active sidebar color, and raise faint/warning text contrast to meet WCAG AA.
24
+ - Fix styling in conversation search, composer notices, and header panel active states; improve mobile touch targets, landscape safe areas, and narrow header layout.
25
+ - Codebase modularization:
26
+ - Split the server (`app.ts`), web shell (`App.vue`, `HostSettings.vue`), and stylesheet (`style.css`) into focused modules, lazy-loading the Kanban board and shrinking both the main JS and CSS bundles.
27
+
3
28
  ## 0.9.2
4
29
 
5
30
  - Open conversations with a plain request instead of the live stream. On an iPhone web app behind a Cloudflare Tunnel, the stream's first 16 KB arrived at once but the rest of a conversation was held back until the stream's next heartbeat, about 20 seconds later. A plain response has an end, so nothing waits for more data. The live stream then resumes from those rows and carries only what changes. Servers or proxies that do not offer the new request (`GET …/timeline/latest`) still get the rows from the stream, as before.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { appendFileSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
2
+ import { appendFileSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, fstatSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
3
3
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
4
4
  import { execFileSync, fork, spawn } from "node:child_process";
5
5
  import { dirname, join, resolve } from "node:path";
@@ -8,7 +8,7 @@ import { DatabaseSync } from "node:sqlite";
8
8
  import { homedir } from "node:os";
9
9
  import { fileURLToPath } from "node:url";
10
10
  // src/server/version.ts
11
- const VERSION = "0.9.2";
11
+ const VERSION = "0.11.0";
12
12
  // src/server/rotating-log.ts
13
13
  /** One writer (the supervisor); bounded active file plus numbered archives. */
14
14
  var RotatingLog = class {
@@ -214,11 +214,13 @@ function manageService(action, options, run = (file, args) => execFileSync(file,
214
214
  "--now",
215
215
  definition.name
216
216
  ]);
217
- else run("launchctl", [
218
- "bootout",
219
- `gui/${options.uid}`,
220
- definition.path
221
- ]);
217
+ else try {
218
+ run("launchctl", [
219
+ "bootout",
220
+ `gui/${options.uid}`,
221
+ definition.path
222
+ ]);
223
+ } catch {}
222
224
  unlinkSync(definition.path);
223
225
  if (options.platform === "linux") run("systemctl", ["--user", "daemon-reload"]);
224
226
  return "Autostart removed; application data is preserved.";
@@ -483,6 +485,26 @@ var Store = class {
483
485
  if (value === null) this.db.prepare("DELETE FROM settings WHERE key=?").run(key);
484
486
  else this.db.prepare("INSERT INTO settings VALUES(?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value").run(key, value);
485
487
  }
488
+ /** Settings whose key starts with `prefix`, as [key, value] pairs. */
489
+ settingsWithPrefix(prefix) {
490
+ return this.db.prepare("SELECT key,value FROM settings WHERE substr(key,1,length(?))=?").all(prefix, prefix).map((row) => [String(row.key), String(row.value)]);
491
+ }
492
+ /**
493
+ * Runs `fn` in one write transaction (BEGIN IMMEDIATE), rolled back if it throws. Inside an
494
+ * open transaction it simply joins it: the outermost caller commits or rolls back.
495
+ */
496
+ transaction(fn) {
497
+ if (this.db.isTransaction) return fn();
498
+ this.db.exec("BEGIN IMMEDIATE");
499
+ try {
500
+ const result = fn();
501
+ this.db.exec("COMMIT");
502
+ return result;
503
+ } catch (error) {
504
+ this.db.exec("ROLLBACK");
505
+ throw error;
506
+ }
507
+ }
486
508
  /** Compare-and-set, for single-use values such as the last accepted TOTP step. */
487
509
  advanceSetting(key, value) {
488
510
  if (value <= Number(this.setting(key) ?? -1)) return false;
@@ -835,6 +857,8 @@ function tokenFile(path) {
835
857
  }
836
858
  };
837
859
  }
860
+ /** Distinct clients whose failures are tracked separately (bounds memory under a flood). */
861
+ const MAX_TRACKED_CLIENTS = 1e4;
838
862
  /**
839
863
  * Login and sessions. A browser signs in once, with the access token and, when enabled, an authenticator code,
840
864
  * and receives an opaque session secret (stored only as a hash). Sessions are listed and
@@ -856,17 +880,10 @@ var Auth = class {
856
880
  this.token = typeof token === "string" ? () => token : token;
857
881
  const saved = store.setting("totp_login_limit");
858
882
  if (saved) this.global = JSON.parse(saved);
859
- if (store.setting("auth_policy") !== "token-plus-totp-v1") {
860
- store.db.exec("BEGIN IMMEDIATE");
861
- try {
862
- if (this.totpEnabled()) store.revokeSessions();
863
- store.setSetting("auth_policy", "token-plus-totp-v1");
864
- store.db.exec("COMMIT");
865
- } catch (error) {
866
- store.db.exec("ROLLBACK");
867
- throw error;
868
- }
869
- }
883
+ if (store.setting("auth_policy") !== "token-plus-totp-v1") store.transaction(() => {
884
+ if (this.totpEnabled()) store.revokeSessions();
885
+ store.setSetting("auth_policy", "token-plus-totp-v1");
886
+ });
870
887
  }
871
888
  totpEnabled() {
872
889
  return this.store.setting("totp_secret") !== null;
@@ -994,18 +1011,13 @@ var Auth = class {
994
1011
  if (!pending || pending.sessionId !== sessionId || pending.expires < now) return false;
995
1012
  const step = matchTotp(base32Decode(pending.secret), code, now);
996
1013
  if (step === null) return false;
997
- this.store.db.exec("BEGIN IMMEDIATE");
998
- try {
1014
+ this.store.transaction(() => {
999
1015
  this.store.setSetting("totp_secret", pending.secret);
1000
1016
  this.store.setSetting("totp_last_step", String(step));
1001
1017
  this.store.db.prepare("DELETE FROM push_subscriptions WHERE session_id<>?").run(sessionId);
1002
1018
  this.store.db.prepare("DELETE FROM sessions WHERE id<>?").run(sessionId);
1003
1019
  this.resetCodeLimit();
1004
- this.store.db.exec("COMMIT");
1005
- } catch (error) {
1006
- this.store.db.exec("ROLLBACK");
1007
- throw error;
1008
- }
1020
+ });
1009
1021
  this.pendingTotp = null;
1010
1022
  return true;
1011
1023
  }
@@ -1029,11 +1041,20 @@ var Auth = class {
1029
1041
  };
1030
1042
  this.store.setSetting("totp_login_limit", JSON.stringify(this.global));
1031
1043
  }
1044
+ /**
1045
+ * The key a client's failures are counted under. Past MAX_TRACKED_CLIENTS distinct clients the
1046
+ * rest share one "overflow" entry, but only after expired entries are dropped: otherwise a
1047
+ * burst of clients long gone would push every new client into the shared lockout for good.
1048
+ */
1049
+ slot(map, client, now) {
1050
+ if (map.has(client) || map.size < MAX_TRACKED_CLIENTS) return client;
1051
+ for (const [key, entry] of map) if (entry.reset <= now) map.delete(key);
1052
+ return map.size < MAX_TRACKED_CLIENTS ? client : "overflow";
1053
+ }
1032
1054
  limited(client, usesCode, now) {
1033
1055
  if (usesCode && this.global.reset > now && this.global.count >= MAX_CODE_FAILURES_GLOBAL) return Math.ceil((this.global.reset - now) / 1e3);
1034
1056
  const map = usesCode ? this.codeFailures : this.tokenFailures;
1035
- if (!map.has(client) && map.size >= 1e4) client = "overflow";
1036
- const entry = map.get(client);
1057
+ const entry = map.get(this.slot(map, client, now));
1037
1058
  const max = usesCode ? MAX_CODE_FAILURES_PER_CLIENT : MAX_TOKEN_FAILURES_PER_CLIENT;
1038
1059
  if (entry && entry.reset > now && entry.count >= max) return Math.ceil((entry.reset - now) / 1e3);
1039
1060
  return 0;
@@ -1049,7 +1070,7 @@ var Auth = class {
1049
1070
  this.store.setSetting("totp_login_limit", JSON.stringify(this.global));
1050
1071
  }
1051
1072
  const map = usesCode ? this.codeFailures : this.tokenFailures;
1052
- if (!map.has(client) && map.size >= 1e4) client = "overflow";
1073
+ client = this.slot(map, client, now);
1053
1074
  let entry = map.get(client);
1054
1075
  if (!entry || entry.reset <= now) map.set(client, entry = {
1055
1076
  count: 0,
@@ -1106,18 +1127,25 @@ function setConfig(store, key, value) {
1106
1127
  }
1107
1128
  store.setSetting(settingName(key), value);
1108
1129
  }
1109
- /** The value in effect for each key: environment, then saved configuration, then the default. */
1130
+ /**
1131
+ * The value in effect for each key: environment, then saved configuration, then the default.
1132
+ * Throws when an environment override is invalid.
1133
+ */
1110
1134
  function effectiveConfig(store, env) {
1111
1135
  const entries = configKeys.map((key) => {
1112
1136
  const { env: name, fallback } = CONFIG_KEYS[key];
1113
1137
  const saved = store.setting(settingName(key));
1114
1138
  const fromEnv = env[name];
1115
- if (fromEnv !== void 0 && fromEnv !== "") return {
1116
- key,
1117
- value: fromEnv,
1118
- source: "environment",
1119
- saved
1120
- };
1139
+ if (fromEnv !== void 0 && fromEnv !== "") {
1140
+ const problem = CONFIG_KEYS[key].check(fromEnv);
1141
+ if (problem) throw new Error(`${name}=${JSON.stringify(fromEnv)} is not valid. ${problem}`);
1142
+ return {
1143
+ key,
1144
+ value: fromEnv,
1145
+ source: "environment",
1146
+ saved
1147
+ };
1148
+ }
1121
1149
  if (saved !== null) return {
1122
1150
  key,
1123
1151
  value: saved,
@@ -1564,25 +1592,40 @@ async function showStatus(paths, args) {
1564
1592
  else console.log(`${out.dim("○")} LitePaseo is not running\n ${out.dim("Start it with: litepaseo start")}`);
1565
1593
  if (!state) process.exitCode = NOT_RUNNING;
1566
1594
  }
1595
+ /** A log file's text, or nothing when it does not exist (yet, or any more after a rotation). */
1596
+ function readIfPresent(path) {
1597
+ try {
1598
+ return readFileSync(path, "utf8");
1599
+ } catch (error) {
1600
+ if (error.code === "ENOENT") return "";
1601
+ throw error;
1602
+ }
1603
+ }
1567
1604
  async function logs(paths, args) {
1568
1605
  const count = args.flags.lines === void 0 ? 100 : Number(args.flags.lines);
1569
1606
  if (!Number.isInteger(count) || count < 0) throw new UsageError("--lines needs a whole number.");
1570
- let text = existsSync(paths.log) ? readFileSync(paths.log, "utf8") : "";
1571
- if (text.split("\n").length <= count && existsSync(paths.log + ".1")) text = readFileSync(paths.log + ".1", "utf8") + text;
1607
+ let text = readIfPresent(paths.log);
1608
+ if (text.split("\n").length <= count) text = readIfPresent(paths.log + ".1") + text;
1572
1609
  const tail = lastLines(text, count);
1573
1610
  if (tail) process.stdout.write(tail.endsWith("\n") ? tail : tail + "\n");
1574
1611
  else if (!args.flags.follow) console.log(out.dim(`No logs yet in ${paths.log}`));
1575
1612
  if (!args.flags.follow) return;
1576
- let position = existsSync(paths.log) ? statSync(paths.log).size : 0;
1577
- let inode = existsSync(paths.log) ? statSync(paths.log).ino : 0;
1613
+ const start = statSync(paths.log, { throwIfNoEntry: false });
1614
+ let position = start?.size ?? 0;
1615
+ let inode = start?.ino ?? 0;
1578
1616
  for (;;) {
1579
1617
  await sleep(500);
1580
- if (!existsSync(paths.log)) continue;
1581
- const info = statSync(paths.log);
1582
- if (info.ino !== inode || info.size < position) [position, inode] = [0, info.ino];
1583
- if (info.size === position) continue;
1584
- const fd = openSync(paths.log, "r");
1618
+ let fd;
1619
+ try {
1620
+ fd = openSync(paths.log, "r");
1621
+ } catch (error) {
1622
+ if (error.code === "ENOENT") continue;
1623
+ throw error;
1624
+ }
1585
1625
  try {
1626
+ const info = fstatSync(fd);
1627
+ if (info.ino !== inode || info.size < position) [position, inode] = [0, info.ino];
1628
+ if (info.size === position) continue;
1586
1629
  const chunk = Buffer.alloc(info.size - position);
1587
1630
  const read = readSync(fd, chunk, 0, chunk.length, position);
1588
1631
  process.stdout.write(chunk.subarray(0, read));
@@ -1721,7 +1764,7 @@ async function run() {
1721
1764
  if (name === "--help" || name === "-h") return console.log(mainHelp(VERSION, displayDirectory(), out));
1722
1765
  if (name === "worker") {
1723
1766
  const paths = await dataDirectory();
1724
- const { runWorker } = await import("./worker-Cq2Lf-Zo.mjs");
1767
+ const { runWorker } = await import("./worker-DGJKY8oy.mjs");
1725
1768
  return runWorker(paths.directory, fileURLToPath(new URL("../web/", import.meta.url)));
1726
1769
  }
1727
1770
  const command = findCommand(name);