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