@lobu/runtime-server 22.0.0 → 24.0.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 (303) hide show
  1. package/dist/catalogs/connectors.json +1448 -212
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +15 -2
  5. package/dist/connectors/google_gmail.ts +1 -0
  6. package/dist/connectors/jira-helpers.ts +313 -0
  7. package/dist/connectors/jira.ts +29 -221
  8. package/dist/connectors/linkedin-browser-script.ts +13 -0
  9. package/dist/connectors/linkedin-draft-page.js +104 -0
  10. package/dist/connectors/linkedin-drafts.ts +73 -0
  11. package/dist/connectors/linkedin-identity.ts +32 -0
  12. package/dist/connectors/linkedin-inbox-adapter.js +1182 -0
  13. package/dist/connectors/linkedin-inbox.ts +156 -0
  14. package/dist/connectors/linkedin-like.ts +114 -0
  15. package/dist/connectors/linkedin-takeout.ts +577 -0
  16. package/dist/connectors/linkedin.ts +4017 -0
  17. package/dist/connectors/reddit.ts +92 -20
  18. package/dist/connectors/slack.ts +1 -0
  19. package/dist/connectors/takeout-utils.ts +240 -0
  20. package/dist/connectors/tiktok-inbox-page.js +9 -9
  21. package/dist/connectors/tiktok-web-page.js +21 -15
  22. package/dist/connectors/tiktok_web.ts +63 -30
  23. package/dist/connectors/whatsapp-web-adapter.js +104 -574
  24. package/dist/connectors/whatsapp-web-helpers.ts +30 -444
  25. package/dist/connectors/whatsapp-web-identity.ts +20 -6
  26. package/dist/connectors/whatsapp_web.ts +46 -646
  27. package/dist/connectors/x-dm-adapter.js +556 -0
  28. package/dist/connectors/x-identity.ts +33 -2
  29. package/dist/connectors/x.ts +266 -120
  30. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  31. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  32. package/dist/db/migrations/20261019120000_retire_identities_of_deleted_entities.sql +21 -0
  33. package/dist/db/migrations/20261020120000_entities_live_metadata_domain.sql +66 -0
  34. package/dist/db/migrations/20261020130000_agents_starters.sql +14 -0
  35. package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +71 -0
  36. package/dist/dependencies.bun.lock +78 -75
  37. package/dist/guest.bundle.js +650 -448
  38. package/dist/owletto/dist/assets/_-CC8cTmRg.js +3 -0
  39. package/dist/owletto/dist/assets/_-ksFp4zVf.js +2 -0
  40. package/dist/owletto/dist/assets/_agentId-DWUFSrVp.js +2 -0
  41. package/dist/owletto/dist/assets/_agentId-MENLoohA.js +2 -0
  42. package/dist/owletto/dist/assets/_automationId-BnHqdXOC.js +2 -0
  43. package/dist/owletto/dist/assets/_connectorKey._connectionId-CefXIqy2.js +2 -0
  44. package/dist/owletto/dist/assets/_connectorKey.index-C1QPGf9E.js +2 -0
  45. package/dist/owletto/dist/assets/_conversationId-DinuPCUp.js +2 -0
  46. package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BeyzVjRm.js} +2 -2
  47. package/dist/owletto/dist/assets/_eventId-3L_qeL_l.js +2 -0
  48. package/dist/owletto/dist/assets/_name-Dgedji78.js +2 -0
  49. package/dist/owletto/dist/assets/_owner-DbrKma4e.js +3 -0
  50. package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +2 -0
  51. package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +2 -0
  52. package/dist/owletto/dist/assets/_slug-ndDr_CUg.js +2 -0
  53. package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +2 -0
  54. package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +2 -0
  55. package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-CRKbM2Xy.js} +2 -2
  56. package/dist/owletto/dist/assets/activity-route-view-CFLNukhD.js +2 -0
  57. package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-Be1Okb2C.js} +2 -2
  58. package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-BA8dU_C6.js} +2 -2
  59. package/dist/owletto/dist/assets/agent-connect-pages-CAV-yXus.js +2 -0
  60. package/dist/owletto/dist/assets/agent-editor-form-Bi6WvYX-.js +2 -0
  61. package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-DMOjG1D4.js} +2 -2
  62. package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-De_2d8Lr.js} +2 -2
  63. package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-gZWl6mAe.js} +2 -2
  64. package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-JLaTamGR.js} +2 -2
  65. package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-DcK41PWj.js} +2 -2
  66. package/dist/owletto/dist/assets/agent-subpage-shell-BBJoyTuC.js +2 -0
  67. package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +6 -0
  68. package/dist/owletto/dist/assets/agents-C-ReckCa.js +2 -0
  69. package/dist/owletto/dist/assets/agents-workbench-CqaKGggb.js +2 -0
  70. package/dist/owletto/dist/assets/app._appId-Cl1fTuIt.js +2 -0
  71. package/dist/owletto/dist/assets/automation-detail-content-BMLL4lxO.js +2 -0
  72. package/dist/owletto/dist/assets/automations-C-ReckCa.js +2 -0
  73. package/dist/owletto/dist/assets/callback-DTKKsfkz.js +2 -0
  74. package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-yU0TmNRH.js} +2 -2
  75. package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-DJfTvlT2.js} +2 -2
  76. package/dist/owletto/dist/assets/client-rows--FrZfJol.js +2 -0
  77. package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-L4K1UT8c.js} +2 -2
  78. package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-U54Gwjit.js} +2 -2
  79. package/dist/owletto/dist/assets/connect-4zqtnDHb.js +2 -0
  80. package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +2 -0
  81. package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +2 -0
  82. package/dist/owletto/dist/assets/connected._clientId.activity-DTpSW1Xy.js +2 -0
  83. package/dist/owletto/dist/assets/connected._clientId.index-h9X5H1x8.js +2 -0
  84. package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-ByvKkyFm.js} +2 -2
  85. package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-DWM9lTao.js} +2 -2
  86. package/dist/owletto/dist/assets/connections-browser-CEwYrYqt.js +2 -0
  87. package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-BocTm__v.js} +2 -2
  88. package/dist/owletto/dist/assets/connector-scope-lists-OYDOydtz.js +2 -0
  89. package/dist/owletto/dist/assets/connectors-CyZpcE5f.js +2 -0
  90. package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-DdfINrVp.js} +2 -2
  91. package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BSznfdYt.js} +2 -2
  92. package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-Dr7tcIB-.js} +2 -2
  93. package/dist/owletto/dist/assets/create-CBGwASon.js +2 -0
  94. package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +2 -0
  95. package/dist/owletto/dist/assets/create-CwThQtd3.js +2 -0
  96. package/dist/owletto/dist/assets/create-automation-form-9T5WnoUs.js +3 -0
  97. package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +2 -0
  98. package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-BWFEyy_P.js} +2 -2
  99. package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +2 -0
  100. package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-2xKS8gRo.js} +2 -2
  101. package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-wG_8QzOF.js} +2 -2
  102. package/dist/owletto/dist/assets/{device-CntqYW65.js → device-6z-xgsoW.js} +2 -2
  103. package/dist/owletto/dist/assets/device-pin-tombstone-Cwq88RMU.js +2 -0
  104. package/dist/owletto/dist/assets/device._deviceId-BDerBfD9.js +2 -0
  105. package/dist/owletto/dist/assets/entity-avatar-Cc1CuI-0.js +2 -0
  106. package/dist/owletto/dist/assets/entity-options-DHdMC1Lx.js +2 -0
  107. package/dist/owletto/dist/assets/entity-page--OkXmlNP.js +2 -0
  108. package/dist/owletto/dist/assets/entity-type-page-89RoK_-P.js +2 -0
  109. package/dist/owletto/dist/assets/event-detail-D4YZRtrA.js +2 -0
  110. package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +2 -0
  111. package/dist/owletto/dist/assets/filter-editors-B1_QUpg_.js +2 -0
  112. package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-Cqih-8IW.js} +2 -2
  113. package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +2 -0
  114. package/dist/owletto/dist/assets/identity-B0nH4yiC.js +2 -0
  115. package/dist/owletto/dist/assets/index-4TSkcsth.js +2 -0
  116. package/dist/owletto/dist/assets/index-BSH07yVD.css +1 -0
  117. package/dist/owletto/dist/assets/index-BgkhXElB.js +2 -0
  118. package/dist/owletto/dist/assets/index-CoW4Bz3w.js +2 -0
  119. package/dist/owletto/dist/assets/index-Codw-Qqi.js +2 -0
  120. package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-DAOyXG1X.js} +2 -2
  121. package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-DKPwCasf.js} +2 -2
  122. package/dist/owletto/dist/assets/index-DMyXd3bJ.js +2 -0
  123. package/dist/owletto/dist/assets/index-DYCqXaMf.js +7950 -0
  124. package/dist/owletto/dist/assets/index-DYYZLcJ0.js +2 -0
  125. package/dist/owletto/dist/assets/index-DYzWV5_z.js +2 -0
  126. package/dist/owletto/dist/assets/index-Da6CrGEu.js +2 -0
  127. package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-DfyDUpuI.js} +2 -2
  128. package/dist/owletto/dist/assets/index-DneshLbf.js +2 -0
  129. package/dist/owletto/dist/assets/index-TgRS2v_F.js +2 -0
  130. package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ZNlrDc_f.js} +2 -2
  131. package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DFvYINBT.js} +3 -3
  132. package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-DFsEqLU1.js} +2 -2
  133. package/dist/owletto/dist/assets/login-DO0j-AYr.js +2 -0
  134. package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-BmNwoAf7.js} +2 -2
  135. package/dist/owletto/dist/assets/member-scope-gate-B2LrMWBU.js +2 -0
  136. package/dist/owletto/dist/assets/memory-browse-page-Cjpl8EbB.js +103 -0
  137. package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-TQcA93xm.js} +2 -2
  138. package/dist/owletto/dist/assets/models-D7aED5Sa.js +2 -0
  139. package/dist/owletto/dist/assets/new-BMrFy5Qa.js +2 -0
  140. package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-ByBhteWA.js} +2 -2
  141. package/dist/owletto/dist/assets/new-DWp3deoW.js +2 -0
  142. package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-D_5uESuz.js} +2 -2
  143. package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-DTFoYP4V.js} +2 -2
  144. package/dist/owletto/dist/assets/peek-pane-content-DF5iGC3c.js +2 -0
  145. package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-C_auqxfP.js} +2 -2
  146. package/dist/owletto/dist/assets/proposal-review-shell-DsNiavG_.js +2 -0
  147. package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +2 -0
  148. package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-3d99S2IE.js} +2 -2
  149. package/dist/owletto/dist/assets/record-activity-C9KfBkXb.js +2 -0
  150. package/dist/owletto/dist/assets/record-field-peek-BBZcRuGT.js +2 -0
  151. package/dist/owletto/dist/assets/record-session-BizRugWs.js +2 -0
  152. package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-DqfcSn8M.js} +2 -2
  153. package/dist/owletto/dist/assets/runs-panel-T1ZxTVz6.js +2 -0
  154. package/dist/owletto/dist/assets/runs-table-D_8QlCCN.js +2 -0
  155. package/dist/owletto/dist/assets/schema-value-normalization-CylKX3PK.js +97 -0
  156. package/dist/owletto/dist/assets/settings-B_ClYztB.js +2 -0
  157. package/dist/owletto/dist/assets/settings-DgX1-xo7.js +2 -0
  158. package/dist/owletto/dist/assets/skills-Drw5tcZw.js +2 -0
  159. package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-Cg249m1S.js} +2 -2
  160. package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-BYbFvHbJ.js} +2 -2
  161. package/dist/owletto/dist/assets/view-param-filters-DMSqkN2J.js +2 -0
  162. package/dist/owletto/dist/index.html +2 -2
  163. package/dist/server-main.bundle.mjs +14031 -12680
  164. package/npm-shrinkwrap.json +329 -313
  165. package/package.json +6 -5
  166. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  167. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  168. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  169. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  170. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  171. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  172. package/vendor/connector-sdk/dist/index.js +2 -0
  173. package/vendor/connector-sdk/package.json +9 -1
  174. package/vendor/core/dist/agent-policy.js +0 -3
  175. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  176. package/vendor/core/dist/agent-tooling.js +3 -1
  177. package/vendor/core/dist/capabilities.d.ts +1 -1
  178. package/vendor/core/dist/capabilities.js +0 -1
  179. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  180. package/vendor/core/dist/connector-query-errors.js +41 -1
  181. package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
  182. package/vendor/core/dist/contracts/agent-settings.js +12 -1
  183. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  184. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  185. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  186. package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
  187. package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
  188. package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
  189. package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
  190. package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
  191. package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
  192. package/vendor/core/dist/contracts/worker/protocol.d.ts +47 -133
  193. package/vendor/core/dist/contracts/worker/protocol.js +33 -62
  194. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  195. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  196. package/vendor/core/dist/index.d.ts +3 -2
  197. package/vendor/core/dist/index.js +3 -1
  198. package/vendor/core/dist/logger.js +10 -25
  199. package/vendor/core/dist/suggestions.d.ts +15 -2
  200. package/vendor/core/dist/suggestions.js +48 -3
  201. package/vendor/core/dist/types.d.ts +26 -0
  202. package/vendor/core/dist/types.js +5 -0
  203. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  204. package/vendor/core/dist/worker/wire.d.ts +0 -10
  205. package/vendor/core/package.json +16 -10
  206. package/vendor/postgres/cf/src/connection.js +18 -0
  207. package/vendor/postgres/cjs/src/connection.js +18 -0
  208. package/vendor/postgres/src/connection.js +18 -0
  209. package/vendor/views/dist/api.d.ts +71 -17
  210. package/vendor/views/dist/api.js +200 -35
  211. package/vendor/views/dist/bridge.d.ts +3 -0
  212. package/vendor/views/dist/bridge.js +9 -1
  213. package/vendor/views/dist/components.d.ts +170 -0
  214. package/vendor/views/dist/components.js +361 -0
  215. package/vendor/views/dist/index.d.ts +1 -1
  216. package/vendor/views/package.json +11 -1
  217. package/dist/owletto/dist/assets/_-CEPl6gU4.js +0 -3
  218. package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
  219. package/dist/owletto/dist/assets/_agentId-CBC_SadO.js +0 -2
  220. package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
  221. package/dist/owletto/dist/assets/_automationId-YTTNksw6.js +0 -2
  222. package/dist/owletto/dist/assets/_connectorKey._connectionId-fK0h7RAp.js +0 -2
  223. package/dist/owletto/dist/assets/_connectorKey.index-C7TPS598.js +0 -2
  224. package/dist/owletto/dist/assets/_conversationId-CEhxlTIo.js +0 -2
  225. package/dist/owletto/dist/assets/_eventId-Cl8GSdjg.js +0 -2
  226. package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
  227. package/dist/owletto/dist/assets/_owner-cUtGHqSw.js +0 -3
  228. package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
  229. package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
  230. package/dist/owletto/dist/assets/_slug-CU1PuHB9.js +0 -2
  231. package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
  232. package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
  233. package/dist/owletto/dist/assets/activity-route-view-DQglkhXU.js +0 -2
  234. package/dist/owletto/dist/assets/agent-connect-pages-B6uKvT_X.js +0 -2
  235. package/dist/owletto/dist/assets/agent-editor-form-oUnIYHd7.js +0 -2
  236. package/dist/owletto/dist/assets/agent-subpage-shell-B3K_jPYR.js +0 -2
  237. package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
  238. package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
  239. package/dist/owletto/dist/assets/agents-workbench-CMyk4PI7.js +0 -2
  240. package/dist/owletto/dist/assets/app._appId-DH1Qutz6.js +0 -2
  241. package/dist/owletto/dist/assets/automation-detail-content-CEDNboId.js +0 -2
  242. package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
  243. package/dist/owletto/dist/assets/callback-CU-hb8JB.js +0 -2
  244. package/dist/owletto/dist/assets/client-rows-EJSKR6z1.js +0 -2
  245. package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
  246. package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
  247. package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
  248. package/dist/owletto/dist/assets/connected._clientId.activity-DQWcUqKM.js +0 -2
  249. package/dist/owletto/dist/assets/connected._clientId.index-BC3R303A.js +0 -2
  250. package/dist/owletto/dist/assets/connections-browser-Cnv2iBbZ.js +0 -2
  251. package/dist/owletto/dist/assets/connector-scope-lists-BKDetNDc.js +0 -2
  252. package/dist/owletto/dist/assets/connectors-BJnk1z_2.js +0 -2
  253. package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
  254. package/dist/owletto/dist/assets/create-JRFM8mMf.js +0 -2
  255. package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
  256. package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
  257. package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
  258. package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
  259. package/dist/owletto/dist/assets/device-pin-tombstone-Bz4JHHMK.js +0 -2
  260. package/dist/owletto/dist/assets/device._deviceId-D4plO3GM.js +0 -2
  261. package/dist/owletto/dist/assets/entity-options-UJs64GdQ.js +0 -2
  262. package/dist/owletto/dist/assets/entity-page-Djz6T50J.js +0 -2
  263. package/dist/owletto/dist/assets/entity-type-page-OznRag6A.js +0 -2
  264. package/dist/owletto/dist/assets/event-detail-04qOUGIP.js +0 -2
  265. package/dist/owletto/dist/assets/events-feed-fucGZSJR.js +0 -2
  266. package/dist/owletto/dist/assets/filter-editors-DCQgGLyR.js +0 -2
  267. package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
  268. package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
  269. package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
  270. package/dist/owletto/dist/assets/index-BLEcy9-T.css +0 -1
  271. package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
  272. package/dist/owletto/dist/assets/index-BOzuAbvi.js +0 -2
  273. package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
  274. package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
  275. package/dist/owletto/dist/assets/index-D3s8rhG9.js +0 -2
  276. package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
  277. package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
  278. package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
  279. package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
  280. package/dist/owletto/dist/assets/index-_oPeVpL_.js +0 -7950
  281. package/dist/owletto/dist/assets/login-QHdxqX-4.js +0 -2
  282. package/dist/owletto/dist/assets/member-scope-gate-CFbrq1by.js +0 -2
  283. package/dist/owletto/dist/assets/memory-browse-page-IrIXuZTF.js +0 -103
  284. package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
  285. package/dist/owletto/dist/assets/new-BWo8_Pms.js +0 -2
  286. package/dist/owletto/dist/assets/new-DpmDXmFI.js +0 -2
  287. package/dist/owletto/dist/assets/peek-pane-content-B2AFNTzP.js +0 -2
  288. package/dist/owletto/dist/assets/proposal-review-shell-DKKGu4Ww.js +0 -2
  289. package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
  290. package/dist/owletto/dist/assets/record-activity-CvgZyCmw.js +0 -2
  291. package/dist/owletto/dist/assets/renderer-BL6VcwQH.js +0 -97
  292. package/dist/owletto/dist/assets/runs-BWtc5rmc.js +0 -2
  293. package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
  294. package/dist/owletto/dist/assets/runs-table-DxIiqrSk.js +0 -2
  295. package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
  296. package/dist/owletto/dist/assets/settings-Crxlwps-.js +0 -2
  297. package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
  298. package/dist/owletto/dist/assets/status-dot-C5KDvvm9.js +0 -2
  299. package/dist/owletto/dist/assets/tabs-B4Er9hJj.js +0 -2
  300. package/dist/owletto/dist/assets/view-param-filters-Cylutoy1.js +0 -2
  301. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  302. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  303. /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Ported from the Owletto extension's whatsapp-web-main-v1.js. WhatsApp's
