@lobu/runtime-server 20.1.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.
Files changed (260) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/connectors/README.md +15 -16
  3. package/dist/connectors/chat-user-identity.ts +41 -0
  4. package/dist/connectors/github.ts +15 -9
  5. package/dist/connectors/google-identity.ts +11 -0
  6. package/dist/connectors/google_calendar.ts +21 -31
  7. package/dist/connectors/google_drive.ts +106 -131
  8. package/dist/connectors/google_gmail.ts +53 -30
  9. package/dist/connectors/hackernews.ts +2 -5
  10. package/dist/connectors/jira.ts +62 -27
  11. package/dist/connectors/linear.ts +55 -21
  12. package/dist/connectors/microsoft_outlook.ts +151 -110
  13. package/dist/connectors/postgres.ts +19 -11
  14. package/dist/connectors/producthunt.ts +8 -6
  15. package/dist/connectors/reddit.ts +2 -2
  16. package/dist/connectors/rss.ts +2 -2
  17. package/dist/connectors/slack-identity.ts +19 -0
  18. package/dist/connectors/whatsapp_web.ts +5 -4
  19. package/dist/connectors/x.ts +32 -17
  20. package/dist/connectors/youtube.ts +18 -5
  21. package/dist/db/migrations/20260915030000_owner_dm_delivery_request_platform.sql +51 -0
  22. package/dist/db/migrations/20260917000000_views.sql +271 -0
  23. package/dist/db/migrations/20260917000001_views_attach_index.sql +14 -0
  24. package/dist/db/migrations/20260918000000_runs_turn_tool_event_uniq.sql +51 -0
  25. package/dist/db/migrations/20260923230000_runs_connector_artifact_hash.sql +32 -0
  26. package/dist/db/migrations/20260924000000_resource_source_files.sql +17 -0
  27. package/dist/dependencies.bun.lock +122 -113
  28. package/dist/guest.bundle.js +78 -10
  29. package/dist/owletto/dist/assets/_-CwFknmeA.js +1 -0
  30. package/dist/owletto/dist/assets/_-DrcppoWh.js +2 -0
  31. package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +1 -0
  32. package/dist/owletto/dist/assets/_agentId-HNcmgH56.js +1 -0
  33. package/dist/owletto/dist/assets/_automationId-BCfrLnUS.js +1 -0
  34. package/dist/owletto/dist/assets/{_connectorKey._connectionId-NQf43Ew3.js → _connectorKey._connectionId-126-iG9w.js} +1 -1
  35. package/dist/owletto/dist/assets/{_connectorKey.index-D-0ZNsgM.js → _connectorKey.index-CywE9A3N.js} +1 -1
  36. package/dist/owletto/dist/assets/_conversationId-CNETA_rY.js +1 -0
  37. package/dist/owletto/dist/assets/_deploymentId-CAVpXf8s.js +1 -0
  38. package/dist/owletto/dist/assets/_name-BP7OlVxL.js +1 -0
  39. package/dist/owletto/dist/assets/_owner-D2eh4R90.js +1 -0
  40. package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +1 -0
  41. package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +1 -0
  42. package/dist/owletto/dist/assets/_slug-DoIaJBbh.js +1 -0
  43. package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +1 -0
  44. package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +1 -0
  45. package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +1 -0
  46. package/dist/owletto/dist/assets/accept-invitation-BWRiEUsd.js +1 -0
  47. package/dist/owletto/dist/assets/activity-route-view-rVdTeVXN.js +1 -0
  48. package/dist/owletto/dist/assets/{agent-card-controls-VJgcB5-0.js → agent-card-controls-JubkhcHt.js} +1 -1
  49. package/dist/owletto/dist/assets/{agent-client-setup-list-C5KRNRw3.js → agent-client-setup-list-Btcy4Cu1.js} +1 -1
  50. package/dist/owletto/dist/assets/{agent-connect-pages-BFSb6vmW.js → agent-connect-pages-Chfqn8iL.js} +1 -1
  51. package/dist/owletto/dist/assets/{agent-editor-form-CajEehVn.js → agent-editor-form-BrOkwfg8.js} +1 -1
  52. package/dist/owletto/dist/assets/{agent-guardrails-route-CZ_rXj-3.js → agent-guardrails-route-CHM7JbIl.js} +1 -1
  53. package/dist/owletto/dist/assets/{agent-loading-shells-Dczhk067.js → agent-loading-shells-DsiGx1fn.js} +1 -1
  54. package/dist/owletto/dist/assets/{agent-permissions-matrix-DIVHvpZG.js → agent-permissions-matrix-L_gFvSu1.js} +1 -1
  55. package/dist/owletto/dist/assets/{agent-skill-context-CxglCznW.js → agent-skill-context-D7tOJ8Pb.js} +1 -1
  56. package/dist/owletto/dist/assets/{agent-skills-route-CatU8soC.js → agent-skills-route-AylS-B9v.js} +1 -1
  57. package/dist/owletto/dist/assets/{agent-subpage-shell-DVSUdIBn.js → agent-subpage-shell-B7tCQ9zd.js} +1 -1
  58. package/dist/owletto/dist/assets/agent-thread-DOYh7WLW.js +8 -0
  59. package/dist/owletto/dist/assets/agents-0ncYwbz6.js +1 -0
  60. package/dist/owletto/dist/assets/agents-workbench-DOwn78eL.js +1 -0
  61. package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +127 -0
  62. package/dist/owletto/dist/assets/{app._appId-BXmITXO7.js → app._appId-fJ_RRn1Z.js} +1 -1
  63. package/dist/owletto/dist/assets/automation-detail-content-CMprQht5.js +1 -0
  64. package/dist/owletto/dist/assets/automations-0ncYwbz6.js +1 -0
  65. package/dist/owletto/dist/assets/{calendar-taCoBmAh.js → calendar-BbD1N97u.js} +1 -1
  66. package/dist/owletto/dist/assets/{callback-CJxC8u_x.js → callback-PELM84Lh.js} +1 -1
  67. package/dist/owletto/dist/assets/{card-kpw3EaKC.js → card-DpLjEqIc.js} +1 -1
  68. package/dist/owletto/dist/assets/{claim-DLHRN0bA.js → claim-BLLvLOBM.js} +1 -1
  69. package/dist/owletto/dist/assets/clients-Bd8WpHSV.js +1 -0
  70. package/dist/owletto/dist/assets/{code-editor-D3X0yQdI.js → code-editor-DGJQDoHD.js} +1 -1
  71. package/dist/owletto/dist/assets/connect-Cx49f4J0.js +1 -0
  72. package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +1 -0
  73. package/dist/owletto/dist/assets/connected._clientId-BYGmFRCF.js +1 -0
  74. package/dist/owletto/dist/assets/{connection-DdBkXNbX.js → connection-B0O8OZuK.js} +1 -1
  75. package/dist/owletto/dist/assets/{connection-feed-detail-DF93zx0A.js → connection-feed-detail-DZjtoEfm.js} +1 -1
  76. package/dist/owletto/dist/assets/{connector-provenance-N3sc0nbo.js → connector-provenance-D_g9gGXU.js} +1 -1
  77. package/dist/owletto/dist/assets/{connectors-Ckn_aoNE.js → connectors-BiMMm_QQ.js} +1 -1
  78. package/dist/owletto/dist/assets/{consent-Bi6KCVtT.js → consent-CIzW-960.js} +1 -1
  79. package/dist/owletto/dist/assets/{core.esm-CFYXLQXH.js → core.esm-Ds4Nuq9d.js} +1 -1
  80. package/dist/owletto/dist/assets/create--fsxroj2.js +1 -0
  81. package/dist/owletto/dist/assets/create-BqL-ahEf.js +1 -0
  82. package/dist/owletto/dist/assets/{create-BiHpu2f4.js → create-BvCaqhwK.js} +1 -1
  83. package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +2 -0
  84. package/dist/owletto/dist/assets/{create._connectorKey-Qynix_hA.js → create._connectorKey--qDi1h6S.js} +1 -1
  85. package/dist/owletto/dist/assets/{cronstrue-D7xlYtGk.js → cronstrue-h8_zIyZD.js} +1 -1
  86. package/dist/owletto/dist/assets/deployments-BROg1Te8.js +1 -0
  87. package/dist/owletto/dist/assets/deployments-ICDss7yS.js +1 -0
  88. package/dist/owletto/dist/assets/deployments-body-DulCUAMt.js +1 -0
  89. package/dist/owletto/dist/assets/device-kTL2l_cz.js +1 -0
  90. package/dist/owletto/dist/assets/{device-pin-tombstone-DrTJYNKG.js → device-pin-tombstone-BmD4pv_e.js} +1 -1
  91. package/dist/owletto/dist/assets/device-rows-BqudjhFu.js +1 -0
  92. package/dist/owletto/dist/assets/{device._deviceId-CIe7taim.js → device._deviceId-CsLJJ6jv.js} +1 -1
  93. package/dist/owletto/dist/assets/entity-options-ErxYvMDH.js +1 -0
  94. package/dist/owletto/dist/assets/entity-page-CYRAwUGO.js +1 -0
  95. package/dist/owletto/dist/assets/entity-type-page-BlAizGlz.js +1 -0
  96. package/dist/owletto/dist/assets/event-page-DTXPxc-E.js +1 -0
  97. package/dist/owletto/dist/assets/events-feed-L3c-LLiJ.js +1 -0
  98. package/dist/owletto/dist/assets/{full-page-spinner-DTSqneUO.js → full-page-spinner-BxcYpJXx.js} +1 -1
  99. package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +1 -0
  100. package/dist/owletto/dist/assets/identity-B8lKn0je.js +1 -0
  101. package/dist/owletto/dist/assets/{index-jGZeANLE.js → index--lEHrFE4.js} +1 -1
  102. package/dist/owletto/dist/assets/{index-CMOHHdFH.js → index-13rywWam.js} +1 -1
  103. package/dist/owletto/dist/assets/{index-Bq4m-sK0.js → index-BRvT0VV9.js} +1 -1
  104. package/dist/owletto/dist/assets/index-BUp24ZJr.js +1 -0
  105. package/dist/owletto/dist/assets/index-B_-MLsof.js +1 -0
  106. package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +1 -0
  107. package/dist/owletto/dist/assets/index-C8CR2-Ck.css +1 -0
  108. package/dist/owletto/dist/assets/{index-OUb5Mlez.js → index-CDz3-ieP.js} +10 -10
  109. package/dist/owletto/dist/assets/index-CFkj9iR_.js +1 -0
  110. package/dist/owletto/dist/assets/index-CgBgOElA.js +1 -0
  111. package/dist/owletto/dist/assets/{index-DkKALC2l.js → index-CheCJomo.js} +1 -1
  112. package/dist/owletto/dist/assets/index-CpiW66xK.js +1 -0
  113. package/dist/owletto/dist/assets/index-DAv5S2aK.js +1 -0
  114. package/dist/owletto/dist/assets/index-DBi2Xr3i.js +1 -0
  115. package/dist/owletto/dist/assets/index-DHOha5OJ.js +1 -0
  116. package/dist/owletto/dist/assets/index-DdGjY1Hb.js +7898 -0
  117. package/dist/owletto/dist/assets/index-Dkyl7l6E.js +1 -0
  118. package/dist/owletto/dist/assets/{index-DYe_DVHa.js → index-QcHQZI87.js} +1 -1
  119. package/dist/owletto/dist/assets/index-kq4537-S.js +1 -0
  120. package/dist/owletto/dist/assets/{json-diff-CANZD4MQ.js → json-diff-BV2STDGj.js} +2 -2
  121. package/dist/owletto/dist/assets/{list-skeleton-DZTUxpBx.js → list-skeleton-CT5n4ND_.js} +1 -1
  122. package/dist/owletto/dist/assets/login-DKsgABYt.js +1 -0
  123. package/dist/owletto/dist/assets/logout-D_CP-emw.js +1 -0
  124. package/dist/owletto/dist/assets/member-scope-gate-BTgmlfFJ.js +1 -0
  125. package/dist/owletto/dist/assets/memory-browse-page-FHaJC3ML.js +101 -0
  126. package/dist/owletto/dist/assets/missing-view-Bve6pJP-.js +1 -0
  127. package/dist/owletto/dist/assets/{model-selector-CvU3VP90.js → model-selector-BLCEahny.js} +1 -1
  128. package/dist/owletto/dist/assets/models-C4N7LQAW.js +1 -0
  129. package/dist/owletto/dist/assets/new-BAIGSdfp.js +1 -0
  130. package/dist/owletto/dist/assets/{new-DIjOVXrQ.js → new-CirOK0Sw.js} +1 -1
  131. package/dist/owletto/dist/assets/new-DzapH2sV.js +1 -0
  132. package/dist/owletto/dist/assets/{oauth-workspace-access-DWfiekRz.js → oauth-workspace-access-BF7jaswv.js} +1 -1
  133. package/dist/owletto/dist/assets/{organization-DHEC7kDq.js → organization-D9RPsWG-.js} +1 -1
  134. package/dist/owletto/dist/assets/{permissions-i7iwnE1a.js → permissions-BlRONw-u.js} +1 -1
  135. package/dist/owletto/dist/assets/{proposal-review-shell-C_LcyUEF.js → proposal-review-shell-uskeFIUr.js} +1 -1
  136. package/dist/owletto/dist/assets/{recent-By19_Buq.js → recent-CmJ4Is6V.js} +1 -1
  137. package/dist/owletto/dist/assets/{renderer-B1UThnk2.js → renderer-Dyf4t8kR.js} +2 -2
  138. package/dist/owletto/dist/assets/{reset-password-Dsz5-Xeo.js → reset-password-BVIeE1Zm.js} +1 -1
  139. package/dist/owletto/dist/assets/runs-CzBeUzlQ.js +1 -0
  140. package/dist/owletto/dist/assets/{runs-panel-wkV1aGD9.js → runs-panel-D7l1uLGm.js} +1 -1
  141. package/dist/owletto/dist/assets/runs-table-dATyiBg2.js +1 -0
  142. package/dist/owletto/dist/assets/{schema-value-normalization--DhnhJNf.js → schema-value-normalization-DgMkyVVE.js} +1 -1
  143. package/dist/owletto/dist/assets/settings-BK1GHmzb.js +1 -0
  144. package/dist/owletto/dist/assets/{settings-Bu239SXe.js → settings-Co1wj_m6.js} +1 -1
  145. package/dist/owletto/dist/assets/skills-DF53JcYt.js +1 -0
  146. package/dist/owletto/dist/assets/{switch-CCKllS7w.js → switch-DDkPrV3p.js} +1 -1
  147. package/dist/owletto/dist/assets/use-applied-views-DELwQQh7.js +1 -0
  148. package/dist/owletto/dist/assets/{use-mention-search-CldNZTiT.js → use-mention-search-CGA3AaKm.js} +1 -1
  149. package/dist/owletto/dist/assets/view-frame-DDr-Xtet.js +1 -0
  150. package/dist/owletto/dist/index.html +2 -2
  151. package/dist/server-main.bundle.mjs +16460 -12976
  152. package/npm-shrinkwrap.json +593 -559
  153. package/package.json +5 -2
  154. package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
  155. package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
  156. package/vendor/connector-sdk/dist/connector-types.d.ts +28 -13
  157. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
  158. package/vendor/connector-sdk/dist/define-connector.js +4 -1
  159. package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
  160. package/vendor/connector-sdk/dist/http-client.js +15 -13
  161. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  162. package/vendor/connector-sdk/dist/retry.d.ts +15 -3
  163. package/vendor/connector-sdk/dist/retry.js +40 -64
  164. package/vendor/connector-sdk/package.json +1 -1
  165. package/vendor/core/dist/agent-policy.js +3 -0
  166. package/vendor/core/dist/connector-query-errors.d.ts +3 -3
  167. package/vendor/core/dist/connector-query-errors.js +8 -3
  168. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +24 -0
  169. package/vendor/core/dist/contracts/tools/manage-connections.js +13 -0
  170. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +15 -25
  171. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +3 -5
  172. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +11 -0
  173. package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
  174. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
  175. package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
  176. package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
  177. package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
  178. package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
  179. package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
  180. package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
  181. package/vendor/core/dist/contracts/tools/source-files.js +55 -0
  182. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
  183. package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
  184. package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
  185. package/vendor/core/dist/contracts/tools/view-path.js +24 -0
  186. package/vendor/core/dist/contracts/worker/protocol.d.ts +73 -8
  187. package/vendor/core/dist/contracts/worker/protocol.js +58 -9
  188. package/vendor/core/dist/credentials.d.ts +16 -1
  189. package/vendor/core/dist/credentials.js +10 -1
  190. package/vendor/core/dist/reserved.d.ts +3 -3
  191. package/vendor/core/dist/reserved.js +9 -1
  192. package/vendor/core/dist/utils/secret-redaction.js +2 -0
  193. package/vendor/core/package.json +25 -5
  194. package/vendor/views/dist/api.d.ts +179 -0
  195. package/vendor/views/dist/api.js +406 -0
  196. package/vendor/views/dist/bridge.d.ts +141 -0
  197. package/vendor/views/dist/bridge.js +330 -0
  198. package/vendor/views/dist/index.d.ts +12 -0
  199. package/vendor/views/dist/index.js +10 -0
  200. package/vendor/views/package.json +35 -0
  201. package/dist/owletto/dist/assets/_-CfcfHJO8.js +0 -1
  202. package/dist/owletto/dist/assets/_-DdvHIadV.js +0 -2
  203. package/dist/owletto/dist/assets/_agentId-BTmFhpb6.js +0 -1
  204. package/dist/owletto/dist/assets/_agentId-DbTBU4KZ.js +0 -1
  205. package/dist/owletto/dist/assets/_automationId-C7dZzg6X.js +0 -1
  206. package/dist/owletto/dist/assets/_conversationId-F5YmyLV9.js +0 -1
  207. package/dist/owletto/dist/assets/_deploymentId-3LTMi0ZT.js +0 -1
  208. package/dist/owletto/dist/assets/_name-BKeZbc-h.js +0 -1
  209. package/dist/owletto/dist/assets/_owner-DglbbDEx.js +0 -1
  210. package/dist/owletto/dist/assets/_skillKey-DhiGYYFq.js +0 -1
  211. package/dist/owletto/dist/assets/_slug-CnQDfsCE.js +0 -1
  212. package/dist/owletto/dist/assets/accept-invitation-Dgoyublh.js +0 -1
  213. package/dist/owletto/dist/assets/activity-route-view-BNzKO6aD.js +0 -1
  214. package/dist/owletto/dist/assets/agent-thread-DnLUOzXk.js +0 -134
  215. package/dist/owletto/dist/assets/agents-OLmcj-qM.js +0 -1
  216. package/dist/owletto/dist/assets/agents-workbench-BOKifKIO.js +0 -1
  217. package/dist/owletto/dist/assets/automation-detail-content-wJC9hhmA.js +0 -1
  218. package/dist/owletto/dist/assets/automations-OLmcj-qM.js +0 -1
  219. package/dist/owletto/dist/assets/clients-R4JsT_Fz.js +0 -1
  220. package/dist/owletto/dist/assets/connect-1ysEq9l0.js +0 -1
  221. package/dist/owletto/dist/assets/connect._clientId-BbMPs6l3.js +0 -1
  222. package/dist/owletto/dist/assets/connected._clientId-ByH4etku.js +0 -1
  223. package/dist/owletto/dist/assets/create-C37QtjbJ.js +0 -1
  224. package/dist/owletto/dist/assets/create-automation-form-Cv2RHsQ6.js +0 -1
  225. package/dist/owletto/dist/assets/create-kAQa5_Q7.js +0 -1
  226. package/dist/owletto/dist/assets/deployments-C5kSeowq.js +0 -1
  227. package/dist/owletto/dist/assets/deployments-body-BPCALbQe.js +0 -1
  228. package/dist/owletto/dist/assets/device-DToHXxDM.js +0 -1
  229. package/dist/owletto/dist/assets/device-rows-fVm-zAiU.js +0 -1
  230. package/dist/owletto/dist/assets/entity-options-DOGD_EyZ.js +0 -1
  231. package/dist/owletto/dist/assets/entity-page-C8oDszRY.js +0 -1
  232. package/dist/owletto/dist/assets/entity-type-page-BfxIgJLq.js +0 -1
  233. package/dist/owletto/dist/assets/events-feed-B9OqmSBy.js +0 -1
  234. package/dist/owletto/dist/assets/guardrails-9Mr6avxk.js +0 -1
  235. package/dist/owletto/dist/assets/identity-DMfCjdBz.js +0 -1
  236. package/dist/owletto/dist/assets/index-Bfux0kHb.js +0 -7898
  237. package/dist/owletto/dist/assets/index-CK2-iHcz.js +0 -1
  238. package/dist/owletto/dist/assets/index-COgBJ_ab.js +0 -1
  239. package/dist/owletto/dist/assets/index-ChcQMdod.css +0 -1
  240. package/dist/owletto/dist/assets/index-CkwwaMrx.js +0 -1
  241. package/dist/owletto/dist/assets/index-D0lZrXrY.js +0 -1
  242. package/dist/owletto/dist/assets/index-DZadnZpq.js +0 -1
  243. package/dist/owletto/dist/assets/index-DcWyuLQS.js +0 -1
  244. package/dist/owletto/dist/assets/index-DlqjyZKQ.js +0 -1
  245. package/dist/owletto/dist/assets/index-Dv0huHrO.js +0 -1
  246. package/dist/owletto/dist/assets/index-DxIDxgPJ.js +0 -1
  247. package/dist/owletto/dist/assets/index-bKUccXCc.js +0 -1
  248. package/dist/owletto/dist/assets/login-D53geSP7.js +0 -1
  249. package/dist/owletto/dist/assets/logout-DKQS25qd.js +0 -1
  250. package/dist/owletto/dist/assets/member-scope-gate-C4QyRm2Q.js +0 -1
  251. package/dist/owletto/dist/assets/memory-browse-page-DOpV3vht.js +0 -101
  252. package/dist/owletto/dist/assets/models-ooBIWFuB.js +0 -1
  253. package/dist/owletto/dist/assets/new-B8_sRMYD.js +0 -1
  254. package/dist/owletto/dist/assets/new-Df1q7GEj.js +0 -1
  255. package/dist/owletto/dist/assets/runs-BQ11PAQT.js +0 -1
  256. package/dist/owletto/dist/assets/runs-table-DzSWYkaf.js +0 -1
  257. package/dist/owletto/dist/assets/settings-FxbIvOhH.js +0 -1
  258. package/dist/owletto/dist/assets/skills-MBZ5ilDK.js +0 -1
  259. package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
  260. package/vendor/core/dist/contracts/tools/manage-view-templates.js +0 -130
