@lobu/runtime-server 21.2.1 → 23.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 (420) hide show
  1. package/dist/catalogs/automations.json +40 -13
  2. package/dist/catalogs/connectors.json +18435 -1259
  3. package/dist/catalogs/skills.json +1 -1
  4. package/dist/component.json +1 -1
  5. package/dist/connectors/README.md +21 -6
  6. package/dist/connectors/_google/actions.ts +270 -0
  7. package/dist/connectors/_google/discovery/calendar_v3.json +1 -0
  8. package/dist/connectors/_google/discovery/chat_v1.json +1 -0
  9. package/dist/connectors/_google/discovery/docs_v1.json +1 -0
  10. package/dist/connectors/_google/discovery/drive_v3.json +1 -0
  11. package/dist/connectors/_google/discovery/gmail_v1.json +1 -0
  12. package/dist/connectors/_google/discovery/people_v1.json +1 -0
  13. package/dist/connectors/_google/discovery/sheets_v4.json +1 -0
  14. package/dist/connectors/_google/discovery/tasks_v1.json +1 -0
  15. package/dist/connectors/_google/discovery/youtube_v3.json +1 -0
  16. package/dist/connectors/_google/discovery.ts +442 -0
  17. package/dist/connectors/_google/errors.ts +91 -0
  18. package/dist/connectors/_google/list-feed.ts +223 -0
  19. package/dist/connectors/_google/policies.ts +127 -0
  20. package/dist/connectors/agentid.ts +43 -0
  21. package/dist/connectors/chat-user-identity.ts +2 -1
  22. package/dist/connectors/github-automation-events.ts +9 -0
  23. package/dist/connectors/github-identity.ts +28 -3
  24. package/dist/connectors/github.ts +101 -59
  25. package/dist/connectors/google_calendar.ts +207 -719
  26. package/dist/connectors/google_drive.ts +16 -2
  27. package/dist/connectors/google_gmail.ts +52 -33
  28. package/dist/connectors/herdr.ts +406 -0
  29. package/dist/connectors/jira-helpers.ts +313 -0
  30. package/dist/connectors/jira.ts +35 -227
  31. package/dist/connectors/linear.ts +7 -4
  32. package/dist/connectors/linkedin-browser-script.ts +13 -0
  33. package/dist/connectors/linkedin-draft-page.js +104 -0
  34. package/dist/connectors/linkedin-drafts.ts +73 -0
  35. package/dist/connectors/linkedin-identity.ts +32 -0
  36. package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  37. package/dist/connectors/linkedin-inbox.ts +156 -0
  38. package/dist/connectors/linkedin-like.ts +114 -0
  39. package/dist/connectors/linkedin-takeout.ts +577 -0
  40. package/dist/connectors/linkedin.ts +3998 -0
  41. package/dist/connectors/postgres.ts +27 -2
  42. package/dist/connectors/takeout-utils.ts +240 -0
  43. package/dist/connectors/tiktok-inbox-page.js +230 -0
  44. package/dist/connectors/tiktok-web-page.js +217 -0
  45. package/dist/connectors/tiktok_web.ts +319 -0
  46. package/dist/connectors/whatsapp-web-adapter.js +285 -567
  47. package/dist/connectors/whatsapp-web-helpers.ts +74 -455
  48. package/dist/connectors/whatsapp-web-identity.ts +135 -0
  49. package/dist/connectors/whatsapp_web.ts +159 -618
  50. package/dist/connectors/x-dm-adapter.js +556 -0
  51. package/dist/connectors/x-identity.ts +31 -2
  52. package/dist/connectors/x.ts +539 -253
  53. package/dist/db/migrations/20261005150000_retire_agent_tool_config.sql +31 -0
  54. package/dist/db/migrations/20261005173700_drop_retired_agent_tool_config.sql +29 -0
  55. package/dist/db/migrations/20261007010000_identity_association_guards.sql +242 -0
  56. package/dist/db/migrations/20261007010001_identity_association_indexes.sql +35 -0
  57. package/dist/db/migrations/20261007012000_connector_browser_requirement.sql +7 -0
  58. package/dist/db/migrations/20261009010000_identity_member_decision_indexes.sql +22 -0
  59. package/dist/db/migrations/20261009015900_retire_remaining_physical_merges.sql +196 -0
  60. package/dist/db/migrations/20261009020000_retire_physical_entity_merge.sql +82 -0
  61. package/dist/db/migrations/20261009030000_retire_physical_merge_indexes.sql +39 -0
  62. package/dist/db/migrations/20261009030001_drop_physical_entity_redirect.sql +62 -0
  63. package/dist/db/migrations/20261009040000_normalize_identity_decisions.sql +60 -0
  64. package/dist/db/migrations/20261010220000_notification_targets_user_event_order.sql +53 -0
  65. package/dist/db/migrations/20261010223000_device_workers_user_fresh_cover.sql +39 -0
  66. package/dist/db/migrations/20261010223001_runs_org_default_view.sql +41 -0
  67. package/dist/db/migrations/20261010223002_events_org_guidance.sql +42 -0
  68. package/dist/db/migrations/20261011002000_finish_product_eval_retirement.sql +37 -0
  69. package/dist/db/migrations/20261011160000_mcp_conversation_workspaces.sql +97 -0
  70. package/dist/db/migrations/20261013120000_events_live_org_effective_date.sql +42 -0
  71. package/dist/db/migrations/20261013150000_events_live_linked_org_ids_gin.sql +41 -0
  72. package/dist/db/migrations/20261014120000_clear_team_device_auto_pause.sql +34 -0
  73. package/dist/db/migrations/20261014150000_connector_webhook_event_type_backfill.sql +30 -0
  74. package/dist/db/migrations/20261014170000_retire_atlassian_mcp_webhook_refresh.sql +51 -0
  75. package/dist/db/migrations/20261015010000_connection_auth_profile_fk_set_null_column.sql +53 -0
  76. package/dist/db/migrations/20261015120000_personal_org_connector_auto_policy.sql +38 -0
  77. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  78. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  79. package/dist/db/migrations/preconditions/20261005150000_retire_agent_tool_config.sql +22 -0
  80. package/dist/db/migrations/preconditions/20261005173700_drop_retired_agent_tool_config.sql +13 -0
  81. package/dist/db/migrations/preconditions/20261009020000_retire_physical_entity_merge.sql +26 -0
  82. package/dist/db/migrations/preconditions/20261011002000_finish_product_eval_retirement.sql +14 -0
  83. package/dist/dependencies.bun.lock +144 -137
  84. package/dist/guest.bundle.js +416 -330
  85. package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
  86. package/dist/owletto/dist/assets/_-DYUE3ix4.js +3 -0
  87. package/dist/owletto/dist/assets/_-DtqBFgK5.js +1 -0
  88. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
  89. package/dist/owletto/dist/assets/_agentId-Cam7Z0N7.js +2 -0
  90. package/dist/owletto/dist/assets/_automationId-CXEiKVZJ.js +2 -0
  91. package/dist/owletto/dist/assets/_connectorKey._connectionId-CS85l61t.js +2 -0
  92. package/dist/owletto/dist/assets/_connectorKey.index-clVDIyW0.js +2 -0
  93. package/dist/owletto/dist/assets/_conversationId-Ci2k-BuN.js +2 -0
  94. package/dist/owletto/dist/assets/_deploymentId-BuUzGtVL.js +2 -0
  95. package/dist/owletto/dist/assets/_eventId-B0662F8h.js +2 -0
  96. package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
  97. package/dist/owletto/dist/assets/_owner-dTWkrKsK.js +3 -0
  98. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
  99. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
  100. package/dist/owletto/dist/assets/_slug-DQHutM41.js +2 -0
  101. package/dist/owletto/dist/assets/_threadId-DtqBFgK5.js +1 -0
  102. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
  103. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
  104. package/dist/owletto/dist/assets/accept-invitation-w17IFTtf.js +2 -0
  105. package/dist/owletto/dist/assets/activity-route-view-CMqYiiKM.js +2 -0
  106. package/dist/owletto/dist/assets/agent-card-controls-mnTN2AZt.js +2 -0
  107. package/dist/owletto/dist/assets/{agent-client-setup-list-BFtgRwe8.js → agent-client-setup-list-Bg3hBfUV.js} +4 -3
  108. package/dist/owletto/dist/assets/agent-connect-pages-B_vrqLVc.js +2 -0
  109. package/dist/owletto/dist/assets/agent-editor-form-hTs7eO_U.js +2 -0
  110. package/dist/owletto/dist/assets/agent-guardrails-route-BOrCXcAl.js +2 -0
  111. package/dist/owletto/dist/assets/agent-loading-shells-Dqcvky-k.js +2 -0
  112. package/dist/owletto/dist/assets/agent-permissions-matrix-BOo_4r_4.js +2 -0
  113. package/dist/owletto/dist/assets/{agent-skill-context-BAr2Dw3F.js → agent-skill-context-CCdvtlmH.js} +2 -1
  114. package/dist/owletto/dist/assets/agent-skills-route-BUxIswuq.js +2 -0
  115. package/dist/owletto/dist/assets/agent-subpage-shell-D92imvSt.js +2 -0
  116. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
  117. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
  118. package/dist/owletto/dist/assets/agents-workbench-Bt5QCYQ7.js +2 -0
  119. package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +128 -0
  120. package/dist/owletto/dist/assets/app._appId-CKv7_squ.js +2 -0
  121. package/dist/owletto/dist/assets/automation-detail-content-vUwVumXf.js +2 -0
  122. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
  123. package/dist/owletto/dist/assets/{callback-CaRe2TOT.js → callback-BRgcL8gz.js} +2 -1
  124. package/dist/owletto/dist/assets/{card-CMmh2mzo.js → card-Djgp00r_.js} +2 -1
  125. package/dist/owletto/dist/assets/claim-BYUZnyMp.js +2 -0
  126. package/dist/owletto/dist/assets/client-rows-EJSKR6z1.js +1 -0
  127. package/dist/owletto/dist/assets/clients-D3Zbjxin.js +2 -0
  128. package/dist/owletto/dist/assets/code-editor-DHeyRGZI.js +16 -0
  129. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
  130. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
  131. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
  132. package/dist/owletto/dist/assets/connected._clientId.activity-Ckdz6I0y.js +2 -0
  133. package/dist/owletto/dist/assets/connected._clientId.index-CNxafNeo.js +2 -0
  134. package/dist/owletto/dist/assets/connection-C3XXFEqh.js +2 -0
  135. package/dist/owletto/dist/assets/connection-feed-detail-CIJJLDP8.js +2 -0
  136. package/dist/owletto/dist/assets/connection-label-BobuYiAG.js +1 -0
  137. package/dist/owletto/dist/assets/connections-browser-CKZjzRz6.js +2 -0
  138. package/dist/owletto/dist/assets/{connector-provenance-BjKiUhYE.js → connector-provenance-8-d8hl10.js} +2 -1
  139. package/dist/owletto/dist/assets/connector-scope-lists-CadPVsI3.js +2 -0
  140. package/dist/owletto/dist/assets/{connectors-Baejya0T.js → connectors-lvLJ30lo.js} +2 -1
  141. package/dist/owletto/dist/assets/consent-CdSvVCgx.js +2 -0
  142. package/dist/owletto/dist/assets/conversations-table-BdXoZAfc.js +2 -0
  143. package/dist/owletto/dist/assets/{core.esm-QA7BQgiK.js → core.esm-CYvgWCuv.js} +2 -1
  144. package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
  145. package/dist/owletto/dist/assets/create-B0qhrrX4.js +2 -0
  146. package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
  147. package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
  148. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
  149. package/dist/owletto/dist/assets/{cronstrue-2GHCtD7h.js → cronstrue-n4qGUraE.js} +2 -1
  150. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
  151. package/dist/owletto/dist/assets/deployments-RvUdVkj3.js +2 -0
  152. package/dist/owletto/dist/assets/{deployments-body-Bm2upStd.js → deployments-body-BMp7UsMo.js} +2 -1
  153. package/dist/owletto/dist/assets/device-CPU6CjkJ.js +2 -0
  154. package/dist/owletto/dist/assets/device-pin-tombstone-CrjG7gPo.js +2 -0
  155. package/dist/owletto/dist/assets/device._deviceId-Cs3ZmXWo.js +2 -0
  156. package/dist/owletto/dist/assets/{entity-options-CrbS6K-i.js → entity-options-uXjgT7y9.js} +2 -1
  157. package/dist/owletto/dist/assets/entity-page-Dc0LGr5U.js +2 -0
  158. package/dist/owletto/dist/assets/entity-type-page-CwZxa0BR.js +2 -0
  159. package/dist/owletto/dist/assets/event-detail-ve2d6Gbb.js +2 -0
  160. package/dist/owletto/dist/assets/events-feed-BtvhZF1f.js +2 -0
  161. package/dist/owletto/dist/assets/filter-editors-Cj-v6NtH.js +2 -0
  162. package/dist/owletto/dist/assets/full-page-spinner-DqpH99np.js +2 -0
  163. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
  164. package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
  165. package/dist/owletto/dist/assets/index-B9uPN6FC.js +2 -0
  166. package/dist/owletto/dist/assets/index-BLEcy9-T.css +1 -0
  167. package/dist/owletto/dist/assets/index-BQVliQW1.js +2 -0
  168. package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
  169. package/dist/owletto/dist/assets/index-CDz3-ieP.js +1 -0
  170. package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
  171. package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
  172. package/dist/owletto/dist/assets/index-Cr5hwh-C.js +7950 -0
  173. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
  174. package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
  175. package/dist/owletto/dist/assets/index-DVk7Ug0d.js +2 -0
  176. package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
  177. package/dist/owletto/dist/assets/index-DtqBFgK5.js +1 -0
  178. package/dist/owletto/dist/assets/index-Hio-HRfo.js +2 -0
  179. package/dist/owletto/dist/assets/{index-Cf0GJoiG.js → index-ICgKp3YK.js} +2 -1
  180. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +1 -0
  181. package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
  182. package/dist/owletto/dist/assets/{index-DlepU3cY.js → index-n7sTbNv4.js} +2 -1
  183. package/dist/owletto/dist/assets/index-rrnUF981.js +1 -0
  184. package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
  185. package/dist/owletto/dist/assets/json-diff-DBoag_OS.js +4 -0
  186. package/dist/owletto/dist/assets/{list-skeleton-BtWn2eo2.js → list-skeleton-C_GuoxAH.js} +2 -1
  187. package/dist/owletto/dist/assets/login-Ci6ixHuL.js +2 -0
  188. package/dist/owletto/dist/assets/logout-CLGgeZB7.js +2 -0
  189. package/dist/owletto/dist/assets/member-scope-gate-B44INDPY.js +2 -0
  190. package/dist/owletto/dist/assets/memory-browse-page-DyQiRvzl.js +103 -0
  191. package/dist/owletto/dist/assets/model-selector-dAbDgJvx.js +2 -0
  192. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
  193. package/dist/owletto/dist/assets/new-BUb7AnEW.js +2 -0
  194. package/dist/owletto/dist/assets/new-BkdULx2r.js +2 -0
  195. package/dist/owletto/dist/assets/new-CHOr-EcI.js +2 -0
  196. package/dist/owletto/dist/assets/oauth-workspace-access-BxsjwgdH.js +2 -0
  197. package/dist/owletto/dist/assets/organization-gxGeDjIV.js +2 -0
  198. package/dist/owletto/dist/assets/peek-pane-content-CHoQHe2H.js +2 -0
  199. package/dist/owletto/dist/assets/{permissions-h_qSft1A.js → permissions-aPHaKLec.js} +2 -1
  200. package/dist/owletto/dist/assets/proposal-review-shell-UcZr87_Q.js +2 -0
  201. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
  202. package/dist/owletto/dist/assets/{recent-JiBNvZzD.js → recent-D-65Pgu-.js} +2 -1
  203. package/dist/owletto/dist/assets/record-activity-CBXH6v1d.js +2 -0
  204. package/dist/owletto/dist/assets/{renderer-DgPLyEbx.js → renderer-mEDnVW0O.js} +28 -27
  205. package/dist/owletto/dist/assets/reset-password-uX_V6bip.js +2 -0
  206. package/dist/owletto/dist/assets/runs-C0rCgGwX.js +2 -0
  207. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
  208. package/dist/owletto/dist/assets/runs-table-syPJ6r6T.js +2 -0
  209. package/dist/owletto/dist/assets/settings-9NkNA1G1.js +2 -0
  210. package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
  211. package/dist/owletto/dist/assets/skill-editor-D_W3QlRz.js +1 -0
  212. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
  213. package/dist/owletto/dist/assets/source-record-panels-CPyzlfD1.js +2 -0
  214. package/dist/owletto/dist/assets/status-dot-B-EWMgq6.js +2 -0
  215. package/dist/owletto/dist/assets/tabs-DqIIkCX-.js +2 -0
  216. package/dist/owletto/dist/assets/{use-mention-search-B4DfZFm5.js → use-mention-search-By8RZyKW.js} +3 -2
  217. package/dist/owletto/dist/assets/view-param-filters-CqLZQrnO.js +2 -0
  218. package/dist/owletto/dist/assets/workspace-label-o_QfBuCM.js +2 -0
  219. package/dist/owletto/dist/index.html +46 -4
  220. package/dist/providers.json +1 -1
  221. package/dist/server-main.bundle.mjs +137029 -133673
  222. package/npm-shrinkwrap.json +612 -645
  223. package/package.json +4 -3
  224. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  225. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  226. package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
  227. package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
  228. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  229. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  230. package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
  231. package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
  232. package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
  233. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
  234. package/vendor/connector-sdk/dist/define-connector.js +3 -0
  235. package/vendor/connector-sdk/dist/index.d.ts +8 -2
  236. package/vendor/connector-sdk/dist/index.js +3 -0
  237. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
  238. package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
  239. package/vendor/connector-sdk/package.json +13 -1
  240. package/vendor/core/dist/agent-policy.js +1 -1
  241. package/vendor/core/dist/agent-store.d.ts +2 -0
  242. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  243. package/vendor/core/dist/agent-tooling.js +1 -1
  244. package/vendor/core/dist/capabilities.d.ts +1 -1
  245. package/vendor/core/dist/capabilities.js +2 -1
  246. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  247. package/vendor/core/dist/connector-query-errors.js +41 -1
  248. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
  249. package/vendor/core/dist/contracts/agent-settings.js +1 -7
  250. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
  251. package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
  252. package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
  253. package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
  254. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
  255. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
  256. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
  257. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
  258. package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
  259. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
  260. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
  261. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  262. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
  263. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
  264. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
  265. package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
  266. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  267. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  268. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
  269. package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
  270. package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
  271. package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
  272. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
  273. package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
  274. package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
  275. package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
  276. package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
  277. package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
  278. package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
  279. package/vendor/core/dist/contracts/worker/protocol.js +88 -76
  280. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  281. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  282. package/vendor/core/dist/index.d.ts +5 -5
  283. package/vendor/core/dist/index.js +4 -6
  284. package/vendor/core/dist/json-template.d.ts +6 -10
  285. package/vendor/core/dist/json-template.js +5 -9
  286. package/vendor/core/dist/logger.js +17 -26
  287. package/vendor/core/dist/shell-safety.d.ts +9 -0
  288. package/vendor/core/dist/shell-safety.js +154 -0
  289. package/vendor/core/dist/suggestions.d.ts +1 -1
  290. package/vendor/core/dist/suggestions.js +1 -1
  291. package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
  292. package/vendor/core/dist/tool-trace-summary.js +1 -1
  293. package/vendor/core/dist/types.d.ts +1 -3
  294. package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
  295. package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
  296. package/vendor/core/dist/worker/auth.d.ts +44 -6
  297. package/vendor/core/dist/worker/auth.js +44 -11
  298. package/vendor/core/dist/worker/wire.d.ts +0 -10
  299. package/vendor/core/package.json +20 -11
  300. package/vendor/views/dist/api.d.ts +39 -29
  301. package/vendor/views/dist/api.js +110 -83
  302. package/vendor/views/dist/bridge.d.ts +4 -0
  303. package/vendor/views/dist/bridge.js +15 -0
  304. package/vendor/views/dist/index.d.ts +1 -0
  305. package/vendor/views/dist/index.js +0 -7
  306. package/vendor/views/package.json +4 -1
  307. package/dist/owletto/dist/assets/_-CLhipgJI.js +0 -1
  308. package/dist/owletto/dist/assets/_-D0ZVGAIA.js +0 -2
  309. package/dist/owletto/dist/assets/_agentId-BLXUf3ot.js +0 -1
  310. package/dist/owletto/dist/assets/_agentId-DnI66MF3.js +0 -1
  311. package/dist/owletto/dist/assets/_automationId-ziwseLb7.js +0 -1
  312. package/dist/owletto/dist/assets/_connectorKey._connectionId-B6V3ySFK.js +0 -1
  313. package/dist/owletto/dist/assets/_connectorKey.index-CR5u_dtt.js +0 -1
  314. package/dist/owletto/dist/assets/_conversationId-FBMYmOl8.js +0 -1
  315. package/dist/owletto/dist/assets/_deploymentId-DNTXbT_m.js +0 -1
  316. package/dist/owletto/dist/assets/_name-B37LKIxH.js +0 -1
  317. package/dist/owletto/dist/assets/_owner-BxYumqC2.js +0 -1
  318. package/dist/owletto/dist/assets/_shape-Bxz-04jR.js +0 -1
  319. package/dist/owletto/dist/assets/_skillKey-D5MFbiw2.js +0 -1
  320. package/dist/owletto/dist/assets/_slug-Dlhit09k.js +0 -1
  321. package/dist/owletto/dist/assets/_viewKey-C6535i-t.js +0 -1
  322. package/dist/owletto/dist/assets/_viewKey-CQCtY3Y8.js +0 -1
  323. package/dist/owletto/dist/assets/_viewKey-CxKfKbRa.js +0 -1
  324. package/dist/owletto/dist/assets/accept-invitation-BQQwec3R.js +0 -1
  325. package/dist/owletto/dist/assets/activity-route-view-BwThvdGs.js +0 -1
  326. package/dist/owletto/dist/assets/agent-card-controls-B3RhzsPz.js +0 -1
  327. package/dist/owletto/dist/assets/agent-connect-pages-BO4wQn4L.js +0 -1
  328. package/dist/owletto/dist/assets/agent-editor-form-BYC4uSNz.js +0 -1
  329. package/dist/owletto/dist/assets/agent-guardrails-route-Dp02G1AQ.js +0 -1
  330. package/dist/owletto/dist/assets/agent-loading-shells-OagauQzV.js +0 -1
  331. package/dist/owletto/dist/assets/agent-permissions-matrix-B9Ho3P1t.js +0 -1
  332. package/dist/owletto/dist/assets/agent-skills-route-B4VUnVi0.js +0 -1
  333. package/dist/owletto/dist/assets/agent-subpage-shell-Dz8I-GUt.js +0 -1
  334. package/dist/owletto/dist/assets/agent-thread-B9-cdkaV.js +0 -8
  335. package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +0 -1
  336. package/dist/owletto/dist/assets/agents-D0CIg4b9.js +0 -1
  337. package/dist/owletto/dist/assets/agents-workbench-C2sr5h82.js +0 -1
  338. package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +0 -127
  339. package/dist/owletto/dist/assets/app._appId-DLsJ_QWS.js +0 -1
  340. package/dist/owletto/dist/assets/automation-detail-content-9Rjb_I9j.js +0 -1
  341. package/dist/owletto/dist/assets/automations-D0CIg4b9.js +0 -1
  342. package/dist/owletto/dist/assets/calendar-DAiyi1ZL.js +0 -1
  343. package/dist/owletto/dist/assets/claim-CYHnUF7G.js +0 -1
  344. package/dist/owletto/dist/assets/clients-Cp1BJ28u.js +0 -1
  345. package/dist/owletto/dist/assets/code-editor-CYsR2VBP.js +0 -15
  346. package/dist/owletto/dist/assets/connect-CZip2g_B.js +0 -1
  347. package/dist/owletto/dist/assets/connect._clientId-CEKY8Dnv.js +0 -1
  348. package/dist/owletto/dist/assets/connected._clientId-C5xRjxNO.js +0 -1
  349. package/dist/owletto/dist/assets/connection-C06HZ241.js +0 -1
  350. package/dist/owletto/dist/assets/connection-feed-detail-D1whY5hL.js +0 -1
  351. package/dist/owletto/dist/assets/consent-CfYDldcF.js +0 -1
  352. package/dist/owletto/dist/assets/create-C3P-3_8O.js +0 -1
  353. package/dist/owletto/dist/assets/create-CwnrPUEw.js +0 -1
  354. package/dist/owletto/dist/assets/create-DOScS9Gl.js +0 -1
  355. package/dist/owletto/dist/assets/create-automation-form-CuxiIRCF.js +0 -2
  356. package/dist/owletto/dist/assets/create._connectorKey-Bjv3lCf8.js +0 -1
  357. package/dist/owletto/dist/assets/deployments-ByBv1DW-.js +0 -1
  358. package/dist/owletto/dist/assets/deployments-C-_ECORv.js +0 -1
  359. package/dist/owletto/dist/assets/device-B0i7Xp8y.js +0 -1
  360. package/dist/owletto/dist/assets/device-automation-BIjs7DZJ.js +0 -1
  361. package/dist/owletto/dist/assets/device-pin-tombstone-Bd6vS2zu.js +0 -1
  362. package/dist/owletto/dist/assets/device-rows-Bwf8qDte.js +0 -1
  363. package/dist/owletto/dist/assets/device._deviceId-DJLAesm3.js +0 -1
  364. package/dist/owletto/dist/assets/entity-page-ijZe_1-6.js +0 -1
  365. package/dist/owletto/dist/assets/entity-type-page-onp2Tk_E.js +0 -1
  366. package/dist/owletto/dist/assets/event-page-C0B2UDY-.js +0 -1
  367. package/dist/owletto/dist/assets/events-feed-DK35T4g7.js +0 -1
  368. package/dist/owletto/dist/assets/full-page-spinner-Dd8eEaxq.js +0 -1
  369. package/dist/owletto/dist/assets/guardrails-DKO8_J-G.js +0 -1
  370. package/dist/owletto/dist/assets/identity-CKM54vrM.js +0 -1
  371. package/dist/owletto/dist/assets/index--VmN5WxW.js +0 -1
  372. package/dist/owletto/dist/assets/index-B2AmRqYh.js +0 -7898
  373. package/dist/owletto/dist/assets/index-B_rcEgFX.js +0 -1
  374. package/dist/owletto/dist/assets/index-BmAuAhub.css +0 -1
  375. package/dist/owletto/dist/assets/index-BmhGe6-Z.js +0 -1
  376. package/dist/owletto/dist/assets/index-C1dJSGrL.js +0 -1
  377. package/dist/owletto/dist/assets/index-CAFw4qCb.js +0 -1
  378. package/dist/owletto/dist/assets/index-CCcc_xBw.js +0 -52
  379. package/dist/owletto/dist/assets/index-CLU3gXVm.js +0 -1
  380. package/dist/owletto/dist/assets/index-CqQVnAY-.js +0 -1
  381. package/dist/owletto/dist/assets/index-CxT0uyIe.js +0 -1
  382. package/dist/owletto/dist/assets/index-DR08e6Ec.js +0 -1
  383. package/dist/owletto/dist/assets/index-DYb9L5FC.js +0 -1
  384. package/dist/owletto/dist/assets/index-SUUcQGT-.js +0 -1
  385. package/dist/owletto/dist/assets/index-SdiFOfR1.js +0 -1
  386. package/dist/owletto/dist/assets/index-zcfi5r1l.js +0 -1
  387. package/dist/owletto/dist/assets/json-diff-ClBBYBQD.js +0 -3
  388. package/dist/owletto/dist/assets/login-d3PdO-qV.js +0 -1
  389. package/dist/owletto/dist/assets/logout-DgckxwLn.js +0 -1
  390. package/dist/owletto/dist/assets/member-scope-gate-DXOCfx-v.js +0 -1
  391. package/dist/owletto/dist/assets/memory-browse-page-CeAnKoTR.js +0 -101
  392. package/dist/owletto/dist/assets/missing-view-DrZ8m8yo.js +0 -1
  393. package/dist/owletto/dist/assets/model-selector-CapL1ARf.js +0 -1
  394. package/dist/owletto/dist/assets/models-CB8mhq7j.js +0 -1
  395. package/dist/owletto/dist/assets/new-BBUb-VR4.js +0 -1
  396. package/dist/owletto/dist/assets/new-CBLJ25_w.js +0 -1
  397. package/dist/owletto/dist/assets/new-tTXB4qBW.js +0 -1
  398. package/dist/owletto/dist/assets/oauth-workspace-access-DearynqZ.js +0 -1
  399. package/dist/owletto/dist/assets/organization-BgdBg-PJ.js +0 -1
  400. package/dist/owletto/dist/assets/pending-seed-CPbfgnLX.js +0 -1
  401. package/dist/owletto/dist/assets/proposal-review-shell-D4YNrrye.js +0 -1
  402. package/dist/owletto/dist/assets/reset-password-B8tWPtIj.js +0 -1
  403. package/dist/owletto/dist/assets/runs-oHveuEUB.js +0 -1
  404. package/dist/owletto/dist/assets/runs-panel-C56GDaJm.js +0 -1
  405. package/dist/owletto/dist/assets/runs-table-BUKDjiBc.js +0 -1
  406. package/dist/owletto/dist/assets/schema-value-normalization-3JuM_r1H.js +0 -1
  407. package/dist/owletto/dist/assets/settings-DaKg6U5O.js +0 -1
  408. package/dist/owletto/dist/assets/settings-DhnRi2nq.js +0 -1
  409. package/dist/owletto/dist/assets/skills-BpQncuMC.js +0 -1
  410. package/dist/owletto/dist/assets/switch-BQ40_DMb.js +0 -1
  411. package/dist/owletto/dist/assets/use-applied-views-B-Z-Weji.js +0 -1
  412. package/dist/owletto/dist/assets/view-frame-C7ciEoLo.js +0 -1
  413. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  414. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  415. package/vendor/core/dist/sentry.d.ts +0 -26
  416. package/vendor/core/dist/sentry.js +0 -133
  417. package/vendor/core/dist/tool-policy.d.ts +0 -74
  418. package/vendor/core/dist/tool-policy.js +0 -305
  419. package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
  420. package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
