@lobu/runtime-device 21.2.1 → 22.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 (196) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +91 -83
  3. package/npm-shrinkwrap.json +492 -438
  4. package/package.json +12 -2
  5. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
  6. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
  7. package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
  8. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
  9. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
  10. package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
  11. package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
  12. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
  13. package/vendor/cli/dist/commands/init.d.ts +0 -2
  14. package/vendor/cli/dist/commands/init.js +0 -27
  15. package/vendor/cli/dist/commands/login.d.ts +17 -0
  16. package/vendor/cli/dist/commands/login.js +43 -17
  17. package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
  18. package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
  19. package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
  20. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
  21. package/vendor/cli/dist/config/define.d.ts +21 -15
  22. package/vendor/cli/dist/config/define.js +2 -2
  23. package/vendor/cli/dist/connectors/README.md +7 -5
  24. package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
  25. package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
  26. package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
  27. package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
  28. package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
  29. package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
  30. package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
  31. package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
  32. package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
  33. package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
  34. package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
  35. package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
  36. package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
  37. package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
  38. package/vendor/cli/dist/connectors/agentid.ts +43 -0
  39. package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
  40. package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
  41. package/vendor/cli/dist/connectors/github-identity.ts +28 -3
  42. package/vendor/cli/dist/connectors/github.ts +101 -59
  43. package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
  44. package/vendor/cli/dist/connectors/google_drive.ts +16 -2
  45. package/vendor/cli/dist/connectors/google_gmail.ts +51 -33
  46. package/vendor/cli/dist/connectors/herdr.ts +406 -0
  47. package/vendor/cli/dist/connectors/jira.ts +6 -6
  48. package/vendor/cli/dist/connectors/linear.ts +7 -4
  49. package/vendor/cli/dist/connectors/postgres.ts +27 -2
  50. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
  51. package/vendor/cli/dist/connectors/tiktok-web-page.js +211 -0
  52. package/vendor/cli/dist/connectors/tiktok_web.ts +286 -0
  53. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +228 -10
  54. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +47 -14
  55. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +121 -0
  56. package/vendor/cli/dist/connectors/whatsapp_web.ts +170 -29
  57. package/vendor/cli/dist/connectors/x.ts +276 -136
  58. package/vendor/cli/dist/index.js +1 -37
  59. package/vendor/cli/dist/internal/context.d.ts +10 -0
  60. package/vendor/cli/dist/internal/context.js +26 -16
  61. package/vendor/cli/dist/internal/node-version.d.ts +1 -1
  62. package/vendor/cli/dist/internal/node-version.js +1 -1
  63. package/vendor/cli/dist/internal/oauth.d.ts +3 -1
  64. package/vendor/cli/dist/internal/oauth.js +4 -3
  65. package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
  66. package/vendor/cli/dist/internal/runtime-components.js +67 -2
  67. package/vendor/cli/dist/mac-auth.js +17 -1
  68. package/vendor/cli/dist/providers.json +1 -1
  69. package/vendor/cli/dist/runtime-components.json +4 -4
  70. package/vendor/cli/dist/templates/AGENTS.md.tmpl +11 -4
  71. package/vendor/cli/dist/templates/README.md.tmpl +1 -1
  72. package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  73. package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
  74. package/vendor/cli/dist/vendor/ora/index.js +424 -0
  75. package/vendor/cli/dist/vendor/ora/license +9 -0
  76. package/vendor/cli/dist/vendor/ora/package.json +64 -0
  77. package/vendor/cli/dist/vendor/ora/readme.md +329 -0
  78. package/vendor/cli/package.json +2 -2
  79. package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
  80. package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
  81. package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
  82. package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
  83. package/vendor/connector-sdk/dist/connector-types.d.ts +159 -45
  84. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
  85. package/vendor/connector-sdk/dist/define-connector.js +3 -0
  86. package/vendor/connector-sdk/dist/index.d.ts +5 -2
  87. package/vendor/connector-sdk/dist/index.js +1 -0
  88. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
  89. package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
  90. package/vendor/connector-sdk/package.json +5 -1
  91. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +31 -27
  92. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +131 -185
  93. package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
  94. package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
  95. package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
  96. package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
  97. package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
  98. package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
  99. package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
  100. package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
  101. package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
  102. package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
  103. package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
  104. package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
  105. package/vendor/connector-worker/dist/daemon/client.d.ts +5 -1
  106. package/vendor/connector-worker/dist/daemon/client.js +3 -0
  107. package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
  108. package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
  109. package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
  110. package/vendor/connector-worker/dist/daemon/executor.js +48 -117
  111. package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
  112. package/vendor/connector-worker/dist/daemon/log.js +23 -2
  113. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +20 -4
  114. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +53 -13
  115. package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
  116. package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
  117. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +2 -0
  118. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
  119. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
  120. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
  121. package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
  122. package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
  123. package/vendor/connector-worker/dist/daemon/start.js +12 -5
  124. package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
  125. package/vendor/connector-worker/dist/executor/isolate.js +66 -15
  126. package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
  127. package/vendor/connector-worker/dist/executor/redact.js +97 -26
  128. package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
  129. package/vendor/connector-worker/dist/executor/runtime.js +26 -0
  130. package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
  131. package/vendor/connector-worker/dist/mac-device-daemon.js +10 -3
  132. package/vendor/connector-worker/package.json +2 -2
  133. package/vendor/core/dist/agent-policy.js +1 -1
  134. package/vendor/core/dist/agent-store.d.ts +2 -0
  135. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  136. package/vendor/core/dist/agent-tooling.js +1 -1
  137. package/vendor/core/dist/capabilities.js +2 -0
  138. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
  139. package/vendor/core/dist/contracts/agent-settings.js +1 -7
  140. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
  141. package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
  142. package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
  143. package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
  144. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
  145. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
  146. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
  147. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
  148. package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
  149. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
  150. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
  151. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
  152. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
  153. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
  154. package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
  155. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
  156. package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
  157. package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
  158. package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
  159. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
  160. package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
  161. package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
  162. package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
  163. package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
  164. package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
  165. package/vendor/core/dist/contracts/worker/protocol.d.ts +122 -28
  166. package/vendor/core/dist/contracts/worker/protocol.js +81 -17
  167. package/vendor/core/dist/index.d.ts +3 -4
  168. package/vendor/core/dist/index.js +3 -6
  169. package/vendor/core/dist/json-template.d.ts +6 -10
  170. package/vendor/core/dist/json-template.js +5 -9
  171. package/vendor/core/dist/logger.js +11 -5
  172. package/vendor/core/dist/shell-safety.d.ts +9 -0
  173. package/vendor/core/dist/shell-safety.js +154 -0
  174. package/vendor/core/dist/suggestions.d.ts +1 -1
  175. package/vendor/core/dist/suggestions.js +1 -1
  176. package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
  177. package/vendor/core/dist/tool-trace-summary.js +1 -1
  178. package/vendor/core/dist/types.d.ts +1 -3
  179. package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
  180. package/vendor/core/dist/utils/{sentry-scrubber.js → diagnostic-scrubber.js} +25 -53
  181. package/vendor/core/dist/worker/auth.d.ts +44 -6
  182. package/vendor/core/dist/worker/auth.js +44 -11
  183. package/vendor/core/package.json +15 -6
  184. package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  185. package/vendor/ora/index.d.ts +332 -0
  186. package/vendor/ora/index.js +424 -0
  187. package/vendor/ora/license +9 -0
  188. package/vendor/ora/package.json +53 -0
  189. package/vendor/ora/readme.md +329 -0
  190. package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
  191. package/vendor/cli/dist/commands/telemetry.js +0 -66
  192. package/vendor/core/dist/sentry.d.ts +0 -26
  193. package/vendor/core/dist/sentry.js +0 -133
  194. package/vendor/core/dist/tool-policy.d.ts +0 -74
  195. package/vendor/core/dist/tool-policy.js +0 -305
  196. package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * GitHub Connector (V1 runtime)
