@lobu/runtime-server 22.0.0 → 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 (218) hide show
  1. package/dist/catalogs/connectors.json +1353 -181
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +14 -1
  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 +1185 -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 +3998 -0
  17. package/dist/connectors/takeout-utils.ts +240 -0
  18. package/dist/connectors/tiktok-inbox-page.js +9 -9
  19. package/dist/connectors/tiktok-web-page.js +21 -15
  20. package/dist/connectors/tiktok_web.ts +63 -30
  21. package/dist/connectors/whatsapp-web-adapter.js +64 -564
  22. package/dist/connectors/whatsapp-web-helpers.ts +30 -444
  23. package/dist/connectors/whatsapp-web-identity.ts +20 -6
  24. package/dist/connectors/whatsapp_web.ts +45 -645
  25. package/dist/connectors/x-dm-adapter.js +556 -0
  26. package/dist/connectors/x-identity.ts +31 -2
  27. package/dist/connectors/x.ts +266 -120
  28. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  29. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  30. package/dist/dependencies.bun.lock +41 -41
  31. package/dist/guest.bundle.js +288 -148
  32. package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
  33. package/dist/owletto/dist/assets/{_-CEPl6gU4.js → _-DYUE3ix4.js} +3 -3
  34. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
  35. package/dist/owletto/dist/assets/{_agentId-CBC_SadO.js → _agentId-Cam7Z0N7.js} +2 -2
  36. package/dist/owletto/dist/assets/{_automationId-YTTNksw6.js → _automationId-CXEiKVZJ.js} +2 -2
  37. package/dist/owletto/dist/assets/{_connectorKey._connectionId-fK0h7RAp.js → _connectorKey._connectionId-CS85l61t.js} +2 -2
  38. package/dist/owletto/dist/assets/{_connectorKey.index-C7TPS598.js → _connectorKey.index-clVDIyW0.js} +2 -2
  39. package/dist/owletto/dist/assets/{_conversationId-CEhxlTIo.js → _conversationId-Ci2k-BuN.js} +2 -2
  40. package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BuUzGtVL.js} +2 -2
  41. package/dist/owletto/dist/assets/{_eventId-Cl8GSdjg.js → _eventId-B0662F8h.js} +2 -2
  42. package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
  43. package/dist/owletto/dist/assets/{_owner-cUtGHqSw.js → _owner-dTWkrKsK.js} +3 -3
  44. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
  45. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
  46. package/dist/owletto/dist/assets/{_slug-CU1PuHB9.js → _slug-DQHutM41.js} +2 -2
  47. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
  48. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
  49. package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-w17IFTtf.js} +2 -2
  50. package/dist/owletto/dist/assets/{activity-route-view-DQglkhXU.js → activity-route-view-CMqYiiKM.js} +2 -2
  51. package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-mnTN2AZt.js} +2 -2
  52. package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-Bg3hBfUV.js} +2 -2
  53. package/dist/owletto/dist/assets/{agent-connect-pages-B6uKvT_X.js → agent-connect-pages-B_vrqLVc.js} +2 -2
  54. package/dist/owletto/dist/assets/{agent-editor-form-oUnIYHd7.js → agent-editor-form-hTs7eO_U.js} +2 -2
  55. package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-BOrCXcAl.js} +2 -2
  56. package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-Dqcvky-k.js} +2 -2
  57. package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-BOo_4r_4.js} +2 -2
  58. package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-CCdvtlmH.js} +2 -2
  59. package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-BUxIswuq.js} +2 -2
  60. package/dist/owletto/dist/assets/{agent-subpage-shell-B3K_jPYR.js → agent-subpage-shell-D92imvSt.js} +2 -2
  61. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
  62. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
  63. package/dist/owletto/dist/assets/{agents-workbench-CMyk4PI7.js → agents-workbench-Bt5QCYQ7.js} +2 -2
  64. package/dist/owletto/dist/assets/{app._appId-DH1Qutz6.js → app._appId-CKv7_squ.js} +2 -2
  65. package/dist/owletto/dist/assets/{automation-detail-content-CEDNboId.js → automation-detail-content-vUwVumXf.js} +2 -2
  66. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
  67. package/dist/owletto/dist/assets/{callback-CU-hb8JB.js → callback-BRgcL8gz.js} +2 -2
  68. package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-Djgp00r_.js} +2 -2
  69. package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-BYUZnyMp.js} +2 -2
  70. package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-D3Zbjxin.js} +2 -2
  71. package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-DHeyRGZI.js} +2 -2
  72. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
  73. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
  74. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
  75. package/dist/owletto/dist/assets/{connected._clientId.activity-DQWcUqKM.js → connected._clientId.activity-Ckdz6I0y.js} +2 -2
  76. package/dist/owletto/dist/assets/{connected._clientId.index-BC3R303A.js → connected._clientId.index-CNxafNeo.js} +2 -2
  77. package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-C3XXFEqh.js} +2 -2
  78. package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-CIJJLDP8.js} +2 -2
  79. package/dist/owletto/dist/assets/{connections-browser-Cnv2iBbZ.js → connections-browser-CKZjzRz6.js} +2 -2
  80. package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-8-d8hl10.js} +2 -2
  81. package/dist/owletto/dist/assets/{connector-scope-lists-BKDetNDc.js → connector-scope-lists-CadPVsI3.js} +2 -2
  82. package/dist/owletto/dist/assets/{connectors-BJnk1z_2.js → connectors-lvLJ30lo.js} +2 -2
  83. package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-CdSvVCgx.js} +2 -2
  84. package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BdXoZAfc.js} +2 -2
  85. package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-CYvgWCuv.js} +2 -2
  86. package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
  87. package/dist/owletto/dist/assets/{create-JRFM8mMf.js → create-B0qhrrX4.js} +2 -2
  88. package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
  89. package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
  90. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
  91. package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-n4qGUraE.js} +2 -2
  92. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
  93. package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-RvUdVkj3.js} +2 -2
  94. package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js} +2 -2
  95. package/dist/owletto/dist/assets/{device-CntqYW65.js → device-CPU6CjkJ.js} +2 -2
  96. package/dist/owletto/dist/assets/{device-pin-tombstone-Bz4JHHMK.js → device-pin-tombstone-CrjG7gPo.js} +2 -2
  97. package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js} +2 -2
  98. package/dist/owletto/dist/assets/{entity-options-UJs64GdQ.js → entity-options-uXjgT7y9.js} +2 -2
  99. package/dist/owletto/dist/assets/{entity-page-Djz6T50J.js → entity-page-Dc0LGr5U.js} +2 -2
  100. package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js} +2 -2
  101. package/dist/owletto/dist/assets/{event-detail-04qOUGIP.js → event-detail-ve2d6Gbb.js} +2 -2
  102. package/dist/owletto/dist/assets/{events-feed-fucGZSJR.js → events-feed-BtvhZF1f.js} +2 -2
  103. package/dist/owletto/dist/assets/{filter-editors-DCQgGLyR.js → filter-editors-Cj-v6NtH.js} +2 -2
  104. package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-DqpH99np.js} +2 -2
  105. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
  106. package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
  107. package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-B9uPN6FC.js} +2 -2
  108. package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-BQVliQW1.js} +2 -2
  109. package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
  110. package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
  111. package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
  112. package/dist/owletto/dist/assets/{index-_oPeVpL_.js → index-Cr5hwh-C.js} +66 -66
  113. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
  114. package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
  115. package/dist/owletto/dist/assets/{index-D3s8rhG9.js → index-DVk7Ug0d.js} +2 -2
  116. package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
  117. package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-Hio-HRfo.js} +2 -2
  118. package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ICgKp3YK.js} +2 -2
  119. package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
  120. package/dist/owletto/dist/assets/{index-BOzuAbvi.js → index-n7sTbNv4.js} +2 -2
  121. package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
  122. package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DBoag_OS.js} +2 -2
  123. package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-C_GuoxAH.js} +2 -2
  124. package/dist/owletto/dist/assets/{login-QHdxqX-4.js → login-Ci6ixHuL.js} +2 -2
  125. package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-CLGgeZB7.js} +2 -2
  126. package/dist/owletto/dist/assets/{member-scope-gate-CFbrq1by.js → member-scope-gate-B44INDPY.js} +2 -2
  127. package/dist/owletto/dist/assets/{memory-browse-page-IrIXuZTF.js → memory-browse-page-DyQiRvzl.js} +2 -2
  128. package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-dAbDgJvx.js} +2 -2
  129. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
  130. package/dist/owletto/dist/assets/{new-BWo8_Pms.js → new-BUb7AnEW.js} +2 -2
  131. package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-BkdULx2r.js} +2 -2
  132. package/dist/owletto/dist/assets/{new-DpmDXmFI.js → new-CHOr-EcI.js} +2 -2
  133. package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-BxsjwgdH.js} +2 -2
  134. package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-gxGeDjIV.js} +2 -2
  135. package/dist/owletto/dist/assets/{peek-pane-content-B2AFNTzP.js → peek-pane-content-CHoQHe2H.js} +2 -2
  136. package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-aPHaKLec.js} +2 -2
  137. package/dist/owletto/dist/assets/{proposal-review-shell-DKKGu4Ww.js → proposal-review-shell-UcZr87_Q.js} +2 -2
  138. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
  139. package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-D-65Pgu-.js} +2 -2
  140. package/dist/owletto/dist/assets/{record-activity-CvgZyCmw.js → record-activity-CBXH6v1d.js} +2 -2
  141. package/dist/owletto/dist/assets/{renderer-BL6VcwQH.js → renderer-mEDnVW0O.js} +2 -2
  142. package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-uX_V6bip.js} +2 -2
  143. package/dist/owletto/dist/assets/{runs-BWtc5rmc.js → runs-C0rCgGwX.js} +2 -2
  144. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
  145. package/dist/owletto/dist/assets/{runs-table-DxIiqrSk.js → runs-table-syPJ6r6T.js} +2 -2
  146. package/dist/owletto/dist/assets/{settings-Crxlwps-.js → settings-9NkNA1G1.js} +2 -2
  147. package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
  148. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
  149. package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-CPyzlfD1.js} +2 -2
  150. package/dist/owletto/dist/assets/{status-dot-C5KDvvm9.js → status-dot-B-EWMgq6.js} +2 -2
  151. package/dist/owletto/dist/assets/{tabs-B4Er9hJj.js → tabs-DqIIkCX-.js} +2 -2
  152. package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-By8RZyKW.js} +2 -2
  153. package/dist/owletto/dist/assets/{view-param-filters-Cylutoy1.js → view-param-filters-CqLZQrnO.js} +2 -2
  154. package/dist/owletto/dist/index.html +1 -1
  155. package/dist/server-main.bundle.mjs +11447 -10762
  156. package/npm-shrinkwrap.json +160 -160
  157. package/package.json +1 -1
  158. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  159. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  160. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  161. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  162. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  163. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  164. package/vendor/connector-sdk/dist/index.js +2 -0
  165. package/vendor/connector-sdk/package.json +9 -1
  166. package/vendor/core/dist/capabilities.d.ts +1 -1
  167. package/vendor/core/dist/capabilities.js +0 -1
  168. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  169. package/vendor/core/dist/connector-query-errors.js +41 -1
  170. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  171. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  172. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  173. package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
  174. package/vendor/core/dist/contracts/worker/protocol.js +9 -61
  175. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  176. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  177. package/vendor/core/dist/index.d.ts +2 -1
  178. package/vendor/core/dist/index.js +1 -0
  179. package/vendor/core/dist/logger.js +10 -25
  180. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  181. package/vendor/core/dist/worker/wire.d.ts +0 -10
  182. package/vendor/core/package.json +6 -6
  183. package/vendor/views/package.json +1 -1
  184. package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
  185. package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
  186. package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
  187. package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
  188. package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
  189. package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
  190. package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
  191. package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
  192. package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
  193. package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
  194. package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
  195. package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
  196. package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
  197. package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
  198. package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
  199. package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
  200. package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
  201. package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
  202. package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
  203. package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
  204. package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
  205. package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
  206. package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
  207. package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
  208. package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
  209. package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
  210. package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
  211. package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
  212. package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
  213. package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
  214. package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
  215. package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
  216. package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
  217. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  218. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
