litepaseo 0.5.0 → 0.5.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 (96) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +7 -2
  3. package/dist/server/cli.mjs +2 -2
  4. package/dist/server/{worker-kSt1QrPO.mjs → worker-C0PSaDFz.mjs} +395 -30
  5. package/dist/web/assets/ChangesPanel-BlAOBntI.css +1 -0
  6. package/dist/web/assets/ChangesPanel-D_Gc7lql.js +2 -0
  7. package/dist/web/assets/ChangesPanel-D_Gc7lql.js.br +0 -0
  8. package/dist/web/assets/ChangesPanel-D_Gc7lql.js.gz +0 -0
  9. package/dist/web/assets/{CodeBlockNode-DLNjY8xM.js → CodeBlockNode-BYeeAHZ5.js} +1 -1
  10. package/dist/web/assets/CodeBlockNode-BYeeAHZ5.js.br +0 -0
  11. package/dist/web/assets/CodeBlockNode-BYeeAHZ5.js.gz +0 -0
  12. package/dist/web/assets/ConversationSearch-BD_oQkce.css +1 -0
  13. package/dist/web/assets/ConversationSearch-FrgBojJC.js +1 -0
  14. package/dist/web/assets/ConversationSearch-FrgBojJC.js.br +0 -0
  15. package/dist/web/assets/ConversationSearch-FrgBojJC.js.gz +0 -0
  16. package/dist/web/assets/{FileViewer-BTfDZAw8.js → FileViewer-BJoCEEXY.js} +1 -1
  17. package/dist/web/assets/FileViewer-BJoCEEXY.js.br +0 -0
  18. package/dist/web/assets/FileViewer-BJoCEEXY.js.gz +0 -0
  19. package/dist/web/assets/{FilesPanel-CRru2ojh.js → FilesPanel-ZVYE0rsS.js} +1 -1
  20. package/dist/web/assets/FilesPanel-ZVYE0rsS.js.br +0 -0
  21. package/dist/web/assets/FilesPanel-ZVYE0rsS.js.gz +0 -0
  22. package/dist/web/assets/{MarkdownMessage-DujO4cqH.js → MarkdownMessage-BcsVBZas.js} +5 -5
  23. package/dist/web/assets/MarkdownMessage-BcsVBZas.js.br +0 -0
  24. package/dist/web/assets/MarkdownMessage-BcsVBZas.js.gz +0 -0
  25. package/dist/web/assets/{PreCodeBlock-B7Xc7kys.js → PreCodeBlock-BYiOSyIK.js} +1 -1
  26. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-DiGKLWsw.js → PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js} +1 -1
  27. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js.br +0 -0
  28. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DRPpyHNP.js.gz +0 -0
  29. package/dist/web/assets/{TerminalPanel-CWtLSa7D.js → TerminalPanel-DdF49dfg.js} +1 -1
  30. package/dist/web/assets/TerminalPanel-DdF49dfg.js.br +0 -0
  31. package/dist/web/assets/TerminalPanel-DdF49dfg.js.gz +0 -0
  32. package/dist/web/assets/{Tooltip-CsHGWZNU.js → Tooltip-CBtAXEd9.js} +1 -1
  33. package/dist/web/assets/Tooltip-CBtAXEd9.js.br +0 -0
  34. package/dist/web/assets/Tooltip-CBtAXEd9.js.gz +0 -0
  35. package/dist/web/assets/{index-CqexjrEd.css → index-BgySs5Da.css} +1 -1
  36. package/dist/web/assets/index-BgySs5Da.css.br +0 -0
  37. package/dist/web/assets/{index-CqexjrEd.css.gz → index-BgySs5Da.css.gz} +0 -0
  38. package/dist/web/assets/index-Ub0Ct8zc.js +34 -0
  39. package/dist/web/assets/index-Ub0Ct8zc.js.br +0 -0
  40. package/dist/web/assets/index-Ub0Ct8zc.js.gz +0 -0
  41. package/dist/web/assets/{index10-CAP5737Y.js → index10-Bf2-WO96.js} +1 -1
  42. package/dist/web/assets/index10-Bf2-WO96.js.br +0 -0
  43. package/dist/web/assets/index10-Bf2-WO96.js.gz +0 -0
  44. package/dist/web/assets/index3-BOkZ-YzF.js +1 -0
  45. package/dist/web/assets/index4-DKRXIWnO.js +1 -0
  46. package/dist/web/assets/{index5-DuGVevnd.js → index5-RYzHOHr1.js} +1 -1
  47. package/dist/web/assets/index5-RYzHOHr1.js.br +0 -0
  48. package/dist/web/assets/index5-RYzHOHr1.js.gz +0 -0
  49. package/dist/web/assets/{index6-BZzSV846.js → index6-DbjQTELa.js} +1 -1
  50. package/dist/web/assets/index6-DbjQTELa.js.br +0 -0
  51. package/dist/web/assets/index6-DbjQTELa.js.gz +0 -0
  52. package/dist/web/assets/{index7-Bg7HuMIo.js → index7-CaEorL43.js} +1 -1
  53. package/dist/web/assets/index7-CaEorL43.js.br +0 -0
  54. package/dist/web/assets/index7-CaEorL43.js.gz +0 -0
  55. package/dist/web/assets/{index8-BOLJEH4G.js → index8-xlmmT8TD.js} +1 -1
  56. package/dist/web/assets/index8-xlmmT8TD.js.br +0 -0
  57. package/dist/web/assets/index8-xlmmT8TD.js.gz +0 -0
  58. package/dist/web/assets/{index9-DcVnlsIH.js → index9-BF08Ra0y.js} +1 -1
  59. package/dist/web/assets/index9-BF08Ra0y.js.br +0 -0
  60. package/dist/web/assets/index9-BF08Ra0y.js.gz +0 -0
  61. package/dist/web/index.html +2 -2
  62. package/dist/web/index.html.br +0 -0
  63. package/dist/web/index.html.gz +0 -0
  64. package/package.json +1 -1
  65. package/dist/web/assets/CodeBlockNode-DLNjY8xM.js.br +0 -0
  66. package/dist/web/assets/CodeBlockNode-DLNjY8xM.js.gz +0 -0
  67. package/dist/web/assets/FileViewer-BTfDZAw8.js.br +0 -0
  68. package/dist/web/assets/FileViewer-BTfDZAw8.js.gz +0 -0
  69. package/dist/web/assets/FilesPanel-CRru2ojh.js.br +0 -0
  70. package/dist/web/assets/FilesPanel-CRru2ojh.js.gz +0 -0
  71. package/dist/web/assets/MarkdownMessage-DujO4cqH.js.br +0 -0
  72. package/dist/web/assets/MarkdownMessage-DujO4cqH.js.gz +0 -0
  73. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DiGKLWsw.js.br +0 -0
  74. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DiGKLWsw.js.gz +0 -0
  75. package/dist/web/assets/TerminalPanel-CWtLSa7D.js.br +0 -0
  76. package/dist/web/assets/TerminalPanel-CWtLSa7D.js.gz +0 -0
  77. package/dist/web/assets/Tooltip-CsHGWZNU.js.br +0 -0
  78. package/dist/web/assets/Tooltip-CsHGWZNU.js.gz +0 -0
  79. package/dist/web/assets/index-CqexjrEd.css.br +0 -0
  80. package/dist/web/assets/index-DWPVaH6x.js +0 -36
  81. package/dist/web/assets/index-DWPVaH6x.js.br +0 -0
  82. package/dist/web/assets/index-DWPVaH6x.js.gz +0 -0
  83. package/dist/web/assets/index10-CAP5737Y.js.br +0 -0
  84. package/dist/web/assets/index10-CAP5737Y.js.gz +0 -0
  85. package/dist/web/assets/index3-De_j5vbG.js +0 -1
  86. package/dist/web/assets/index4-DPSQ7O6T.js +0 -1
  87. package/dist/web/assets/index5-DuGVevnd.js.br +0 -0
  88. package/dist/web/assets/index5-DuGVevnd.js.gz +0 -0
  89. package/dist/web/assets/index6-BZzSV846.js.br +0 -0
  90. package/dist/web/assets/index6-BZzSV846.js.gz +0 -0
  91. package/dist/web/assets/index7-Bg7HuMIo.js.br +0 -0
  92. package/dist/web/assets/index7-Bg7HuMIo.js.gz +0 -0
  93. package/dist/web/assets/index8-BOLJEH4G.js.br +0 -0
  94. package/dist/web/assets/index8-BOLJEH4G.js.gz +0 -0
  95. package/dist/web/assets/index9-DcVnlsIH.js.br +0 -0
  96. package/dist/web/assets/index9-DcVnlsIH.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.2