5
5
  * normalization and action code retain the extension implementation; the
6
- * connector-owned feed listener below now observes changes and emits records
7
- * through the generic browser transport. Do not "clean it up" casually: it
8
- * reaches into WhatsApp's own module registry via window.require and its shape
9
- * is load-bearing.
6
+ * connector-owned feed listener below observes new messages and emits
7
+ * references only (never content) through the generic browser transport. It
8
+ * reaches into WhatsApp's own module registry via window.require; those private
9
+ * module shapes are load-bearing.
10
10
  *
11
11
  * How it gets into the page: the connector serialises this function with
12
12
  * Function.prototype.toString() and runs `(<source>)()` through the generic
@@ -33,8 +33,11 @@ export function whatsAppWebAdapterProgram() {
33
33
  // when this number moves: shipping a fix under the old number leaves every
34
34
  // already-open tab running the previous code with nothing to show for it.
35
35
  // Keep in lockstep with WHATSAPP_ADAPTER_VERSION in whatsapp-web-helpers.ts.
36
- const ADAPTER_VERSION = 22;
36
+ const ADAPTER_VERSION = 26;
37
37
  const SOURCE_ERROR_ID = "whatsapp-web:source-observation-error";
38
+ // Storage rows one `chat:` read examines; a whole personal history is
39
+ // usually under this, so one read answers.
40
+ const CHAT_SCAN_ROWS = 20_000;
38
41
  const MAX_RECORD_BYTES = 128 * 1024;
39
42
  const MAX_BUFFER_BYTES = 16 * 1024 * 1024;
40
43
  const MAX_BUFFER_ENTRIES = 10_000;
@@ -91,8 +94,7 @@ export function whatsAppWebAdapterProgram() {
91
94
  });