@@ -1737,6 +1737,7 @@
1737
1737
  "eventKinds": {
1738
1738
  "thread": {
1739
1739
  "description": "A Gmail email thread",
1740
+ "updatedEvent": true,
1740
1741
  "metadataSchema": {
1741
1742
  "type": "object",
1742
1743
  "properties": {
@@ -18836,6 +18837,1230 @@
18836
18837
  "login_enabled": false
18837
18838
  }
18838
18839
  },
18840
+ {
18841
+ "id": "linkedin",
18842
+ "name": "LinkedIn",
18843
+ "version": "3.20.0",
18844
+ "description": "Read LinkedIn feeds, notifications, and recent inbox messages through paired Chrome. Subscribe to source changes, answer direct messages, and prepare message, post, or comment drafts for human submission. Also supports local LinkedIn Data Export CSV files.",
18845
+ "detail": {
18846
+ "source_path": "linkedin.ts",
18847
+ "auth_schema": {
18848
+ "methods": [
18849
+ {
18850
+ "type": "browser",
18851
+ "mode": "live"
18852
+ },
18853
+ {
18854
+ "type": "none",
18855
+ "label": "Local data export"
18856
+ },
18857
+ {
18858
+ "type": "oauth",
18859
+ "provider": "linkedin",
18860
+ "requiredScopes": [],
18861
+ "loginScopes": [
18862
+ "openid",
18863
+ "profile",
18864
+ "email"
18865
+ ],
18866
+ "loginProvisioning": {
18867
+ "autoCreateConnection": false
18868
+ },
18869
+ "authorizationUrl": "https://www.linkedin.com/oauth/v2/authorization",
18870
+ "tokenUrl": "https://www.linkedin.com/oauth/v2/accessToken",
18871
+ "userinfoUrl": "https://api.linkedin.com/v2/userinfo",
18872
+ "tokenEndpointAuthMethod": "client_secret_post",
18873
+ "clientIdKey": "LINKEDIN_CLIENT_ID",
18874
+ "clientSecretKey": "LINKEDIN_CLIENT_SECRET",
18875
+ "description": "Identity-only LinkedIn sign-in. Feeds use the browser or local exports.",
18876
+ "setupInstructions": "Enable Sign In with LinkedIn using OpenID Connect in your LinkedIn app. Register /api/auth/oauth2/callback/linkedin on your Lobu origin for sign-in, then enter the client ID and client secret."
18877
+ }
18878
+ ]
18879
+ },
18880
+ "browser": {
18881
+ "authMethods": [
18882
+ "browser"
18883
+ ],
18884
+ "origins": [
18885
+ "https://www.linkedin.com"
18886
+ ],
18887
+ "accountProbe": {
18888
+ "url": "https://www.linkedin.com/feed/foryou/",
18889
+ "expression": "(async () => {\n const raw = document.cookie.split('; ').find(cookie => cookie.startsWith('JSESSIONID='));\n if (!raw) return null;\n const csrf = decodeURIComponent(raw.slice(11)).replace(/^\"|\"$/g, '');\n const response = await fetch('/voyager/api/me', {\n credentials: 'include',\n headers: { 'csrf-token': csrf, 'x-restli-protocol-version': '2.0.0' },\n });\n if (response.status === 401 || response.status === 403) return null;\n if (!response.ok) throw new Error('LinkedIn account check failed (HTTP ' + response.status + ')');\n const self = await response.json();\n const accountId = self.miniProfile?.entityUrn;\n return typeof accountId === 'string' && accountId ? { accountId } : null;\n })()"
18890
+ }
18891
+ },
18892
+ "webhook": null,
18893
+ "feeds_schema": {
18894
+ "notifications": {
18895
+ "key": "notifications",
18896
+ "name": "Notifications",
18897
+ "description": "Read notification content and links without marking them seen. Subscriptions check once per minute while the paired browser is online; grouped notification content changes activate Automations, and catch-up beyond the scan budget reports a source gap. Exact source timestamps are unavailable.",
18898
+ "webhook": {
18899
+ "mode": "trigger",
18900
+ "events": [
18901
+ "notification.changed",
18902
+ "source.gap"
18903
+ ]
18904
+ },
18905
+ "eventKinds": {
18906
+ "notification.changed": {
18907
+ "description": "A new or meaningfully changed LinkedIn notification"
18908
+ },
18909
+ "source.gap": {
18910
+ "description": "Catch-up scanned its page budget without reaching a known notification"
18911
+ }
18912
+ },
18913
+ "operations": [
18914
+ "read"
18915
+ ]
18916
+ },
18917
+ "live_messages": {
18918
+ "key": "live_messages",
18919
+ "name": "Live Messages",
18920
+ "description": "Read recent messages from inbox conversations without marking them seen. The cursor pages conversations and their recent message pages, not a full history export; `id:<message URN>` reads one recent message back. Rows carry the conversation's thread_id and full conversation_id, whether it is a group, the sender's member id, slug and name, and the message's content_kind; a company page inbox's rows also carry the visitor's topic when LinkedIn shows one. The `inbox` setting reads a company page's inbox the signed-in member administers instead of the member's own. Subscriptions check once per minute while the browser is online and report catch-up gaps.",
18921
+ "configSchema": {
18922
+ "type": "object",
18923
+ "properties": {
18924
+ "inbox": {
18925
+ "type": "string",
18926
+ "pattern": "^(?:me|urn:li:fsd_pageMailbox:[0-9]+)$",
18927
+ "default": "me",
18928
+ "description": "Whose inbox to read: \"me\" (default) for the signed-in member, or a company page's mailbox URN (urn:li:fsd_pageMailbox:<number>, the mailboxUrn the page's admin inbox at /company/<id>/admin/inbox/ requests; it differs from the company id). The signed-in member must administer the page. Changing it restarts the feed's subscription from a fresh baseline."
18929
+ }
18930
+ }
18931
+ },
18932
+ "webhook": {
18933
+ "mode": "trigger",
18934
+ "events": [
18935
+ "message.created",
18936
+ "source.gap"
18937
+ ]
18938
+ },
18939
+ "eventKinds": {
18940
+ "message.created": {
18941
+ "description": "A new LinkedIn inbox message"
18942
+ },
18943
+ "source.gap": {
18944
+ "description": "A conversation's recent message page may hide older catch-up messages"
18945
+ }
18946
+ },
18947
+ "operations": [
18948
+ "read"
18949
+ ]
18950
+ },
18951
+ "home_feed": {
18952
+ "key": "home_feed",
18953
+ "name": "Home Feed",
18954
+ "description": "Your personalized LinkedIn home feed.",
18955
+ "configSchema": {
18956
+ "type": "object",
18957
+ "properties": {
18958
+ "max_scrolls": {
18959
+ "type": "integer",
18960
+ "minimum": 1,
18961
+ "maximum": 30,
18962
+ "default": 8,
18963
+ "description": "Maximum scroll iterations for the home feed (default: 8). Upper end of the range when min_scrolls is set."
18964
+ },
18965
+ "min_scrolls": {
18966
+ "type": "integer",
18967
+ "minimum": 1,
18968
+ "maximum": 30,
18969
+ "description": "Optional lower bound. When set below max_scrolls, each sync picks a uniform random scroll count in [min_scrolls, max_scrolls]."
18970
+ }
18971
+ }
18972
+ },
18973
+ "eventKinds": {
18974
+ "post": {
18975
+ "description": "A post from your personalized LinkedIn home feed",
18976
+ "attributions": [
18977
+ {
18978
+ "name": "author",
18979
+ "role": "authored_by",
18980
+ "autoCreate": true,
18981
+ "target": {
18982
+ "entityType": "person",
18983
+ "titlePath": "author_name",
18984
+ "identities": [
18985
+ {
18986
+ "namespace": "linkedin_slug",
18987
+ "eventPath": "metadata.author_linkedin_slug"
18988
+ }
18989
+ ]
18990
+ },
18991
+ "traits": {
18992
+ "linkedin_url": {
18993
+ "eventPath": "metadata.author_profile_url",
18994
+ "mergeStrategy": "prefer_non_empty"
18995
+ }
18996
+ }
18997
+ },
18998
+ {
18999
+ "name": "engager",
19000
+ "role": "performed_by",
19001
+ "autoCreate": true,
19002
+ "target": {
19003
+ "entityType": "person",
19004
+ "titlePath": "metadata.social_actor",
19005
+ "identities": [
19006
+ {
19007
+ "namespace": "linkedin_slug",
19008
+ "eventPath": "metadata.social_actor_slug"
19009
+ }
19010
+ ]
19011
+ },
19012
+ "traits": {
19013
+ "linkedin_url": {
19014
+ "eventPath": "metadata.social_actor_profile_url",
19015
+ "mergeStrategy": "prefer_non_empty"
19016
+ }
19017
+ }
19018
+ }
19019
+ ],
19020
+ "metadataSchema": {
19021
+ "type": "object",
19022
+ "properties": {
19023
+ "author": {
19024
+ "type": "string"
19025
+ },
19026
+ "author_linkedin_slug": {
19027
+ "type": "string"
19028
+ },
19029
+ "author_profile_url": {
19030
+ "type": "string"
19031
+ },
19032
+ "social_actor": {
19033
+ "type": "string",
19034
+ "description": "Member whose engagement surfaced this post (likes/commented/reposted banners)."
19035
+ },
19036
+ "social_action": {
19037
+ "type": "string",
19038
+ "description": "Engagement verb: like, love, celebrate, support, insightful, funny, comment, repost."
19039
+ },
19040
+ "social_actor_slug": {
19041
+ "type": "string"
19042
+ },
19043
+ "social_actor_profile_url": {
19044
+ "type": "string"
19045
+ },
19046
+ "reactions": {
19047
+ "type": "number"
19048
+ },
19049
+ "comments": {
19050
+ "type": "number"
19051
+ },
19052
+ "reposts": {
19053
+ "type": "number"
19054
+ }
19055
+ }
19056
+ }
19057
+ },
19058
+ "comment": {
19059
+ "description": "A complete comment or reply on a personalized feed post",
19060
+ "attributions": [
19061
+ {
19062
+ "name": "commenter",
19063
+ "role": "authored_by",
19064
+ "autoCreate": true,
19065
+ "target": {
19066
+ "entityType": "person",
19067
+ "titlePath": "author_name",
19068
+ "identities": [
19069
+ {
19070
+ "namespace": "linkedin_slug",
19071
+ "eventPath": "metadata.author_linkedin_slug"
19072
+ }
19073
+ ]
19074
+ },
19075
+ "traits": {
19076
+ "linkedin_url": {
19077
+ "eventPath": "metadata.author_profile_url",
19078
+ "mergeStrategy": "prefer_non_empty"
19079
+ }
19080
+ }
19081
+ },
19082
+ {
19083
+ "name": "post_author",
19084
+ "role": "about",
19085
+ "autoCreate": true,
19086
+ "target": {
19087
+ "entityType": "person",
19088
+ "titlePath": "metadata.parent_author",
19089
+ "identities": [
19090
+ {
19091
+ "namespace": "linkedin_slug",
19092
+ "eventPath": "metadata.parent_author_linkedin_slug"
19093
+ }
19094
+ ]
19095
+ },
19096
+ "traits": {
19097
+ "linkedin_url": {
19098
+ "eventPath": "metadata.parent_author_profile_url",
19099
+ "mergeStrategy": "prefer_non_empty"
19100
+ }
19101
+ }
19102
+ },
19103
+ {
19104
+ "name": "parent_comment_author",
19105
+ "role": "mentions",
19106
+ "autoCreate": true,
19107
+ "target": {
19108
+ "entityType": "person",
19109
+ "titlePath": "metadata.parent_comment_author",
19110
+ "identities": [
19111
+ {
19112
+ "namespace": "linkedin_slug",
19113
+ "eventPath": "metadata.parent_comment_author_linkedin_slug"
19114
+ }
19115
+ ]
19116
+ },
19117
+ "traits": {
19118
+ "linkedin_url": {
19119
+ "eventPath": "metadata.parent_comment_author_profile_url",
19120
+ "mergeStrategy": "prefer_non_empty"
19121
+ }
19122
+ }
19123
+ }
19124
+ ],
19125
+ "metadataSchema": {
19126
+ "type": "object",
19127
+ "properties": {
19128
+ "author": {
19129
+ "type": "string"
19130
+ },
19131
+ "author_linkedin_slug": {
19132
+ "type": "string"
19133
+ },
19134
+ "author_profile_url": {
19135
+ "type": "string"
19136
+ },
19137
+ "parent_post_origin_id": {
19138
+ "type": "string"
19139
+ },
19140
+ "parent_author": {
19141
+ "type": "string"
19142
+ },
19143
+ "parent_author_linkedin_slug": {
19144
+ "type": "string"
19145
+ },
19146
+ "parent_author_profile_url": {
19147
+ "type": "string"
19148
+ },
19149
+ "comment_urn": {
19150
+ "type": "string"
19151
+ },
19152
+ "comment_id": {
19153
+ "type": "string"
19154
+ },
19155
+ "parent_activity_id": {
19156
+ "type": "string"
19157
+ },
19158
+ "parent_activity_namespace": {
19159
+ "type": "string"
19160
+ },
19161
+ "parent_comment_origin_id": {
19162
+ "type": "string"
19163
+ },
19164
+ "parent_comment_id": {
19165
+ "type": "string"
19166
+ },
19167
+ "parent_comment_author": {
19168
+ "type": "string"
19169
+ },
19170
+ "parent_comment_author_linkedin_slug": {
19171
+ "type": "string"
19172
+ },
19173
+ "parent_comment_author_profile_url": {
19174
+ "type": "string"
19175
+ },
19176
+ "is_reply": {
19177
+ "type": "boolean"
19178
+ },
19179
+ "reactions": {
19180
+ "type": "number"
19181
+ },
19182
+ "comments": {
19183
+ "type": "number"
19184
+ },
19185
+ "reposts": {
19186
+ "type": "number"
19187
+ }
19188
+ }
19189
+ }
19190
+ }
19191
+ },
19192
+ "operations": [
19193
+ "sync"
19194
+ ]
19195
+ },
19196
+ "company_updates": {
19197
+ "key": "company_updates",
19198
+ "name": "Company Updates",
19199
+ "description": "Posts and updates from the company LinkedIn page.",
19200
+ "configSchema": {
19201
+ "type": "object",
19202
+ "required": [
19203
+ "company_url"
19204
+ ],
19205
+ "properties": {
19206
+ "company_url": {
19207
+ "type": "string",
19208
+ "description": "LinkedIn company page URL (e.g., \"https://www.linkedin.com/company/openai\")"
19209
+ },
19210
+ "max_scrolls": {
19211
+ "type": "integer",
19212
+ "minimum": 1,
19213
+ "maximum": 20,
19214
+ "default": 5,
19215
+ "description": "Maximum scroll iterations for pagination (default: 5)"
19216
+ }
19217
+ }
19218
+ },
19219
+ "eventKinds": {
19220
+ "post": {
19221
+ "description": "A company LinkedIn post",
19222
+ "attributions": [
19223
+ {
19224
+ "role": "authored_by",
19225
+ "autoCreate": true,
19226
+ "target": {
19227
+ "entityType": "person",
19228
+ "titlePath": "author_name",
19229
+ "identities": [
19230
+ {
19231
+ "namespace": "linkedin_member_id",
19232
+ "eventPath": "metadata.author_member_id"
19233
+ },
19234
+ {
19235
+ "namespace": "linkedin_slug",
19236
+ "eventPath": "metadata.author_linkedin_slug"
19237
+ }
19238
+ ]
19239
+ },
19240
+ "traits": {
19241
+ "linkedin_headline": {
19242
+ "eventPath": "metadata.author_headline",
19243
+ "mergeStrategy": "prefer_non_empty"
19244
+ },
19245
+ "last_linkedin_post_at": {
19246
+ "eventPath": "occurred_at",
19247
+ "mergeStrategy": "overwrite"
19248
+ }
19249
+ }
19250
+ }
19251
+ ],
19252
+ "metadataSchema": {
19253
+ "type": "object",
19254
+ "properties": {
19255
+ "author_headline": {
19256
+ "type": "string"
19257
+ },
19258
+ "author_member_id": {
19259
+ "type": "string"
19260
+ },
19261
+ "author_linkedin_slug": {
19262
+ "type": "string"
19263
+ },
19264
+ "likes": {
19265
+ "type": "number"
19266
+ },
19267
+ "comments": {
19268
+ "type": "number"
19269
+ },
19270
+ "shares": {
19271
+ "type": "number"
19272
+ }
19273
+ }
19274
+ }
19275
+ }
19276
+ },
19277
+ "operations": [
19278
+ "sync"
19279
+ ]
19280
+ },
19281
+ "jobs": {
19282
+ "key": "jobs",
19283
+ "name": "Job Listings",
19284
+ "description": "Open job positions (hiring velocity signal).",
19285
+ "configSchema": {
19286
+ "type": "object",
19287
+ "required": [
19288
+ "company_url"
19289
+ ],
19290
+ "properties": {
19291
+ "company_url": {
19292
+ "type": "string",
19293
+ "description": "LinkedIn company page URL (e.g., \"https://www.linkedin.com/company/openai\")"
19294
+ },
19295
+ "max_scrolls": {
19296
+ "type": "integer",
19297
+ "minimum": 1,
19298
+ "maximum": 10,
19299
+ "default": 3,
19300
+ "description": "Maximum scroll iterations for job listings (default: 3)"
19301
+ }
19302
+ }
19303
+ },
19304
+ "eventKinds": {
19305
+ "job_posting": {
19306
+ "description": "An open job listing",
19307
+ "metadataSchema": {
19308
+ "type": "object",
19309
+ "properties": {
19310
+ "location": {
19311
+ "type": "string"
19312
+ }
19313
+ }
19314
+ }
19315
+ }
19316
+ },
19317
+ "operations": [
19318
+ "sync"
19319
+ ]
19320
+ },
19321
+ "messages": {
19322
+ "key": "messages",
19323
+ "name": "Messages",
19324
+ "configSchema": {
19325
+ "type": "object",
19326
+ "properties": {
19327
+ "takeout_dir": {
19328
+ "type": "string",
19329
+ "description": "Path to the LinkedIn Data Export folder."
19330
+ },
19331
+ "batch_size": {
19332
+ "type": "integer",
19333
+ "minimum": 1,
19334
+ "maximum": 5000,
19335
+ "default": 1000,
19336
+ "description": "Maximum events to emit per sync run."
19337
+ }
19338
+ }
19339
+ },
19340
+ "eventKinds": {
19341
+ "message": {
19342
+ "description": "A LinkedIn direct message",
19343
+ "attributions": [
19344
+ {
19345
+ "role": "authored_by",
19346
+ "autoCreate": true,
19347
+ "target": {
19348
+ "entityType": "person",
19349
+ "titlePath": "metadata.from",
19350
+ "identities": [
19351
+ {
19352
+ "namespace": "linkedin_slug",
19353
+ "eventPath": "metadata.sender_linkedin_slug"
19354
+ }
19355
+ ]
19356
+ },
19357
+ "traits": {
19358
+ "linkedin_url": {
19359
+ "eventPath": "metadata.sender_profile_url",
19360
+ "mergeStrategy": "prefer_non_empty"
19361
+ },
19362
+ "last_linkedin_message_at": {
19363
+ "eventPath": "occurred_at",
19364
+ "mergeStrategy": "overwrite"
19365
+ }
19366
+ }
19367
+ }
19368
+ ]
19369
+ }
19370
+ },
19371
+ "operations": [
19372
+ "sync"
19373
+ ]
19374
+ },
19375
+ "connections": {
19376
+ "key": "connections",
19377
+ "name": "Connections",
19378
+ "configSchema": {
19379
+ "type": "object",
19380
+ "properties": {
19381
+ "takeout_dir": {
19382
+ "type": "string",
19383
+ "description": "Path to the LinkedIn Data Export folder."
19384
+ },
19385
+ "batch_size": {
19386
+ "type": "integer",
19387
+ "minimum": 1,
19388
+ "maximum": 5000,
19389
+ "default": 1000,
19390
+ "description": "Maximum events to emit per sync run."
19391
+ }
19392
+ }
19393
+ },
19394
+ "eventKinds": {
19395
+ "connection": {
19396
+ "description": "A first-degree LinkedIn connection",
19397
+ "attributions": [
19398
+ {
19399
+ "role": "about",
19400
+ "autoCreate": true,
19401
+ "target": {
19402
+ "entityType": "person",
19403
+ "titlePath": "author_name",
19404
+ "identities": [
19405
+ {
19406
+ "namespace": "linkedin_slug",
19407
+ "eventPath": "metadata.linkedin_slug"
19408
+ },
19409
+ {
19410
+ "namespace": "email",
19411
+ "eventPath": "metadata.email"
19412
+ }
19413
+ ]
19414
+ },
19415
+ "traits": {
19416
+ "linkedin_url": {
19417
+ "eventPath": "metadata.linkedin_url",
19418
+ "mergeStrategy": "prefer_non_empty"
19419
+ },
19420
+ "company": {
19421
+ "eventPath": "metadata.company",
19422
+ "mergeStrategy": "prefer_non_empty"
19423
+ },
19424
+ "position": {
19425
+ "eventPath": "metadata.position",
19426
+ "mergeStrategy": "prefer_non_empty"
19427
+ }
19428
+ }
19429
+ }
19430
+ ]
19431
+ }
19432
+ },
19433
+ "operations": [
19434
+ "sync"
19435
+ ]
19436
+ },
19437
+ "invitations": {
19438
+ "key": "invitations",
19439
+ "name": "Invitations",
19440
+ "configSchema": {
19441
+ "type": "object",
19442
+ "properties": {
19443
+ "takeout_dir": {
19444
+ "type": "string",
19445
+ "description": "Path to the LinkedIn Data Export folder."
19446
+ },
19447
+ "batch_size": {
19448
+ "type": "integer",
19449
+ "minimum": 1,
19450
+ "maximum": 5000,
19451
+ "default": 1000,
19452
+ "description": "Maximum events to emit per sync run."
19453
+ }
19454
+ }
19455
+ },
19456
+ "operations": [
19457
+ "sync"
19458
+ ]
19459
+ },
19460
+ "applied_jobs": {
19461
+ "key": "applied_jobs",
19462
+ "name": "Applied Jobs",
19463
+ "description": "Your own applied/saved job postings from the LinkedIn Data Export.",
19464
+ "configSchema": {
19465
+ "type": "object",
19466
+ "properties": {
19467
+ "takeout_dir": {
19468
+ "type": "string",
19469
+ "description": "Path to the LinkedIn Data Export folder."
19470
+ },
19471
+ "batch_size": {
19472
+ "type": "integer",
19473
+ "minimum": 1,
19474
+ "maximum": 5000,
19475
+ "default": 1000,
19476
+ "description": "Maximum events to emit per sync run."
19477
+ }
19478
+ }
19479
+ },
19480
+ "operations": [
19481
+ "sync"
19482
+ ]
19483
+ },
19484
+ "profile": {
19485
+ "key": "profile",
19486
+ "name": "Profile",
19487
+ "configSchema": {
19488
+ "type": "object",
19489
+ "properties": {
19490
+ "takeout_dir": {
19491
+ "type": "string",
19492
+ "description": "Path to the LinkedIn Data Export folder."
19493
+ },
19494
+ "batch_size": {
19495
+ "type": "integer",
19496
+ "minimum": 1,
19497
+ "maximum": 5000,
19498
+ "default": 1000,
19499
+ "description": "Maximum events to emit per sync run."
19500
+ }
19501
+ }
19502
+ },
19503
+ "operations": [
19504
+ "sync"
19505
+ ]
19506
+ },
19507
+ "companies": {
19508
+ "key": "companies",
19509
+ "name": "Company Follows",
19510
+ "configSchema": {
19511
+ "type": "object",
19512
+ "properties": {
19513
+ "takeout_dir": {
19514
+ "type": "string",
19515
+ "description": "Path to the LinkedIn Data Export folder."
19516
+ },
19517
+ "batch_size": {
19518
+ "type": "integer",
19519
+ "minimum": 1,
19520
+ "maximum": 5000,
19521
+ "default": 1000,
19522
+ "description": "Maximum events to emit per sync run."
19523
+ }
19524
+ }
19525
+ },
19526
+ "operations": [
19527
+ "sync"
19528
+ ]
19529
+ },
19530
+ "learning": {
19531
+ "key": "learning",
19532
+ "name": "Learning",
19533
+ "configSchema": {
19534
+ "type": "object",
19535
+ "properties": {
19536
+ "takeout_dir": {
19537
+ "type": "string",
19538
+ "description": "Path to the LinkedIn Data Export folder."
19539
+ },
19540
+ "batch_size": {
19541
+ "type": "integer",
19542
+ "minimum": 1,
19543
+ "maximum": 5000,
19544
+ "default": 1000,
19545
+ "description": "Maximum events to emit per sync run."
19546
+ }
19547
+ }
19548
+ },
19549
+ "operations": [
19550
+ "sync"
19551
+ ]
19552
+ },
19553
+ "events": {
19554
+ "key": "events",
19555
+ "name": "Events",
19556
+ "configSchema": {
19557
+ "type": "object",
19558
+ "properties": {
19559
+ "takeout_dir": {
19560
+ "type": "string",
19561
+ "description": "Path to the LinkedIn Data Export folder."
19562
+ },
19563
+ "batch_size": {
19564
+ "type": "integer",
19565
+ "minimum": 1,
19566
+ "maximum": 5000,
19567
+ "default": 1000,
19568
+ "description": "Maximum events to emit per sync run."
19569
+ }
19570
+ }
19571
+ },
19572
+ "operations": [
19573
+ "sync"
19574
+ ]
19575
+ },
19576
+ "endorsements": {
19577
+ "key": "endorsements",
19578
+ "name": "Endorsements and Recommendations",
19579
+ "configSchema": {
19580
+ "type": "object",
19581
+ "properties": {
19582
+ "takeout_dir": {
19583
+ "type": "string",
19584
+ "description": "Path to the LinkedIn Data Export folder."
19585
+ },
19586
+ "batch_size": {
19587
+ "type": "integer",
19588
+ "minimum": 1,
19589
+ "maximum": 5000,
19590
+ "default": 1000,
19591
+ "description": "Maximum events to emit per sync run."
19592
+ }
19593
+ }
19594
+ },
19595
+ "operations": [
19596
+ "sync"
19597
+ ]
19598
+ },
19599
+ "media": {
19600
+ "key": "media",
19601
+ "name": "Rich Media",
19602
+ "configSchema": {
19603
+ "type": "object",
19604
+ "properties": {
19605
+ "takeout_dir": {
19606
+ "type": "string",
19607
+ "description": "Path to the LinkedIn Data Export folder."
19608
+ },
19609
+ "batch_size": {
19610
+ "type": "integer",
19611
+ "minimum": 1,
19612
+ "maximum": 5000,
19613
+ "default": 1000,
19614
+ "description": "Maximum events to emit per sync run."
19615
+ }
19616
+ }
19617
+ },
19618
+ "operations": [
19619
+ "sync"
19620
+ ]
19621
+ }
19622
+ },
19623
+ "actions_schema": {
19624
+ "set_like": {
19625
+ "key": "set_like",
19626
+ "name": "Set like",
19627
+ "kind": "write",
19628
+ "description": "Set the Like reaction on one exact LinkedIn post and verify it after reload. Already-matching posts are unchanged. Preserves other reaction types. Never comments or posts; selection and budgets belong to the Automation.",
19629
+ "annotations": {
19630
+ "openWorldHint": true,
19631
+ "destructiveHint": false,
19632
+ "idempotentHint": true
19633
+ },
19634
+ "inputSchema": {
19635
+ "type": "object",
19636
+ "required": [
19637
+ "post_url",
19638
+ "liked"
19639
+ ],
19640
+ "properties": {
19641
+ "post_url": {
19642
+ "type": "string",
19643
+ "format": "uri"
19644
+ },
19645
+ "liked": {
19646
+ "type": "boolean"
19647
+ }
19648
+ },
19649
+ "additionalProperties": false
19650
+ }
19651
+ },
19652
+ "send_message": {
19653
+ "key": "send_message",
19654
+ "name": "Send direct message reply",
19655
+ "kind": "write",
19656
+ "description": "Send a text reply into an exact existing LinkedIn direct-message conversation and confirm it appears there. Pass a member-inbox row's thread_id, or a row's full conversation_id to reply from the inbox the message came from (a company page the signed-in member administers). This direct send is approved only for answering direct messages on accounts the owner operates; group conversations are refused, and posts, comments and other messages stay draft-only through prepare_message, prepare_post and prepare_comment. A retry with the same idempotency_key returns the earlier message instead of sending again.",
19657
+ "annotations": {
19658
+ "openWorldHint": true,
19659
+ "destructiveHint": false,
19660
+ "idempotentHint": true
19661
+ },
19662
+ "inputSchema": {
19663
+ "type": "object",
19664
+ "required": [
19665
+ "conversation_id",
19666
+ "text",
19667
+ "idempotency_key"
19668
+ ],
19669
+ "additionalProperties": false,
19670
+ "properties": {
19671
+ "conversation_id": {
19672
+ "type": "string",
19673
+ "pattern": "^(?:[A-Za-z0-9_-]+=*|urn:li:msg_conversation:\\((?:urn:li:fsd_profile:[A-Za-z0-9_-]+|urn:li:fsd_pageMailbox:[0-9]+),[A-Za-z0-9_-]+=*\\))$",
19674
+ "maxLength": 500,
19675
+ "description": "The row's thread_id (the member's own inbox) or its full conversation_id (the inbox it names)."
19676
+ },
19677
+ "text": {
19678
+ "type": "string",
19679
+ "minLength": 1,
19680
+ "maxLength": 3000
19681
+ },
19682
+ "idempotency_key": {
19683
+ "type": "string",
19684
+ "minLength": 1,
19685
+ "maxLength": 300,
19686
+ "description": "One reply per key: a retry returns the first send."
19687
+ }
19688
+ }
19689
+ }
19690
+ },
19691
+ "prepare_message": {
19692
+ "key": "prepare_message",
19693
+ "name": "Prepare message",
19694
+ "kind": "write",
19695
+ "description": "Prepare a text reply in an exact existing conversation. Execute with activation: { kind: 'page_visit', urls: [conversation_url] }. When the user visits that URL, fill its empty composer. The user clicks Send. Never sends or overwrites a draft.",
19696
+ "annotations": {
19697
+ "openWorldHint": true,
19698
+ "destructiveHint": false,
19699
+ "idempotentHint": false
19700
+ },
19701
+ "inputSchema": {
19702
+ "type": "object",
19703
+ "required": [
19704
+ "conversation_url",
19705
+ "body"
19706
+ ],
19707
+ "additionalProperties": false,
19708
+ "properties": {
19709
+ "conversation_url": {
19710
+ "type": "string",
19711
+ "format": "uri"
19712
+ },
19713
+ "body": {
19714
+ "type": "string",
19715
+ "minLength": 1,
19716
+ "maxLength": 3000
19717
+ }
19718
+ }
19719
+ }
19720
+ },
19721
+ "prepare_post": {
19722
+ "key": "prepare_post",
19723
+ "name": "Prepare personal post",
19724
+ "kind": "write",
19725
+ "description": "Prepare a text post for the signed-in member. Execute with activation: { kind: 'page_visit', urls: ['https://www.linkedin.com/feed/foryou/'] }. When the user visits that page, open its personal post composer and fill an empty draft. The user clicks Post. Never publishes or overwrites a draft.",
19726
+ "annotations": {
19727
+ "openWorldHint": true,
19728
+ "destructiveHint": false,
19729
+ "idempotentHint": false
19730
+ },
19731
+ "inputSchema": {
19732
+ "type": "object",
19733
+ "required": [
19734
+ "body"
19735
+ ],
19736
+ "additionalProperties": false,
19737
+ "properties": {
19738
+ "body": {
19739
+ "type": "string",
19740
+ "minLength": 1,
19741
+ "maxLength": 3000
19742
+ }
19743
+ }
19744
+ }
19745
+ },
19746
+ "prepare_comment": {
19747
+ "key": "prepare_comment",
19748
+ "name": "Prepare comment",
19749
+ "description": "Stage a comment draft after the user opens the exact LinkedIn post (fill composer, banner). The page-activation target is the post page URL with a trailing slash (https://www.linkedin.com/feed/update/urn:li:activity:<id>/), the form LinkedIn settles on. NEVER opens a tab or submits — the human must click Post.",
19750
+ "kind": "write",
19751
+ "annotations": {
19752
+ "openWorldHint": true,
19753
+ "destructiveHint": false,
19754
+ "idempotentHint": false
19755
+ },
19756
+ "inputSchema": {
19757
+ "type": "object",
19758
+ "required": [
19759
+ "body"
19760
+ ],
19761
+ "anyOf": [
19762
+ {
19763
+ "required": [
19764
+ "post_url"
19765
+ ]
19766
+ },
19767
+ {
19768
+ "required": [
19769
+ "activity_id"
19770
+ ]
19771
+ }
19772
+ ],
19773
+ "properties": {
19774
+ "post_url": {
19775
+ "type": "string",
19776
+ "description": "LinkedIn post URL, or activity id / URN (e.g. \"https://www.linkedin.com/feed/update/urn:li:activity:7312345678901234567\", \"urn:li:activity:7312345678901234567\", or \"7312345678901234567\")."
19777
+ },
19778
+ "activity_id": {
19779
+ "type": "string",
19780
+ "description": "Activity id when post_url is omitted (digits or urn:li:activity:…)."
19781
+ },
19782
+ "body": {
19783
+ "type": "string",
19784
+ "description": "Draft comment text. Left in the composer for the user to edit/send.",
19785
+ "minLength": 1,
19786
+ "maxLength": 3000
19787
+ },
19788
+ "reason": {
19789
+ "type": "string",
19790
+ "description": "Optional short explanation for the in-page banner (truncated).",
19791
+ "maxLength": 500
19792
+ },
19793
+ "banner": {
19794
+ "type": "boolean",
19795
+ "description": "Inject a small in-page Lobu handoff banner (default true)."
19796
+ }
19797
+ }
19798
+ },
19799
+ "outputSchema": {
19800
+ "type": "object",
19801
+ "properties": {
19802
+ "prepared": {
19803
+ "type": "boolean"
19804
+ },
19805
+ "status": {
19806
+ "type": "string",
19807
+ "enum": [
19808
+ "not_actionable",
19809
+ "prepared"
19810
+ ],
19811
+ "description": "prepared after the draft is staged; not_actionable when the input did not carry a durable post id (no browser action was taken)."
19812
+ },
19813
+ "reason": {
19814
+ "type": "string",
19815
+ "description": "Present with status=not_actionable: why the input was not actionable (e.g. missing_durable_post_id)."
19816
+ },
19817
+ "tab_id": {
19818
+ "type": "integer"
19819
+ },
19820
+ "post_url": {
19821
+ "type": "string"
19822
+ },
19823
+ "body": {
19824
+ "type": "string"
19825
+ },
19826
+ "method": {
19827
+ "type": "string"
19828
+ },
19829
+ "banner_shown": {
19830
+ "type": "boolean"
19831
+ },
19832
+ "reason_preview": {
19833
+ "type": "string"
19834
+ },
19835
+ "message": {
19836
+ "type": "string"
19837
+ }
19838
+ }
19839
+ }
19840
+ },
19841
+ "verify_staged_comment": {
19842
+ "key": "verify_staged_comment",
19843
+ "name": "Verify staged comment",
19844
+ "description": "Re-open a LinkedIn post in the paired Chrome browser and check whether a comment matching the draft body is visible. Read-only — never posts. Best-effort DOM scrape (not a guarantee of publication).",
19845
+ "kind": "read",
19846
+ "annotations": {
19847
+ "openWorldHint": true,
19848
+ "destructiveHint": false,
19849
+ "idempotentHint": true
19850
+ },
19851
+ "inputSchema": {
19852
+ "type": "object",
19853
+ "required": [
19854
+ "body"
19855
+ ],
19856
+ "anyOf": [
19857
+ {
19858
+ "required": [
19859
+ "post_url"
19860
+ ]
19861
+ },
19862
+ {
19863
+ "required": [
19864
+ "activity_id"
19865
+ ]
19866
+ }
19867
+ ],
19868
+ "properties": {
19869
+ "post_url": {
19870
+ "type": "string",
19871
+ "description": "LinkedIn post URL, activity id, or URN (same shapes as prepare_comment)."
19872
+ },
19873
+ "activity_id": {
19874
+ "type": "string",
19875
+ "description": "Activity id when post_url is omitted (digits or urn:li:activity:…)."
19876
+ },
19877
+ "body": {
19878
+ "type": "string",
19879
+ "description": "Expected comment text (the staged draft).",
19880
+ "minLength": 1,
19881
+ "maxLength": 3000
19882
+ },
19883
+ "author_hint": {
19884
+ "type": "string",
19885
+ "description": "Optional author display-name substring to require when matching.",
19886
+ "maxLength": 200
19887
+ },
19888
+ "focus": {
19889
+ "type": "boolean",
19890
+ "description": "Bring the post tab to the foreground (default true)."
19891
+ }
19892
+ }
19893
+ },
19894
+ "outputSchema": {
19895
+ "type": "object",
19896
+ "properties": {
19897
+ "verified": {
19898
+ "type": "boolean"
19899
+ },
19900
+ "status": {
19901
+ "type": "string",
19902
+ "enum": [
19903
+ "not_actionable",
19904
+ "verified"
19905
+ ],
19906
+ "description": "verified after a matching comment is found; not_actionable when the input did not carry a durable post id (no browser action was taken)."
19907
+ },
19908
+ "reason": {
19909
+ "type": "string",
19910
+ "description": "Present whenever verification did not succeed: why (e.g. missing_durable_post_id, no_matching_comment, no_comments_visible, scrape_exception)."
19911
+ },
19912
+ "post_url": {
19913
+ "type": "string"
19914
+ },
19915
+ "body": {
19916
+ "type": "string"
19917
+ },
19918
+ "tab_id": {
19919
+ "type": "integer"
19920
+ },
19921
+ "comments_scanned": {
19922
+ "type": "integer"
19923
+ },
19924
+ "match": {
19925
+ "type": "object",
19926
+ "properties": {
19927
+ "author": {
19928
+ "type": "string"
19929
+ },
19930
+ "text_preview": {
19931
+ "type": "string"
19932
+ },
19933
+ "match_kind": {
19934
+ "type": "string",
19935
+ "enum": [
19936
+ "exact",
19937
+ "prefix",
19938
+ "contains"
19939
+ ]
19940
+ }
19941
+ }
19942
+ },
19943
+ "message": {
19944
+ "type": "string"
19945
+ }
19946
+ }
19947
+ }
19948
+ },
19949
+ "read_my_activity": {
19950
+ "key": "read_my_activity",
19951
+ "name": "Read my activity",
19952
+ "description": "Read the signed-in member's own recent LinkedIn posts and comments from their profile activity pages in the paired Chrome browser, and return them without storing any events. Read-only.",
19953
+ "kind": "read",
19954
+ "annotations": {
19955
+ "openWorldHint": true,
19956
+ "destructiveHint": false,
19957
+ "idempotentHint": true
19958
+ },
19959
+ "inputSchema": {
19960
+ "type": "object",
19961
+ "properties": {
19962
+ "kinds": {
19963
+ "type": "array",
19964
+ "items": {
19965
+ "type": "string",
19966
+ "enum": [
19967
+ "posts",
19968
+ "comments"
19969
+ ]
19970
+ },
19971
+ "description": "Which activity lists to read. Default [\"posts\", \"comments\"]."
19972
+ },
19973
+ "max_scrolls": {
19974
+ "type": "integer",
19975
+ "minimum": 1,
19976
+ "maximum": 10,
19977
+ "description": "Scroll passes per list (default 3)."
19978
+ }
19979
+ }
19980
+ }
19981
+ },
19982
+ "read_home_feed": {
19983
+ "key": "read_home_feed",
19984
+ "name": "Read home feed",
19985
+ "description": "Read the signed-in member's current LinkedIn home feed in the paired Chrome browser, and return the visible posts and comments without storing any events. Read-only.",
19986
+ "kind": "read",
19987
+ "annotations": {
19988
+ "openWorldHint": true,
19989
+ "destructiveHint": false,
19990
+ "idempotentHint": true
19991
+ },
19992
+ "inputSchema": {
19993
+ "type": "object",
19994
+ "properties": {
19995
+ "max_scrolls": {
19996
+ "type": "integer",
19997
+ "minimum": 1,
19998
+ "maximum": 10,
19999
+ "description": "Scroll passes over the feed (default 6)."
20000
+ }
20001
+ }
20002
+ }
20003
+ },
20004
+ "verify_browser": {
20005
+ "name": "Verify browser connection",
20006
+ "kind": "read",
20007
+ "description": "Check the selected browser and any declared account identity without reading source content.",
20008
+ "inputSchema": {
20009
+ "type": "object",
20010
+ "properties": {},
20011
+ "additionalProperties": false
20012
+ }
20013
+ }
20014
+ },
20015
+ "automation_events": [
20016
+ {
20017
+ "key": "notification.changed",
20018
+ "label": "Notification Changed",
20019
+ "resourceType": "notification",
20020
+ "description": "A new or changed notification reference. Read its content from the notifications feed."
20021
+ },
20022
+ {
20023
+ "key": "message.created",
20024
+ "label": "Message Created",
20025
+ "resourceType": "message",
20026
+ "description": "A new inbox message reference. Read its content from the live messages feed by id:<message URN>. A reply Automation can answer a direct message in its conversation.",
20027
+ "capabilities": {
20028
+ "replyToSource": true
20029
+ }
20030
+ },
20031
+ {
20032
+ "key": "source.gap",
20033
+ "label": "Source Gap",
20034
+ "description": "Catch-up reached the end of what LinkedIn exposes, so earlier changes at this conversation or notification position may be missing."
20035
+ },
20036
+ {
20037
+ "key": "post",
20038
+ "label": "Post"
20039
+ },
20040
+ {
20041
+ "key": "comment",
20042
+ "label": "Comment"
20043
+ },
20044
+ {
20045
+ "key": "job_posting",
20046
+ "label": "Job Posting"
20047
+ },
20048
+ {
20049
+ "key": "message",
20050
+ "label": "Message"
20051
+ },
20052
+ {
20053
+ "key": "connection",
20054
+ "label": "Connection"
20055
+ }
20056
+ ],
20057
+ "options_schema": null,
20058
+ "favicon_domain": "linkedin.com",
20059
+ "required_capability": null,
20060
+ "runtime": null,
20061
+ "login_enabled": false
20062
+ }
20063
+ },
18839
20064
  {
18840
20065
  "id": "market.quotes",
18841
20066
  "name": "Market Quotes",
@@ -20032,7 +21257,7 @@
20032
21257
  {
20033
21258
  "id": "tiktok.web",
20034
21259
  "name": "TikTok",
20035
- "version": "1.1.5",
21260
+ "version": "1.1.9",
20036
21261
  "description": "Read TikTok through your signed-in paired browser, inspect post visuals, set likes, and prepare comments for human submission. Automations decide what to read and act on.",
20037
21262
  "detail": {
20038
21263
  "source_path": "tiktok_web.ts",
@@ -20053,7 +21278,7 @@
20053
21278
  ],
20054
21279
  "accountProbe": {
20055
21280
  "url": "https://www.tiktok.com",
20056
- "expression": "(async function tiktokPage(command, args = {}) {\n const visible = (e) => !!e && e.getClientRects().length > 0, assertNoChallenge = () => {\n if (visible(document.querySelector(\"#captcha-verify-container-main-page\")))\n throw Error(\"TikTok verification required; complete the challenge in the connected browser\");\n };\n assertNoChallenge();\n const scope = () => {\n const script = document.querySelector(\"#__UNIVERSAL_DATA_FOR_REHYDRATION__\");\n return script ? JSON.parse(script.textContent).__DEFAULT_SCOPE__ || {} : {};\n }, identity = () => {\n const user = scope()[\"webapp.app-context\"]?.user;\n return typeof user?.uid === \"string\" && /^[0-9]+$/.test(user.uid) ? { accountId: user.uid, displayName: user.uniqueId } : null;\n }, wait = async (read) => {\n for (let i = 0;i < 40; i++) {\n const value = read();\n if (value)\n return value;\n await new Promise((resolve) => setTimeout(resolve, 250));\n }\n throw Error(\"TikTok page did not expose the requested content; it may be loading, signed out, or unavailable\");\n };\n if (command === \"identity\")\n try {\n return await wait(identity);\n } catch {\n return null;\n }\n if (!identity())\n throw Error(\"TikTok sign-in is required\");\n const assertFollowing = () => {\n if (location.origin !== \"https://www.tiktok.com\" || location.pathname !== \"/following\")\n throw Error(\"TikTok Following page changed\");\n assertNoChallenge();\n if (!identity())\n throw Error(\"TikTok sign-in is required\");\n };\n if (command === \"following_status\" || command === \"following_wait\") {\n assertFollowing();\n document.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n if (command === \"following_wait\") {\n await new Promise((resolve) => setTimeout(resolve, 250));\n assertFollowing();\n }\n return { ready: !0 };\n }\n const project = (item) => ({\n id: item.id,\n desc: item.desc,\n createTime: item.createTime,\n author: item.author && { id: item.author.id, uniqueId: item.author.uniqueId, nickname: item.author.nickname },\n video: item.video && { duration: item.video.duration, width: item.video.width, height: item.video.height },\n imagePost: item.imagePost && { images: item.imagePost.images?.map(() => ({})) },\n stats: item.stats && { diggCount: item.stats.diggCount, commentCount: item.stats.commentCount, playCount: item.stats.playCount, shareCount: item.stats.shareCount },\n digged: item.digged\n });\n if (command === \"following_posts\") {\n assertFollowing();\n const url = new URL(args.url);\n if (url.origin !== location.origin || url.pathname !== \"/api/following/item_list/\" || url.username || url.password)\n throw Error(\"Unexpected TikTok Following URL\");\n if (!Number.isInteger(args.limit) || args.limit < 1 || args.limit > 30 || !Array.isArray(args.seen_ids))\n throw Error(\"Invalid TikTok Following collection request\");\n const seen = new Set(args.seen_ids), items = new Map, requested = new Set;\n let { cursor, level } = args, hasMore = !0;\n const controller = new AbortController, timer = setTimeout(() => controller.abort(), 16000);\n try {\n for (let round = 0;round < 12 && seen.size < args.limit && hasMore; round++) {\n assertFollowing();\n if (typeof cursor !== \"string\" || !cursor || cursor.length > 256 || !Number.isSafeInteger(level) || level < 1)\n throw Error(\"TikTok Following continuation is unavailable\");\n const key = `${level}:${cursor}`;\n if (requested.has(key))\n break;\n requested.add(key);\n url.searchParams.set(\"count\", \"30\");\n url.searchParams.set(\"pullType\", \"2\");\n url.searchParams.set(\"cursor\", cursor);\n url.searchParams.set(\"level\", String(level));\n document.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n const response = await fetch(url.href, { credentials: \"include\", signal: controller.signal });\n if (response.status !== 200)\n throw Error(\"TikTok Following continuation request failed\");\n const json = await response.json();\n assertFollowing();\n if (json.status_code !== 0 || json.statusCode !== void 0 && json.statusCode !== 0 || !Array.isArray(json.itemList) || typeof json.hasMore !== \"boolean\")\n throw Error(\"TikTok did not return a successful Following feed\");\n for (const item of json.itemList) {\n seen.add(item.id);\n items.set(item.id, project(item));\n }\n ({ cursor, level, hasMore } = json);\n }\n } finally {\n clearTimeout(timer);\n }\n assertFollowing();\n if (seen.size < args.limit && hasMore)\n throw Error(`TikTok Following read incomplete: collected ${seen.size} of ${args.limit} requested posts; retry the read`);\n return { items: [...items.values()] };\n }\n if (command === \"snapshot\")\n return { items: (scope()[\"webapp.updated-items\"] || []).map(project) };\n if (command === \"post_links\")\n return { rows: (await wait(() => {\n assertNoChallenge();\n const rendered = [...document.querySelectorAll('a[href*=\"/video/\"],a[href*=\"/photo/\"]')].filter(visible);\n return rendered.length ? rendered : null;\n })).map((a) => ({\n url: a.href,\n text: a.querySelector(\"img\")?.alt || a.innerText || \"\"\n })) };\n const detail = args.source_item || await wait(() => scope()[\"webapp.video-detail\"]?.itemInfo?.itemStruct), target = new URL(args.url);\n if (!/^[A-Za-z0-9_.]{1,64}$/.test(detail.author?.uniqueId || \"\"))\n throw Error(\"TikTok post author is invalid\");\n const assertTarget = () => {\n if (location.origin !== target.origin || location.pathname !== target.pathname || detail.id !== target.pathname.split(\"/\").pop())\n throw Error(\"TikTok post changed; refusing to act on a different post\");\n };\n assertTarget();\n const card = await wait(() => {\n const matches = [...document.querySelectorAll('[data-e2e=\"recommend-list-item-container\"]')].filter((candidate) => visible(candidate) && candidate.querySelector('[data-e2e=\"more-menu-icon\"]')?.getAttribute(\"data-more-menu-item-id\") === detail.id);\n if (matches.length > 1)\n throw Error(\"TikTok displayed post identity is ambiguous\");\n return matches[0];\n });\n assertTarget();\n const author = card.querySelector(`a[href=\"/@${detail.author.uniqueId}\"]`), description = card.querySelector('[data-e2e=\"video-desc\"]'), compact = (text) => String(text || \"\").replace(/\\s+/g, \"\").trim();\n if (!author || detail.desc && !compact(description?.textContent).includes(compact(detail.desc)))\n throw Error(\"TikTok displayed post does not match the requested source record\");\n const likeButton = card.querySelector('[data-e2e=\"like-icon\"]'), liked = () => {\n const value = likeButton?.getAttribute(\"aria-pressed\");\n if (value !== \"true\" && value !== \"false\")\n throw Error(\"TikTok like state is unavailable\");\n return value === \"true\";\n };\n if (command === \"detail\")\n return { item: project(detail), liked: liked() };\n if (command === \"mute\") {\n card.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n return { muted: !0 };\n }\n if (command === \"photo\") {\n const count = detail.imagePost?.images?.length, index = args.index;\n if (!Number.isInteger(index) || index < 0 || !count || index >= count)\n throw Error(\"Photo index is outside this post\");\n const carousel = card.querySelector(\".swiper\")?.swiper;\n if (typeof carousel?.slideToLoop !== \"function\" || typeof carousel?.autoplay?.stop !== \"function\")\n throw Error(\"TikTok photo carousel is unavailable\");\n carousel.autoplay.stop();\n carousel.slideToLoop(index, 0);\n await wait(() => carousel.realIndex === index && !carousel.animating);\n const slide = card.querySelector(\".swiper-slide-active\"), image = slide?.querySelector(\"img\");\n await wait(() => image?.complete && image.naturalWidth > 0);\n assertTarget();\n slide.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { photo_index: index, photo_count: count };\n }\n if (command === \"set_like\") {\n if (typeof args.liked !== \"boolean\")\n throw Error(\"liked must be a boolean\");\n const before = liked();\n if (before !== args.liked) {\n likeButton.click();\n await wait(() => liked() === args.liked);\n }\n assertTarget();\n return { liked: liked(), changed: before !== args.liked };\n }\n if (command === \"frame\") {\n const video = card.querySelector(\"video\");\n if (!video)\n throw Error(\"No playable video on this post\");\n video.muted = !0;\n await video.play();\n await wait(() => video.readyState >= 2 && Number.isFinite(video.duration) && video.duration > 0);\n assertTarget();\n video.pause();\n const seconds = args.seconds;\n if (!Number.isFinite(seconds) || seconds < 0 || seconds >= video.duration)\n throw Error(\"Frame time is outside the video duration\");\n video.currentTime = seconds;\n await wait(() => !video.seeking && Math.abs(video.currentTime - seconds) < 0.15 && video.readyState >= 2);\n assertTarget();\n video.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { seconds: video.currentTime, duration_seconds: video.duration };\n }\n if (command === \"open_comment\") {\n if (![...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].find(visible)) {\n const button = card.querySelector('[data-e2e=\"comment-icon\"]');\n if (!button)\n throw Error(\"TikTok comment control is unavailable\");\n button.click();\n }\n const editor = await wait(() => [...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].find(visible));\n assertTarget();\n if (editor.textContent.trim())\n throw Error(\"The comment composer already contains text; preserving the user's draft\");\n editor.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { opened: !0 };\n }\n if (command === \"comment_text\") {\n const editors = [...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].filter(visible);\n if (editors.length !== 1)\n throw Error(\"TikTok comment composer is ambiguous\");\n return { text: editors[0].innerText };\n }\n throw Error(\"Unsupported TikTok page command\");\n })(\"identity\",{})"
21281
+ "expression": "Promise.resolve().then(() => (async function tiktokPage(command, args = {}) {\n const interrupt = (reason, message) => {\n throw Object.assign(Error(message), { browser_interruption: reason });\n }, visible = (e) => !!e && e.getClientRects().length > 0, assertNoChallenge = () => {\n if (visible(document.querySelector(\"#captcha-verify-container-main-page\")))\n interrupt(\"challenge_required\", \"TikTok verification required; complete the challenge in the connected browser\");\n };\n assertNoChallenge();\n const scope = () => {\n const script = document.querySelector(\"#__UNIVERSAL_DATA_FOR_REHYDRATION__\");\n return script ? JSON.parse(script.textContent).__DEFAULT_SCOPE__ || {} : {};\n }, identity = () => {\n const user = scope()[\"webapp.app-context\"]?.user;\n return typeof user?.uid === \"string\" && /^[0-9]+$/.test(user.uid) ? { accountId: user.uid, displayName: user.uniqueId } : null;\n }, wait = async (read) => {\n for (let i = 0;i < 40; i++) {\n assertNoChallenge();\n const value = read();\n if (value)\n return value;\n await new Promise((resolve) => setTimeout(resolve, 250));\n }\n interrupt(\"loading_failure\", \"TikTok page did not expose the requested content\");\n };\n if (command === \"identity\")\n try {\n return await wait(identity);\n } catch (error) {\n if (error.browser_interruption !== \"loading_failure\")\n throw error;\n return null;\n }\n const owner = identity()?.accountId;\n if (!owner)\n interrupt(\"login_required\", \"TikTok sign-in is required\");\n if (command === \"read_failure\")\n interrupt(\"loading_failure\", \"TikTok page did not finish loading the requested content\");\n const assertTimeline = (path) => {\n if (location.origin !== \"https://www.tiktok.com\" || location.pathname !== path)\n throw Error(\"TikTok timeline page changed\");\n assertNoChallenge();\n if (!identity())\n interrupt(\"login_required\", \"TikTok sign-in is required\");\n if (identity().accountId !== owner)\n interrupt(\"account_mismatch\", \"TikTok account changed during the read\");\n }, assertFollowing = () => assertTimeline(\"/following\");\n if ([\"following_status\", \"following_wait\", \"for_you_status\", \"for_you_wait\"].includes(command)) {\n const path = command.startsWith(\"following_\") ? \"/following\" : \"/\";\n assertTimeline(path);\n document.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n if (command.endsWith(\"_wait\")) {\n await new Promise((resolve) => setTimeout(resolve, 250));\n assertTimeline(path);\n }\n return { ready: !0 };\n }\n const project = (item) => ({\n id: item.id,\n desc: item.desc,\n createTime: item.createTime,\n author: item.author && { id: item.author.id, uniqueId: item.author.uniqueId, nickname: item.author.nickname },\n video: item.video && { duration: item.video.duration, width: item.video.width, height: item.video.height },\n imagePost: item.imagePost && { images: item.imagePost.images?.map(() => ({})) },\n stats: item.stats && { diggCount: item.stats.diggCount, commentCount: item.stats.commentCount, playCount: item.stats.playCount, shareCount: item.stats.shareCount },\n digged: item.digged\n });\n if (command === \"following_posts\") {\n assertFollowing();\n const url = new URL(args.url);\n if (url.origin !== location.origin || url.pathname !== \"/api/following/item_list/\" || url.username || url.password)\n throw Error(\"Unexpected TikTok Following URL\");\n if (!Number.isInteger(args.limit) || args.limit < 1 || args.limit > 30 || !Array.isArray(args.seen_ids))\n throw Error(\"Invalid TikTok Following collection request\");\n const seen = new Set(args.seen_ids), items = new Map, requested = new Set;\n let { cursor, level } = args, hasMore = !0;\n const controller = new AbortController, timer = setTimeout(() => controller.abort(), 16000);\n try {\n for (let round = 0;round < 12 && seen.size < args.limit && hasMore; round++) {\n assertFollowing();\n if (typeof cursor !== \"string\" || !cursor || cursor.length > 256 || !Number.isSafeInteger(level) || level < 1)\n throw Error(\"TikTok Following continuation is unavailable\");\n const key = `${level}:${cursor}`;\n if (requested.has(key))\n break;\n requested.add(key);\n url.searchParams.set(\"count\", \"30\");\n url.searchParams.set(\"pullType\", \"2\");\n url.searchParams.set(\"cursor\", cursor);\n url.searchParams.set(\"level\", String(level));\n document.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n const response = await fetch(url.href, { credentials: \"include\", signal: controller.signal });\n if (response.status !== 200)\n throw Error(\"TikTok Following continuation request failed\");\n const json = await response.json();\n assertFollowing();\n if (json.status_code !== 0 || json.statusCode !== void 0 && json.statusCode !== 0 || !Array.isArray(json.itemList) || typeof json.hasMore !== \"boolean\")\n throw Error(\"TikTok did not return a successful Following feed\");\n for (const item of json.itemList) {\n seen.add(item.id);\n items.set(item.id, project(item));\n }\n ({ cursor, level, hasMore } = json);\n }\n } finally {\n clearTimeout(timer);\n }\n assertFollowing();\n if (seen.size < args.limit && hasMore)\n throw Error(`TikTok Following read incomplete: collected ${seen.size} of ${args.limit} requested posts; retry the read`);\n return { items: [...items.values()] };\n }\n if (command === \"post_links\")\n return { rows: (await wait(() => {\n assertNoChallenge();\n const rendered = [...document.querySelectorAll('a[href*=\"/video/\"],a[href*=\"/photo/\"]')].filter(visible);\n return rendered.length ? rendered : null;\n })).map((a) => ({\n url: a.href,\n text: a.querySelector(\"img\")?.alt || a.innerText || \"\"\n })) };\n const detail = args.source_item || await wait(() => scope()[\"webapp.video-detail\"]?.itemInfo?.itemStruct), target = new URL(args.url);\n if (!/^[A-Za-z0-9_.]{1,64}$/.test(detail.author?.uniqueId || \"\"))\n throw Error(\"TikTok post author is invalid\");\n const assertTarget = () => {\n if (location.origin !== target.origin || location.pathname !== target.pathname || detail.id !== target.pathname.split(\"/\").pop())\n throw Error(\"TikTok post changed; refusing to act on a different post\");\n };\n assertTarget();\n const card = await wait(() => {\n const matches = [...document.querySelectorAll('[data-e2e=\"recommend-list-item-container\"]')].filter((candidate) => visible(candidate) && candidate.querySelector('[data-e2e=\"more-menu-icon\"]')?.getAttribute(\"data-more-menu-item-id\") === detail.id);\n if (matches.length > 1)\n throw Error(\"TikTok displayed post identity is ambiguous\");\n return matches[0];\n });\n assertTarget();\n const author = card.querySelector(`a[href=\"/@${detail.author.uniqueId}\"]`), description = card.querySelector('[data-e2e=\"video-desc\"]'), compact = (text) => String(text || \"\").replace(/\\s+/g, \"\").trim();\n if (!author || detail.desc && !compact(description?.textContent).includes(compact(detail.desc)))\n throw Error(\"TikTok displayed post does not match the requested source record\");\n const likeButton = card.querySelector('[data-e2e=\"like-icon\"]'), liked = () => {\n const value = likeButton?.getAttribute(\"aria-pressed\");\n if (value !== \"true\" && value !== \"false\")\n throw Error(\"TikTok like state is unavailable\");\n return value === \"true\";\n };\n if (command === \"detail\")\n return { item: project(detail), liked: liked() };\n if (command === \"mute\") {\n card.querySelectorAll(\"video,audio\").forEach((media) => {\n media.muted = !0;\n });\n return { muted: !0 };\n }\n if (command === \"photo\") {\n const count = detail.imagePost?.images?.length, index = args.index;\n if (!Number.isInteger(index) || index < 0 || !count || index >= count)\n throw Error(\"Photo index is outside this post\");\n const carousel = card.querySelector(\".swiper\")?.swiper;\n if (typeof carousel?.slideToLoop !== \"function\" || typeof carousel?.autoplay?.stop !== \"function\")\n throw Error(\"TikTok photo carousel is unavailable\");\n carousel.autoplay.stop();\n carousel.slideToLoop(index, 0);\n await wait(() => carousel.realIndex === index && !carousel.animating);\n const slide = card.querySelector(\".swiper-slide-active\"), image = slide?.querySelector(\"img\");\n await wait(() => image?.complete && image.naturalWidth > 0);\n assertTarget();\n slide.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { photo_index: index, photo_count: count };\n }\n if (command === \"set_like\") {\n if (typeof args.liked !== \"boolean\")\n throw Error(\"liked must be a boolean\");\n const before = liked();\n if (before !== args.liked) {\n likeButton.click();\n await wait(() => liked() === args.liked);\n }\n assertTarget();\n return { liked: liked(), changed: before !== args.liked };\n }\n if (command === \"frame\") {\n const video = card.querySelector(\"video\");\n if (!video)\n throw Error(\"No playable video on this post\");\n video.muted = !0;\n await video.play();\n await wait(() => video.readyState >= 2 && Number.isFinite(video.duration) && video.duration > 0);\n assertTarget();\n video.pause();\n const seconds = args.seconds;\n if (!Number.isFinite(seconds) || seconds < 0 || seconds >= video.duration)\n throw Error(\"Frame time is outside the video duration\");\n video.currentTime = seconds;\n await wait(() => !video.seeking && Math.abs(video.currentTime - seconds) < 0.15 && video.readyState >= 2);\n assertTarget();\n video.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { seconds: video.currentTime, duration_seconds: video.duration };\n }\n if (command === \"open_comment\") {\n if (![...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].find(visible)) {\n const button = card.querySelector('[data-e2e=\"comment-icon\"]');\n if (!button)\n throw Error(\"TikTok comment control is unavailable\");\n button.click();\n }\n const editor = await wait(() => [...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].find(visible));\n assertTarget();\n if (editor.textContent.trim())\n throw Error(\"The comment composer already contains text; preserving the user's draft\");\n editor.scrollIntoView({ block: \"center\", behavior: \"instant\" });\n return { opened: !0 };\n }\n if (command === \"comment_text\") {\n const editors = [...document.querySelectorAll('[contenteditable=\"true\"][role=\"textbox\"]')].filter(visible);\n if (editors.length !== 1)\n throw Error(\"TikTok comment composer is ambiguous\");\n return { text: editors[0].innerText };\n }\n throw Error(\"Unsupported TikTok page command\");\n })(\"identity\",{})).catch(error => { if (!error.browser_interruption) throw error; return { __lobu_browser_interruption: { reason: error.browser_interruption, message: error.message } }; })"
20057
21282
  }
20058
21283
  },
20059
21284
  "webhook": null,
@@ -20077,7 +21302,7 @@
20077
21302
  "for_you": {
20078
21303
  "key": "for_you",
20079
21304
  "name": "For You",
20080
- "description": "Initial personalized timeline snapshot. No history coverage or continuation; repeat reads can overlap.",
21305
+ "description": "Initial personalized timeline snapshot. Ad units without canonical post identity are excluded. No history coverage or continuation; repeat reads can overlap.",
20081
21306
  "operations": [
20082
21307
  "read"
20083
21308
  ]
@@ -20234,8 +21459,8 @@
20234
21459
  {
20235
21460
  "id": "whatsapp.web",
20236
21461
  "name": "WhatsApp",
20237
- "version": "1.0.9",
20238
- "description": "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.",
21462
+ "version": "2.1.0",
21463
+ "description": "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.",
20239
21464
  "detail": {
20240
21465
  "source_path": "whatsapp_web.ts",
20241
21466
  "auth_schema": {
@@ -20252,7 +21477,7 @@
20252
21477
  ],
20253
21478
  "accountProbe": {
20254
21479
  "url": "https://web.whatsapp.com/",
20255
- "expression": "(async () => {\n (function whatsAppWebAdapterProgram() {\n const SYSTEM_TYPES = new Set([\n \"gp2\",\n \"notification_template\",\n \"e2e_notification\"\n ]);\n let readinessSignature = null, readinessStableSince = 0;\n const existing = globalThis.__owlettoWhatsAppAdapterV1;\n if (existing?.version === 22)\n return;\n existing?.detach?.();\n const listeners = new Map;\n function detach(bindingId) {\n const selected = bindingId ? [listeners.get(bindingId)] : [...listeners.values()];\n for (const state of selected) {\n if (!state)\n continue;\n state.collection.off(\"add\", state.onAdd);\n state.collection.off(\"change\", state.onChange);\n window.removeEventListener(\"message\", state.onReply);\n listeners.delete(state.id);\n }\n }\n function listen(request) {\n const collection = requireFirst([\"WAWebCollections\"])?.Msg;\n if (typeof collection?.on !== \"function\" || typeof collection?.off !== \"function\")\n throw Error(\"WhatsApp message observation is unavailable in this build\");\n if (!request.bridge_id || !request.token)\n throw Error(\"A feed bridge is required\");\n const post = (state2, entry) => window.postMessage({\n type: \"lobu-feed-record\",\n token: state2.token,\n sequence: entry.sequence,\n record: entry.record\n }, location.origin), reportError = (state2, message, sequence = ++state2.sequence) => {\n state2.error = message;\n post(state2, {\n sequence,\n record: {\n id: \"whatsapp-web:source-observation-error\",\n source_error: message\n }\n });\n }, resident = listeners.get(request.bridge_id), previous = resident?.request.references_only === request.references_only && resident?.request.chat_filter === request.chat_filter && resident?.request.minimum_timestamp === request.minimum_timestamp ? resident : null;\n detach(request.bridge_id);\n const state = {\n ...previous ?? {\n id: request.bridge_id,\n collection,\n sequence: 0,\n pending: new Map,\n fingerprints: new Map,\n pendingBytes: 0,\n fingerprintBytes: 0,\n error: null\n },\n collection,\n error: null\n };\n state.token = request.token;\n state.request = request;\n state.post = (entry) => post(state, entry);\n const observe = (model, kind) => {\n if (state.error)\n return;\n const sequence = ++state.sequence;\n (request.references_only ? Promise.resolve(messageReference(model)) : normalizeMessage(model, \"reconcile\")).then((record) => {\n if (listeners.get(state.id) !== state || !record || record.timestamp <= 0)\n return;\n if (state.request.chat_filter === \"group\" && !record.is_group)\n return;\n if (state.request.chat_filter === \"individual\" && record.is_group)\n return;\n if (state.request.minimum_timestamp != null && record.timestamp < state.request.minimum_timestamp)\n return;\n if (kind === \"add\" && record.timestamp < state.request.recent_since)\n return;\n if (request.references_only)\n record = {\n id: record.id,\n events: [{\n id: record.id,\n event_type: \"message.created\",\n resource_ref: record.id,\n resource_type: \"message\",\n occurred_at: new Date(record.timestamp * 1000).toISOString()\n }]\n };\n const previous2 = state.pending.get(record.id), seen = state.fingerprints.get(record.id);\n if (seen && seen.sequence >= sequence)\n return;\n const fingerprint = JSON.stringify(record);\n if (seen?.fingerprint === fingerprint) {\n seen.sequence = sequence;\n return;\n }\n const bytes = new TextEncoder().encode(fingerprint).length;\n if (bytes > 131072 || state.pendingBytes - (previous2?.bytes ?? 0) + bytes > 16777216 || state.pending.size >= 1e4 && !previous2) {\n reportError(state, \"WhatsApp page observation buffer overflowed; recovery is required\", sequence);\n return;\n }\n const entry = { sequence, record, bytes };\n state.pendingBytes += bytes - (previous2?.bytes ?? 0);\n state.pending.set(record.id, entry);\n state.fingerprintBytes += bytes - (seen?.bytes ?? 0);\n state.fingerprints.delete(record.id);\n state.fingerprints.set(record.id, { fingerprint, sequence, bytes });\n while (state.fingerprints.size > 1e4 || state.fingerprintBytes > 16777216) {\n const oldest = state.fingerprints.keys().next().value;\n state.fingerprintBytes -= state.fingerprints.get(oldest).bytes;\n state.fingerprints.delete(oldest);\n }\n post(state, entry);\n }).catch(() => {\n if (listeners.get(state.id) !== state)\n return;\n reportError(state, \"WhatsApp source observation failed; recovery is required\", sequence);\n });\n };\n state.onAdd = (model) => observe(model, \"add\");\n state.onChange = (model) => observe(model, \"change\");\n state.onReply = (event) => {\n if (event.source !== window || event.origin !== location.origin || event.data?.token !== state.token)\n return;\n if (event.data.type === \"lobu-feed-record:stop\") {\n detach(state.id);\n return;\n }\n if (event.data.type !== \"lobu-feed-record:ack\")\n return;\n for (const [id, entry] of state.pending) {\n if (entry.sequence !== event.data.sequence)\n continue;\n if (event.data.ok) {\n state.pendingBytes -= entry.bytes;\n state.pending.delete(id);\n entry.resolve?.();\n } else\n entry.reject?.(Error(\"Browser rejected the source reference batch\"));\n break;\n }\n };\n listeners.set(state.id, state);\n try {\n collection.on(\"add\", state.onAdd);\n collection.on(\"change\", state.onChange);\n window.addEventListener(\"message\", state.onReply);\n } catch (error) {\n reportError(state, \"WhatsApp source observation failed; recovery is required\");\n throw error;\n }\n if (previous?.error)\n post(state, {\n sequence: ++state.sequence,\n record: { id: \"whatsapp-web:source-observation-error\", source_error: previous.error }\n });\n for (const entry of state.pending.values())\n post(state, entry);\n return { ok: !0, listening: !0 };\n }\n async function publishChanges(request) {\n const state = listeners.get(request.bridge_id);\n if (!state?.request.references_only || state.token !== request.token)\n throw Error(\"Source listener is unavailable\");\n const record = request.batch, bytes = new TextEncoder().encode(JSON.stringify(record)).length, previous = state.pending.get(record.id);\n if (bytes > 131072 || state.pendingBytes - (previous?.bytes ?? 0) + bytes > 16777216 || state.pending.size >= 1e4 && !previous)\n throw Error(\"Source replay buffer is full\");\n await new Promise((resolve, reject) => {\n const timer = setTimeout(() => reject(Error(\"Source replay was not accepted by the browser\")), 1e4), entry = {\n record,\n bytes,\n sequence: ++state.sequence,\n resolve: () => {\n clearTimeout(timer);\n resolve();\n },\n reject: (error) => {\n clearTimeout(timer);\n reject(error);\n }\n };\n state.pendingBytes += bytes - (previous?.bytes ?? 0);\n state.pending.set(record.id, entry);\n state.post(entry);\n });\n return { ok: !0 };\n }\n function requireFirst(names) {\n for (const name of names)\n try {\n const module2 = window.require?.(name);\n if (module2)\n return module2;\n } catch {}\n return null;\n }\n function meUser() {\n const module2 = requireFirst([\n \"WAWebUserPrefsMeUser\",\n \"WAWebUserPrefsMe\",\n \"WAWebUserPrefs\"\n ]);\n if (!module2)\n return null;\n for (const accessor of [\n \"getMaybeMePnUser\",\n \"getMaybeMeUser\",\n \"getMeUser\",\n \"getMeUserOrThrow\",\n \"getMaybeMeLidUser\"\n ])\n try {\n const value = module2[accessor]?.();\n if (value)\n return value;\n } catch {}\n try {\n return module2.me ?? null;\n } catch {}\n return null;\n }\n const SEND_MODULES = [\n \"WAWebSendTextMsgChatAction\",\n \"WAWebSendMsgChatAction\",\n \"WAWebSendMessage\"\n ], REACTION_MODULES = [\n \"WAWebSendReactionMsgAction\",\n \"WAWebSendReactionMsg\",\n \"WAWebReactionAction\"\n ], REVOKE_MODULES = [\n \"WAWebChatSendMessages\",\n \"WAWebRevokeMsgAction\",\n \"WAWebDeleteChatAction\",\n \"WAWebRevokeMessage\"\n ], EDIT_MODULES = [\"WAWebSendMessageEditAction\", \"WAWebEditMessage\"], DRAFT_MODULES = [\n \"WAWebChatDraftUtils\",\n \"WAWebSetDraft\",\n \"WAWebComposeBoxActions\"\n ];\n function modelData(model) {\n return model?.attributes ?? model?._data ?? model ?? {};\n }\n function messageReference(model) {\n const row = modelData(model), key = row.id ?? model?.id, id = rawId(key), remote = widString(key?.remote ?? row.chatId ?? (key?.fromMe ? row.to : row.from));\n if (!id || !remote || remote === \"status@broadcast\" || remote.endsWith(\"@newsletter\") || SYSTEM_TYPES.has(row.type))\n return null;\n return { id, timestamp: unixSeconds(row), is_group: remote.endsWith(\"@g.us\") };\n }\n async function observeMessages(input = {}) {\n const after = input.after ?? null;\n if (after !== null && (!Number.isSafeInteger(after) || after < 0))\n throw Error(\"Invalid WhatsApp observation cursor\");\n const database = await new Promise((resolve, reject) => {\n const request = indexedDB.open(\"model-storage\");\n request.onupgradeneeded = () => {\n request.transaction.abort();\n reject(Error(\"WhatsApp source history database is unavailable\"));\n };\n request.onerror = () => reject(request.error);\n request.onblocked = () => reject(Error(\"WhatsApp source history database is blocked\"));\n request.onsuccess = () => resolve(request.result);\n });\n let rows;\n try {\n rows = await new Promise((resolve, reject) => {\n const transaction = database.transaction(\"message\", \"readonly\");\n transaction.onabort = () => reject(transaction.error ?? Error(\"WhatsApp source observation aborted\"));\n const request = transaction.objectStore(\"message\").index(\"rowId\").openCursor(after === null ? null : IDBKeyRange.lowerBound(after, !0), after === null ? \"prev\" : \"next\"), page2 = [];\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (!cursor) {\n resolve(page2);\n return;\n }\n if (!Number.isSafeInteger(cursor.key) || cursor.key <= 0 || typeof cursor.value.id !== \"string\") {\n reject(Error(\"WhatsApp source history has an unsupported key layout\"));\n return;\n }\n page2.push({ position: cursor.key, id: cursor.value.id, timestamp: unixSeconds(cursor.value), type: cursor.value.type });\n if (after === null || page2.length > 500)\n resolve(page2);\n else\n cursor.continue();\n };\n });\n } finally {\n database.close();\n }\n if (after === null)\n return { after: rows[0]?.position ?? 0, references: [], hasMore: !1 };\n const page = rows.slice(0, 500), references = [];\n if (page.length) {\n const keys = requireFirst([\"WAWebMsgKey\"]);\n if (typeof keys?.fromString !== \"function\")\n throw Error(\"WhatsApp source message keys are unavailable\");\n for (const row of page) {\n const reference = messageReference({ id: keys.fromString(row.id), t: row.timestamp, type: row.type });\n if (!reference)\n continue;\n if (reference.timestamp <= 0)\n continue;\n if (reference.timestamp < input.started_at)\n continue;\n if (input.chat_filter === \"group\" && !reference.is_group)\n continue;\n if (input.chat_filter === \"individual\" && reference.is_group)\n continue;\n references.push(reference);\n }\n }\n return { after: page[page.length - 1]?.position ?? after, references, hasMore: rows.length > 500 };\n }\n function models(collection) {\n if (Array.isArray(collection?._models))\n return collection._models;\n if (Array.isArray(collection?.models))\n return collection.models;\n if (typeof collection?.toArray === \"function\")\n try {\n return collection.toArray();\n } catch {}\n return [];\n }\n function widString(value) {\n if (typeof value === \"string\")\n return value;\n if (!value)\n return null;\n if (typeof value._serialized === \"string\")\n return value._serialized;\n try {\n const rendered = value.toString?.();\n return rendered && rendered !== \"[object Object]\" ? String(rendered) : null;\n } catch {\n return null;\n }\n }\n function rawId(value) {\n if (typeof value === \"string\")\n return value && !/^(?:true|false)_/i.test(value) ? value : null;\n if (typeof value?.id === \"string\")\n return value.id && !/^(?:true|false)_/i.test(value.id) ? value.id : null;\n return null;\n }\n function unixSeconds(row) {\n const value = Number(row?.t ?? row?.timestamp ?? row?.ephemeralStartTimestamp ?? 0);\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;\n }\n async function canonicalJid(value) {\n const original = widString(value);\n if (!original)\n return { jid: null, lid: null };\n let jid = original.toLowerCase();\n if (jid.endsWith(\"@c.us\"))\n jid = `${jid.slice(0, -5)}@s.whatsapp.net`;\n if (!jid.endsWith(\"@lid\"))\n return { jid, lid: null };\n const migration = requireFirst([\n \"WAWebLidMigrationUtils\",\n \"WAWebLidMigration\"\n ]), toPn = migration?.toPn ?? migration?.getPnForLid ?? migration?.lidToPhone;\n if (typeof toPn === \"function\")\n try {\n const converted = await toPn.call(migration, value), phoneJid = widString(converted);\n if (phoneJid)\n return {\n jid: phoneJid.endsWith(\"@c.us\") ? `${phoneJid.slice(0, -5)}@s.whatsapp.net` : phoneJid,\n lid: jid\n };\n } catch {}\n return { jid, lid: jid };\n }\n function collectionByRawId(collection, id) {\n if (!id)\n return null;\n for (const model of models(collection)) {\n const row = modelData(model);\n if (rawId(row.id ?? model?.id) === id)\n return model;\n }\n return null;\n }\n function reactionTargetId(row) {\n return rawId(row.reactionParentKey) ?? rawId(row.parentMsgKey) ?? rawId(row.parentMessageKey) ?? (typeof row.quotedStanzaID === \"string\" ? row.quotedStanzaID : null);\n }\n function normalizeReactions(row) {\n const source = row.reactions ?? row.reactionCollection ?? row.reactionsBySender;\n return (Array.isArray(source) ? source : models(source)).map((reaction) => {\n const data = modelData(reaction);\n return {\n emoji: data.text ?? data.reactionText ?? data.emoji ?? null,\n sender_jid: widString(data.senderUserJid ?? data.sender ?? data.author),\n from_me: Boolean(data.fromMe)\n };\n }).filter((reaction) => typeof reaction.emoji === \"string\" && reaction.emoji.length > 0);\n }\n function nameIndex(collections) {\n const byId = (collection) => {\n const map = new Map;\n for (const model of models(collection)) {\n const id = widString(modelData(model).id ?? model?.id);\n if (id && !map.has(id))\n map.set(id, model);\n }\n return map;\n };\n return { chats: byId(collections?.Chat), contacts: byId(collections?.Contact) };\n }\n function contactName(names, jid) {\n if (!jid)\n return null;\n const contact = names?.contacts?.get(jid);\n if (!contact)\n return null;\n const row = modelData(contact);\n return row.name ?? row.pushname ?? row.shortName ?? row.formattedName ?? null;\n }\n function chatName(names, jid) {\n if (!jid)\n return null;\n const chat = names?.chats?.get(jid);\n if (!chat)\n return null;\n const row = modelData(chat);\n return row.name ?? row.formattedTitle ?? row.contact?.name ?? row.contact?.pushname ?? null;\n }\n async function normalizeMessage(model, eventType = \"snapshot\", collectionsOverride = null, names = null) {\n const collections = collectionsOverride ?? requireFirst([\"WAWebCollections\"]);\n if (!collections)\n return null;\n const nameLookup = names ?? nameIndex(collections);\n let row = modelData(model), key = row.id ?? model?.id, id = rawId(key);\n if (!id)\n return null;\n if (row.type === \"reaction\") {\n const targetId = reactionTargetId(row), target = collectionByRawId(collections.Msg, targetId);\n if (target) {\n model = target;\n row = modelData(model);\n key = row.id ?? model?.id;\n id = rawId(key);\n }\n }\n const fromMe = Boolean(key?.fromMe ?? row.fromMe), remoteRaw = key?.remote ?? row.chatId, fromRaw = row.from, toRaw = row.to, authorRaw = row.author ?? key?.participant, chatRaw = remoteRaw ?? (fromMe ? toRaw : fromRaw), chat = await canonicalJid(chatRaw);\n if (!chat.jid || chat.jid === \"status@broadcast\" || chat.jid.endsWith(\"@newsletter\"))\n return null;\n const senderRaw = fromMe ? fromRaw : authorRaw ?? fromRaw, sender = await canonicalJid(senderRaw), participant = await canonicalJid(key?.participant ?? row.participant ?? (fromMe ? toRaw : null)), timestamp = unixSeconds(row), body = typeof row.body === \"string\" ? row.body : \"\", caption = typeof row.caption === \"string\" ? row.caption : \"\", quotedId = typeof row.quotedStanzaID === \"string\" ? row.quotedStanzaID : rawId(row.quotedMsg?.id ?? row.quotedMsgKey), type = typeof row.type === \"string\" ? row.type : \"unknown\";\n return {\n id,\n chat_jid: chat.jid,\n chat_lid: chat.lid,\n chat_name: chatName(nameLookup, widString(chatRaw)),\n sender_jid: sender.jid,\n sender_lid: sender.lid,\n push_name: contactName(nameLookup, widString(senderRaw)) ?? row.notifyName ?? null,\n participant: participant.jid,\n from_me: fromMe,\n is_group: chat.jid.endsWith(\"@g.us\"),\n timestamp,\n occurred_at: timestamp > 0 ? new Date(timestamp * 1000).toISOString() : null,\n body,\n caption,\n message_type: type,\n media_kind: type === \"ptt\" ? \"audio\" : [\"image\", \"video\", \"audio\", \"document\", \"sticker\"].includes(type) ? type : null,\n media_type: typeof row.mimetype === \"string\" ? row.mimetype : null,\n media_size: Number.isFinite(Number(row.size ?? row.fileSize)) ? Number(row.size ?? row.fileSize) : null,\n media_filename: row.filename ?? row.fileName ?? row.title ?? null,\n quoted_id: quotedId,\n is_forwarded: Boolean(row.isForwarded || Number(row.forwardingScore) > 0),\n is_starred: Boolean(row.star ?? row.isStarred),\n is_system_event: SYSTEM_TYPES.has(type),\n edited: Boolean(row.isEdited || row.editVersion || row.latestEditMsgKey),\n edit_timestamp: Number(row.editTimestamp ?? row.lastEditTimestamp) || null,\n revoked: Boolean(row.isRevoked || row.revoked || type === \"revoked\"),\n reactions: normalizeReactions(row),\n event_type: eventType\n };\n }\n function readiness() {\n if (typeof window.require !== \"function\")\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"whatsapp_runtime_unavailable\"\n };\n const collections = requireFirst([\"WAWebCollections\"]);\n if (!collections?.Msg || !collections?.Chat)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"collections_unavailable\"\n };\n const me = meUser(), qrVisible = Boolean(document.querySelector('[data-testid=\"qrcode\"], canvas[aria-label*=\"Scan\" i], [data-ref] canvas'));\n if (!me && qrVisible)\n return { ready: !1, state: \"logged_out\", reason: \"qr_code_visible\" };\n if (!me)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"authenticated_self_identity_unavailable\"\n };\n const socket = requireFirst([\"WAWebSocketModel\"])?.Socket, connection = socket ?? requireFirst([\"WAWebSocketState\", \"WAWebConn\", \"WAWebConnectionState\"]), connectionState = String(connection?.getSocketState?.() ?? connection?.state ?? connection?.socketState ?? \"\").toLowerCase();\n if (!connectionState)\n return {\n ready: !1,\n state: \"capability_unavailable\",\n reason: \"connection_state_unavailable\"\n };\n if (!/^(connected|open|ready|syncing)$/.test(connectionState))\n return {\n ready: !1,\n state: \"not_ready\",\n reason: `connection_${connectionState}`\n };\n if (socket) {\n const stream = String(socket.stream ?? \"\").toLowerCase();\n if (!stream)\n return {\n ready: !1,\n state: \"capability_unavailable\",\n reason: \"stream_state_unavailable\"\n };\n if (!/^(connected|open|ready)$/.test(stream))\n return { ready: !1, state: \"not_ready\", reason: `stream_${stream}` };\n if (socket.hasSynced === !1)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"initial_sync_incomplete\"\n };\n }\n const offlineDelivery = requireFirst([\n \"WAWebOfflineDelivery\",\n \"WAWebOfflineDeliveryState\"\n ]);\n if ((offlineDelivery?.isOfflineDeliveryComplete?.() ?? offlineDelivery?.offlineDeliveryComplete ?? offlineDelivery?.isComplete) === !1)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"offline_delivery_incomplete\"\n };\n const hydration = requireFirst([\n \"WAWebInitialSyncInfo\",\n \"WAWebHistorySync\",\n \"WAWebAppState\"\n ]);\n if ((hydration?.isInitialSyncComplete?.() ?? hydration?.initialSyncComplete ?? hydration?.isHydrated ?? !0) !== !0)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"initial_sync_incomplete\"\n };\n if (!Array.isArray(collections.Chat._models) && !Array.isArray(collections.Chat.models))\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"chat_store_placeholder\"\n };\n const signature = `${widString(me)}:${models(collections.Chat).length}:${models(collections.Msg).length}`;\n if (signature !== readinessSignature) {\n readinessSignature = signature;\n readinessStableSince = Date.now();\n return { ready: !1, state: \"hydrating\", reason: \"stores_settling\" };\n }\n if (Date.now() - readinessStableSince < 500)\n return { ready: !1, state: \"hydrating\", reason: \"stores_settling\" };\n return {\n ready: !0,\n state: \"ready\",\n message_count: models(collections.Msg).length,\n chat_count: models(collections.Chat).length\n };\n }\n function operationCapabilities() {\n const history = requireFirst([\"WAWebChatLoadMessages\"]), search = requireFirst([\n \"WAWebChatMessageSearch\",\n \"WAWebMessageSearch\",\n \"WAWebSearchMessages\"\n ]), draft = requireFirst(DRAFT_MODULES), send = requireFirst(SEND_MODULES), edit = requireFirst(EDIT_MODULES), reaction = requireFirst(REACTION_MODULES), revoke = requireFirst(REVOKE_MODULES), mediaModule = requireFirst([\"WAWebDownloadManager\"]), media = mediaModule?.downloadManager ?? mediaModule, hasFunction = (module2, names) => names.some((name) => typeof module2?.[name] === \"function\");\n return {\n collect: hasFunction(history, [\"loadEarlierMsgs\"]),\n read_messages: typeof indexedDB < \"u\" && typeof requireFirst([\"WAWebMsgKey\"])?.fromString === \"function\" && typeof requireFirst([\"WAWebCollections\"])?.Msg?.getMessagesById === \"function\",\n download_media: hasFunction(media, [\"downloadAndMaybeDecrypt\"]) || models(requireFirst([\"WAWebCollections\"])?.Msg).some((model) => typeof model?.downloadMedia === \"function\"),\n search_messages: hasFunction(search, [\"searchMessages\", \"searchMsgs\", \"search\"]) || Boolean(requireFirst([\"WAWebCollections\"])?.Msg),\n draft_message: hasFunction(draft, [\n \"setDraft\",\n \"setChatDraft\",\n \"saveDraft\"\n ]),\n send_message: hasFunction(send, [\n \"sendTextMsgToChat\",\n \"sendMessage\",\n \"addAndSendTextMsg\"\n ]),\n edit_message: hasFunction(edit, [\"sendMessageEdit\", \"editMessage\"]),\n react_message: hasFunction(reaction, [\n \"sendReactionToMsg\",\n \"sendReaction\"\n ]),\n revoke_message: hasFunction(revoke, [\"sendRevokeMsgs\", \"revokeMessage\"])\n };\n }\n function oldestMessage(chat) {\n let oldest = null;\n for (const message of models(modelData(chat).msgs ?? chat?.msgs)) {\n const row = modelData(message), timestamp = unixSeconds(row), id = rawId(row.id ?? message?.id);\n if (!id)\n continue;\n if (!oldest || timestamp < oldest.timestamp || timestamp === oldest.timestamp && id < oldest.id)\n oldest = { timestamp, id };\n }\n return oldest;\n }\n function chatHasEarlier(chat) {\n const row = modelData(chat), state = row.msgs?.msgLoadState ?? chat?.msgs?.msgLoadState ?? row.msgLoadState ?? {};\n if (state.noEarlierMsgs === !0 || state.hasEarlierMsgs === !1)\n return !1;\n if (row.hasEarlierMsgs === !1)\n return !1;\n return !0;\n }\n async function loadEarlier(chat, limit, deadline) {\n const loader = requireFirst([\"WAWebChatLoadMessages\"]);\n if (typeof loader?.loadEarlierMsgs !== \"function\")\n return {\n available: !1,\n reason: \"WAWebChatLoadMessages.loadEarlierMsgs unavailable\",\n loads: 0\n };\n let loads = 0;\n const beforeIds = new Set(models(modelData(chat).msgs ?? chat?.msgs).map((message) => rawId(modelData(message).id ?? message?.id)).filter(Boolean));\n let previous = oldestMessage(chat), madeProgress = !1;\n while (loads < limit && chatHasEarlier(chat)) {\n if (deadline && Date.now() >= deadline)\n throw Error(\"history deadline budget exhausted\");\n await loader.loadEarlierMsgs({ chat, msgCollection: chat.msgs });\n loads += 1;\n const next = oldestMessage(chat);\n if (!next || previous && next.id === previous.id && next.timestamp === previous.timestamp)\n break;\n madeProgress = !0;\n previous = next;\n }\n let hasMore = chatHasEarlier(chat);\n const loadedIds = () => models(modelData(chat).msgs ?? chat?.msgs).map((message) => rawId(modelData(message).id ?? message?.id)).filter((id) => id && !beforeIds.has(id));\n if (hasMore && !madeProgress)\n return {\n available: !0,\n loads,\n has_more: !0,\n loaded_ids: loadedIds(),\n frontier_advanced: !1,\n error: \"WhatsApp history loader made no progress\"\n };\n if (hasMore) {\n const phone = loader.loadEarlierMsgsFromPhone ?? loader.requestEarlierMsgsFromPhone ?? loader.loadEarlierMsgsFromServer, state = modelData(chat).msgs?.msgLoadState ?? chat?.msgs?.msgLoadState ?? {}, wantsPhone = state.canRequestFromPhone === !0 || state.hasMoreFromPhone === !0;\n if (wantsPhone && typeof phone !== \"function\")\n return {\n available: !0,\n loads,\n has_more: !0,\n loaded_ids: loadedIds(),\n frontier_advanced: !1,\n error: \"phone-assisted WhatsApp history is advertised but its loader is unavailable\"\n };\n if (typeof phone === \"function\" && wantsPhone)\n try {\n await phone.call(loader, { chat, msgCollection: chat.msgs });\n hasMore = chatHasEarlier(chat);\n } catch (error) {\n return {\n available: !0,\n loads,\n has_more: !0,\n loaded_ids: loadedIds(),\n frontier_advanced: !1,\n error: `phone-assisted history failed: ${String(error)}`\n };\n }\n }\n return {\n available: !0,\n loads,\n has_more: hasMore,\n loaded_ids: loadedIds(),\n frontier_advanced: !0\n };\n }\n function uniqueMessageModels(collections) {\n const byId = new Map;\n for (const message of models(collections.Msg)) {\n const id = rawId(modelData(message).id ?? message?.id);\n if (id)\n byId.set(id, message);\n }\n for (const chat of models(collections.Chat))\n for (const message of models(modelData(chat).msgs ?? chat?.msgs)) {\n const id = rawId(modelData(message).id ?? message?.id);\n if (id)\n byId.set(id, message);\n }\n return [...byId.values()];\n }\n async function collect(request) {\n const status = readiness();\n if (!status.ready)\n return { ok: !1, error: status };\n const collections = requireFirst([\"WAWebCollections\"]), chatFilter = [\"all\", \"individual\", \"group\"].includes(request.chat_filter) ? request.chat_filter : \"all\", chatRows = [];\n for (const chat of models(collections.Chat)) {\n const raw = widString(modelData(chat).id ?? chat?.id), jid = (await canonicalJid(raw)).jid;\n if (!jid || jid === \"status@broadcast\" || jid.endsWith(\"@newsletter\") || chatFilter === \"group\" && !jid.endsWith(\"@g.us\") || chatFilter === \"individual\" && jid.endsWith(\"@g.us\"))\n continue;\n chatRows.push({ chat, jid });\n }\n chatRows.sort((a, b) => a.jid.localeCompare(b.jid));\n const backfill = request.backfill ?? { complete: !1, chats: {} }, updates = {};\n let cursor = backfill.cursor_chat_jid ?? null;\n const loadedByChat = new Map, backfillMessageIds = new Set, eligible = request.backfill_disabled ? [] : chatRows.filter((entry) => backfill.chats?.[entry.jid]?.has_more !== !1);\n if (eligible.length > 0) {\n let start = cursor ? eligible.findIndex((entry) => entry.jid > cursor) : 0;\n if (start < 0)\n start = 0;\n const selected = [...eligible.slice(start), ...eligible.slice(0, start)].slice(0, Math.max(1, Number(request.max_chats) || 1)), budgetMs = Number(request.budget_ms), historyDeadline = Number.isFinite(budgetMs) && budgetMs > 0 ? Date.now() + budgetMs : null;\n for (const entry of selected) {\n if (historyDeadline && Date.now() >= historyDeadline)\n break;\n try {\n const loaded = await loadEarlier(entry.chat, Math.max(1, Number(request.max_loads_per_chat) || 1), historyDeadline);\n if (!loaded.available)\n return {\n ok: !1,\n error: {\n state: \"capability_unavailable\",\n reason: loaded.reason\n }\n };\n const oldest = oldestMessage(entry.chat);\n for (const id of loaded.loaded_ids)\n backfillMessageIds.add(id);\n loadedByChat.set(entry.jid, loaded.loaded_ids);\n if (loaded.frontier_advanced === !1) {\n updates[entry.jid] = {\n ...backfill.chats?.[entry.jid] ?? {},\n error: loaded.error,\n has_more: !0,\n loads: loaded.loads\n };\n continue;\n }\n updates[entry.jid] = {\n oldest_timestamp: oldest?.timestamp ?? null,\n oldest_id: oldest?.id ?? null,\n has_more: loaded.has_more,\n loads: loaded.loads\n };\n cursor = entry.jid;\n } catch (error) {\n if (/unavailable/i.test(String(error)))\n return {\n ok: !1,\n error: {\n state: \"capability_unavailable\",\n reason: String(error)\n }\n };\n updates[entry.jid] = {\n ...backfill.chats?.[entry.jid] ?? {},\n error: String(error),\n has_more: !0\n };\n }\n }\n }\n const minimum = Number.isFinite(Number(request.minimum_timestamp)) ? Number(request.minimum_timestamp) : null, recent = Number.isFinite(Number(request.recent_since)) ? Number(request.recent_since) : null, dirtyRanges = Array.isArray(request.dirty_ranges) ? request.dirty_ranges : [], dirtyByMessageId = new Map(dirtyRanges.filter((marker) => marker?.message_id).map((marker) => [marker.message_id, marker])), normalized = [], quarantined = [], names = nameIndex(collections);\n for (const model of uniqueMessageModels(collections)) {\n const message = await normalizeMessage(model, \"reconcile\", collections, names);\n if (!message)\n continue;\n if (message.timestamp <= 0) {\n quarantined.push({\n key: `${message.chat_jid}:${message.id}`,\n message_id: message.id,\n chat_jid: message.chat_jid,\n reason: \"missing_stable_timestamp\"\n });\n continue;\n }\n if (chatFilter === \"group\" && !message.is_group)\n continue;\n if (chatFilter === \"individual\" && message.is_group)\n continue;\n if (minimum != null && message.timestamp < minimum)\n continue;\n if (recent != null && message.timestamp < recent && !backfillMessageIds.has(message.id) && !dirtyByMessageId.has(message.id))\n continue;\n normalized.push(message);\n }\n normalized.sort((a, b) => a.timestamp - b.timestamp || a.id.localeCompare(b.id));\n const maxMessages = Math.max(1, Math.min(Number(request.max_messages) || 1000, 2000)), byId = new Map(normalized.map((message) => [message.id, message])), historyPages = [];\n for (const [chatJid, ids] of loadedByChat)\n historyPages.push({\n chat_jid: chatJid,\n ...updates[chatJid] ?? {},\n messages: ids.map((id) => byId.get(id)).filter(Boolean)\n });\n const messages = normalized.filter((message) => !backfillMessageIds.has(message.id)).slice(-maxMessages).sort((a, b) => a.timestamp - b.timestamp || a.id.localeCompare(b.id)), mergedChats = { ...backfill.chats ?? {}, ...updates };\n return {\n ok: !0,\n status,\n messages,\n history_pages: historyPages,\n quarantined,\n dirty_reconciled: normalized.filter((message) => dirtyByMessageId.has(message.id)).map((message) => ({\n key: dirtyByMessageId.get(message.id).key,\n message_id: message.id\n })),\n backfill: {\n complete: request.backfill_disabled === !0 || chatRows.length > 0 && chatRows.every((entry) => mergedChats[entry.jid]?.has_more === !1),\n cursor_chat_jid: cursor,\n inventory: chatRows.map((entry) => entry.jid),\n chats: updates\n }\n };\n }\n async function resolveChat(collections, input) {\n if (input?.self_chat === !0) {\n const me = meUser(), selfJid = (await canonicalJid(me)).jid;\n let self = null;\n for (const chat of models(collections.Chat))\n if ((await canonicalJid(modelData(chat).id ?? chat?.id)).jid === selfJid) {\n self = chat;\n break;\n }\n if (!self)\n throw Error(\"WhatsApp self chat is not loaded\");\n return self;\n }\n const requestedJidRaw = typeof input?.chat_jid === \"string\" ? input.chat_jid.trim().toLowerCase() : null, requestedJid = requestedJidRaw ? (await canonicalJid(requestedJidRaw)).jid : null, requestedName = typeof input?.chat_name === \"string\" ? input.chat_name.trim().toLowerCase() : null, matches = [];\n for (const chat of models(collections.Chat)) {\n const row = modelData(chat), jid = (await canonicalJid(row.id ?? chat?.id)).jid, name = String(row.name ?? row.formattedTitle ?? row.contact?.name ?? \"\").trim().toLowerCase();\n if (requestedJid ? jid === requestedJid : requestedName && name === requestedName)\n matches.push(chat);\n }\n if (matches.length === 0)\n throw Error(\"WhatsApp chat not found; pass an exact canonical chat_jid or exact chat_name\");\n if (matches.length > 1)\n throw Error(\"WhatsApp chat name is ambiguous; pass chat_jid\");\n return matches[0];\n }\n async function waitForPostState(check, label, timeoutMs = 2000) {\n const deadline = Date.now() + timeoutMs;\n do {\n if (check())\n return;\n await new Promise((resolve) => setTimeout(resolve, 50));\n } while (Date.now() < deadline);\n throw Error(`WhatsApp did not confirm ${label}`);\n }\n async function readMessages(input = {}) {\n const query = String(input.query ?? \"\").trim(), chatFilter = input.chat_filter ?? \"all\", limit = Math.min(100, Math.max(1, Math.trunc(Number(input.limit) || 50)));\n let before = null;\n if (input.cursor) {\n const cursor = JSON.parse(input.cursor);\n if (cursor.v !== 1 || !Number.isSafeInteger(cursor.before) || cursor.before <= 0 || cursor.query !== query || cursor.chat_filter !== chatFilter)\n throw Error(\"Invalid WhatsApp source cursor or changed query scope\");\n before = cursor.before;\n }\n const keyModule = requireFirst([\"WAWebMsgKey\"]), exactId = query.startsWith(\"id:\") ? query.slice(3) : null, database = await new Promise((resolve, reject) => {\n const request = indexedDB.open(\"model-storage\");\n request.onupgradeneeded = () => {\n request.transaction.abort();\n reject(Error(\"WhatsApp source history database is unavailable\"));\n };\n request.onerror = () => reject(request.error);\n request.onblocked = () => reject(Error(\"WhatsApp source history database is blocked\"));\n request.onsuccess = () => resolve(request.result);\n });\n let sourceRows;\n try {\n sourceRows = await new Promise((resolve, reject) => {\n const transaction = database.transaction(\"message\", \"readonly\");\n transaction.onabort = () => reject(transaction.error ?? Error(\"WhatsApp source read aborted\"));\n const index = transaction.objectStore(\"message\").index(\"rowId\"), range = before === null ? null : IDBKeyRange.upperBound(before, !0), request = index.openCursor(range, \"prev\"), rows = [];\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (!cursor) {\n resolve(rows);\n return;\n }\n if (!Number.isSafeInteger(cursor.key) || cursor.key <= 0 || typeof cursor.value.id !== \"string\") {\n reject(Error(\"WhatsApp source history has an unsupported key layout\"));\n return;\n }\n if (exactId !== null) {\n if (keyModule.fromString(cursor.value.id).id !== exactId) {\n cursor.continue();\n return;\n }\n resolve([{ position: cursor.key, id: cursor.value.id }]);\n return;\n }\n rows.push({ position: cursor.key, id: cursor.value.id });\n if (rows.length > limit)\n resolve(rows);\n else\n cursor.continue();\n };\n });\n } finally {\n database.close();\n }\n const hasMore = sourceRows.length > limit, page = sourceRows.slice(0, limit), collections = requireFirst([\"WAWebCollections\"]), selected = page.filter((row) => {\n const key = keyModule.fromString(row.id);\n if (exactId !== null && key.id !== exactId)\n return !1;\n const remote = widString(key.remote);\n if (remote === \"status@broadcast\" || remote.endsWith(\"@newsletter\"))\n return !1;\n const isGroup = remote.endsWith(\"@g.us\");\n return !(chatFilter === \"group\" && !isGroup) && !(chatFilter === \"individual\" && isGroup);\n }), results = [];\n if (selected.length) {\n const loaded = await collections.Msg.getMessagesById(selected.map((row) => row.id));\n if (loaded?.canceled || !Array.isArray(loaded?.messages))\n throw Error(\"Source message loading was canceled or unavailable\");\n const byKey = new Map(loaded.messages.map((model) => [String(model.id ?? modelData(model).id), model])), names = nameIndex(collections);\n for (const row of selected) {\n const model = byKey.get(row.id);\n if (!model)\n throw Error(\"Source message could not be loaded; retry the read\");\n const message = await normalizeMessage(model, \"snapshot\", collections, names);\n if (!message || message.timestamp <= 0)\n continue;\n if (exactId === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase()))\n continue;\n results.push(message);\n }\n }\n return {\n results,\n hasMore,\n ...hasMore ? { nextCursor: JSON.stringify({ v: 1, before: page[page.length - 1].position, query, chat_filter: chatFilter }) } : {}\n };\n }\n async function searchMessages(input) {\n const collections = requireFirst([\"WAWebCollections\"]), query = String(input?.query ?? \"\").trim();\n if (!query)\n throw Error(\"query is required\");\n const offset = Math.max(0, Number(input?.offset) || 0), requestedLimit = Math.max(1, Math.min(Number(input?.limit) || 50, 100));\n if (offset >= 100)\n throw Error(\"WhatsApp source search supports only the first 100 matches\");\n const limit = Math.min(requestedLimit, 100 - offset), searchSourceLimit = 100, chatFilter = [\"all\", \"individual\", \"group\"].includes(input?.chat_filter) ? input.chat_filter : \"all\", chat = input?.chat_jid || input?.chat_name || input?.self_chat === !0 ? await resolveChat(collections, input) : null;\n let scopedChats = chat ? [chat] : void 0;\n if (!chat && chatFilter !== \"all\") {\n scopedChats = [];\n for (const candidate of models(collections.Chat)) {\n const jid = (await canonicalJid(modelData(candidate).id ?? candidate?.id)).jid;\n if (!jid || jid === \"status@broadcast\" || jid.endsWith(\"@newsletter\"))\n continue;\n const isGroup = jid.endsWith(\"@g.us\");\n if (chatFilter === \"group\" ? isGroup : !isGroup)\n scopedChats.push(candidate);\n }\n }\n const search = requireFirst([\n \"WAWebChatMessageSearch\",\n \"WAWebMessageSearch\",\n \"WAWebSearchMessages\"\n ]);\n let found = null;\n for (const fn of [\n search?.searchMessages,\n search?.searchMsgs,\n search?.search\n ]) {\n if (typeof fn !== \"function\")\n continue;\n try {\n found = await fn.call(search, query, scopedChats, searchSourceLimit);\n break;\n } catch {}\n }\n let source = \"whatsapp_fts\", candidates = Array.isArray(found) ? found : models(found?.messages ?? found);\n if (!found) {\n source = \"loaded_model_fallback\";\n const needle = query.toLowerCase();\n candidates = uniqueMessageModels(collections).filter((model) => {\n const row = modelData(model);\n if (chat) {\n const chatId = widString(modelData(chat).id ?? chat?.id);\n if (widString(row.id?.remote ?? row.chatId) !== chatId)\n return !1;\n }\n return String(row.body ?? row.caption ?? \"\").toLowerCase().includes(needle);\n });\n }\n const normalized = [], names = nameIndex(collections);\n for (const candidate of candidates) {\n const model = candidate?.msg ?? candidate?.message ?? candidate, message = await normalizeMessage(model, \"search\", collections, names);\n if (!message || Number(message.timestamp) <= 0)\n continue;\n if (chatFilter === \"group\" && !message.is_group)\n continue;\n if (chatFilter === \"individual\" && message.is_group)\n continue;\n normalized.push(message);\n if (normalized.length >= searchSourceLimit)\n break;\n }\n return {\n source,\n results: normalized.slice(offset, offset + limit),\n hasMore: offset + limit < normalized.length\n };\n }\n async function draftMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), chat = await resolveChat(collections, input), text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const draft = {\n body: text,\n timestamp: Math.floor(Date.now() / 1000),\n type: \"chat\",\n mentionedJidList: [],\n quotedMsg: null\n }, module2 = requireFirst(DRAFT_MODULES);\n let applied = !1;\n for (const fn of [\n module2?.setDraft,\n module2?.setChatDraft,\n module2?.saveDraft\n ]) {\n if (typeof fn !== \"function\")\n continue;\n try {\n await fn.call(module2, chat, draft);\n applied = !0;\n break;\n } catch {\n try {\n await fn.call(module2, draft, chat);\n applied = !0;\n break;\n } catch {}\n }\n }\n if (!applied && typeof chat?.setDraft === \"function\") {\n await chat.setDraft(draft);\n applied = !0;\n }\n if (!applied)\n throw Error(\"WhatsApp draft capability is unavailable in this web build\");\n const stored = modelData(chat).draft ?? chat.get?.(\"draft\") ?? null;\n if (!stored || typeof stored !== \"object\" || stored.body !== text)\n throw Error(\"WhatsApp rejected the persistent draft shape\");\n return {\n drafted: !0,\n sent: !1,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n draft\n };\n }\n async function sendMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), chat = await resolveChat(collections, input), text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const module2 = requireFirst(SEND_MODULES);\n if (typeof module2?.createTextMsgData === \"function\" && typeof module2?.addAndSendTextMsg === \"function\") {\n const data = await module2.createTextMsgData(chat, text), plannedId = rawId(data?.id);\n if (!plannedId)\n throw Error(\"WhatsApp did not assign an id to the outgoing message\");\n await module2.addAndSendTextMsg(chat, data);\n return {\n sent: !0,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n message_id: plannedId\n };\n }\n const fn = module2?.sendTextMsgToChat ?? module2?.sendMessage ?? chat?.sendMessage;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp send capability is unavailable in this web build\");\n const result = fn === chat?.sendMessage ? await fn.call(chat, text) : await fn.call(module2, chat, text), messageId = rawId(modelData(result).id ?? result?.id);\n if (!messageId)\n throw Error(\"WhatsApp send acknowledgment has no raw message ID\");\n return {\n sent: !0,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n message_id: messageId\n };\n }\n function messageActionAllowed(message, predicateNames, legacyFlags) {\n const row = modelData(message);\n for (const flag of legacyFlags)\n if (row[flag] === !0)\n return !0;\n const capability = requireFirst([\"WAWebMsgActionCapability\"]);\n for (const name of predicateNames) {\n if (typeof capability?.[name] !== \"function\")\n continue;\n try {\n if (capability[name](message) === !0)\n return !0;\n } catch {}\n }\n return !1;\n }\n function resolveMessage(collections, id) {\n const raw = String(id ?? \"\").trim();\n if (!raw)\n throw Error(\"message_id is required\");\n const message = collectionByRawId(collections.Msg, raw);\n if (!message)\n throw Error(`WhatsApp message ${raw} is not loaded; sync or search it first`);\n return message;\n }\n async function editMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), before = modelData(message);\n if (!(before.id?.fromMe ?? before.fromMe))\n throw Error(\"WhatsApp only permits editing outgoing messages\");\n if (!messageActionAllowed(message, [\"canEditText\", \"canEditCaption\", \"canEnterEditingFlow\"], [\"canEdit\", \"isEditable\"]))\n throw Error(\"WhatsApp did not affirm that this message is currently editable\");\n const text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const module2 = requireFirst(EDIT_MODULES), fn = module2?.sendMessageEdit ?? module2?.editMessage ?? message?.edit;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp edit capability is unavailable in this web build\");\n await (fn === message?.edit ? fn.call(message, text) : fn.call(module2, message, text, {}));\n await waitForPostState(() => {\n const row = modelData(message);\n return row.body === text && Boolean(row.isEdited || row.editVersion || row.latestEditMsgKey);\n }, \"message edit\");\n return {\n edited: !0,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function reactMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), emoji = input?.remove ? \"\" : String(input?.emoji ?? \"\");\n if (!input?.remove && !emoji)\n throw Error(\"emoji is required unless remove=true\");\n const module2 = requireFirst(REACTION_MODULES), fn = module2?.sendReactionToMsg ?? module2?.sendReaction ?? message?.react;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp reaction capability is unavailable in this web build\");\n await (fn === message?.react ? fn.call(message, emoji) : fn.call(module2, message, emoji));\n await waitForPostState(() => {\n const row = modelData(message), reactions = normalizeReactions(row);\n if (reactions.length > 0)\n return input?.remove ? !reactions.some((reaction) => reaction.from_me) : reactions.some((reaction) => reaction.from_me && reaction.emoji === emoji);\n return input?.remove ? !0 : row.hasReaction === !0;\n }, \"reaction state\");\n return {\n reacted: !0,\n confirmed: input?.remove ? normalizeReactions(modelData(message)).length > 0 : !0,\n removed: Boolean(input?.remove),\n emoji: emoji || null,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function revokeMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), before = modelData(message);\n if (!(before.id?.fromMe ?? before.fromMe))\n throw Error(\"WhatsApp only permits revoking outgoing messages\");\n if (!messageActionAllowed(message, [\"canSenderRevokeMsg\", \"canAdminRevokeMsg\"], [\"canRevoke\", \"isRevokable\"]))\n throw Error(\"WhatsApp did not affirm that this message is currently revokable\");\n const module2 = requireFirst(REVOKE_MODULES), fn = module2?.sendRevokeMsgs ?? module2?.sendRevoke ?? module2?.revokeMessage ?? message?.sendRevoke ?? message?.revoke;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp revoke capability is unavailable in this web build\");\n if (fn === message?.sendRevoke || fn === message?.revoke)\n await fn.call(message);\n else\n await fn.call(module2, [message], modelData(message).id?.remote);\n await waitForPostState(() => {\n const row = modelData(message);\n return Boolean(row.isRevoked || row.revoked || row.type === \"revoked\");\n }, \"message revoke\");\n return {\n revoked: !0,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function blobFromMedia(model) {\n const row = modelData(model);\n let result = null;\n if (typeof model?.downloadMedia === \"function\")\n result = await model.downloadMedia({\n downloadEvenIfExpensive: !0,\n rmrReason: 1\n });\n result = result ?? modelData(model).mediaData?.mediaBlob ?? model?.mediaData?.mediaBlob ?? row.mediaBlob ?? null;\n if (!result) {\n const managerModule = requireFirst([\"WAWebDownloadManager\"]), manager = managerModule?.downloadManager ?? managerModule;\n if (typeof manager?.downloadAndMaybeDecrypt === \"function\")\n result = await manager.downloadAndMaybeDecrypt({\n directPath: row.directPath,\n encFilehash: row.encFilehash,\n filehash: row.filehash,\n mediaKey: row.mediaKey,\n mediaKeyTimestamp: row.mediaKeyTimestamp,\n type: row.type,\n mimetype: row.mimetype,\n downloadOrigin: null,\n partialVideoOpts: null,\n downloadQpl: new Proxy({}, {\n get: () => () => {}\n }),\n signal: new AbortController().signal\n });\n }\n if (result === \"NEED_POKE\" || result?.status === \"NEED_POKE\")\n return { status: \"NEED_POKE\" };\n const candidate = result?.blob ?? result?.mediaBlob ?? result;\n if (candidate instanceof Blob)\n return { status: \"downloaded\", blob: candidate };\n if (candidate instanceof ArrayBuffer || ArrayBuffer.isView(candidate))\n return {\n status: \"downloaded\",\n blob: new Blob([candidate], {\n type: row.mimetype || \"application/octet-stream\"\n })\n };\n if (candidate?.getData) {\n const data = await candidate.getData();\n if (data instanceof Blob)\n return { status: \"downloaded\", blob: data };\n if (data instanceof ArrayBuffer || ArrayBuffer.isView(data))\n return {\n status: \"downloaded\",\n blob: new Blob([data], { type: row.mimetype })\n };\n }\n return { status: row.directPath ? \"unavailable\" : \"expired\" };\n }\n function bytesToBase64(bytes) {\n let binary = \"\";\n const chunk = 32768;\n for (let i = 0;i < bytes.length; i += chunk)\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n return btoa(binary);\n }\n async function downloadMedia(input) {\n const collections = requireFirst([\"WAWebCollections\"]), model = resolveMessage(collections, input?.message_id), row = modelData(model);\n if (row.isViewOnce || row.viewOnce || row.type === \"view_once\")\n return { status: \"view_once\" };\n const limit = Math.max(1, Number(input?.max_bytes) || 1), size = Number(row.size ?? row.fileSize ?? 0);\n if (size > limit)\n return { status: \"too_large\", size_bytes: size };\n if ((row.type === \"video\" || String(row.mimetype ?? \"\").startsWith(\"video/\")) && size <= 0)\n return { status: \"metadata_only\", retryable: !0, size_bytes: null };\n const budgetMs = Math.max(0, Number(input?.timeout_ms) || 0);\n let downloaded, budgetTimer = null;\n try {\n downloaded = budgetMs ? await Promise.race([\n blobFromMedia(model),\n new Promise((_, reject) => {\n budgetTimer = setTimeout(() => reject(Object.assign(Error(\"media download exceeded its budget\"), { state: \"timeout_retryable\" })), budgetMs);\n })\n ]) : await blobFromMedia(model);\n } catch (error) {\n const detail = String(error), reported = String(error?.state ?? error?.status ?? \"\"), explicit = [\n \"NEED_POKE\",\n \"awaiting_primary_device\",\n \"view_once\",\n \"expired\",\n \"too_large\",\n \"timeout_retryable\",\n \"metadata_only\",\n \"unavailable\"\n ].find((state) => reported === state || detail.toLowerCase().includes(state.toLowerCase()));\n return {\n status: explicit ?? \"unavailable\",\n retryable: [\n \"NEED_POKE\",\n \"awaiting_primary_device\",\n \"timeout_retryable\",\n \"metadata_only\",\n \"unavailable\"\n ].includes(explicit ?? \"unavailable\"),\n detail: detail.slice(0, 200)\n };\n } finally {\n if (budgetTimer !== null)\n clearTimeout(budgetTimer);\n }\n if (!downloaded.blob)\n return downloaded;\n if (downloaded.blob.size > limit)\n return { status: \"too_large\", size_bytes: downloaded.blob.size };\n const bytes = new Uint8Array(await downloaded.blob.arrayBuffer());\n if (bytes.length === 0)\n return { status: \"unavailable\", detail: \"empty\" };\n const mime = downloaded.blob.type || row.mimetype || \"application/octet-stream\";\n return {\n status: \"downloaded\",\n attachment: {\n kind: mime.startsWith(\"audio/\") ? \"audio\" : mime.startsWith(\"image/\") ? \"image\" : \"file\",\n filename: row.filename ?? row.fileName ?? `whatsapp-${rawId(row.id ?? model?.id)}`,\n mime_type: mime,\n data: bytesToBase64(bytes),\n size_bytes: bytes.length\n }\n };\n }\n async function invoke(request) {\n try {\n if (Number(request?.adapter_version) !== 22)\n return {\n ok: !1,\n error: {\n state: \"adapter_mismatch\",\n reason: \"expected 22\"\n }\n };\n if (request.op === \"account_identity\") {\n const accountId = widString(meUser());\n return accountId ? { accountId } : null;\n }\n if (request.op === \"probe\") {\n const status = readiness();\n return status.ready ? { ok: !0, status, capabilities: operationCapabilities() } : { ok: !1, error: status };\n }\n if (request.op === \"listen\")\n return listen(request);\n if (request.op === \"publish_changes\")\n return await publishChanges(request);\n if (request.op === \"observe_messages\")\n return { ok: !0, ...await observeMessages(request.input) };\n if (operationCapabilities()[request.op] !== !0)\n return {\n ok: !1,\n error: {\n state: \"capability_unavailable\",\n reason: `${request.op} is unavailable in this WhatsApp Web build`\n }\n };\n if (request.op === \"collect\")\n return await collect(request);\n if (request.op === \"read_messages\")\n return { ok: !0, ...await readMessages(request.input) };\n if (request.op === \"download_media\")\n return { ok: !0, ...await downloadMedia(request) };\n if (request.op === \"search_messages\")\n return { ok: !0, ...await searchMessages(request.input) };\n if (request.op === \"draft_message\")\n return { ok: !0, ...await draftMessage(request.input) };\n if (request.op === \"send_message\")\n return { ok: !0, ...await sendMessage(request.input) };\n if (request.op === \"edit_message\")\n return { ok: !0, ...await editMessage(request.input) };\n if (request.op === \"react_message\")\n return { ok: !0, ...await reactMessage(request.input) };\n if (request.op === \"revoke_message\")\n return { ok: !0, ...await revokeMessage(request.input) };\n return {\n ok: !1,\n error: { state: \"unsupported_operation\", reason: String(request?.op) }\n };\n } catch (error) {\n return {\n ok: !1,\n error: {\n state: \"operation_failed\",\n reason: error instanceof Error ? error.message : String(error)\n }\n };\n }\n }\n globalThis.__owlettoWhatsAppAdapterV1 = { version: 22, invoke, detach };\n })();\n for (let i = 0; i < 40; i++) {\n const identity = await globalThis.__owlettoWhatsAppAdapterV1.invoke({ op: \"account_identity\", adapter_version: 22 });\n if (identity?.accountId) return identity;\n await new Promise(resolve => setTimeout(resolve, 250));\n }\n return null;\n })()"
21480
+ "expression": "(async () => {\n (function whatsAppWebAdapterProgram() {\n const SYSTEM_TYPES = new Set([\n \"gp2\",\n \"notification_template\",\n \"e2e_notification\"\n ]);\n let readinessSignature = null, readinessStableSince = 0;\n const existing = globalThis.__owlettoWhatsAppAdapterV1;\n if (existing?.version === 25)\n return;\n existing?.detach?.();\n const listeners = new Map;\n function detach(bindingId) {\n const selected = bindingId ? [listeners.get(bindingId)] : [...listeners.values()];\n for (const state of selected) {\n if (!state)\n continue;\n state.collection.off(\"add\", state.onAdd);\n state.collection.off(\"change\", state.onChange);\n window.removeEventListener(\"message\", state.onReply);\n listeners.delete(state.id);\n }\n }\n function listen(request) {\n const collection = requireFirst([\"WAWebCollections\"])?.Msg;\n if (typeof collection?.on !== \"function\" || typeof collection?.off !== \"function\")\n throw Error(\"WhatsApp message observation is unavailable in this build\");\n if (!request.bridge_id || !request.token)\n throw Error(\"A feed bridge is required\");\n const post = (state2, entry) => window.postMessage({\n type: \"lobu-feed-record\",\n token: state2.token,\n sequence: entry.sequence,\n record: entry.record\n }, location.origin), reportError = (state2, message, sequence = ++state2.sequence) => {\n state2.error = message;\n post(state2, {\n sequence,\n record: {\n id: \"whatsapp-web:source-observation-error\",\n source_error: message\n }\n });\n }, resident = listeners.get(request.bridge_id), previous = resident?.request.chat_filter === request.chat_filter && resident?.request.minimum_timestamp === request.minimum_timestamp ? resident : null;\n detach(request.bridge_id);\n const state = {\n ...previous ?? {\n id: request.bridge_id,\n collection,\n sequence: 0,\n pending: new Map,\n fingerprints: new Map,\n pendingBytes: 0,\n fingerprintBytes: 0,\n error: null\n },\n collection,\n error: null\n };\n state.token = request.token;\n state.request = request;\n state.post = (entry) => post(state, entry);\n const observe = (model) => {\n if (state.error)\n return;\n const sequence = ++state.sequence;\n new Promise((resolve) => resolve(messageReference(model))).then((record) => {\n if (listeners.get(state.id) !== state || !record || record.timestamp <= 0)\n return;\n if (state.request.chat_filter === \"group\" && !record.is_group)\n return;\n if (state.request.chat_filter === \"individual\" && record.is_group)\n return;\n if (state.request.minimum_timestamp != null && record.timestamp < state.request.minimum_timestamp)\n return;\n record = {\n id: record.id,\n events: [{\n id: record.id,\n event_type: \"message.created\",\n resource_ref: record.id,\n resource_type: \"message\",\n occurred_at: new Date(record.timestamp * 1000).toISOString()\n }]\n };\n const previous2 = state.pending.get(record.id), seen = state.fingerprints.get(record.id);\n if (seen && seen.sequence >= sequence)\n return;\n const fingerprint = JSON.stringify(record);\n if (seen?.fingerprint === fingerprint) {\n seen.sequence = sequence;\n return;\n }\n const bytes = new TextEncoder().encode(fingerprint).length;\n if (bytes > 131072 || state.pendingBytes - (previous2?.bytes ?? 0) + bytes > 16777216 || state.pending.size >= 1e4 && !previous2) {\n reportError(state, \"WhatsApp page observation buffer overflowed; recovery is required\", sequence);\n return;\n }\n const entry = { sequence, record, bytes };\n state.pendingBytes += bytes - (previous2?.bytes ?? 0);\n state.pending.set(record.id, entry);\n state.fingerprintBytes += bytes - (seen?.bytes ?? 0);\n state.fingerprints.delete(record.id);\n state.fingerprints.set(record.id, { fingerprint, sequence, bytes });\n while (state.fingerprints.size > 1e4 || state.fingerprintBytes > 16777216) {\n const oldest = state.fingerprints.keys().next().value;\n state.fingerprintBytes -= state.fingerprints.get(oldest).bytes;\n state.fingerprints.delete(oldest);\n }\n post(state, entry);\n }).catch(() => {\n if (listeners.get(state.id) !== state)\n return;\n reportError(state, \"WhatsApp source observation failed; recovery is required\", sequence);\n });\n };\n state.onAdd = (model) => observe(model);\n state.onChange = (model) => observe(model);\n state.onReply = (event) => {\n if (event.source !== window || event.origin !== location.origin || event.data?.token !== state.token)\n return;\n if (event.data.type === \"lobu-feed-record:stop\") {\n detach(state.id);\n return;\n }\n if (event.data.type !== \"lobu-feed-record:ack\")\n return;\n for (const [id, entry] of state.pending) {\n if (entry.sequence !== event.data.sequence)\n continue;\n if (event.data.ok) {\n state.pendingBytes -= entry.bytes;\n state.pending.delete(id);\n entry.resolve?.();\n } else\n entry.reject?.(Error(\"Browser rejected the source reference batch\"));\n break;\n }\n };\n listeners.set(state.id, state);\n try {\n collection.on(\"add\", state.onAdd);\n collection.on(\"change\", state.onChange);\n window.addEventListener(\"message\", state.onReply);\n } catch (error) {\n reportError(state, \"WhatsApp source observation failed; recovery is required\");\n throw error;\n }\n if (previous?.error)\n post(state, {\n sequence: ++state.sequence,\n record: { id: \"whatsapp-web:source-observation-error\", source_error: previous.error }\n });\n for (const entry of state.pending.values())\n post(state, entry);\n return { ok: !0, listening: !0 };\n }\n async function publishChanges(request) {\n const state = listeners.get(request.bridge_id);\n if (!state || state.token !== request.token)\n throw Error(\"Source listener is unavailable\");\n const record = request.batch, bytes = new TextEncoder().encode(JSON.stringify(record)).length, previous = state.pending.get(record.id);\n if (bytes > 131072 || state.pendingBytes - (previous?.bytes ?? 0) + bytes > 16777216 || state.pending.size >= 1e4 && !previous)\n throw Error(\"Source replay buffer is full\");\n await new Promise((resolve, reject) => {\n const timer = setTimeout(() => reject(Error(\"Source replay was not accepted by the browser\")), 1e4), entry = {\n record,\n bytes,\n sequence: ++state.sequence,\n resolve: () => {\n clearTimeout(timer);\n resolve();\n },\n reject: (error) => {\n clearTimeout(timer);\n reject(error);\n }\n };\n state.pendingBytes += bytes - (previous?.bytes ?? 0);\n state.pending.set(record.id, entry);\n state.post(entry);\n });\n return { ok: !0 };\n }\n function requireFirst(names) {\n for (const name of names)\n try {\n const module2 = window.require?.(name);\n if (module2)\n return module2;\n } catch {}\n return null;\n }\n function meUser() {\n const module2 = requireFirst([\n \"WAWebUserPrefsMeUser\",\n \"WAWebUserPrefsMe\",\n \"WAWebUserPrefs\"\n ]);\n if (!module2)\n return null;\n for (const accessor of [\n \"getMaybeMePnUser\",\n \"getMaybeMeUser\",\n \"getMeUser\",\n \"getMeUserOrThrow\",\n \"getMaybeMeLidUser\"\n ])\n try {\n const value = module2[accessor]?.();\n if (value)\n return value;\n } catch {}\n try {\n return module2.me ?? null;\n } catch {}\n return null;\n }\n async function ownJids() {\n const module2 = requireFirst([\"WAWebUserPrefsMeUser\"]), candidates = [meUser()];\n for (const accessor of [\"getMaybeMePnUser\", \"getMaybeMeLidUser\"])\n try {\n candidates.push(module2?.[accessor]?.());\n } catch {}\n const forms = new Set;\n for (const value of candidates) {\n const own = await canonicalJid(value);\n if (own.jid)\n forms.add(own.jid);\n if (own.lid)\n forms.add(own.lid);\n }\n return forms;\n }\n async function mentionsOwnAccount(row) {\n const addressed = [\n ...Array.isArray(row.mentionedJidList) ? row.mentionedJidList : [],\n row.quotedParticipant\n ].filter(Boolean);\n if (addressed.length === 0)\n return !1;\n const own = await ownJids();\n for (const value of addressed) {\n const candidate = await canonicalJid(value);\n if (own.has(candidate.jid) || candidate.lid && own.has(candidate.lid))\n return !0;\n }\n return !1;\n }\n const SEND_MODULES = [\n \"WAWebSendTextMsgChatAction\",\n \"WAWebSendMsgChatAction\",\n \"WAWebSendMessage\"\n ], REACTION_MODULES = [\n \"WAWebSendReactionMsgAction\",\n \"WAWebSendReactionMsg\",\n \"WAWebReactionAction\"\n ], REVOKE_MODULES = [\n \"WAWebChatSendMessages\",\n \"WAWebRevokeMsgAction\",\n \"WAWebDeleteChatAction\",\n \"WAWebRevokeMessage\"\n ], EDIT_MODULES = [\"WAWebSendMessageEditAction\", \"WAWebEditMessage\"], DRAFT_MODULES = [\n \"WAWebChatDraftUtils\",\n \"WAWebSetDraft\",\n \"WAWebComposeBoxActions\"\n ];\n function modelData(model) {\n return model?.attributes ?? model?._data ?? model ?? {};\n }\n function messageReference(model) {\n const row = modelData(model), key = row.id ?? model?.id, id = rawId(key), remote = widString(key?.remote ?? row.chatId ?? (key?.fromMe ? row.to : row.from));\n if (!id || !remote || remote === \"status@broadcast\" || remote.endsWith(\"@newsletter\") || SYSTEM_TYPES.has(row.type))\n return null;\n return { id, timestamp: unixSeconds(row), is_group: remote.endsWith(\"@g.us\") };\n }\n async function observeMessages(input = {}) {\n const after = input.after ?? null;\n if (after !== null && (!Number.isSafeInteger(after) || after < 0))\n throw Error(\"Invalid WhatsApp observation cursor\");\n const database = await new Promise((resolve, reject) => {\n const request = indexedDB.open(\"model-storage\");\n request.onupgradeneeded = () => {\n request.transaction.abort();\n reject(Error(\"WhatsApp source history database is unavailable\"));\n };\n request.onerror = () => reject(request.error);\n request.onblocked = () => reject(Error(\"WhatsApp source history database is blocked\"));\n request.onsuccess = () => resolve(request.result);\n });\n let rows;\n try {\n rows = await new Promise((resolve, reject) => {\n const transaction = database.transaction(\"message\", \"readonly\");\n transaction.onabort = () => reject(transaction.error ?? Error(\"WhatsApp source observation aborted\"));\n const request = transaction.objectStore(\"message\").index(\"rowId\").openCursor(after === null ? null : IDBKeyRange.lowerBound(after, !0), after === null ? \"prev\" : \"next\"), page2 = [];\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (!cursor) {\n resolve(page2);\n return;\n }\n if (!Number.isSafeInteger(cursor.key) || cursor.key <= 0 || typeof cursor.value.id !== \"string\") {\n reject(Error(\"WhatsApp source history has an unsupported key layout\"));\n return;\n }\n page2.push({ position: cursor.key, id: cursor.value.id, timestamp: unixSeconds(cursor.value), type: cursor.value.type });\n if (after === null || page2.length > 500)\n resolve(page2);\n else\n cursor.continue();\n };\n });\n } finally {\n database.close();\n }\n if (after === null)\n return { after: rows[0]?.position ?? 0, references: [], hasMore: !1 };\n const page = rows.slice(0, 500), references = [];\n if (page.length) {\n const keys = requireFirst([\"WAWebMsgKey\"]);\n if (typeof keys?.fromString !== \"function\")\n throw Error(\"WhatsApp source message keys are unavailable\");\n for (const row of page) {\n const reference = messageReference({ id: keys.fromString(row.id), t: row.timestamp, type: row.type });\n if (!reference)\n continue;\n if (reference.timestamp <= 0)\n continue;\n if (reference.timestamp < input.started_at)\n continue;\n if (input.chat_filter === \"group\" && !reference.is_group)\n continue;\n if (input.chat_filter === \"individual\" && reference.is_group)\n continue;\n references.push(reference);\n }\n }\n return { after: page[page.length - 1]?.position ?? after, references, hasMore: rows.length > 500 };\n }\n function models(collection) {\n if (Array.isArray(collection?._models))\n return collection._models;\n if (Array.isArray(collection?.models))\n return collection.models;\n if (typeof collection?.toArray === \"function\")\n try {\n return collection.toArray();\n } catch {}\n return [];\n }\n function widString(value) {\n if (typeof value === \"string\")\n return value;\n if (!value)\n return null;\n if (typeof value._serialized === \"string\")\n return value._serialized;\n try {\n const rendered = value.toString?.();\n return rendered && rendered !== \"[object Object]\" ? String(rendered) : null;\n } catch {\n return null;\n }\n }\n function rawId(value) {\n if (typeof value === \"string\")\n return value && !/^(?:true|false)_/i.test(value) ? value : null;\n if (typeof value?.id === \"string\")\n return value.id && !/^(?:true|false)_/i.test(value.id) ? value.id : null;\n return null;\n }\n function unixSeconds(row) {\n const value = Number(row?.t ?? row?.timestamp ?? row?.ephemeralStartTimestamp ?? 0);\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;\n }\n async function canonicalJid(value) {\n const original = widString(value);\n if (!original)\n return { jid: null, lid: null };\n let jid = original.toLowerCase();\n if (jid.endsWith(\"@c.us\"))\n jid = `${jid.slice(0, -5)}@s.whatsapp.net`;\n if (!jid.endsWith(\"@lid\"))\n return { jid, lid: null };\n const migration = requireFirst([\n \"WAWebLidMigrationUtils\",\n \"WAWebLidMigration\"\n ]), toPn = migration?.toPn ?? migration?.getPnForLid ?? migration?.lidToPhone;\n if (typeof toPn === \"function\")\n try {\n const converted = await toPn.call(migration, value), phoneJid = widString(converted);\n if (phoneJid)\n return {\n jid: phoneJid.endsWith(\"@c.us\") ? `${phoneJid.slice(0, -5)}@s.whatsapp.net` : phoneJid,\n lid: jid\n };\n } catch {}\n return { jid, lid: jid };\n }\n function collectionByRawId(collection, id) {\n if (!id)\n return null;\n for (const model of models(collection)) {\n const row = modelData(model);\n if (rawId(row.id ?? model?.id) === id)\n return model;\n }\n return null;\n }\n function reactionTargetId(row) {\n return rawId(row.reactionParentKey) ?? rawId(row.parentMsgKey) ?? rawId(row.parentMessageKey) ?? (typeof row.quotedStanzaID === \"string\" ? row.quotedStanzaID : null);\n }\n function normalizeReactions(row) {\n const source = row.reactions ?? row.reactionCollection ?? row.reactionsBySender;\n return (Array.isArray(source) ? source : models(source)).map((reaction) => {\n const data = modelData(reaction);\n return {\n emoji: data.text ?? data.reactionText ?? data.emoji ?? null,\n sender_jid: widString(data.senderUserJid ?? data.sender ?? data.author),\n from_me: Boolean(data.fromMe)\n };\n }).filter((reaction) => typeof reaction.emoji === \"string\" && reaction.emoji.length > 0);\n }\n function nameIndex(collections) {\n const byId = (collection) => {\n const map = new Map;\n for (const model of models(collection)) {\n const id = widString(modelData(model).id ?? model?.id);\n if (id && !map.has(id))\n map.set(id, model);\n }\n return map;\n };\n return { chats: byId(collections?.Chat), contacts: byId(collections?.Contact) };\n }\n function contactName(names, jid) {\n if (!jid)\n return null;\n const contact = names?.contacts?.get(jid);\n if (!contact)\n return null;\n const row = modelData(contact);\n return row.name ?? row.pushname ?? row.shortName ?? row.formattedName ?? null;\n }\n function chatName(names, jid) {\n if (!jid)\n return null;\n const chat = names?.chats?.get(jid);\n if (!chat)\n return null;\n const row = modelData(chat);\n return row.name ?? row.formattedTitle ?? row.contact?.name ?? row.contact?.pushname ?? null;\n }\n async function normalizeMessage(model, eventType = \"snapshot\", collectionsOverride = null, names = null) {\n const collections = collectionsOverride ?? requireFirst([\"WAWebCollections\"]);\n if (!collections)\n return null;\n const nameLookup = names ?? nameIndex(collections);\n let row = modelData(model), key = row.id ?? model?.id, id = rawId(key);\n if (!id)\n return null;\n if (row.type === \"reaction\") {\n const targetId = reactionTargetId(row), target = collectionByRawId(collections.Msg, targetId);\n if (target) {\n model = target;\n row = modelData(model);\n key = row.id ?? model?.id;\n id = rawId(key);\n }\n }\n const fromMe = Boolean(key?.fromMe ?? row.fromMe), remoteRaw = key?.remote ?? row.chatId, fromRaw = row.from, toRaw = row.to, authorRaw = row.author ?? key?.participant, chatRaw = remoteRaw ?? (fromMe ? toRaw : fromRaw), chat = await canonicalJid(chatRaw);\n if (!chat.jid || chat.jid === \"status@broadcast\" || chat.jid.endsWith(\"@newsletter\"))\n return null;\n const senderRaw = fromMe ? fromRaw : authorRaw ?? fromRaw, sender = await canonicalJid(senderRaw), participant = await canonicalJid(key?.participant ?? row.participant ?? (fromMe ? toRaw : null)), timestamp = unixSeconds(row), body = typeof row.body === \"string\" ? row.body : \"\", caption = typeof row.caption === \"string\" ? row.caption : \"\", quotedId = typeof row.quotedStanzaID === \"string\" ? row.quotedStanzaID : rawId(row.quotedMsg?.id ?? row.quotedMsgKey), type = typeof row.type === \"string\" ? row.type : \"unknown\";\n return {\n id,\n chat_jid: chat.jid,\n chat_lid: chat.lid,\n chat_name: chatName(nameLookup, widString(chatRaw)),\n sender_jid: sender.jid,\n sender_lid: sender.lid,\n push_name: contactName(nameLookup, widString(senderRaw)) ?? row.notifyName ?? null,\n participant: participant.jid,\n from_me: fromMe,\n is_group: chat.jid.endsWith(\"@g.us\"),\n timestamp,\n occurred_at: timestamp > 0 ? new Date(timestamp * 1000).toISOString() : null,\n body,\n caption,\n message_type: type,\n media_kind: type === \"ptt\" ? \"audio\" : [\"image\", \"video\", \"audio\", \"document\", \"sticker\"].includes(type) ? type : null,\n media_type: typeof row.mimetype === \"string\" ? row.mimetype : null,\n media_size: Number.isFinite(Number(row.size ?? row.fileSize)) ? Number(row.size ?? row.fileSize) : null,\n media_filename: row.filename ?? row.fileName ?? row.title ?? null,\n quoted_id: quotedId,\n mentions_me: await mentionsOwnAccount(row),\n is_forwarded: Boolean(row.isForwarded || Number(row.forwardingScore) > 0),\n is_starred: Boolean(row.star ?? row.isStarred),\n is_system_event: SYSTEM_TYPES.has(type),\n edited: Boolean(row.isEdited || row.editVersion || row.latestEditMsgKey),\n edit_timestamp: Number(row.editTimestamp ?? row.lastEditTimestamp) || null,\n revoked: Boolean(row.isRevoked || row.revoked || type === \"revoked\"),\n reactions: normalizeReactions(row),\n event_type: eventType\n };\n }\n function readiness() {\n if (typeof window.require !== \"function\")\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"whatsapp_runtime_unavailable\"\n };\n const collections = requireFirst([\"WAWebCollections\"]);\n if (!collections?.Msg || !collections?.Chat)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"collections_unavailable\"\n };\n const me = meUser(), qrVisible = Boolean(document.querySelector('[data-testid=\"qrcode\"], canvas[aria-label*=\"Scan\" i], [data-ref] canvas'));\n if (!me && qrVisible)\n return { ready: !1, state: \"logged_out\", reason: \"qr_code_visible\" };\n if (!me)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"authenticated_self_identity_unavailable\"\n };\n const socket = requireFirst([\"WAWebSocketModel\"])?.Socket, connection = socket ?? requireFirst([\"WAWebSocketState\", \"WAWebConn\", \"WAWebConnectionState\"]), connectionState = String(connection?.getSocketState?.() ?? connection?.state ?? connection?.socketState ?? \"\").toLowerCase();\n if (!connectionState)\n return {\n ready: !1,\n state: \"capability_unavailable\",\n reason: \"connection_state_unavailable\"\n };\n if (!/^(connected|open|ready|syncing)$/.test(connectionState))\n return {\n ready: !1,\n state: \"not_ready\",\n reason: `connection_${connectionState}`\n };\n if (socket) {\n const stream = String(socket.stream ?? \"\").toLowerCase();\n if (!stream)\n return {\n ready: !1,\n state: \"capability_unavailable\",\n reason: \"stream_state_unavailable\"\n };\n if (!/^(connected|open|ready)$/.test(stream))\n return { ready: !1, state: \"not_ready\", reason: `stream_${stream}` };\n if (socket.hasSynced === !1)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"initial_sync_incomplete\"\n };\n }\n const offlineDelivery = requireFirst([\n \"WAWebOfflineDelivery\",\n \"WAWebOfflineDeliveryState\"\n ]);\n if ((offlineDelivery?.isOfflineDeliveryComplete?.() ?? offlineDelivery?.offlineDeliveryComplete ?? offlineDelivery?.isComplete) === !1)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"offline_delivery_incomplete\"\n };\n const hydration = requireFirst([\n \"WAWebInitialSyncInfo\",\n \"WAWebHistorySync\",\n \"WAWebAppState\"\n ]);\n if ((hydration?.isInitialSyncComplete?.() ?? hydration?.initialSyncComplete ?? hydration?.isHydrated ?? !0) !== !0)\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"initial_sync_incomplete\"\n };\n if (!Array.isArray(collections.Chat._models) && !Array.isArray(collections.Chat.models))\n return {\n ready: !1,\n state: \"hydrating\",\n reason: \"chat_store_placeholder\"\n };\n const signature = `${widString(me)}:${models(collections.Chat).length}:${models(collections.Msg).length}`;\n if (signature !== readinessSignature) {\n readinessSignature = signature;\n readinessStableSince = Date.now();\n return { ready: !1, state: \"hydrating\", reason: \"stores_settling\" };\n }\n if (Date.now() - readinessStableSince < 500)\n return { ready: !1, state: \"hydrating\", reason: \"stores_settling\" };\n return {\n ready: !0,\n state: \"ready\",\n message_count: models(collections.Msg).length,\n chat_count: models(collections.Chat).length\n };\n }\n function operationCapabilities() {\n const search = requireFirst([\n \"WAWebChatMessageSearch\",\n \"WAWebMessageSearch\",\n \"WAWebSearchMessages\"\n ]), draft = requireFirst(DRAFT_MODULES), send = requireFirst(SEND_MODULES), edit = requireFirst(EDIT_MODULES), reaction = requireFirst(REACTION_MODULES), revoke = requireFirst(REVOKE_MODULES), hasFunction = (module2, names) => names.some((name) => typeof module2?.[name] === \"function\");\n return {\n read_messages: typeof indexedDB < \"u\" && typeof requireFirst([\"WAWebMsgKey\"])?.fromString === \"function\" && typeof requireFirst([\"WAWebCollections\"])?.Msg?.getMessagesById === \"function\",\n search_messages: hasFunction(search, [\"searchMessages\", \"searchMsgs\", \"search\"]) || Boolean(requireFirst([\"WAWebCollections\"])?.Msg),\n draft_message: hasFunction(draft, [\n \"setDraft\",\n \"setChatDraft\",\n \"saveDraft\"\n ]),\n send_message: hasFunction(send, [\n \"sendTextMsgToChat\",\n \"sendMessage\",\n \"addAndSendTextMsg\"\n ]),\n edit_message: hasFunction(edit, [\"sendMessageEdit\", \"editMessage\"]),\n react_message: hasFunction(reaction, [\n \"sendReactionToMsg\",\n \"sendReaction\"\n ]),\n revoke_message: hasFunction(revoke, [\"sendRevokeMsgs\", \"revokeMessage\"])\n };\n }\n function uniqueMessageModels(collections) {\n const byId = new Map;\n for (const message of models(collections.Msg)) {\n const id = rawId(modelData(message).id ?? message?.id);\n if (id)\n byId.set(id, message);\n }\n for (const chat of models(collections.Chat))\n for (const message of models(modelData(chat).msgs ?? chat?.msgs)) {\n const id = rawId(modelData(message).id ?? message?.id);\n if (id)\n byId.set(id, message);\n }\n return [...byId.values()];\n }\n async function resolveChat(collections, input) {\n if (input?.self_chat === !0) {\n const me = meUser(), selfJid = (await canonicalJid(me)).jid;\n let self = null;\n for (const chat of models(collections.Chat))\n if ((await canonicalJid(modelData(chat).id ?? chat?.id)).jid === selfJid) {\n self = chat;\n break;\n }\n if (!self)\n throw Error(\"WhatsApp self chat is not loaded\");\n return self;\n }\n const requestedJidRaw = typeof input?.chat_jid === \"string\" ? input.chat_jid.trim().toLowerCase() : null, requestedJid = requestedJidRaw ? (await canonicalJid(requestedJidRaw)).jid : null, requestedName = typeof input?.chat_name === \"string\" ? input.chat_name.trim().toLowerCase() : null, matches = [];\n for (const chat of models(collections.Chat)) {\n const row = modelData(chat), jid = (await canonicalJid(row.id ?? chat?.id)).jid, name = String(row.name ?? row.formattedTitle ?? row.contact?.name ?? \"\").trim().toLowerCase();\n if (requestedJid ? jid === requestedJid : requestedName && name === requestedName)\n matches.push(chat);\n }\n if (matches.length === 0)\n throw Error(\"WhatsApp chat not found; pass an exact canonical chat_jid or exact chat_name\");\n if (matches.length > 1)\n throw Error(\"WhatsApp chat name is ambiguous; pass chat_jid\");\n return matches[0];\n }\n async function waitForPostState(check, label, timeoutMs = 2000) {\n const deadline = Date.now() + timeoutMs;\n do {\n if (check())\n return;\n await new Promise((resolve) => setTimeout(resolve, 50));\n } while (Date.now() < deadline);\n throw Error(`WhatsApp did not confirm ${label}`);\n }\n async function readMessages(input = {}) {\n const query = String(input.query ?? \"\").trim(), chatFilter = input.chat_filter ?? \"all\", limit = Math.min(100, Math.max(1, Math.trunc(Number(input.limit) || 50)));\n let before = null;\n if (input.cursor) {\n const cursor = JSON.parse(input.cursor);\n if (cursor.v !== 1 || !Number.isSafeInteger(cursor.before) || cursor.before <= 0 || cursor.query !== query || cursor.chat_filter !== chatFilter)\n throw Error(\"Invalid WhatsApp source cursor or changed query scope\");\n before = cursor.before;\n }\n const keyModule = requireFirst([\"WAWebMsgKey\"]), exactId = query.startsWith(\"id:\") ? query.slice(3) : null, database = await new Promise((resolve, reject) => {\n const request = indexedDB.open(\"model-storage\");\n request.onupgradeneeded = () => {\n request.transaction.abort();\n reject(Error(\"WhatsApp source history database is unavailable\"));\n };\n request.onerror = () => reject(request.error);\n request.onblocked = () => reject(Error(\"WhatsApp source history database is blocked\"));\n request.onsuccess = () => resolve(request.result);\n });\n let sourceRows;\n try {\n sourceRows = await new Promise((resolve, reject) => {\n const transaction = database.transaction(\"message\", \"readonly\");\n transaction.onabort = () => reject(transaction.error ?? Error(\"WhatsApp source read aborted\"));\n const index = transaction.objectStore(\"message\").index(\"rowId\"), range = before === null ? null : IDBKeyRange.upperBound(before, !0), request = index.openCursor(range, \"prev\"), rows = [];\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (!cursor) {\n resolve(rows);\n return;\n }\n if (!Number.isSafeInteger(cursor.key) || cursor.key <= 0 || typeof cursor.value.id !== \"string\") {\n reject(Error(\"WhatsApp source history has an unsupported key layout\"));\n return;\n }\n if (exactId !== null) {\n if (keyModule.fromString(cursor.value.id).id !== exactId) {\n cursor.continue();\n return;\n }\n resolve([{ position: cursor.key, id: cursor.value.id }]);\n return;\n }\n rows.push({ position: cursor.key, id: cursor.value.id });\n if (rows.length > limit)\n resolve(rows);\n else\n cursor.continue();\n };\n });\n } finally {\n database.close();\n }\n const hasMore = sourceRows.length > limit, page = sourceRows.slice(0, limit), collections = requireFirst([\"WAWebCollections\"]), selected = page.filter((row) => {\n const key = keyModule.fromString(row.id);\n if (exactId !== null && key.id !== exactId)\n return !1;\n const remote = widString(key.remote);\n if (remote === \"status@broadcast\" || remote.endsWith(\"@newsletter\"))\n return !1;\n const isGroup = remote.endsWith(\"@g.us\");\n return !(chatFilter === \"group\" && !isGroup) && !(chatFilter === \"individual\" && isGroup);\n }), results = [];\n if (selected.length) {\n const loaded = await collections.Msg.getMessagesById(selected.map((row) => row.id));\n if (loaded?.canceled || !Array.isArray(loaded?.messages))\n throw Error(\"Source message loading was canceled or unavailable\");\n const byKey = new Map(loaded.messages.map((model) => [String(model.id ?? modelData(model).id), model])), names = nameIndex(collections);\n for (const row of selected) {\n const model = byKey.get(row.id);\n if (!model)\n throw Error(\"Source message could not be loaded; retry the read\");\n const message = await normalizeMessage(model, \"snapshot\", collections, names);\n if (!message || message.timestamp <= 0)\n continue;\n if (exactId === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase()))\n continue;\n results.push(message);\n }\n }\n return {\n results,\n hasMore,\n ...hasMore ? { nextCursor: JSON.stringify({ v: 1, before: page[page.length - 1].position, query, chat_filter: chatFilter }) } : {}\n };\n }\n async function searchMessages(input) {\n const collections = requireFirst([\"WAWebCollections\"]), query = String(input?.query ?? \"\").trim();\n if (!query)\n throw Error(\"query is required\");\n const offset = Math.max(0, Number(input?.offset) || 0), requestedLimit = Math.max(1, Math.min(Number(input?.limit) || 50, 100));\n if (offset >= 100)\n throw Error(\"WhatsApp source search supports only the first 100 matches\");\n const limit = Math.min(requestedLimit, 100 - offset), searchSourceLimit = 100, chatFilter = [\"all\", \"individual\", \"group\"].includes(input?.chat_filter) ? input.chat_filter : \"all\", chat = input?.chat_jid || input?.chat_name || input?.self_chat === !0 ? await resolveChat(collections, input) : null;\n let scopedChats = chat ? [chat] : void 0;\n if (!chat && chatFilter !== \"all\") {\n scopedChats = [];\n for (const candidate of models(collections.Chat)) {\n const jid = (await canonicalJid(modelData(candidate).id ?? candidate?.id)).jid;\n if (!jid || jid === \"status@broadcast\" || jid.endsWith(\"@newsletter\"))\n continue;\n const isGroup = jid.endsWith(\"@g.us\");\n if (chatFilter === \"group\" ? isGroup : !isGroup)\n scopedChats.push(candidate);\n }\n }\n const search = requireFirst([\n \"WAWebChatMessageSearch\",\n \"WAWebMessageSearch\",\n \"WAWebSearchMessages\"\n ]);\n let found = null;\n for (const fn of [\n search?.searchMessages,\n search?.searchMsgs,\n search?.search\n ]) {\n if (typeof fn !== \"function\")\n continue;\n try {\n found = await fn.call(search, query, scopedChats, searchSourceLimit);\n break;\n } catch {}\n }\n let source = \"whatsapp_fts\", candidates = Array.isArray(found) ? found : models(found?.messages ?? found);\n if (!found) {\n source = \"loaded_model_fallback\";\n const needle = query.toLowerCase();\n candidates = uniqueMessageModels(collections).filter((model) => {\n const row = modelData(model);\n if (chat) {\n const chatId = widString(modelData(chat).id ?? chat?.id);\n if (widString(row.id?.remote ?? row.chatId) !== chatId)\n return !1;\n }\n return String(row.body ?? row.caption ?? \"\").toLowerCase().includes(needle);\n });\n }\n const normalized = [], names = nameIndex(collections);\n for (const candidate of candidates) {\n const model = candidate?.msg ?? candidate?.message ?? candidate, message = await normalizeMessage(model, \"search\", collections, names);\n if (!message || Number(message.timestamp) <= 0)\n continue;\n if (chatFilter === \"group\" && !message.is_group)\n continue;\n if (chatFilter === \"individual\" && message.is_group)\n continue;\n normalized.push(message);\n if (normalized.length >= searchSourceLimit)\n break;\n }\n return {\n source,\n results: normalized.slice(offset, offset + limit),\n hasMore: offset + limit < normalized.length\n };\n }\n async function draftMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), chat = await resolveChat(collections, input), text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const draft = {\n body: text,\n timestamp: Math.floor(Date.now() / 1000),\n type: \"chat\",\n mentionedJidList: [],\n quotedMsg: null\n }, module2 = requireFirst(DRAFT_MODULES);\n let applied = !1;\n for (const fn of [\n module2?.setDraft,\n module2?.setChatDraft,\n module2?.saveDraft\n ]) {\n if (typeof fn !== \"function\")\n continue;\n try {\n await fn.call(module2, chat, draft);\n applied = !0;\n break;\n } catch {\n try {\n await fn.call(module2, draft, chat);\n applied = !0;\n break;\n } catch {}\n }\n }\n if (!applied && typeof chat?.setDraft === \"function\") {\n await chat.setDraft(draft);\n applied = !0;\n }\n if (!applied)\n throw Error(\"WhatsApp draft capability is unavailable in this web build\");\n const stored = modelData(chat).draft ?? chat.get?.(\"draft\") ?? null;\n if (!stored || typeof stored !== \"object\" || stored.body !== text)\n throw Error(\"WhatsApp rejected the persistent draft shape\");\n return {\n drafted: !0,\n sent: !1,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n draft\n };\n }\n async function sendMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), chat = await resolveChat(collections, input), text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const module2 = requireFirst(SEND_MODULES);\n if (typeof module2?.createTextMsgData === \"function\" && typeof module2?.addAndSendTextMsg === \"function\") {\n const data = await module2.createTextMsgData(chat, text), plannedId = rawId(data?.id);\n if (!plannedId)\n throw Error(\"WhatsApp did not assign an id to the outgoing message\");\n await module2.addAndSendTextMsg(chat, data);\n return {\n sent: !0,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n message_id: plannedId\n };\n }\n const fn = module2?.sendTextMsgToChat ?? module2?.sendMessage ?? chat?.sendMessage;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp send capability is unavailable in this web build\");\n const result = fn === chat?.sendMessage ? await fn.call(chat, text) : await fn.call(module2, chat, text), messageId = rawId(modelData(result).id ?? result?.id);\n if (!messageId)\n throw Error(\"WhatsApp send acknowledgment has no raw message ID\");\n return {\n sent: !0,\n chat_jid: widString(modelData(chat).id ?? chat?.id),\n message_id: messageId\n };\n }\n function messageActionAllowed(message, predicateNames, legacyFlags) {\n const row = modelData(message);\n for (const flag of legacyFlags)\n if (row[flag] === !0)\n return !0;\n const capability = requireFirst([\"WAWebMsgActionCapability\"]);\n for (const name of predicateNames) {\n if (typeof capability?.[name] !== \"function\")\n continue;\n try {\n if (capability[name](message) === !0)\n return !0;\n } catch {}\n }\n return !1;\n }\n function resolveMessage(collections, id) {\n const raw = String(id ?? \"\").trim();\n if (!raw)\n throw Error(\"message_id is required\");\n const message = collectionByRawId(collections.Msg, raw);\n if (!message)\n throw Error(`WhatsApp message ${raw} is not loaded; read it with id:${raw} from the live messages feed or search it first`);\n return message;\n }\n async function editMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), before = modelData(message);\n if (!(before.id?.fromMe ?? before.fromMe))\n throw Error(\"WhatsApp only permits editing outgoing messages\");\n if (!messageActionAllowed(message, [\"canEditText\", \"canEditCaption\", \"canEnterEditingFlow\"], [\"canEdit\", \"isEditable\"]))\n throw Error(\"WhatsApp did not affirm that this message is currently editable\");\n const text = String(input?.text ?? \"\");\n if (!text.trim())\n throw Error(\"text is required\");\n const module2 = requireFirst(EDIT_MODULES), fn = module2?.sendMessageEdit ?? module2?.editMessage ?? message?.edit;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp edit capability is unavailable in this web build\");\n await (fn === message?.edit ? fn.call(message, text) : fn.call(module2, message, text, {}));\n await waitForPostState(() => {\n const row = modelData(message);\n return row.body === text && Boolean(row.isEdited || row.editVersion || row.latestEditMsgKey);\n }, \"message edit\");\n return {\n edited: !0,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function reactMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), emoji = input?.remove ? \"\" : String(input?.emoji ?? \"\");\n if (!input?.remove && !emoji)\n throw Error(\"emoji is required unless remove=true\");\n const module2 = requireFirst(REACTION_MODULES), fn = module2?.sendReactionToMsg ?? module2?.sendReaction ?? message?.react;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp reaction capability is unavailable in this web build\");\n await (fn === message?.react ? fn.call(message, emoji) : fn.call(module2, message, emoji));\n await waitForPostState(() => {\n const row = modelData(message), reactions = normalizeReactions(row);\n if (reactions.length > 0)\n return input?.remove ? !reactions.some((reaction) => reaction.from_me) : reactions.some((reaction) => reaction.from_me && reaction.emoji === emoji);\n return input?.remove ? !0 : row.hasReaction === !0;\n }, \"reaction state\");\n return {\n reacted: !0,\n confirmed: input?.remove ? normalizeReactions(modelData(message)).length > 0 : !0,\n removed: Boolean(input?.remove),\n emoji: emoji || null,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function revokeMessage(input) {\n const collections = requireFirst([\"WAWebCollections\"]), message = resolveMessage(collections, input?.message_id), before = modelData(message);\n if (!(before.id?.fromMe ?? before.fromMe))\n throw Error(\"WhatsApp only permits revoking outgoing messages\");\n if (!messageActionAllowed(message, [\"canSenderRevokeMsg\", \"canAdminRevokeMsg\"], [\"canRevoke\", \"isRevokable\"]))\n throw Error(\"WhatsApp did not affirm that this message is currently revokable\");\n const module2 = requireFirst(REVOKE_MODULES), fn = module2?.sendRevokeMsgs ?? module2?.sendRevoke ?? module2?.revokeMessage ?? message?.sendRevoke ?? message?.revoke;\n if (typeof fn !== \"function\")\n throw Error(\"WhatsApp revoke capability is unavailable in this web build\");\n if (fn === message?.sendRevoke || fn === message?.revoke)\n await fn.call(message);\n else\n await fn.call(module2, [message], modelData(message).id?.remote);\n await waitForPostState(() => {\n const row = modelData(message);\n return Boolean(row.isRevoked || row.revoked || row.type === \"revoked\");\n }, \"message revoke\");\n return {\n revoked: !0,\n message_id: rawId(modelData(message).id ?? message?.id)\n };\n }\n async function invoke(request) {\n try {\n if (Number(request?.adapter_version) !== 25)\n return {\n ok: !1,\n error: {\n state: \"adapter_mismatch\",\n reason: \"expected 25\"\n }\n };\n if (request.op === \"account_identity\") {\n const accountId = widString(meUser());\n return accountId ? { accountId } : null;\n }\n if (request.op === \"probe\") {\n const status = readiness();\n return status.ready ? { ok: !0, status, capabilities: operationCapabilities() } : { ok: !1, error: status };\n }\n if (request.op === \"listen\")\n return listen(request);\n if (request.op === \"publish_changes\")\n return await publishChanges(request);\n if (request.op === \"observe_messages\")\n return { ok: !0, ...await observeMessages(request.input) };\n if (operationCapabilities()[request.op] !== !0)\n return {\n ok: !1,\n error: {\n state: \"capability_unavailable\",\n reason: `${request.op} is unavailable in this WhatsApp Web build`\n }\n };\n if (request.op === \"read_messages\")\n return { ok: !0, ...await readMessages(request.input) };\n if (request.op === \"search_messages\")\n return { ok: !0, ...await searchMessages(request.input) };\n if (request.op === \"draft_message\")\n return { ok: !0, ...await draftMessage(request.input) };\n if (request.op === \"send_message\")\n return { ok: !0, ...await sendMessage(request.input) };\n if (request.op === \"edit_message\")\n return { ok: !0, ...await editMessage(request.input) };\n if (request.op === \"react_message\")\n return { ok: !0, ...await reactMessage(request.input) };\n if (request.op === \"revoke_message\")\n return { ok: !0, ...await revokeMessage(request.input) };\n return {\n ok: !1,\n error: { state: \"unsupported_operation\", reason: String(request?.op) }\n };\n } catch (error) {\n return {\n ok: !1,\n error: {\n state: \"operation_failed\",\n reason: error instanceof Error ? error.message : String(error)\n }\n };\n }\n }\n globalThis.__owlettoWhatsAppAdapterV1 = { version: 25, invoke, detach };\n })();\n for (let i = 0; i < 40; i++) {\n const identity = await globalThis.__owlettoWhatsAppAdapterV1.invoke({ op: \"account_identity\", adapter_version: 25 });\n if (identity?.accountId) return identity;\n await new Promise(resolve => setTimeout(resolve, 250));\n }\n return null;\n })()"
20256
21481
  }
20257
21482
  },
20258
21483
  "webhook": null,
@@ -20285,177 +21510,6 @@
20285
21510
  "operations": [
20286
21511
  "read"
20287
21512
  ]
20288
- },
20289
- "messages": {
20290
- "webhook": {
20291
- "events": [
20292
- "message"
20293
- ],
20294
- "mode": "trigger"
20295
- },
20296
- "key": "messages",
20297
- "name": "Messages",
20298
- "description": "Personal WhatsApp messages from one-to-one and group chats. Syncs live changes and progressively hydrates history available to WhatsApp Web.",
20299
- "configSchema": {
20300
- "type": "object",
20301
- "properties": {
20302
- "chat_filter": {
20303
- "type": "string",
20304
- "enum": [
20305
- "all",
20306
- "individual",
20307
- "group"
20308
- ],
20309
- "default": "all",
20310
- "description": "Which chats to include."
20311
- },
20312
- "max_messages_per_sync": {
20313
- "type": "integer",
20314
- "minimum": 1,
20315
- "maximum": 1000,
20316
- "default": 1000,
20317
- "description": "Bounded maximum messages emitted per sync. Additional durable history resumes on later runs."
20318
- }
20319
- }
20320
- },
20321
- "eventKinds": {
20322
- "message": {
20323
- "description": "A WhatsApp message, caption, media placeholder, edit, revoke, or reaction-updated message.",
20324
- "metadataSchema": {
20325
- "type": "object",
20326
- "required": [
20327
- "source",
20328
- "origin_id",
20329
- "chat_jid",
20330
- "is_group",
20331
- "from_me"
20332
- ],
20333
- "properties": {
20334
- "source": {
20335
- "type": "string",
20336
- "const": "whatsapp_web"
20337
- },
20338
- "origin_id": {
20339
- "type": "string"
20340
- },
20341
- "chat_jid": {
20342
- "type": "string"
20343
- },
20344
- "is_group": {
20345
- "type": "boolean"
20346
- },
20347
- "from_me": {
20348
- "type": "boolean"
20349
- },
20350
- "is_direct_inbound": {
20351
- "type": "boolean"
20352
- },
20353
- "participant": {
20354
- "type": "string"
20355
- },
20356
- "sender_jid": {
20357
- "type": "string"
20358
- },
20359
- "sender_phone": {
20360
- "type": "string"
20361
- },
20362
- "push_name": {
20363
- "type": "string"
20364
- },
20365
- "media_type": {
20366
- "type": "string"
20367
- },
20368
- "quoted_id": {
20369
- "type": "string"
20370
- },
20371
- "is_forwarded": {
20372
- "type": "boolean"
20373
- },
20374
- "is_starred": {
20375
- "type": "boolean"
20376
- },
20377
- "is_system_event": {
20378
- "type": "boolean"
20379
- },
20380
- "edited": {
20381
- "type": "boolean"
20382
- },
20383
- "edit_timestamp": {
20384
- "type": "number"
20385
- },
20386
- "revoked": {
20387
- "type": "boolean"
20388
- },
20389
- "reactions": {
20390
- "type": "array",
20391
- "items": {
20392
- "type": "object"
20393
- }
20394
- },
20395
- "voice_note_skipped": {
20396
- "type": "string",
20397
- "enum": [
20398
- "not_downloaded",
20399
- "too_large",
20400
- "empty",
20401
- "read_error",
20402
- "invalid_path"
20403
- ]
20404
- },
20405
- "media_status": {
20406
- "type": "string",
20407
- "enum": [
20408
- "downloaded",
20409
- "awaiting_primary_device",
20410
- "view_once",
20411
- "expired",
20412
- "too_large",
20413
- "timeout_retryable",
20414
- "metadata_only",
20415
- "unavailable"
20416
- ]
20417
- }
20418
- }
20419
- },
20420
- "attributions": [
20421
- {
20422
- "role": "authored_by",
20423
- "autoCreate": true,
20424
- "target": {
20425
- "entityType": "person",
20426
- "createWhen": {
20427
- "path": "metadata.is_direct_inbound",
20428
- "equals": true
20429
- },
20430
- "titlePath": "metadata.push_name",
20431
- "identities": [
20432
- {
20433
- "namespace": "wa_jid",
20434
- "eventPath": "metadata.sender_jid"
20435
- },
20436
- {
20437
- "namespace": "phone",
20438
- "eventPath": "metadata.sender_phone"
20439
- }
20440
- ]
20441
- },
20442
- "traits": {
20443
- "push_name": {
20444
- "eventPath": "metadata.push_name",
20445
- "mergeStrategy": "prefer_non_empty"
20446
- },
20447
- "last_seen_at": {
20448
- "eventPath": "occurred_at",
20449
- "mergeStrategy": "overwrite"
20450
- }
20451
- }
20452
- }
20453
- ]
20454
- }
20455
- },
20456
- "operations": [
20457
- "sync"
20458
- ]
20459
21513
  }
20460
21514
  },
20461
21515
  "actions_schema": {
@@ -20514,6 +21568,9 @@
20514
21568
  "items": {
20515
21569
  "type": "object"
20516
21570
  }
21571
+ },
21572
+ "hasMore": {
21573
+ "type": "boolean"
20517
21574
  }
20518
21575
  }
20519
21576
  }
@@ -20793,7 +21850,7 @@
20793
21850
  "channel_id": {
20794
21851
  "type": "string",
20795
21852
  "title": "Chat",
20796
- "description": "WhatsApp chat ID. Replies into a group need this set to that group."
21853
+ "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."
20797
21854
  }
20798
21855
  }