4
+
5
+ - Queue controls: pause/resume, move earlier, and confirm uncertain deliveries without resending. Sidebar badges and queue event streams replace periodic polling.
6
+ - Queue payloads are stored separately with atomic writes; legacy queues migrate automatically. Completed-message deduplication receipts are retained for 30 days.
7
+ - Read-only workspace Changes panel with expandable diffs and file-path copying.
8
+ - Full-history conversation search with paginated results and jumps to matching messages, including merged streaming replies.
9
+ - Guard concurrent queue delivery checks and ignore stale queue/search responses. Load diff contents only when expanded and clear stale diffs after failed refreshes.
10
+
11
+ ## 0.5.1
12
+
13
+ - Turn-finished push notifications preview the latest agent reply instead of the thread
14
+ title (usually the first prompt). Failed turns show their error when available.
15
+
16
+ - Queued messages and attachments are saved by the BFF and sent when the agent finishes,
17
+ even after the browser closes or the device sleeps. Pending messages survive BFF restarts
18
+ and are visible across signed-in devices. Edit text, remove, or interrupt from the queue.
19
+ - Uncertain deliveries pause the queue for review instead of automatically retrying.
20
+
3
21
  ## 0.5.0
4
22
 
5
23
  ### Sidebar
package/README.md CHANGED
@@ -45,9 +45,13 @@ package, with no separate database service to deploy.
45
45
  - Manage conversations across multiple Paseo hosts in one place.
46
46
  - Create sessions, choose a provider/model, send messages, stop turns, and answer
47
47
  permission requests or structured questions.
48
- - Queue messages while an agent works, then edit, drop or send one at once as an
48
+ - Queue messages on the server while an agent works; they continue after you close the browser
49
+ and survive server restarts. Edit, drop or send one at once as an
49
50
  interrupt; rewind a conversation (and, where the provider supports it, its files)
50
51
  to an earlier message.
52
+ - Review workspace uncommitted changes in a read-only diff panel, including file paths and addition/deletion counts.
53
+ - Search user and agent messages across the full conversation history and jump to matches.
54
+ - Pause, resume and reorder queued messages; check uncertain delivery without resending. Sidebar queue indicators stay synchronized across devices.
51
55
  - Read long conversations without clicking through pages: history loads as you
52
56
  scroll, an outline rail previews and jumps to any prompt, and code is
53
57
  syntax highlighted.
@@ -167,7 +171,8 @@ field, LitePaseo retries once with the other format.
167
171
  | `litepaseo token set` | Choose your own token (at least 16 characters; typed without echo or read from stdin) |
