@lobu/runtime-server 24.1.1 → 24.2.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 +151 -37
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -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 +5 -3
- 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 +81 -83
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-Cjvw31gU.js +2 -0
- package/dist/owletto/dist/assets/_-iToIRRFt.js +3 -0
- package/dist/owletto/dist/assets/_agentId-CLdj0X7j.js +2 -0
- package/dist/owletto/dist/assets/_agentId-D5cAWjrP.js +2 -0
- package/dist/owletto/dist/assets/_automationId-BhEZmkJU.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DZtLc3WW.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BoYpah_l.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-ML2TjCwN.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BYc3I2EL.js +2 -0
- package/dist/owletto/dist/assets/_name-BsOZmvlH.js +2 -0
- package/dist/owletto/dist/assets/_owner-UuyQLJ-0.js +3 -0
- package/dist/owletto/dist/assets/_shape-BpnVAYWH.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CYrGvNn-.js +2 -0
- package/dist/owletto/dist/assets/_slug-MHQU8ftJ.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CGAJ1ucr.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CMkhfs1k.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-D2T_a2dj.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-_G_lDz5K.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-ColL5rdd.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-BgyLhJCo.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BryZas7Z.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-C24p9LLg.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-D9PpDgR-.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-jkf9DjdO.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C8j8kRB1.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-B9giw2u2.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-BMZ3r1bP.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-D49f-bzP.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-BGHYHWDO.js} +4 -4
- package/dist/owletto/dist/assets/agents-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-D1YL3VAB.js +2 -0
- package/dist/owletto/dist/assets/app._appId-A51tx2jU.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DCAZBKle.js +2 -0
- package/dist/owletto/dist/assets/automations-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/callback-WmyCei3R.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-Cspo-4M6.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-CCKdBtFt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-CmK3DkSP.js +2 -0
- package/dist/owletto/dist/assets/client-rows-fFuxzFtE.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-C8FJbT2P.js} +3 -3
- package/dist/owletto/dist/assets/connect-BmCUJ3lr.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-B6StGCPK.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CPiMA6Bx.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-BialEDmu.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-X1wVi6v0.js +2 -0
- package/dist/owletto/dist/assets/{connection-CNm2ukrI.js → connection-DJd9bnEc.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-WcGCA6qY.js → connection-feed-detail-IO6G5QjL.js} +2 -2
- package/dist/owletto/dist/assets/connections-browser-CzdcZeiU.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-bmBJJ9B4.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-B44Q9W-j.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-CTWPDH8f.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-C_WBfmQ8.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-kcjg8Giw.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-CoJ5Splc.js} +2 -2
- package/dist/owletto/dist/assets/create-CQE5rD0i.js +2 -0
- package/dist/owletto/dist/assets/create-DQNlRTUX.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-y3tq2QIJ.js +3 -0
- package/dist/owletto/dist/assets/create-lOFSQV_5.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-icyNicvn.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-CeUS_78Q.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-Br9JHadR.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-7UpeD4Sq.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-DGMmjr01.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-BZIa-7i5.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-BcTafZ2e.js +2 -0
- package/dist/owletto/dist/assets/entity-page-CY7PF3X9.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BzMZttzh.js +2 -0
- package/dist/owletto/dist/assets/{event-detail-DV_zfWnC.js → event-detail-C25TvOb_.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-C4VrjIc1.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-oNjBX9a2.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-DtmqQmgl.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-Acfam-JF.js +2 -0
- package/dist/owletto/dist/assets/identity-BkK8ggdp.js +2 -0
- package/dist/owletto/dist/assets/index-BhBYXtEN.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-Bhop_otG.js} +2 -2
- package/dist/owletto/dist/assets/index-Bw5iV_J7.js +2 -0
- package/dist/owletto/dist/assets/index-C3dpyynY.js +2 -0
- package/dist/owletto/dist/assets/index-C3zAbslo.js +2 -0
- package/dist/owletto/dist/assets/index-CGKN_WN_.js +2 -0
- package/dist/owletto/dist/assets/{index-DB1iWI_a.js → index-CgRaCOzW.js} +2 -2
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DRbaESbJ.js} +2 -2
- package/dist/owletto/dist/assets/index-DfIoxD5Q.js +2 -0
- package/dist/owletto/dist/assets/index-DijuudSs.js +2 -0
- package/dist/owletto/dist/assets/index-Dr7bouPX.css +1 -0
- package/dist/owletto/dist/assets/index-JmEl29py.js +7950 -0
- package/dist/owletto/dist/assets/index-NK2VKPoL.js +2 -0
- package/dist/owletto/dist/assets/index-_5qsmBkt.js +2 -0
- package/dist/owletto/dist/assets/{index-B64PGxQm.js → index-qkOKpRYs.js} +2 -2
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-wzYkECAe.js +2 -0
- package/dist/owletto/dist/assets/json-diff-4sMmayDd.js +4 -0
- package/dist/owletto/dist/assets/linked-record-peek-B0_B4PnF.js +97 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-BafzvpOM.js} +2 -2
- package/dist/owletto/dist/assets/login-XL5XxN6y.js +2 -0
- package/dist/owletto/dist/assets/{logout-Bkzc7J44.js → logout-CMxdhLbM.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-Dit3MXBQ.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DTlM_9MY.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-BeFuFH7p.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVaDnKN.js +2 -0
- package/dist/owletto/dist/assets/new-1QLuS1o-.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-ChwqLmVY.js} +2 -2
- package/dist/owletto/dist/assets/new-D21LGMl6.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-D15LYKSe.js} +2 -2
- package/dist/owletto/dist/assets/organization-CoUJYXx7.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-BvkYk72J.js +2 -0
- package/dist/owletto/dist/assets/permissions-C6UFdvz2.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CmLy1MZf.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-_awBxu2Y.js +2 -0
- package/dist/owletto/dist/assets/record-activity-Doeu5kPO.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-CJzFoVKc.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CzZw6RcC.js → reset-password-Y-WO77iR.js} +2 -2
- package/dist/owletto/dist/assets/runs-B0zVYb-w.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-Dkyybqos.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-B1APZv7d.js → runs-table-9OVdfPXZ.js} +2 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-DcJqbCrU.js +2 -0
- package/dist/owletto/dist/assets/settings-Cfy9tCOF.js +2 -0
- package/dist/owletto/dist/assets/settings-Dg0D_l_w.js +2 -0
- package/dist/owletto/dist/assets/skills-oxA7P5Fe.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-BeAZeMLy.js +2 -0
- package/dist/owletto/dist/assets/status-dot-_LQZmEIX.js +2 -0
- package/dist/owletto/dist/assets/use-automations-DS3uz3pb.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-CAFbh-Dk.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-BpQ70c28.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-FuOZyjMg.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-CWwlobOd.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +44298 -40801
- package/npm-shrinkwrap.json +389 -402
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -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/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 +3 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +113 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +41 -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/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +6 -1
- 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._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/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-pin-tombstone-2U0UMu3_.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/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-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-CxF2XXzl.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.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/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/runs-panel-C0_DNTcq.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 → .bun-tag-22d644c2873790db} +0 -0
package/dist/connectors/x.ts
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* - live_messages: DMs read live from the signed-in browser without importing
|
|
24
24
|
* history; Automations subscribe to `message.created` and can
|
|
25
25
|
* answer through `send_message`
|
|
26
|
+
* - notifications: signed-in All timeline; metadata-only sync, explicit source reads
|
|
26
27
|
* - following_timeline: live chronological Following timeline (OAuth API,
|
|
27
28
|
* source reads only; does not import tweet events)
|
|
28
29
|
* - home_feed: personalized x.com home timeline (extension only — the
|
|
@@ -3146,19 +3147,32 @@ async function readyXLiveTab(
|
|
|
3146
3147
|
return nav.tab_id;
|
|
3147
3148
|
}
|
|
3148
3149
|
|
|
3150
|
+
/** Bind source access to the account saved by the connection's browser probe. */
|
|
3151
|
+
function requireXAccount(ctx: {
|
|
3152
|
+
sessionState?: Record<string, unknown> | null;
|
|
3153
|
+
}): string {
|
|
3154
|
+
const account = ctx.sessionState?.account_id;
|
|
3155
|
+
if (typeof account !== "string" || !/^[0-9]{1,20}$/.test(account))
|
|
3156
|
+
throw new Error(
|
|
3157
|
+
"X saved account identity is unavailable; reconnect this connection",
|
|
3158
|
+
);
|
|
3159
|
+
return account;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3149
3162
|
/** One call into the page program, installing it first when absent or stale. */
|
|
3150
3163
|
async function invokeXDirectMessages<T>(
|
|
3151
3164
|
dispatcher: ChromeActionDispatcher,
|
|
3152
3165
|
tabId: number,
|
|
3153
|
-
op: "read" | "listen" | "send",
|
|
3166
|
+
op: "read" | "listen" | "send" | "readNotifications",
|
|
3154
3167
|
input: Record<string, unknown>,
|
|
3168
|
+
accountId: string,
|
|
3155
3169
|
): Promise<T> {
|
|
3156
3170
|
const result = await dispatcher.dispatch<{
|
|
3157
3171
|
value?: T;
|
|
3158
3172
|
exception?: { description?: string } | unknown;
|
|
3159
3173
|
}>("evaluate", {
|
|
3160
3174
|
tab_id: tabId,
|
|
3161
|
-
expression: `(() => { (${xDirectMessagesProgram.toString()})(); return globalThis.__lobuXDirectMessagesV1.${op}(${xScriptArgument(input)}); })()`,
|
|
3175
|
+
expression: `(() => { (${xDirectMessagesProgram.toString()})(); return globalThis.__lobuXDirectMessagesV1.${op}(${xScriptArgument({ ...input, account_id: accountId })}); })()`,
|
|
3162
3176
|
await_promise: true,
|
|
3163
3177
|
});
|
|
3164
3178
|
if (result.exception || !result.value) {
|
|
@@ -3184,16 +3198,23 @@ async function readXLiveMessages(
|
|
|
3184
3198
|
assertNoWindow(ctx, message);
|
|
3185
3199
|
assertNoMatch(ctx, message);
|
|
3186
3200
|
const dispatcher = requireXBrowser(ctx);
|
|
3201
|
+
const accountId = requireXAccount(ctx);
|
|
3187
3202
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3188
3203
|
const page = await invokeXDirectMessages<{
|
|
3189
3204
|
rows: Array<Record<string, unknown>>;
|
|
3190
3205
|
nextCursor?: string;
|
|
3191
3206
|
hasMore: boolean;
|
|
3192
|
-
}>(
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3207
|
+
}>(
|
|
3208
|
+
dispatcher,
|
|
3209
|
+
tabId,
|
|
3210
|
+
"read",
|
|
3211
|
+
{
|
|
3212
|
+
query: ctx.query,
|
|
3213
|
+
cursor: ctx.cursor,
|
|
3214
|
+
limit: ctx.limit,
|
|
3215
|
+
},
|
|
3216
|
+
accountId,
|
|
3217
|
+
);
|
|
3197
3218
|
return {
|
|
3198
3219
|
rows: page.rows,
|
|
3199
3220
|
columns: X_LIVE_MESSAGE_COLUMNS,
|
|
@@ -3209,6 +3230,7 @@ async function readXLiveMessages(
|
|
|
3209
3230
|
*/
|
|
3210
3231
|
async function observeXLiveMessages(ctx: FeedObserveContext): Promise<void> {
|
|
3211
3232
|
const dispatcher = requireXBrowser(ctx);
|
|
3233
|
+
const accountId = requireXAccount(ctx);
|
|
3212
3234
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3213
3235
|
const binding = await dispatcher.dispatch<{
|
|
3214
3236
|
bridge_id?: string;
|
|
@@ -3224,11 +3246,148 @@ async function observeXLiveMessages(ctx: FeedObserveContext): Promise<void> {
|
|
|
3224
3246
|
) {
|
|
3225
3247
|
throw new Error("The paired browser must support source subscriptions");
|
|
3226
3248
|
}
|
|
3227
|
-
await invokeXDirectMessages(
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3249
|
+
await invokeXDirectMessages(
|
|
3250
|
+
dispatcher,
|
|
3251
|
+
tabId,
|
|
3252
|
+
"listen",
|
|
3253
|
+
{
|
|
3254
|
+
checkpoint: ctx.checkpoint ?? null,
|
|
3255
|
+
bridge_id: binding.bridge_id,
|
|
3256
|
+
token: binding.token,
|
|
3257
|
+
},
|
|
3258
|
+
accountId,
|
|
3259
|
+
);
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
async function readXNotifications(
|
|
3263
|
+
ctx: FeedReadContext,
|
|
3264
|
+
): Promise<FeedReadResult> {
|
|
3265
|
+
const message =
|
|
3266
|
+
"X notifications support source cursor pagination only; queries, windows, offsets, matching and sorting are unsupported";
|
|
3267
|
+
assertNoOffsetPaging(ctx, message);
|
|
3268
|
+
assertNoSort(ctx, message);
|
|
3269
|
+
assertNoWindow(ctx, message);
|
|
3270
|
+
assertNoMatch(ctx, message);
|
|
3271
|
+
if (ctx.query) throw new Error(message);
|
|
3272
|
+
const browser = requireXBrowser(ctx);
|
|
3273
|
+
const accountId = requireXAccount(ctx);
|
|
3274
|
+
const result = await invokeXDirectMessages<FeedReadResult>(
|
|
3275
|
+
browser,
|
|
3276
|
+
await readyXLiveTab(browser),
|
|
3277
|
+
"readNotifications",
|
|
3278
|
+
{ cursor: ctx.cursor, limit: ctx.limit },
|
|
3279
|
+
accountId,
|
|
3280
|
+
);
|
|
3281
|
+
return {
|
|
3282
|
+
rows: result.rows,
|
|
3283
|
+
nextCursor: result.nextCursor,
|
|
3284
|
+
hasMore: result.hasMore,
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
async function syncXNotifications(ctx: SyncContext): Promise<SyncResult> {
|
|
3289
|
+
const browser = requireXBrowser(ctx);
|
|
3290
|
+
const accountId = requireXAccount(ctx);
|
|
3291
|
+
if (
|
|
3292
|
+
ctx.checkpoint?.notifications_account &&
|
|
3293
|
+
ctx.checkpoint.notifications_account !== accountId
|
|
3294
|
+
)
|
|
3295
|
+
throw new Error("X notification checkpoint belongs to another account");
|
|
3296
|
+
const tab = await readyXLiveTab(browser);
|
|
3297
|
+
const saved = ctx.checkpoint?.notifications_cursor as
|
|
3298
|
+
| string
|
|
3299
|
+
| null
|
|
3300
|
+
| undefined;
|
|
3301
|
+
const previousHead = ctx.checkpoint?.notifications_head_revision;
|
|
3302
|
+
let head: string | undefined;
|
|
3303
|
+
let catchingUp = !!saved;
|
|
3304
|
+
let cursor: string | undefined;
|
|
3305
|
+
let account: string | undefined;
|
|
3306
|
+
let cursorReset = false;
|
|
3307
|
+
const seenCursors = new Set<string>();
|
|
3308
|
+
const seenItems = new Set<string>();
|
|
3309
|
+
const events: EventEnvelope[] = [];
|
|
3310
|
+
for (let page = 0; page < 10; page++) {
|
|
3311
|
+
if (cursor) seenCursors.add(cursor);
|
|
3312
|
+
const result = await invokeXDirectMessages<
|
|
3313
|
+
FeedReadResult & { account_id: string; expired?: boolean }
|
|
3314
|
+
>(
|
|
3315
|
+
browser,
|
|
3316
|
+
tab,
|
|
3317
|
+
"readNotifications",
|
|
3318
|
+
{
|
|
3319
|
+
cursor,
|
|
3320
|
+
limit: 100,
|
|
3321
|
+
restartExpired: !cursorReset,
|
|
3322
|
+
metadataOnly: true,
|
|
3323
|
+
},
|
|
3324
|
+
accountId,
|
|
3325
|
+
);
|
|
3326
|
+
account = result.account_id;
|
|
3327
|
+
if (
|
|
3328
|
+
ctx.checkpoint?.notifications_account &&
|
|
3329
|
+
ctx.checkpoint.notifications_account !== account
|
|
3330
|
+
)
|
|
3331
|
+
throw new Error("X notification checkpoint belongs to another account");
|
|
3332
|
+
if (result.expired) {
|
|
3333
|
+
if (page === 9)
|
|
3334
|
+
throw new Error(
|
|
3335
|
+
"X notification cursor restart exceeds the page budget; retry without committing",
|
|
3336
|
+
);
|
|
3337
|
+
cursorReset = true;
|
|
3338
|
+
cursor = undefined;
|
|
3339
|
+
seenCursors.clear();
|
|
3340
|
+
continue;
|
|
3341
|
+
}
|
|
3342
|
+
head ??= result.rows[0]?.revision as string | undefined;
|
|
3343
|
+
for (const row of result.rows) {
|
|
3344
|
+
if (seenItems.has(String(row.id))) continue;
|
|
3345
|
+
seenItems.add(String(row.id));
|
|
3346
|
+
events.push({
|
|
3347
|
+
origin_id: `x_notification_${row.id}`,
|
|
3348
|
+
origin_type: "notification",
|
|
3349
|
+
payload_text: "",
|
|
3350
|
+
title: "X notification reference",
|
|
3351
|
+
source_url: String(row.url),
|
|
3352
|
+
occurred_at: new Date(String(row.occurred_at)),
|
|
3353
|
+
metadata: {
|
|
3354
|
+
account_id: row.account_id,
|
|
3355
|
+
entry_id: row.entry_id,
|
|
3356
|
+
notification_id: row.notification_id,
|
|
3357
|
+
kind: row.kind,
|
|
3358
|
+
actor_ids: row.actor_ids,
|
|
3359
|
+
tweet_ids: row.tweet_ids,
|
|
3360
|
+
revision: row.revision,
|
|
3361
|
+
timestamp_basis: row.timestamp_basis,
|
|
3362
|
+
},
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
cursor = result.nextCursor;
|
|
3366
|
+
// Do not skip arrivals spanning multiple pages before resuming history.
|
|
3367
|
+
// A missing head boundary falls back to a full sweep from this position.
|
|
3368
|
+
if (
|
|
3369
|
+
catchingUp &&
|
|
3370
|
+
result.rows.some((row) => row.revision === previousHead)
|
|
3371
|
+
) {
|
|
3372
|
+
catchingUp = false;
|
|
3373
|
+
if (cursor && saved) cursor = saved;
|
|
3374
|
+
}
|
|
3375
|
+
if (!cursor) break;
|
|
3376
|
+
if (seenCursors.has(cursor))
|
|
3377
|
+
throw new Error("X notification cursor did not advance");
|
|
3378
|
+
}
|
|
3379
|
+
await ctx.commit(events, {
|
|
3380
|
+
notifications_cursor: cursor ?? null,
|
|
3381
|
+
notifications_account: account,
|
|
3382
|
+
notifications_head_revision: head ?? null,
|
|
3231
3383
|
});
|
|
3384
|
+
return {
|
|
3385
|
+
status: cursor ? "more" : "complete",
|
|
3386
|
+
metadata: {
|
|
3387
|
+
items_found: events.length,
|
|
3388
|
+
...(cursorReset ? { cursor_reset: true } : {}),
|
|
3389
|
+
},
|
|
3390
|
+
};
|
|
3232
3391
|
}
|
|
3233
3392
|
|
|
3234
3393
|
// ── Connector ──────────────────────────────────────────────────
|
|
@@ -3238,8 +3397,8 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3238
3397
|
key: "x",
|
|
3239
3398
|
name: "X (Twitter)",
|
|
3240
3399
|
description:
|
|
3241
|
-
"Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, and reads and answers DMs live in the paired browser. Links social actors into the person graph.",
|
|
3242
|
-
version: "3.
|
|
3400
|
+
"Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, captures notification references, and reads and answers DMs live in the paired browser. Links social actors into the person graph.",
|
|
3401
|
+
version: "3.16.0",
|
|
3243
3402
|
faviconDomain: "x.com",
|
|
3244
3403
|
browser: {
|
|
3245
3404
|
origins: ["https://x.com", "https://twitter.com"],
|
|
@@ -3324,8 +3483,23 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3324
3483
|
{ key: "liked_tweet", label: "Liked Tweet" },
|
|
3325
3484
|
{ key: "bookmark", label: "Bookmark" },
|
|
3326
3485
|
{ key: "dm_message", label: "DM Message" },
|
|
3486
|
+
{ key: "notification", label: "Notification" },
|
|
3327
3487
|
],
|
|
3328
3488
|
feeds: {
|
|
3489
|
+
notifications: {
|
|
3490
|
+
key: "notifications",
|
|
3491
|
+
name: "Notifications",
|
|
3492
|
+
description:
|
|
3493
|
+
"Read the signed-in account's retained All notifications timeline and capture metadata-only references without opening the notification panel or marking items seen. Includes source-exposed grouped reactions/follows and post entries; source icon categories are retained. History is limited by X. For post entries the source date is post creation time, not an invented notification time. Requires browser authentication; this is not OS push interception.",
|
|
3494
|
+
read: readXNotifications,
|
|
3495
|
+
sync: syncXNotifications,
|
|
3496
|
+
eventKinds: {
|
|
3497
|
+
notification: {
|
|
3498
|
+
description:
|
|
3499
|
+
"A metadata-only reference to an X notification timeline item",
|
|
3500
|
+
},
|
|
3501
|
+
},
|
|
3502
|
+
},
|
|
3329
3503
|
live_messages: {
|
|
3330
3504
|
key: "live_messages",
|
|
3331
3505
|
name: "Live messages",
|
|
@@ -3585,6 +3759,7 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3585
3759
|
try {
|
|
3586
3760
|
if (ctx.actionKey === "send_message") {
|
|
3587
3761
|
const dispatcher = requireXBrowser(ctx);
|
|
3762
|
+
const accountId = requireXAccount(ctx);
|
|
3588
3763
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3589
3764
|
const output = await invokeXDirectMessages<Record<string, unknown>>(
|
|
3590
3765
|
dispatcher,
|
|
@@ -3595,6 +3770,7 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3595
3770
|
text: ctx.input.text,
|
|
3596
3771
|
idempotency_key: ctx.input.idempotency_key,
|
|
3597
3772
|
},
|
|
3773
|
+
accountId,
|
|
3598
3774
|
);
|
|
3599
3775
|
return { success: true, output };
|
|
3600
3776
|
}
|
|
@@ -40,7 +40,9 @@ SET attach = COALESCE((
|
|
|
40
40
|
AND e.organization_id = v.organization_id
|
|
41
41
|
AND e.deleted_at IS NULL
|
|
42
42
|
AND (
|
|
43
|
-
|
|
43
|
+
-- CASE, not AND: the planner may OR the id and slug indexes, computing
|
|
44
|
+
-- the id key for a slug pin before any sibling condition.
|
|
45
|
+
e.id = CASE WHEN jsonb_typeof(a.x->'entity') = 'number' THEN (a.x->>'entity')::bigint END
|
|
44
46
|
OR (jsonb_typeof(a.x->'entity') = 'string' AND e.parent_id IS NULL AND e.slug = a.x->>'entity')
|
|
45
47
|
)
|
|
46
48
|
) m
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- migrate:up transaction:false
|
|
2
|
+
-- lobu:no-quiesce
|
|
3
|
+
|
|
4
|
+
-- Each authorized connection/event-type pair has an independently bounded
|
|
5
|
+
-- arrival scan. Unrelated source history cannot increase page scan work.
|
|
6
|
+
DO $heal$
|
|
7
|
+
BEGIN
|
|
8
|
+
IF EXISTS (
|
|
9
|
+
SELECT 1 FROM pg_index i
|
|
10
|
+
JOIN pg_class c ON c.oid = i.indexrelid
|
|
11
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
12
|
+
WHERE n.nspname = 'public' AND c.relname = 'idx_events_source_reference_arrival'
|
|
13
|
+
AND NOT i.indisvalid
|
|
14
|
+
) THEN
|
|
15
|
+
EXECUTE 'DROP INDEX public.idx_events_source_reference_arrival';
|
|
16
|
+
END IF;
|
|
17
|
+
END
|
|
18
|
+
$heal$;
|
|
19
|
+
|
|
20
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_events_source_reference_arrival
|
|
21
|
+
ON public.events (organization_id, connection_id, semantic_type, created_at, id)
|
|
22
|
+
WHERE origin_type = 'source_reference' AND payload_type = 'empty'
|
|
23
|
+
AND cardinality(COALESCE(entity_ids, '{}'::bigint[])) = 0;
|
|
24
|
+
|
|
25
|
+
-- migrate:down transaction:false
|
|
26
|
+
|
|
27
|
+
DROP INDEX CONCURRENTLY IF EXISTS public.idx_events_source_reference_arrival;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- lobu:no-quiesce
|
|
3
|
+
-- One receipt per agent-turn write whose own storage carries no idempotency
|
|
4
|
+
-- key: a chat post, a presented event, an upload, generated media, an ask, an
|
|
5
|
+
-- entity create. The key is the turn-derived one (organization, agent,
|
|
6
|
+
-- conversation, initiating input message, write surface, canonical args), so a
|
|
7
|
+
-- re-run, a redelivered message or a model repeating itself runs the write
|
|
8
|
+
-- once per input message within the receipt retention window.
|
|
9
|
+
--
|
|
10
|
+
-- The receipt is claimed BEFORE the effect ('claimed', no result) and
|
|
11
|
+
-- completed after it ('done', result). A later repeat replays a done result;
|
|
12
|
+
-- a claim without one means an earlier attempt stopped mid-way and may have
|
|
13
|
+
-- been delivered, so the repeat answers "already attempted" instead of
|
|
14
|
+
-- delivering twice. Only an explicit refusal before the effect deletes its
|
|
15
|
+
-- claim; thrown errors retain it because delivery may already have happened.
|
|
16
|
+
--
|
|
17
|
+
-- New table only: code running before this deploy never reads it.
|
|
18
|
+
-- Pruned with the runs retention window (sweepCompletedRuns), hence the
|
|
19
|
+
-- created_at index.
|
|
20
|
+
CREATE TABLE IF NOT EXISTS public.turn_write_receipts (
|
|
21
|
+
organization_id text NOT NULL REFERENCES public.organization(id) ON DELETE CASCADE,
|
|
22
|
+
idempotency_key text NOT NULL,
|
|
23
|
+
surface text NOT NULL,
|
|
24
|
+
state text NOT NULL CHECK (state IN ('claimed', 'done')),
|
|
25
|
+
result jsonb,
|
|
26
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
27
|
+
PRIMARY KEY (organization_id, idempotency_key)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- squawk-ignore require-concurrent-index-creation -- table created immediately above
|
|
31
|
+
CREATE INDEX IF NOT EXISTS idx_turn_write_receipts_created_at
|
|
32
|
+
ON public.turn_write_receipts (created_at);
|
|
33
|
+
|
|
34
|
+
-- migrate:down
|
|
35
|
+
-- squawk-ignore ban-drop-table -- rollback of the receipt table introduced above
|
|
36
|
+
DROP TABLE IF EXISTS public.turn_write_receipts;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
-- squawk-ignore-file prefer-robust-stmts
|
|
2
|
+
-- migrate:up
|
|
3
|
+
-- lobu:quiesce old replicas Number() a NULL stored endpoint into entity 0 in unlink/update_link audit events and cannot address source endpoints in link/list_links, so they must not serve once source endpoints can be written
|
|
4
|
+
-- No source record is materialized. A source endpoint is an immutable type id plus its declared key.
|
|
5
|
+
ALTER TABLE entity_relationships
|
|
6
|
+
ADD COLUMN IF NOT EXISTS from_entity_type_id bigint,
|
|
7
|
+
ADD COLUMN IF NOT EXISTS from_source_key text,
|
|
8
|
+
ADD COLUMN IF NOT EXISTS to_entity_type_id bigint,
|
|
9
|
+
ADD COLUMN IF NOT EXISTS to_source_key text;
|
|
10
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_from_type_fk;
|
|
11
|
+
ALTER TABLE entity_relationships ADD CONSTRAINT entity_relationships_from_type_fk FOREIGN KEY (from_entity_type_id) REFERENCES entity_types(id) NOT VALID;
|
|
12
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_to_type_fk;
|
|
13
|
+
ALTER TABLE entity_relationships ADD CONSTRAINT entity_relationships_to_type_fk FOREIGN KEY (to_entity_type_id) REFERENCES entity_types(id) NOT VALID;
|
|
14
|
+
ALTER TABLE entity_relationships VALIDATE CONSTRAINT entity_relationships_from_type_fk;
|
|
15
|
+
ALTER TABLE entity_relationships VALIDATE CONSTRAINT entity_relationships_to_type_fk;
|
|
16
|
+
-- squawk-ignore ban-drop-not-null
|
|
17
|
+
ALTER TABLE entity_relationships ALTER COLUMN from_entity_id DROP NOT NULL;
|
|
18
|
+
-- squawk-ignore ban-drop-not-null
|
|
19
|
+
ALTER TABLE entity_relationships ALTER COLUMN to_entity_id DROP NOT NULL;
|
|
20
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_from_reference;
|
|
21
|
+
ALTER TABLE entity_relationships ADD CONSTRAINT entity_relationships_from_reference CHECK (
|
|
22
|
+
(from_entity_id IS NOT NULL AND from_entity_type_id IS NULL AND from_source_key IS NULL)
|
|
23
|
+
OR (from_entity_id IS NULL AND from_entity_type_id IS NOT NULL AND from_source_key IS NOT NULL
|
|
24
|
+
AND octet_length(from_source_key) BETWEEN 1 AND 1024)
|
|
25
|
+
) NOT VALID;
|
|
26
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_to_reference;
|
|
27
|
+
ALTER TABLE entity_relationships ADD CONSTRAINT entity_relationships_to_reference CHECK (
|
|
28
|
+
(to_entity_id IS NOT NULL AND to_entity_type_id IS NULL AND to_source_key IS NULL)
|
|
29
|
+
OR (to_entity_id IS NULL AND to_entity_type_id IS NOT NULL AND to_source_key IS NOT NULL
|
|
30
|
+
AND octet_length(to_source_key) BETWEEN 1 AND 1024)
|
|
31
|
+
) NOT VALID;
|
|
32
|
+
ALTER TABLE entity_relationships VALIDATE CONSTRAINT entity_relationships_from_reference;
|
|
33
|
+
ALTER TABLE entity_relationships VALIDATE CONSTRAINT entity_relationships_to_reference;
|
|
34
|
+
|
|
35
|
+
-- Existing stored-only arbiters remain valid for connector and ACL writers.
|
|
36
|
+
-- The new subset is empty during migration; the key byte bound keeps this exact btree key bounded.
|
|
37
|
+
-- squawk-ignore require-concurrent-index-creation
|
|
38
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_entity_relationships_live_source_pair ON entity_relationships (
|
|
39
|
+
organization_id, COALESCE(from_entity_id, 0), COALESCE(from_entity_type_id, 0), COALESCE(from_source_key, ''),
|
|
40
|
+
COALESCE(to_entity_id, 0), COALESCE(to_entity_type_id, 0), COALESCE(to_source_key, ''), relationship_type_id
|
|
41
|
+
) WHERE deleted_at IS NULL AND (from_entity_id IS NULL OR to_entity_id IS NULL);
|
|
42
|
+
-- squawk-ignore require-concurrent-index-creation
|
|
43
|
+
CREATE INDEX IF NOT EXISTS idx_entity_relationships_from_source ON entity_relationships (from_entity_type_id, from_source_key, organization_id)
|
|
44
|
+
WHERE from_entity_type_id IS NOT NULL AND deleted_at IS NULL;
|
|
45
|
+
-- squawk-ignore require-concurrent-index-creation
|
|
46
|
+
CREATE INDEX IF NOT EXISTS idx_entity_relationships_to_source ON entity_relationships (to_entity_type_id, to_source_key, organization_id)
|
|
47
|
+
WHERE to_entity_type_id IS NOT NULL AND deleted_at IS NULL;
|
|
48
|
+
|
|
49
|
+
CREATE OR REPLACE FUNCTION lobu_guard_source_relationships() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
50
|
+
DECLARE rt entity_relationship_types; source_type entity_types; type_id bigint;
|
|
51
|
+
BEGIN
|
|
52
|
+
IF TG_OP = 'UPDATE' AND (OLD.from_entity_type_id IS NOT NULL OR OLD.to_entity_type_id IS NOT NULL) AND
|
|
53
|
+
(NEW.from_entity_id, NEW.from_entity_type_id, NEW.from_source_key, NEW.to_entity_id, NEW.to_entity_type_id, NEW.to_source_key)
|
|
54
|
+
IS DISTINCT FROM
|
|
55
|
+
(OLD.from_entity_id, OLD.from_entity_type_id, OLD.from_source_key, OLD.to_entity_id, OLD.to_entity_type_id, OLD.to_source_key) THEN
|
|
56
|
+
RAISE EXCEPTION 'Source relationship endpoints are immutable; unlink and create a new relationship';
|
|
57
|
+
END IF;
|
|
58
|
+
IF NEW.from_entity_type_id IS NULL AND NEW.to_entity_type_id IS NULL THEN RETURN NEW; END IF;
|
|
59
|
+
SELECT * INTO rt FROM entity_relationship_types WHERE id = NEW.relationship_type_id FOR SHARE;
|
|
60
|
+
IF rt.purpose IN ('authorization', 'identity') OR rt.slug = 'member_of' THEN
|
|
61
|
+
RAISE EXCEPTION 'Authorization and identity associations require stored endpoints';
|
|
62
|
+
END IF;
|
|
63
|
+
-- Withdrawals remain possible after a source disconnect or disappearance.
|
|
64
|
+
IF NEW.deleted_at IS NOT NULL THEN RETURN NEW; END IF;
|
|
65
|
+
FOR type_id IN SELECT DISTINCT id FROM unnest(ARRAY[NEW.from_entity_type_id, NEW.to_entity_type_id]) AS ids(id)
|
|
66
|
+
WHERE id IS NOT NULL ORDER BY id LOOP
|
|
67
|
+
SELECT * INTO source_type FROM entity_types WHERE id = type_id FOR SHARE;
|
|
68
|
+
IF source_type.deleted_at IS NOT NULL OR source_type.backing_sql IS NULL
|
|
69
|
+
OR source_type.organization_id IS DISTINCT FROM NEW.organization_id
|
|
70
|
+
OR source_type.metadata_schema->>'x-lobu-record-key' IS NULL THEN
|
|
71
|
+
RAISE EXCEPTION 'Source endpoints require a live workspace type with a declared stable record key';
|
|
72
|
+
END IF;
|
|
73
|
+
END LOOP;
|
|
74
|
+
RETURN NEW;
|
|
75
|
+
END $$;
|
|
76
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_relationships ON entity_relationships;
|
|
77
|
+
CREATE TRIGGER lobu_guard_source_relationships BEFORE INSERT OR UPDATE ON entity_relationships
|
|
78
|
+
FOR EACH ROW EXECUTE FUNCTION lobu_guard_source_relationships();
|
|
79
|
+
|
|
80
|
+
CREATE OR REPLACE FUNCTION lobu_guard_source_type_contract() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
81
|
+
DECLARE blocking_ids bigint[];
|
|
82
|
+
BEGIN
|
|
83
|
+
IF (NEW.deleted_at, NEW.backing_sql, NEW.backing_source, NEW.metadata_schema->>'x-lobu-record-key')
|
|
84
|
+
IS DISTINCT FROM (OLD.deleted_at, OLD.backing_sql, OLD.backing_source, OLD.metadata_schema->>'x-lobu-record-key')
|
|
85
|
+
AND (EXISTS (SELECT 1 FROM entity_relationships WHERE from_entity_type_id = OLD.id AND deleted_at IS NULL)
|
|
86
|
+
OR EXISTS (SELECT 1 FROM entity_relationships WHERE to_entity_type_id = OLD.id AND deleted_at IS NULL)) THEN
|
|
87
|
+
SELECT array_agg(id) INTO blocking_ids FROM (
|
|
88
|
+
SELECT id FROM entity_relationships WHERE organization_id = OLD.organization_id AND deleted_at IS NULL
|
|
89
|
+
AND (from_entity_type_id = OLD.id OR to_entity_type_id = OLD.id) ORDER BY id LIMIT 25
|
|
90
|
+
) AS blockers;
|
|
91
|
+
RAISE EXCEPTION 'Source record contract has live relationships; unlink relationship IDs % then retry changing backing, key, or deleting the type (at most 25 shown)', blocking_ids
|
|
92
|
+
USING ERRCODE = 'check_violation', CONSTRAINT = 'entity_types_source_relationship_contract';
|
|
93
|
+
END IF;
|
|
94
|
+
RETURN NEW;
|
|
95
|
+
END $$;
|
|
96
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_type_contract ON entity_types;
|
|
97
|
+
CREATE TRIGGER lobu_guard_source_type_contract BEFORE UPDATE ON entity_types
|
|
98
|
+
FOR EACH ROW EXECUTE FUNCTION lobu_guard_source_type_contract();
|
|
99
|
+
|
|
100
|
+
CREATE OR REPLACE FUNCTION lobu_guard_source_relationship_type() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
101
|
+
DECLARE blocking_ids bigint[];
|
|
102
|
+
BEGIN
|
|
103
|
+
IF (NEW.purpose IN ('authorization', 'identity') OR NEW.slug = 'member_of')
|
|
104
|
+
AND EXISTS (SELECT 1 FROM entity_relationships WHERE relationship_type_id = OLD.id
|
|
105
|
+
AND deleted_at IS NULL AND (from_entity_type_id IS NOT NULL OR to_entity_type_id IS NOT NULL)) THEN
|
|
106
|
+
SELECT array_agg(id) INTO blocking_ids FROM (
|
|
107
|
+
SELECT id FROM entity_relationships WHERE relationship_type_id = OLD.id AND organization_id = OLD.organization_id
|
|
108
|
+
AND deleted_at IS NULL AND (from_entity_type_id IS NOT NULL OR to_entity_type_id IS NOT NULL) ORDER BY id LIMIT 25
|
|
109
|
+
) AS blockers;
|
|
110
|
+
RAISE EXCEPTION 'Source relationships cannot become authorization or identity associations; unlink relationship IDs % then retry (at most 25 shown)', blocking_ids
|
|
111
|
+
USING ERRCODE = 'check_violation', CONSTRAINT = 'entity_relationship_types_source_endpoint_purpose';
|
|
112
|
+
END IF;
|
|
113
|
+
RETURN NEW;
|
|
114
|
+
END $$;
|
|
115
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_relationship_type ON entity_relationship_types;
|
|
116
|
+
CREATE TRIGGER lobu_guard_source_relationship_type BEFORE UPDATE ON entity_relationship_types
|
|
117
|
+
FOR EACH ROW EXECUTE FUNCTION lobu_guard_source_relationship_type();
|
|
118
|
+
|
|
119
|
+
-- migrate:down
|
|
120
|
+
-- Refuse rollback while the old binary would misinterpret source endpoints.
|
|
121
|
+
DO $$ BEGIN
|
|
122
|
+
IF EXISTS (SELECT 1 FROM entity_relationships WHERE from_entity_type_id IS NOT NULL OR to_entity_type_id IS NOT NULL) THEN
|
|
123
|
+
RAISE EXCEPTION 'Cannot roll back while source relationship history exists';
|
|
124
|
+
END IF;
|
|
125
|
+
END $$;
|
|
126
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_relationship_type ON entity_relationship_types;
|
|
127
|
+
DROP FUNCTION IF EXISTS lobu_guard_source_relationship_type();
|
|
128
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_type_contract ON entity_types;
|
|
129
|
+
DROP FUNCTION IF EXISTS lobu_guard_source_type_contract();
|
|
130
|
+
DROP TRIGGER IF EXISTS lobu_guard_source_relationships ON entity_relationships;
|
|
131
|
+
DROP FUNCTION IF EXISTS lobu_guard_source_relationships();
|
|
132
|
+
-- squawk-ignore require-concurrent-index-deletion
|
|
133
|
+
DROP INDEX IF EXISTS idx_entity_relationships_from_source;
|
|
134
|
+
-- squawk-ignore require-concurrent-index-deletion
|
|
135
|
+
DROP INDEX IF EXISTS idx_entity_relationships_to_source;
|
|
136
|
+
-- squawk-ignore require-concurrent-index-deletion
|
|
137
|
+
DROP INDEX IF EXISTS idx_entity_relationships_live_source_pair;
|
|
138
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_from_reference;
|
|
139
|
+
ALTER TABLE entity_relationships DROP CONSTRAINT IF EXISTS entity_relationships_to_reference;
|
|
140
|
+
ALTER TABLE entity_relationships ALTER COLUMN from_entity_id SET NOT NULL;
|
|
141
|
+
ALTER TABLE entity_relationships ALTER COLUMN to_entity_id SET NOT NULL;
|
|
142
|
+
ALTER TABLE entity_relationships DROP COLUMN IF EXISTS from_entity_type_id, DROP COLUMN IF EXISTS from_source_key,
|
|
143
|
+
DROP COLUMN IF EXISTS to_entity_type_id, DROP COLUMN IF EXISTS to_source_key;
|