3
3
  *
4
- * Syncs GitHub repository content and executes write actions. Also subscribes
5
- * to real-time issue/PR/comment deliveries via inbound webhooks (registered at
6
- * connect time); the raw deliveries are landed downstream (extract-load), so
7
- * this connector only owns the subscription lifecycle here.
4
+ * Syncs GitHub repository content and executes write actions. Provider
5
+ * deliveries (the App webhook, or a per-connection hook for OAuth/PAT) mark the
6
+ * matching feed due; star deliveries are recorded directly through the
7
+ * stargazers feed's `normalize`, keyed on the poll's origin_id.
8
8
  */
9
9
 
10
10
  import { randomBytes } from 'node:crypto';
@@ -17,9 +17,11 @@ import {
17
17
  createHttpClient,
18
18
  type EventAttributionRule,
19
19
  type EventEnvelope,
20
+ type FeedWebhookDeclaration,
20
21
  SubscriptionCandidateSchema,
21
22
  type SyncContext,
22
23
  type SyncResult,
24
+ type WebhookRecordContext,
23
25
  type WebhookRegistration,
24
26
  type WebhookRegistrationContext,
25
27
  } from '@lobu/connector-sdk';
@@ -35,6 +37,7 @@ import {
35
37
  githubUserIdentityKey,
36
38
  normalizeGithubLogin,
37
39
  normalizeGithubRepoFullName,
40
+ resolveGithubToken,
38
41
  } from './github-identity.js';