@@ -1,50 +1,41 @@
1
1
  /**
2
- * WhatsApp owns its page adapter, normalization, and collection checkpoints.
3
- * The paired browser provides generic evaluate and feed_listen operations;
4
- * its durable record buffer wakes the existing feed sync through worker poll.
5
- * Successful sync checkpoints acknowledge exact buffered revisions. Ordinary
6
- * collection still supplies history and reconciles the page's current state.
2
+ * WhatsApp's feed reads live without importing message history into events.
3
+ * The page adapter answers source reads and observes new messages; observation
4
+ * publishes references only, through the paired browser's generic evaluate
5
+ * and feed_listen operations. An Automation reads content live when it runs. The only
6
+ * checkpoint is the observation position used to replay missed references.
7
7
  *
8
8
  * Auth stays in the user's signed-in WhatsApp Web tab. Org policy governs
9
9
  * message writes; there is no connector-side action ledger.
10
10
  */
11
11
 
12
12
  import {
13
+ assertNoOffsetPaging,
14
+ assertNoSort,
15
+ assertNoWindow,
16
+ requireBrowser,
17
+ splitReferenceBatches,
13
18
  type ActionContext,
14
19
  type ActionResult,
15
20
  type ChromeActionDispatcher,
16
21
  ConnectorRuntime,
17
- type EventEnvelope,
22
+ type FeedReadContext,
23
+ type FeedReadResult,
24
+ type FeedObserveContext,
18
25
  type RuntimeConnectorDefinition,
19
- type SyncContext,
20
- type SyncResult,
21
26
  } from "@lobu/connector-sdk";