@@ -4,6 +4,6 @@
4
4
  "server": "dist/server.bundle.mjs",
5
5
  "embeddingsServer": "dist/embeddings-server.mjs"
6
6
  },
7
- "version": "20.1.0",
7
+ "version": "21.0.0",
8
8
  "verify": "dist/verify.mjs"
9
9
  }
@@ -44,11 +44,8 @@ export default defineConnector({
44
44
  // Fetch data, transform to events...
45
45
  const events: EventEnvelope[] = [];
46
46
 
47
- return {
48
- events,
49
- checkpoint: { last_sync_at: new Date().toISOString() },
50
- metadata: { query, items_found: events.length },
51
- };
47
+ await ctx.commit(events, { last_sync_at: new Date().toISOString() });
48
+ return { status: 'complete', metadata: { query, items_found: events.length } };
52
49
  },
53
50
  },
54
51
  },
@@ -234,10 +231,11 @@ feeds: {
234
231
  issue: { description: 'An issue changed' },
235
232
  },
236
233
  // Incremental materialization for local search and Automations.
237
- sync: async (ctx) => ({
238
- events: await fetchChangedIssues(ctx.config.project, ctx.checkpoint),
239
- checkpoint: { synced_at: new Date().toISOString() },
240
- }),
234
+ sync: async (ctx) => {
235
+ const events = await fetchChangedIssues(ctx.config.project, ctx.checkpoint);
236
+ await ctx.commit(events, { synced_at: new Date().toISOString() });
237
+ return { status: 'complete' };
238
+ },
241
239
  // Direct source read with native filtering and pagination.