39
42
 
40
43
  type GitHubContentType =
@@ -377,12 +380,19 @@ const GITHUB_REPO_ATTRIBUTION: EventAttributionRule = {
377
380
  },
378
381
  };
379
382
 
383
+ // A delivery belongs to the repo feeds configured for its repository. GitHub
384
+ // owner/repo names are case-insensitive.
385
+ const GITHUB_REPO_MATCH: FeedWebhookDeclaration['match'] = {
386
+ fields: { repo_owner: 'repository.owner.login', repo_name: 'repository.name' },
387
+ caseInsensitive: true,
388
+ };
389
+
380
390
  export default class GitHubConnector extends ConnectorRuntime {
381
391
  readonly definition: RuntimeConnectorDefinition = {
382
392
  key: 'github',
383
393
  name: 'GitHub',
384
394
  description: 'Collects GitHub issues/discussions and executes repo actions.',
385
- version: '1.3.0',
395
+ version: '1.5.0',
386
396
  automationEvents: GITHUB_AUTOMATION_EVENTS,
387
397
  faviconDomain: 'github.com',
388
398
  // A GitHub connection gives the agent's sandbox an authenticated `gh`.
@@ -400,6 +410,7 @@ export default class GitHubConnector extends ConnectorRuntime {
400
410
  algorithm: 'sha256',
401
411
  signaturePrefix: 'sha256=',
402
412
  dedupeHeader: 'x-github-delivery',
413
+ eventType: { header: 'x-github-event' },
403
414
  // App-installation delivery: one App-level webhook is configured ONCE on
404
415
  // the GitHub App (not per connection), and inbound deliveries route via
405
416
  // the shared `/api/v1/app-webhooks/github` endpoint keyed on
@@ -468,10 +479,11 @@ export default class GitHubConnector extends ConnectorRuntime {
468
479
  type: 'oauth',
469
480
  provider: 'github',
470
481
  requiredScopes: ['read:user'],
471
- // Webhook scopes are OPTIONAL and requested incrementally — only when
472
- // the user enables a live feed (repo) or org-wide ingestion (org), not
473
- // at first connect. `repo` covers reads of private repos.
474
- optionalScopes: ['repo', 'admin:repo_hook', 'admin:org_hook'],
482
+ // OPTIONAL scopes are requested only when selected, never at first
483
+ // connect. `repo` covers private-repo reads and write actions; listing
484
+ // repository collaborators for access sync needs `read:org` alongside
485
+ // `repo`; the hook scopes back live feeds and org-wide ingestion.
486
+ optionalScopes: ['repo', 'read:org', 'admin:repo_hook', 'admin:org_hook'],
475
487
  loginScopes: ['read:user', 'user:email'],
476
488
  clientIdKey: 'GITHUB_CLIENT_ID',
477
489
  clientSecretKey: 'GITHUB_CLIENT_SECRET',
@@ -479,7 +491,7 @@ export default class GitHubConnector extends ConnectorRuntime {
479
491
  tokenEndpointAuthMethod: 'client_secret_post',
480
492
  required: false,
481
493
  description:
482
- 'GitHub OAuth enables repo access for this connection. Upgrade to the optional repo scope for private repositories and write actions.',
494
+ 'GitHub OAuth enables repo access for this connection. Upgrade to repo for private repositories and write actions; add read:org to synchronize repository access permissions.',
483
495
  loginProvisioning: {
484
496
  autoCreateConnection: true,
485
497
  },
@@ -509,7 +521,7 @@ export default class GitHubConnector extends ConnectorRuntime {
509
521
  requiredScopes: [],
510
522
  description: 'Sync GitHub issues from a repository.',
511
523
  displayNameTemplate: '{repo_owner}/{repo_name} issues',
512
- webhook: { events: ['issues'] },
524
+ webhook: { events: ['issues'], match: GITHUB_REPO_MATCH },
513
525
  configSchema: {
514
526
  type: 'object',
515
527
  required: ['repo_owner', 'repo_name'],
@@ -542,7 +554,7 @@ export default class GitHubConnector extends ConnectorRuntime {
542
554
  requiredScopes: [],
543
555
  description: 'Sync GitHub pull requests from a repository.',
544
556
  displayNameTemplate: '{repo_owner}/{repo_name} PRs',
545
- webhook: { events: ['pull_request'] },
557
+ webhook: { events: ['pull_request'], match: GITHUB_REPO_MATCH },
546
558
  configSchema: {
547
559
  type: 'object',
548
560
  required: ['repo_owner', 'repo_name'],
@@ -575,7 +587,7 @@ export default class GitHubConnector extends ConnectorRuntime {
575
587
  requiredScopes: [],
576
588
  description: 'Sync comments on GitHub issues.',
577
589
  displayNameTemplate: '{repo_owner}/{repo_name} issue comments',
578
- webhook: { events: ['issue_comment'] },
590
+ webhook: { events: ['issue_comment'], match: GITHUB_REPO_MATCH },
579
591
  configSchema: {
580
592
  type: 'object',
581
593
  required: ['repo_owner', 'repo_name'],
@@ -604,7 +616,7 @@ export default class GitHubConnector extends ConnectorRuntime {
604
616
  requiredScopes: [],
605
617
  description: 'Sync comments on GitHub pull requests.',
606
618
  displayNameTemplate: '{repo_owner}/{repo_name} PR comments',
607
- webhook: { events: ['pull_request_review_comment'] },
619
+ webhook: { events: ['pull_request_review_comment'], match: GITHUB_REPO_MATCH },
608
620
  configSchema: {
609
621
  type: 'object',
610
622
  required: ['repo_owner', 'repo_name'],
@@ -633,7 +645,7 @@ export default class GitHubConnector extends ConnectorRuntime {
633
645
  requiredScopes: [],
634
646
  description: 'Sync GitHub discussions from a repository.',
635
647
  displayNameTemplate: '{repo_owner}/{repo_name} discussions',
636
- webhook: { events: ['discussion'] },
648
+ webhook: { events: ['discussion'], match: GITHUB_REPO_MATCH },
637
649
  configSchema: {
638
650
  type: 'object',
639
651
  required: ['repo_owner', 'repo_name'],
@@ -665,7 +677,7 @@ export default class GitHubConnector extends ConnectorRuntime {
665
677
  requiredScopes: [],
666
678
  description: 'Sync comments on GitHub discussions.',
667
679
  displayNameTemplate: '{repo_owner}/{repo_name} discussion comments',
668
- webhook: { events: ['discussion_comment'] },
680
+ webhook: { events: ['discussion_comment'], match: GITHUB_REPO_MATCH },
669
681
  configSchema: {
670
682
  type: 'object',
671
683
  required: ['repo_owner', 'repo_name'],
@@ -695,7 +707,7 @@ export default class GitHubConnector extends ConnectorRuntime {
695
707
  requiredScopes: [],
696
708
  description: 'Sync commits pushed to a repository, attributed to their authors.',
697
709
  displayNameTemplate: '{repo_owner}/{repo_name} commits',
698
- webhook: { events: ['push'] },
710
+ webhook: { events: ['push'], match: GITHUB_REPO_MATCH },
699
711
  configSchema: {
700
712
  type: 'object',
701
713
  required: ['repo_owner', 'repo_name'],
@@ -726,7 +738,12 @@ export default class GitHubConnector extends ConnectorRuntime {
726
738
  requiredScopes: [],
727
739
  description: 'Sync GitHub users who starred a repository.',
728
740
  displayNameTemplate: '{repo_owner}/{repo_name} stargazers',
729
- webhook: { events: ['star', 'watch'], mode: 'store' },
741
+ webhook: {
742
+ events: ['star', 'watch'],
743
+ kind: 'record',
744
+ match: GITHUB_REPO_MATCH,
745
+ normalize: (payload, ctx) => this.normalizeStarDelivery(payload, ctx),
746
+ },
730
747
  configSchema: {
731
748
  type: 'object',
732
749
  required: ['repo_owner', 'repo_name'],
@@ -911,7 +928,7 @@ export default class GitHubConnector extends ConnectorRuntime {
911
928
  private async syncFeed(ctx: SyncContext): Promise<SyncResult> {
912
929
  const config = ctx.config as GitHubConfig;
913
930
  const repo = this.resolveRepo(config, {});
914
- const token = this.resolveToken(ctx.credentials?.accessToken, config);
931
+ const token = resolveGithubToken(ctx.credentials?.accessToken, config);
915
932
  const contentType = (ctx.feedKey ?? 'issues') as GitHubContentType;
916
933
  // Cold start / checkpoint reset: resolveSince falls back to lookback_days
917
934
  // (default 365). Every PR in that window is first-seen and would flood
@@ -963,7 +980,7 @@ export default class GitHubConnector extends ConnectorRuntime {
963
980
  try {
964
981
  const config = ctx.config as GitHubConfig;
965
982
  const repo = this.resolveRepo(config, ctx.input);
966
- const token = this.resolveToken(ctx.credentials?.accessToken, config);
983
+ const token = resolveGithubToken(ctx.credentials?.accessToken, config);
967
984
 
968
985
  if (!token) {
969
986
  return { success: false, error: 'GitHub action requires OAuth or GITHUB_TOKEN.' };
@@ -994,7 +1011,7 @@ export default class GitHubConnector extends ConnectorRuntime {
994
1011
  }
995
1012
 
996
1013
  // -------------------------------------------------------------------------
997
- // Webhooks (subscription lifecycle — raw deliveries land downstream)
1014
+ // Webhooks (subscription lifecycle; the platform dispatches deliveries)
998
1015
  // -------------------------------------------------------------------------
999
1016
 
1000
1017
  /**
@@ -1046,7 +1063,7 @@ export default class GitHubConnector extends ConnectorRuntime {
1046
1063
  return { externalId: '', metadata: { delivery: 'app_installation', noop: true } };
1047
1064
  }
1048
1065
 
1049
- const token = this.resolveToken(ctx.credentials?.accessToken, ctx.config);
1066
+ const token = resolveGithubToken(ctx.credentials?.accessToken, ctx.config);
1050
1067
  if (!token) {
1051
1068
  throw new Error('GitHub webhook registration requires OAuth or GITHUB_TOKEN.');
1052
1069
  }
@@ -1067,10 +1084,9 @@ export default class GitHubConnector extends ConnectorRuntime {
1067
1084
  body: {
1068
1085
  name: 'web',
1069
1086
  active: true,
1070
- // Subscribe to EVERY event type (extract-load: land it all raw, filter
1071
- // downstream). Org-wide this captures pushes, PRs, issues, comments,
1072
- // releases, CI runs, stars, membership changes, etc. across all repos.
1073
- // Override with config.webhook_events for a narrower subscription.
1087
+ // Subscribe to every event type; the platform dispatches only the
1088
+ // events a feed declares and acks the rest. Override with
1089
+ // config.webhook_events for a narrower subscription.
1074
1090
  events: ctx.config.webhook_events ?? ['*'],
1075
1091
  config: {
1076
1092
  url: ctx.callbackUrl,
@@ -1093,7 +1109,7 @@ export default class GitHubConnector extends ConnectorRuntime {
1093
1109
  const externalId = ctx.externalId;
1094
1110
  if (!externalId) return;
1095
1111
 
1096
- const token = this.resolveToken(ctx.credentials?.accessToken, ctx.config);
1112
+ const token = resolveGithubToken(ctx.credentials?.accessToken, ctx.config);
1097
1113
  if (!token) return;
1098
1114
 
1099
1115
  const base = this.hooksApiUrl(ctx.config);
@@ -1125,20 +1141,6 @@ export default class GitHubConnector extends ConnectorRuntime {
1125
1141
  return { owner, repo };
1126
1142
  }
1127
1143
 
1128
- private resolveToken(oauthToken: string | undefined, config: GitHubConfig): string | null {
1129
- if (oauthToken && oauthToken.trim().length > 0) {
1130
- return oauthToken;
1131
- }
1132
-
1133
- const envOverrides = config.env_overrides ?? {};
1134
- const configuredToken =
1135
- asString(envOverrides.GITHUB_TOKEN) ??
1136
- asString((config as Record<string, unknown>).GITHUB_TOKEN) ??
1137
- asString((config as Record<string, unknown>).github_token);
1138
-
1139
- return configuredToken ?? null;
1140
- }
1141
-
1142
1144
  private resolveSince(checkpoint: Record<string, unknown> | null, lookbackDays: number): string {
1143
1145
  const cp = (checkpoint ?? {}) as GitHubCheckpoint;
1144
1146
  const fromCheckpoint = toIsoOrUndefined(cp.last_sync_at);
@@ -1676,24 +1678,7 @@ export default class GitHubConnector extends ConnectorRuntime {
1676
1678
  });
1677
1679
 
1678
1680
  if (!previousStargazer) {
1679
- events.push({
1680
- origin_id: `stargazer_${repo.owner}_${repo.repo}_${githubKeyForOriginId(key)}`,
1681
- title: `${login} starred ${repo.owner}/${repo.repo}`,
1682
- payload_text: `${login} starred ${repo.owner}/${repo.repo}.`,
1683
- author_name: login,
1684
- source_url: user.html_url ?? `https://github.com/${login}`,
1685
- occurred_at: starredAt,
1686
- origin_type: 'stargazer',
1687
- score: 1,
1688
- metadata: {
1689
- actor: this.buildActor(user, login),
1690
- target,
1691
- action: 'starred',
1692
- starred_at: starredAt.toISOString(),
1693
- source: 'github_stargazers_snapshot',
1694
- ...this.buildAuthorMetadata({ login, id: user.id }),
1695
- },
1696
- });
1681
+ events.push(this.stargazerEvent({ repo, user, login, starredAt, target, source: 'github_stargazers_snapshot' }));
1697
1682
  }
1698
1683
  }
1699
1684
  const current = [...new Map(currentStargazers.map(star => [star.key, star])).values()];
@@ -1729,6 +1714,63 @@ export default class GitHubConnector extends ConnectorRuntime {
1729
1714
  return { events, checkpoint: { last_sync_at: scan.started_at, stargazers: current }, status: 'complete' };
1730
1715
  }
1731
1716
 
1717
+ /** The `stargazer` envelope the poll and a live star delivery share, so both key one origin_id. */
1718
+ private stargazerEvent(params: {
1719
+ repo: RepoRef;
1720
+ user: GitHubStargazerLike['user'] | GitHubStargazerLike;
1721
+ login: string;
1722
+ starredAt: Date;
1723
+ target: ReturnType<GitHubConnector['buildRepoTarget']>;
1724
+ source: string;
1725
+ }): EventEnvelope {
1726
+ const { repo, user, login, starredAt } = params;
1727
+ const key = githubUserIdentityKey({ userId: user?.id, login });
1728
+ return {
1729
+ origin_id: `stargazer_${repo.owner}_${repo.repo}_${githubKeyForOriginId(key)}`,
1730
+ title: `${login} starred ${repo.owner}/${repo.repo}`,
1731
+ payload_text: `${login} starred ${repo.owner}/${repo.repo}.`,
1732
+ author_name: login,
1733
+ source_url: user?.html_url ?? `https://github.com/${login}`,
1734
+ occurred_at: starredAt,
1735
+ origin_type: 'stargazer',
1736
+ score: 1,
1737
+ metadata: {
1738
+ actor: this.buildActor(user, login),
1739
+ target: params.target,
1740
+ action: 'starred',
1741
+ starred_at: starredAt.toISOString(),
1742
+ source: params.source,
1743
+ ...this.buildAuthorMetadata({ login, id: user?.id }),
1744
+ },
1745
+ };
1746
+ }
1747
+
1748
+ /**
1749
+ * Record a live star delivery as the stargazer event the poll emits for the
1750
+ * same user. Only a new star records; an unstar is left to the poll's
1751
+ * snapshot diff. The feed config (not the payload's display casing) names
1752
+ * the repo, so the origin_id matches the poll's.
1753
+ */
1754
+ private normalizeStarDelivery(payload: unknown, ctx: WebhookRecordContext): EventEnvelope | null {
1755
+ const body = payload && typeof payload === 'object' ? (payload as Record<string, unknown>) : null;
1756
+ const action = asString(body?.action);
1757
+ const starred = ctx.eventType === 'star' ? action === 'created' : ctx.eventType === 'watch' && action === 'started';
1758
+ const sender = body?.sender as GitHubStargazerLike | undefined;
1759
+ const login = asString(sender?.login);
1760
+ if (!body || !starred || !login) return null;
1761
+ const repo = this.resolveRepo(ctx.config as GitHubConfig, {});
1762
+ const event = this.stargazerEvent({
1763
+ repo,
1764
+ user: sender,
1765
+ login,
1766
+ starredAt: new Date(toIsoOrUndefined(body.starred_at) ?? ctx.receivedAt),
1767
+ target: this.buildRepoTarget(repo, (body.repository ?? {}) as GitHubRepositoryLike),
1768
+ source: 'github_star_webhook',
1769
+ });
1770
+ this.stampRepoAttribution([event], repo, { attachAutomationSignals: false });
1771
+ return event;
1772
+ }
1773
+
1732
1774
  private shouldRefreshStargazerProfile(
1733
1775
  previous: GitHubStargazerCheckpoint | undefined,
1734
1776
  now: Date