22
27
  import {
23
- type BrowserCheckpoint,
24
- buildCollectionPlan,
25
28
  type ChatFilter,
26
- type CollectResponse,
27
- type DirtyMarker,
28
- isMediaEligible,
29
- MAX_MEDIA_BYTES,
30
- MAX_MEDIA_PER_RUN,
31
- type MediaRecord,
32
- type MediaStatus,
33
- mergeBrowserCheckpoint,
34
- mergeCollectedMessages,
29
+ messageContentKind,
35
30
  messagePayloadText,
36
- messageRevision,
37
31
  messageTitle,
38
32
  normalizeRelayedMessage,
39
- toEventEnvelope,
33
+ type ObservationCheckpoint,
40
34
  WHATSAPP_ADAPTER_VERSION,
41
35
  WHATSAPP_ORIGIN,
42
- type WhatsAppMessage,
43
36
  } from "./whatsapp-web-helpers.js";
44
37
  import { whatsAppWebAdapterProgram } from "./whatsapp-web-adapter.js";
45
38
 
46
- const SOURCE_OBSERVATION_ERROR_ID = "whatsapp-web:source-observation-error";
47
-
48
39
  /**
49
40
  * How long a run waits for WhatsApp Web to finish hydrating before giving up.
50
41
  *
@@ -65,44 +56,9 @@ const SOURCE_OBSERVATION_ERROR_ID = "whatsapp-web:source-observation-error";
65
56
  */