168
172
  | `litepaseo token rotate` | Replace the token with a new random one |
169
173
  | `litepaseo serve` | Run in the foreground |
170
- | `litepaseo version` | Show the installed and running versions (`-v` prints just the number) |
174
+ | `litepaseo version` | Show the installed and running versions (`--json` for scripts) |
175
+ | `litepaseo -v` | Print just the installed version number (also `--version`) |
171
176
  | `litepaseo --help` | List commands; `litepaseo help <command>` explains one |
172
177
 
173
178
  For automatic startup, install a systemd user service on Linux or a LaunchAgent
@@ -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.5.0";
11
+ const VERSION = "0.5.2";
12
12
  // src/server/rotating-log.ts
13
13
  /** One writer (the supervisor); bounded active file plus numbered archives. */
14
14
  var RotatingLog = class {
@@ -1715,7 +1715,7 @@ async function run() {
1715
1715
  if (name === "--help" || name === "-h") return console.log(mainHelp(VERSION, displayDirectory(), out));
1716
1716
  if (name === "worker") {
1717
1717
  const paths = await dataDirectory();
1718
- const { runWorker } = await import("./worker-kSt1QrPO.mjs");
1718
+ const { runWorker } = await import("./worker-C0PSaDFz.mjs");
1719
1719
  return runWorker(paths.directory, fileURLToPath(new URL("../web/", import.meta.url)));
1720
1720
  }
1721
1721
  const command = findCommand(name);
@@ -1254,6 +1254,261 @@ async function importProjectIcon(value, fetchIcon = fetch) {
1254
1254
  }
1255
1255
  throw lastError;
1256
1256
  }
1257
+ // src/server/message-status.ts
1258
+ /** Positive evidence only. Missing, rewound, or out-of-window messages remain uncertain. */
1259
+ async function confirmedMessages(driver, agentId, ids, maxPages = 5) {
1260
+ const wanted = new Set(ids), confirmed = /* @__PURE__ */ new Set();
1261
+ let cursor = null;
1262
+ const seen = /* @__PURE__ */ new Set();
1263
+ for (let pageNumber = 0; pageNumber < maxPages && confirmed.size < wanted.size; pageNumber++) {
1264
+ const page = await driver.fetchAgentTimeline(agentId, {
1265
+ direction: cursor ? "before" : "tail",
1266
+ ...cursor ? { cursor } : {},
1267
+ limit: 200,
1268
+ projection: "projected"
1269
+ });
1270
+ for (const entry of page.entries) {
1271
+ const item = entry.item;
1272
+ if (item.type !== "user_message") continue;
1273
+ const id = item.clientMessageId ?? item.messageId;
1274
+ if (typeof id === "string" && wanted.has(id)) confirmed.add(id);
1275
+ }
1276
+ if (!page.hasOlder || !page.startCursor) break;
1277
+ const key = JSON.stringify(page.startCursor);
1278
+ if (seen.has(key)) break;
1279
+ seen.add(key);
1280
+ cursor = page.startCursor;
1281
+ }
1282
+ return [...confirmed];
1283
+ }
1284
+ // src/server/send-queue.ts
1285
+ /** Durable ownership transfers to the BFF before enqueue is acknowledged. */
1286
+ var ServerSendQueue = class {
1287
+ entries;
1288
+ listeners = /* @__PURE__ */ new Set();
1289
+ saved = /* @__PURE__ */ new Map();
1290
+ inflight = /* @__PURE__ */ new Set();
1291
+ checking = /* @__PURE__ */ new Set();
1292
+ awaitingTurn = /* @__PURE__ */ new Map();
1293
+ stops;
1294
+ closed = false;
1295
+ prunedAt = 0;
1296
+ store;
1297
+ hosts;
1298
+ constructor(store, hosts) {
1299
+ this.store = store;
1300
+ this.hosts = hosts;
1301
+ const ids = JSON.parse(store.setting("send-queue-order") ?? "[]");
1302
+ this.entries = store.setting("send-queue") !== null ? JSON.parse(store.setting("send-queue")) : ids.map((id) => JSON.parse(store.setting(`send-queue-entry:${id}`))).filter(Boolean);
1303
+ for (const entry of this.entries) if (entry.sending) {
1304
+ entry.sending = false;
1305
+ entry.error = "Delivery outcome unknown after restart. Check the conversation before sending again.";
1306
+ }
1307
+ this.save();
1308
+ this.stops = [
1309
+ hosts.onAgentsChanged(() => this.tick()),
1310
+ hosts.onHostsChanged(() => this.tick()),
1311
+ hosts.onTransition((_previous, next) => {
1312
+ if (next && (next.turnActive === true || next.status === "running" || next.status === "initializing")) this.awaitingTurn.delete(next.key);
1313
+ this.tick();
1314
+ })
1315
+ ];
1316
+ this.tick();
1317
+ }
1318
+ key(e) {
1319
+ return `${e.host}:${e.agent}`;
1320
+ }
1321
+ summary() {
1322
+ const result = {};
1323
+ for (const e of this.entries) {
1324
+ const a = this.hosts.agents.get(this.key(e));
1325
+ const key = a?.workspaceId ? `${e.host}:${a.workspaceId}` : this.key(e);
1326
+ const item = result[key] ??= {
1327
+ count: 0,
1328
+ paused: false
1329
+ };
1330
+ item.count++;
1331
+ item.paused ||= !!(e.paused || e.error);
1332
+ }
1333
+ return result;
1334
+ }
1335
+ onChange(fn) {
1336
+ this.listeners.add(fn);
1337
+ return () => {
1338
+ this.listeners.delete(fn);
1339
+ };
1340
+ }
1341
+ save() {
1342
+ const ownTransaction = !this.store.db.isTransaction;
1343
+ if (ownTransaction) this.store.db.exec("BEGIN IMMEDIATE");
1344
+ try {
1345
+ const ids = new Set(this.entries.map((e) => e.id));
1346
+ for (const id of this.saved.keys()) if (!ids.has(id)) {
1347
+ this.store.setSetting(`send-queue-entry:${id}`, null);
1348
+ this.saved.delete(id);
1349
+ }
1350
+ for (const e of this.entries) {
1351
+ const json = JSON.stringify(e);
1352
+ if (this.saved.get(e.id) !== json) {
1353
+ this.store.setSetting(`send-queue-entry:${e.id}`, json);
1354
+ this.saved.set(e.id, json);
1355
+ }
1356
+ }
1357
+ this.store.setSetting("send-queue-order", JSON.stringify([...ids]));
1358
+ this.store.setSetting("send-queue", null);
1359
+ if (ownTransaction) this.store.db.exec("COMMIT");
1360
+ } catch (error) {
1361
+ if (ownTransaction) this.store.db.exec("ROLLBACK");
1362
+ this.saved.clear();
1363
+ throw error;
1364
+ }
1365
+ queueMicrotask(() => {
1366
+ if (!this.closed) for (const fn of this.listeners) fn();
1367
+ });
1368
+ }
1369
+ async control(host, agent, id, action) {
1370
+ const e = this.get(host, agent, id);
1371
+ if (action === "check") {
1372
+ if (!e.error) return;
1373
+ const key = this.key(e);
1374
+ this.checking.add(key);
1375
+ let confirmed;
1376
+ try {
1377
+ confirmed = await confirmedMessages(this.hosts.get(host).driver, agent, [id]);
1378
+ } finally {
1379
+ this.checking.delete(key);
1380
+ }
1381
+ if (this.closed) return;
1382
+ if (!confirmed.includes(id)) throw new Error("Delivery remains unknown. Check the conversation before retrying.");
1383
+ if (!this.entries.includes(e) || e.sending) return;
1384
+ this.entries = this.entries.filter((item) => item !== e);
1385
+ this.awaitingTurn.delete(this.key(e));
1386
+ } else if (action === "up") {
1387
+ const i = this.entries.indexOf(e);
1388
+ const earlier = this.entries.slice(0, i).findLastIndex((item) => this.key(item) === this.key(e));
1389
+ if (earlier >= 0 && this.entries[earlier].error) throw new Error("Resolve the uncertain delivery before moving messages ahead of it.");
1390
+ if (earlier >= 0) [this.entries[i], this.entries[earlier]] = [this.entries[earlier], e];
1391
+ } else e.paused = action === "pause";
1392
+ this.save();
1393
+ this.tick();
1394
+ }
1395
+ list(host, agent) {
1396
+ return this.entries.filter((e) => e.host === host && e.agent === agent).map(({ prepared, ...entry }) => ({ ...entry }));
1397
+ }
1398
+ pruneReceipts() {
1399
+ const now = Date.now();
1400
+ if (now - this.prunedAt < 36e5) return;
1401
+ this.prunedAt = now;
1402
+ const pending = new Set(this.entries.map((e) => e.id));
1403
+ for (const row of this.store.db.prepare("SELECT key,value FROM settings WHERE key LIKE 'queued-message:%'").all()) {
1404
+ const key = String(row.key), value = JSON.parse(String(row.value));
1405
+ if (Array.isArray(value)) this.store.setSetting(key, JSON.stringify({
1406
+ host: value[0],
1407
+ agent: value[1],
1408
+ at: now
1409
+ }));
1410
+ else if (now - value.at > 2592e6 && !pending.has(key.slice(15))) this.store.setSetting(key, null);
1411
+ }
1412
+ }
1413
+ accepted(host, agent, id) {
1414
+ const value = JSON.parse(this.store.setting(`queued-message:${id}`) ?? "null");
1415
+ return Array.isArray(value) ? value[0] === host && value[1] === agent : value?.host === host && value?.agent === agent;
1416
+ }
1417
+ add(entry) {
1418
+ this.pruneReceipts();
1419
+ if (this.accepted(entry.host, entry.agent, entry.id)) return;
1420
+ if (this.entries.some((e) => e.id === entry.id)) throw new Error("Message ID already queued");
1421
+ if (this.entries.length >= 100 || [...this.saved.values()].reduce((size, json) => size + json.length, 0) + JSON.stringify(entry).length > 94371840) throw new Error("Queue is full. Remove queued messages first.");
1422
+ this.entries.push(entry);
1423
+ this.store.db.exec("BEGIN IMMEDIATE");
1424
+ try {
1425
+ this.save();
1426
+ this.store.setSetting(`queued-message:${entry.id}`, JSON.stringify({
1427
+ host: entry.host,
1428
+ agent: entry.agent,
1429
+ at: Date.now()
1430
+ }));
1431
+ this.store.db.exec("COMMIT");
1432
+ } catch (error) {
1433
+ this.store.db.exec("ROLLBACK");
1434
+ this.saved.clear();
1435
+ this.entries.pop();
1436
+ throw error;
1437
+ }
1438
+ this.tick();
1439
+ }
1440
+ get(host, agent, id) {
1441
+ const e = this.entries.find((e) => e.host === host && e.agent === agent && e.id === id);
1442
+ if (!e) throw new Error("Queued message no longer available");
1443
+ if (this.checking.has(this.key(e))) throw new Error("Delivery check in progress. Try again when it completes.");
1444
+ if (e.sending || this.inflight.has(this.key(e))) throw new Error("Message is being sent. Refresh the queue.");
1445
+ return e;
1446
+ }
1447
+ remove(host, agent, id) {
1448
+ const e = this.get(host, agent, id);
1449
+ this.entries = this.entries.filter((item) => item !== e);
1450
+ this.save();
1451
+ this.tick();
1452
+ }
1453
+ edit(host, agent, id, text) {
1454
+ const e = this.get(host, agent, id);
1455
+ if (!text.trim() && !e.attachmentNames.length) throw new Error("Message cannot be empty");
1456
+ e.text = text;
1457
+ this.save();
1458
+ }
1459
+ async interrupt(host, agent, id) {
1460
+ await this.dispatch(this.get(host, agent, id), "interrupt");
1461
+ }
1462
+ tick() {
1463
+ if (this.closed) return;
1464
+ const seen = /* @__PURE__ */ new Set();
1465
+ for (const e of this.entries) {
1466
+ const key = this.key(e);
1467
+ if (seen.has(key)) continue;
1468
+ seen.add(key);
1469
+ const a = this.hosts.agents.get(key);
1470
+ const client = this.hosts.clients.get(e.host);
1471
+ if (!a || client?.driver.getConnectionState().status !== "connected") continue;
1472
+ if (!(a.turnActive === false || a.turnActive === void 0 && a.status !== "running" && a.status !== "initializing")) {
1473
+ this.awaitingTurn.delete(key);
1474
+ continue;
1475
+ }
1476
+ if (this.awaitingTurn.has(key) && (a.activityAt ?? 0) !== this.awaitingTurn.get(key)) this.awaitingTurn.delete(key);
1477
+ if (this.checking.has(key) || e.paused || e.error || e.sending || this.inflight.has(key) || this.awaitingTurn.has(key)) continue;
1478
+ this.dispatch(e, "steer");
1479
+ }
1480
+ }
1481
+ async dispatch(e, behavior) {
1482
+ const key = this.key(e);
1483
+ this.inflight.add(key);
1484
+ this.awaitingTurn.set(key, this.hosts.agents.get(key)?.activityAt ?? 0);
1485
+ e.sending = true;
1486
+ delete e.error;
1487
+ this.save();
1488
+ try {
1489
+ await this.hosts.get(e.host).api.agents.ref(e.agent).send(e.text, {
1490
+ messageId: e.id,
1491
+ activeTurnBehavior: behavior,
1492
+ ...e.prepared
1493
+ });
1494
+ this.entries = this.entries.filter((item) => item !== e);
1495
+ } catch {
1496
+ this.awaitingTurn.delete(key);
1497
+ e.error = "Delivery outcome unknown. Check the conversation before sending again.";
1498
+ } finally {
1499
+ e.sending = false;
1500
+ this.inflight.delete(key);
1501
+ if (!this.closed) {
1502
+ this.save();
1503
+ this.tick();
1504
+ }
1505
+ }
1506
+ }
1507
+ close() {
1508
+ this.closed = true;
1509
+ for (const stop of this.stops) stop();
1510
+ }
1511
+ };
1257
1512
  // src/server/sse.ts
1258
1513
  const HEARTBEAT_MS = 2e4;
1259
1514
  /** Server-sent events over a plain fetch response, so the bearer header still authenticates. */
@@ -1390,6 +1645,12 @@ const path = z.string().min(1).max(4096).refine((p) => !p.includes("\0"));
1390
1645
  * keeps state beyond an open terminal stream.
1391
1646
  */
1392
1647
  function registerWorkspaceRoutes(app, hosts, store, valid) {
1648
+ app.get("/api/hosts/:host/changes", async (c) => {
1649
+ const cwd = path.parse(c.req.query("cwd"));
1650
+ const result = await hosts.get(c.req.param("host")).driver.getCheckoutDiff(cwd, { mode: "uncommitted" });
1651
+ if (result.error) return c.json({ error: result.error.message }, 409);
1652
+ return c.json(result);
1653
+ });
1393
1654
  app.get("/api/hosts/:host/fs/list", async (c) => {
1394
1655
  const cwd = path.parse(c.req.query("cwd"));
1395
1656
  const dir = c.req.query("path") || ".";
@@ -1820,32 +2081,25 @@ var Attachments = class {
1820
2081
  for (const id of ids) this.delete(id);
1821
2082
  }
1822
2083
  };
1823
- // src/server/message-status.ts
1824
- /** Positive evidence only. Missing, rewound, or out-of-window messages remain uncertain. */
1825
- async function confirmedMessages(driver, agentId, ids, maxPages = 5) {
1826
- const wanted = new Set(ids), confirmed = /* @__PURE__ */ new Set();
1827
- let cursor = null;
1828
- const seen = /* @__PURE__ */ new Set();
1829
- for (let pageNumber = 0; pageNumber < maxPages && confirmed.size < wanted.size; pageNumber++) {
1830
- const page = await driver.fetchAgentTimeline(agentId, {
1831
- direction: cursor ? "before" : "tail",
1832
- ...cursor ? { cursor } : {},
1833
- limit: 200,
1834
- projection: "projected"
1835
- });
1836
- for (const entry of page.entries) {
1837
- const item = entry.item;
1838
- if (item.type !== "user_message") continue;
1839
- const id = item.clientMessageId ?? item.messageId;
1840
- if (typeof id === "string" && wanted.has(id)) confirmed.add(id);
1841
- }
1842
- if (!page.hasOlder || !page.startCursor) break;
1843
- const key = JSON.stringify(page.startCursor);
1844
- if (seen.has(key)) break;
1845
- seen.add(key);
1846
- cursor = page.startCursor;
2084
+ // src/server/notification-preview.ts
2085
+ /** A bounded timeline read; never use the user's prompt or a previous turn as the preview. */
2086
+ async function notificationPreview(driver, agent, startedAt, endedAt) {
2087
+ const page = await driver.fetchAgentTimeline(agent, {
2088
+ direction: "tail",
2089
+ limit: 200,
2090
+ projection: "projected"
2091
+ });
2092
+ for (let i = page.entries.length - 1; i >= 0; i--) {
2093
+ const entry = page.entries[i];
2094
+ const at = Date.parse(entry.timestamp);
2095
+ if (endedAt && at > endedAt) continue;
2096
+ if (startedAt && at < startedAt) return null;
2097
+ if (entry.item.type === "user_message") return null;
2098
+ if (entry.item.type !== "assistant_message") continue;
2099
+ const text = entry.item.text?.replace(/\s+/g, " ").trim();
2100
+ if (text) return text.slice(0, 240);
1847
2101
  }
1848
- return [...confirmed];
2102
+ return null;
1849
2103
  }
1850
2104
  // src/shared/wire.ts
1851
2105
  /** "Run npm test" → "run npm test", for use mid-sentence ("wants to run npm test"). */
@@ -1896,12 +2150,14 @@ var Notifier = class {
1896
2150
  waiting = /* @__PURE__ */ new Set();
1897
2151
  recent = /* @__PURE__ */ new Map();
1898
2152
  now;
2153
+ replyPreview;
1899
2154
  constructor(options) {
1900
2155
  this.store = options.store;
1901
2156
  this.sender = options.sender;
1902
2157
  this.isViewing = options.isViewing;
1903
2158
  this.hostLabel = options.hostLabel;
1904
2159
  this.now = options.now ?? Date.now;
2160
+ this.replyPreview = options.replyPreview;
1905
2161
  }
1906
2162
  get waitingCount() {
1907
2163
  return this.waiting.size;
@@ -1916,11 +2172,11 @@ var Notifier = class {
1916
2172
  if (next.attention && !previous.attention || newPermission) {
1917
2173
  const permission = next.pendingPermissions[0];
1918
2174
  const what = permission ? permission.kind === "question" ? `asks: ${permission.title || permission.name}` : `wants to ${midSentence(permission.title || permission.name)}` : "is waiting for you";
1919
- this.emit("attention", next, `${next.project} · needs your input`, `${next.title || "Session"} ${what}`);
2175
+ this.emit("attention", next, `${next.project} · needs your input`, permission ? `The agent ${what}` : "The agent is waiting for your input.", permission ? void 0 : previous);
1920
2176
  } else if (previous.status === "running" && next.status !== "running") {
1921
2177
  if (this.now() - next.activityAt > STALE_MS) return;
1922
2178
  const failed = next.status === "error";
1923
- this.emit(failed ? "turn-failed" : "turn-done", next, `${next.project} · ${failed ? "turn failed" : "turn finished"}`, next.title || "Session");
2179
+ this.emit(failed ? "turn-failed" : "turn-done", next, `${next.project} · ${failed ? "turn failed" : "turn finished"}`, failed ? next.lastError || "The agent could not finish this turn." : "The agent finished this turn.", failed ? void 0 : previous);
1924
2180
  }
1925
2181
  }
1926
2182
  async test(sessionId) {
@@ -1935,12 +2191,27 @@ var Notifier = class {
1935
2191
  })));
1936
2192
  return subs.length;
1937
2193
  }
1938
- emit(kind, agent, title, body) {
2194
+ async emit(kind, agent, title, body, previous) {
1939
2195
  const dedupeKey = `${kind}:${agent.key}`;
1940
2196
  const now = this.now();
1941
2197
  if (now - (this.recent.get(dedupeKey) ?? -Infinity) < DEDUPE_MS) return;
1942
2198
  this.recent.set(dedupeKey, now);
1943
2199
  if (this.recent.size > 5e3) this.recent.clear();
2200
+ const pref = kind === "attention" ? "attention" : "turns";
2201
+ const subscriptions = this.store.pushSubscriptions().filter((s) => s.prefs[pref] && !this.isViewing(agent.key, s.sessionId));
2202
+ if (!subscriptions.length) return;
2203
+ if (previous && this.replyPreview) {
2204
+ let timer;
2205
+ try {
2206
+ const preview = await Promise.race([this.replyPreview(agent, previous), new Promise((resolve) => {
2207
+ timer = setTimeout(() => resolve(null), 5e3);
2208
+ timer.unref();
2209
+ })]);
2210
+ if (preview?.trim()) body = preview.replace(/\s+/g, " ").trim();
2211
+ } catch {} finally {
2212
+ clearTimeout(timer);
2213
+ }
2214
+ }
1944
2215
  const message = {
1945
2216
  title,
1946
2217
  body: `${body} — ${this.hostLabel(agent.hostId)}`.slice(0, 240),
@@ -1949,8 +2220,7 @@ var Notifier = class {
1949
2220
  kind,
1950
2221
  badge: this.waiting.size
1951
2222
  };
1952
- const pref = kind === "attention" ? "attention" : "turns";
1953
- for (const subscription of this.store.pushSubscriptions()) if (subscription.prefs[pref] && !this.isViewing(agent.key, subscription.sessionId)) this.deliver(subscription, message);
2223
+ for (const subscription of subscriptions) if (!this.isViewing(agent.key, subscription.sessionId)) this.deliver(subscription, message);
1954
2224
  }
1955
2225
  async deliver(subscription, message) {
1956
2226
  const session = this.store.sessionById(subscription.sessionId);
@@ -2753,12 +3023,14 @@ function createApp(store, hosts, token, webRoot, options = {}) {
2753
3023
  ...metrics
2754
3024
  })));
2755
3025
  const attachments = new Attachments();
3026
+ const sendQueue = new ServerSendQueue(store, hosts);
2756
3027
  const projectIcons = new IconCache();
2757
3028
  const viewers = /* @__PURE__ */ new Map();
2758
3029
  const notifier = new Notifier({
2759
3030
  store,
2760
3031
  sender: options.pushSender ?? webPushSender(store, options.pushSubject ?? "mailto:litepaseo@example.com"),
2761
3032
  isViewing: (key, sessionId) => (viewers.get(key)?.get(sessionId) ?? 0) > 0,
3033
+ replyPreview: (agent, previous) => notificationPreview(hosts.get(agent.hostId).driver, agent.id, previous.turnStartedAt, agent.attention ? void 0 : agent.activityAt),
2762
3034
  hostLabel: (id) => hosts.label(id) || store.hosts().find((h) => h.id === id)?.label || ""
2763
3035
  });
2764
3036
  hosts.onTransition((previous, next) => notifier.transition(previous, next));
@@ -3445,6 +3717,98 @@ function createApp(store, hosts, token, webRoot, options = {}) {
3445
3717
  }
3446
3718
  return c.json({ ok: true });
3447
3719
  });
3720
+ app.get("/api/queue/stream", (c) => eventStream(c.req.raw.signal, (send) => {
3721
+ const publish = () => send(sendQueue.summary());
3722
+ const stop = sendQueue.onChange(publish), stopHosts = hosts.onAgentsChanged(publish);
3723
+ publish();
3724
+ return () => {
3725
+ stop();
3726
+ stopHosts();
3727
+ };
3728
+ }, streamValidity(c)));
3729
+ app.get("/api/hosts/:host/agents/:agent/queue/stream", (c) => eventStream(c.req.raw.signal, (send) => {
3730
+ const publish = () => send(sendQueue.list(c.req.param("host"), c.req.param("agent")));
3731
+ const stop = sendQueue.onChange(publish);
3732
+ publish();
3733
+ return stop;
3734
+ }, streamValidity(c)));
3735
+ app.post("/api/hosts/:host/agents/:agent/queue/:id/control", async (c) => {
3736
+ const { action } = z.object({ action: z.enum([
3737
+ "pause",
3738
+ "resume",
3739
+ "up",
3740
+ "check"
3741
+ ]) }).parse(await c.req.json());
3742
+ try {
3743
+ await sendQueue.control(c.req.param("host"), c.req.param("agent"), c.req.param("id"), action);
3744
+ } catch (error) {
3745
+ return c.json({ error: error.message }, 409);
3746
+ }
3747
+ return c.json({ ok: true });
3748
+ });
3749
+ app.get("/api/hosts/:host/agents/:agent/search", async (c) => {
3750
+ const query = z.string().trim().min(1).max(500).parse(c.req.query("q"));
3751
+ const cursor = z.coerce.number().int().nonnegative().optional().parse(c.req.query("cursor"));
3752
+ const result = await hosts.get(c.req.param("host")).driver.searchAgentTimeline({
3753
+ agentId: c.req.param("agent"),
3754
+ query,
3755
+ cursor
3756
+ });
3757
+ if (result.error) return c.json({ error: result.error }, 502);
3758
+ return c.json(result);
3759
+ });
3760
+ app.get("/api/hosts/:host/agents/:agent/queue", (c) => c.json(sendQueue.list(c.req.param("host"), c.req.param("agent"))));
3761
+ app.post("/api/hosts/:host/agents/:agent/queue", async (c) => {
3762
+ const input = z.object({
3763
+ id: z.string().uuid(),
3764
+ text: z.string().trim().max(1e5),
3765
+ attachmentIds: z.array(z.string().uuid()).max(4).default([])
3766
+ }).refine((v) => !!v.text || !!v.attachmentIds.length).parse(await c.req.json());
3767
+ const host = c.req.param("host"), agent = c.req.param("agent");
3768
+ hosts.get(host);
3769
+ if (sendQueue.accepted(host, agent, input.id)) return c.json({ ok: true });
3770
+ try {
3771
+ const attachmentNames = input.attachmentIds.map((id) => attachments.get(id, attachmentOwner(c), host, agent).name);
3772
+ const prepared = await attachments.prepare(hosts, attachmentOwner(c), host, agent, input.attachmentIds);
3773
+ sendQueue.add({
3774
+ id: input.id,
3775
+ text: input.text,
3776
+ host,
3777
+ agent,
3778
+ attachmentNames,
3779
+ prepared
3780
+ });
3781
+ attachments.consumed(input.attachmentIds);
3782
+ return c.json({ ok: true }, 201);
3783
+ } catch (error) {
3784
+ return c.json({ error: error.message }, 400);
3785
+ }
3786
+ });
3787
+ app.delete("/api/hosts/:host/agents/:agent/queue/:id", (c) => {
3788
+ try {
3789
+ sendQueue.remove(c.req.param("host"), c.req.param("agent"), c.req.param("id"));
3790
+ } catch (error) {
3791
+ return c.json({ error: error.message }, 409);
3792
+ }
3793
+ return c.json({ ok: true });
3794
+ });
3795
+ app.patch("/api/hosts/:host/agents/:agent/queue/:id", async (c) => {
3796
+ const { text } = z.object({ text: z.string().max(1e5) }).parse(await c.req.json());
3797
+ try {
3798
+ sendQueue.edit(c.req.param("host"), c.req.param("agent"), c.req.param("id"), text);
3799
+ } catch (error) {
3800
+ return c.json({ error: error.message }, 409);
3801
+ }
3802
+ return c.json({ ok: true });
3803
+ });
3804
+ app.post("/api/hosts/:host/agents/:agent/queue/:id/send", async (c) => {
3805
+ try {
3806
+ await sendQueue.interrupt(c.req.param("host"), c.req.param("agent"), c.req.param("id"));
3807
+ } catch (error) {
3808
+ return c.json({ error: error.message }, 409);
3809
+ }
3810
+ return c.json({ ok: true });
3811
+ });
3448
3812
  app.post("/api/hosts/:host/agents/:agent/messages/status", async (c) => {
3449
3813
  const { messageIds } = z.object({ messageIds: z.array(z.string().uuid()).min(1).max(20) }).parse(await c.req.json());
3450
3814
  const { driver } = hosts.get(c.req.param("host"));
@@ -3760,6 +4124,7 @@ function createApp(store, hosts, token, webRoot, options = {}) {
3760
4124
  clearTimeout(agentFlush);
3761
4125
  clearTimeout(hostFlush);
3762
4126
  agentFlush = hostFlush = void 0;
4127
+ sendQueue.close();
3763
4128
  attachments.close();
3764
4129
  dictationStreams.close();
3765
4130
  }
@@ -0,0 +1 @@
1
+ .changes-panel[data-v-4de9f4ce]{height:100%;padding:12px;font-size:13px;overflow:auto}details[data-v-4de9f4ce]{border-top:1px solid var(--border);margin-top:12px;padding-top:8px}summary[data-v-4de9f4ce]{cursor:pointer;overflow-wrap:anywhere}pre[data-v-4de9f4ce]{font-size:12px;overflow:auto}code span[data-v-4de9f4ce]{white-space:pre;display:block}.add[data-v-4de9f4ce]{background:#2842}.remove[data-v-4de9f4ce]{background:#c332}.hunk[data-v-4de9f4ce]{color:var(--fg-muted)}
@@ -0,0 +1,2 @@
1
+ import{$ as e,G as t,I as n,P as r,S as i,T as a,f as o,g as s,ot as c,rt as l,v as u,y as d,z as f}from"./vue.runtime.esm-bundler-DwGo9CTz.js";import{n as p}from"./index-Ub0Ct8zc.js";var m={class:`changes-panel`},h=[`disabled`],g={key:0,role:`alert`},_={key:1},v={key:2},y=[`onToggle`],b=[`onClick`],x={key:0},S={key:1},C={class:`hunk`},w=p(a({__name:`ChangesPanel`,props:{hostId:{},cwd:{},api:{type:Function}},setup(a){let p=a,w=e([]),T=e(``),E=e(!1),D=e(!1),O=0,k=e(new Set);r(()=>O++);async function A(){let e=++O;E.value=!0,T.value=``,w.value=[],D.value=!1,k.value=new Set;try{let t=await p.api(`/hosts/${encodeURIComponent(p.hostId)}/changes?cwd=${encodeURIComponent(p.cwd)}`);if(e!==O)return;w.value=t.files,D.value=!!t.diffTooLarge}catch(t){e===O&&(T.value=t.message)}finally{e===O&&(E.value=!1)}}async function j(e){try{await navigator.clipboard.writeText(e)}catch{T.value=`Could not copy path.`}}return t(()=>[p.hostId,p.cwd],()=>{w.value=[],A()},{immediate:!0}),(e,t)=>(n(),d(`section`,m,[t[0]||=s(`p`,null,`Workspace uncommitted changes · includes changes from all contributors.`,-1),s(`button`,{class:`btn`,disabled:E.value,onClick:A},c(E.value?`Loading…`:`Refresh changes`),9,h),T.value?(n(),d(`p`,g,c(T.value),1)):u(``,!0),D.value?(n(),d(`p`,_,`Diff exceeds the host limit; some changes are omitted.`)):u(``,!0),!E.value&&!T.value&&!w.value.length?(n(),d(`p`,v,`No uncommitted changes.`)):u(``,!0),(n(!0),d(o,null,f(w.value,e=>(n(),d(`details`,{key:e.path,onToggle:t=>t.target.open?k.value.add(e.path):k.value.delete(e.path)},[s(`summary`,null,[i(c(e.oldPath?e.oldPath+` → `:``)+c(e.path)+` `,1),s(`span`,null,`+`+c(e.additions)+` −`+c(e.deletions),1)]),s(`button`,{class:`btn btn-ghost`,onClick:t=>j(e.path)},`Copy path`,8,b),e.status===`binary`?(n(),d(`p`,x,`Binary file changed.`)):e.status===`too_large`?(n(),d(`p`,S,`File diff is too large to display.`)):u(``,!0),k.value.has(e.path)?(n(!0),d(o,{key:2},f(e.hunks,(e,t)=>(n(),d(`pre`,{key:t},[s(`code`,null,[s(`span`,C,`@@ −`+c(e.oldStart)+`,`+c(e.oldCount)+` +`+c(e.newStart)+`,`+c(e.newCount)+` @@
2
+ `,1),(n(!0),d(o,null,f(e.lines,(e,t)=>(n(),d(`span`,{key:t,class:l(e.type)},c(e.type===`add`?`+`:e.type===`remove`?`−`:` `)+c(e.content),3))),128))])]))),128)):u(``,!0)],40,y))),128))]))}}),[[`__scopeId`,`data-v-4de9f4ce`]]);export{w as default};