@lobu/runtime-server 20.2.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +15 -16
- package/dist/connectors/github.ts +15 -9
- package/dist/connectors/google_calendar.ts +21 -31
- package/dist/connectors/google_drive.ts +106 -131
- package/dist/connectors/google_gmail.ts +53 -30
- package/dist/connectors/hackernews.ts +2 -5
- package/dist/connectors/jira.ts +62 -27
- package/dist/connectors/linear.ts +55 -21
- package/dist/connectors/microsoft_outlook.ts +151 -110
- package/dist/connectors/postgres.ts +19 -11
- package/dist/connectors/producthunt.ts +8 -6
- package/dist/connectors/reddit.ts +2 -2
- package/dist/connectors/rss.ts +2 -2
- package/dist/connectors/whatsapp_web.ts +5 -4
- package/dist/connectors/x.ts +32 -17
- package/dist/connectors/youtube.ts +18 -5
- package/dist/db/migrations/20260917000000_views.sql +271 -0
- package/dist/db/migrations/20260917000001_views_attach_index.sql +14 -0
- package/dist/db/migrations/20260918000000_runs_turn_tool_event_uniq.sql +51 -0
- package/dist/db/migrations/20260923230000_runs_connector_artifact_hash.sql +32 -0
- package/dist/db/migrations/20260924000000_resource_source_files.sql +17 -0
- package/dist/dependencies.bun.lock +109 -98
- package/dist/guest.bundle.js +78 -10
- package/dist/owletto/dist/assets/_-CwFknmeA.js +1 -0
- package/dist/owletto/dist/assets/_-DrcppoWh.js +2 -0
- package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +1 -0
- package/dist/owletto/dist/assets/_agentId-HNcmgH56.js +1 -0
- package/dist/owletto/dist/assets/_automationId-BCfrLnUS.js +1 -0
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-BAJGfcy7.js → _connectorKey._connectionId-126-iG9w.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey.index-BBF8vGJS.js → _connectorKey.index-CywE9A3N.js} +1 -1
- package/dist/owletto/dist/assets/_conversationId-CNETA_rY.js +1 -0
- package/dist/owletto/dist/assets/_deploymentId-CAVpXf8s.js +1 -0
- package/dist/owletto/dist/assets/_name-BP7OlVxL.js +1 -0
- package/dist/owletto/dist/assets/_owner-D2eh4R90.js +1 -0
- package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +1 -0
- package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +1 -0
- package/dist/owletto/dist/assets/_slug-DoIaJBbh.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +1 -0
- package/dist/owletto/dist/assets/accept-invitation-BWRiEUsd.js +1 -0
- package/dist/owletto/dist/assets/activity-route-view-rVdTeVXN.js +1 -0
- package/dist/owletto/dist/assets/{agent-card-controls-CZO6GI0s.js → agent-card-controls-JubkhcHt.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-_chLOorY.js → agent-client-setup-list-Btcy4Cu1.js} +1 -1
- package/dist/owletto/dist/assets/{agent-connect-pages-DWBgSIYT.js → agent-connect-pages-Chfqn8iL.js} +1 -1
- package/dist/owletto/dist/assets/{agent-editor-form-BTNlg0kQ.js → agent-editor-form-BrOkwfg8.js} +1 -1
- package/dist/owletto/dist/assets/{agent-guardrails-route-B5uoMC6o.js → agent-guardrails-route-CHM7JbIl.js} +1 -1
- package/dist/owletto/dist/assets/{agent-loading-shells-CLoLeFcB.js → agent-loading-shells-DsiGx1fn.js} +1 -1
- package/dist/owletto/dist/assets/{agent-permissions-matrix-TP00-MYL.js → agent-permissions-matrix-L_gFvSu1.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skill-context-D4a2QCoZ.js → agent-skill-context-D7tOJ8Pb.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skills-route-KVDDTbJB.js → agent-skills-route-AylS-B9v.js} +1 -1
- package/dist/owletto/dist/assets/{agent-subpage-shell-DuVYZvBE.js → agent-subpage-shell-B7tCQ9zd.js} +1 -1
- package/dist/owletto/dist/assets/agent-thread-DOYh7WLW.js +8 -0
- package/dist/owletto/dist/assets/agents-0ncYwbz6.js +1 -0
- package/dist/owletto/dist/assets/agents-workbench-DOwn78eL.js +1 -0
- package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +127 -0
- package/dist/owletto/dist/assets/{app._appId-D0_LQTJU.js → app._appId-fJ_RRn1Z.js} +1 -1
- package/dist/owletto/dist/assets/automation-detail-content-CMprQht5.js +1 -0
- package/dist/owletto/dist/assets/automations-0ncYwbz6.js +1 -0
- package/dist/owletto/dist/assets/{calendar-C0XpOHd8.js → calendar-BbD1N97u.js} +1 -1
- package/dist/owletto/dist/assets/{callback-CO_K9eR-.js → callback-PELM84Lh.js} +1 -1
- package/dist/owletto/dist/assets/{card-DeFQuU_J.js → card-DpLjEqIc.js} +1 -1
- package/dist/owletto/dist/assets/{claim-CUpWOSie.js → claim-BLLvLOBM.js} +1 -1
- package/dist/owletto/dist/assets/clients-Bd8WpHSV.js +1 -0
- package/dist/owletto/dist/assets/{code-editor-BqGUZFt6.js → code-editor-DGJQDoHD.js} +1 -1
- package/dist/owletto/dist/assets/connect-Cx49f4J0.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +1 -0
- package/dist/owletto/dist/assets/connected._clientId-BYGmFRCF.js +1 -0
- package/dist/owletto/dist/assets/{connection-BgAlYjeV.js → connection-B0O8OZuK.js} +1 -1
- package/dist/owletto/dist/assets/{connection-feed-detail-B3ePAinf.js → connection-feed-detail-DZjtoEfm.js} +1 -1
- package/dist/owletto/dist/assets/{connector-provenance-DgsDg0Z9.js → connector-provenance-D_g9gGXU.js} +1 -1
- package/dist/owletto/dist/assets/{connectors-CqPQPo9U.js → connectors-BiMMm_QQ.js} +1 -1
- package/dist/owletto/dist/assets/{consent-bswcIzsf.js → consent-CIzW-960.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-DsLgjoel.js → core.esm-Ds4Nuq9d.js} +1 -1
- package/dist/owletto/dist/assets/create--fsxroj2.js +1 -0
- package/dist/owletto/dist/assets/create-BqL-ahEf.js +1 -0
- package/dist/owletto/dist/assets/{create-Dwo04oWV.js → create-BvCaqhwK.js} +1 -1
- package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +2 -0
- package/dist/owletto/dist/assets/{create._connectorKey-CCBb2pil.js → create._connectorKey--qDi1h6S.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-ChFyC9ps.js → cronstrue-h8_zIyZD.js} +1 -1
- package/dist/owletto/dist/assets/deployments-BROg1Te8.js +1 -0
- package/dist/owletto/dist/assets/deployments-ICDss7yS.js +1 -0
- package/dist/owletto/dist/assets/deployments-body-DulCUAMt.js +1 -0
- package/dist/owletto/dist/assets/device-kTL2l_cz.js +1 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-1ikyqSdb.js → device-pin-tombstone-BmD4pv_e.js} +1 -1
- package/dist/owletto/dist/assets/device-rows-BqudjhFu.js +1 -0
- package/dist/owletto/dist/assets/{device._deviceId-DTYKGBY8.js → device._deviceId-CsLJJ6jv.js} +1 -1
- package/dist/owletto/dist/assets/entity-options-ErxYvMDH.js +1 -0
- package/dist/owletto/dist/assets/entity-page-CYRAwUGO.js +1 -0
- package/dist/owletto/dist/assets/entity-type-page-BlAizGlz.js +1 -0
- package/dist/owletto/dist/assets/event-page-DTXPxc-E.js +1 -0
- package/dist/owletto/dist/assets/events-feed-L3c-LLiJ.js +1 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BN2G_YiM.js → full-page-spinner-BxcYpJXx.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +1 -0
- package/dist/owletto/dist/assets/identity-B8lKn0je.js +1 -0
- package/dist/owletto/dist/assets/{index-C6VAJ8Ku.js → index--lEHrFE4.js} +1 -1
- package/dist/owletto/dist/assets/{index-hSE2E46p.js → index-13rywWam.js} +1 -1
- package/dist/owletto/dist/assets/{index-C-u4yR8Z.js → index-BRvT0VV9.js} +1 -1
- package/dist/owletto/dist/assets/index-BUp24ZJr.js +1 -0
- package/dist/owletto/dist/assets/index-B_-MLsof.js +1 -0
- package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +1 -0
- package/dist/owletto/dist/assets/index-C8CR2-Ck.css +1 -0
- package/dist/owletto/dist/assets/{index-OUb5Mlez.js → index-CDz3-ieP.js} +10 -10
- package/dist/owletto/dist/assets/index-CFkj9iR_.js +1 -0
- package/dist/owletto/dist/assets/index-CgBgOElA.js +1 -0
- package/dist/owletto/dist/assets/{index-C2oCgDX7.js → index-CheCJomo.js} +1 -1
- package/dist/owletto/dist/assets/index-CpiW66xK.js +1 -0
- package/dist/owletto/dist/assets/index-DAv5S2aK.js +1 -0
- package/dist/owletto/dist/assets/index-DBi2Xr3i.js +1 -0
- package/dist/owletto/dist/assets/index-DHOha5OJ.js +1 -0
- package/dist/owletto/dist/assets/index-DdGjY1Hb.js +7898 -0
- package/dist/owletto/dist/assets/index-Dkyl7l6E.js +1 -0
- package/dist/owletto/dist/assets/{index-vdqhlocx.js → index-QcHQZI87.js} +1 -1
- package/dist/owletto/dist/assets/index-kq4537-S.js +1 -0
- package/dist/owletto/dist/assets/{json-diff-DnsW7Pin.js → json-diff-BV2STDGj.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-CHzLN7GK.js → list-skeleton-CT5n4ND_.js} +1 -1
- package/dist/owletto/dist/assets/login-DKsgABYt.js +1 -0
- package/dist/owletto/dist/assets/logout-D_CP-emw.js +1 -0
- package/dist/owletto/dist/assets/member-scope-gate-BTgmlfFJ.js +1 -0
- package/dist/owletto/dist/assets/memory-browse-page-FHaJC3ML.js +101 -0
- package/dist/owletto/dist/assets/missing-view-Bve6pJP-.js +1 -0
- package/dist/owletto/dist/assets/{model-selector-DfbmHjLu.js → model-selector-BLCEahny.js} +1 -1
- package/dist/owletto/dist/assets/models-C4N7LQAW.js +1 -0
- package/dist/owletto/dist/assets/new-BAIGSdfp.js +1 -0
- package/dist/owletto/dist/assets/{new-Df_dY6Z5.js → new-CirOK0Sw.js} +1 -1
- package/dist/owletto/dist/assets/new-DzapH2sV.js +1 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-D9GmiMfK.js → oauth-workspace-access-BF7jaswv.js} +1 -1
- package/dist/owletto/dist/assets/{organization-uSDYkJpX.js → organization-D9RPsWG-.js} +1 -1
- package/dist/owletto/dist/assets/{permissions-Fe0DP6b8.js → permissions-BlRONw-u.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-D9HwnDda.js → proposal-review-shell-uskeFIUr.js} +1 -1
- package/dist/owletto/dist/assets/{recent-C03LhMD7.js → recent-CmJ4Is6V.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-CHNejd95.js → renderer-Dyf4t8kR.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CuISnlG_.js → reset-password-BVIeE1Zm.js} +1 -1
- package/dist/owletto/dist/assets/runs-CzBeUzlQ.js +1 -0
- package/dist/owletto/dist/assets/{runs-panel-DsdESupx.js → runs-panel-D7l1uLGm.js} +1 -1
- package/dist/owletto/dist/assets/runs-table-dATyiBg2.js +1 -0
- package/dist/owletto/dist/assets/{schema-value-normalization-B--OWDL8.js → schema-value-normalization-DgMkyVVE.js} +1 -1
- package/dist/owletto/dist/assets/settings-BK1GHmzb.js +1 -0
- package/dist/owletto/dist/assets/{settings-wGNHtsDP.js → settings-Co1wj_m6.js} +1 -1
- package/dist/owletto/dist/assets/skills-DF53JcYt.js +1 -0
- package/dist/owletto/dist/assets/{switch-Dzse_XFM.js → switch-DDkPrV3p.js} +1 -1
- package/dist/owletto/dist/assets/use-applied-views-DELwQQh7.js +1 -0
- package/dist/owletto/dist/assets/{use-mention-search-uyW1Uwf6.js → use-mention-search-CGA3AaKm.js} +1 -1
- package/dist/owletto/dist/assets/view-frame-DDr-Xtet.js +1 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +6703 -3581
- package/npm-shrinkwrap.json +530 -472
- package/package.json +5 -2
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
- package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
- package/vendor/connector-sdk/dist/connector-types.d.ts +28 -13
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
- package/vendor/connector-sdk/dist/define-connector.js +4 -1
- package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
- package/vendor/connector-sdk/dist/http-client.js +15 -13
- package/vendor/connector-sdk/dist/index.d.ts +1 -1
- package/vendor/connector-sdk/dist/retry.d.ts +15 -3
- package/vendor/connector-sdk/dist/retry.js +40 -64
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/agent-policy.js +3 -0
- package/vendor/core/dist/connector-query-errors.d.ts +3 -3
- package/vendor/core/dist/connector-query-errors.js +8 -3
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +24 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +13 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +15 -25
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +3 -5
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
- package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
- package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
- package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
- package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/source-files.js +55 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
- package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
- package/vendor/core/dist/contracts/tools/view-path.js +24 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +73 -8
- package/vendor/core/dist/contracts/worker/protocol.js +58 -9
- package/vendor/core/dist/reserved.d.ts +3 -3
- package/vendor/core/dist/reserved.js +9 -1
- package/vendor/core/dist/utils/secret-redaction.js +2 -0
- package/vendor/core/package.json +25 -5
- package/vendor/views/dist/api.d.ts +179 -0
- package/vendor/views/dist/api.js +406 -0
- package/vendor/views/dist/bridge.d.ts +141 -0
- package/vendor/views/dist/bridge.js +330 -0
- package/vendor/views/dist/index.d.ts +12 -0
- package/vendor/views/dist/index.js +10 -0
- package/vendor/views/package.json +35 -0
- package/dist/owletto/dist/assets/_-Ds4DyQjj.js +0 -2
- package/dist/owletto/dist/assets/_-VmyR6aN_.js +0 -1
- package/dist/owletto/dist/assets/_agentId-BAVnp0c7.js +0 -1
- package/dist/owletto/dist/assets/_agentId-Df-3rGi5.js +0 -1
- package/dist/owletto/dist/assets/_automationId-D696vOjd.js +0 -1
- package/dist/owletto/dist/assets/_conversationId-Ci4rgrHm.js +0 -1
- package/dist/owletto/dist/assets/_deploymentId-Iy-D5PDq.js +0 -1
- package/dist/owletto/dist/assets/_name-CeGwb0oK.js +0 -1
- package/dist/owletto/dist/assets/_owner-CFR1G8OX.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-DuLcQWBu.js +0 -1
- package/dist/owletto/dist/assets/_slug-CDSO20ac.js +0 -1
- package/dist/owletto/dist/assets/accept-invitation-Db5jklHT.js +0 -1
- package/dist/owletto/dist/assets/activity-route-view-DVW3DoB7.js +0 -1
- package/dist/owletto/dist/assets/agent-thread-CzCJU3-R.js +0 -134
- package/dist/owletto/dist/assets/agents-DFs57C3c.js +0 -1
- package/dist/owletto/dist/assets/agents-workbench-C2bUlJP2.js +0 -1
- package/dist/owletto/dist/assets/automation-detail-content-DWkdhnv2.js +0 -1
- package/dist/owletto/dist/assets/automations-DFs57C3c.js +0 -1
- package/dist/owletto/dist/assets/clients-DhYr4lyL.js +0 -1
- package/dist/owletto/dist/assets/connect-Dtb-E5An.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-DWtceAAw.js +0 -1
- package/dist/owletto/dist/assets/connected._clientId-CMe-wTuV.js +0 -1
- package/dist/owletto/dist/assets/create-CcXUdke7.js +0 -1
- package/dist/owletto/dist/assets/create-Cp6hMoeU.js +0 -1
- package/dist/owletto/dist/assets/create-automation-form-CJ4meayB.js +0 -1
- package/dist/owletto/dist/assets/deployments-CjfFxyDA.js +0 -1
- package/dist/owletto/dist/assets/deployments-body-Cg0KiWGr.js +0 -1
- package/dist/owletto/dist/assets/device-DpY67Jaj.js +0 -1
- package/dist/owletto/dist/assets/device-rows-Cp3yMcuV.js +0 -1
- package/dist/owletto/dist/assets/entity-options-1EaSGMX4.js +0 -1
- package/dist/owletto/dist/assets/entity-page-DJmM70dv.js +0 -1
- package/dist/owletto/dist/assets/entity-type-page-C3mT7tXn.js +0 -1
- package/dist/owletto/dist/assets/events-feed-iliGfjit.js +0 -1
- package/dist/owletto/dist/assets/guardrails-CLlnRRy9.js +0 -1
- package/dist/owletto/dist/assets/identity-MSLryUi8.js +0 -1
- package/dist/owletto/dist/assets/index-3o4Eepb4.js +0 -1
- package/dist/owletto/dist/assets/index-BUr8321-.js +0 -7898
- package/dist/owletto/dist/assets/index-Bulu5ldM.js +0 -1
- package/dist/owletto/dist/assets/index-BvbfITqH.js +0 -1
- package/dist/owletto/dist/assets/index-ChcQMdod.css +0 -1
- package/dist/owletto/dist/assets/index-Clw9ZBj-.js +0 -1
- package/dist/owletto/dist/assets/index-D2oL4Ydo.js +0 -1
- package/dist/owletto/dist/assets/index-D7wulT4y.js +0 -1
- package/dist/owletto/dist/assets/index-DOLFe19K.js +0 -1
- package/dist/owletto/dist/assets/index-DTSA0Xh1.js +0 -1
- package/dist/owletto/dist/assets/index-DxXXVPU0.js +0 -1
- package/dist/owletto/dist/assets/index-nzvsA3hT.js +0 -1
- package/dist/owletto/dist/assets/login-CCKNM0gV.js +0 -1
- package/dist/owletto/dist/assets/logout-B-N2aodZ.js +0 -1
- package/dist/owletto/dist/assets/member-scope-gate-B560Wg-t.js +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-DMDqKJn7.js +0 -101
- package/dist/owletto/dist/assets/models-M51OGDRE.js +0 -1
- package/dist/owletto/dist/assets/new-BVQS9H-Y.js +0 -1
- package/dist/owletto/dist/assets/new-DxDVE9nL.js +0 -1
- package/dist/owletto/dist/assets/runs-BnYdToDc.js +0 -1
- package/dist/owletto/dist/assets/runs-table-B7jKuILd.js +0 -1
- package/dist/owletto/dist/assets/settings-Bg9yCCoN.js +0 -1
- package/dist/owletto/dist/assets/skills-CN5Ube7A.js +0 -1
- package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
- package/vendor/core/dist/contracts/tools/manage-view-templates.js +0 -130
|
@@ -31,6 +31,13 @@ import {
|
|
|
31
31
|
type SyncResult,
|
|
32
32
|
} from '@lobu/connector-sdk';
|
|
33
33
|
|
|
34
|
+
/** What one YouTube sync gathers before it is committed. */
|
|
35
|
+
type YouTubeSyncPage = {
|
|
36
|
+
events: EventEnvelope[];
|
|
37
|
+
checkpoint: Record<string, unknown>;
|
|
38
|
+
metadata?: SyncResult['metadata'];
|
|
39
|
+
};
|
|
40
|
+
|
|
34
41
|
// ---------------------------------------------------------------------------
|
|
35
42
|
// YouTube API types
|
|
36
43
|
// ---------------------------------------------------------------------------
|
|
@@ -613,6 +620,12 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
613
620
|
// -------------------------------------------------------------------------
|
|
614
621
|
|
|
615
622
|
private async syncFeed(ctx: SyncContext): Promise<SyncResult> {
|
|
623
|
+
const page = await this.collectFeed(ctx);
|
|
624
|
+
await ctx.commit(page.events, page.checkpoint);
|
|
625
|
+
return { status: 'complete', ...(page.metadata ? { metadata: page.metadata } : {}) };
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
private async collectFeed(ctx: SyncContext): Promise<YouTubeSyncPage> {
|
|
616
629
|
const auth = this.resolveAuth(ctx);
|
|
617
630
|
|
|
618
631
|
switch (ctx.feedKey) {
|
|
@@ -800,7 +813,7 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
800
813
|
// Feed: liked_videos
|
|
801
814
|
// -------------------------------------------------------------------------
|
|
802
815
|
|
|
803
|
-
private async syncLikedVideos(ctx: SyncContext, auth: YouTubeAuth): Promise<
|
|
816
|
+
private async syncLikedVideos(ctx: SyncContext, auth: YouTubeAuth): Promise<YouTubeSyncPage> {
|
|
804
817
|
this.requireOAuth(auth, 'liked_videos');
|
|
805
818
|
const maxResults = Math.min(Math.max((ctx.config.max_results as number) ?? 500, 1), 5000);
|
|
806
819
|
const likesPlaylistId = await this.fetchLikesPlaylistId(auth);
|
|
@@ -820,7 +833,7 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
820
833
|
// Feed: playlists
|
|
821
834
|
// -------------------------------------------------------------------------
|
|
822
835
|
|
|
823
|
-
private async syncPlaylists(ctx: SyncContext, auth: YouTubeAuth): Promise<
|
|
836
|
+
private async syncPlaylists(ctx: SyncContext, auth: YouTubeAuth): Promise<YouTubeSyncPage> {
|
|
824
837
|
this.requireOAuth(auth, 'playlists');
|
|
825
838
|
const maxPlaylists = Math.min(Math.max((ctx.config.max_playlists as number) ?? 100, 1), 500);
|
|
826
839
|
const includeItems = (ctx.config.include_items as boolean) ?? true;
|
|
@@ -894,7 +907,7 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
894
907
|
// Feed: subscriptions
|
|
895
908
|
// -------------------------------------------------------------------------
|
|
896
909
|
|
|
897
|
-
private async syncSubscriptions(ctx: SyncContext, auth: YouTubeAuth): Promise<
|
|
910
|
+
private async syncSubscriptions(ctx: SyncContext, auth: YouTubeAuth): Promise<YouTubeSyncPage> {
|
|
898
911
|
this.requireOAuth(auth, 'subscriptions');
|
|
899
912
|
const maxResults = Math.min(Math.max((ctx.config.max_results as number) ?? 1000, 1), 5000);
|
|
900
913
|
const events: EventEnvelope[] = [];
|
|
@@ -964,7 +977,7 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
964
977
|
// Feed: videos (keyword search)
|
|
965
978
|
// -------------------------------------------------------------------------
|
|
966
979
|
|
|
967
|
-
private async syncSearchVideos(ctx: SyncContext, auth: YouTubeAuth): Promise<
|
|
980
|
+
private async syncSearchVideos(ctx: SyncContext, auth: YouTubeAuth): Promise<YouTubeSyncPage> {
|
|
968
981
|
const searchQuery = ctx.config.search_query as string;
|
|
969
982
|
if (!searchQuery) {
|
|
970
983
|
throw new Error('search_query is required.');
|
|
@@ -1250,7 +1263,7 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
1250
1263
|
return events;
|
|
1251
1264
|
}
|
|
1252
1265
|
|
|
1253
|
-
private buildListCheckpointResult(events: EventEnvelope[]):
|
|
1266
|
+
private buildListCheckpointResult(events: EventEnvelope[]): YouTubeSyncPage {
|
|
1254
1267
|
events.sort((a, b) => b.occurred_at.getTime() - a.occurred_at.getTime());
|
|
1255
1268
|
const latest = events.length > 0 ? events[0].occurred_at.toISOString() : undefined;
|
|
1256
1269
|
return {
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
-- Lobu views replace view templates (phase 1).
|
|
2
|
+
--
|
|
3
|
+
-- New table `views`: one row per view with its current source, compiled
|
|
4
|
+
-- browser bundle, content hash, extracted attach/params/actions metadata and
|
|
5
|
+
-- `last_writer` (apply_id | tool call | user). Same source means the same
|
|
6
|
+
-- hash and no write. Git is the only history of definitions, so there is no
|
|
7
|
+
-- versions table. Deleted: `view_template_versions`,
|
|
8
|
+
-- `view_template_active_tabs`, plus the default-template pointer columns on
|
|
9
|
+
-- `entity_types` and `entities`. Nothing else in the schema changes.
|
|
10
|
+
--
|
|
11
|
+
-- The 17 stored demo template rows are converted, never cleared: every
|
|
12
|
+
-- `view_template_versions` row becomes one `views` row. The active version of
|
|
13
|
+
-- each (resource, tab) group keeps the plain derived key; superseded versions
|
|
14
|
+
-- keep `-v<version>` suffixed keys so no authored content is lost. The
|
|
15
|
+
-- original JSON template is preserved verbatim inside the converted module as
|
|
16
|
+
-- `TEMPLATE`, with the attach/params/actions the row carried. Converted rows
|
|
17
|
+
-- store an empty `compiled_code` and are inert until re-saved through
|
|
18
|
+
-- `manage_views` with a real TSX module, which compiles and fills the bundle.
|
|
19
|
+
--
|
|
20
|
+
-- Lock safety: the dropped tables are small org-config tables (tens of rows;
|
|
21
|
+
-- 17 version rows measured on prod 2026-09-16), so the ACCESS EXCLUSIVE lock
|
|
22
|
+
-- on DROP is held for milliseconds and no concurrent writer blocks on it.
|
|
23
|
+
-- The conversion is one INSERT ... SELECT, fail-closed: key collisions fall
|
|
24
|
+
-- back to deterministic `legacy-view-<id>` keys, and any unexpected conflict
|
|
25
|
+
-- aborts the transaction instead of discarding authored data. The attach GIN
|
|
26
|
+
-- index ships in the follow-up 20260917000001 migration (CONCURRENTLY cannot
|
|
27
|
+
-- run inside this transactional file).
|
|
28
|
+
-- migrate:up
|
|
29
|
+
CREATE TABLE IF NOT EXISTS public.views (
|
|
30
|
+
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
31
|
+
organization_id text NOT NULL,
|
|
32
|
+
key text NOT NULL,
|
|
33
|
+
name text NOT NULL,
|
|
34
|
+
description text NOT NULL DEFAULT '',
|
|
35
|
+
source_code text NOT NULL,
|
|
36
|
+
compiled_code text NOT NULL DEFAULT '',
|
|
37
|
+
content_hash text NOT NULL,
|
|
38
|
+
attach jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
39
|
+
params jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
40
|
+
actions jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
41
|
+
last_writer text NOT NULL,
|
|
42
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
43
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
44
|
+
CONSTRAINT views_key_check CHECK ((key ~ '^[a-z0-9][a-z0-9-]{0,63}$'::text)),
|
|
45
|
+
CONSTRAINT views_organization_key_unique UNIQUE (organization_id, key)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
-- Convert every stored template version into a view. Grouped by
|
|
49
|
+
-- (organization, resource, tab); the active version of each group keeps the
|
|
50
|
+
-- plain key and superseded versions keep `-v<version>` keys. Active means the
|
|
51
|
+
-- parent pointer column for default tabs, `view_template_active_tabs` for
|
|
52
|
+
-- named tabs, and the latest version when no pointer names one.
|
|
53
|
+
WITH ranked AS (
|
|
54
|
+
SELECT v.*,
|
|
55
|
+
ROW_NUMBER() OVER (
|
|
56
|
+
PARTITION BY v.organization_id, v.resource_type, v.resource_id, COALESCE(v.tab_name, '')
|
|
57
|
+
ORDER BY v.version DESC
|
|
58
|
+
) AS rn
|
|
59
|
+
FROM public.view_template_versions v
|
|
60
|
+
),
|
|
61
|
+
active_default AS (
|
|
62
|
+
SELECT et.organization_id, 'entity_type'::text AS resource_type, et.slug AS resource_id,
|
|
63
|
+
et.current_view_template_version_id AS version_id
|
|
64
|
+
FROM public.entity_types et
|
|
65
|
+
WHERE et.current_view_template_version_id IS NOT NULL
|
|
66
|
+
UNION ALL
|
|
67
|
+
SELECT e.organization_id, 'entity'::text AS resource_type, e.id::text AS resource_id,
|
|
68
|
+
e.current_view_template_version_id AS version_id
|
|
69
|
+
FROM public.entities e
|
|
70
|
+
WHERE e.current_view_template_version_id IS NOT NULL
|
|
71
|
+
),
|
|
72
|
+
active_tabs AS (
|
|
73
|
+
SELECT organization_id, resource_type, resource_id, tab_name,
|
|
74
|
+
current_version_id AS version_id
|
|
75
|
+
FROM public.view_template_active_tabs
|
|
76
|
+
),
|
|
77
|
+
flagged AS (
|
|
78
|
+
SELECT r.organization_id, r.resource_type, r.resource_id, r.tab_name,
|
|
79
|
+
r.id, r.version, r.json_template, r.created_by, r.rn,
|
|
80
|
+
CASE
|
|
81
|
+
WHEN r.tab_name IS NULL AND d.version_id = r.id THEN true
|
|
82
|
+
WHEN r.tab_name IS NOT NULL AND t.version_id = r.id THEN true
|
|
83
|
+
WHEN r.rn = 1
|
|
84
|
+
AND NOT EXISTS (
|
|
85
|
+
SELECT 1 FROM active_default d2
|
|
86
|
+
WHERE d2.organization_id = r.organization_id
|
|
87
|
+
AND d2.resource_type = r.resource_type
|
|
88
|
+
AND d2.resource_id = r.resource_id
|
|
89
|
+
AND r.tab_name IS NULL
|
|
90
|
+
)
|
|
91
|
+
AND NOT EXISTS (
|
|
92
|
+
SELECT 1 FROM active_tabs t2
|
|
93
|
+
WHERE t2.organization_id = r.organization_id
|
|
94
|
+
AND t2.resource_type = r.resource_type
|
|
95
|
+
AND t2.resource_id = r.resource_id
|
|
96
|
+
AND t2.tab_name IS NOT DISTINCT FROM r.tab_name
|
|
97
|
+
AND r.tab_name IS NOT NULL
|
|
98
|
+
)
|
|
99
|
+
THEN true
|
|
100
|
+
ELSE false
|
|
101
|
+
END AS is_active
|
|
102
|
+
FROM ranked r
|
|
103
|
+
LEFT JOIN active_default d
|
|
104
|
+
ON d.organization_id = r.organization_id
|
|
105
|
+
AND d.resource_type = r.resource_type
|
|
106
|
+
AND d.resource_id = r.resource_id
|
|
107
|
+
AND r.tab_name IS NULL
|
|
108
|
+
LEFT JOIN active_tabs t
|
|
109
|
+
ON t.organization_id = r.organization_id
|
|
110
|
+
AND t.resource_type = r.resource_type
|
|
111
|
+
AND t.resource_id = r.resource_id
|
|
112
|
+
AND t.tab_name = r.tab_name
|
|
113
|
+
AND r.tab_name IS NOT NULL
|
|
114
|
+
),
|
|
115
|
+
shaped AS (
|
|
116
|
+
SELECT f.organization_id, f.resource_type, f.resource_id, f.tab_name,
|
|
117
|
+
f.id, f.version, f.json_template, f.created_by, f.rn, f.is_active,
|
|
118
|
+
-- Slug the key from tab + resource; trim to the key grammar the views
|
|
119
|
+
-- table enforces. Values are data, never identifiers, so anything outside
|
|
120
|
+
-- [a-z0-9] folds to a dash.
|
|
121
|
+
NULLIF(
|
|
122
|
+
TRIM(
|
|
123
|
+
BOTH '-' FROM REGEXP_REPLACE(
|
|
124
|
+
LOWER(COALESCE(f.tab_name, 'default') || '-' || f.resource_type || '-' || f.resource_id),
|
|
125
|
+
'[^a-z0-9]+', '-', 'g'
|
|
126
|
+
)
|
|
127
|
+
),
|
|
128
|
+
''
|
|
129
|
+
) AS base_key,
|
|
130
|
+
CASE WHEN f.tab_name IS NULL THEN 'overview' ELSE 'tab' END AS placement,
|
|
131
|
+
CASE WHEN JSONB_TYPEOF(f.json_template->'interactions') = 'object'
|
|
132
|
+
THEN COALESCE((
|
|
133
|
+
SELECT JSONB_OBJECT_AGG(e.key, JSONB_BUILD_OBJECT('emits', e.value->>'emits'))
|
|
134
|
+
FROM JSONB_EACH(f.json_template->'interactions') AS e(key, value)
|
|
135
|
+
WHERE JSONB_TYPEOF(e.value) = 'object'
|
|
136
|
+
AND e.value->>'emits' IS NOT NULL
|
|
137
|
+
AND e.value->>'emits' <> ''
|
|
138
|
+
), '{}'::jsonb)
|
|
139
|
+
ELSE '{}'::jsonb
|
|
140
|
+
END AS actions
|
|
141
|
+
FROM flagged f
|
|
142
|
+
),
|
|
143
|
+
keyed AS (
|
|
144
|
+
SELECT s.*,
|
|
145
|
+
COALESCE(s.base_key, 'view') AS slug,
|
|
146
|
+
CASE WHEN s.resource_type = 'entity_type'
|
|
147
|
+
THEN JSONB_BUILD_ARRAY(JSONB_BUILD_OBJECT('type', s.resource_id, 'placement', s.placement))
|
|
148
|
+
ELSE JSONB_BUILD_ARRAY(
|
|
149
|
+
CASE WHEN s.resource_id ~ '^[0-9]+$'
|
|
150
|
+
THEN JSONB_BUILD_OBJECT('entity', s.resource_id::bigint, 'placement', s.placement)
|
|
151
|
+
ELSE JSONB_BUILD_OBJECT('entity', s.resource_id, 'placement', s.placement)
|
|
152
|
+
END
|
|
153
|
+
)
|
|
154
|
+
END AS attach
|
|
155
|
+
FROM shaped s
|
|
156
|
+
),
|
|
157
|
+
sourced AS (
|
|
158
|
+
SELECT k.organization_id, k.resource_id, k.resource_type, k.tab_name,
|
|
159
|
+
k.id, k.version, k.created_by, k.is_active, k.slug, k.attach, k.actions,
|
|
160
|
+
-- Newlines in resource ids would break out of the `//` header comment,
|
|
161
|
+
-- so they fold to spaces. Everything else below is value concatenation,
|
|
162
|
+
-- never a string literal, so quotes need no escaping.
|
|
163
|
+
'// Converted from view template ('
|
|
164
|
+
|| k.resource_type || ':'
|
|
165
|
+
|| REPLACE(REPLACE(k.resource_id, CHR(10), ' '), CHR(13), ' ')
|
|
166
|
+
|| COALESCE('/' || REPLACE(REPLACE(k.tab_name, CHR(10), ' '), CHR(13), ' '), '')
|
|
167
|
+
|| ', v' || k.version::text
|
|
168
|
+
|| ') by migration 20260917000000_views.' || CHR(10)
|
|
169
|
+
|| '// The original JSON template is preserved below as TEMPLATE.'
|
|
170
|
+
|| CHR(10)
|
|
171
|
+
|| '// Re-save through manage_views with a real TSX module to recompile this view.'
|
|
172
|
+
|| CHR(10)
|
|
173
|
+
|| 'export const view = { attach: ' || k.attach::text
|
|
174
|
+
|| ', params: {}, actions: ' || k.actions::text || ' };' || CHR(10)
|
|
175
|
+
|| 'const TEMPLATE = ' || k.json_template::text || ';' || CHR(10)
|
|
176
|
+
|| 'export default function ConvertedView() { return null; }' || CHR(10)
|
|
177
|
+
AS source_code
|
|
178
|
+
FROM keyed k
|
|
179
|
+
),
|
|
180
|
+
final AS (
|
|
181
|
+
SELECT s.organization_id,
|
|
182
|
+
LEFT(s.slug, 64) AS plain_key,
|
|
183
|
+
LEFT(s.slug, 44) || '-v' || s.version::text AS versioned_key,
|
|
184
|
+
s.is_active, s.version, s.id,
|
|
185
|
+
LEFT(
|
|
186
|
+
s.resource_id
|
|
187
|
+
|| COALESCE(' / ' || NULLIF(s.tab_name, ''), ''),
|
|
188
|
+
120
|
|
189
|
+
) AS view_name,
|
|
190
|
+
'Converted from a view template by migration 20260917000000_views; re-save to recompile.'
|
|
191
|
+
AS view_description,
|
|
192
|
+
s.source_code,
|
|
193
|
+
SUBSTRING(MD5(s.source_code) FROM 1 FOR 16) AS source_hash,
|
|
194
|
+
s.attach, s.actions, s.created_by
|
|
195
|
+
FROM sourced s
|
|
196
|
+
),
|
|
197
|
+
deduped AS (
|
|
198
|
+
SELECT f.*,
|
|
199
|
+
CASE WHEN f.is_active THEN f.plain_key ELSE f.versioned_key END AS candidate_key,
|
|
200
|
+
COUNT(*) OVER (
|
|
201
|
+
PARTITION BY f.organization_id,
|
|
202
|
+
CASE WHEN f.is_active THEN f.plain_key ELSE f.versioned_key END
|
|
203
|
+
) AS key_count
|
|
204
|
+
FROM final f
|
|
205
|
+
)
|
|
206
|
+
INSERT INTO public.views (
|
|
207
|
+
organization_id, key, name, description, source_code, compiled_code,
|
|
208
|
+
content_hash, attach, params, actions, last_writer
|
|
209
|
+
)
|
|
210
|
+
SELECT d.organization_id,
|
|
211
|
+
CASE
|
|
212
|
+
WHEN d.key_count > 1 OR d.candidate_key ~ '^legacy-view-[0-9]+$'
|
|
213
|
+
THEN 'legacy-view-' || d.id::text
|
|
214
|
+
ELSE d.candidate_key
|
|
215
|
+
END,
|
|
216
|
+
d.view_name, d.view_description, d.source_code, '',
|
|
217
|
+
d.source_hash, d.attach, '{}'::jsonb, d.actions,
|
|
218
|
+
'migration:view-templates'
|
|
219
|
+
FROM deduped d;
|
|
220
|
+
|
|
221
|
+
-- Retire the template tables and their default-template pointers. The foreign
|
|
222
|
+
-- keys go first so the table drops do not depend on drop order.
|
|
223
|
+
ALTER TABLE ONLY public.entities DROP CONSTRAINT IF EXISTS entities_view_template_version_fk;
|
|
224
|
+
ALTER TABLE ONLY public.entity_types DROP CONSTRAINT IF EXISTS entity_types_view_template_version_fk;
|
|
225
|
+
-- The template feature is retired; every stored row converts into a `views`
|
|
226
|
+
-- row above, so no authored content is lost.
|
|
227
|
+
-- squawk-ignore ban-drop-table
|
|
228
|
+
DROP TABLE IF EXISTS public.view_template_active_tabs;
|
|
229
|
+
-- squawk-ignore ban-drop-table
|
|
230
|
+
DROP TABLE IF EXISTS public.view_template_versions;
|
|
231
|
+
ALTER TABLE ONLY public.entities DROP COLUMN IF EXISTS current_view_template_version_id;
|
|
232
|
+
ALTER TABLE ONLY public.entity_types DROP COLUMN IF EXISTS current_view_template_version_id;
|
|
233
|
+
|
|
234
|
+
-- migrate:down
|
|
235
|
+
-- Irreversible for data: converted template rows are not restored (recover
|
|
236
|
+
-- them from a backup). The retired schema comes back empty so a down/up
|
|
237
|
+
-- round-trip keeps working. Foreign keys are deliberately not recreated: the
|
|
238
|
+
-- down path exists for local rollback, where old code runs its joins without
|
|
239
|
+
-- needing the constraints enforced.
|
|
240
|
+
CREATE TABLE IF NOT EXISTS public.view_template_versions (
|
|
241
|
+
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
242
|
+
resource_type text NOT NULL,
|
|
243
|
+
resource_id text NOT NULL,
|
|
244
|
+
organization_id text NOT NULL,
|
|
245
|
+
version bigint NOT NULL,
|
|
246
|
+
tab_name text,
|
|
247
|
+
tab_order bigint DEFAULT 0,
|
|
248
|
+
json_template jsonb NOT NULL,
|
|
249
|
+
change_notes text,
|
|
250
|
+
created_by text NOT NULL,
|
|
251
|
+
created_at timestamp with time zone DEFAULT now(),
|
|
252
|
+
CONSTRAINT view_template_versions_resource_type_check CHECK ((resource_type = ANY (ARRAY['entity_type'::text, 'entity'::text])))
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
CREATE TABLE IF NOT EXISTS public.view_template_active_tabs (
|
|
256
|
+
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
257
|
+
resource_type text NOT NULL,
|
|
258
|
+
resource_id text NOT NULL,
|
|
259
|
+
organization_id text NOT NULL,
|
|
260
|
+
tab_name text NOT NULL,
|
|
261
|
+
tab_order bigint DEFAULT 0,
|
|
262
|
+
current_version_id bigint NOT NULL,
|
|
263
|
+
CONSTRAINT view_template_active_tabs_resource_type_check CHECK ((resource_type = ANY (ARRAY['entity_type'::text, 'entity'::text]))),
|
|
264
|
+
CONSTRAINT view_template_active_tabs_unique UNIQUE (resource_type, resource_id, organization_id, tab_name)
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
ALTER TABLE ONLY public.entities ADD COLUMN IF NOT EXISTS current_view_template_version_id bigint;
|
|
268
|
+
ALTER TABLE ONLY public.entity_types ADD COLUMN IF NOT EXISTS current_view_template_version_id bigint;
|
|
269
|
+
|
|
270
|
+
-- squawk-ignore ban-drop-table
|
|
271
|
+
DROP TABLE IF EXISTS public.views;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Attach index for `views` (phase 1).
|
|
2
|
+
--
|
|
3
|
+
-- Mount-point reads filter views by their attach lines (`attach @> ...`), so
|
|
4
|
+
-- the payload gets a GIN index like the other jsonb filter columns. Split
|
|
5
|
+
-- from 20260917000000_views because CONCURRENTLY cannot run inside that
|
|
6
|
+
-- file's transactional section (one statement per transaction:false file).
|
|
7
|
+
-- No reader exists in PR1 yet: the index is pre-provisioned for the PR3 mount
|
|
8
|
+
-- points so the stacked rollout adds no later schema change for it.
|
|
9
|
+
-- migrate:up transaction:false
|
|
10
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_views_attach
|
|
11
|
+
ON public.views USING gin (attach);
|
|
12
|
+
|
|
13
|
+
-- migrate:down transaction:false
|
|
14
|
+
DROP INDEX CONCURRENTLY IF EXISTS public.idx_views_attach;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
-- migrate:up transaction:false
|
|
2
|
+
|
|
3
|
+
-- Keyed idempotence for agent-turn tool traces (#3662 follow-up).
|
|
4
|
+
--
|
|
5
|
+
-- Heartbeat tool receipts are `thread_response` rows carrying a
|
|
6
|
+
-- `customEvent.name = 'tool_use'` payload, keyed by the canonical
|
|
7
|
+
-- (organization, conversation, initiating input message, tool call id) tuple in
|
|
8
|
+
-- `idempotency_key` (`turn-tool:v1:...`, set by the agent-turn worker API).
|
|
9
|
+
--
|
|
10
|
+
-- The pre-existing `runs_idempotency_key_uniq` partial index only covers live
|
|
11
|
+
-- rows (`status IN ('pending','claimed','running')`): once a trace is claimed
|
|
12
|
+
-- and delivered it drops out of that index, so a heartbeat retry re-inserted
|
|
13
|
+
-- the same trace as a second row and the beat ACKed all events. This index is
|
|
14
|
+
-- scoped to exactly the tool-trace shape across ALL statuses — pending,
|
|
15
|
+
-- claimed, failed and delivered alike — so a retry collides no matter what
|
|
16
|
+
-- delivery state the first insert has reached. A conflicting same-key payload
|
|
17
|
+
-- (same key, different trace body) collides too; the worker API re-reads the
|
|
18
|
+
-- stored row and rejects it rather than ACKing, so the worker keeps the
|
|
19
|
+
-- evidence queued instead of retiring it unwritten.
|
|
20
|
+
--
|
|
21
|
+
-- Narrowly scoped on purpose: only `thread_response` rows whose payload is a
|
|
22
|
+
-- `tool_use` custom event and that carry a key participate. Every other row —
|
|
23
|
+
-- including keyless legacy traces — stays out of the index entirely.
|
|
24
|
+
|
|
25
|
+
-- Fail loudly before index construction if an earlier partial rollout already
|
|
26
|
+
-- wrote duplicate keyed rows. This migration never chooses a winner or deletes
|
|
27
|
+
-- evidence; an operator must inspect and reconcile the conflicting facts.
|
|
28
|
+
DO $$
|
|
29
|
+
BEGIN
|
|
30
|
+
IF EXISTS (
|
|
31
|
+
SELECT 1
|
|
32
|
+
FROM public.runs
|
|
33
|
+
WHERE queue_name = 'thread_response'
|
|
34
|
+
AND action_input->'customEvent'->>'name' = 'tool_use'
|
|
35
|
+
AND idempotency_key IS NOT NULL
|
|
36
|
+
GROUP BY idempotency_key
|
|
37
|
+
HAVING count(*) > 1
|
|
38
|
+
) THEN
|
|
39
|
+
RAISE EXCEPTION 'duplicate keyed agent-turn tool traces block idx_runs_turn_tool_event_uniq';
|
|
40
|
+
END IF;
|
|
41
|
+
END $$;
|
|
42
|
+
|
|
43
|
+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS idx_runs_turn_tool_event_uniq
|
|
44
|
+
ON public.runs (idempotency_key)
|
|
45
|
+
WHERE queue_name = 'thread_response'
|
|
46
|
+
AND action_input->'customEvent'->>'name' = 'tool_use'
|
|
47
|
+
AND idempotency_key IS NOT NULL;
|
|
48
|
+
|
|
49
|
+
-- migrate:down transaction:false
|
|
50
|
+
|
|
51
|
+
DROP INDEX CONCURRENTLY IF EXISTS public.idx_runs_turn_tool_event_uniq;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- Deliberately requires the existing quiesced deployment: old replicas must
|
|
3
|
+
-- stop admitting/claiming connector runs before this one-time cutover.
|
|
4
|
+
-- Cost: ADD COLUMN is metadata-only, with no history backfill. The cutover
|
|
5
|
+
-- updates pending connector runs only. Tested on fixtures, not production size.
|
|
6
|
+
SET LOCAL lock_timeout = '5s';
|
|
7
|
+
SET LOCAL statement_timeout = '60s';
|
|
8
|
+
|
|
9
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS connector_artifact_hash text;
|
|
10
|
+
|
|
11
|
+
-- Today's mutable version row cannot prove yesterday's admitted identity.
|
|
12
|
+
-- Preserve the run as a visible failure; never guess its hash or replay it.
|
|
13
|
+
UPDATE runs r
|
|
14
|
+
SET status = 'failed', completed_at = CURRENT_TIMESTAMP,
|
|
15
|
+
approval_status = CASE WHEN approval_status = 'pending' THEN 'rejected' ELSE approval_status END,
|
|
16
|
+
error_message = 'The admitted connector manifest was not recorded. Re-run this operation against the current device contract.'
|
|
17
|
+
WHERE r.status = 'pending'
|
|
18
|
+
AND r.run_type IN ('sync', 'action', 'auth')
|
|
19
|
+
AND r.connector_artifact_hash IS NULL
|
|
20
|
+
AND (
|
|
21
|
+
SELECT cv.source_path LIKE 'device-manifest://%'
|
|
22
|
+
AND cv.compiled_code IS NULL AND cv.compile_config_hash IS NULL
|
|
23
|
+
AND cv.source_code IS NULL AND cv.compiled_code_hash IS NOT NULL
|
|
24
|
+
FROM connector_versions cv
|
|
25
|
+
WHERE cv.connector_key = r.connector_key AND cv.version = r.connector_version
|
|
26
|
+
AND (cv.organization_id = r.organization_id OR cv.organization_id IS NULL)
|
|
27
|
+
ORDER BY cv.organization_id NULLS LAST
|
|
28
|
+
LIMIT 1
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
-- migrate:down
|
|
32
|
+
ALTER TABLE runs DROP COLUMN IF EXISTS connector_artifact_hash;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
ALTER TABLE views
|
|
3
|
+
ADD COLUMN IF NOT EXISTS source_files jsonb,
|
|
4
|
+
ADD COLUMN IF NOT EXISTS dependencies jsonb,
|
|
5
|
+
ADD COLUMN IF NOT EXISTS source_complete boolean;
|
|
6
|
+
|
|
7
|
+
ALTER TABLE connector_versions
|
|
8
|
+
ADD COLUMN IF NOT EXISTS source_files jsonb,
|
|
9
|
+
ADD COLUMN IF NOT EXISTS dependencies jsonb,
|
|
10
|
+
ADD COLUMN IF NOT EXISTS source_complete boolean;
|
|
11
|
+
|
|
12
|
+
-- Existing artifacts have unknown source provenance. Re-saving captures it;
|
|
13
|
+
-- neither a compiled-code hash nor source-looking text proves completeness.
|
|
14
|
+
|
|
15
|
+
-- migrate:down
|
|
16
|
+
ALTER TABLE connector_versions DROP COLUMN IF EXISTS source_files, DROP COLUMN IF EXISTS dependencies, DROP COLUMN IF EXISTS source_complete;
|
|
17
|
+
ALTER TABLE views DROP COLUMN IF EXISTS source_files, DROP COLUMN IF EXISTS dependencies, DROP COLUMN IF EXISTS source_complete;
|