66
57
  const READY_TIMEOUT_MS = 120_000;
67
58
  const READY_POLL_INTERVAL_MS = 500;
68
- /**
69
- * Per-item budget, enforced by the ADAPTER inside the page.
70
- *
71
- * A caller-side timer cannot bound a dispatch: it cannot cancel one, so racing
72
- * it only stops us waiting while the request stays in flight in the parent
73
- * worker. The child then finishes and exits, the device's answer arrives with
74
- * nobody to receive it, and the parent's reply-send finds a dead IPC channel —
75
- * which failed a prod sync run that had already written its events, and once
76
- * killed the worker daemon outright. Measured `download_media` evaluates take
77
- * 3.9-5.2s, so the old 4s caller-side cap orphaned nearly every media item.
78
- *
79
- * The extension's `evaluate` op takes no timeout and its schema is deliberately
80
- * frozen, but the adapter request shape is ours: send the budget with the
81
- * request and let the page enforce it, so a slow item comes back as an ordinary
82
- * `timeout_retryable` answer instead of an abandoned dispatch. This mirrors how
83
- * `x.ts` hands `timeout_ms` to `wait_for_selector` rather than racing it.
84
- */
85
- const MEDIA_ITEM_TIMEOUT_MS = 20_000;
86
-
87
- /**
88
- * Outer bound on the whole media phase, checked between items. The per-item
89
- * budget above caps any single download; this stops a long queue of merely
90
- * slow ones from consuming a run. Items past it stay retryable.
91
- */
92
- const MEDIA_PHASE_BUDGET_MS = 60_000;
93
- const MEDIA_CONCURRENCY = 3;
94
- const MAX_TOTAL_MEDIA_BYTES = 4 * 1024 * 1024;
95
- const MAX_DIRTY_MARKERS_PERSISTED = 250;
96
- /**
97
- * Media retry rows the checkpoint carries between runs. Attachments are never
98
- * persisted — only the status/backoff bookkeeping the extension kept in
99
- * IndexedDB, which is what decides whether to re-attempt a download.
100
- */
101
- const MAX_MEDIA_RECORDS_PERSISTED = 500;
102
59
 
103
60
  interface WhatsAppWebConfig {
104
61
  chat_filter?: ChatFilter;
105
- max_messages_per_sync?: number;
106
62
  }
107
63
 
108
64
  /** Adapter failures the bridge can recover from by re-injecting the program. */
@@ -120,33 +76,13 @@ class WhatsAppAdapterError extends Error {
120
76
  }
121
77
  }
122
78
 