20799
21856
  },
@@ -20899,8 +21956,8 @@
20899
21956
  {
20900
21957
  "id": "x",
20901
21958
  "name": "X (Twitter)",
20902
- "version": "3.14.2",
20903
- "description": "Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, and reads the chronological Following timeline live through the X API. Links social actors into the person graph.",
21959
+ "version": "3.15.0",
21960
+ "description": "Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, and reads and answers DMs live in the paired browser. Links social actors into the person graph.",
20904
21961
  "detail": {
20905
21962
  "source_path": "x.ts",
20906
21963
  "auth_schema": {
@@ -20958,6 +22015,20 @@
20958
22015
  },
20959
22016
  "webhook": null,
20960
22017
  "feeds_schema": {
22018
+ "live_messages": {
22019
+ "key": "live_messages",
22020
+ "name": "Live messages",
22021
+ "description": "Read recent X direct messages live from the paired browser without importing history or marking them read, page by the returned cursor, or read one message by id:<message id>. Message requests from accounts the user does not follow are included and marked is_request. Active Automations subscribe to new-message references; the browser checks once a minute while it is online and resumes from X's inbox update cursor after reconnecting. Requires a browser-authenticated X connection.",
22022
+ "webhook": {
22023
+ "mode": "trigger",
22024
+ "events": [
22025
+ "message.created"
22026
+ ]
22027
+ },
22028
+ "operations": [
22029
+ "read"
22030
+ ]
22031
+ },
20961
22032
  "following_timeline": {
20962
22033
  "key": "following_timeline",
20963
22034
  "name": "Following Timeline (live)",
@@ -22177,6 +23248,67 @@
22177
23248
  }
22178
23249
  },
22179
23250
  "actions_schema": {
23251
+ "send_message": {
23252
+ "key": "send_message",
23253
+ "kind": "write",
23254
+ "name": "Send DM reply",
23255
+ "description": "Requires an X connection authenticated through your paired Chrome browser. Send a text reply into an exact existing X direct message conversation and confirm it appears there. This direct send is approved only for answering DMs on bot accounts the owner operates; public replies and posts stay draft-only through prepare_reply. On retry, reuse both this input's idempotency_key and the enclosing operations.execute idempotency_key. The browser can recognise an earlier send only while its request ID is on the latest conversation page; matching recent text without a request ID is refused.",
23256
+ "annotations": {
23257
+ "destructiveHint": false,
23258
+ "idempotentHint": false,
23259
+ "openWorldHint": true
23260
+ },
23261
+ "inputSchema": {
23262
+ "type": "object",
23263
+ "required": [
23264
+ "conversation_id",
23265
+ "text",
23266
+ "idempotency_key"
23267
+ ],
23268
+ "additionalProperties": false,
23269
+ "properties": {
23270
+ "conversation_id": {
23271
+ "type": "string",
23272
+ "pattern": "^[0-9]{1,20}(-[0-9]{1,20})?$",
23273
+ "description": "Exact X DM conversation ID, the conversation_id of a live_messages row."
23274
+ },
23275
+ "text": {
23276
+ "type": "string",
23277
+ "minLength": 1,
23278
+ "maxLength": 10000
23279
+ },
23280
+ "idempotency_key": {
23281
+ "type": "string",
23282
+ "minLength": 1,
23283
+ "maxLength": 200,
23284
+ "description": "Stable key used to derive X's client request ID. Reuse it and the enclosing operation's idempotency_key on retry; browser deduplication only checks the latest conversation page."
23285
+ }
23286
+ }
23287
+ },
23288
+ "outputSchema": {
23289
+ "type": "object",
23290
+ "properties": {
23291
+ "sent": {
23292
+ "type": "boolean"
23293
+ },
23294
+ "deduplicated": {
23295
+ "type": "boolean"
23296
+ },
23297
+ "id": {
23298
+ "type": "string"
23299
+ },
23300
+ "message_id": {
23301
+ "type": "string"
23302
+ },
23303
+ "conversation_id": {
23304
+ "type": "string"
23305
+ },
23306
+ "occurred_at": {
23307
+ "type": "string"
23308
+ }
23309
+ }
23310
+ }
23311
+ },
22180
23312
  "prepare_reply": {
22181
23313
  "key": "prepare_reply",
22182
23314
  "kind": "write",
@@ -22278,7 +23410,47 @@
22278
23410
  }
22279
23411
  }
22280
23412
  },
22281
- "automation_events": null,
23413
+ "automation_events": [
23414
+ {
23415
+ "key": "message.created",
23416
+ "label": "New DM",
23417
+ "resourceType": "message",
23418
+ "description": "A new X direct message reference from the paired browser. The Automation reads its content from the live messages feed, or replies in the conversation it came from.",
23419
+ "filterSchema": {
23420
+ "type": "object",
23421
+ "properties": {
23422
+ "channel_id": {
23423
+ "type": "string",
23424
+ "title": "Conversation",
23425
+ "description": "X DM conversation ID."
23426
+ }
23427
+ }
23428
+ },
23429
+ "capabilities": {
23430
+ "replyToSource": true
23431
+ }
23432
+ },
23433
+ {
23434
+ "key": "tweet",
23435
+ "label": "Tweet"
23436
+ },
23437
+ {
23438
+ "key": "reply",
23439
+ "label": "Reply"
23440
+ },
23441
+ {
23442
+ "key": "liked_tweet",
23443
+ "label": "Liked Tweet"
23444
+ },
23445
+ {
23446
+ "key": "bookmark",
23447
+ "label": "Bookmark"
23448
+ },
23449
+ {
23450
+ "key": "dm_message",
23451
+ "label": "DM Message"
23452
+ }
23453
+ ],
22282
23454
  "options_schema": null,
22283
23455
  "favicon_domain": "x.com",
22284
23456
  "required_capability": null,