@lobu/runtime-server 24.1.1 → 24.3.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/connectors.json +175 -39
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -1
- package/dist/connectors/gchat.ts +31 -1
- package/dist/connectors/google_gmail.ts +70 -41
- package/dist/connectors/google_gmail_references.ts +406 -0
- package/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/dist/connectors/linkedin-inbox.ts +13 -0
- package/dist/connectors/linkedin.ts +1 -1
- package/dist/connectors/postgres.ts +14 -8
- package/dist/connectors/reddit.ts +171 -5
- package/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/dist/connectors/whatsapp_web.ts +48 -17
- package/dist/connectors/x-dm-adapter.js +252 -35
- package/dist/connectors/x.ts +189 -13
- package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +3 -1
- package/dist/db/migrations/20261024050000_events_source_reference_arrival.sql +27 -0
- package/dist/db/migrations/20261026000000_turn_write_receipts.sql +36 -0
- package/dist/db/migrations/20261026190000_federated_relationship_endpoints.sql +143 -0
- package/dist/dependencies.bun.lock +137 -202
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-XKF0m81R.js +3 -0
- package/dist/owletto/dist/assets/_-e8MbEBtw.js +2 -0
- package/dist/owletto/dist/assets/_agentId-Cv9goIFf.js +2 -0
- package/dist/owletto/dist/assets/_agentId-emObu67X.js +2 -0
- package/dist/owletto/dist/assets/_automationId-CfFFAYK1.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D6NKXSOE.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-DFrkLLTU.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-D3vuAQPe.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BV5SQaUA.js +2 -0
- package/dist/owletto/dist/assets/_name-DjtJMop4.js +2 -0
- package/dist/owletto/dist/assets/_owner-oBX68rb9.js +3 -0
- package/dist/owletto/dist/assets/_shape-C4lLPAwI.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-Cw-7q6hI.js +2 -0
- package/dist/owletto/dist/assets/_slug-B2g5qzn3.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CIKGCtdK.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-Dx4kJo7o.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-38lHBvjO.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-voRYSM3a.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-DiU7Un5w.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-Bkyw22GW.js} +4 -4
- package/dist/owletto/dist/assets/agent-connect-pages-CpBxQCpx.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-QrIDroFL.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-CyoGSxcZ.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-CamDtzHY.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-CgsQ8BK_.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-lWbXKEm1.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-D-w3tY_2.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-CLqpn5Tb.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-CsRexwTv.js} +4 -4
- package/dist/owletto/dist/assets/agents-DzH_FFKU.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-CmGrMvPC.js +2 -0
- package/dist/owletto/dist/assets/app-bridge-C4nPtae3.js +121 -0
- package/dist/owletto/dist/assets/app._appId-BO7G38fL.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DMYxs6F6.js +2 -0
- package/dist/owletto/dist/assets/automations-DzH_FFKU.js +2 -0
- package/dist/owletto/dist/assets/calendar-DDCCSPW6.js +2 -0
- package/dist/owletto/dist/assets/callback-DFciMR8u.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-BCsbrdGs.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-BRua2b_7.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-BLIy1Zc3.js +2 -0
- package/dist/owletto/dist/assets/client-rows-DiJQ5D1z.js +2 -0
- package/dist/owletto/dist/assets/clients-8-EpRjsm.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-BFZa4EIt.js} +3 -3
- package/dist/owletto/dist/assets/connect-C0cHE9Xl.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-D2K4tmvW.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-D4EG5a0v.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-DhoCT6sT.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-Dn4qw2Us.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-BTI5JXA3.js +2 -0
- package/dist/owletto/dist/assets/connection-X9VU9Ijm.js +2 -0
- package/dist/owletto/dist/assets/connection-feed-detail-B6ydKasK.js +2 -0
- package/dist/owletto/dist/assets/connections-browser-BMV8bf54.js +2 -0
- package/dist/owletto/dist/assets/connector-boxes-DqZA-FdG.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-BIg8P8WY.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CJYz53YF.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-BroKpwhB.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-fzLN-Qy7.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-Df7QXE0w.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-A1UnFbGs.js} +2 -2
- package/dist/owletto/dist/assets/create-BjwsYarn.js +2 -0
- package/dist/owletto/dist/assets/create-Dzr4mlr0.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-DHW6OUoS.js +3 -0
- package/dist/owletto/dist/assets/create-c94SPL21.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-DLLn2nej.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-xxpD1P2-.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-C3AEoL5c.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-2U0UMu3_.js → device-pin-tombstone-B_te59GE.js} +2 -2
- package/dist/owletto/dist/assets/device._deviceId-ZU09qrot.js +2 -0
- package/dist/owletto/dist/assets/elk-worker.min-BENGc9gn.js +23 -0
- package/dist/owletto/dist/assets/{entity-avatar-mdh7Kq5D.js → entity-avatar-CEV4ttUQ.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-DJv2EhVV.js +2 -0
- package/dist/owletto/dist/assets/entity-page-BUghWZ1s.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-Lf6ONdpf.js +2 -0
- package/dist/owletto/dist/assets/event-card-CBlsG32u.js +2 -0
- package/dist/owletto/dist/assets/event-detail-BKSGEOdW.js +2 -0
- package/dist/owletto/dist/assets/events-feed-VfU4csn2.js +2 -0
- package/dist/owletto/dist/assets/feed-event-kinds-BYuZCoU4.js +2 -0
- package/dist/owletto/dist/assets/filter-bar-COU0sBFQ.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-C1Q_jEzD.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-6ZJv1uzM.js +2 -0
- package/dist/owletto/dist/assets/identity-BaFLmbSo.js +2 -0
- package/dist/owletto/dist/assets/index-008wj-Pz.js +7950 -0
- package/dist/owletto/dist/assets/index-BaetvYLa.js +2 -0
- package/dist/owletto/dist/assets/index-BiEf5xOE.css +1 -0
- package/dist/owletto/dist/assets/{index-CxF2XXzl.js → index-BrDP4PCs.js} +2 -2
- package/dist/owletto/dist/assets/index-BuXIeK7D.js +2 -0
- package/dist/owletto/dist/assets/index-CAVcR9za.js +2 -0
- package/dist/owletto/dist/assets/index-CMLfWGPU.js +2 -0
- package/dist/owletto/dist/assets/index-D0YEYP7N.js +2 -0
- package/dist/owletto/dist/assets/index-DFyBbp7b.js +2 -0
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DNtYqkiA.js} +2 -2
- package/dist/owletto/dist/assets/index-DQxzeM37.js +2 -0
- package/dist/owletto/dist/assets/index-DkO0nPex.js +2 -0
- package/dist/owletto/dist/assets/index-KlRId0g6.js +2 -0
- package/dist/owletto/dist/assets/index-Ywnqi4A6.js +2 -0
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-xnxhf3Op.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-yIub2xUM.js} +2 -2
- package/dist/owletto/dist/assets/json-diff-LE_vNZrM.js +4 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-Kzxi2OXB.js} +2 -2
- package/dist/owletto/dist/assets/login-DWOT6jtS.js +2 -0
- package/dist/owletto/dist/assets/logout-Dt_VDilG.js +2 -0
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-De75CR7W.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-p2vIbfkC.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-3l9lY50C.js} +2 -2
- package/dist/owletto/dist/assets/model-udnQ_S43.js +2 -0
- package/dist/owletto/dist/assets/models-CQj7GIOp.js +2 -0
- package/dist/owletto/dist/assets/new-BOwIHkre.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-BbdwuJPm.js} +2 -2
- package/dist/owletto/dist/assets/new-DTuFCQhV.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-QPo4YwRX.js} +2 -2
- package/dist/owletto/dist/assets/organization-BDzjnqPf.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-D7yt0PrA.js +2 -0
- package/dist/owletto/dist/assets/permissions-CfoY4WFY.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CVkLnnKo.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-DXUTTGGp.js +2 -0
- package/dist/owletto/dist/assets/record-activity-BXhvJbd9.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-D07szzqN.js} +2 -2
- package/dist/owletto/dist/assets/renderer-AJxSmE3-.js +97 -0
- package/dist/owletto/dist/assets/reset-password-kRYyQuTY.js +2 -0
- package/dist/owletto/dist/assets/runs-lG2ChtOt.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-LnGpHCAQ.js +2 -0
- package/dist/owletto/dist/assets/schema-type-editor-panel-C_Es0qDf.js +2 -0
- package/dist/owletto/dist/assets/settings-CEAOg7fr.js +2 -0
- package/dist/owletto/dist/assets/settings-gGYXbFfd.js +2 -0
- package/dist/owletto/dist/assets/skills-BOL5c_Tk.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-CjFPgKKJ.js +2 -0
- package/dist/owletto/dist/assets/status-dot-CSBtKT4g.js +2 -0
- package/dist/owletto/dist/assets/table-DHM-vCxP.js +2 -0
- package/dist/owletto/dist/assets/use-automations-C4TSie1i.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-PfZrNbu_.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-D-fJx_Md.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-DkX4YdDT.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-2ubIf_3N.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +137007 -132255
- package/npm-shrinkwrap.json +723 -1095
- package/package.json +7 -10
- package/vendor/@better-auth-kysely-adapter/LICENSE.md +20 -0
- package/vendor/@better-auth-kysely-adapter/README.md +17 -0
- package/vendor/@better-auth-kysely-adapter/dist/bun-sqlite-dialect-DoOVo4ja.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/d1-sqlite-dialect-Cru74LbR.mjs +133 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.d.mts +116 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.mjs +719 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.d.mts +27 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/sqlite-introspector-DSCAP82F.mjs +90 -0
- package/vendor/@better-auth-kysely-adapter/package.json +52 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +34 -1
- package/vendor/connector-sdk/dist/index.d.ts +3 -1
- package/vendor/connector-sdk/dist/index.js +4 -0
- package/vendor/connector-sdk/dist/redact.d.ts +10 -0
- package/vendor/connector-sdk/dist/redact.js +130 -0
- package/vendor/connector-sdk/dist/types.d.ts +2 -1
- package/vendor/connector-sdk/package.json +6 -1
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +4 -1
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +117 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +47 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/errors.d.ts +0 -20
- package/vendor/core/dist/errors.js +1 -25
- package/vendor/core/dist/otel.js +38 -10
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/utils/ajv.js +3 -1
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +31 -5
- package/vendor/postgres/.bun-tag-22d644c2873790db +0 -0
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- package/vendor/views/dist/api.js +31 -7
- package/vendor/views/dist/bridge.d.ts +2 -1
- package/vendor/views/dist/bridge.js +10 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-BorucF19.js +0 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +0 -2
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DgRrCE2B.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DSrZIYcs.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DWxv1uoi.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BTP5ijdT.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-98Y3RuRO.js +0 -2
- package/dist/owletto/dist/assets/_deploymentId-B1UWPY0i.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BAnr8g8z.js +0 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +0 -2
- package/dist/owletto/dist/assets/_owner-C79BwQ0I.js +0 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +0 -2
- package/dist/owletto/dist/assets/_slug-DbPdDc-5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-UXU5Fx2G.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-D7ORHntE.js +0 -2
- package/dist/owletto/dist/assets/agent-card-controls-CplnPhbv.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BmknviTI.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-TdvvIc_J.js +0 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-BkZu1LYE.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-B3vvvZZe.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-CZJvnjNC.js +0 -2
- package/dist/owletto/dist/assets/agents-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-DJ67GZ93.js +0 -2
- package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +0 -128
- package/dist/owletto/dist/assets/app._appId-Cp78oEZ9.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-DSwbRpbx.js +0 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/callback-CBexCo3F.js +0 -2
- package/dist/owletto/dist/assets/client-rows-BYbsXGy9.js +0 -2
- package/dist/owletto/dist/assets/clients-BhNl1tVq.js +0 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-BqprYeOX.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-DhRoSzBr.js +0 -2
- package/dist/owletto/dist/assets/connection-CNm2ukrI.js +0 -2
- package/dist/owletto/dist/assets/connection-feed-detail-WcGCA6qY.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-CrtnAs0Q.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CRFEpSvk.js +0 -2
- package/dist/owletto/dist/assets/conversations-table-D_HOe1jN.js +0 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +0 -2
- package/dist/owletto/dist/assets/create-CCjZxIkK.js +0 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-Bpy92SM5.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +0 -2
- package/dist/owletto/dist/assets/deployments-C5hvipQh.js +0 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +0 -2
- package/dist/owletto/dist/assets/deployments-body-DGII20dQ.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-Bn37UpWH.js +0 -2
- package/dist/owletto/dist/assets/entity-options-Clz_WXK-.js +0 -2
- package/dist/owletto/dist/assets/entity-page-D3e4iPle.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-DebN1vCM.js +0 -2
- package/dist/owletto/dist/assets/event-detail-DV_zfWnC.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-Bwhqj7lY.js +0 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +0 -2
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +0 -2
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +0 -2
- package/dist/owletto/dist/assets/index-9YuSRymd.js +0 -7950
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +0 -2
- package/dist/owletto/dist/assets/index-B64PGxQm.js +0 -2
- package/dist/owletto/dist/assets/index-BSH07yVD.css +0 -1
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +0 -2
- package/dist/owletto/dist/assets/index-CDz3-ieP.js +0 -12
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +0 -2
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +0 -2
- package/dist/owletto/dist/assets/index-DB1iWI_a.js +0 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +0 -2
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +0 -2
- package/dist/owletto/dist/assets/index-Vcq4gwWv.js +0 -2
- package/dist/owletto/dist/assets/index-fgAJydgX.js +0 -2
- package/dist/owletto/dist/assets/json-diff-DIN5Jhfx.js +0 -4
- package/dist/owletto/dist/assets/login-DxGYyE4n.js +0 -2
- package/dist/owletto/dist/assets/logout-Bkzc7J44.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-BnuhLJ6X.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-D_UlBa27.js +0 -103
- package/dist/owletto/dist/assets/models-BAVeysNq.js +0 -2
- package/dist/owletto/dist/assets/new-C2av0diq.js +0 -2
- package/dist/owletto/dist/assets/new-snm1ctHn.js +0 -2
- package/dist/owletto/dist/assets/organization-Cb0W823y.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-BNR9ImQY.js +0 -2
- package/dist/owletto/dist/assets/permissions-Dv39zWKt.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CFhOqCLf.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +0 -2
- package/dist/owletto/dist/assets/recent-QhnLDU1_.js +0 -2
- package/dist/owletto/dist/assets/record-activity-ZJntBfN_.js +0 -2
- package/dist/owletto/dist/assets/record-field-peek-Brh1IQGy.js +0 -2
- package/dist/owletto/dist/assets/reset-password-CzZw6RcC.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-C0_DNTcq.js +0 -2
- package/dist/owletto/dist/assets/runs-table-B1APZv7d.js +0 -2
- package/dist/owletto/dist/assets/schema-value-normalization-CKdPjdPC.js +0 -97
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +0 -2
- package/dist/owletto/dist/assets/settings-VDNiffKU.js +0 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-BdfOVPWn.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-B0quibBi.js +0 -2
- /package/vendor/{postgres/.bun-tag-2f292c6554a8475e → @better-auth-kysely-adapter/.bun-tag-abf95749a412716} +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/** Gmail mailbox additions, retained as references rather than email content. */
|
|
2
|
+
import type {
|
|
3
|
+
EventEnvelope,
|
|
4
|
+
HttpClient,
|
|
5
|
+
SyncContext,
|
|
6
|
+
SyncResult,
|
|
7
|
+
} from '@lobu/connector-sdk';
|
|
8
|
+
|
|
9
|
+
const BASE = 'https://gmail.googleapis.com/gmail/v1/users/me';
|
|
10
|
+
const REQUEST_BUDGET = 20;
|
|
11
|
+
|
|
12
|
+
export interface GmailReferenceState {
|
|
13
|
+
version: 1;
|
|
14
|
+
account: string;
|
|
15
|
+
history_id: string;
|
|
16
|
+
inventory?: { page_token?: string; recent_tokens?: string[] };
|
|
17
|
+
partial?: { record_id: string; after_message_id: string; digest: string };
|
|
18
|
+
history_page?: { token: string; recent_tokens?: string[] };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ReferenceCheckpoint {
|
|
22
|
+
references?: GmailReferenceState;
|
|
23
|
+
}
|
|
24
|
+
interface ReferenceConfig {
|
|
25
|
+
max_results?: number;
|
|
26
|
+
}
|
|
27
|
+
interface MessageIdentity {
|
|
28
|
+
id: string;
|
|
29
|
+
threadId: string;
|
|
30
|
+
}
|
|
31
|
+
interface HistoryRecord {
|
|
32
|
+
id: string;
|
|
33
|
+
messagesAdded?: Array<{ message: MessageIdentity }>;
|
|
34
|
+
}
|
|
35
|
+
interface HistoryPage {
|
|
36
|
+
historyId: string;
|
|
37
|
+
history?: HistoryRecord[];
|
|
38
|
+
nextPageToken?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function historyId(value: unknown): string {
|
|
42
|
+
if (typeof value !== 'string' || !/^\d{1,128}$/.test(value))
|
|
43
|
+
throw new Error('Gmail returned an invalid history identity');
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function nativeId(value: unknown): string {
|
|
48
|
+
if (typeof value !== 'string' || !/^[a-zA-Z0-9_-]{1,256}$/.test(value))
|
|
49
|
+
throw new Error('Gmail returned an invalid message identity');
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function profile(
|
|
54
|
+
http: HttpClient,
|
|
55
|
+
): Promise<{ account: string; history: string }> {
|
|
56
|
+
const result = await http.raw(
|
|
57
|
+
`${BASE}/profile?fields=emailAddress,historyId`,
|
|
58
|
+
);
|
|
59
|
+
if (!result.ok) throw new Error(`Gmail profile error (${result.status})`);
|
|
60
|
+
const data = (await result.json()) as {
|
|
61
|
+
emailAddress?: string;
|
|
62
|
+
historyId?: string;
|
|
63
|
+
};
|
|
64
|
+
const account = data.emailAddress?.trim().toLowerCase();
|
|
65
|
+
if (!account || !/^[^\s@]+@[^\s@]+$/.test(account))
|
|
66
|
+
throw new Error('Gmail returned an invalid account identity');
|
|
67
|
+
return { account, history: historyId(data.historyId) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function gap(
|
|
71
|
+
account: string,
|
|
72
|
+
key: string,
|
|
73
|
+
metadata: Record<string, unknown>,
|
|
74
|
+
): EventEnvelope {
|
|
75
|
+
return {
|
|
76
|
+
origin_id: `gmail_gap:${encodeURIComponent(account)}:${key}`,
|
|
77
|
+
origin_type: 'source_gap',
|
|
78
|
+
payload_text: '',
|
|
79
|
+
// A gap has no provider occurrence timestamp. The epoch keeps retries of
|
|
80
|
+
// this same source discontinuity identical; arrival reads use created_at.
|
|
81
|
+
occurred_at: new Date(0),
|
|
82
|
+
metadata: {
|
|
83
|
+
...metadata,
|
|
84
|
+
source_occurred_at: null,
|
|
85
|
+
timestamp_basis: 'unknown',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function messageReference(
|
|
91
|
+
state: GmailReferenceState,
|
|
92
|
+
stub: MessageIdentity,
|
|
93
|
+
): EventEnvelope {
|
|
94
|
+
const id = nativeId(stub.id);
|
|
95
|
+
const thread = nativeId(stub.threadId);
|
|
96
|
+
return {
|
|
97
|
+
// Thread content uses bare thread IDs, which may equal the first message ID.
|
|
98
|
+
// Scope native identity to the authenticated account, independently of feeds.
|
|
99
|
+
origin_id: `gmail_message:${encodeURIComponent(state.account)}:${id}`,
|
|
100
|
+
origin_type: 'message_reference',
|
|
101
|
+
payload_text: '',
|
|
102
|
+
source_url: `https://mail.google.com/mail/u/${encodeURIComponent(state.account)}/#all/${thread}`,
|
|
103
|
+
// List/history stubs do not include provider occurrence time. This stable
|
|
104
|
+
// transport sentinel is NOT the email date: use created_at for arrival
|
|
105
|
+
// previews and source_occurred_at for provider-time rendering. Never infer
|
|
106
|
+
// a first contact from it. Omitting title/text also avoids empty embeddings.
|
|
107
|
+
occurred_at: new Date(0),
|
|
108
|
+
metadata: {
|
|
109
|
+
source_id: id,
|
|
110
|
+
thread_id: thread,
|
|
111
|
+
source_occurred_at: null,
|
|
112
|
+
timestamp_basis: 'unknown',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function identities(stubs: MessageIdentity[]): MessageIdentity[] {
|
|
118
|
+
const messages = new Map<string, MessageIdentity>();
|
|
119
|
+
for (const stub of stubs) {
|
|
120
|
+
const id = nativeId(stub?.id);
|
|
121
|
+
const threadId = nativeId(stub?.threadId);
|
|
122
|
+
const previous = messages.get(id);
|
|
123
|
+
if (previous && previous.threadId !== threadId)
|
|
124
|
+
throw new Error('Gmail message identity conflicts');
|
|
125
|
+
messages.set(id, { id, threadId });
|
|
126
|
+
}
|
|
127
|
+
return [...messages.values()];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function additions(record: HistoryRecord): MessageIdentity[] {
|
|
131
|
+
const entries =
|
|
132
|
+
record.messagesAdded === undefined ? [] : record.messagesAdded;
|
|
133
|
+
if (!Array.isArray(entries))
|
|
134
|
+
throw new Error('Gmail returned invalid history additions');
|
|
135
|
+
return identities(entries.map((entry) => entry?.message)).sort((a, b) =>
|
|
136
|
+
a.id < b.id ? -1 : a.id > b.id ? 1 : 0,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function pageToken(value: unknown): string | undefined {
|
|
141
|
+
if (value === undefined) return undefined;
|
|
142
|
+
if (typeof value !== 'string' || !value || value.length > 8192)
|
|
143
|
+
throw new Error('Gmail returned an invalid page token');
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Remember only a bounded set of exact recent cursors. Empty advancing pages
|
|
148
|
+
// are legitimate source progress; the per-pass request budget bounds work.
|
|
149
|
+
// Reject actual short cursor cycles without imposing an item-arrival deadline.
|
|
150
|
+
function nextTokens(
|
|
151
|
+
next: string,
|
|
152
|
+
current: string | undefined,
|
|
153
|
+
recent: string[] = [],
|
|
154
|
+
): string[] {
|
|
155
|
+
if (next === current || recent.includes(next))
|
|
156
|
+
throw new Error('Gmail cursor did not advance');
|
|
157
|
+
return [
|
|
158
|
+
...recent,
|
|
159
|
+
...(current && !recent.includes(current) ? [current] : []),
|
|
160
|
+
next,
|
|
161
|
+
].slice(-8);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Initial available-message inventory, then Gmail messageAdded history,
|
|
166
|
+
* including spam/trash. This is not a current-state mailbox mirror, an
|
|
167
|
+
* edit/deletion archive or an observer capture subscription.
|
|
168
|
+
* Every durable position travels with exactly the references it covers.
|
|
169
|
+
*/
|
|
170
|
+
export async function syncGmailReferences(
|
|
171
|
+
ctx: SyncContext<ReferenceCheckpoint, ReferenceConfig>,
|
|
172
|
+
createClient: (token: string) => HttpClient,
|
|
173
|
+
): Promise<SyncResult> {
|
|
174
|
+
const token = ctx.credentials?.accessToken;
|
|
175
|
+
if (!token) throw new Error('Gmail requires Google OAuth credentials.');
|
|
176
|
+
const maximum = ctx.config.max_results ?? 500;
|
|
177
|
+
if (!Number.isInteger(maximum) || maximum < 1 || maximum > 500)
|
|
178
|
+
throw new Error('Gmail reference max_results must be between 1 and 500');
|
|
179
|
+
const http = createClient(token);
|
|
180
|
+
const identity = await profile(http);
|
|
181
|
+
const saved = ctx.checkpoint?.references;
|
|
182
|
+
if (saved && saved.account !== identity.account)
|
|
183
|
+
throw new Error(
|
|
184
|
+
'Gmail reference account does not match its saved checkpoint',
|
|
185
|
+
);
|
|
186
|
+
if (saved && saved.version !== 1)
|
|
187
|
+
throw new Error('Gmail reference checkpoint version is unsupported');
|
|
188
|
+
if (saved) historyId(saved.history_id);
|
|
189
|
+
let state: GmailReferenceState = saved
|
|
190
|
+
? { ...saved }
|
|
191
|
+
: {
|
|
192
|
+
version: 1,
|
|
193
|
+
account: identity.account,
|
|
194
|
+
history_id: identity.history,
|
|
195
|
+
inventory: {},
|
|
196
|
+
};
|
|
197
|
+
const commit = async (events: EventEnvelope[], next: GmailReferenceState) => {
|
|
198
|
+
if ((await profile(http)).account !== state.account)
|
|
199
|
+
throw new Error('Gmail reference account changed during capture');
|
|
200
|
+
await ctx.commit(events, { references: next });
|
|
201
|
+
state = next;
|
|
202
|
+
};
|
|
203
|
+
// Commit the history boundary before the first inventory page so arrivals
|
|
204
|
+
// during a long scan are reconciled after available history has been listed.
|
|
205
|
+
if (!saved) {
|
|
206
|
+
await commit([], {
|
|
207
|
+
version: 1,
|
|
208
|
+
account: identity.account,
|
|
209
|
+
history_id: identity.history,
|
|
210
|
+
inventory: {},
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
let inspected = 0;
|
|
214
|
+
let found = 0;
|
|
215
|
+
const recover = async (reason: string) => {
|
|
216
|
+
const baseline = await profile(http);
|
|
217
|
+
if (baseline.account !== state.account)
|
|
218
|
+
throw new Error('Gmail reference account changed during recovery');
|
|
219
|
+
const event = gap(
|
|
220
|
+
state.account,
|
|
221
|
+
`${reason}:${state.history_id}:${baseline.history}`,
|
|
222
|
+
{
|
|
223
|
+
reason,
|
|
224
|
+
from_history_id: state.history_id,
|
|
225
|
+
to_history_id: baseline.history,
|
|
226
|
+
recovery: 'available_message_inventory',
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
await commit([event], {
|
|
230
|
+
version: 1,
|
|
231
|
+
account: state.account,
|
|
232
|
+
history_id: baseline.history,
|
|
233
|
+
inventory: {},
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
status: 'more',
|
|
237
|
+
metadata: { items_found: found + 1, continuity_gap: true },
|
|
238
|
+
} satisfies SyncResult;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
for (let requests = 0; requests < REQUEST_BUDGET; requests++) {
|
|
242
|
+
if (state.inventory) {
|
|
243
|
+
const params = new URLSearchParams({
|
|
244
|
+
includeSpamTrash: 'true',
|
|
245
|
+
maxResults: String(maximum - inspected),
|
|
246
|
+
fields: 'messages(id,threadId),nextPageToken',
|
|
247
|
+
});
|
|
248
|
+
if (state.inventory.page_token)
|
|
249
|
+
params.set('pageToken', state.inventory.page_token);
|
|
250
|
+
const result = await http.raw(`${BASE}/messages?${params}`);
|
|
251
|
+
if (!result.ok) {
|
|
252
|
+
if (
|
|
253
|
+
state.inventory.page_token &&
|
|
254
|
+
(result.status === 400 || result.status === 404)
|
|
255
|
+
) {
|
|
256
|
+
// Retain this generation's original pre-inventory history baseline.
|
|
257
|
+
await commit([], { ...state, inventory: {} });
|
|
258
|
+
return {
|
|
259
|
+
status: 'more',
|
|
260
|
+
metadata: { items_found: found, inventory_restarted: true },
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
throw new Error(`Gmail reference inventory error (${result.status})`);
|
|
264
|
+
}
|
|
265
|
+
const data = (await result.json()) as {
|
|
266
|
+
messages?: MessageIdentity[];
|
|
267
|
+
nextPageToken?: string;
|
|
268
|
+
};
|
|
269
|
+
const messages = data.messages === undefined ? [] : data.messages;
|
|
270
|
+
if (!Array.isArray(messages))
|
|
271
|
+
throw new Error('Gmail returned invalid inventory messages');
|
|
272
|
+
const token = pageToken(data.nextPageToken);
|
|
273
|
+
if (messages.length > maximum - inspected)
|
|
274
|
+
throw new Error(
|
|
275
|
+
'Gmail inventory exceeded its requested message budget',
|
|
276
|
+
);
|
|
277
|
+
const recent = token
|
|
278
|
+
? nextTokens(
|
|
279
|
+
token,
|
|
280
|
+
state.inventory.page_token,
|
|
281
|
+
state.inventory.recent_tokens,
|
|
282
|
+
)
|
|
283
|
+
: undefined;
|
|
284
|
+
const events: EventEnvelope[] = [];
|
|
285
|
+
for (const message of identities(messages))
|
|
286
|
+
events.push(messageReference(state, message));
|
|
287
|
+
inspected += messages.length;
|
|
288
|
+
found += events.length;
|
|
289
|
+
const next = { ...state };
|
|
290
|
+
if (token) next.inventory = { page_token: token, recent_tokens: recent };
|
|
291
|
+
else delete next.inventory;
|
|
292
|
+
await commit(events, next);
|
|
293
|
+
} else {
|
|
294
|
+
const params = new URLSearchParams({
|
|
295
|
+
startHistoryId: state.history_id,
|
|
296
|
+
historyTypes: 'messageAdded',
|
|
297
|
+
maxResults: '1',
|
|
298
|
+
fields:
|
|
299
|
+
'history(id,messagesAdded(message(id,threadId))),historyId,nextPageToken',
|
|
300
|
+
});
|
|
301
|
+
if (state.history_page) params.set('pageToken', state.history_page.token);
|
|
302
|
+
const result = await http.raw(`${BASE}/history?${params}`);
|
|
303
|
+
if (!result.ok) {
|
|
304
|
+
if (
|
|
305
|
+
state.history_page &&
|
|
306
|
+
(result.status === 400 || result.status === 404)
|
|
307
|
+
) {
|
|
308
|
+
// A retired page token does not prove the history boundary expired.
|
|
309
|
+
// Replay from that boundary, retaining any partially consumed record.
|
|
310
|
+
const next = { ...state };
|
|
311
|
+
delete next.history_page;
|
|
312
|
+
await commit([], next);
|
|
313
|
+
return { status: 'more', metadata: { items_found: found } };
|
|
314
|
+
}
|
|
315
|
+
if (result.status === 404) return recover('history_expired');
|
|
316
|
+
throw new Error(`Gmail reference history error (${result.status})`);
|
|
317
|
+
}
|
|
318
|
+
const page = (await result.json()) as HistoryPage;
|
|
319
|
+
const head = historyId(page.historyId);
|
|
320
|
+
if (BigInt(head) < BigInt(state.history_id))
|
|
321
|
+
throw new Error('Gmail history moved backwards');
|
|
322
|
+
const records = page.history === undefined ? [] : page.history;
|
|
323
|
+
if (!Array.isArray(records))
|
|
324
|
+
throw new Error('Gmail returned invalid history records');
|
|
325
|
+
const token = pageToken(page.nextPageToken);
|
|
326
|
+
if (records.length > 1)
|
|
327
|
+
throw new Error('Gmail history exceeded its requested record budget');
|
|
328
|
+
const record = records[0];
|
|
329
|
+
if (records.length === 0) {
|
|
330
|
+
if (token) {
|
|
331
|
+
const recent = nextTokens(
|
|
332
|
+
token,
|
|
333
|
+
state.history_page?.token,
|
|
334
|
+
state.history_page?.recent_tokens,
|
|
335
|
+
);
|
|
336
|
+
await commit([], {
|
|
337
|
+
...state,
|
|
338
|
+
history_page: { token, recent_tokens: recent },
|
|
339
|
+
});
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (state.partial) return recover('history_anchor_missing');
|
|
343
|
+
const next = { ...state, history_id: head };
|
|
344
|
+
delete next.history_page;
|
|
345
|
+
await commit([], next);
|
|
346
|
+
return { status: 'complete', metadata: { items_found: found } };
|
|
347
|
+
}
|
|
348
|
+
const recordId = historyId(record?.id);
|
|
349
|
+
if (
|
|
350
|
+
BigInt(recordId) <= BigInt(state.history_id) ||
|
|
351
|
+
BigInt(recordId) > BigInt(head)
|
|
352
|
+
)
|
|
353
|
+
throw new Error('Gmail returned an invalid history boundary');
|
|
354
|
+
if (state.partial && recordId !== state.partial.record_id)
|
|
355
|
+
return recover('history_anchor_missing');
|
|
356
|
+
const messages = additions(record);
|
|
357
|
+
const digest = Array.from(
|
|
358
|
+
new Uint8Array(
|
|
359
|
+
await crypto.subtle.digest(
|
|
360
|
+
'SHA-256',
|
|
361
|
+
new TextEncoder().encode(JSON.stringify(messages)),
|
|
362
|
+
),
|
|
363
|
+
),
|
|
364
|
+
(byte) => byte.toString(16).padStart(2, '0'),
|
|
365
|
+
).join('');
|
|
366
|
+
if (
|
|
367
|
+
state.partial &&
|
|
368
|
+
(state.partial.digest !== digest ||
|
|
369
|
+
!messages.some(
|
|
370
|
+
(message) => message.id === state.partial?.after_message_id,
|
|
371
|
+
))
|
|
372
|
+
)
|
|
373
|
+
return recover('history_anchor_changed');
|
|
374
|
+
const unread = state.partial
|
|
375
|
+
? messages.filter(
|
|
376
|
+
(message) => message.id > state.partial!.after_message_id,
|
|
377
|
+
)
|
|
378
|
+
: messages;
|
|
379
|
+
const batch = unread.slice(0, maximum - inspected);
|
|
380
|
+
const events: EventEnvelope[] = [];
|
|
381
|
+
for (const message of batch) {
|
|
382
|
+
events.push(messageReference(state, message));
|
|
383
|
+
inspected++;
|
|
384
|
+
}
|
|
385
|
+
found += events.length;
|
|
386
|
+
const next = { ...state };
|
|
387
|
+
if (batch.length < unread.length) {
|
|
388
|
+
next.partial = {
|
|
389
|
+
record_id: recordId,
|
|
390
|
+
after_message_id: batch[batch.length - 1].id,
|
|
391
|
+
digest,
|
|
392
|
+
};
|
|
393
|
+
} else {
|
|
394
|
+
next.history_id = token ? recordId : head;
|
|
395
|
+
delete next.partial;
|
|
396
|
+
delete next.history_page;
|
|
397
|
+
}
|
|
398
|
+
await commit(events, next);
|
|
399
|
+
if (!next.partial && !token)
|
|
400
|
+
return { status: 'complete', metadata: { items_found: found } };
|
|
401
|
+
}
|
|
402
|
+
if (inspected >= maximum)
|
|
403
|
+
return { status: 'more', metadata: { items_found: found } };
|
|
404
|
+
}
|
|
405
|
+
return { status: 'more', metadata: { items_found: found } };
|
|
406
|
+
}
|
|
@@ -57,6 +57,14 @@ export function linkedInInboxProgram() {
|
|
|
57
57
|
fail("Account identity is unavailable");
|
|
58
58
|
return urn.replace("fs_miniProfile", "fsd_profile");
|
|
59
59
|
}
|
|
60
|
+
async function boundAccount(expected) {
|
|
61
|
+
if (typeof expected !== "string" || !/^urn:li:fs_miniProfile:.+$/.test(expected))
|
|
62
|
+
fail("Source requires the connection's saved account; reconnect this source");
|
|
63
|
+
const member = await account();
|
|
64
|
+
if (expected.replace(/^urn:li:fs_miniProfile:/, "urn:li:fsd_profile:") !== member)
|
|
65
|
+
fail("Source does not match the connection's saved account; reconnect this source");
|
|
66
|
+
return member;
|
|
67
|
+
}
|
|
60
68
|
const PAGE_MAILBOX = /^urn:li:fsd_pageMailbox:[0-9]+$/;
|
|
61
69
|
const NOT_ADMIN =
|
|
62
70
|
"The signed-in LinkedIn account does not administer this page inbox";
|
|
@@ -83,8 +91,8 @@ export function linkedInInboxProgram() {
|
|
|
83
91
|
// The inbox one feed reads: the signed-in member's own ("me", the default),
|
|
84
92
|
// or a company page's mailbox the member administers. `member` is the
|
|
85
93
|
// signed-in account, which must not change while the inbox is in use.
|
|
86
|
-
async function inboxOf(selected) {
|
|
87
|
-
const member = await
|
|
94
|
+
async function inboxOf(selected, expected) {
|
|
95
|
+
const member = await boundAccount(expected);
|
|
88
96
|
if (selected === undefined || selected === null || selected === "me")
|
|
89
97
|
return { mailbox: member, member, page: false };
|
|
90
98
|
if (typeof selected !== "string" || !PAGE_MAILBOX.test(selected))
|
|
@@ -656,7 +664,7 @@ export function linkedInInboxProgram() {
|
|
|
656
664
|
}
|
|
657
665
|
async function read(input) {
|
|
658
666
|
const inbox = await inboxOf(
|
|
659
|
-
input.feed === "live_messages" ? input.inbox : undefined
|
|
667
|
+
input.feed === "live_messages" ? input.inbox : undefined, input.expected_account
|
|
660
668
|
);
|
|
661
669
|
const mailbox = inbox.mailbox;
|
|
662
670
|
const cursor = cursorOf(input.cursor, input.feed, inbox);
|
|
@@ -713,6 +721,17 @@ export function linkedInInboxProgram() {
|
|
|
713
721
|
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
714
722
|
.join("");
|
|
715
723
|
}
|
|
724
|
+
// Keep SHA-256 fingerprints losslessly in base64url inside checkpoints.
|
|
725
|
+
// Batch checkpoints carry both predecessor and successor, so hex would
|
|
726
|
+
// exhaust the transport budget before a large interrupted pass can resume.
|
|
727
|
+
function compactHash(value) {
|
|
728
|
+
if (typeof value !== "string" || !/^[a-f0-9]{64}$/.test(value)) return value;
|
|
729
|
+
return btoa(String.fromCharCode(...value.match(/../g).map(byte => parseInt(byte, 16))))
|
|
730
|
+
.replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
731
|
+
}
|
|
732
|
+
function compactSeen(seen) {
|
|
733
|
+
return Object.fromEntries(Object.entries(seen ?? {}).map(([key, value]) => [compactHash(key), Array.isArray(value) ? [compactHash(value[0]), value[1]] : compactHash(value)]));
|
|
734
|
+
}
|
|
716
735
|
// One observation pass is bounded source work. Message catch-up resumes from
|
|
717
736
|
// its checkpoint; notifications reorder at the top and report a gap instead.
|
|
718
737
|
const NOTIFICATION_PAGES_PER_PASS = 10;
|
|
@@ -753,7 +772,7 @@ export function linkedInInboxProgram() {
|
|
|
753
772
|
}
|
|
754
773
|
payload = next;
|
|
755
774
|
}
|
|
756
|
-
// `seen`
|
|
775
|
+
// `seen` records source position; the delivery layer also carries a monotonic generation.
|
|
757
776
|
return {};
|
|
758
777
|
}
|
|
759
778
|
async function catchUpConversation(
|
|
@@ -844,14 +863,19 @@ export function linkedInInboxProgram() {
|
|
|
844
863
|
async function snapshot(feed, previous, inbox) {
|
|
845
864
|
const observedAt = Date.now();
|
|
846
865
|
const observed = new Map();
|
|
866
|
+
const previousSeen = compactSeen(previous?.seen);
|
|
847
867
|
const events = [];
|
|
848
868
|
// Returns whether the previous checkpoint already held this identity.
|
|
849
869
|
async function observe(row, eventType, resourceType, revisionText) {
|
|
850
870
|
const identity = await digest(row.id);
|
|
851
871
|
const revision =
|
|
852
872
|
revisionText === undefined ? identity : await digest(revisionText);
|
|
853
|
-
const
|
|
854
|
-
|
|
873
|
+
const key = compactHash(identity);
|
|
874
|
+
const fingerprint = revisionText === undefined ? "1" : compactHash(revision);
|
|
875
|
+
const stored = previousSeen[key];
|
|
876
|
+
const prior = Array.isArray(stored) ? stored[0] : stored;
|
|
877
|
+
const unchanged = prior === fingerprint || (revisionText === undefined && prior === key);
|
|
878
|
+
if (previous && !unchanged && !observed.has(key)) {
|
|
855
879
|
events.push({
|
|
856
880
|
id: `${identity}:${revision}`,
|
|
857
881
|
event_type: eventType,
|
|
@@ -860,8 +884,12 @@ export function linkedInInboxProgram() {
|
|
|
860
884
|
occurred_at: row.occurred_at ?? new Date(observedAt).toISOString(),
|
|
861
885
|
});
|
|
862
886
|
}
|
|
863
|
-
|
|
864
|
-
|
|
887
|
+
// Overlapping pages must checkpoint the same revision we emitted first.
|
|
888
|
+
if (!observed.has(key)) observed.set(key, fingerprint);
|
|
889
|
+
// Accepted chunks suppress repeats, but newly accepted items are not
|
|
890
|
+
// the original catch-up boundary. Otherwise a rebind stops on page one
|
|
891
|
+
// before reaching unfinished provider pages.
|
|
892
|
+
return Array.isArray(stored) ? stored[1] === true : prior !== undefined;
|
|
865
893
|
}
|
|
866
894
|
// The provider cannot show what lies beyond this position. Report it once
|
|
867
895
|
// per position and advance, rather than retrying or claiming completeness.
|
|
@@ -890,41 +918,84 @@ export function linkedInInboxProgram() {
|
|
|
890
918
|
seen: Object.fromEntries(
|
|
891
919
|
[
|
|
892
920
|
...observed,
|
|
893
|
-
...Object.entries(
|
|
921
|
+
...Object.entries(previousSeen).filter(
|
|
894
922
|
([identity]) => !observed.has(identity)
|
|
895
923
|
),
|
|
896
|
-
].slice(0, SEEN_LIMIT)
|
|
924
|
+
].slice(0, feed === "notifications" ? Math.max(SEEN_LIMIT, observed.size) : SEEN_LIMIT).map(([key, value]) => [key, Array.isArray(value) ? value[0] : value])
|
|
897
925
|
),
|
|
898
926
|
};
|
|
899
|
-
return { checkpoint, events, more };
|
|
927
|
+
return { checkpoint, events, more, observed };
|
|
900
928
|
}
|
|
901
|
-
//
|
|
902
|
-
//
|
|
929
|
+
// Each accepted chunk commits only its own seen identities. Source position
|
|
930
|
+
// advances on the final chunk; a rebind can safely rescan the unfinished page.
|
|
903
931
|
async function batchesOf(feed, previous, result) {
|
|
904
|
-
const next = { linkedin_inbox: result.checkpoint };
|
|
905
932
|
const { events } = result;
|
|
906
|
-
const
|
|
907
|
-
const
|
|
908
|
-
|
|
933
|
+
const prior = previous?.linkedin_inbox;
|
|
934
|
+
const epoch = prior?.observation_epoch ?? (prior
|
|
935
|
+
? await digest(JSON.stringify(["legacy-observation", prior]))
|
|
936
|
+
: crypto.randomUUID());
|
|
937
|
+
let generation = prior?.observation_generation ?? 0;
|
|
938
|
+
if (!Number.isSafeInteger(generation) || generation < 0)
|
|
939
|
+
fail("Invalid observation generation");
|
|
940
|
+
const size = (batch) => new TextEncoder().encode(JSON.stringify(batch)).length;
|
|
909
941
|
const batches = [];
|
|
942
|
+
let cursor = previous;
|
|
910
943
|
for (let offset = 0; ; ) {
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
...
|
|
915
|
-
|
|
916
|
-
:
|
|
917
|
-
});
|
|
944
|
+
const nextGeneration = events.length || !prior?.observation_epoch ? generation + 1 : generation;
|
|
945
|
+
if (!Number.isSafeInteger(nextGeneration)) fail("Observation generation exhausted");
|
|
946
|
+
const observedEvents = await Promise.all(events.slice(offset, offset + BATCH_EVENTS).map(async (event) => ({
|
|
947
|
+
...event,
|
|
948
|
+
id: event.event_type === "notification.changed"
|
|
949
|
+
? await digest(JSON.stringify([epoch, nextGeneration, event.id])) : event.id,
|
|
950
|
+
})));
|
|
951
|
+
const through = async (end) => {
|
|
952
|
+
const final = end === events.length;
|
|
953
|
+
let seen = compactSeen(cursor?.linkedin_inbox?.seen);
|
|
954
|
+
for (const event of events.slice(offset, end)) {
|
|
955
|
+
const identity = compactHash(await digest(event.resource_ref));
|
|
956
|
+
if (result.observed.has(identity)) {
|
|
957
|
+
const prior = seen[identity];
|
|
958
|
+
const anchor = Array.isArray(prior) ? prior[1] : prior !== undefined;
|
|
959
|
+
seen[identity] = [result.observed.get(identity), anchor];
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
// Keep the prior completed pass's bounded anchors until this pass ends.
|
|
963
|
+
// Only provisional message IDs can be evicted safely: native-ID replay
|
|
964
|
+
// dedupes, while evicting an original anchor invents a new source gap.
|
|
965
|
+
// Mutable notification fingerprints survive the entire unfinished pass.
|
|
966
|
+
if (feed === "live_messages") {
|
|
967
|
+
const entries = Object.entries(seen);
|
|
968
|
+
const original = ([, value]) => !Array.isArray(value) || value[1] === true;
|
|
969
|
+
seen = Object.fromEntries([
|
|
970
|
+
...entries.filter(original),
|
|
971
|
+
...entries.filter((entry) => !original(entry)).slice(-SEEN_LIMIT),
|
|
972
|
+
]);
|
|
973
|
+
}
|
|
974
|
+
const next = { linkedin_inbox: {
|
|
975
|
+
...(final ? result.checkpoint : { ...prior, seen }),
|
|
976
|
+
observation_epoch: epoch,
|
|
977
|
+
observation_generation: nextGeneration,
|
|
978
|
+
} };
|
|
979
|
+
const slice = observedEvents.slice(0, end - offset);
|
|
980
|
+
return {
|
|
981
|
+
id: `${feed}:${epoch}:${nextGeneration}:${await digest(JSON.stringify([cursor, next, slice]))}`,
|
|
982
|
+
events: slice,
|
|
983
|
+
checkpoint: { previous: cursor, next },
|
|
984
|
+
...(final ? { more: result.more } : {}),
|
|
985
|
+
};
|
|
986
|
+
};
|
|
918
987
|
let end = Math.min(offset + BATCH_EVENTS, events.length);
|
|
919
|
-
let batch = through(end);
|
|
988
|
+
let batch = await through(end);
|
|
920
989
|
while (size(batch) > BATCH_BYTES && end - offset > 1) {
|
|
921
990
|
end = offset + Math.floor((end - offset) / 2);
|
|
922
|
-
batch = through(end);
|
|
991
|
+
batch = await through(end);
|
|
923
992
|
}
|
|
924
993
|
if (size(batch) > BATCH_BYTES)
|
|
925
994
|
fail("Source reference batch exceeds the browser record limit");
|
|
926
995
|
batches.push(batch);
|
|
927
996
|
if (end === events.length) return batches;
|
|
997
|
+
cursor = batch.checkpoint.next;
|
|
998
|
+
generation++;
|
|
928
999
|
offset = end;
|
|
929
1000
|
}
|
|
930
1001
|
}
|
|
@@ -1010,11 +1081,11 @@ export function linkedInInboxProgram() {
|
|
|
1010
1081
|
"LinkedIn source delivery was rejected; reattach from the durable checkpoint"
|
|
1011
1082
|
);
|
|
1012
1083
|
if (event.data.ok && listener.batches.length) {
|
|
1013
|
-
//
|
|
1014
|
-
//
|
|
1084
|
+
// The page receipt means buffered, not committed. A reattach uses the
|
|
1085
|
+
// server's durable per-chunk checkpoint; observation identities survive replay.
|
|
1015
1086
|
const done = listener.batches.shift();
|
|
1016
1087
|
if (done.checkpoint) listener.checkpoint = done.checkpoint.next;
|
|
1017
|
-
|
|
1088
|
+
if (listener.batches.length) post(listener, listener.batches[0]);
|
|
1018
1089
|
}
|
|
1019
1090
|
}
|
|
1020
1091
|
// Direct send, approved ONLY for replying to direct messages on accounts the
|
|
@@ -1046,9 +1117,9 @@ export function linkedInInboxProgram() {
|
|
|
1046
1117
|
// `conversation_id` is a thread id of the member's own inbox, or a full
|
|
1047
1118
|
// conversation URN whose mailbox names the inbox the reply leaves from: the
|
|
1048
1119
|
// member's own or a page the member administers.
|
|
1049
|
-
async function sendTarget(given) {
|
|
1120
|
+
async function sendTarget(given, expected) {
|
|
1050
1121
|
if (typeof given === "string" && /^[A-Za-z0-9_-]+=*$/.test(given)) {
|
|
1051
|
-
const member = await
|
|
1122
|
+
const member = await boundAccount(expected);
|
|
1052
1123
|
return { inbox: { mailbox: member, member, page: false }, thread: given };
|
|
1053
1124
|
}
|
|
1054
1125
|
const match =
|
|
@@ -1061,14 +1132,14 @@ export function linkedInInboxProgram() {
|
|
|
1061
1132
|
"conversation_id must be a LinkedIn conversation thread id or conversation URN"
|
|
1062
1133
|
);
|
|
1063
1134
|
if (PAGE_MAILBOX.test(match[1]))
|
|
1064
|
-
return { inbox: await inboxOf(match[1]), thread: match[2] };
|
|
1065
|
-
const member = await
|
|
1135
|
+
return { inbox: await inboxOf(match[1], expected), thread: match[2] };
|
|
1136
|
+
const member = await boundAccount(expected);
|
|
1066
1137
|
if (match[1] !== member)
|
|
1067
1138
|
fail("The conversation belongs to another LinkedIn account; not sending");
|
|
1068
1139
|
return { inbox: { mailbox: member, member, page: false }, thread: match[2] };
|
|
1069
1140
|
}
|
|
1070
1141
|
async function send(input) {
|
|
1071
|
-
const { inbox, thread } = await sendTarget(input.conversation_id);
|
|
1142
|
+
const { inbox, thread } = await sendTarget(input.conversation_id, input.expected_account);
|
|
1072
1143
|
const mailbox = inbox.mailbox;
|
|
1073
1144
|
const text = typeof input.text === "string" ? input.text.trim() : "";
|
|
1074
1145
|
if (!text || text.length > 3000)
|
|
@@ -1145,7 +1216,7 @@ export function linkedInInboxProgram() {
|
|
|
1145
1216
|
if (!input.bridge_id || !input.token)
|
|
1146
1217
|
fail("Source subscription binding is required");
|
|
1147
1218
|
const inbox = await inboxOf(
|
|
1148
|
-
input.feed === "live_messages" ? input.inbox : undefined
|
|
1219
|
+
input.feed === "live_messages" ? input.inbox : undefined, input.expected_account
|
|
1149
1220
|
);
|
|
1150
1221
|
const previous = input.checkpoint?.linkedin_inbox;
|
|
1151
1222
|
// A mailbox change restarts the baseline, but never permits a changed sign-in.
|
|
@@ -1164,7 +1235,7 @@ export function linkedInInboxProgram() {
|
|
|
1164
1235
|
inbox,
|
|
1165
1236
|
// The last posted record; only its receipt may advance delivery.
|
|
1166
1237
|
sequence: 0,
|
|
1167
|
-
// The checkpoint the next snapshot starts from, set by
|
|
1238
|
+
// The checkpoint the next snapshot starts from, set by each batch receipt.
|
|
1168
1239
|
checkpoint: input.checkpoint ?? null,
|
|
1169
1240
|
// Undelivered batches of the current snapshot, in order.
|
|
1170
1241
|
batches: [],
|