123
- /**
124
- * Pull the chrome action dispatcher off sessionState. The connector-worker
125
- * host splices a live `chrome_dispatcher` onto every sync AND action context;
126
- * its `dispatch()` rides a host capability up to the daemon and out to the
127
- * gateway's chrome-action bridge.
128
- */
129
- function requireExtensionDispatcher(ctx: {
130
- sessionState?: Record<string, unknown> | null;
131
- }): ChromeActionDispatcher {
132
- const handle = ctx.sessionState?.chrome_dispatcher as
133
- | ChromeActionDispatcher
134
- | undefined;
135
- if (!handle || typeof handle.dispatch !== "function") {
136
- throw new Error(
137
- "WhatsApp Web connector requires a paired Owletto Chrome extension. No chrome_dispatcher was injected into sessionState — pin this connection to a chrome-extension device."
138
- );
139
- }
140
- return handle;
141
- }
142
-
143
79
  /**
144
80
  * A hydrated WhatsApp Web tab in the extension's persistent agent window.
145
81
  *
146
82
  * The window is persistent on purpose: a cold tab costs a 20s load plus up to
147
83
  * 25s of WhatsApp hydration, and every one of those seconds is spent inside a
148
- * run's budget. Reusing the window keeps the message model hot for ordinary
149
- * collection and keeps the page observer attached between syncs.
84
+ * run's budget. Reusing the window keeps the message model hot for reads and
85
+ * keeps the page observer attached between runs.
150
86
  */
