@circuitwall/jarela 2.3.0 → 2.4.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 (208) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  13. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  18. package/.next/standalone/.next/server/app/api/v1/access/[identity]/route.js +7 -0
  19. package/.next/standalone/.next/server/app/api/v1/access/route.js +7 -0
  20. package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js +7 -0
  21. package/.next/standalone/.next/server/app/api/v1/agents/[id]/display-filters/route.js +17 -5
  22. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +7 -0
  23. package/.next/standalone/.next/server/app/api/v1/agents/[id]/thread/route.js +17 -5
  24. package/.next/standalone/.next/server/app/api/v1/agents/route.js +7 -0
  25. package/.next/standalone/.next/server/app/api/v1/allowed-sites/[hostname]/route.js +7 -0
  26. package/.next/standalone/.next/server/app/api/v1/allowed-sites/route.js +7 -0
  27. package/.next/standalone/.next/server/app/api/v1/artifacts/lifecycle/route.js +7 -0
  28. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +26 -32
  29. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/[remote_jid]/route.js +18 -7
  31. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/route.js +18 -7
  32. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +26 -32
  33. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +27 -33
  35. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +26 -32
  37. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/[route_id]/route.js +28 -12
  39. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/route.js +28 -12
  40. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +26 -32
  41. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js +9 -2
  43. package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/v1/bridges/route.js +19 -7
  45. package/.next/standalone/.next/server/app/api/v1/bridges/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js +17 -5
  47. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js +7 -0
  48. package/.next/standalone/.next/server/app/api/v1/documents/search/route.js +7 -0
  49. package/.next/standalone/.next/server/app/api/v1/documents/settings/route.js +7 -0
  50. package/.next/standalone/.next/server/app/api/v1/env-sync/allowlist/route.js +7 -0
  51. package/.next/standalone/.next/server/app/api/v1/env-sync/route.js +7 -0
  52. package/.next/standalone/.next/server/app/api/v1/events/route.js +26 -32
  53. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/v1/extension/browser/activate/route.js +7 -0
  55. package/.next/standalone/.next/server/app/api/v1/extension/browser/foreground/route.js +7 -0
  56. package/.next/standalone/.next/server/app/api/v1/extension/browser/history/route.js +7 -0
  57. package/.next/standalone/.next/server/app/api/v1/extension/browser/poll/route.js +7 -0
  58. package/.next/standalone/.next/server/app/api/v1/extension/browser/progress/route.js +7 -0
  59. package/.next/standalone/.next/server/app/api/v1/extension/browser/result/route.js +7 -0
  60. package/.next/standalone/.next/server/app/api/v1/extension/browser/retry/route.js +7 -0
  61. package/.next/standalone/.next/server/app/api/v1/extension/browser/status/route.js +7 -0
  62. package/.next/standalone/.next/server/app/api/v1/extension/browser/tabs/route.js +7 -0
  63. package/.next/standalone/.next/server/app/api/v1/harnesses/[id]/route.js +7 -0
  64. package/.next/standalone/.next/server/app/api/v1/harnesses/default/route.js +7 -0
  65. package/.next/standalone/.next/server/app/api/v1/harnesses/route.js +7 -0
  66. package/.next/standalone/.next/server/app/api/v1/health/route.js +17 -5
  67. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/route.js +7 -0
  68. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +7 -0
  69. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +7 -0
  70. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +7 -0
  71. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +7 -0
  72. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +7 -0
  73. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +7 -0
  74. package/.next/standalone/.next/server/app/api/v1/integrations/route.js +7 -0
  75. package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js +17 -5
  76. package/.next/standalone/.next/server/app/api/v1/maps/embed/route.js +7 -0
  77. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +17 -5
  78. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +17 -5
  79. package/.next/standalone/.next/server/app/api/v1/memory/[namespace]/[key]/route.js +7 -0
  80. package/.next/standalone/.next/server/app/api/v1/memory/policy/route.js +7 -0
  81. package/.next/standalone/.next/server/app/api/v1/memory/route.js +7 -0
  82. package/.next/standalone/.next/server/app/api/v1/memory/search/route.js +7 -0
  83. package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js +7 -0
  84. package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js +7 -0
  85. package/.next/standalone/.next/server/app/api/v1/models/route.js +7 -0
  86. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +27 -12
  87. package/.next/standalone/.next/server/app/api/v1/profile/location/route.js +7 -0
  88. package/.next/standalone/.next/server/app/api/v1/profile/route.js +7 -0
  89. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +7 -0
  90. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/probe/route.js +7 -0
  91. package/.next/standalone/.next/server/app/api/v1/providers/github-copilot/auth/route.js +7 -0
  92. package/.next/standalone/.next/server/app/api/v1/providers/route.js +7 -0
  93. package/.next/standalone/.next/server/app/api/v1/proxy-config/route.js +7 -0
  94. package/.next/standalone/.next/server/app/api/v1/redaction/init/route.js +7 -0
  95. package/.next/standalone/.next/server/app/api/v1/redaction/route.js +7 -0
  96. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/route.js +17 -5
  97. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/route.js +7 -0
  98. package/.next/standalone/.next/server/app/api/v1/security/idle-timeout/route.js +7 -0
  99. package/.next/standalone/.next/server/app/api/v1/security/pin/route.js +7 -0
  100. package/.next/standalone/.next/server/app/api/v1/security/state/route.js +7 -0
  101. package/.next/standalone/.next/server/app/api/v1/security/unlock/route.js +7 -0
  102. package/.next/standalone/.next/server/app/api/v1/security/verify-pin/route.js +7 -0
  103. package/.next/standalone/.next/server/app/api/v1/skills/[id]/route.js +7 -0
  104. package/.next/standalone/.next/server/app/api/v1/skills/repos/[id]/route.js +7 -0
  105. package/.next/standalone/.next/server/app/api/v1/skills/repos/route.js +7 -0
  106. package/.next/standalone/.next/server/app/api/v1/skills/route.js +7 -0
  107. package/.next/standalone/.next/server/app/api/v1/tasks/[agent_id]/route.js +7 -0
  108. package/.next/standalone/.next/server/app/api/v1/tasks/route.js +7 -0
  109. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js +7 -0
  110. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js +12 -6
  111. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +7 -0
  112. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +0 -1
  113. package/.next/standalone/.next/server/app/api/v1/threads/route.js +17 -5
  114. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  115. package/.next/standalone/.next/server/app/api/v1/voice/transcribe/route.js +17 -5
  116. package/.next/standalone/.next/server/app/api/v1/voice/tts/route.js +17 -5
  117. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/route.js +17 -5
  118. package/.next/standalone/.next/server/app/page.js +322 -275
  119. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  120. package/.next/standalone/.next/server/app/setup/page.js +8 -0
  121. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  122. package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
  123. package/.next/standalone/.next/server/chunks/1388.js +106 -36
  124. package/.next/standalone/.next/server/chunks/2068.js +47 -10
  125. package/.next/standalone/.next/server/chunks/210.js +6 -6
  126. package/.next/standalone/.next/server/chunks/2447.js +10 -5
  127. package/.next/standalone/.next/server/chunks/2471.js +17 -17
  128. package/.next/standalone/.next/server/chunks/3042.js +10 -8
  129. package/.next/standalone/.next/server/chunks/{4540.js → 309.js} +104 -38
  130. package/.next/standalone/.next/server/chunks/{2350.js → 3272.js} +104 -37
  131. package/.next/standalone/.next/server/chunks/3399.js +525 -525
  132. package/.next/standalone/.next/server/chunks/3524.js +150 -67
  133. package/.next/standalone/.next/server/chunks/4189.js +1 -1
  134. package/.next/standalone/.next/server/chunks/4508.js +2 -2
  135. package/.next/standalone/.next/server/chunks/46.js +73 -28
  136. package/.next/standalone/.next/server/chunks/5908.js +63 -42
  137. package/.next/standalone/.next/server/chunks/6142.js +10 -2
  138. package/.next/standalone/.next/server/chunks/6649.js +1 -1
  139. package/.next/standalone/.next/server/chunks/8461.js +10 -8
  140. package/.next/standalone/.next/server/chunks/9032.js +5 -5
  141. package/.next/standalone/.next/server/chunks/9164.js +435 -176
  142. package/.next/standalone/.next/server/chunks/9304.js +51 -12
  143. package/.next/standalone/.next/server/chunks/{423.js → 9590.js} +66 -21
  144. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  145. package/.next/standalone/.next/server/middleware.js +71 -18
  146. package/.next/standalone/.next/server/pages/404.html +2 -2
  147. package/.next/standalone/.next/server/pages/500.html +1 -1
  148. package/.next/standalone/.next/server/preview-props.json +3 -3
  149. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  150. package/.next/standalone/.next/static/chunks/app/{page-213a623b37226452.js → page-04748847c6ff866f.js} +171 -132
  151. package/.next/standalone/.next/static/css/{312542a5725ba0d5.css → 2669e8744cc8c212.css} +2 -2
  152. package/.next/standalone/docs/adoption/changesets.json +49 -0
  153. package/.next/standalone/package.json +1 -1
  154. package/CHANGELOG.md +19 -0
  155. package/app/api/v1/threads/[thread_id]/run/route.ts +0 -1
  156. package/components/chat/MessageBubble.tsx +12 -0
  157. package/components/integrations/NetworkSection.tsx +2 -2
  158. package/lib/agents/citation-checker.test.ts +40 -2
  159. package/lib/agents/citation-checker.ts +56 -11
  160. package/lib/agents/context-boundary.ts +5 -6
  161. package/lib/agents/instruction-edits.test.ts +120 -0
  162. package/lib/agents/instruction-edits.ts +65 -42
  163. package/lib/agents/prepare/request.ts +0 -2
  164. package/lib/agents/prepare/system-prompt.test.ts +10 -0
  165. package/lib/agents/prepare/system-prompt.ts +8 -2
  166. package/lib/agents/proposals.test.ts +76 -0
  167. package/lib/agents/proposals.ts +13 -5
  168. package/lib/agents/run-thread.auto-boundary.test.ts +125 -5
  169. package/lib/agents/run-thread.ts +24 -9
  170. package/lib/agents/sqlite-checkpoint-saver.test.ts +91 -0
  171. package/lib/agents/warm-summary-background.ts +22 -2
  172. package/lib/agents/warm-topics.test.ts +155 -1
  173. package/lib/agents/warm-topics.ts +27 -7
  174. package/lib/bridges/dispatcher.ts +1 -0
  175. package/lib/bridges/message-role.test.ts +81 -0
  176. package/lib/bridges/message-role.ts +23 -10
  177. package/lib/bridges/types.ts +6 -0
  178. package/lib/bridges/whatsapp-link.test.ts +32 -0
  179. package/lib/bridges/whatsapp-link.ts +21 -0
  180. package/lib/bridges/whatsapp.inbound.test.ts +239 -0
  181. package/lib/bridges/whatsapp.sender.test.ts +80 -1
  182. package/lib/bridges/whatsapp.ts +76 -38
  183. package/lib/pricing/snapshot.test.ts +70 -0
  184. package/lib/pricing/snapshot.ts +10 -2
  185. package/lib/proxy/dispatcher.test.ts +119 -1
  186. package/lib/proxy/dispatcher.ts +22 -9
  187. package/lib/stores/agent-configs.ts +10 -5
  188. package/lib/stores/bridges.test.ts +81 -0
  189. package/lib/stores/bridges.ts +9 -8
  190. package/lib/stores/proxy-config.test.ts +120 -0
  191. package/lib/stores/proxy-config.ts +22 -4
  192. package/lib/stores/threads.ts +12 -8
  193. package/lib/tools/communications/calendar.test.ts +43 -2
  194. package/lib/tools/communications/calendar.ts +2 -0
  195. package/lib/tools/communications/gmail.test.ts +51 -1
  196. package/lib/tools/communications/gmail.ts +44 -2
  197. package/lib/tools/communications/outlook-calendar.ts +2 -0
  198. package/lib/tools/communications/outlook.test.ts +33 -2
  199. package/lib/tools/communications/outlook.ts +2 -0
  200. package/lib/tools/filesystem/edit-match.test.ts +133 -0
  201. package/lib/tools/filesystem/edit-match.ts +7 -2
  202. package/lib/tools/support/result-refs.test.ts +131 -0
  203. package/lib/tools/support/result-refs.ts +41 -9
  204. package/lib/utils/source-link.test.ts +51 -0
  205. package/lib/utils/source-link.ts +45 -0
  206. package/package.json +1 -1
  207. /package/.next/standalone/.next/static/{bMRK5y3ruT7c3WtBfCQOG → hwujW4hR1b-r3k5WdMxZO}/_buildManifest.js +0 -0
  208. /package/.next/standalone/.next/static/{bMRK5y3ruT7c3WtBfCQOG → hwujW4hR1b-r3k5WdMxZO}/_ssgManifest.js +0 -0
