@lobu/runtime-server 21.0.0 → 21.1.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 (182) hide show
  1. package/dist/catalogs/automations.json +0 -8
  2. package/dist/component.json +1 -1
  3. package/dist/connectors/github.ts +269 -194
  4. package/dist/connectors/google_calendar.ts +36 -132
  5. package/dist/connectors/jira.ts +13 -4
  6. package/dist/connectors/producthunt.ts +3 -1
  7. package/dist/connectors/reddit.ts +34 -4
  8. package/dist/db/migrations/20260928120000_classification_consolidation.sql +51 -0
  9. package/dist/dependencies.bun.lock +11 -11
  10. package/dist/owletto/dist/assets/_-00GgOtdu.js +1 -0
  11. package/dist/owletto/dist/assets/{_-DrcppoWh.js → _-XlUwOWCI.js} +2 -2
  12. package/dist/owletto/dist/assets/{_agentId-HNcmgH56.js → _agentId-B2DrawIk.js} +1 -1
  13. package/dist/owletto/dist/assets/_agentId-CS0AcWH2.js +1 -0
  14. package/dist/owletto/dist/assets/{_automationId-BCfrLnUS.js → _automationId-BLnqLtUv.js} +1 -1
  15. package/dist/owletto/dist/assets/{_connectorKey._connectionId-126-iG9w.js → _connectorKey._connectionId-DcUWoZ-C.js} +1 -1
  16. package/dist/owletto/dist/assets/{_connectorKey.index-CywE9A3N.js → _connectorKey.index-C_yKycN_.js} +1 -1
  17. package/dist/owletto/dist/assets/{_conversationId-CNETA_rY.js → _conversationId-CpuEvflw.js} +1 -1
  18. package/dist/owletto/dist/assets/{_deploymentId-CAVpXf8s.js → _deploymentId-BL9tnDFl.js} +1 -1
  19. package/dist/owletto/dist/assets/_name-DlxjWkKk.js +1 -0
  20. package/dist/owletto/dist/assets/{_owner-D2eh4R90.js → _owner-Cg50UU6m.js} +1 -1
  21. package/dist/owletto/dist/assets/_shape-BWZW4mj8.js +1 -0
  22. package/dist/owletto/dist/assets/_skillKey-B25fO0_O.js +1 -0
  23. package/dist/owletto/dist/assets/{_slug-DoIaJBbh.js → _slug-DbD-wv2m.js} +1 -1
  24. package/dist/owletto/dist/assets/_viewKey-BcTEvQ3N.js +1 -0
  25. package/dist/owletto/dist/assets/_viewKey-W4RjiUWL.js +1 -0
  26. package/dist/owletto/dist/assets/_viewKey-iGPCKSda.js +1 -0
  27. package/dist/owletto/dist/assets/{accept-invitation-BWRiEUsd.js → accept-invitation-BmQKbQem.js} +1 -1
  28. package/dist/owletto/dist/assets/{activity-route-view-rVdTeVXN.js → activity-route-view-BvtAoGVt.js} +1 -1
  29. package/dist/owletto/dist/assets/{agent-card-controls-JubkhcHt.js → agent-card-controls-bhTMPoVi.js} +1 -1
  30. package/dist/owletto/dist/assets/{agent-client-setup-list-Btcy4Cu1.js → agent-client-setup-list-BBbq_2B1.js} +1 -1
  31. package/dist/owletto/dist/assets/{agent-connect-pages-Chfqn8iL.js → agent-connect-pages-DkDlFVY5.js} +1 -1
  32. package/dist/owletto/dist/assets/{agent-editor-form-BrOkwfg8.js → agent-editor-form-DwHD9j1Y.js} +1 -1
  33. package/dist/owletto/dist/assets/{agent-guardrails-route-CHM7JbIl.js → agent-guardrails-route-0PsTrqMC.js} +1 -1
  34. package/dist/owletto/dist/assets/{agent-loading-shells-DsiGx1fn.js → agent-loading-shells-BQLjzMPy.js} +1 -1
  35. package/dist/owletto/dist/assets/{agent-permissions-matrix-L_gFvSu1.js → agent-permissions-matrix-B-Q5rmuB.js} +1 -1
  36. package/dist/owletto/dist/assets/{agent-skill-context-D7tOJ8Pb.js → agent-skill-context-s42Q4Wjo.js} +1 -1
  37. package/dist/owletto/dist/assets/{agent-skills-route-AylS-B9v.js → agent-skills-route-Cwq1QrhW.js} +1 -1
  38. package/dist/owletto/dist/assets/{agent-subpage-shell-B7tCQ9zd.js → agent-subpage-shell-DtzoRy6N.js} +1 -1
  39. package/dist/owletto/dist/assets/{agent-thread-DOYh7WLW.js → agent-thread-D7AGGjRV.js} +1 -1
  40. package/dist/owletto/dist/assets/agents-BqCKU4CT.js +1 -0
  41. package/dist/owletto/dist/assets/{agents-workbench-DOwn78eL.js → agents-workbench-Cl7FO7b3.js} +1 -1
  42. package/dist/owletto/dist/assets/{app._appId-fJ_RRn1Z.js → app._appId-CqYz3AOO.js} +1 -1
  43. package/dist/owletto/dist/assets/{automation-detail-content-CMprQht5.js → automation-detail-content-CKSywvzE.js} +1 -1
  44. package/dist/owletto/dist/assets/automations-BqCKU4CT.js +1 -0
  45. package/dist/owletto/dist/assets/{calendar-BbD1N97u.js → calendar-CHXehtu0.js} +1 -1
  46. package/dist/owletto/dist/assets/{callback-PELM84Lh.js → callback-DZ3YyXeV.js} +1 -1
  47. package/dist/owletto/dist/assets/{card-DpLjEqIc.js → card-4Ull9W6d.js} +1 -1
  48. package/dist/owletto/dist/assets/{claim-BLLvLOBM.js → claim-BGLCPLXq.js} +1 -1
  49. package/dist/owletto/dist/assets/{clients-Bd8WpHSV.js → clients-C7ubnFsS.js} +1 -1
  50. package/dist/owletto/dist/assets/{code-editor-DGJQDoHD.js → code-editor-BHiWR94J.js} +1 -1
  51. package/dist/owletto/dist/assets/connect-BNatqg6j.js +1 -0
  52. package/dist/owletto/dist/assets/connect._clientId-BGG2IqiQ.js +1 -0
  53. package/dist/owletto/dist/assets/{connected._clientId-BYGmFRCF.js → connected._clientId-7RU89sVW.js} +1 -1
  54. package/dist/owletto/dist/assets/{connection-B0O8OZuK.js → connection-CTaUGXl6.js} +1 -1
  55. package/dist/owletto/dist/assets/{connection-feed-detail-DZjtoEfm.js → connection-feed-detail-B1xieiEh.js} +1 -1
  56. package/dist/owletto/dist/assets/{connector-provenance-D_g9gGXU.js → connector-provenance-DRdUEmQ1.js} +1 -1
  57. package/dist/owletto/dist/assets/{connectors-BiMMm_QQ.js → connectors-NBwCLuZg.js} +1 -1
  58. package/dist/owletto/dist/assets/{consent-CIzW-960.js → consent-fmhPPlpi.js} +1 -1
  59. package/dist/owletto/dist/assets/{core.esm-Ds4Nuq9d.js → core.esm-C-eNiUAl.js} +1 -1
  60. package/dist/owletto/dist/assets/{create-BvCaqhwK.js → create-8bBbQJGY.js} +1 -1
  61. package/dist/owletto/dist/assets/create-Cl6cfNAp.js +1 -0
  62. package/dist/owletto/dist/assets/create-DrVso8O7.js +1 -0
  63. package/dist/owletto/dist/assets/create-automation-form-De8J-JD5.js +2 -0
  64. package/dist/owletto/dist/assets/{create._connectorKey--qDi1h6S.js → create._connectorKey-CHAotlsF.js} +1 -1
  65. package/dist/owletto/dist/assets/{cronstrue-h8_zIyZD.js → cronstrue-C5yTgk5z.js} +1 -1
  66. package/dist/owletto/dist/assets/deployments-C7M3fV5K.js +1 -0
  67. package/dist/owletto/dist/assets/{deployments-ICDss7yS.js → deployments-D1gbQwsy.js} +1 -1
  68. package/dist/owletto/dist/assets/{deployments-body-DulCUAMt.js → deployments-body-DycIGlnL.js} +1 -1
  69. package/dist/owletto/dist/assets/{device-kTL2l_cz.js → device-DyPnQkhO.js} +1 -1
  70. package/dist/owletto/dist/assets/{device-pin-tombstone-BmD4pv_e.js → device-pin-tombstone-CwJitllC.js} +1 -1
  71. package/dist/owletto/dist/assets/{device-rows-BqudjhFu.js → device-rows-BBhW1C7Y.js} +1 -1
  72. package/dist/owletto/dist/assets/{device._deviceId-CsLJJ6jv.js → device._deviceId-XswfXHOc.js} +1 -1
  73. package/dist/owletto/dist/assets/{entity-options-ErxYvMDH.js → entity-options-utGBmFX0.js} +1 -1
  74. package/dist/owletto/dist/assets/{entity-page-CYRAwUGO.js → entity-page-BxwuqqWk.js} +1 -1
  75. package/dist/owletto/dist/assets/{entity-type-page-BlAizGlz.js → entity-type-page-BrWqk6so.js} +1 -1
  76. package/dist/owletto/dist/assets/{event-page-DTXPxc-E.js → event-page-LIm4EDmJ.js} +1 -1
  77. package/dist/owletto/dist/assets/{events-feed-L3c-LLiJ.js → events-feed-C4L8mQV7.js} +1 -1
  78. package/dist/owletto/dist/assets/{full-page-spinner-BxcYpJXx.js → full-page-spinner-DsU-Cb3L.js} +1 -1
  79. package/dist/owletto/dist/assets/guardrails-CGFWCfbQ.js +1 -0
  80. package/dist/owletto/dist/assets/identity-uPYpPogR.js +1 -0
  81. package/dist/owletto/dist/assets/{index-13rywWam.js → index-1YrrvVJ4.js} +1 -1
  82. package/dist/owletto/dist/assets/index-BKMafTe4.js +1 -0
  83. package/dist/owletto/dist/assets/index-BsL1-C2-.js +1 -0
  84. package/dist/owletto/dist/assets/index-C58oW727.js +1 -0
  85. package/dist/owletto/dist/assets/{index--lEHrFE4.js → index-CQ4s6nzy.js} +1 -1
  86. package/dist/owletto/dist/assets/{index-DAv5S2aK.js → index-CpWKAAGX.js} +1 -1
  87. package/dist/owletto/dist/assets/{index-QcHQZI87.js → index-D2dcENg2.js} +1 -1
  88. package/dist/owletto/dist/assets/{index-CheCJomo.js → index-DCK0KhMM.js} +1 -1
  89. package/dist/owletto/dist/assets/{index-BRvT0VV9.js → index-DXqiRON3.js} +1 -1
  90. package/dist/owletto/dist/assets/index-DgEc5IvT.js +1 -0
  91. package/dist/owletto/dist/assets/{index-DdGjY1Hb.js → index-DtRfQcRH.js} +1530 -1530
  92. package/dist/owletto/dist/assets/index-DvhM9tuI.js +1 -0
  93. package/dist/owletto/dist/assets/{index-CFkj9iR_.js → index-DwtfHCHB.js} +1 -1
  94. package/dist/owletto/dist/assets/index-DyYFZjh-.js +1 -0
  95. package/dist/owletto/dist/assets/{index-B_-MLsof.js → index-nOYvNROJ.js} +1 -1
  96. package/dist/owletto/dist/assets/index-oDoJENMF.js +1 -0
  97. package/dist/owletto/dist/assets/index-rPdUEOa3.js +1 -0
  98. package/dist/owletto/dist/assets/{json-diff-BV2STDGj.js → json-diff-DYeX-xLk.js} +1 -1
  99. package/dist/owletto/dist/assets/{list-skeleton-CT5n4ND_.js → list-skeleton-s4GPSJ8J.js} +1 -1
  100. package/dist/owletto/dist/assets/{login-DKsgABYt.js → login-Di5VF2F_.js} +1 -1
  101. package/dist/owletto/dist/assets/{logout-D_CP-emw.js → logout-BuaQGSnw.js} +1 -1
  102. package/dist/owletto/dist/assets/{member-scope-gate-BTgmlfFJ.js → member-scope-gate-CJqJZk7T.js} +1 -1
  103. package/dist/owletto/dist/assets/{memory-browse-page-FHaJC3ML.js → memory-browse-page-Bibfs2sK.js} +1 -1
  104. package/dist/owletto/dist/assets/{missing-view-Bve6pJP-.js → missing-view-CD4DOaG8.js} +1 -1
  105. package/dist/owletto/dist/assets/{model-selector-BLCEahny.js → model-selector-XC5CI2Et.js} +1 -1
  106. package/dist/owletto/dist/assets/models--8mTFOLz.js +1 -0
  107. package/dist/owletto/dist/assets/{new-CirOK0Sw.js → new-BzkA1sq2.js} +1 -1
  108. package/dist/owletto/dist/assets/{new-DzapH2sV.js → new-C3f0BShb.js} +1 -1
  109. package/dist/owletto/dist/assets/{new-BAIGSdfp.js → new-DA5LF6iB.js} +1 -1
  110. package/dist/owletto/dist/assets/{oauth-workspace-access-BF7jaswv.js → oauth-workspace-access-D6epOq0R.js} +1 -1
  111. package/dist/owletto/dist/assets/{organization-D9RPsWG-.js → organization-DOtBRqDQ.js} +1 -1
  112. package/dist/owletto/dist/assets/{permissions-BlRONw-u.js → permissions-D8uJHINS.js} +1 -1
  113. package/dist/owletto/dist/assets/{proposal-review-shell-uskeFIUr.js → proposal-review-shell-C3K-JXjb.js} +1 -1
  114. package/dist/owletto/dist/assets/{recent-CmJ4Is6V.js → recent-CFcWceBl.js} +1 -1
  115. package/dist/owletto/dist/assets/{renderer-Dyf4t8kR.js → renderer-1nRJFMGx.js} +1 -1
  116. package/dist/owletto/dist/assets/{reset-password-BVIeE1Zm.js → reset-password-9RTWhBEb.js} +1 -1
  117. package/dist/owletto/dist/assets/{runs-CzBeUzlQ.js → runs-_yVh6PPB.js} +1 -1
  118. package/dist/owletto/dist/assets/{runs-panel-D7l1uLGm.js → runs-panel-B2852xus.js} +1 -1
  119. package/dist/owletto/dist/assets/{runs-table-dATyiBg2.js → runs-table--dnFQatY.js} +1 -1
  120. package/dist/owletto/dist/assets/{schema-value-normalization-DgMkyVVE.js → schema-value-normalization-BspxVEGy.js} +1 -1
  121. package/dist/owletto/dist/assets/{settings-Co1wj_m6.js → settings-9lDASETT.js} +1 -1
  122. package/dist/owletto/dist/assets/settings-DQo_ZS2P.js +1 -0
  123. package/dist/owletto/dist/assets/skills-a5xQ4RE9.js +1 -0
  124. package/dist/owletto/dist/assets/{switch-DDkPrV3p.js → switch-CxDXvPGE.js} +1 -1
  125. package/dist/owletto/dist/assets/{use-applied-views-DELwQQh7.js → use-applied-views-DvMT3wap.js} +1 -1
  126. package/dist/owletto/dist/assets/{use-mention-search-CGA3AaKm.js → use-mention-search-CeTEE3oE.js} +1 -1
  127. package/dist/owletto/dist/assets/{view-frame-DDr-Xtet.js → view-frame-HoBawpT2.js} +1 -1
  128. package/dist/owletto/dist/index.html +1 -1
  129. package/dist/providers.json +0 -1
  130. package/dist/server-main.bundle.mjs +2365 -3969
  131. package/npm-shrinkwrap.json +41 -41
  132. package/package.json +1 -1
  133. package/vendor/connector-sdk/dist/connector-types.d.ts +0 -2
  134. package/vendor/connector-sdk/package.json +1 -1
  135. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +14 -0
  136. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +12 -1
  137. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +0 -10
  138. package/vendor/core/dist/contracts/tools/manage-automations.js +0 -33
  139. package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +4 -34
  140. package/vendor/core/dist/contracts/tools/manage-classifiers.js +13 -44
  141. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +0 -9
  142. package/vendor/core/dist/contracts/tools/manage-entity.js +0 -6
  143. package/vendor/core/dist/contracts/tools/view-attach.d.ts +20 -0
  144. package/vendor/core/dist/contracts/tools/view-attach.js +45 -0
  145. package/vendor/core/dist/contracts/worker/protocol.d.ts +17 -0
  146. package/vendor/core/dist/contracts/worker/protocol.js +12 -1
  147. package/vendor/core/dist/index.d.ts +1 -1
  148. package/vendor/core/dist/provider-config-types.d.ts +0 -9
  149. package/vendor/core/dist/sdk-compat.d.ts +1 -1
  150. package/vendor/core/package.json +6 -1
  151. package/vendor/views/dist/api.d.ts +9 -4
  152. package/vendor/views/dist/api.js +6 -2
  153. package/vendor/views/package.json +1 -1
  154. package/dist/owletto/dist/assets/_-CwFknmeA.js +0 -1
  155. package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +0 -1
  156. package/dist/owletto/dist/assets/_name-BP7OlVxL.js +0 -1
  157. package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +0 -1
  158. package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +0 -1
  159. package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +0 -1
  160. package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +0 -1
  161. package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +0 -1
  162. package/dist/owletto/dist/assets/agents-0ncYwbz6.js +0 -1
  163. package/dist/owletto/dist/assets/automations-0ncYwbz6.js +0 -1
  164. package/dist/owletto/dist/assets/connect-Cx49f4J0.js +0 -1
  165. package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +0 -1
  166. package/dist/owletto/dist/assets/create--fsxroj2.js +0 -1
  167. package/dist/owletto/dist/assets/create-BqL-ahEf.js +0 -1
  168. package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +0 -2
  169. package/dist/owletto/dist/assets/deployments-BROg1Te8.js +0 -1
  170. package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +0 -1
  171. package/dist/owletto/dist/assets/identity-B8lKn0je.js +0 -1
  172. package/dist/owletto/dist/assets/index-BUp24ZJr.js +0 -1
  173. package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +0 -1
  174. package/dist/owletto/dist/assets/index-CgBgOElA.js +0 -1
  175. package/dist/owletto/dist/assets/index-CpiW66xK.js +0 -1
  176. package/dist/owletto/dist/assets/index-DBi2Xr3i.js +0 -1
  177. package/dist/owletto/dist/assets/index-DHOha5OJ.js +0 -1
  178. package/dist/owletto/dist/assets/index-Dkyl7l6E.js +0 -1
  179. package/dist/owletto/dist/assets/index-kq4537-S.js +0 -1
  180. package/dist/owletto/dist/assets/models-C4N7LQAW.js +0 -1
  181. package/dist/owletto/dist/assets/settings-BK1GHmzb.js +0 -1
  182. package/dist/owletto/dist/assets/skills-DF53JcYt.js +0 -1