151
87
  async function openWhatsAppTab(
152
88
  dispatcher: ChromeActionDispatcher
@@ -291,11 +227,6 @@ const TRANSIENT_READINESS_PATTERN = /hydrating|stores_settling/i;
291
227
  * its CDP timeout and the adapter never gets to name a state -- the bridge
292
228
  * REJECTS the dispatch instead of returning an adapter-shaped error, so this
293
229
  * message carries no connector prefix to classify on.
294
- *
295
- * Only the readiness phase may treat it as transient. A `collect` that times
296
- * out is a real failure, and the server's dependency_unavailable branch skips
297
- * `consecutive_failures` -- classifying it here would let a permanently broken
298
- * collect retry forever without ever walking the feed toward its hard pause.
299
230
  */
300
231
  const BARE_EVALUATE_TIMEOUT_PATTERN = /\btimed out\b/i;
301
232
  const DEPENDENCY_UNAVAILABLE_PREFIX =
@@ -303,19 +234,15 @@ const DEPENDENCY_UNAVAILABLE_PREFIX =
303
234
 
304
235
  /**
305
236
  * Only readiness-phase WhatsApp failures are transient. Authentication, adapter
306
- * corruption, unsupported operations, and collection errors remain ordinary
307
- * connector failures and still count toward source health.
237
+ * corruption, and unsupported operations remain ordinary connector failures
238
+ * and still count toward source health.
308
239
  */
309
- function classifyWhatsAppReadinessFailure(
310
- error: unknown,
311
- { allowBareTimeout = false }: { allowBareTimeout?: boolean } = {}
312
- ): string | null {
240
+ function classifyWhatsAppReadinessFailure(error: unknown): string | null {
313
241
  if (!(error instanceof Error)) return null;
314
242
  // A dispatch the bridge abandoned never reaches the adapter, so it has no
315
243
  // connector prefix to match. Classify it before the prefix gate below, or a
316
- // hydration stall that timed out is booked as a hard failure. Readiness only:
317
- // see BARE_EVALUATE_TIMEOUT_PATTERN for why collect must not opt in.
318
- if (allowBareTimeout && BARE_EVALUATE_TIMEOUT_PATTERN.test(error.message)) {
244
+ // hydration stall that timed out is booked as a hard failure.
245
+ if (BARE_EVALUATE_TIMEOUT_PATTERN.test(error.message)) {
319
246
  return `${DEPENDENCY_UNAVAILABLE_PREFIX} ${error.message}`;
320
247
  }
321
248
  // MAIN-world adapter failures may cross the extension/worker boundary without
@@ -371,9 +298,7 @@ async function readyWhatsAppTab(
371
298
  }
372
299
  await new Promise((resolve) => setTimeout(resolve, READY_POLL_INTERVAL_MS));
373
300
  } while (Date.now() < deadline);
374
- const transient = classifyWhatsAppReadinessFailure(lastError, {
375
- allowBareTimeout: true,
376
- });
301
+ const transient = classifyWhatsAppReadinessFailure(lastError);
377
302
  if (transient) throw new Error(transient);
378
303
  throw (
379
304
  lastError ??
@@ -381,204 +306,6 @@ async function readyWhatsAppTab(
381
306
  );
382
307
  }
383
308
 
384
- const MEDIA_STATES: ReadonlySet<string> = new Set([
385
- "downloaded",
386
- "NEED_POKE",
387
- "awaiting_primary_device",
388
- "view_once",
389
- "expired",
390
- "too_large",
391
- "timeout_retryable",
392
- "metadata_only",
393
- "unavailable",
394
- ]);
395
- const TERMINAL_MEDIA_STATES: ReadonlySet<string> = new Set([
396
- "downloaded",
397
- "view_once",
398
- "expired",
399
- "too_large",
400
- ]);
401
- const RETRYABLE_MEDIA_STATES = [
402
- "awaiting_primary_device",
403
- "timeout_retryable",
404
- "unavailable",
405
- "metadata_only",
406
- ];
407
-
408
- function mediaBackoff(attempts: number): number {
409
- return Date.now() + Math.min(60 * 60_000, 5_000 * 2 ** Math.min(attempts, 8));
410
- }
411
-
412
- /**
413
- * Download the media the run is allowed to spend on, and carry the retry
414
- * bookkeeping forward in the checkpoint.
415
- *
416
- * The extension cached blobs in IndexedDB; a checkpoint cannot hold megabytes
417
- * of base64, so only the status/backoff row survives a run. A message whose
418
- * media already downloaded is not re-attempted because the head cursor has
419
- * moved past it — the cache only ever mattered for re-emitted rows.
420
- */
421
- async function downloadEligibleMedia(
422
- dispatcher: ChromeActionDispatcher,
423
- tabId: number,
424
- messages: WhatsAppMessage[],
425
- priorMedia: Record<string, MediaRecord>
426
- ): Promise<{
427
- results: Map<string, MediaRecord>;
428
- nextMedia: Record<string, MediaRecord>;
429
- }> {
430
- const results = new Map<string, MediaRecord>();
431
- const nextMedia: Record<string, MediaRecord> = {};
432
- const queue: Array<{
433
- message: WhatsAppMessage;
434
- previous: MediaRecord | undefined;
435
- revision: string;
436
- }> = [];
437
- let totalBytes = 0;
438
-
439
- const remember = (record: MediaRecord) => {
440
- results.set(record.id, record);
441
- // Terminal rows need no further bookkeeping; only pending retries are
442
- // worth a checkpoint slot. So a prior record is ALWAYS retryable — there
443
- // is no terminal-prior case to short-circuit. Re-downloading inside the
444
- // recent-overlap window costs one fetch and dedupes on content hash;
445
- // persisting terminal rows to avoid it would grow the checkpoint without
446
- // bound.
447
- if (record.retryable)
448
- nextMedia[record.id] = { ...record, attachment: undefined };
449
- };
450
-
451
- const defer = (message: WhatsAppMessage, previous?: MediaRecord) => {
452
- remember({
453
- id: message.id,
454
- revision: messageRevision(message),
455
- status: "metadata_only",
456
- retryable: true,
457
- attempts: previous?.attempts ?? 0,
458
- next_attempt_at: Date.now() + 5_000,
459
- updated_at: Date.now(),
460
- });
461
- };
462
-
463
- for (const message of messages) {
464
- if (!isMediaEligible(message)) continue;
465
- const revision = messageRevision(message);
466
- const previous = priorMedia[message.id];
467
- if (
468
- previous?.revision === revision &&
469
- (previous.next_attempt_at ?? 0) > Date.now()
470
- ) {
471
- remember(previous);
472
- continue;
473
- }
474
- if (queue.length >= MAX_MEDIA_PER_RUN) {
475
- defer(message, previous);
476
- continue;
477
- }
478
- queue.push({ message, previous, revision });
479
- }
480
-
481
- const mediaDeadline = Date.now() + MEDIA_PHASE_BUDGET_MS;
482
- let cursor = 0;
483
- const worker = async (): Promise<void> => {
484
- while (cursor < queue.length) {
485
- const item = queue[cursor++];
486
- if (!item) return;
487
- const { message, previous, revision } = item;
488
- if (Date.now() > mediaDeadline) {
489
- // Out of phase budget: leave the rest retryable rather than starting a
490
- // dispatch this run cannot wait for.
491
- defer(message, previous);
492
- continue;
493
- }
494
- try {
495
- const response = await invokeAdapter<{
496
- status?: string;
497
- retryable?: boolean;
498
- attachment?: MediaRecord["attachment"];
499
- }>(dispatcher, tabId, {
500
- op: "download_media",
501
- message_id: message.id,
502
- max_bytes: MAX_MEDIA_BYTES,
503
- timeout_ms: MEDIA_ITEM_TIMEOUT_MS,
504
- });
505
- const rawStatus = MEDIA_STATES.has(response.status ?? "")
506
- ? (response.status as string)
507
- : "unavailable";
508
- const status = (
509
- rawStatus === "NEED_POKE" ? "awaiting_primary_device" : rawStatus
510
- ) as MediaStatus;
511
- const attempts = (previous?.attempts ?? 0) + 1;
512
- const retryable = Boolean(
513
- response.retryable ||
514
- rawStatus === "NEED_POKE" ||
515
- RETRYABLE_MEDIA_STATES.includes(status)
516
- );
517
- const record: MediaRecord = {
518
- id: message.id,
519
- revision,
520
- status,
521
- raw_status: rawStatus,
522
- retryable,
523
- attachment: response.attachment,
524
- mime_type:
525
- response.attachment?.mime_type ?? message.media_type ?? null,
526
- attempts,
527
- next_attempt_at: retryable ? mediaBackoff(attempts) : null,
528
- updated_at: Date.now(),
529
- };
530
- const size = Number(record.attachment?.size_bytes) || 0;
531
- if (size && totalBytes + size > MAX_TOTAL_MEDIA_BYTES) {
532
- // Over the per-run byte budget: emit the metadata placeholder and
533
- // leave the download to a later run.
534
- remember({
535
- ...record,
536
- attachment: undefined,
537
- status: "metadata_only",
538
- retryable: true,
539
- });
540
- } else {
541
- totalBytes += size;
542
- remember(record);
543
- }
544
- } catch (error) {
545
- const attempts = (previous?.attempts ?? 0) + 1;
546
- // Both the phase budget and the child-side dispatch backstop mean
547
- // "try again later", not "this media is gone".
548
- const text = String(error);
549
- const timedOut =
550
- text.includes("timed out") || text.includes("IPC may be wedged");
551
- const reported =
552
- error instanceof WhatsAppAdapterError ? error.state : null;
553
- const explicitState =
554
- reported && MEDIA_STATES.has(reported) ? reported : null;
555
- const status = (
556
- explicitState === "NEED_POKE"
557
- ? "awaiting_primary_device"
558
- : (explicitState ??
559
- (timedOut ? "timeout_retryable" : "unavailable"))
560
- ) as MediaStatus;
561
- const retryable = !TERMINAL_MEDIA_STATES.has(status);
562
- remember({
563
- id: message.id,
564
- revision,
565
- status,
566
- retryable,
567
- attempts,
568
- next_attempt_at: retryable ? mediaBackoff(attempts) : null,
569
- updated_at: Date.now(),
570
- });
571
- }
572
- }
573
- };
574
- await Promise.all(
575
- Array.from({ length: Math.min(MEDIA_CONCURRENCY, queue.length) }, () =>
576
- worker()
577
- )
578
- );
579
- return { results, nextMedia };
580
- }
581
-
582
309
  /** Normalise adapter search/read hits into the row shape the tools return. */
583
310
  function normalizedSearchResults(
584
311
  results: unknown[] | null | undefined
@@ -593,10 +320,15 @@ function normalizedSearchResults(
593
320
  chat_name: message.chat_name ?? null,
594
321
  title: messageTitle(message),
595
322
  text: messagePayloadText(message),
323
+ content_kind: messageContentKind(message),
596
324
  occurred_at: message.occurred_at,
597
325
  from_me: message.from_me,
598
326
  sender_jid: message.sender_jid ?? null,
327
+ sender_phone: message.sender_phone ?? null,
328
+ push_name: message.push_name ?? null,
329
+ is_group: message.is_group,
599
330
  quoted_id: message.quoted_id ?? null,
331
+ mentions_me: message.mentions_me === true,
600
332
  });
601
333
  }
602
334
  return rows;
@@ -611,33 +343,59 @@ const WRITE_ACTIONS = new Set([
611
343
  ]);
612
344
 
613
345
  export default class WhatsAppWebConnector extends ConnectorRuntime<
614
- BrowserCheckpoint,
346
+ ObservationCheckpoint,
615
347
  WhatsAppWebConfig
616
348
  > {
617
349
  readonly definition: RuntimeConnectorDefinition<
618
- BrowserCheckpoint,
350
+ ObservationCheckpoint,
619
351
  WhatsAppWebConfig
620
352
  > = {
621
353
  key: "whatsapp.web",
622
354
  name: "WhatsApp",
623
355
  description:
624
- "Personal WhatsApp messages read from WhatsApp Web in the paired Owletto Chrome. Syncs one-to-one and group chats, progressively hydrates history, and can search, draft, send, edit, react to, and revoke messages.",
625
- version: "1.0.4",
356
+ "Personal WhatsApp messages read live from WhatsApp Web in the paired Owletto Chrome without importing message history. Automations react to new-message references and read content on demand. Search, draft, send, edit, react to, and revoke messages.",
357
+ version: "2.1.0",
626
358
  faviconDomain: "whatsapp.com",
627
- // Implicit auth: the user is already signed into WhatsApp Web in the
628
- // paired Chrome. There is no artifact to relay — the QR is rendered by
629
- // web.whatsapp.com itself — and an auth run carries no chrome dispatcher,
630
- // so a handshake here could not read the page. A logged-out page fails
631
- // the readiness probe with the exact remedy instead.
632
- authSchema: { methods: [{ type: "none" }] },
359
+ authSchema: { methods: [{ type: "browser", mode: "live" }] },
360
+ browser: {
361
+ origins: [WHATSAPP_ORIGIN],
362
+ accountProbe: {
363
+ url: `${WHATSAPP_ORIGIN}/`,
364
+ expression: `(async () => {
365
+ (${whatsAppWebAdapterProgram.toString()})();
366
+ for (let i = 0; i < 40; i++) {
367
+ const identity = await globalThis.__owlettoWhatsAppAdapterV1.invoke({ op: "account_identity", adapter_version: ${WHATSAPP_ADAPTER_VERSION} });
368
+ if (identity?.accountId) return identity;
369
+ await new Promise(resolve => setTimeout(resolve, 250));
370
+ }
371
+ return null;
372
+ })()`,
373
+ },
374
+ },
375
+ automationEvents: [{
376
+ key: "message.created", label: "New message", resourceType: "message",
377
+ description: "A new message reference from WhatsApp Web. The Automation can read its content from the live messages feed, or reply in the chat it came from.",
378
+ filterSchema: {
379
+ type: "object",
380
+ properties: {
381
+ channel_id: {
382
+ type: "string",
383
+ title: "Chat",
384
+ description: "WhatsApp chat ID. Scoping replies to a group allows replies without a mention, subject to the other trigger filters. Unscoped group replies require an @mention or a reply quoting the account.",
385
+ },
386
+ },
387
+ },
388
+ capabilities: { replyToSource: true },
389
+ }],
633
390
  feeds: {
634
- messages: {
635
- sync: (ctx) => this.syncMessages(ctx),
636
- webhook: { events: ["message"], mode: "trigger" },
637
- key: "messages",
638
- name: "Messages",
391
+ live_messages: {
392
+ key: "live_messages",
393
+ name: "Live messages",
639
394
  description:
640
- "Personal WhatsApp messages from one-to-one and group chats. Syncs live changes and progressively hydrates history available to WhatsApp Web.",
395
+ "Read messages directly from WhatsApp Web without importing history, using literal text search or id:<message ID>. Active Automations can subscribe to new-message references. Requires the paired browser to be online and signed in; reconnects replay messages still available in WhatsApp's local history.",
396
+ read: (ctx) => this.readMessages(ctx),
397
+ observe: (ctx) => this.observeMessages(ctx),
398
+ webhook: { mode: "trigger", events: ["message.created"] },
641
399
  configSchema: {
642
400
  type: "object",
643
401
  properties: {
@@ -647,102 +405,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
647
405
  default: "all",
648
406
  description: "Which chats to include.",
649
407
  },
650
- max_messages_per_sync: {
651
- type: "integer",
652
- minimum: 1,
653
- maximum: 1000,
654
- default: 1000,
655
- description:
656
- "Bounded maximum messages emitted per sync. Additional durable history resumes on later runs.",
657
- },
658
- },
659
- },
660
- eventKinds: {
661
- message: {
662
- description:
663
- "A WhatsApp message, caption, media placeholder, edit, revoke, or reaction-updated message.",
664
- metadataSchema: {
665
- type: "object",
666
- required: [
667
- "source",
668
- "origin_id",
669
- "chat_jid",
670
- "is_group",
671
- "from_me",
672
- ],
673
- properties: {
674
- source: { type: "string", const: "whatsapp_web" },
675
- origin_id: { type: "string" },
676
- chat_jid: { type: "string" },
677
- is_group: { type: "boolean" },
678
- from_me: { type: "boolean" },
679
- is_direct_inbound: { type: "boolean" },
680
- participant: { type: "string" },
681
- sender_jid: { type: "string" },
682
- sender_phone: { type: "string" },
683
- push_name: { type: "string" },
684
- media_type: { type: "string" },
685
- quoted_id: { type: "string" },
686
- is_forwarded: { type: "boolean" },
687
- is_starred: { type: "boolean" },
688
- is_system_event: { type: "boolean" },
689
- edited: { type: "boolean" },
690
- edit_timestamp: { type: "number" },
691
- revoked: { type: "boolean" },
692
- reactions: { type: "array", items: { type: "object" } },
693
- voice_note_skipped: {
694
- type: "string",
695
- enum: [
696
- "not_downloaded",
697
- "too_large",
698
- "empty",
699
- "read_error",
700
- "invalid_path",
701
- ],
702
- },
703
- media_status: {
704
- type: "string",
705
- enum: [
706
- "downloaded",
707
- "awaiting_primary_device",
708
- "view_once",
709
- "expired",
710
- "too_large",
711
- "timeout_retryable",
712
- "metadata_only",
713
- "unavailable",
714
- ],
715
- },
716
- },
717
- },
718
- attributions: [
719
- {
720
- role: "authored_by",
721
- autoCreate: true,
722
- target: {
723
- entityType: "person",
724
- createWhen: {
725
- path: "metadata.is_direct_inbound",
726
- equals: true,
727
- },
728
- titlePath: "metadata.push_name",
729
- identities: [
730
- { namespace: "wa_jid", eventPath: "metadata.sender_jid" },
731
- { namespace: "phone", eventPath: "metadata.sender_phone" },
732
- ],
733
- },
734
- traits: {
735
- push_name: {
736
- eventPath: "metadata.push_name",
737
- mergeStrategy: "prefer_non_empty",
738
- },
739
- last_seen_at: {
740
- eventPath: "occurred_at",
741
- mergeStrategy: "overwrite",
742
- },
743
- },
744
- },
745
- ],
746
408
  },
747
409
  },
748
410
  },
@@ -789,6 +451,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
789
451
  enum: ["whatsapp_fts", "loaded_model_fallback"],
790
452
  },
791
453
  results: { type: "array", items: { type: "object" } },
454
+ hasMore: { type: "boolean" },
792
455
  },
793
456
  },
794
457
  },
@@ -929,217 +592,98 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
929
592
  },