@@ -2835,6 +2835,22 @@ var SelectorType;
2835
2835
  })(SelectorType || (SelectorType = {}));
2836
2836
 
2837
2837
 
2838
+ /***/ }),
2839
+
2840
+ /***/ 49585:
2841
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2842
+
2843
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2844
+ /* harmony export */ f: () => (/* binding */ SerdeContext)
2845
+ /* harmony export */ });
2846
+ class SerdeContext {
2847
+ serdeContext;
2848
+ setSerdeContext(serdeContext) {
2849
+ this.serdeContext = serdeContext;
2850
+ }
2851
+ }
2852
+
2853
+
2838
2854
  /***/ }),
2839
2855
 
2840
2856
  /***/ 52053:
@@ -4476,22 +4492,6 @@ function determineTimestampFormat(ns, settings) {
4476
4492
  }
4477
4493
 
4478
4494
 
4479
- /***/ }),
4480
-
4481
- /***/ 71966:
4482
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4483
-
4484
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4485
- /* harmony export */ f: () => (/* binding */ SerdeContext)
4486
- /* harmony export */ });
4487
- class SerdeContext {
4488
- serdeContext;
4489
- setSerdeContext(serdeContext) {
4490
- this.serdeContext = serdeContext;
4491
- }
4492
- }
4493
-
4494
-
4495
4495
  /***/ }),