92
95
  };
93
96
  const resident = listeners.get(request.bridge_id);
94
- const previous = resident?.request.references_only === request.references_only
95
- && resident?.request.chat_filter === request.chat_filter
97
+ const previous = resident?.request.chat_filter === request.chat_filter
96
98
  && resident?.request.minimum_timestamp === request.minimum_timestamp ? resident : null;
97
99
  detach(request.bridge_id);
98
100
  // A new listener identity fences pending normalization from the detached
@@ -109,19 +111,17 @@ export function whatsAppWebAdapterProgram() {
109
111
  state.token = request.token;
110
112
  state.request = request;
111
113
  state.post = (entry) => post(state, entry);
112
- const observe = (model, kind) => {
114
+ const observe = (model) => {
113
115
  if (state.error) return;
114
116
  const sequence = ++state.sequence;
115
- const normalized = request.references_only ? Promise.resolve(messageReference(model)) : normalizeMessage(model, "reconcile");
116
- void normalized.then((record) => {
117
+ // A throwing model getter must reach the error record below, not escape
118
+ // the collection handler, so the reference is read inside the promise.
119
+ void new Promise((resolve) => resolve(messageReference(model))).then((record) => {
117
120
  if (listeners.get(state.id) !== state || !record || record.timestamp <= 0) return;
118
121
  if (state.request.chat_filter === "group" && !record.is_group) return;
119
122
  if (state.request.chat_filter === "individual" && record.is_group) return;
120
123
  if (state.request.minimum_timestamp != null && record.timestamp < state.request.minimum_timestamp) return;
121
- // Loading historical models also emits add. Changes to old messages
122
- // still pass; they are exactly what the recent collection window misses.
123
- if (kind === "add" && record.timestamp < state.request.recent_since) return;
124
- if (request.references_only) record = {
124
+ record = {
125
125
  id: record.id,
126
126
  events: [{ id: record.id, event_type: "message.created", resource_ref: record.id,
127
127
  resource_type: "message", occurred_at: new Date(record.timestamp * 1000).toISOString() }],
@@ -154,8 +154,8 @@ export function whatsAppWebAdapterProgram() {
154
154
  reportError(state, "WhatsApp source observation failed; recovery is required", sequence);
155
155
  });
156
156
  };
157
- state.onAdd = (model) => observe(model, "add");
158
- state.onChange = (model) => observe(model, "change");
157
+ state.onAdd = (model) => observe(model);
158
+ state.onChange = (model) => observe(model);
159
159
  state.onReply = (event) => {
160
160
  if (event.source !== window || event.origin !== location.origin || event.data?.token !== state.token) return;
161
161
  if (event.data.type === "lobu-feed-record:stop") { detach(state.id); return; }
@@ -191,7 +191,7 @@ export function whatsAppWebAdapterProgram() {
191
191
  // not server delivery: the server advances the cursor only with its own commit.
192
192
  async function publishChanges(request) {
193
193
  const state = listeners.get(request.bridge_id);
194
- if (!state?.request.references_only || state.token !== request.token) throw new Error("Source listener is unavailable");
194
+ if (!state || state.token !== request.token) throw new Error("Source listener is unavailable");
195
195
  const record = request.batch;
196
196
  const bytes = new TextEncoder().encode(JSON.stringify(record)).length;
197
197
  const previous = state.pending.get(record.id);
@@ -266,6 +266,50 @@ export function whatsAppWebAdapterProgram() {
266
266
  return null;
267
267
  }
268
268
 
269
+ /**
270
+ * Every canonical form of the account's own identity. `meUser()` prefers
271
+ * the phone-number WID, but a group can address a member by its LID WID
272
+ * instead, so a mention or a quote of the account must match either form.
273
+ */
274
+ async function ownJids() {
275
+ const module = requireFirst(["WAWebUserPrefsMeUser"]);
276
+ const candidates = [meUser()];
277
+ for (const accessor of ["getMaybeMePnUser", "getMaybeMeLidUser"]) {
278
+ try {
279
+ candidates.push(module?.[accessor]?.());
280
+ } catch {
281
+ /* WhatsApp's private module graph throws freely; a miss is not fatal. */
282
+ }
283
+ }
284
+ const forms = new Set();
285
+ for (const value of candidates) {
286
+ const own = await canonicalJid(value);
287
+ if (own.jid) forms.add(own.jid);
288
+ if (own.lid) forms.add(own.lid);
289
+ }
290
+ return forms;
291
+ }
292
+
293
+ /**
294
+ * Whether a message addresses the account: it @mentions the account, or it
295
+ * replies to (quotes) one of the account's messages.
296
+ */
297
+ async function mentionsOwnAccount(row) {
298
+ const addressed = [
299
+ ...(Array.isArray(row.mentionedJidList) ? row.mentionedJidList : []),
300
+ row.quotedParticipant,
301
+ ].filter(Boolean);
302
+ if (addressed.length === 0) return false;
303
+ const own = await ownJids();
304
+ for (const value of addressed) {
305
+ const candidate = await canonicalJid(value);
306
+ if (own.has(candidate.jid) || (candidate.lid && own.has(candidate.lid))) {
307
+ return true;
308
+ }
309
+ }
310
+ return false;
311
+ }
312
+
269
313
  /**
270
314
  * Module names for each write op, most-current first.
271
315
  *
@@ -484,20 +528,8 @@ export function whatsAppWebAdapterProgram() {
484
528
  }
485
529
 
486
530
  /**
487
- * Name lookups for one collect.
488
- *
489
- * `normalizeMessage` runs per message and used to walk a whole collection on
490
- * each call -- the chat name over 947 chats, the sender name over 5323
491
- * contacts. That is O(messages x collection) of SYNCHRONOUS work: measured on
492
- * a live prod tab the contact scan alone projects to ~6.8s, a real collect
493
- * never yielded the main thread, and the extension's 90s run fence killed the
494
- * run. Every run was slower than the last as backfill grew the store.
495
- *
496
- * Built once per collect and thrown away with it -- no cache to invalidate,
497
- * and nothing here outlives the call. Only names are indexed: they read
498
- * static fields, whereas `collectionByRawId` serves the reaction paths, which
499
- * mutate a model in place without changing the collection, so that one keeps
500
- * scanning.
531
+ * Build name lookups once per read or search so normalizing each message
532
+ * does not rescan every chat and contact. Nothing here outlives the call.
501
533
  */
502
534
  function nameIndex(collections) {
503
535
  const byId = (collection) => {
@@ -545,8 +577,7 @@ export function whatsAppWebAdapterProgram() {
545
577
  const collections =
546
578
  collectionsOverride ?? requireFirst(["WAWebCollections"]);
547
579
  if (!collections) return null;
548
- // A single normalise (the watch path) builds its own; a collect passes one
549
- // in so the whole run shares it.
580
+ // Reads and searches share one name index across their result batch.
550
581
  const nameLookup = names ?? nameIndex(collections);
551
582
  let row = modelData(model);
552
583
  let key = row.id ?? model?.id;
@@ -623,6 +654,7 @@ export function whatsAppWebAdapterProgram() {
623
654
  : null,
624
655
  media_filename: row.filename ?? row.fileName ?? row.title ?? null,
625
656
  quoted_id: quotedId,
657
+ mentions_me: await mentionsOwnAccount(row),
626
658
  is_forwarded: Boolean(row.isForwarded || Number(row.forwardingScore) > 0),
627
659
  is_starred: Boolean(row.star ?? row.isStarred),
628
660
  is_system_event: SYSTEM_TYPES.has(type),
@@ -671,7 +703,7 @@ export function whatsAppWebAdapterProgram() {
671
703
  // Socket.stream was DISCONNECTED, then both were CONNECTED after reload.
672
704
  // Current WhatsApp exposes account and transport state separately. An
673
705
  // authenticated account can retain hydrated stores while its stream is
674
- // disconnected; those cached messages are not a successful live sync.
706
+ // disconnected; those cached messages are not a successful live read.
675
707
  const socket = requireFirst(["WAWebSocketModel"])?.Socket;
676
708
  const connection =
677
709
  socket ??
@@ -776,7 +808,6 @@ export function whatsAppWebAdapterProgram() {
776
808
  }
777
809
 
778
810
  function operationCapabilities() {
779
- const history = requireFirst(["WAWebChatLoadMessages"]);
780
811
  const search = requireFirst([
781
812
  "WAWebChatMessageSearch",
782
813
  "WAWebMessageSearch",
@@ -787,23 +818,13 @@ export function whatsAppWebAdapterProgram() {
787
818
  const edit = requireFirst(EDIT_MODULES);
788
819
  const reaction = requireFirst(REACTION_MODULES);
789
820
  const revoke = requireFirst(REVOKE_MODULES);
790
- // Same nesting as the download path: the module root only exports
791
- // `{ enforceKaleidoscopeScore, downloadManager }`.
792
- const mediaModule = requireFirst(["WAWebDownloadManager"]);
793
- const media = mediaModule?.downloadManager ?? mediaModule;
794
821
  const hasFunction = (module, names) =>
795
822
  names.some((name) => typeof module?.[name] === "function");
796
823
  return {
797
- collect: hasFunction(history, ["loadEarlierMsgs"]),
798
824
  read_messages:
799
825
  typeof indexedDB !== "undefined" &&
800
826
  typeof requireFirst(["WAWebMsgKey"])?.fromString === "function" &&
801
827
  typeof requireFirst(["WAWebCollections"])?.Msg?.getMessagesById === "function",
802
- download_media:
803
- hasFunction(media, ["downloadAndMaybeDecrypt"]) ||
804
- models(requireFirst(["WAWebCollections"])?.Msg).some(
805
- (model) => typeof model?.downloadMedia === "function"
806
- ),
807
828
  search_messages:
808
829
  hasFunction(search, ["searchMessages", "searchMsgs", "search"]) ||
809
830
  Boolean(requireFirst(["WAWebCollections"])?.Msg),
@@ -829,130 +850,6 @@ export function whatsAppWebAdapterProgram() {
829
850
  };
830
851
  }
831
852
 
832
- function oldestMessage(chat) {
833
- let oldest = null;
834
- for (const message of models(modelData(chat).msgs ?? chat?.msgs)) {
835
- const row = modelData(message);
836
- const timestamp = unixSeconds(row);
837
- const id = rawId(row.id ?? message?.id);
838
- if (!id) continue;
839
- if (
840
- !oldest ||
841
- timestamp < oldest.timestamp ||
842
- (timestamp === oldest.timestamp && id < oldest.id)
843
- ) {
844
- oldest = { timestamp, id };
845
- }
846
- }
847
- return oldest;
848
- }
849
-
850
- function chatHasEarlier(chat) {
851
- const row = modelData(chat);
852
- const state =
853
- row.msgs?.msgLoadState ??
854
- chat?.msgs?.msgLoadState ??
855
- row.msgLoadState ??
856
- {};
857
- if (state.noEarlierMsgs === true || state.hasEarlierMsgs === false)
858
- return false;
859
- if (row.hasEarlierMsgs === false) return false;
860
- return true;
861
- }
862
-
863
- async function loadEarlier(chat, limit, deadline) {
864
- const loader = requireFirst(["WAWebChatLoadMessages"]);
865
- if (typeof loader?.loadEarlierMsgs !== "function") {
866
- return {
867
- available: false,
868
- reason: "WAWebChatLoadMessages.loadEarlierMsgs unavailable",
869
- loads: 0,
870
- };
871
- }
872
- let loads = 0;
873
- const beforeIds = new Set(
874
- models(modelData(chat).msgs ?? chat?.msgs)
875
- .map((message) => rawId(modelData(message).id ?? message?.id))
876
- .filter(Boolean)
877
- );
878
- let previous = oldestMessage(chat);
879
- let madeProgress = false;
880
- while (loads < limit && chatHasEarlier(chat)) {
881
- if (deadline && Date.now() >= deadline)
882
- throw new Error("history deadline budget exhausted");
883
- await loader.loadEarlierMsgs({ chat, msgCollection: chat.msgs });
884
- loads += 1;
885
- const next = oldestMessage(chat);
886
- if (
887
- !next ||
888
- (previous &&
889
- next.id === previous.id &&
890
- next.timestamp === previous.timestamp)
891
- )
892
- break;
893
- madeProgress = true;
894
- previous = next;
895
- }
896
- let hasMore = chatHasEarlier(chat);
897
- const loadedIds = () =>
898
- models(modelData(chat).msgs ?? chat?.msgs)
899
- .map((message) => rawId(modelData(message).id ?? message?.id))
900
- .filter((id) => id && !beforeIds.has(id));
901
- if (hasMore && !madeProgress) {
902
- return {
903
- available: true,
904
- loads,
905
- has_more: true,
906
- loaded_ids: loadedIds(),
907
- frontier_advanced: false,
908
- error: "WhatsApp history loader made no progress",
909
- };
910
- }
911
- if (hasMore) {
912
- const phone =
913
- loader.loadEarlierMsgsFromPhone ??
914
- loader.requestEarlierMsgsFromPhone ??
915
- loader.loadEarlierMsgsFromServer;
916
- const state =
917
- modelData(chat).msgs?.msgLoadState ?? chat?.msgs?.msgLoadState ?? {};
918
- const wantsPhone =
919
- state.canRequestFromPhone === true || state.hasMoreFromPhone === true;
920
- if (wantsPhone && typeof phone !== "function") {
921
- return {
922
- available: true,
923
- loads,
924
- has_more: true,
925
- loaded_ids: loadedIds(),
926
- frontier_advanced: false,
927
- error:
928
- "phone-assisted WhatsApp history is advertised but its loader is unavailable",
929
- };
930
- }
931
- if (typeof phone === "function" && wantsPhone) {
932
- try {
933
- await phone.call(loader, { chat, msgCollection: chat.msgs });
934
- hasMore = chatHasEarlier(chat);
935
- } catch (error) {
936
- return {
937
- available: true,
938
- loads,
939
- has_more: true,
940
- loaded_ids: loadedIds(),
941
- frontier_advanced: false,
942
- error: `phone-assisted history failed: ${String(error)}`,
943
- };
944
- }
945
- }
946
- }
947
- return {
948
- available: true,
949
- loads,
950
- has_more: hasMore,
951
- loaded_ids: loadedIds(),
952
- frontier_advanced: true,
953
- };
954
- }
955
-
956
853
  function uniqueMessageModels(collections) {
957
854
  const byId = new Map();
958
855
  for (const message of models(collections.Msg)) {
@@ -968,208 +865,6 @@ export function whatsAppWebAdapterProgram() {
968
865
  return [...byId.values()];
969
866
  }
970
867
 
971
- async function collect(request) {
972
- const status = readiness();
973
- if (!status.ready) return { ok: false, error: status };
974
- const collections = requireFirst(["WAWebCollections"]);
975
- const chatFilter = ["all", "individual", "group"].includes(
976
- request.chat_filter
977
- )
978
- ? request.chat_filter
979
- : "all";
980
- const chatRows = [];
981
- for (const chat of models(collections.Chat)) {
982
- const raw = widString(modelData(chat).id ?? chat?.id);
983
- const jid = (await canonicalJid(raw)).jid;
984
- if (
985
- !jid ||
986
- jid === "status@broadcast" ||
987
- jid.endsWith("@newsletter") ||
988
- (chatFilter === "group" && !jid.endsWith("@g.us")) ||
989
- (chatFilter === "individual" && jid.endsWith("@g.us"))
990
- )
991
- continue;
992
- chatRows.push({ chat, jid });
993
- }
994
- chatRows.sort((a, b) => a.jid.localeCompare(b.jid));
995
- const backfill = request.backfill ?? { complete: false, chats: {} };
996
- const updates = {};
997
- let cursor = backfill.cursor_chat_jid ?? null;
998
- const loadedByChat = new Map();
999
- const backfillMessageIds = new Set();
1000
- const eligible = request.backfill_disabled
1001
- ? []
1002
- : chatRows.filter(
1003
- (entry) => backfill.chats?.[entry.jid]?.has_more !== false
1004
- );
1005
- if (eligible.length > 0) {
1006
- let start = cursor
1007
- ? eligible.findIndex((entry) => entry.jid > cursor)
1008
- : 0;
1009
- if (start < 0) start = 0;
1010
- const rotated = [...eligible.slice(start), ...eligible.slice(0, start)];
1011
- const selected = rotated.slice(
1012
- 0,
1013
- Math.max(1, Number(request.max_chats) || 1)
1014
- );
1015
- // The connector sends a relative budget, not an absolute instant: it runs
1016
- // on a different machine than this page, so any shared epoch would be off
1017
- // by the clock skew between them. Resolving it here against this page's
1018
- // own clock keeps the budget exact.
1019
- const budgetMs = Number(request.budget_ms);
1020
- const historyDeadline =
1021
- Number.isFinite(budgetMs) && budgetMs > 0
1022
- ? Date.now() + budgetMs
1023
- : null;
1024
- for (const entry of selected) {
1025
- if (historyDeadline && Date.now() >= historyDeadline) break;
1026
- try {
1027
- const loaded = await loadEarlier(
1028
- entry.chat,
1029
- Math.max(1, Number(request.max_loads_per_chat) || 1),
1030
- historyDeadline
1031
- );
1032
- if (!loaded.available) {
1033
- return {
1034
- ok: false,
1035
- error: {
1036
- state: "capability_unavailable",
1037
- reason: loaded.reason,
1038
- },
1039
- };
1040
- }
1041
- const oldest = oldestMessage(entry.chat);
1042
- for (const id of loaded.loaded_ids) backfillMessageIds.add(id);
1043
- loadedByChat.set(entry.jid, loaded.loaded_ids);
1044
- if (loaded.frontier_advanced === false) {
1045
- updates[entry.jid] = {
1046
- ...(backfill.chats?.[entry.jid] ?? {}),
1047
- error: loaded.error,
1048
- has_more: true,
1049
- loads: loaded.loads,
1050
- };
1051
- continue;
1052
- }
1053
- updates[entry.jid] = {
1054
- oldest_timestamp: oldest?.timestamp ?? null,
1055
- oldest_id: oldest?.id ?? null,
1056
- has_more: loaded.has_more,
1057
- loads: loaded.loads,
1058
- };
1059
- cursor = entry.jid;
1060
- } catch (error) {
1061
- if (/unavailable/i.test(String(error))) {
1062
- return {
1063
- ok: false,
1064
- error: {
1065
- state: "capability_unavailable",
1066
- reason: String(error),
1067
- },
1068
- };
1069
- }
1070
- updates[entry.jid] = {
1071
- ...(backfill.chats?.[entry.jid] ?? {}),
1072
- error: String(error),
1073
- has_more: true,
1074
- };
1075
- }
1076
- }
1077
- }
1078
-
1079
- const minimum = Number.isFinite(Number(request.minimum_timestamp))
1080
- ? Number(request.minimum_timestamp)
1081
- : null;
1082
- const recent = Number.isFinite(Number(request.recent_since))
1083
- ? Number(request.recent_since)
1084
- : null;
1085
- const dirtyRanges = Array.isArray(request.dirty_ranges)
1086
- ? request.dirty_ranges
1087
- : [];
1088
- const dirtyByMessageId = new Map(
1089
- dirtyRanges
1090
- .filter((marker) => marker?.message_id)
1091
- .map((marker) => [marker.message_id, marker])
1092
- );
1093
- const normalized = [];
1094
- const quarantined = [];
1095
- const names = nameIndex(collections);
1096
- for (const model of uniqueMessageModels(collections)) {
1097
- const message = await normalizeMessage(
1098
- model,
1099
- "reconcile",
1100
- collections,
1101
- names
1102
- );
1103
- if (!message) continue;
1104
- if (message.timestamp <= 0) {
1105
- quarantined.push({
1106
- key: `${message.chat_jid}:${message.id}`,
1107
- message_id: message.id,
1108
- chat_jid: message.chat_jid,
1109
- reason: "missing_stable_timestamp",
1110
- });
1111
- continue;
1112
- }
1113
- if (chatFilter === "group" && !message.is_group) continue;
1114
- if (chatFilter === "individual" && message.is_group) continue;
1115
- if (minimum != null && message.timestamp < minimum) continue;
1116
- if (
1117
- recent != null &&
1118
- message.timestamp < recent &&
1119
- !backfillMessageIds.has(message.id) &&
1120
- !dirtyByMessageId.has(message.id)
1121
- )
1122
- continue;
1123
- normalized.push(message);
1124
- }
1125
- normalized.sort(
1126
- (a, b) => a.timestamp - b.timestamp || a.id.localeCompare(b.id)
1127
- );
1128
- const maxMessages = Math.max(
1129
- 1,
1130
- Math.min(Number(request.max_messages) || 1_000, 2_000)
1131
- );
1132
- const byId = new Map(normalized.map((message) => [message.id, message]));
1133
- const historyPages = [];
1134
- for (const [chatJid, ids] of loadedByChat) {
1135
- historyPages.push({
1136
- chat_jid: chatJid,
1137
- ...(updates[chatJid] ?? {}),
1138
- messages: ids.map((id) => byId.get(id)).filter(Boolean),
1139
- });
1140
- }
1141
- const messages = normalized
1142
- .filter((message) => !backfillMessageIds.has(message.id))
1143
- .slice(-maxMessages)
1144
- .sort((a, b) => a.timestamp - b.timestamp || a.id.localeCompare(b.id));
1145
- const mergedChats = { ...(backfill.chats ?? {}), ...updates };
1146
- return {
1147
- ok: true,
1148
- status,
1149
- messages,
1150
- history_pages: historyPages,
1151
- quarantined,
1152
- dirty_reconciled: normalized
1153
- .filter((message) => dirtyByMessageId.has(message.id))
1154
- .map((message) => ({
1155
- key: dirtyByMessageId.get(message.id).key,
1156
- message_id: message.id,
1157
- })),
1158
- backfill: {
1159
- // `chatRows` is empty when the tab answered `probe` but its Chat
1160
- // collection has not populated yet. A bare `.every()` is vacuously true
1161
- // there, which would record a finished backfill that never ran.
1162
- complete:
1163
- request.backfill_disabled === true ||
1164
- (chatRows.length > 0 &&
1165
- chatRows.every((entry) => mergedChats[entry.jid]?.has_more === false)),
1166
- cursor_chat_jid: cursor,
1167
- inventory: chatRows.map((entry) => entry.jid),
1168
- chats: updates,
1169
- },
1170
- };
1171
- }
1172
-
1173
868
  async function resolveChat(collections, input) {
1174
869
  if (input?.self_chat === true) {
1175
870
  const me = meUser();
@@ -1253,6 +948,11 @@ export function whatsAppWebAdapterProgram() {
1253
948
  }
1254
949
  const keyModule = requireFirst(["WAWebMsgKey"]);
1255
950
  const exactId = query.startsWith("id:") ? query.slice(3) : null;
951
+ let chatJid = null;
952
+ if (query.startsWith("chat:")) {
953
+ const chat = await resolveChat(requireFirst(["WAWebCollections"]), { chat_jid: query.slice(5) });
954
+ chatJid = (await canonicalJid(modelData(chat).id ?? chat?.id)).jid;
955
+ }
1256
956
  const database = await new Promise((resolve, reject) => {
1257
957
  const request = indexedDB.open("model-storage");
1258
958
  // Never create an empty replacement database when WhatsApp changes its
@@ -1288,24 +988,46 @@ export function whatsAppWebAdapterProgram() {
1288
988
  return;
1289
989
  }
1290
990
  rows.push({ position: cursor.key, id: cursor.value.id });
1291
- if (rows.length > limit) resolve(rows);
991
+ if (rows.length > (chatJid === null ? limit : CHAT_SCAN_ROWS)) resolve(rows);
1292
992
  else cursor.continue();
1293
993
  };
1294
994
  });
1295
995
  } finally {
1296
996
  database.close();
1297
997
  }
1298
- const hasMore = sourceRows.length > limit;
1299
- const page = sourceRows.slice(0, limit);
998
+ let hasMore = sourceRows.length > limit;
999
+ let page = sourceRows.slice(0, limit);
1000
+ let last = page[page.length - 1];
1001
+ if (chatJid !== null) {
1002
+ // A chat read scans one large storage page, then keeps that chat's rows.
1003
+ // Matching happens after the transaction closes because LID conversion
1004
+ // awaits, and history can key a chat by phone or by LID.
1005
+ const examined = sourceRows.slice(0, CHAT_SCAN_ROWS);
1006
+ const canonical = new Map();
1007
+ const matches = [];
1008
+ for (const row of examined) {
1009
+ const remote = keyModule.fromString(row.id).remote;
1010
+ const raw = widString(remote);
1011
+ if (!canonical.has(raw)) canonical.set(raw, (await canonicalJid(remote)).jid);
1012
+ if (canonical.get(raw) !== chatJid) continue;
1013
+ matches.push(row);
1014
+ if (matches.length > limit) break;
1015
+ }
1016
+ page = matches.slice(0, limit);
1017
+ hasMore = matches.length > limit || sourceRows.length > CHAT_SCAN_ROWS;
1018
+ last = matches.length > limit ? page[page.length - 1] : examined[examined.length - 1];
1019
+ }
1300
1020
  const collections = requireFirst(["WAWebCollections"]);
1301
- const selected = page.filter((row) => {
1021
+ const selected = [];
1022
+ for (const row of page) {
1302
1023
  const key = keyModule.fromString(row.id);
1303
- if (exactId !== null && key.id !== exactId) return false;
1024
+ if (exactId !== null && key.id !== exactId) continue;
1304
1025
  const remote = widString(key.remote);
1305
- if (remote === "status@broadcast" || remote.endsWith("@newsletter")) return false;
1026
+ if (remote === "status@broadcast" || remote.endsWith("@newsletter")) continue;
1306
1027
  const isGroup = remote.endsWith("@g.us");
1307
- return !(chatFilter === "group" && !isGroup) && !(chatFilter === "individual" && isGroup);
1308
- });
1028
+ if ((chatFilter === "group" && !isGroup) || (chatFilter === "individual" && isGroup)) continue;
1029
+ selected.push(row);
1030
+ }
1309
1031
  const results = [];
1310
1032
  if (selected.length) {
1311
1033
  const loaded = await collections.Msg.getMessagesById(selected.map((row) => row.id));
@@ -1322,14 +1044,14 @@ export function whatsAppWebAdapterProgram() {
1322
1044
  // Skip them like search does; throwing would pin every later read to
1323
1045
  // the same cursor.
1324
1046
  if (!message || message.timestamp <= 0) continue;
1325
- if (exactId === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase())) continue;
1047
+ if (exactId === null && chatJid === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase())) continue;
1326
1048
  results.push(message);
1327
1049
  }
1328
1050
  }
1329
1051
  return {
1330
1052
  results,
1331
1053
  hasMore,
1332
- ...(hasMore ? { nextCursor: JSON.stringify({ v: 1, before: page[page.length - 1].position, query, chat_filter: chatFilter }) } : {}),
1054
+ ...(hasMore ? { nextCursor: JSON.stringify({ v: 1, before: last.position, query, chat_filter: chatFilter }) } : {}),
1333
1055
  };
1334
1056
  }
1335
1057
 
@@ -1581,7 +1303,7 @@ export function whatsAppWebAdapterProgram() {
1581
1303
  const message = collectionByRawId(collections.Msg, raw);
1582
1304
  if (!message)
1583
1305
  throw new Error(
1584
- `WhatsApp message ${raw} is not loaded; sync or search it first`
1306
+ `WhatsApp message ${raw} is not loaded; read it with id:${raw} from the live messages feed or search it first`
1585
1307
  );
1586
1308
  return message;
1587
1309
  }
@@ -1731,195 +1453,6 @@ export function whatsAppWebAdapterProgram() {
1731
1453
  };
1732
1454
  }
1733
1455
 
1734
- async function blobFromMedia(model) {
1735
- const row = modelData(model);
1736
- let result = null;
1737
- if (typeof model?.downloadMedia === "function") {
1738
- result = await model.downloadMedia({
1739
- downloadEvenIfExpensive: true,
1740
- rmrReason: 1,
1741
- });
1742
- }
1743
- result =
1744
- result ??
1745
- modelData(model).mediaData?.mediaBlob ??
1746
- model?.mediaData?.mediaBlob ??
1747
- row.mediaBlob ??
1748
- null;
1749
- if (!result) {
1750
- // The module exports `{ enforceKaleidoscopeScore, downloadManager }` —
1751
- // the method sits on the nested object, so probing the module root only
1752
- // ever found `undefined` and this fallback never ran.
1753
- const managerModule = requireFirst(["WAWebDownloadManager"]);
1754
- const manager = managerModule?.downloadManager ?? managerModule;
1755
- if (typeof manager?.downloadAndMaybeDecrypt === "function") {
1756
- // `downloadQpl` is NOT optional: the very first thing the function
1757
- // does is call `downloadQpl.addAnnotations(...)`, so omitting it threw
1758
- // "Cannot read properties of undefined" before a byte was fetched.
1759
- // It is only WhatsApp's performance logger, so a stub that answers
1760
- // every method with a no-op satisfies it — and a permissive proxy
1761
- // keeps working when a future build calls a method we have not seen
1762
- // (this already happened once: `addAnnotations` alone was not enough,
1763
- // the build also calls `addPoint`).
1764
- result = await manager.downloadAndMaybeDecrypt({
1765
- directPath: row.directPath,
1766
- encFilehash: row.encFilehash,
1767
- filehash: row.filehash,
1768
- mediaKey: row.mediaKey,
1769
- mediaKeyTimestamp: row.mediaKeyTimestamp,
1770
- type: row.type,
1771
- mimetype: row.mimetype,
1772
- downloadOrigin: null,
1773
- partialVideoOpts: null,
1774
- downloadQpl: new Proxy(
1775
- {},
1776
- {
1777
- get: () => () => {
1778
- /* WhatsApp's QPL telemetry; nothing to record here. */
1779
- },
1780
- }
1781
- ),
1782
- signal: new AbortController().signal,
1783
- });
1784
- }
1785
- }
1786
- if (result === "NEED_POKE" || result?.status === "NEED_POKE")
1787
- return { status: "NEED_POKE" };
1788
- const candidate = result?.blob ?? result?.mediaBlob ?? result;
1789
- if (candidate instanceof Blob)
1790
- return { status: "downloaded", blob: candidate };
1791
- // `downloadAndMaybeDecrypt` resolves the decrypted bytes as a raw
1792
- // ArrayBuffer, not a Blob. Falling through to the Blob checks below
1793
- // reported a perfectly good download as `unavailable`.
1794
- if (candidate instanceof ArrayBuffer || ArrayBuffer.isView(candidate))
1795
- return {
1796
- status: "downloaded",
1797
- blob: new Blob([candidate], {
1798
- type: row.mimetype || "application/octet-stream",
1799
- }),
1800
- };
1801
- if (candidate?.getData) {
1802
- const data = await candidate.getData();
1803
- if (data instanceof Blob) return { status: "downloaded", blob: data };
1804
- if (data instanceof ArrayBuffer || ArrayBuffer.isView(data))
1805
- return {
1806
- status: "downloaded",
1807
- blob: new Blob([data], { type: row.mimetype }),
1808
- };
1809
- }
1810
- return { status: row.directPath ? "unavailable" : "expired" };
1811
- }
1812
-
1813
- function bytesToBase64(bytes) {
1814
- let binary = "";
1815
- const chunk = 0x8000;
1816
- for (let i = 0; i < bytes.length; i += chunk) {
1817
- binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
1818
- }
1819
- return btoa(binary);
1820
- }
1821
-
1822
- async function downloadMedia(input) {
1823
- const collections = requireFirst(["WAWebCollections"]);
1824
- const model = resolveMessage(collections, input?.message_id);
1825
- const row = modelData(model);
1826
- if (row.isViewOnce || row.viewOnce || row.type === "view_once")
1827
- return { status: "view_once" };
1828
- const limit = Math.max(1, Number(input?.max_bytes) || 1);
1829
- const size = Number(row.size ?? row.fileSize ?? 0);
1830
- if (size > limit) return { status: "too_large", size_bytes: size };
1831
- const isVideo =
1832
- row.type === "video" || String(row.mimetype ?? "").startsWith("video/");
1833
- if (isVideo && size <= 0) {
1834
- return { status: "metadata_only", retryable: true, size_bytes: null };
1835
- }
1836
- // Bound the fetch HERE, where the work happens, so the dispatch always
1837
- // answers. A caller-side timer cannot cancel an in-flight dispatch: it only
1838
- // stops the caller waiting, and the reply then arrives with nobody left to
1839
- // receive it. Racing inside the page is safe — there is no IPC child to
1840
- // outlive — and it turns "too slow" into an ordinary retryable answer.
1841
- const budgetMs = Math.max(0, Number(input?.timeout_ms) || 0);
1842
- let downloaded;
1843
- // Held so a download that wins the race can cancel its own timer. A sync
1844
- // collects several items, and a stray rejecting timer per item would keep
1845
- // firing into the page long after its answer shipped.
1846
- let budgetTimer = null;
1847
- try {
1848
- downloaded = budgetMs
1849
- ? await Promise.race([
1850
- blobFromMedia(model),
1851
- new Promise((_, reject) => {
1852
- budgetTimer = setTimeout(
1853
- () =>
1854
- reject(
1855
- Object.assign(
1856
- new Error("media download exceeded its budget"),
1857
- { state: "timeout_retryable" }
1858
- )
1859
- ),
1860
- budgetMs
1861
- );
1862
- }),
1863
- ])
1864
- : await blobFromMedia(model);
1865
- } catch (error) {
1866
- const detail = String(error);
1867
- const reported = String(error?.state ?? error?.status ?? "");
1868
- const explicit = [
1869
- "NEED_POKE",
1870
- "awaiting_primary_device",
1871
- "view_once",
1872
- "expired",
1873
- "too_large",
1874
- "timeout_retryable",
1875
- "metadata_only",
1876
- "unavailable",
1877
- ].find(
1878
- (state) =>
1879
- reported === state ||
1880
- detail.toLowerCase().includes(state.toLowerCase())
1881
- );
1882
- return {
1883
- status: explicit ?? "unavailable",
1884
- retryable: [
1885
- "NEED_POKE",
1886
- "awaiting_primary_device",
1887
- "timeout_retryable",
1888
- "metadata_only",
1889
- "unavailable",
1890
- ].includes(explicit ?? "unavailable"),
1891
- detail: detail.slice(0, 200),
1892
- };
1893
- } finally {
1894
- if (budgetTimer !== null) clearTimeout(budgetTimer);
1895
- }
1896
- if (!downloaded.blob) return downloaded;
1897
- if (downloaded.blob.size > limit)
1898
- return { status: "too_large", size_bytes: downloaded.blob.size };
1899
- const bytes = new Uint8Array(await downloaded.blob.arrayBuffer());
1900
- if (bytes.length === 0) return { status: "unavailable", detail: "empty" };
1901
- const mime =
1902
- downloaded.blob.type || row.mimetype || "application/octet-stream";
1903
- const kind = mime.startsWith("audio/")
1904
- ? "audio"
1905
- : mime.startsWith("image/")
1906
- ? "image"
1907
- : "file";
1908
- return {
1909
- status: "downloaded",
1910
- attachment: {
1911
- kind,
1912
- filename:
1913
- row.filename ??
1914
- row.fileName ??
1915
- `whatsapp-${rawId(row.id ?? model?.id)}`,
1916
- mime_type: mime,
1917
- data: bytesToBase64(bytes),
1918
- size_bytes: bytes.length,
1919
- },
1920
- };
1921
- }
1922
-
1923
1456
  async function invoke(request) {
1924
1457
  try {
1925
1458
  if (Number(request?.adapter_version) !== ADAPTER_VERSION) {
@@ -1954,11 +1487,8 @@ export function whatsAppWebAdapterProgram() {
1954
1487
  },
1955
1488
  };
1956
1489
  }
1957
- if (request.op === "collect") return await collect(request);
1958
1490
  if (request.op === "read_messages")
1959
1491
  return { ok: true, ...(await readMessages(request.input)) };
1960
- if (request.op === "download_media")
1961
- return { ok: true, ...(await downloadMedia(request)) };
1962
1492
  if (request.op === "search_messages")
1963
1493
  return { ok: true, ...(await searchMessages(request.input)) };
1964
1494
  if (request.op === "draft_message")