930
593
  };
931
594
 
932
- private async syncMessages(
933
- ctx: SyncContext<BrowserCheckpoint, WhatsAppWebConfig>
934
- ): Promise<SyncResult> {
935
- const dispatcher = requireExtensionDispatcher(ctx);
595
+ private async observeMessages(ctx: FeedObserveContext<ObservationCheckpoint, WhatsAppWebConfig>): Promise<void> {
596
+ const dispatcher = requireBrowser(ctx);
936
597
  const tabId = await readyWhatsAppTab(dispatcher);
937
- return await this.collectMessages(ctx, dispatcher, tabId);
938
- }
939
-
940
- /**
941
- * The collect phase re-checks readiness inside the page, so a message landing
942
- * between the passing probe and this dispatch surfaces the same transient
943
- * `stores_settling` here. `readyWhatsAppTab` classifies that as a dependency
944
- * failure; without the same treatment on this path an ordinary race counts
945
- * against the feed's consecutive-failure budget and walks it toward a pause.
946
- */
947
- private async collectMessages(
948
- ctx: SyncContext<BrowserCheckpoint, WhatsAppWebConfig>,
949
- dispatcher: ChromeActionDispatcher,
950
- tabId: number
951
- ): Promise<SyncResult> {
952
- try {
953
- return await this.collectMessagesInner(ctx, dispatcher, tabId);
954
- } catch (error) {
955
- const transient = classifyWhatsAppReadinessFailure(error);
956
- if (transient) throw new Error(transient);
957
- throw error;
598
+ const chatFilter = ctx.config.chat_filter ?? "all";
599
+ const previous = ctx.checkpoint?.observation?.chat_filter === chatFilter ? ctx.checkpoint.observation : undefined;
600
+ const startedAt = previous?.started_at ?? Math.floor(Date.now() / 1000);
601
+ // Snapshot before attaching so replay covers messages arriving during setup.
602
+ let after = previous?.after ?? (await invokeAdapter<{ after: number }>(
603
+ dispatcher, tabId, { op: "observe_messages", input: {} })).after;
604
+ const binding = await dispatcher.dispatch<{
605
+ bridge_id: string; token: string; listening?: boolean; subscription?: { scope_key: string };
606
+ }>("feed_listen", { tab_id: tabId });
607
+ if (!binding.bridge_id || !binding.token || !binding.subscription || binding.listening === false) {
608
+ throw new Error("A browser supporting source subscriptions is required for WhatsApp");
958
609
  }
959
- }
960
-
961
- private async collectMessagesInner(
962
- ctx: SyncContext<BrowserCheckpoint, WhatsAppWebConfig>,
963
- dispatcher: ChromeActionDispatcher,
964
- tabId: number
965
- ): Promise<SyncResult> {
966
- const { checkpoint, request } = buildCollectionPlan({
967
- checkpoint: ctx.checkpoint as Record<string, unknown> | null,
968
- config: ctx.config as Record<string, unknown>,
610
+ await invokeAdapter(dispatcher, tabId, {
611
+ op: "listen", bridge_id: binding.bridge_id, token: binding.token,
612
+ chat_filter: chatFilter, minimum_timestamp: startedAt,
969
613
  });
970
-
971
- const observed = await dispatcher.dispatch<{
972
- bridge_id: string;
973
- binding_id: string;
974
- epoch: string;
975
- token: string;
976
- listening?: boolean;
977
- records: Array<{ revision: number; payload: Record<string, unknown> }>;
978
- }>("feed_listen", { tab_id: tabId }).catch((error: unknown) => {
979
- const message = error instanceof Error ? error.message : String(error);
980
- if (message.includes("Owletto for Chrome: unknown dispatch") && message.includes("action_key='feed_listen'")) {
981
- throw new Error("[lobu:dependency_unavailable:browser_extension_update_required] Update the paired Owletto extension to support connector feed listeners");
614
+ let cursor = ctx.checkpoint ?? null;
615
+ for (let page = 0; page < 10; page++) {
616
+ const replay = await invokeAdapter<{
617
+ after: number; references: Array<{ id: string; timestamp: number }>; hasMore: boolean;
618
+ }>(dispatcher, tabId, { op: "observe_messages", input: { after, started_at: startedAt, chat_filter: chatFilter } });
619
+ const next: ObservationCheckpoint = {
620
+ observation: { after: replay.after, started_at: startedAt, chat_filter: chatFilter },
621
+ };
622
+ const events = replay.references.map(reference => ({
623
+ id: reference.id, event_type: "message.created", resource_type: "message",
624
+ resource_ref: reference.id, occurred_at: new Date(reference.timestamp * 1000).toISOString(),
625
+ }));
626
+ // Earlier chunks may be replayed after interruption; existing signal
627
+ // dedupe handles them. Advance only after the entire page is accepted.
628
+ const batches = splitReferenceBatches(events, (slice, isLast, offset) => ({
629
+ id: `replay:${chatFilter}:${startedAt}:${after}:${replay.after}:${offset}`,
630
+ events: slice,
631
+ ...(isLast ? { checkpoint: { previous: cursor, next } } : {}),
632
+ more: isLast && replay.hasMore && page === 9,
633
+ }));
634
+ for (const batch of batches) {
635
+ await invokeAdapter(dispatcher, tabId, {
636
+ op: "publish_changes", bridge_id: binding.bridge_id, token: binding.token, batch,
637
+ });
982
638
  }
983
- throw error;
984
- });
985
- if (!observed.bridge_id || !Array.isArray(observed.records)) {
986
- throw new Error("The paired browser must support connector feed listeners; update the Owletto extension");
987
- }
988
- const sourceErrors = observed.records.filter((row) =>
989
- row.payload.id === SOURCE_OBSERVATION_ERROR_ID &&
990
- typeof row.payload.source_error === "string"
991
- );
992
- // A real rebind proves a prior page failure recovered. A dry snapshot
993
- // cannot install that listener, so it must keep surfacing the marker.
994
- if (observed.listening !== false) await invokeAdapter(dispatcher, tabId, {
995
- op: "listen", bridge_id: observed.bridge_id, token: observed.token,
996
- chat_filter: request.chat_filter,
997
- minimum_timestamp: request.minimum_timestamp,
998
- recent_since: request.recent_since ?? Math.floor(Date.now() / 1000) - 15 * 60,
999
- });
1000
- else if (sourceErrors.length > 0) {
1001
- throw new Error(String(sourceErrors[0].payload.source_error));
639
+ if (!replay.hasMore) return;
640
+ cursor = next;
641
+ after = replay.after;
1002
642
  }
643
+ }
1003
644
 
1004
- // Recovery ranges and media retries remain in the normal feed checkpoint.
1005
- const dirtyBefore = checkpoint.dirty ?? [];
1006
- const dirtyBatch = dirtyBefore.slice(0, MAX_DIRTY_MARKERS_PERSISTED);
1007
- request.dirty_ranges = dirtyBatch.map((marker) => ({
1008
- key: marker.key,
1009
- chat_jid: marker.chat_jid ?? null,
1010
- message_id: marker.message_id ?? null,
1011
- minimum_timestamp: marker.minimum_timestamp ?? null,
1012
- }));
1013
-
1014
- const result = await invokeAdapter<CollectResponse>(
1015
- dispatcher,
1016
- tabId,
1017
- request as unknown as Record<string, unknown>
1018
- );
1019
-
1020
- // History pages come back separately from the recent window so a backfill
1021
- // page can advance its chat cursor without competing for the recent slot.
1022
- const historyMessages = (result.history_pages ?? []).flatMap(
1023
- (page) => page.messages ?? []
1024
- );
1025
- const inScope = (row: Record<string, unknown>) =>
1026
- (request.chat_filter !== "group" || row.is_group === true) &&
1027
- (request.chat_filter !== "individual" || row.is_group !== true) &&
1028
- (request.minimum_timestamp == null || Number(row.timestamp) >= request.minimum_timestamp);
1029
- const buffered = observed.records.filter((row) =>
1030
- !sourceErrors.includes(row) && inScope(row.payload)
1031
- );
1032
- const bufferedIds = new Set(buffered.map((row) => row.payload.id));
1033
- const messages = mergeCollectedMessages(
1034
- [...(result.messages ?? []), ...historyMessages],
1035
- buffered.map((row) => row.payload),
1036
- request.minimum_timestamp
1037
- ).sort((a, b) => Number(bufferedIds.has(b.id)) - Number(bufferedIds.has(a.id)) || a.timestamp - b.timestamp || a.id.localeCompare(b.id))
1038
- .slice(0, request.max_messages);
1039
-
1040
- const emittedIds = new Set(messages.map((message) => message.id));
1041
- const reconciledKeys = new Set(
1042
- (result.dirty_reconciled ?? [])
1043
- .filter(
1044
- (marker) => marker.message_id && emittedIds.has(marker.message_id)
1045
- )
1046
- .map((marker) => marker.key)
1047
- );
1048
-
1049
- const { results: media, nextMedia } = await downloadEligibleMedia(
1050
- dispatcher,
1051
- tabId,
1052
- messages,
1053
- checkpoint.media ?? {}
1054
- );
1055
-
1056
- const events: EventEnvelope[] = messages.map((message) =>
1057
- toEventEnvelope(message, media.get(message.id))
1058
- );
1059
-
1060
- const nextCheckpoint = mergeBrowserCheckpoint(
1061
- checkpoint as unknown as Record<string, unknown>,
1062
- result,
1063
- messages
1064
- );
1065
- // A live burst can consume this run's budget. Retain collection cursors
1066
- // when any collected row was deferred, so backfill cannot skip that page.
1067
- const deferredCollection = mergeCollectedMessages(
1068
- [...(result.messages ?? []), ...historyMessages], [], request.minimum_timestamp
1069
- ).some((row) => !emittedIds.has(row.id));
1070
- if (deferredCollection) {
1071
- nextCheckpoint.head = checkpoint.head;
1072
- nextCheckpoint.backfill = { ...checkpoint.backfill, complete: false };
1073
- }
1074
- nextCheckpoint.source_ack = {
1075
- binding_id: observed.binding_id,
1076
- epoch: observed.epoch,
1077
- records: observed.records
1078
- .filter((row) => sourceErrors.includes(row) || emittedIds.has(String(row.payload.id)) || !inScope(row.payload))
1079
- .map((row) => ({ id: String(row.payload.id), revision: row.revision })),
645
+ private async readMessages(ctx: FeedReadContext<WhatsAppWebConfig>): Promise<FeedReadResult> {
646
+ assertNoOffsetPaging(ctx, "WhatsApp live reads paginate with the returned cursor, not an offset.");
647
+ assertNoSort(ctx, "WhatsApp live reads use source storage order; explicit sorting is not supported.");
648
+ // Source message time cannot represent edits, revokes, or delayed arrivals.
649
+ // Automations subscribe to new-message references and read content by ID.
650
+ assertNoWindow(ctx, "WhatsApp live reads do not support change-time windows; subscribe to message.created and read references by id:<message ID>.");
651
+ const dispatcher = requireBrowser(ctx);
652
+ const tabId = await readyWhatsAppTab(dispatcher);
653
+ const response = await invokeAdapter<{
654
+ results: unknown[];
655
+ nextCursor?: string;
656
+ hasMore: boolean;
657
+ }>(dispatcher, tabId, {
658
+ op: "read_messages",
659
+ input: {
660
+ query: ctx.query,
661
+ cursor: ctx.cursor,
662
+ limit: ctx.limit,
663
+ chat_filter: ctx.config.chat_filter ?? "all",
664
+ },
665
+ });
666
+ return {
667
+ rows: normalizedSearchResults(response.results),
668
+ columns: [
669
+ { name: "id", type: "string" },
670
+ { name: "chat_jid", type: "string" },
671
+ { name: "chat_name", type: "string" },
672
+ { name: "title", type: "string" },
673
+ { name: "text", type: "string" },
674
+ { name: "content_kind", type: "string" },
675
+ { name: "occurred_at", type: "string" },
676
+ { name: "from_me", type: "boolean" },
677
+ { name: "sender_jid", type: "string" },
678
+ { name: "sender_phone", type: "string" },
679
+ { name: "push_name", type: "string" },
680
+ { name: "is_group", type: "boolean" },
681
+ { name: "quoted_id", type: "string" },
682
+ { name: "mentions_me", type: "boolean" },
683
+ ],
684
+ nextCursor: response.nextCursor,
685
+ hasMore: response.hasMore,
1080
686
  };
1081
-
1082
- // Carry forward the markers this run did not reconcile, plus anything the
1083
- // adapter newly quarantined.
1084
- const dirtyByKey = new Map<string, DirtyMarker>();
1085
- for (const marker of dirtyBefore) {
1086
- if (!reconciledKeys.has(marker.key)) dirtyByKey.set(marker.key, marker);
1087
- }
1088
- for (const marker of result.quarantined ?? []) {
1089
- dirtyByKey.set(marker.key, {
1090
- ...marker,
1091
- message_id: marker.message_id ?? null,
1092
- minimum_timestamp: null,
1093
- });
1094
- }
1095
- const dirty: DirtyMarker[] = [...dirtyByKey.values()].slice(
1096
- 0,
1097
- MAX_DIRTY_MARKERS_PERSISTED
1098
- );
1099
- // `mergeBrowserCheckpoint` spreads the prior checkpoint forward, so every
1100
- // one of these fields must be REPLACED, not conditionally set: a marker
1101
- // the adapter just reconciled has to leave the checkpoint, or the next run
1102
- // re-requests it and the list never empties.
1103
- const diagnostics: Record<string, unknown> = {};
1104
- if (dirty.length > 0) {
1105
- nextCheckpoint.dirty = dirty;
1106
- nextCheckpoint.backfill.complete = false;
1107
- const reasons: Record<string, number> = {};
1108
- for (const marker of dirty) {
1109
- const reason = marker.reason ?? "unknown";
1110
- reasons[reason] = (reasons[reason] ?? 0) + 1;
1111
- }
1112
- diagnostics.dirty_reconciliation = {
1113
- pending_count: dirty.length,
1114
- requested_count: dirtyBatch.length,
1115
- reasons: Object.fromEntries(Object.entries(reasons).slice(0, 10)),
1116
- };
1117
- } else {
1118
- nextCheckpoint.dirty = undefined;
1119
- }
1120
-
1121
- const persistedMedia = Object.entries(nextMedia).slice(
1122
- 0,
1123
- MAX_MEDIA_RECORDS_PERSISTED
1124
- );
1125
- nextCheckpoint.media =
1126
- persistedMedia.length > 0
1127
- ? Object.fromEntries(persistedMedia)
1128
- : undefined;
1129
-
1130
- const mediaStatusCounts: Record<string, number> = {};
1131
- for (const record of media.values()) {
1132
- mediaStatusCounts[record.status] =
1133
- (mediaStatusCounts[record.status] ?? 0) + 1;
1134
- }
1135
- if (Object.keys(mediaStatusCounts).length > 0) {
1136
- diagnostics.media_status_counts = mediaStatusCounts;
1137
- }
1138
- nextCheckpoint.diagnostics =
1139
- Object.keys(diagnostics).length > 0 ? diagnostics : undefined;
1140
-
1141
- await ctx.commit(events, nextCheckpoint as unknown as BrowserCheckpoint);
1142
- return { status: "complete" };
1143
687
  }
1144
688
 
1145
689
  async execute(ctx: ActionContext): Promise<ActionResult> {
@@ -1148,7 +692,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
1148
692
  return { success: false, error: `Unknown action: ${action}` };
1149
693
  }
1150
694
  try {
1151
- const dispatcher = requireExtensionDispatcher(ctx);
695
+ const dispatcher = requireBrowser(ctx);
1152
696
  const tabId = await readyWhatsAppTab(dispatcher);
1153
697
  const response = await invokeAdapter<Record<string, unknown>>(
1154
698
  dispatcher,
@@ -1163,9 +707,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
1163
707
  results: normalizedSearchResults(
1164
708
  response.results as unknown[] | undefined
1165
709
  ),
1166
- ...(typeof response.total === "number"
1167
- ? { total: response.total }
1168
- : {}),
1169
710
  ...(typeof response.hasMore === "boolean"
1170
711
  ? { hasMore: response.hasMore }
1171
712
  : {}),
@@ -1173,8 +714,8 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
1173
714
  };
1174
715
  }
1175
716
  // A send that reports no raw WhatsApp key.id did not demonstrably land;
1176
- // fail loudly rather than record a success the message stream will not
1177
- // corroborate on the next sync.
717
+ // fail loudly rather than record a success no message reference will
718
+ // corroborate.
1178
719
  if (action === "send_message" && !response.message_id) {
1179
720
  return {
1180
721
  success: false,