4496
4496
 
4497
4497
  /***/ 72315:
@@ -5539,7 +5539,7 @@ const parseUrl = (url) => {
5539
5539
  /* harmony import */ var _smithy_core_transport__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(51810);
5540
5540
  /* harmony import */ var _smithy_core_transport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48296);
5541
5541
  /* harmony import */ var _smithy_core_transport__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(97776);
5542
- /* harmony import */ var _SerdeContext__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71966);
5542
+ /* harmony import */ var _SerdeContext__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(49585);
5543
5543
 
5544
5544
 
5545
5545
 
@@ -21,12 +21,12 @@ exports.modules = {
21
21
  /* harmony export */ S0: () => (/* binding */ getRecentMessagesWindow),
22
22
  /* harmony export */ T1: () => (/* binding */ setThreadContextPin),
23
23
  /* harmony export */ TX: () => (/* binding */ getMessagesByAutomationCategory),
24
+ /* harmony export */ Tb: () => (/* binding */ countForegroundThreadMessages),
24
25
  /* harmony export */ VL: () => (/* binding */ getMessages),
25
26
  /* harmony export */ Xi: () => (/* binding */ appendMessageDraft),
26
27
  /* harmony export */ Zb: () => (/* binding */ mergeMessageMetadata),
27
28
  /* harmony export */ e8: () => (/* binding */ updateMessageContent),
28
29
  /* harmony export */ fG: () => (/* binding */ getThread),
29
- /* harmony export */ fW: () => (/* binding */ countThreadMessagesFromSeq),
30
30
  /* harmony export */ k3: () => (/* binding */ getRecentlyUsedToolNames),
31
31
  /* harmony export */ m9: () => (/* binding */ isValidThreadContextCursor),
32
32
  /* harmony export */ mI: () => (/* binding */ touchThread),
@@ -141,8 +141,10 @@ function getThread(thread_id) {
141
141
  function getThreadMessageBySeq(thread_id, seq) {
142
142
  return (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare(MSG_COLS_SQL + " WHERE thread_id=? AND rowid=?").get(thread_id, seq) ?? null;
143
143
  }
144
- function countThreadMessagesFromSeq(thread_id, seq) {
145
- const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT COUNT(*) AS n FROM messages WHERE thread_id=? AND rowid>=?").get(thread_id, seq);
144
+ // Rows that size compaction can prune: automation-channel rows are kept
145
+ // (see pruneThreadMessages), so they must not count toward its trigger.
146
+ function countForegroundThreadMessages(thread_id, fromSeq = 0) {
147
+ const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT COUNT(*) AS n FROM messages WHERE thread_id=? AND rowid>=? AND " + foregroundCategoryGuardSql()).get(thread_id, fromSeq, ...FOREGROUND_EXCLUDED_CATEGORIES);
146
148
  return row?.n ?? 0;
147
149
  }
148
150
  function isValidThreadContextCursor(thread_id, seq) {
@@ -582,11 +584,11 @@ function setThreadContextPin(thread_id, hot_since, hot_since_seq) {
582
584
  }
583
585
  (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE threads SET hot_since=?, hot_since_seq=? WHERE thread_id=?").run(hot_since, hot_since === null ? null : hot_since_seq, thread_id);
584
586
  }
585
- // Called by moveThreadContextBoundary whenever the user explicitly moves the
586
- // boundary (drag, or manual /compact) — never by the auto-detector's own
587
- // commit path, which calls setThreadContextPin directly. `untilMessageCount`
588
- // is a one-time write; the read side (lib/agents/run-thread.ts) just compares
589
- // against it, no per-turn write needed.
587
+ // Armed by moveThreadContextBoundary whenever the user explicitly moves the
588
+ // boundary (drag, or manual /compact), and by the auto-detector's hot-turn
589
+ // cooldown when a compaction pass ends without a commit (a commit writes the
590
+ // lock in the same transaction). `untilMessageCount` is a one-time write; the
591
+ // read side (lib/agents/run-thread.ts) just compares against it.
590
592
  function setAutoBoundaryLock(thread_id, untilMessageCount) {
591
593
  (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE threads SET auto_boundary_locked_until_msg_count=? WHERE thread_id=?").run(Math.max(0, untilMessageCount), thread_id);
592
594
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.id = 4540;
3
- exports.ids = [4540];
2
+ exports.id = 309;
3
+ exports.ids = [309];
4
4
  exports.modules = {
5
5
 
6
- /***/ 44540:
6
+ /***/ 70309:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
9
 
@@ -203,6 +203,26 @@ function safeBridgeId(id) {
203
203
  return baseDir();
204
204
  }
205
205
 
206
+ ;// ./lib/bridges/whatsapp-link.ts
207
+ /**
208
+ * WhatsApp click-to-chat link for a Baileys JID.
209
+ *
210
+ * WhatsApp has no permalink to a group or to a single message, so only 1:1
211
+ * chats with a phone-number JID get a link: `https://wa.me/<digits>` opens
212
+ * that chat in the WhatsApp app or WhatsApp Web. `@lid` ids hide the phone
213
+ * number, and groups, channels and broadcasts have no public chat URL.
214
+ */ // E.164 numbers are at most 15 digits; the shortest real ones are 7–8.
215
+ const E164_DIGITS = /^[1-9]\d{6,14}$/;
216
+ function whatsappChatLink(jid) {
217
+ if (!jid) return null;
218
+ const at = jid.lastIndexOf("@");
219
+ if (at < 0) return null;
220
+ const host = jid.slice(at + 1);
221
+ if (host !== "s.whatsapp.net" && host !== "c.us") return null;
222
+ const digits = jid.slice(0, at).split(":")[0];
223
+ return E164_DIGITS.test(digits) ? `https://wa.me/${digits}` : null;
224
+ }
225
+
206
226
  // EXTERNAL MODULE: ./lib/utils/error.ts
207
227
  var error = __webpack_require__(22032);
208
228
  ;// ./lib/bridges/whatsapp.ts
@@ -235,6 +255,7 @@ var error = __webpack_require__(22032);
235
255
 
236
256
 
237
257
 
258
+
238
259
  class WhatsAppBridgeAdapter {
239
260
  static{
240
261
  this.SENT_IDS_MAX = 500;
@@ -458,10 +479,10 @@ class WhatsAppBridgeAdapter {
458
479
  // adapter should re-deliver to agents) and the legacy
459
480
  // `replace`/`update` events that arrive via messages.update.
460
481
  if (payload.type !== "notify" && payload.type !== "append") return;
461
- // On a fresh adapter boot the watermark is whatever the last run
462
- // persisted. Read it once per batch (cheap SQLite call) so we can
463
- // hard-reject very old appends without doing any per-message work.
464
- const watermark = payload.type === "append" ? (0,bridges/* getMaxRouteLastSeenTs */.mp)(this.bridge_id) : 0;
482
+ // On a fresh adapter boot the watermarks are whatever the last run
483
+ // persisted. Read them once per batch (one cheap SQLite call) so old
484
+ // appends are rejected without per-message queries.
485
+ const watermarks = payload.type === "append" ? (0,bridges/* getRouteLastSeenTsMap */.gH)(this.bridge_id) : null;
465
486
  for (const raw of payload.messages ?? []){
466
487
  const m = raw;
467
488
  if (!m.key?.remoteJid) continue;
@@ -488,18 +509,20 @@ class WhatsAppBridgeAdapter {
488
509
  // "real" the moment we see any message from it, even one whose
489
510
  // body we end up unable to represent (e.g. reactions, polls).
490
511
  const ts = typeof m.messageTimestamp === "number" ? m.messageTimestamp * 1000 : (m.messageTimestamp?.low ?? 0) * 1000 || Date.now();
491
- // Watermark gate: on `append` batches, skip anything strictly
492
- // older than the highest per-route watermark we've persisted. This
493
- // prevents the server's reconnect replay from re-delivering
494
- // messages we already routed in a previous process lifetime.
495
- // `notify` events skip this check — they're live and may legitimately
496
- // arrive in any order relative to the cross-route max.
497
- if (payload.type === "append" && watermark > 0 && ts > 0 && ts <= watermark) {
512
+ // Watermark gate: on `append` batches, skip anything at or below
513
+ // this chat's own persisted watermark. This prevents the server's
514
+ // reconnect replay from re-delivering messages we already routed in
515
+ // a previous process lifetime. `notify` events skip this check —
516
+ // they're live and may legitimately arrive out of order.
517
+ const watermark = watermarks?.get(remote_jid) ?? 0;
518
+ if (watermark > 0 && ts > 0 && ts <= watermark) {
498
519
  continue;
499
520
  }
500
- // In groups, pushName is typically the participant's display name,
501
- // not the group subject. Avoid poisoning the group chat label.
502
- this.observeChat(remote_jid, is_group ? null : m.pushName ?? null, ts);
521
+ // pushName names the *sender*: in groups that's a participant, and on
522
+ // fromMe messages it's the user's own name. Only a counterpart's
523
+ // pushName in a 1:1 chat is a valid label for the chat itself.
524
+ const chatPushName = is_group || m.key.fromMe ? null : m.pushName ?? null;
525
+ this.observeChat(remote_jid, chatPushName, ts);
503
526
  // Unwrap protocol envelopes (view-once, ephemeral, etc.) so we can
504
527
  // see the underlying payload uniformly, then turn it into a text
505
528
  // body + ContentPart attachments the agent can consume.
@@ -517,7 +540,7 @@ class WhatsAppBridgeAdapter {
517
540
  // chats it's undefined — the sender == remote_jid. Normalize so the
518
541
  // dispatcher gets a routable user JID, not the legacy @c.us form.
519
542
  const participant_jid = is_group && m.key.participant ? normalizeUserJid(m.key.participant) : null;
520
- const chat_name = this.chats.get(remote_jid)?.name ?? m.pushName ?? null;
543
+ const chat_name = this.chats.get(remote_jid)?.name ?? chatPushName;
521
544
  const sender = resolveWhatsAppSender({
522
545
  fromMe: m.key.fromMe === true,
523
546
  isGroup: is_group,
@@ -575,7 +598,11 @@ class WhatsAppBridgeAdapter {
575
598
  const ct = raw;
576
599
  const chatJid = pickContactChatJid(ct);
577
600
  if (!chatJid) continue;
578
- const name = ct.name ?? ct.verifiedName ?? ct.notify ?? null;
601
+ const name = [
602
+ ct.name,
603
+ ct.verifiedName,
604
+ ct.notify
605
+ ].find((n)=>n?.trim()) ?? null;
579
606
  this.observeChat(chatJid, name, null);
580
607
  }
581
608
  });
@@ -600,7 +627,11 @@ class WhatsAppBridgeAdapter {
600
627
  for (const ct of list){
601
628
  const chatJid = pickContactChatJid(ct);
602
629
  if (!chatJid) continue;
603
- this.observeChat(chatJid, ct.name ?? ct.verifiedName ?? ct.notify ?? null, null);
630
+ this.observeChat(chatJid, [
631
+ ct.name,
632
+ ct.verifiedName,
633
+ ct.notify
634
+ ].find((n)=>n?.trim()) ?? null, null);
604
635
  }
605
636
  });
606
637
  // Group profile/settings updates (subject/description/permissions/etc.).
@@ -709,6 +740,9 @@ class WhatsAppBridgeAdapter {
709
740
  error: null
710
741
  });
711
742
  }
743
+ chatLink(remote_jid) {
744
+ return whatsappChatLink(remote_jid);
745
+ }
712
746
  async sendText(remote_jid, text) {
713
747
  // Hard guard: refuse to send to any chat whose route is in silent_mode.
714
748
  // The dispatcher already short-circuits before calling sendText, but
@@ -965,7 +999,10 @@ class WhatsAppBridgeAdapter {
965
999
  });
966
1000
  attachments.push(ref);
967
1001
  const sizeKb = Math.max(1, Math.round(buf.length / 1024));
968
- text = (text ? text + "\n" : "") + `[Attached ${label}: ${filename} (${mime}, ${sizeKb} KB); retained as a Jarela file reference.]`;
1002
+ // Sender-supplied document names can carry newlines or brackets;
1003
+ // describe the attachment by the store's sanitized name.
1004
+ const shownName = oneLine("filename" in ref && ref.filename || filename);
1005
+ text = (text ? text + "\n" : "") + `[Attached ${label}: ${shownName} (${mime}, ${sizeKb} KB); retained as a Jarela file reference.]`;
969
1006
  } catch (err) {
970
1007
  const m = (0,error/* errorMessage */.g)(err);
971
1008
  console.warn(`[bridge ${this.bridge_id}] failed to spill ${label} from ${remote_jid}: ${m}`);
@@ -1020,8 +1057,8 @@ class WhatsAppBridgeAdapter {
1020
1057
  `lat=${degreesLatitude ?? "?"}`,
1021
1058
  `lng=${degreesLongitude ?? "?"}`
1022
1059
  ];
1023
- if (name) parts.push(`name="${name}"`);
1024
- if (address) parts.push(`address="${address}"`);
1060
+ if (name) parts.push(`name=${JSON.stringify(oneLine(name))}`);
1061
+ if (address) parts.push(`address=${JSON.stringify(oneLine(address))}`);
1025
1062
  text = (text ? text + "\n" : "") + `[location: ${parts.join(" ")}]`;
1026
1063
  }
1027
1064
  if (inner.liveLocationMessage) {
@@ -1029,12 +1066,12 @@ class WhatsAppBridgeAdapter {
1029
1066
  text = (text ? text + "\n" : "") + `[live-location: lat=${degreesLatitude ?? "?"} lng=${degreesLongitude ?? "?"}]`;
1030
1067
  }
1031
1068
  if (inner.contactMessage) {
1032
- const name = inner.contactMessage.displayName ?? "unknown";
1033
- const vcard = inner.contactMessage.vcard ?? "";
1069
+ const name = oneLine(inner.contactMessage.displayName ?? "") || "unknown";
1070
+ const vcard = stripVcardBinary(inner.contactMessage.vcard ?? "");
1034
1071
  text = (text ? text + "\n" : "") + `[contact: ${name}]\n${vcard}`;
1035
1072
  }
1036
1073
  if (inner.contactsArrayMessage) {
1037
- const names = (inner.contactsArrayMessage.contacts ?? []).map((c)=>c?.displayName ?? "unknown").join(", ");
1074
+ const names = (inner.contactsArrayMessage.contacts ?? []).map((c)=>oneLine(c?.displayName ?? "") || "unknown").join(", ");
1038
1075
  text = (text ? text + "\n" : "") + `[contacts: ${names}]`;
1039
1076
  }
1040
1077
  return {
@@ -1046,8 +1083,9 @@ class WhatsAppBridgeAdapter {
1046
1083
  if (!remote_jid) return;
1047
1084
  const existing = this.chats.get(remote_jid);
1048
1085
  // Prefer the most recently-observed name (group subjects rename; users
1049
- // change push names). Don't overwrite a known name with null.
1050
- const nextName = name ?? existing?.name ?? null;
1086
+ // change push names). Don't overwrite a known name with a missing or
1087
+ // blank one.
1088
+ const nextName = name?.trim() || existing?.name || null;
1051
1089
  const nextTs = ts && (!existing?.last_message_at || ts > existing.last_message_at) ? ts : existing?.last_message_at ?? null;
1052
1090
  this.chats.set(remote_jid, {
1053
1091
  remote_jid,
@@ -1064,6 +1102,27 @@ class WhatsAppBridgeAdapter {
1064
1102
  return this.currentStatus;
1065
1103
  }
1066
1104
  }
1105
+ function oneLine(value) {
1106
+ return value.replace(/[\s\u0085\u2028\u2029]+/g, " ").trim();
1107
+ }
1108
+ /**
1109
+ * Phones embed contact photos and logos as base64 vCard properties, often
1110
+ * tens of KB of noise in the agent's context. Drop those properties,
1111
+ * including their folded continuation lines (RFC 6350 §3.2), and keep the
1112
+ * readable fields.
1113
+ */ function stripVcardBinary(vcard) {
1114
+ const out = [];
1115
+ let skipping = false;
1116
+ for (const line of vcard.split(/\r\n|\r|\n/)){
1117
+ if (/^[ \t]/.test(line)) {
1118
+ if (!skipping) out.push(line);
1119
+ continue;
1120
+ }
1121
+ skipping = /^(?:[\w-]+\.)?(?:PHOTO|LOGO|SOUND|KEY)[;:]/i.test(line);
1122
+ if (!skipping) out.push(line);
1123
+ }
1124
+ return out.join("\n").trim();
1125
+ }
1067
1126
  // Minimal pino-compatible silent logger. Baileys uses `logger.child()`
1068
1127
  // chaining internally, so we return ourselves for every child call.
1069
1128
  function makeSilentLogger() {
@@ -1177,6 +1236,9 @@ function sanitizeMediaType(raw, kind, fallback) {
1177
1236
  return primary;
1178
1237
  }
1179
1238
  function resolveWhatsAppSender(input) {
1239
+ // Platforms send blank display names ("" or whitespace) for contacts that
1240
+ // never set one; treat those as missing so the fallbacks still apply.
1241
+ const named = (...names)=>names.find((n)=>!!n && n.trim().length > 0)?.trim();
1180
1242
  if (input.fromMe) {
1181
1243
  return {
1182
1244
  senderJid: input.selfJid ?? "me",
@@ -1187,12 +1249,12 @@ function resolveWhatsAppSender(input) {
1187
1249
  const senderJid = input.participantJid ?? input.remoteJid;
1188
1250
  return {
1189
1251
  senderJid,
1190
- senderName: input.participantName ?? input.pushName ?? senderJid
1252
+ senderName: named(input.participantName, input.pushName) ?? senderJid
1191
1253
  };
1192
1254
  }
1193
1255
  return {
1194
1256
  senderJid: input.remoteJid,
1195
- senderName: input.pushName ?? input.chatName ?? input.remoteJid
1257
+ senderName: named(input.pushName, input.chatName) ?? input.remoteJid
1196
1258
  };
1197
1259
  }
1198
1260
  /**
@@ -1319,8 +1381,8 @@ function listBridgeModules() {
1319
1381
  /* harmony export */ X9: () => (/* binding */ listBridges),
1320
1382
  /* harmony export */ aM: () => (/* binding */ getRoute),
1321
1383
  /* harmony export */ e1: () => (/* binding */ getBridge),
1384
+ /* harmony export */ gH: () => (/* binding */ getRouteLastSeenTsMap),
1322
1385
  /* harmony export */ kZ: () => (/* binding */ listIgnores),
1323
- /* harmony export */ mp: () => (/* binding */ getMaxRouteLastSeenTs),
1324
1386
  /* harmony export */ nE: () => (/* binding */ removeIgnore),
1325
1387
  /* harmony export */ pi: () => (/* binding */ isIgnored),
1326
1388
  /* harmony export */ po: () => (/* binding */ updateBridge),
@@ -1453,12 +1515,16 @@ function bumpRouteLastSeenTs(bridgeId, remoteJid, ts) {
1453
1515
  if (!Number.isFinite(ts) || ts <= 0) return;
1454
1516
  (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("UPDATE bridge_routes SET last_seen_ts=? WHERE bridge_id=? AND remote_jid=? AND (last_seen_ts IS NULL OR last_seen_ts < ?)").run(ts, bridgeId, remoteJid, ts);
1455
1517
  }
1456
- // Snapshot the highest watermark across every route on a bridge. The
1457
- // adapter uses this on reconnect to short-circuit very-old appends before
1458
- // it has loaded individual route rows.
1459
- function getMaxRouteLastSeenTs(bridgeId) {
1460
- const row = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT MAX(last_seen_ts) AS m FROM bridge_routes WHERE bridge_id=?").get(bridgeId);
1461
- return row?.m ?? 0;
1518
+ // Per-chat watermarks for every explicitly routed chat on a bridge, loaded
1519
+ // once per upsert batch. Each chat is gated only by its own progress: a
1520
+ // bridge-wide maximum would drop chat B's offline backlog as soon as a newer
1521
+ // message from chat A had been delivered.
1522
+ function getRouteLastSeenTsMap(bridgeId) {
1523
+ const rows = (0,_lib_db__WEBPACK_IMPORTED_MODULE_1__/* .getDb */ .Lf)().prepare("SELECT remote_jid, last_seen_ts FROM bridge_routes WHERE bridge_id=? AND last_seen_ts IS NOT NULL").all(bridgeId);
1524
+ return new Map(rows.map((r)=>[
1525
+ r.remote_jid,
1526
+ r.last_seen_ts
1527
+ ]));
1462
1528
  }
1463
1529
  // ---------------------------------------------------------------------------
1464
1530
  // Ignore-list CRUD (per-bridge chat blocklist)
@@ -1504,4 +1570,4 @@ function removeIgnore(bridgeId, remoteJid) {
1504
1570
 
1505
1571
  };
1506
1572
  ;
1507
- //# sourceMappingURL=4540.js.map
1573
+ //# sourceMappingURL=309.js.map