@@ -17,7 +17,6 @@ import {
17
17
  createHttpClient,
18
18
  type EventAttributionRule,
19
19
  type EventEnvelope,
20
- paginateByOffset,
21
20
  SubscriptionCandidateSchema,
22
21
  type SyncContext,
23
22
  type SyncResult,
@@ -75,9 +74,50 @@ interface GitHubConfig {
75
74
  installation_ref?: number | string;
76
75
  }
77
76
 
77
+ interface GitHubPosition {
78
+ page?: number;
79
+ cursor?: string;
80
+ comment_cursor?: string;
81
+ }
82
+
83
+ interface GitHubContentProgress extends GitHubPosition {
84
+ scope: string;
85
+ since: string;
86
+ started_at: string;
87
+ }
88
+
89
+ interface GitHubPage {
90
+ events: EventEnvelope[];
91
+ next?: GitHubPosition;
92
+ }
93
+
94
+ interface GitHubPageInfo {
95
+ hasNextPage: boolean;
96
+ endCursor?: string | null;
97
+ }
98
+
99
+ function nextGitHubCursor(info: GitHubPageInfo | undefined, current?: string): string | undefined {
100
+ if (!info || typeof info.hasNextPage !== 'boolean') {
101
+ throw new Error('GitHub omitted pagination information.');
102
+ }
103
+ if (!info.hasNextPage) return undefined;
104
+ if (!info.endCursor || info.endCursor === current) {
105
+ throw new Error('GitHub returned a missing or repeated page cursor.');
106
+ }
107
+ return info.endCursor;
108
+ }
109
+
78
110
  interface GitHubCheckpoint {
79
111
  last_sync_at?: string;
112
+ commits?: {
113
+ since: string;
114
+ started_at: string;
115
+ head_sha?: string;
116
+ next_page: number;
117
+ };
118
+ content?: GitHubContentProgress;
80
119
  stargazers?: GitHubStargazerCheckpoint[];
120
+ stargazer_scan?: { scope: string; page: number; started_at: string; current: GitHubStargazerCheckpoint[] };
81
121
  }
82
122
 
83
123
  interface GitHubStargazerCheckpoint {
@@ -243,18 +283,6 @@ function asString(value: unknown): string | undefined {
243
283
  return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
244
284
  }
245
285
 
246
- /**
247
- * Coerce a GitHub list response to an array. `http.json()` returns
248
- * `await response.json()`, which is `null`/`undefined` for an empty-body 200
249
- * (GitHub occasionally serves these). The list sync paths immediately read
250
- * `.length` / iterate, so a bare null threw
251
- * `Cannot read properties of undefined (reading 'length')` and crashed the
252
- * whole sync (#2033). Treat any non-array response as an empty page.
253
- */
254
- function asArray<T>(value: T[] | null | undefined): T[] {
255
- return Array.isArray(value) ? value : [];
256
- }
257
-
258
286
  function toIsoOrUndefined(value: unknown): string | undefined {
259
287
  const str = asString(value);
260
288
  if (!str) return undefined;
@@ -280,9 +308,7 @@ const LOOKBACK_PROP = {
280
308
  const STARGAZER_PROFILE_REFRESH_MS = 30 * 24 * 60 * 60 * 1000;
281
309
  const STARGAZER_PROFILE_FETCH_LIMIT = 25;
282
310
 
283
- // Bound a single commits sync to 30 pages (3000 commits). Incremental `since`
284
- // keeps steady-state runs tiny; the cap only matters on a cold backfill of a
285
- // busy repo, where the remaining history rides subsequent runs.
311
+ // Resume after at most 30 data pages, keeping the same immutable commit graph.
286
312
  const COMMITS_MAX_PAGES = 30;
287
313
 
288
314
  const LABELS_PROP = {
@@ -902,37 +928,37 @@ export default class GitHubConnector extends ConnectorRuntime {
902
928
  );
903
929
  const sinceIso = this.resolveSince(ctx.checkpoint, config.lookback_days ?? 365);
904
930
 
931
+ const checkpoint = (ctx.checkpoint ?? {}) as GitHubCheckpoint;
932
+ let result: { events: EventEnvelope[]; checkpoint: GitHubCheckpoint; status: SyncResult['status'] };
905
933
  if (contentType === 'stargazers') {
906
- const result = await this.syncStargazers(repo, ctx.checkpoint, token);
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>);
913
- return {
914
- status: 'complete',
915
- metadata: {
916
- items_found: result.events.length,
917
- current_stargazers: result.currentStargazers.length,
918
- },
934
+ result = await this.syncStargazers(repo, checkpoint, token);
935
+ } else if (contentType === 'commits') {
936
+ result = await this.syncCommits(repo, sinceIso, ctx.checkpoint, token);
937
+ } else {
938
+ const labelsFilter = config.labels_filter ?? [];
939
+ const scope = JSON.stringify([repo.owner, repo.repo, contentType, labelsFilter, config.lookback_days ?? 365]);
940
+ const progress = checkpoint.content?.scope === scope ? checkpoint.content : {
941
+ scope,
942
+ since: sinceIso,
943
+ // The REST `since` boundary is exclusive and timestamps have second
944
+ // precision. Overlap that second to recover updates made during a scan.
945
+ started_at: new Date(Math.floor(Date.now() / 1000) * 1000 - 1000).toISOString(),
946
+ };
947
+ const page = await this.syncContent({ repo, contentType, progress, labelsFilter, token });
948
+ result = {
949
+ events: page.events,
950
+ checkpoint: page.next
951
+ ? { ...checkpoint, content: { scope, since: progress.since, started_at: progress.started_at, ...page.next } }
952
+ : { last_sync_at: progress.started_at },
953
+ status: page.next ? 'more' : 'complete',
919
954
  };
920
955
  }
921
-
922
- const events = await this.syncContent({
923
- repo,
924
- contentType,
925
- sinceIso,
926
- labelsFilter: config.labels_filter ?? [],
927
- token,
928
- });
956
+ const { events } = result;
929
957
  this.stampRepoAttribution(events, repo, { attachAutomationSignals });
930
958
 
931
- await ctx.commit(events, {
932
- last_sync_at: new Date().toISOString(),
933
- } as Record<string, unknown>);
959
+ await ctx.commit(events, result.checkpoint as Record<string, unknown>);
934
960
  return {
935
- status: 'complete',
961
+ status: result.status,
936
962
  metadata: {
937
963
  items_found: events.length,
938
964
  },
@@ -1157,58 +1183,83 @@ export default class GitHubConnector extends ConnectorRuntime {
1157
1183
 
1158
1184
  private async syncContent(params: {
1159
1185
  repo: RepoRef;
1160
- contentType: Exclude<GitHubContentType, 'stargazers'>;
1161
- sinceIso: string;
1186
+ contentType: Exclude<GitHubContentType, 'stargazers' | 'commits'>;
1187
+ progress: GitHubContentProgress;
1162
1188
  labelsFilter: string[];
1163
1189
  token: string | null;
1164
- }): Promise<EventEnvelope[]> {
1165
- const { repo, contentType, sinceIso, labelsFilter, token } = params;
1190
+ }): Promise<GitHubPage> {
1191
+ const { repo, contentType, progress, labelsFilter, token } = params;
1166
1192
 
1167
1193
  switch (contentType) {
1168
1194
  case 'issues':
1169
1195
  case 'pull_requests':
1170
- return await this.syncIssuesAndPulls(repo, contentType, sinceIso, labelsFilter, token);
1196
+ return await this.syncIssuesAndPulls(repo, contentType, progress, labelsFilter, token);
1171
1197
  case 'issue_comments':
1172
- return await this.syncIssueComments(repo, sinceIso, token);
1198
+ return await this.syncIssueComments(repo, progress, token);
1173
1199
  case 'pr_comments':
1174
- return await this.syncPullRequestComments(repo, sinceIso, token);
1200
+ return await this.syncPullRequestComments(repo, progress, token);
1175
1201
  case 'discussions':
1176
- return await this.syncDiscussions(repo, sinceIso, token);
1202
+ return await this.syncDiscussions(repo, progress, token);
1177
1203
  case 'discussion_comments':
1178
- return await this.syncDiscussionComments(repo, sinceIso, token);
1179
- case 'commits':
1180
- return await this.syncCommits(repo, sinceIso, token);
1204
+ return await this.syncDiscussionComments(repo, progress, token);
1181
1205
  }
1182
1206
  }
1183
1207
 
1184
1208
  private async syncCommits(
1185
1209
  repo: RepoRef,
1186
1210
  sinceIso: string,
1211
+ rawCheckpoint: Record<string, unknown> | null,
1187
1212
  token: string | null
1188
- ): Promise<EventEnvelope[]> {
1213
+ ): Promise<{ events: EventEnvelope[]; checkpoint: GitHubCheckpoint; status: SyncResult['status'] }> {
1189
1214
  const events: EventEnvelope[] = [];
1190
-
1191
- // Commits are durable and fully queryable, so polling recovers the complete
1192
- // "who committed when" history — no webhook dependency. `since` filters by
1193
- // commit date for incremental syncs; pagination is bounded so one run can't
1194
- // walk an unbounded history (deeper backfill rides subsequent runs).
1195
- const pages = paginateByOffset<GitHubCommitLike>(
1196
- async (offset, pageSize) => {
1197
- const query = new URLSearchParams({
1198
- per_page: String(pageSize),
1199
- page: String(offset / pageSize + 1),
1215
+ const checkpoint = (rawCheckpoint ?? {}) as GitHubCheckpoint;
1216
+ const progress: NonNullable<GitHubCheckpoint['commits']> = checkpoint.commits
1217
+ ? { ...checkpoint.commits }
1218
+ : {
1200
1219
  since: sinceIso,
1201
- });
1202
- const url = `${githubRepoApiUrl(repo, '/commits')}?${query.toString()}`;
1203
- const commits = asArray(
1204
- await this.requestJson<GitHubCommitLike[]>({ url, token })
1205
- );
1206
- return { items: commits, hasMore: commits.length === pageSize };
1207
- },
1208
- { pageSize: 100, maxPages: COMMITS_MAX_PAGES }
1209
- );
1220
+ // Use the start, not the end of a potentially multi-run scan. Round down
1221
+ // to GitHub's timestamp precision so commits in this second are replayed.
1222
+ started_at: new Date(Math.floor(Date.now() / 1000) * 1000).toISOString(),
1223
+ next_page: 1,
1224
+ };
1225
+ const more = () => ({
1226
+ events,
1227
+ checkpoint: { ...checkpoint, commits: progress },
1228
+ status: 'more' as const,
1229
+ });
1230
+ const complete = () => ({
1231
+ events,
1232
+ checkpoint: { last_sync_at: progress.started_at },
1233
+ status: 'complete' as const,
1234
+ });
1210
1235
 
1211
- for await (const commits of pages) {
1236
+ if (!progress.head_sha) {
1237
+ // Resolve the unfiltered default-branch head before paging. A date-filtered
1238
+ // first commit need not be the tip; pinning that could omit merge ancestry.
1239
+ const head = await this.requestJson<GitHubCommitLike[]>({
1240
+ url: `${githubRepoApiUrl(repo, '/commits')}?per_page=1`,
1241
+ token,
1242
+ });
1243
+ if (!Array.isArray(head)) return more();
1244
+ if (head.length === 0) return complete();
1245
+ progress.head_sha = head[0]?.sha;
1246
+ if (!progress.head_sha) return more();
1247
+ }
1248
+
1249
+ for (let page = 0; page < COMMITS_MAX_PAGES; page++) {
1250
+ const query = new URLSearchParams({
1251
+ per_page: '100',
1252
+ page: String(progress.next_page),
1253
+ since: progress.since,
1254
+ // New commits and force pushes cannot move offsets in this snapshot.
1255
+ sha: progress.head_sha,
1256
+ });
1257
+ const commits = await this.requestJson<GitHubCommitLike[]>({
1258
+ url: `${githubRepoApiUrl(repo, '/commits')}?${query.toString()}`,
1259
+ token,
1260
+ });
1261
+ // An empty body is indeterminate, not evidence that history is exhausted.
1262
+ if (!Array.isArray(commits)) return more();
1212
1263
  for (const commit of commits) {
1213
1264
  if (!commit.sha) continue;
1214
1265
  const authoredAtIso = commit.commit?.author?.date;
@@ -1242,31 +1293,36 @@ export default class GitHubConnector extends ConnectorRuntime {
1242
1293
  },
1243
1294
  });
1244
1295
  }
1296
+ progress.next_page += 1;
1297
+ if (commits.length < 100) return complete();
1245
1298
  }
1246
1299
 
1247
- return events;
1300
+ return more();
1248
1301
  }
1249
1302
 
1250
1303
  private async syncIssuesAndPulls(
1251
1304
  repo: RepoRef,
1252
1305
  contentType: 'issues' | 'pull_requests',
1253
- sinceIso: string,
1306
+ progress: GitHubContentProgress,
1254
1307
  labelsFilter: string[],
1255
1308
  token: string | null
1256
- ): Promise<EventEnvelope[]> {
1309
+ ): Promise<GitHubPage> {
1257
1310
  const query = new URLSearchParams({
1258
1311
  state: 'all',
1259
1312
  per_page: '100',
1260
- sort: 'updated',
1261
- direction: 'desc',
1262
- since: sinceIso,
1313
+ // Updates must not move consumed records to a different offset.
1314
+ sort: 'created',
1315
+ direction: 'asc',
1316
+ since: progress.since,
1317
+ page: String(progress.page ?? 1),
1263
1318
  });
1264
1319
  if (labelsFilter.length > 0) {
1265
1320
  query.set('labels', labelsFilter.join(','));
1266
1321
  }
1267
1322
 
1268
1323
  const url = `${githubRepoApiUrl(repo, '/issues')}?${query.toString()}`;
1269
- const items = asArray(await this.requestJson<GitHubIssueLike[]>({ url, token }));
1324
+ const items = await this.requestJson<GitHubIssueLike[]>({ url, token });
1325
+ if (!Array.isArray(items)) return { events: [], next: progress };
1270
1326
  const events: EventEnvelope[] = [];
1271
1327
 
1272
1328
  for (const item of items) {
@@ -1303,26 +1359,27 @@ export default class GitHubConnector extends ConnectorRuntime {
1303
1359
  });
1304
1360
  }
1305
1361
 
1306
- return events;
1362
+ return { events, next: items.length === 100 ? { page: (progress.page ?? 1) + 1 } : undefined };
1307
1363
  }
1308
1364
 
1309
1365
  private async syncIssueComments(
1310
1366
  repo: RepoRef,
1311
- sinceIso: string,
1367
+ progress: GitHubContentProgress,
1312
1368
  token: string | null
1313
- ): Promise<EventEnvelope[]> {
1369
+ ): Promise<GitHubPage> {
1314
1370
  const query = new URLSearchParams({
1315
1371
  per_page: '100',
1316
- sort: 'updated',
1317
- direction: 'desc',
1318
- since: sinceIso,
1372
+ // Updates must not move consumed records to a different offset.
1373
+ sort: 'created',
1374
+ direction: 'asc',
1375
+ since: progress.since,
1376
+ page: String(progress.page ?? 1),
1319
1377
  });
1320
1378
  const url = `${githubRepoApiUrl(repo, '/issues/comments')}?${query.toString()}`;
1321
- const comments = asArray(
1322
- await this.requestJson<GitHubCommentLike[]>({ url, token })
1323
- );
1379
+ const comments = await this.requestJson<GitHubCommentLike[]>({ url, token });
1380
+ if (!Array.isArray(comments)) return { events: [], next: progress };
1324
1381
 
1325
- return comments
1382
+ const events = comments
1326
1383
  .map((comment): EventEnvelope | null => {
1327
1384
  const createdAt = new Date(comment.created_at);
1328
1385
  if (Number.isNaN(createdAt.getTime())) return null;
@@ -1348,25 +1405,27 @@ export default class GitHubConnector extends ConnectorRuntime {
1348
1405
  };
1349
1406
  })
1350
1407
  .filter((value): value is EventEnvelope => value !== null);
1408
+ return { events, next: comments.length === 100 ? { page: (progress.page ?? 1) + 1 } : undefined };
1351
1409
  }
1352
1410
 
1353
1411
  private async syncPullRequestComments(
1354
1412
  repo: RepoRef,
1355
- sinceIso: string,
1413
+ progress: GitHubContentProgress,
1356
1414
  token: string | null
1357
- ): Promise<EventEnvelope[]> {
1415
+ ): Promise<GitHubPage> {
1358
1416
  const query = new URLSearchParams({
1359
1417
  per_page: '100',
1360
- sort: 'updated',
1361
- direction: 'desc',
1362
- since: sinceIso,
1418
+ // Updates must not move consumed records to a different offset.
1419
+ sort: 'created',
1420
+ direction: 'asc',
1421
+ since: progress.since,
1422
+ page: String(progress.page ?? 1),
1363
1423
  });
1364
1424
  const url = `${githubRepoApiUrl(repo, '/pulls/comments')}?${query.toString()}`;
1365
- const comments = asArray(
1366
- await this.requestJson<GitHubCommentLike[]>({ url, token })
1367
- );
1425
+ const comments = await this.requestJson<GitHubCommentLike[]>({ url, token });
1426
+ if (!Array.isArray(comments)) return { events: [], next: progress };
1368
1427
 
1369
- return comments
1428
+ const events = comments
1370
1429
  .map((comment): EventEnvelope | null => {
1371
1430
  const createdAt = new Date(comment.created_at);
1372
1431
  if (Number.isNaN(createdAt.getTime())) return null;
@@ -1392,17 +1451,19 @@ export default class GitHubConnector extends ConnectorRuntime {
1392
1451
  };
1393
1452
  })
1394
1453
  .filter((value): value is EventEnvelope => value !== null);
1454
+ return { events, next: comments.length === 100 ? { page: (progress.page ?? 1) + 1 } : undefined };
1395
1455
  }
1396
1456
 
1397
1457
  private async syncDiscussions(
1398
1458
  repo: RepoRef,
1399
- sinceIso: string,
1459
+ progress: GitHubContentProgress,
1400
1460
  token: string | null
1401
- ): Promise<EventEnvelope[]> {
1461
+ ): Promise<GitHubPage> {
1402
1462
  const query = `
1403
- query($owner: String!, $repo: String!) {
1463
+ query($owner: String!, $repo: String!, $cursor: String) {
1404
1464
  repository(owner: $owner, name: $repo) {
1405
- discussions(first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
1465
+ discussions(first: 100, after: $cursor, orderBy: {field: CREATED_AT, direction: ASC}) {
1466
+ pageInfo { hasNextPage endCursor }
1406
1467
  nodes {
1407
1468
  id
1408
1469
  number
@@ -1424,19 +1485,21 @@ export default class GitHubConnector extends ConnectorRuntime {
1424
1485
  const response = await this.requestGraphQL<{
1425
1486
  data?: {
1426
1487
  repository?: {
1427
- discussions?: { nodes?: GraphQLDiscussionNode[] };
1488
+ discussions?: { nodes?: GraphQLDiscussionNode[]; pageInfo?: GitHubPageInfo };
1428
1489
  };
1429
1490
  };
1430
1491
  }>({
1431
1492
  token,
1432
1493
  query,
1433
- variables: { owner: repo.owner, repo: repo.repo },
1494
+ variables: { owner: repo.owner, repo: repo.repo, cursor: progress.cursor },
1434
1495
  });
1435
1496
 
1436
- const discussions = response.data?.repository?.discussions?.nodes ?? [];
1437
- const since = new Date(sinceIso).getTime();
1497
+ const connection = response.data?.repository?.discussions;
1498
+ const cursor = nextGitHubCursor(connection?.pageInfo, progress.cursor);
1499
+ const discussions = connection?.nodes ?? [];
1500
+ const since = new Date(progress.since).getTime();
1438
1501
 
1439
- return discussions
1502
+ const events = discussions
1440
1503
  .map((discussion): EventEnvelope | null => {
1441
1504
  const createdAt = new Date(discussion.createdAt);
1442
1505
  const updatedAt = new Date(discussion.updatedAt).getTime();
@@ -1464,20 +1527,23 @@ export default class GitHubConnector extends ConnectorRuntime {
1464
1527
  };
1465
1528
  })
1466
1529
  .filter((value): value is EventEnvelope => value !== null);
1530
+ return { events, next: cursor ? { cursor } : undefined };
1467
1531
  }
1468
1532
 
1469
1533
  private async syncDiscussionComments(
1470
1534
  repo: RepoRef,
1471
- sinceIso: string,
1535
+ progress: GitHubContentProgress,
1472
1536
  token: string | null
1473
- ): Promise<EventEnvelope[]> {
1537
+ ): Promise<GitHubPage> {
1474
1538
  const query = `
1475
- query($owner: String!, $repo: String!) {
1539
+ query($owner: String!, $repo: String!, $cursor: String, $commentCursor: String) {
1476
1540
  repository(owner: $owner, name: $repo) {
1477
- discussions(first: 50, orderBy: {field: UPDATED_AT, direction: DESC}) {
1541
+ discussions(first: 1, after: $cursor, orderBy: {field: CREATED_AT, direction: ASC}) {
1542
+ pageInfo { hasNextPage endCursor }
1478
1543
  nodes {
1479
1544
  number
1480
- comments(first: 50) {
1545
+ comments(first: 100, after: $commentCursor) {
1546
+ pageInfo { hasNextPage endCursor }
1481
1547
  nodes {
1482
1548
  id
1483
1549
  body
@@ -1498,9 +1564,10 @@ export default class GitHubConnector extends ConnectorRuntime {
1498
1564
  data?: {
1499
1565
  repository?: {
1500
1566
  discussions?: {
1567
+ pageInfo?: GitHubPageInfo;
1501
1568
  nodes?: Array<{
1502
1569
  number: number;
1503
- comments?: { nodes?: Array<Omit<GraphQLDiscussionCommentNode, 'discussion'>> };
1570
+ comments?: { nodes?: Array<Omit<GraphQLDiscussionCommentNode, 'discussion'>>; pageInfo?: GitHubPageInfo };
1504
1571
  }>;
1505
1572
  };
1506
1573
  };
@@ -1508,11 +1575,16 @@ export default class GitHubConnector extends ConnectorRuntime {
1508
1575
  }>({
1509
1576
  token,
1510
1577
  query,
1511
- variables: { owner: repo.owner, repo: repo.repo },
1578
+ variables: { owner: repo.owner, repo: repo.repo, cursor: progress.cursor, commentCursor: progress.comment_cursor },
1512
1579
  });
1513
1580
 
1514
- const discussions = response.data?.repository?.discussions?.nodes ?? [];
1515
- const since = new Date(sinceIso).getTime();
1581
+ const connection = response.data?.repository?.discussions;
1582
+ const cursor = nextGitHubCursor(connection?.pageInfo, progress.cursor);
1583
+ const discussions = connection?.nodes ?? [];
1584
+ const commentCursor = discussions[0]
1585
+ ? nextGitHubCursor(discussions[0].comments?.pageInfo, progress.comment_cursor)
1586
+ : undefined;
1587
+ const since = new Date(progress.since).getTime();
1516
1588
  const result: EventEnvelope[] = [];
1517
1589
 
1518
1590
  for (const discussion of discussions) {
@@ -1543,98 +1615,97 @@ export default class GitHubConnector extends ConnectorRuntime {
1543
1615
  }
1544
1616
  }
1545
1617
 
1546
- return result;
1618
+ return {
1619
+ events: result,
1620
+ next: commentCursor ? { cursor: progress.cursor, comment_cursor: commentCursor }
1621
+ : cursor ? { cursor } : undefined,
1622
+ };
1547
1623
  }
1548
1624
 
1549
1625
  private async syncStargazers(
1550
1626
  repo: RepoRef,
1551
- checkpoint: Record<string, unknown> | null,
1627
+ checkpoint: GitHubCheckpoint,
1552
1628
  token: string | null
1553
- ): Promise<{ events: EventEnvelope[]; currentStargazers: GitHubStargazerCheckpoint[] }> {
1554
- const previous = this.parseStargazerCheckpoint(checkpoint);
1629
+ ): Promise<{ events: EventEnvelope[]; checkpoint: GitHubCheckpoint; status: SyncResult['status'] }> {
1630
+ const previous = this.parseStargazerCheckpoint(checkpoint as Record<string, unknown>);
1555
1631
  const previousByKey = new Map(previous.map((stargazer) => [stargazer.key, stargazer]));
1556
- const currentStargazers: GitHubStargazerCheckpoint[] = [];
1632
+ const scope = JSON.stringify([repo.owner, repo.repo]);
1633
+ const scan = checkpoint.stargazer_scan?.scope === scope ? checkpoint.stargazer_scan : {
1634
+ scope, page: 1, started_at: new Date().toISOString(), current: [],
1635
+ };
1636
+ const currentStargazers = [...scan.current];
1557
1637
  const events: EventEnvelope[] = [];
1558
- const now = new Date();
1638
+ const now = new Date(scan.started_at);
1559
1639
  const repoInfo = await this.fetchRepository(repo, token);
1560
1640
  const target = this.buildRepoTarget(repo, repoInfo);
1561
1641
  let remainingProfileFetches = STARGAZER_PROFILE_FETCH_LIMIT;
1562
1642
 
1563
- const pages = paginateByOffset<GitHubStargazerLike>(
1564
- async (offset, pageSize) => {
1565
- const query = new URLSearchParams({
1566
- per_page: String(pageSize),
1567
- page: String(offset / pageSize + 1),
1568
- });
1569
- const url = `${githubRepoApiUrl(repo, '/stargazers')}?${query.toString()}`;
1570
- const stargazers = asArray(
1571
- await this.requestJson<GitHubStargazerLike[]>({
1572
- url,
1643
+ const query = new URLSearchParams({ per_page: '100', page: String(scan.page) });
1644
+ const stargazers = await this.requestJson<GitHubStargazerLike[]>({
1645
+ url: `${githubRepoApiUrl(repo, '/stargazers')}?${query.toString()}`,
1646
+ token, accept: 'application/vnd.github.star+json',
1647
+ });
1648
+ if (!Array.isArray(stargazers)) {
1649
+ return { events: [], checkpoint: { ...checkpoint, stargazer_scan: scan }, status: 'more' };
1650
+ }
1651
+ for (const stargazer of stargazers) {
1652
+ const user = stargazer.user ?? stargazer;
1653
+ const login = user.login;
1654
+ if (!login) continue;
1655
+
1656
+ const key = githubUserIdentityKey({ userId: user.id, login });
1657
+ const starredAtIso = toIsoOrUndefined(stargazer.starred_at) ?? now.toISOString();
1658
+ const starredAt = new Date(starredAtIso);
1659
+ if (Number.isNaN(starredAt.getTime())) continue;
1660
+
1661
+ const previousStargazer = previousByKey.get(key);
1662
+ const shouldRefreshProfile = this.shouldRefreshStargazerProfile(previousStargazer, now);
1663
+ const profileFetchedAt = shouldRefreshProfile && remainingProfileFetches > 0
1664
+ ? await this.enqueueStargazerProfileEvent({
1665
+ events,
1666
+ login,
1573
1667
  token,
1574
- accept: 'application/vnd.github.star+json',
1668
+ fallback: user,
1669
+ fetchedAt: now,
1575
1670
  })
1576
- );
1577
- return { items: stargazers, hasMore: stargazers.length === pageSize };
1578
- },
1579
- { pageSize: 100 }
1580
- );
1671
+ : (previousStargazer?.profile_fetched_at ?? null);
1672
+ if (shouldRefreshProfile && remainingProfileFetches > 0) remainingProfileFetches -= 1;
1581
1673
 
1582
- for await (const stargazers of pages) {
1583
- for (const stargazer of stargazers) {
1584
- const user = stargazer.user ?? stargazer;
1585
- const login = user.login;
1586
- if (!login) continue;
1587
-
1588
- const key = githubUserIdentityKey({ userId: user.id, login });
1589
- const starredAtIso = toIsoOrUndefined(stargazer.starred_at) ?? now.toISOString();
1590
- const starredAt = new Date(starredAtIso);
1591
- if (Number.isNaN(starredAt.getTime())) continue;
1592
-
1593
- const previousStargazer = previousByKey.get(key);
1594
- const shouldRefreshProfile = this.shouldRefreshStargazerProfile(previousStargazer, now);
1595
- const profileFetchedAt = shouldRefreshProfile && remainingProfileFetches > 0
1596
- ? await this.enqueueStargazerProfileEvent({
1597
- events,
1598
- login,
1599
- token,
1600
- fallback: user,
1601
- fetchedAt: now,
1602
- })
1603
- : (previousStargazer?.profile_fetched_at ?? null);
1604
- if (shouldRefreshProfile && remainingProfileFetches > 0) remainingProfileFetches -= 1;
1605
-
1606
- currentStargazers.push({
1607
- key,
1608
- login,
1609
- starred_at: starredAt.toISOString(),
1610
- user_id: user.id ?? previousStargazer?.user_id ?? null,
1611
- user_type: user.type ?? previousStargazer?.user_type ?? null,
1612
- html_url: user.html_url ?? previousStargazer?.html_url ?? `https://github.com/${login}`,
1613
- profile_fetched_at: profileFetchedAt,
1614
- });
1674
+ currentStargazers.push({
1675
+ key,
1676
+ login,
1677
+ starred_at: starredAt.toISOString(),
1678
+ user_id: user.id ?? previousStargazer?.user_id ?? null,
1679
+ user_type: user.type ?? previousStargazer?.user_type ?? null,
1680
+ html_url: user.html_url ?? previousStargazer?.html_url ?? `https://github.com/${login}`,
1681
+ profile_fetched_at: profileFetchedAt,
1682
+ });
1615
1683
 
1616
- if (!previousStargazer) {
1617
- events.push({
1618
- origin_id: `stargazer_${repo.owner}_${repo.repo}_${githubKeyForOriginId(key)}`,
1619
- title: `${login} starred ${repo.owner}/${repo.repo}`,
1620
- payload_text: `${login} starred ${repo.owner}/${repo.repo}.`,
1621
- author_name: login,
1622
- source_url: user.html_url ?? `https://github.com/${login}`,
1623
- occurred_at: starredAt,
1624
- origin_type: 'stargazer',
1625
- score: 1,
1626
- metadata: {
1627
- actor: this.buildActor(user, login),
1628
- target,
1629
- action: 'starred',
1630
- starred_at: starredAt.toISOString(),
1631
- source: 'github_stargazers_snapshot',
1632
- ...this.buildAuthorMetadata({ login, id: user.id }),
1633
- },
1634
- });
1635
- }
1684
+ if (!previousStargazer) {
1685
+ events.push({
1686
+ origin_id: `stargazer_${repo.owner}_${repo.repo}_${githubKeyForOriginId(key)}`,
1687
+ title: `${login} starred ${repo.owner}/${repo.repo}`,
1688
+ payload_text: `${login} starred ${repo.owner}/${repo.repo}.`,
1689
+ author_name: login,
1690
+ source_url: user.html_url ?? `https://github.com/${login}`,
1691
+ occurred_at: starredAt,
1692
+ origin_type: 'stargazer',
1693
+ score: 1,
1694
+ metadata: {
1695
+ actor: this.buildActor(user, login),
1696
+ target,
1697
+ action: 'starred',
1698
+ starred_at: starredAt.toISOString(),
1699
+ source: 'github_stargazers_snapshot',
1700
+ ...this.buildAuthorMetadata({ login, id: user.id }),
1701
+ },
1702
+ });
1636
1703
  }
1637
1704
  }
1705
+ const current = [...new Map(currentStargazers.map(star => [star.key, star])).values()];
1706
+ if (stargazers.length === 100) {
1707
+ return { events, checkpoint: { ...checkpoint, stargazer_scan: { ...scan, page: scan.page + 1, current } }, status: 'more' };
1708
+ }
1638
1709
 
1639
1710
  const currentKeys = new Set(currentStargazers.map((stargazer) => stargazer.key));
1640
1711
  for (const previousStargazer of previous) {
@@ -1661,7 +1732,7 @@ export default class GitHubConnector extends ConnectorRuntime {
1661
1732
  });
1662
1733
  }
1663
1734
 
1664
- return { events, currentStargazers };
1735
+ return { events, checkpoint: { last_sync_at: scan.started_at, stargazers: current }, status: 'complete' };
1665
1736
  }
1666
1737
 
1667
1738
  private shouldRefreshStargazerProfile(
@@ -2083,7 +2154,7 @@ export default class GitHubConnector extends ConnectorRuntime {
2083
2154
  query: string;
2084
2155
  variables?: Record<string, unknown>;
2085
2156
  }): Promise<T> {
2086
- return await this.requestJson<T>({
2157
+ const response = await this.requestJson<T & { errors?: Array<{ message: string }> }>({
2087
2158
  method: 'POST',
2088
2159
  url: 'https://api.github.com/graphql',
2089
2160
  token: params.token,
@@ -2095,6 +2166,10 @@ export default class GitHubConnector extends ConnectorRuntime {
2095
2166
  // on a 5xx even though it goes out as POST. A mutation must not set this.
2096
2167
  idempotent: true,
2097
2168
  });
2169
+ if (response?.errors?.length) {
2170
+ throw new Error(`GitHub GraphQL error: ${response.errors.map(error => error.message).join('; ')}`);
2171
+ }
2172
+ return response;
2098
2173
  }
2099
2174
 
2100
2175
  private readonly http = createHttpClient({ errorPrefix: 'GitHub API' });