242
240
  read: async (ctx) => {
243
241
  const page = await queryIssues({
@@ -258,7 +256,8 @@ A feed's `eventKinds` are also the **default Automation trigger catalog**. The f
258
256
 
259
257
  The worker calls the selected feed's `sync` handler for scheduled,
260
258
  webhook-triggered, and manually triggered sync runs. It receives a `SyncContext`
261
- and returns a `SyncResult`.
259
+ stores events through `ctx.commit`, and returns a `SyncResult` saying whether
260
+ the source is caught up.
262
261
 
263
262
  ### SyncContext
264
263
 
@@ -271,8 +270,9 @@ interface SyncContext {
271
270
  credentials: SyncCredentials | null; // OAuth/session credentials; env_keys are in config
272
271
  entityIds: number[]; // Linked entity IDs
273
272
  sessionState?: Record<string, unknown>; // Browser session state (cookies, tokens)
274
- emitEvents?: (events: EventEnvelope[]) => Promise<void>; // Stream events mid-sync
275
- updateCheckpoint?: (cp: Record<string, unknown>) => Promise<void>; // Save progress mid-sync
273
+ // Store a page, then move its checkpoint; resolves once both are durable.
274
+ // `null` stores the events and leaves the checkpoint where it is.
275
+ commit: (events: EventEnvelope[], checkpoint: Record<string, unknown> | null) => Promise<void>;
276
276
  }
277
277
  ```
278
278
 
@@ -280,8 +280,7 @@ interface SyncContext {
280
280
 
281
281
  ```typescript
282
282
  interface SyncResult {
283
- events: EventEnvelope[]; // Events to ingest
284
- checkpoint: Record<string, unknown> | null; // Updated checkpoint to persist
283
+ status: 'complete' | 'more'; // Caught up, or stopped early with work left (reruns now)
285
284
  auth_update?: Record<string, unknown>; // Updated session state (browser cookies, etc.)
286
285
  metadata?: {
287
286
  items_found?: number;
@@ -320,7 +319,7 @@ Use checkpoints to implement incremental sync. Common patterns:
320
319
  - **Timestamp-based**: Store `last_sync_at` and use it as a `since` filter on the next sync (see `github.ts`)
321
320
  - **ID-based**: Store a list of seen IDs for deduplication, trimmed to a max size to prevent unbounded growth (see `rss.ts`)
322
321
 
323
- For long-running syncs, use `ctx.emitEvents()` to stream event batches to the platform as they're collected, and `ctx.updateCheckpoint()` to persist progress. If the sync crashes mid-way, the next run resumes from the last saved checkpoint.
322
+ Commit as you go: call `await ctx.commit(events, checkpoint)` once per source page, with the checkpoint that resumes after that page, and await it before fetching the next. A large commit may be transported in chunks, but its checkpoint moves only with the final chunk; if the run is killed or crashes mid-way, replay may supersede already-stored events, and no checkpoint ever covers events that were not stored. A pass that stops early at a budget (pages, rows, time) returns `{ status: 'more' }` so the next run starts immediately; `more` is only honored when the pass moved the checkpoint, so a pass that makes no progress falls back to the schedule instead of looping.
324
323
 
325
324
  ## Reading from the Source
326
325
 
@@ -527,7 +526,7 @@ Connectors can also be installed manually via `client.connections.installConnect
527
526
 
528
527
  1. For fleet workers and embedded-mode hosts (worker + gateway share a host), the gateway sends only `connector_key` in the worker-poll response — both runtimes have the `.ts` source on disk, and the worker compiles locally via the shared pipeline at `@lobu/connector-worker/compile`. For DB-only / device workers without source on disk, the gateway sends `compiled_code` inline.
529
528
  2. The bundle is self-contained — the SDK and every pure-JS dependency are inlined — and is evaluated inside a V8 isolate in the worker process. The isolate has no module loader, so a bundle that still `require()`s a Node builtin is rejected before it runs.
530
- 3. Host and guest speak the SDK shapes (`SyncContext` / `ActionContext` / `AuthContext` in, `SyncResult` / `ActionResult` / `AuthResult` out, no envelope) across named host capabilities. Sync events stream up as the connector emits them.
529
+ 3. Host and guest speak the SDK shapes (`SyncContext` / `ActionContext` / `AuthContext` in, `SyncResult` / `ActionResult` / `AuthResult` out, no envelope) across named host capabilities. Sync pages and their checkpoints cross the `ctx.commit` capability together.
531
530
  4. `IsolateExecutor` defaults to a 10-minute wall clock and a 512 MB heap for every run; interactive auth runs disable the fixed timeout while waiting for the user.
532
531
  5. The guest has no filesystem, no ambient environment, and no socket of its own: everything it can reach is a named capability the host granted — `fetch` and, for the DB connectors, a host-dialled TCP socket — plus the explicit values supplied in `job.env`.
533
532
  6. Connection credentials and config flow through the typed job context (`ctx.credentials`, `ctx.config`, or auth's `previousCredentials`). The worker API token is never forwarded to connector code. `ctx.credentials.accessToken` is a per-run placeholder the host resolves at the wire (see "`oauth` - OAuth providers" above); `ctx.config` and `previousCredentials` still carry real values.
@@ -18,6 +18,18 @@
18
18
  * these links authorize approvals and agent re-binding.
19
19
  */
20
20
 
21
+ /**
22
+ * How a platform's stored user keys are scoped for a reverse lookup.
23
+ *
24
+ * `team-prefix` — keys for one tenant all begin with `prefix`, so a search must
25
+ * be constrained to it (Slack: `T0XYZ:`).
26
+ * `global` — ids are unique platform-wide, so the namespace needs no narrowing
27
+ * (Google: one account can only ever have one id).
28
+ */
29
+ export type ChatUserKeyScope =
30
+ | { kind: 'team-prefix'; prefix: string }
31
+ | { kind: 'global' };
32
+
21
33
  /** How one chat platform keys a sender identity. */
22
34
  export interface ChatUserIdentity {
23
35
  /** Chat platform key an inbound message arrives on (`slack`, `gchat`, …). */
@@ -42,4 +54,33 @@ export interface ChatUserIdentity {
42
54
  teamId: string | null | undefined,
43
55
  platformUserId: string | null | undefined,
44
56
  ): string | null;
57
+
58
+ /**
59
+ * The REVERSE of `buildUserKey`, for "which platform id does this Lobu user
60
+ * have here?": how stored keys are scoped when searching within `teamId`.
61
+ *
62
+ * Required, not optional, and deliberately NOT a bare nullable string. The
63
+ * two failure shapes must not collapse into one value: `global` means the
64
+ * platform has no tenant axis so the whole namespace is in scope, while null
65
+ * means this platform REQUIRES a team and did not get a usable one. A caller
66
+ * that treats those alike widens a Slack search past its `TEAM:` prefix and
67
+ * can return an id from a DIFFERENT workspace — the exact cross-tenant bleed
68
+ * `buildUserKey` exists to prevent. Callers must refuse on null.
69
+ */
70
+ userKeyScope(teamId: string | null | undefined): ChatUserKeyScope | null;
71
+
72
+ /**
73
+ * Recover from a stored key the id the PLATFORM addresses this user by — the
74
+ * form its API takes (`openDM`, a mention), which is also the form
75
+ * `buildUserKey` accepts back.
76
+ *
77
+ * NOT "the key minus its scope prefix". Google stores the bare account id but
78
+ * addresses `users/<id>`, and the chat SDK routes a DM by inferring the
79
+ * adapter from exactly that prefix, so a bare id does not reach Google Chat
80
+ * at all. Each platform owns the difference; core must never re-derive it.
81
+ *
82
+ * Returns null when the stored key is not one this platform could have
83
+ * written — fail closed rather than address a malformed id.
84
+ */
85
+ platformUserIdFromKey(key: string): string | null;
45
86
  }
@@ -905,12 +905,13 @@ export default class GitHubConnector extends ConnectorRuntime {
905
905
  if (contentType === 'stargazers') {
906
906
  const result = await this.syncStargazers(repo, ctx.checkpoint, token);
907
907
  this.stampRepoAttribution(result.events, repo, { attachAutomationSignals });
908
+ // One commit: removed stargazers are only known against the full snapshot.
909
+ await ctx.commit(result.events, {
910
+ last_sync_at: new Date().toISOString(),
911
+ stargazers: result.currentStargazers,
912
+ } as Record<string, unknown>);
908
913
  return {
909
- events: result.events,
910
- checkpoint: {
911
- last_sync_at: new Date().toISOString(),
912
- stargazers: result.currentStargazers,
913
- } as Record<string, unknown>,
914
+ status: 'complete',
914
915
  metadata: {
915
916
  items_found: result.events.length,
916
917
  current_stargazers: result.currentStargazers.length,
@@ -927,11 +928,11 @@ export default class GitHubConnector extends ConnectorRuntime {
927
928
  });
928
929
  this.stampRepoAttribution(events, repo, { attachAutomationSignals });
929
930
 
931
+ await ctx.commit(events, {
932
+ last_sync_at: new Date().toISOString(),
933
+ } as Record<string, unknown>);
930
934
  return {
931
- events,
932
- checkpoint: {
933
- last_sync_at: new Date().toISOString(),
934
- } as Record<string, unknown>,
935
+ status: 'complete',
935
936
  metadata: {
936
937
  items_found: events.length,
937
938
  },
@@ -2090,6 +2091,9 @@ export default class GitHubConnector extends ConnectorRuntime {
2090
2091
  query: params.query,
2091
2092
  variables: params.variables ?? {},
2092
2093
  },
2094
+ // Every caller sends a query (discussion reads), which is safe to repeat
2095
+ // on a 5xx even though it goes out as POST. A mutation must not set this.
2096
+ idempotent: true,
2093
2097
  });
2094
2098
  }
2095
2099
 
@@ -2101,6 +2105,7 @@ export default class GitHubConnector extends ConnectorRuntime {
2101
2105
  token: string | null;
2102
2106
  body?: Record<string, unknown>;
2103
2107
  accept?: string;
2108
+ idempotent?: boolean;
2104
2109
  }): Promise<T> {
2105
2110
  const headers: Record<string, string> = {
2106
2111
  Accept: params.accept ?? 'application/vnd.github+json',
@@ -2115,6 +2120,7 @@ export default class GitHubConnector extends ConnectorRuntime {
2115
2120
  method: params.method ?? 'GET',
2116
2121
  headers,
2117
2122
  body: params.body ? JSON.stringify(params.body) : undefined,
2123
+ idempotent: params.idempotent,
2118
2124
  });
2119
2125
  }
2120
2126
  }
@@ -104,4 +104,15 @@ export const gchatChatUserIdentity: ChatUserIdentity = {
104
104
  buildUserKey(_teamId, platformUserId) {
105
105
  return normalizeGoogleUserId(platformUserId);
106
106
  },
107
+ // Global for the same reason `buildUserKey` ignores the team: one Google
108
+ // account has exactly one id, so there is no tenant axis to narrow by and
109
+ // nothing to bleed across. Never null — a missing team is not an error here.
110
+ userKeyScope: () => ({ kind: 'global' }),
111
+ // Re-wraps the bare stored id as the resource name Chat addresses people by.
112
+ // The `users/` prefix is load-bearing on the way out as well as in: the chat
113
+ // SDK picks the Google Chat adapter off it, so a bare id is not routable.
114
+ platformUserIdFromKey(key) {
115
+ const bare = normalizeGoogleUserId(key);
116
+ return bare ? `${GCHAT_USER_PREFIX}${bare}` : null;
117
+ },
107
118
  };
@@ -457,7 +457,6 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
457
457
  const lookbackDays = (ctx.config.lookback_days as number) ?? 30;
458
458
 
459
459
  const checkpoint = (ctx.checkpoint ?? {}) as CalendarCheckpoint;
460
- const events: EventEnvelope[] = [];
461
460
  const durableChanges = ctx.feedKey === 'changes';
462
461
 
463
462
  // A checkpoint minted under a different scope (or by an older version that
@@ -467,10 +466,13 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
467
466
  const scope = JSON.stringify([CHECKPOINT_SCOPE_VERSION, calendarId, lookbackDays]);
468
467
  const resumable = checkpoint.scope === scope;
469
468
 
470
- /** Traversal reached the last page: store its cursor and stamp the run. */
471
- const finish = (items: EventEnvelope[], syncToken?: string): SyncResult => {
472
- const result = this.buildResult(items, syncToken);
473
- return { ...result, checkpoint: { ...result.checkpoint, scope } };
469
+ /** Traversal reached the last page: commit it with its cursor and stamp the run. */
470
+ const finish = async (items: EventEnvelope[], syncToken?: string): Promise<SyncResult> => {
471
+ await ctx.commit(items, {
472
+ ...this.completedCheckpoint(syncToken),
473
+ scope,
474
+ } as Record<string, unknown>);
475
+ return { status: 'complete' };
474
476
  };
475
477
 
476
478
  if (resumable && checkpoint.sync_token) {
@@ -517,15 +519,14 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
517
519
  const baseParams = params.toString();
518
520
 
519
521
  /**
520
- * Ran out of budget mid-traversal: park the next page token and return no
521
- * sync token and no `last_sync_at`, so nothing downstream can read this run
522
- * as a completed window. The next scheduled run resumes from `token`.
522
+ * Mid-traversal: the next page token, with no sync token and no
523
+ * `last_sync_at`, so nothing downstream can read it as a completed window.
524
+ * A run that stops here resumes from `token`.
523
525
  */
524
- const park = (token: string): SyncResult => ({
525
- ...this.buildResult(events, undefined),
526
- checkpoint: { scope, pending: { params: baseParams, page_token: token } },
527
- });
526
+ const parked = (token: string) =>
527
+ ({ scope, pending: { params: baseParams, page_token: token } }) as Record<string, unknown>;
528
528
 
529
+ let collected = 0;
529
530
  let pageToken = pending?.page_token;
530
531
  const seenTokens = new Set<string>();
531
532
  for (let page = 0; ; page++) {
@@ -549,6 +550,7 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
549
550
  // A provider page is atomic: `max_results` caps how much a run starts,
550
551
  // never how much of a fetched page is stored. Dropping a page's tail
551
552
  // would lose those events for good once the cursor moved past them.
553
+ const events: EventEnvelope[] = [];
552
554
  for (const calEvent of items) {
553
555
  const envelope = durableChanges
554
556
  ? this.calendarEventToChangeEnvelope(calEvent)
@@ -570,17 +572,19 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
570
572
  throw new Error('Google Calendar returned a repeated page token.');
571
573
  }
572
574
  pageToken = data.nextPageToken;
575
+ await ctx.commit(events, parked(pageToken));
576
+ collected += events.length;
573
577
 
574
578
  // Stop once this run has collected its share, once the provider returns
575
579
  // an empty page, or at the hard ceiling — the last of which is the only
576
580
  // bound on a window of nothing but filtered-out items, where
577
- // `events.length` never reaches the cap.
581
+ // `collected` never reaches the cap. The traversal continues next run.
578
582
  if (
579
- events.length >= maxResults ||
583
+ collected >= maxResults ||
580
584
  items.length === 0 ||
581
585
  page + 1 >= MAX_SYNC_PAGES
582
586
  ) {
583
- return park(pageToken);
587
+ return { status: 'more' };
584
588
  }
585
589
  }
586
590
  }
@@ -985,29 +989,15 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
985
989
  };
986
990
  }
987
991
 
988
- private buildResult(
989
- events: EventEnvelope[],
990
- syncToken: string | undefined
991
- ): SyncResult {
992
- // Sort events by occurred_at descending
993
- events.sort((a, b) => b.occurred_at.getTime() - a.occurred_at.getTime());
994
-
992
+ private completedCheckpoint(syncToken: string | undefined): CalendarCheckpoint {
995
993
  // Built fresh rather than spread over the previous checkpoint: the whole
996
994
  // object replaces the stored one, so a run that recovered from a rejected
997
995
  // token cannot leave that token behind. When the sync produced no new token
998
996
  // the key is absent, and the next run correctly starts from a full sync.
999
- const newCheckpoint: CalendarCheckpoint = {
997
+ return {
1000
998
  ...(syncToken ? { sync_token: syncToken } : {}),
1001
999
  last_sync_at: new Date().toISOString(),
1002
1000
  };
1003
-
1004
- return {
1005
- events,
1006
- checkpoint: newCheckpoint as Record<string, unknown>,
1007
- metadata: {
1008
- items_found: events.length,
1009
- },
1010
- };
1011
1001
  }
1012
1002
 
1013
1003
  // Auth-aware client (Bearer + retry/backoff on transient 429/5xx). Built per
@@ -286,6 +286,27 @@ function buildListQuery(config: DriveConfig): string {
286
286
  // Connector
287
287
  // ---------------------------------------------------------------------------
288
288
 
289
+ type DriveCommit = (events: EventEnvelope[], checkpoint: DriveCheckpoint) => Promise<void>;
290
+
291
+ /**
292
+ * Checkpoint for a bootstrap with list pages still unread.
293
+ *
294
+ * `page_token` is deliberately absent: while it is missing the feed cannot go
295
+ * incremental, which is exactly the property that keeps the unread files
296
+ * reachable.
297
+ */
298
+ function bootstrapCheckpoint(
299
+ pendingPageToken: string,
300
+ listPageToken: string,
301
+ startedAt: string
302
+ ): DriveCheckpoint {
303
+ return {
304
+ pending_page_token: pendingPageToken,
305
+ list_page_token: listPageToken,
306
+ last_sync_at: startedAt,
307
+ };
308
+ }
309
+
289
310
  export default class GoogleDriveConnector extends ConnectorRuntime<
290
311
  Record<string, unknown>,
291
312
  DriveConfig
@@ -493,8 +514,11 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
493
514
 
494
515
  // An unfinished bootstrap outranks everything: going incremental with pages
495
516
  // still unread would strand every file the traversal never reached.
517
+ const commit = (events: EventEnvelope[], next: DriveCheckpoint) =>
518
+ ctx.commit(events, next as Record<string, unknown>);
519
+
496
520
  if (checkpoint.list_page_token && checkpoint.pending_page_token) {
497
- return this.fullSync(http, config, {
521
+ return this.fullSync(http, config, commit, {
498
522
  startToken: checkpoint.pending_page_token,
499
523
  listPageToken: checkpoint.list_page_token,
500
524
  startedAt: checkpoint.last_sync_at,
@@ -506,25 +530,15 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
506
530
  http,
507
531
  checkpoint.page_token,
508
532
  config,
533
+ commit,
509
534
  checkpoint.last_sync_at
510
535
  );
511
- if (result) {
512
- // A partial run must NOT advance `last_sync_at`. The view-churn guard
513
- // skips content for files modified before that stamp, so stamping now
514
- // would make the next run treat the unread backlog as already-stored
515
- // and drop its content on the floor.
516
- return this.buildResult(
517
- result.events,
518
- result.nextPageToken,
519
- result.partial ? checkpoint.last_sync_at : undefined,
520
- { changesPending: result.partial }
521
- );
522
- }
536
+ if (result) return result;
523
537
  // Token rejected (see isPageTokenRejection). Fall through to ONE full
524
538
  // re-list, exactly as the Calendar connector does — never a retry loop.
525
539
  }
526
540
 
527
- return this.fullSync(http, config);
541
+ return this.fullSync(http, config, commit);
528
542
  }
529
543
 
530
544
  /**
@@ -539,6 +553,7 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
539
553
  private async fullSync(
540
554
  http: HttpClient,
541
555
  config: DriveConfig,
556
+ commit: DriveCommit,
542
557
  resume?: { startToken: string; listPageToken: string; startedAt?: string }
543
558
  ): Promise<SyncResult> {
544
559
  // A resumed bootstrap keeps the token minted when the traversal STARTED —
@@ -555,7 +570,7 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
555
570
  const maxResults = Math.min(config.max_results ?? 500, 2000);
556
571
  const includeContent = config.include_content !== false;
557
572
  const q = buildListQuery(config);
558
- const events: EventEnvelope[] = [];
573
+ let collected = 0;
559
574
 
560
575
  // 1000 is Drive's max pageSize, so 200 pages is 200k files — far past any
561
576
  // configurable max_results. Defensive bound against a self-referential
@@ -605,43 +620,53 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
605
620
  { maxPages: MAX_PAGES, initialCursor: resume?.listPageToken ?? null }
606
621
  );
607
622
 
623
+ // A Drive `q` has no equivalent on `changes.list` and cannot be re-evaluated
624
+ // client-side against a change record, so the only way to keep honouring it
625
+ // is to keep listing. Withholding the token re-lists next run; promoting it
626
+ // would silently widen the feed to every changed file in the Drive.
627
+ const hasCustomQuery = typeof config.query === 'string' && config.query.trim() !== '';
628
+
608
629
  const deadline = this.now() + SYNC_TIME_BUDGET_MS;
609
630
  for await (const items of pages) {
631
+ const events: EventEnvelope[] = [];
610
632
  for (const file of items) {
611
633
  events.push(await this.driveFileToEnvelope(http, file, includeContent, 'upserted'));
612
634
  }
613
- // Tested only BETWEEN pages: a page is consumed whole or not at all, so
614
- // `nextListPageToken` always addresses the first file we have not read.
615
- // Stopping on the clock parks a checkpoint; being killed on it does not.
616
- if (events.length >= maxResults || this.now() >= deadline) break;
617
- }
618
-
619
- // Unread pages mean the bootstrap is unfinished, and WHY it stopped is
620
- // irrelevant: the item cap, the clock, and the paginator's own MAX_PAGES
621
- // ceiling all leave files the change feed will never replay. Only Drive
622
- // withholding a nextPageToken proves the traversal exhausted, so that —
623
- // not the reason for stopping — is what may promote the change token.
624
- if (nextListPageToken) {
625
- return this.buildBootstrapResult(
626
- events,
627
- startToken,
628
- nextListPageToken,
629
- bootstrapStartedAt,
630
- searchIncomplete
631
- );
635
+ collected += events.length;
636
+ // Only Drive withholding a nextPageToken proves the traversal exhausted,
637
+ // so that — not the reason a run stops — is what may promote the change
638
+ // token. Until then each page commits with the bootstrap parked on the
639
+ // next unread page: a page is consumed whole or not at all, so the list
640
+ // token always addresses the first file not yet stored.
641
+ if (!nextListPageToken) {
642
+ await commit(events, {
643
+ ...(hasCustomQuery ? {} : { page_token: startToken }),
644
+ last_sync_at: bootstrapStartedAt,
645
+ });
646
+ return {
647
+ status: 'complete',
648
+ metadata: {
649
+ items_found: collected,
650
+ bootstrap_complete: true,
651
+ ...(searchIncomplete ? { search_incomplete: true } : {}),
652
+ },
653
+ };
654
+ }
655
+ await commit(events, bootstrapCheckpoint(startToken, nextListPageToken, bootstrapStartedAt));
656
+ if (collected >= maxResults || this.now() >= deadline) break;
632
657
  }
633
658
 
634
- // A Drive `q` has no equivalent on `changes.list` and cannot be re-evaluated
635
- // client-side against a change record, so the only way to keep honouring it
636
- // is to keep listing. Withholding the token re-lists next run; promoting it
637
- // would silently widen the feed to every changed file in the Drive.
638
- const hasCustomQuery = typeof config.query === 'string' && config.query.trim() !== '';
639
- return this.buildResult(
640
- events,
641
- hasCustomQuery ? undefined : startToken,
642
- bootstrapStartedAt,
643
- { searchIncomplete }
644
- );
659
+ // Unread pages remain, and WHY this run stopped is irrelevant: the item
660
+ // cap, the clock, and the paginator's own MAX_PAGES ceiling all leave files
661
+ // the change feed will never replay. The bootstrap resumes next run.
662
+ return {
663
+ status: 'more',
664
+ metadata: {
665
+ items_found: collected,
666
+ bootstrap_complete: false,
667
+ ...(searchIncomplete ? { search_incomplete: true } : {}),
668
+ },
669
+ };
645
670
  }
646
671
 
647
672
  /**
@@ -654,12 +679,9 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
654
679
  http: HttpClient,
655
680
  pageToken: string,
656
681
  config: DriveConfig,
682
+ commit: DriveCommit,
657
683
  lastSyncAt?: string
658
- ): Promise<{
659
- events: EventEnvelope[];
660
- nextPageToken?: string;
661
- partial: boolean;
662
- } | null> {
684
+ ): Promise<SyncResult | null> {
663
685
  const includeContent = config.include_content !== false;
664
686
  const includeTrashed = Boolean(config.include_trashed);
665
687
  const folderId =
@@ -667,7 +689,7 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
667
689
  ? config.folder_id.trim()
668
690
  : undefined;
669
691
  const maxResults = Math.min(config.max_results ?? 500, 2000);
670
- const events: EventEnvelope[] = [];
692
+ let collected = 0;
671
693
  let nextPageToken: string | undefined;
672
694
  // The cursor for the page AFTER the one just consumed. A run that stops
673
695
  // early persists this instead of dropping back to a full re-list — a
@@ -718,8 +740,9 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
718
740
  // start of the next page, so stopping part-way through one would skip the
719
741
  // changes still in it.
720
742
  const deadline = this.now() + SYNC_TIME_BUDGET_MS;
721
- let stoppedEarly = false;
722
743
  for await (const items of pages) {
744
+ if (rejected) return null;
745
+ const events: EventEnvelope[] = [];
723
746
  for (const change of items) {
724
747
  const envelope = await this.changeToEnvelope(
725
748
  http,
@@ -731,25 +754,41 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
731
754
  );
732
755
  if (envelope) events.push(envelope);
733
756
  }
734
- if (rejected) break;
735
- if ((events.length >= maxResults || this.now() >= deadline) && resumeCursor) {
736
- stoppedEarly = true;
737
- break;
757
+ collected += events.length;
758
+ if (!resumeCursor) {
759
+ // The stream is caught up: the page that carried `newStartPageToken`
760
+ // commits it and stamps the run. Rebuilt rather than spread over the
761
+ // previous checkpoint so a run that recovered from a rejected token
762
+ // cannot leave that token behind; without a new token the key is
763
+ // absent and the next run correctly re-lists.
764
+ await commit(events, {
765
+ ...(nextPageToken ? { page_token: nextPageToken } : {}),
766
+ last_sync_at: new Date().toISOString(),
767
+ });
768
+ return {
769
+ status: 'complete',
770
+ metadata: { items_found: collected, bootstrap_complete: true },
771
+ };
738
772
  }
773
+ // Mid-stream: commit with the cursor of the next page, a resumable
774
+ // position in the change stream. `last_sync_at` does NOT advance — the
775
+ // view-churn guard skips content for files modified before that stamp,
776
+ // so stamping now would make the next run treat the unread backlog as
777
+ // already stored and drop its content on the floor.
778
+ await commit(events, {
779
+ page_token: resumeCursor,
780
+ ...(lastSyncAt ? { last_sync_at: lastSyncAt } : {}),
781
+ });
782
+ if (collected >= maxResults || this.now() >= deadline) break;
739
783
  }
740
-
741
784
  if (rejected) return null;
742
785
 
743
- // Either we stopped on the cap, or the paginator ran out of pages with the
744
- // stream still open (MAX_PAGES). Both leave changes unread, and both must
745
- // hand back the cursor: discarding it would silently demote the next run to
746
- // a full re-list and restart the whole bootstrap.
747
- const unread = stoppedEarly || (!nextPageToken && Boolean(resumeCursor));
748
- if (unread && resumeCursor) {
749
- return { events, nextPageToken: resumeCursor, partial: true };
750
- }
751
-
752
- return { events, nextPageToken, partial: false };
786
+ // Stopped on the cap or the clock, or the paginator ran out of pages
787
+ // (MAX_PAGES) with the stream still open. The committed cursor resumes it.
788
+ return {
789
+ status: 'more',
790
+ metadata: { items_found: collected, bootstrap_complete: true, changes_pending: true },
791
+ };
753
792
  }
754
793
 
755
794
  private async fetchStartPageToken(http: HttpClient): Promise<string> {
@@ -1219,70 +1258,6 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
1219
1258
  };
1220
1259
  }
1221
1260
 
1222
- /**
1223
- * Checkpoint for a bootstrap that stopped on `max_results` with pages left.
1224
- *
1225
- * `page_token` is deliberately absent: while it is missing the feed cannot go
1226
- * incremental, which is exactly the property that keeps the unread files
1227
- * reachable. `bootstrap_complete: false` is surfaced in metadata so an
1228
- * operator can see the traversal is still catching up rather than guessing
1229
- * from a suspiciously round item count.
1230
- */
1231
- private buildBootstrapResult(
1232
- events: EventEnvelope[],
1233
- pendingPageToken: string,
1234
- listPageToken: string,
1235
- startedAt: string,
1236
- searchIncomplete = false
1237
- ): SyncResult {
1238
- events.sort((a, b) => b.occurred_at.getTime() - a.occurred_at.getTime());
1239
-
1240
- const checkpoint: DriveCheckpoint = {
1241
- pending_page_token: pendingPageToken,
1242
- list_page_token: listPageToken,
1243
- last_sync_at: startedAt,
1244
- };
1245
-
1246
- return {
1247
- events,
1248
- checkpoint: checkpoint as Record<string, unknown>,
1249
- metadata: {
1250
- items_found: events.length,
1251
- bootstrap_complete: false,
1252
- ...(searchIncomplete ? { search_incomplete: true } : {}),
1253
- },
1254
- };
1255
- }
1256
-
1257
- private buildResult(
1258
- events: EventEnvelope[],
1259
- pageToken: string | undefined,
1260
- /** Stamp to persist as-is; omit to advance `last_sync_at` to now. */
1261
- keepLastSyncAt: string | undefined,
1262
- flags: { changesPending?: boolean; searchIncomplete?: boolean } = {}
1263
- ): SyncResult {
1264
- events.sort((a, b) => b.occurred_at.getTime() - a.occurred_at.getTime());
1265
-
1266
- // Rebuilt rather than spread over the previous checkpoint so a run that
1267
- // recovered from a rejected token cannot leave that token behind. Without a
1268
- // new token the key is absent and the next run correctly re-lists.
1269
- const newCheckpoint: DriveCheckpoint = {
1270
- ...(pageToken ? { page_token: pageToken } : {}),
1271
- last_sync_at: keepLastSyncAt ?? new Date().toISOString(),
1272
- };
1273
-
1274
- return {
1275
- events,
1276
- checkpoint: newCheckpoint as Record<string, unknown>,
1277
- metadata: {
1278
- items_found: events.length,
1279
- bootstrap_complete: true,
1280
- ...(flags.changesPending ? { changes_pending: true } : {}),
1281
- ...(flags.searchIncomplete ? { search_incomplete: true } : {}),
1282
- },
1283
- };
1284
- }
1285
-
1286
1261
  /** Overridable so a test can drive the time budget without sleeping. */
1287
1262
  protected now(): number {
1288
1263
  return Date.now();