@mastra/factory 0.30.0-alpha.4 → 0.31.0-alpha.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 (148) hide show
  1. package/README.md +32 -10
  2. package/dist/factory.d.ts +12 -1
  3. package/dist/factory.d.ts.map +1 -1
  4. package/dist/factory.js +72 -31
  5. package/dist/factory.js.map +1 -1
  6. package/dist/integrations/gitlab/api.d.ts +3 -2
  7. package/dist/integrations/gitlab/api.d.ts.map +1 -1
  8. package/dist/integrations/gitlab/api.js +12 -9
  9. package/dist/integrations/gitlab/api.js.map +1 -1
  10. package/dist/integrations/issue-reconcile-worker.d.ts +5 -0
  11. package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -1
  12. package/dist/integrations/issue-reconcile-worker.js +17 -1
  13. package/dist/integrations/issue-reconcile-worker.js.map +1 -1
  14. package/dist/integrations/platform/connect/routes.d.ts +22 -13
  15. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  16. package/dist/integrations/platform/connect/routes.js +63 -64
  17. package/dist/integrations/platform/connect/routes.js.map +1 -1
  18. package/dist/integrations/platform/foundation/connect-binding.d.ts +125 -0
  19. package/dist/integrations/platform/foundation/connect-binding.d.ts.map +1 -0
  20. package/dist/integrations/platform/foundation/connect-binding.js +252 -0
  21. package/dist/integrations/platform/foundation/connect-binding.js.map +1 -0
  22. package/dist/integrations/platform/foundation/connect-event-poller.d.ts +49 -0
  23. package/dist/integrations/platform/foundation/connect-event-poller.d.ts.map +1 -0
  24. package/dist/integrations/platform/foundation/connect-event-poller.js +304 -0
  25. package/dist/integrations/platform/foundation/connect-event-poller.js.map +1 -0
  26. package/dist/integrations/platform/foundation/connect-events.d.ts +31 -0
  27. package/dist/integrations/platform/foundation/connect-events.d.ts.map +1 -0
  28. package/dist/integrations/platform/foundation/connect-events.js +7 -0
  29. package/dist/integrations/platform/foundation/connect-events.js.map +1 -0
  30. package/dist/integrations/platform/foundation/index.d.ts +10 -0
  31. package/dist/integrations/platform/foundation/index.d.ts.map +1 -0
  32. package/dist/integrations/platform/foundation/index.js +6 -0
  33. package/dist/integrations/platform/foundation/intake.d.ts +39 -0
  34. package/dist/integrations/platform/foundation/intake.d.ts.map +1 -0
  35. package/dist/integrations/platform/foundation/intake.js +45 -0
  36. package/dist/integrations/platform/foundation/intake.js.map +1 -0
  37. package/dist/integrations/platform/foundation/integration.d.ts +84 -0
  38. package/dist/integrations/platform/foundation/integration.d.ts.map +1 -0
  39. package/dist/integrations/platform/foundation/integration.js +107 -0
  40. package/dist/integrations/platform/foundation/integration.js.map +1 -0
  41. package/dist/integrations/platform/github/event-worker.d.ts +2 -2
  42. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  43. package/dist/integrations/platform/github/event-worker.js +4 -8
  44. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  45. package/dist/integrations/platform/github/integration.d.ts +3 -0
  46. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  47. package/dist/integrations/platform/github/integration.js +131 -70
  48. package/dist/integrations/platform/github/integration.js.map +1 -1
  49. package/dist/integrations/platform/gitlab/connect-events.d.ts +22 -0
  50. package/dist/integrations/platform/gitlab/connect-events.d.ts.map +1 -0
  51. package/dist/integrations/platform/gitlab/connect-events.js +49 -0
  52. package/dist/integrations/platform/gitlab/connect-events.js.map +1 -0
  53. package/dist/integrations/platform/gitlab/integration.d.ts +24 -15
  54. package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -1
  55. package/dist/integrations/platform/gitlab/integration.js +61 -26
  56. package/dist/integrations/platform/gitlab/integration.js.map +1 -1
  57. package/dist/integrations/platform/incidentio/intake.d.ts +33 -0
  58. package/dist/integrations/platform/incidentio/intake.d.ts.map +1 -0
  59. package/dist/integrations/platform/incidentio/intake.js +271 -0
  60. package/dist/integrations/platform/incidentio/intake.js.map +1 -0
  61. package/dist/integrations/platform/incidentio/integration.d.ts +11 -23
  62. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
  63. package/dist/integrations/platform/incidentio/integration.js +27 -297
  64. package/dist/integrations/platform/incidentio/integration.js.map +1 -1
  65. package/dist/integrations/platform/jira/intake.d.ts +60 -0
  66. package/dist/integrations/platform/jira/intake.d.ts.map +1 -0
  67. package/dist/integrations/platform/jira/intake.js +445 -0
  68. package/dist/integrations/platform/jira/intake.js.map +1 -0
  69. package/dist/integrations/platform/jira/integration.d.ts +13 -37
  70. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  71. package/dist/integrations/platform/jira/integration.js +29 -468
  72. package/dist/integrations/platform/jira/integration.js.map +1 -1
  73. package/dist/integrations/platform/linear/event-worker.d.ts +2 -2
  74. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
  75. package/dist/integrations/platform/linear/event-worker.js +5 -9
  76. package/dist/integrations/platform/linear/event-worker.js.map +1 -1
  77. package/dist/integrations/platform/linear/integration.d.ts +3 -1
  78. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  79. package/dist/integrations/platform/linear/integration.js +9 -9
  80. package/dist/integrations/platform/linear/integration.js.map +1 -1
  81. package/dist/integrations/platform/logging.d.ts +6 -0
  82. package/dist/integrations/platform/logging.d.ts.map +1 -0
  83. package/dist/integrations/platform/logging.js +25 -0
  84. package/dist/integrations/platform/logging.js.map +1 -0
  85. package/dist/integrations/platform/platform-connect.d.ts +38 -0
  86. package/dist/integrations/platform/platform-connect.d.ts.map +1 -0
  87. package/dist/integrations/platform/platform-connect.js +109 -0
  88. package/dist/integrations/platform/platform-connect.js.map +1 -0
  89. package/dist/integrations/platform/vanta/integration.d.ts +12 -18
  90. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
  91. package/dist/integrations/platform/vanta/integration.js +38 -38
  92. package/dist/integrations/platform/vanta/integration.js.map +1 -1
  93. package/dist/memory-embedder.d.ts +11 -0
  94. package/dist/memory-embedder.d.ts.map +1 -0
  95. package/dist/memory-embedder.js +19 -0
  96. package/dist/memory-embedder.js.map +1 -0
  97. package/dist/metrics/config.d.ts +1 -1
  98. package/dist/metrics/config.d.ts.map +1 -1
  99. package/dist/metrics/config.js +1 -0
  100. package/dist/metrics/config.js.map +1 -1
  101. package/dist/metrics/index.js +2 -2
  102. package/dist/metrics/index.js.map +1 -1
  103. package/dist/metrics/sandbox.d.ts +3 -3
  104. package/dist/metrics/sandbox.js +13 -13
  105. package/dist/metrics/sandbox.js.map +1 -1
  106. package/dist/metrics/session.d.ts +28 -0
  107. package/dist/metrics/session.d.ts.map +1 -0
  108. package/dist/metrics/session.js +76 -0
  109. package/dist/metrics/session.js.map +1 -0
  110. package/dist/routes/source-control-sessions.d.ts +5 -0
  111. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  112. package/dist/routes/source-control-sessions.js +65 -7
  113. package/dist/routes/source-control-sessions.js.map +1 -1
  114. package/dist/routes/surface.d.ts +5 -0
  115. package/dist/routes/surface.d.ts.map +1 -1
  116. package/dist/routes/surface.js +1 -0
  117. package/dist/routes/surface.js.map +1 -1
  118. package/dist/rules/dispatcher.d.ts.map +1 -1
  119. package/dist/rules/dispatcher.js.map +1 -1
  120. package/dist/rules/processor.d.ts +29 -1
  121. package/dist/rules/processor.d.ts.map +1 -1
  122. package/dist/rules/processor.js +156 -23
  123. package/dist/rules/processor.js.map +1 -1
  124. package/dist/rules/public-failure-reason.js +1 -1
  125. package/dist/rules/public-failure-reason.js.map +1 -1
  126. package/dist/rules/transition-service.d.ts.map +1 -1
  127. package/dist/rules/transition-service.js +33 -9
  128. package/dist/rules/transition-service.js.map +1 -1
  129. package/dist/storage/domains/work-items/base.d.ts +2 -0
  130. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  131. package/dist/storage/domains/work-items/base.js +4 -2
  132. package/dist/storage/domains/work-items/base.js.map +1 -1
  133. package/dist/work-item-branch.d.ts +7 -1
  134. package/dist/work-item-branch.d.ts.map +1 -1
  135. package/dist/work-item-branch.js +9 -1
  136. package/dist/work-item-branch.js.map +1 -1
  137. package/dist/work-items/card-facts.d.ts.map +1 -1
  138. package/dist/work-items/card-facts.js +2 -2
  139. package/dist/work-items/card-facts.js.map +1 -1
  140. package/package.json +13 -13
  141. package/dist/integrations/platform/api-client.d.ts +0 -34
  142. package/dist/integrations/platform/api-client.d.ts.map +0 -1
  143. package/dist/integrations/platform/api-client.js +0 -186
  144. package/dist/integrations/platform/api-client.js.map +0 -1
  145. package/dist/integrations/platform/gitlab/event-worker.d.ts +0 -64
  146. package/dist/integrations/platform/gitlab/event-worker.d.ts.map +0 -1
  147. package/dist/integrations/platform/gitlab/event-worker.js +0 -304
  148. package/dist/integrations/platform/gitlab/event-worker.js.map +0 -1
@@ -0,0 +1,107 @@
1
+ import { IssueReconcileWorker } from "../../issue-reconcile-worker.js";
2
+ import { PlatformConnectBinding } from "./connect-binding.js";
3
+ // src/integrations/platform/foundation/integration.ts
4
+ /** Reconciles run hourly unless an integration says otherwise. */
5
+ const DEFAULT_PLATFORM_RECONCILE_INTERVAL_MS = 36e5;
6
+ /**
7
+ * Base class for a Factory integration whose provider is reached through
8
+ * Mastra Connect. It owns the Connect client, project-scoped connection
9
+ * listing, the connection proxy, linking existing org connections to the
10
+ * Factory project, the provider's connect routes and the reconcile worker.
11
+ * Capabilities (`intake`, `versionControl`) are composed in by subclasses.
12
+ */
13
+ var PlatformConnectIntegration = class {
14
+ id;
15
+ binding;
16
+ #connectProviders;
17
+ #reconcileIntervalMs;
18
+ constructor(options) {
19
+ this.id = options.id;
20
+ this.binding = new PlatformConnectBinding({
21
+ integrationId: options.id,
22
+ providerKeys: options.providerKeys,
23
+ ...options.connect ? { connect: options.connect } : {},
24
+ ...options.linkOrgConnectionsAtBoot ? { linkOrgConnectionsAtBoot: true } : {},
25
+ ...options.connectionFilter ? { filter: options.connectionFilter } : {}
26
+ });
27
+ this.#connectProviders = options.connectProviders ?? [];
28
+ this.#reconcileIntervalMs = options.reconcileIntervalMs ?? options.reconcileDefaultIntervalMs ?? 36e5;
29
+ }
30
+ get connect() {
31
+ return this.binding.connect;
32
+ }
33
+ get providerKeys() {
34
+ return this.binding.providerKeys;
35
+ }
36
+ /** How often the reconcile worker runs. */
37
+ get reconcileIntervalMs() {
38
+ return this.#reconcileIntervalMs;
39
+ }
40
+ /** The project's `active` and `needs_reauth` connections for the integration's provider keys. */
41
+ listConnections(options) {
42
+ return this.binding.listConnections(options);
43
+ }
44
+ /** Active connections, sorted by id. */
45
+ activeConnections() {
46
+ return this.binding.activeConnections();
47
+ }
48
+ connectionFor(providerKey, predicate) {
49
+ return this.binding.connectionFor(providerKey, predicate);
50
+ }
51
+ invalidateConnections() {
52
+ this.binding.invalidateConnections();
53
+ }
54
+ proxy(connectionId, request) {
55
+ return this.binding.proxy(connectionId, request);
56
+ }
57
+ linkOrgConnections() {
58
+ return this.binding.linkOrgConnections();
59
+ }
60
+ get needsLinking() {
61
+ return this.binding.needsLinking;
62
+ }
63
+ platformConnectProviders() {
64
+ return this.#connectProviders.map((provider) => ({
65
+ provider: provider.provider,
66
+ integrationId: provider.integrationId,
67
+ connectionIntegrationIds: provider.connectionIntegrationIds ?? [provider.integrationId],
68
+ binding: this.binding
69
+ }));
70
+ }
71
+ /**
72
+ * The reconciler the reconcile worker runs, or null when the integration
73
+ * has nothing to reconcile in this context. Integrations without a
74
+ * reconcile return null.
75
+ */
76
+ reconcile(_ctx) {
77
+ return null;
78
+ }
79
+ /**
80
+ * Starts boot linking (non-blocking) and returns the reconcile worker, when
81
+ * the integration reconciles. Linking that adds a connection triggers one
82
+ * extra reconcile.
83
+ */
84
+ workers(ctx) {
85
+ this.binding.ensureBootLinked();
86
+ const reconcile = this.reconcile(ctx);
87
+ if (!reconcile) return [];
88
+ const worker = new IssueReconcileWorker({
89
+ integrationId: this.id,
90
+ reconcile,
91
+ intervalMs: this.#reconcileIntervalMs
92
+ });
93
+ this.binding.onConnectionsLinked(() => worker.requestRun());
94
+ return [worker];
95
+ }
96
+ diagnostics() {
97
+ const needsLinking = this.needsLinking;
98
+ return {
99
+ configured: true,
100
+ mode: "platform",
101
+ ...needsLinking.length > 0 ? { needsLinking } : {}
102
+ };
103
+ }
104
+ };
105
+ export { DEFAULT_PLATFORM_RECONCILE_INTERVAL_MS, PlatformConnectIntegration };
106
+
107
+ //# sourceMappingURL=integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.js","names":[],"sources":["../../../../src/integrations/platform/foundation/integration.ts"],"sourcesContent":["import type { ConnectClient, ProxyRequestOptions } from '@mastra/connect';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { FactoryIntegration, IntegrationContext } from '../../base.js';\nimport { IssueReconcileWorker } from '../../issue-reconcile-worker.js';\nimport type { IssueReconciler } from '../../issue-reconciler.js';\nimport type { PlatformConnectProviderRegistration, PlatformConnectProviderSource } from '../connect/routes.js';\nimport type { PlatformConnectOption } from '../platform-connect.js';\nimport { PlatformConnectBinding } from './connect-binding.js';\nimport type { LinkOrgConnectionsResult, NeedsLinkingEntry, PlatformConnection } from './connect-binding.js';\n\n/** Reconciles run hourly unless an integration says otherwise. */\nexport const DEFAULT_PLATFORM_RECONCILE_INTERVAL_MS = 60 * 60_000;\n\n/** A provider the integration registers with the platform connect routes. */\nexport interface PlatformConnectProvider {\n /** SPA-facing provider slug, the `:provider` path segment. */\n provider: string;\n /** Platform integration id used to mint connect sessions. */\n integrationId: string;\n /** Connection `integrationId` variants that belong to this provider. Defaults to `[integrationId]`. */\n connectionIntegrationIds?: readonly string[];\n}\n\nexport interface PlatformConnectIntegrationOptions {\n /** The integration's id, also its reconcile worker's name prefix. */\n id: string;\n /** Connect integration ids (provider keys) the integration owns. */\n providerKeys: readonly string[];\n connect?: PlatformConnectOption;\n /** Link the org's global connections for `providerKeys` to the Factory project at boot. */\n linkOrgConnectionsAtBoot?: boolean;\n /** Providers the integration exposes through the platform connect routes. */\n connectProviders?: readonly PlatformConnectProvider[];\n /** Narrows the provider's connections further, e.g. to one configured connection id. */\n connectionFilter?: (connection: PlatformConnection) => boolean;\n /**\n * The reconcile interval from the integration's constructor option or\n * environment variable. Takes precedence over `reconcileDefaultIntervalMs`.\n */\n reconcileIntervalMs?: number;\n /** The integration's own default reconcile interval, in place of hourly. */\n reconcileDefaultIntervalMs?: number;\n}\n\n/**\n * Base class for a Factory integration whose provider is reached through\n * Mastra Connect. It owns the Connect client, project-scoped connection\n * listing, the connection proxy, linking existing org connections to the\n * Factory project, the provider's connect routes and the reconcile worker.\n * Capabilities (`intake`, `versionControl`) are composed in by subclasses.\n */\nexport abstract class PlatformConnectIntegration implements FactoryIntegration, PlatformConnectProviderSource {\n readonly id: string;\n readonly binding: PlatformConnectBinding;\n readonly #connectProviders: readonly PlatformConnectProvider[];\n readonly #reconcileIntervalMs: number;\n\n constructor(options: PlatformConnectIntegrationOptions) {\n this.id = options.id;\n this.binding = new PlatformConnectBinding({\n integrationId: options.id,\n providerKeys: options.providerKeys,\n ...(options.connect ? { connect: options.connect } : {}),\n ...(options.linkOrgConnectionsAtBoot ? { linkOrgConnectionsAtBoot: true } : {}),\n ...(options.connectionFilter ? { filter: options.connectionFilter } : {}),\n });\n this.#connectProviders = options.connectProviders ?? [];\n this.#reconcileIntervalMs =\n options.reconcileIntervalMs ?? options.reconcileDefaultIntervalMs ?? DEFAULT_PLATFORM_RECONCILE_INTERVAL_MS;\n }\n\n get connect(): ConnectClient {\n return this.binding.connect;\n }\n\n get providerKeys(): readonly string[] {\n return this.binding.providerKeys;\n }\n\n /** How often the reconcile worker runs. */\n get reconcileIntervalMs(): number {\n return this.#reconcileIntervalMs;\n }\n\n /** The project's `active` and `needs_reauth` connections for the integration's provider keys. */\n listConnections(options?: { fresh?: boolean }): Promise<PlatformConnection[]> {\n return this.binding.listConnections(options);\n }\n\n /** Active connections, sorted by id. */\n activeConnections(): Promise<PlatformConnection[]> {\n return this.binding.activeConnections();\n }\n\n connectionFor(\n providerKey: string,\n predicate?: (connection: PlatformConnection) => boolean,\n ): Promise<PlatformConnection | null> {\n return this.binding.connectionFor(providerKey, predicate);\n }\n\n invalidateConnections(): void {\n this.binding.invalidateConnections();\n }\n\n proxy(connectionId: string, request: ProxyRequestOptions): Promise<unknown> {\n return this.binding.proxy(connectionId, request);\n }\n\n linkOrgConnections(): Promise<LinkOrgConnectionsResult> {\n return this.binding.linkOrgConnections();\n }\n\n get needsLinking(): NeedsLinkingEntry[] {\n return this.binding.needsLinking;\n }\n\n platformConnectProviders(): PlatformConnectProviderRegistration[] {\n return this.#connectProviders.map(provider => ({\n provider: provider.provider,\n integrationId: provider.integrationId,\n connectionIntegrationIds: provider.connectionIntegrationIds ?? [provider.integrationId],\n binding: this.binding,\n }));\n }\n\n /**\n * The reconciler the reconcile worker runs, or null when the integration\n * has nothing to reconcile in this context. Integrations without a\n * reconcile return null.\n */\n protected reconcile(_ctx: IntegrationContext): IssueReconciler | null {\n return null;\n }\n\n /**\n * Starts boot linking (non-blocking) and returns the reconcile worker, when\n * the integration reconciles. Linking that adds a connection triggers one\n * extra reconcile.\n */\n workers(ctx: IntegrationContext): MastraWorker[] {\n void this.binding.ensureBootLinked();\n const reconcile = this.reconcile(ctx);\n if (!reconcile) return [];\n const worker = new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n intervalMs: this.#reconcileIntervalMs,\n });\n this.binding.onConnectionsLinked(() => worker.requestRun());\n return [worker];\n }\n\n abstract routes(ctx: IntegrationContext): ApiRoute[];\n\n diagnostics(): Record<string, unknown> {\n const needsLinking = this.needsLinking;\n return {\n configured: true,\n mode: 'platform',\n ...(needsLinking.length > 0 ? { needsLinking } : {}),\n };\n }\n}\n"],"mappings":";;;;AAaA,MAAa,yCAAyC;;;;;;;;AAwCtD,IAAsB,6BAAtB,MAA8G;CAC5G;CACA;CACA;CACA;CAEA,YAAY,SAA4C;EACtD,KAAK,KAAK,QAAQ;EAClB,KAAK,UAAU,IAAI,uBAAuB;GACxC,eAAe,QAAQ;GACvB,cAAc,QAAQ;GACtB,GAAI,QAAQ,UAAU,EAAE,SAAS,QAAQ,QAAQ,IAA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Y,KAAK;EACnB,CAAC;EACD,KAAK,QAAQ,0BAA0B,OAAO,WAAW,CAAC;EAC1D,OAAO,CAAC,MAAM;CAChB;CAIA,cAAuC;EACrC,MAAM,eAAe,KAAK;EAC1B,OAAO;GACL,YAAY;GACZ,MAAM;GACN,GAAI,aAAa,SAAS,IAAI,EAAE,aAAa,IAAI,CAAC;EACpD;CACF;AACF"}
@@ -1,4 +1,5 @@
1
1
  import type { MountedMastraCode } from '@mastra/code-sdk';
2
+ import type { ConnectClient } from '@mastra/connect';
2
3
  import { MastraWorker } from '@mastra/core/worker';
3
4
  import type { WorkerDeps } from '@mastra/core/worker';
4
5
  import type { IntegrationStorageHandle } from '../../../storage/domains/integrations/base.js';
@@ -8,7 +9,6 @@ import type { GithubReconcileRepositorySource } from '../../github/reconcile-wor
8
9
  import type { GithubPullRequestDiscovery, GithubPullRequestReconciler } from '../../github/rules.js';
9
10
  import { dispatchGithubWebhook } from '../../github/webhook.js';
10
11
  import type { GithubWebhookDispatchIntegration, ParsedGithubWebhook } from '../../github/webhook.js';
11
- import type { PlatformApiClient } from '../api-client.js';
12
12
  type EventCursor = {
13
13
  afterEventId: string;
14
14
  } | {
@@ -21,7 +21,7 @@ type PlatformGithubEventWorkerSettings = {
21
21
  export type PlatformGithubEventStorage = IntegrationStorageHandle<Record<string, unknown>, PlatformGithubEventWorkerSettings, Record<string, unknown>>;
22
22
  export type PlatformGithubEventDispatchIntegration = GithubWebhookDispatchIntegration;
23
23
  export interface PlatformGithubEventWorkerConfig {
24
- client: PlatformApiClient;
24
+ client: ConnectClient;
25
25
  controller: MountedMastraCode['controller'];
26
26
  github: PlatformGithubEventDispatchIntegration;
27
27
  storage: PlatformGithubEventStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"event-worker.d.ts","sourceRoot":"","sources":["../../../../src/integrations/platform/github/event-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EA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AI,CAAC,CAoB3B;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAa1B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;CAwcF"}
@@ -2,7 +2,7 @@ import "../../dependabot/sync.js";
2
2
  import "../../github/reconcile-worker.js";
3
3
  import { listPullRequestSubscriptionsForWebhook, retirePullRequestSubscription } from "../../github/subscriptions.js";
4
4
  import { dispatchGithubWebhook, isFactoryAppSender, resolveAuthorizedBots } from "../../github/webhook.js";
5
- import { PlatformApiError } from "../api-client.js";
5
+ import { platformErrorStatus, platformRetryDelayMs } from "../platform-connect.js";
6
6
  import { NoopLeaseProvider, isLeaseProvider } from "@mastra/core/events";
7
7
  import { MastraWorker } from "@mastra/core/worker";
8
8
  // src/integrations/platform/github/event-worker.ts
@@ -163,7 +163,7 @@ var PlatformGithubEventWorker = class extends MastraWorker {
163
163
  if (!await this.#ensureLease()) return;
164
164
  nextDelay = await this.#poll();
165
165
  } catch (error) {
166
- nextDelay = retryDelay(error, this.#intervalMs);
166
+ nextDelay = platformRetryDelayMs(error, this.#intervalMs);
167
167
  this.deps?.logger.error("Platform GitHub event polling cycle failed", {
168
168
  error: error instanceof Error ? error.message : String(error),
169
169
  retryInMs: nextDelay
@@ -207,14 +207,14 @@ var PlatformGithubEventWorker = class extends MastraWorker {
207
207
  try {
208
208
  await this.#pollRepository(repository.id);
209
209
  } catch (error) {
210
- const delay = retryDelay(error, this.#intervalMs);
210
+ const delay = platformRetryDelayMs(error, this.#intervalMs);
211
211
  retryInMs = Math.max(retryInMs, delay);
212
212
  this.deps?.logger.error("Platform GitHub repository event polling failed", {
213
213
  repositoryId: repository.id,
214
214
  error: error instanceof Error ? error.message : String(error),
215
215
  retryInMs: delay
216
216
  });
217
- if (error instanceof PlatformApiError && error.status === 429) break;
217
+ if (platformErrorStatus(error) === 429) break;
218
218
  }
219
219
  }
220
220
  await this.#maybeReconcile(repositories);
@@ -570,10 +570,6 @@ function parseEvent(event) {
570
570
  payload: event.payload
571
571
  };
572
572
  }
573
- function retryDelay(error, fallbackMs) {
574
- if (error instanceof PlatformApiError && error.status === 429 && error.retryAfterSeconds !== null) return Math.max(fallbackMs, error.retryAfterSeconds * 1e3);
575
- return fallbackMs;
576
- }
577
573
  export { PlatformGithubEventWorker };
578
574
 
579
575
  //# sourceMappingURL=event-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-worker.js","names":[],"sources":["../../../../src/integrations/platform/github/event-worker.ts"],"sourcesContent":["import type { MountedMastraCode } from '@mastra/code-sdk';\nimport { isLeaseProvider, NoopLeaseProvider } from '@mastra/core/events';\nimport type { LeaseProvider, PubSub } from '@mastra/core/events';\nimport { MastraWorker } from '@mastra/core/worker';\nimport type { WorkerDeps } from '@mastra/core/worker';\n\nimport type { IntegrationStorageHandle } from '../../../storage/domains/integrations/base.js';\nimport type { ExternalRepositoryProjectTarget } from '../../../storage/domains/source-control/base.js';\nimport { DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS } from '../../dependabot/sync.js';\nimport type { DependabotSync } from '../../dependabot/sync.js';\nimport type { GithubRepositoryPermission } from '../../github/integration.js';\nimport type { GithubIssueReconciler } from '../../github/issue-reconciler.js';\nimport { DEFAULT_GITHUB_PR_DISCOVERY_INTERVAL_MS } from '../../github/reconcile-worker.js';\nimport type { GithubReconcileRepositorySource } from '../../github/reconcile-worker.js';\nimport type {\n GithubPullRequestDiscovery,\n GithubPullRequestReconciler,\n ReconcileRepository,\n} from '../../github/rules.js';\nimport { listPullRequestSubscriptionsForWebhook, retirePullRequestSubscription } from '../../github/subscriptions.js';\nimport { dispatchGithubWebhook, isFactoryAppSender, resolveAuthorizedBots } from '../../github/webhook.js';\nimport type {\n GithubWebhookDispatchIntegration,\n GithubWebhookNotification,\n ParsedGithubWebhook,\n} from '../../github/webhook.js';\nimport type { PlatformApiClient } from '../api-client.js';\nimport { PlatformApiError } from '../api-client.js';\n\nconst API_PREFIX = '/v1/server/github-app';\nconst DEFAULT_POLL_INTERVAL_MS = 20_000;\n// Event polling is the primary sync; the sweeps only catch drift (missed\n// events, cards ingested before polling was linked), so they run hourly.\nconst DEFAULT_RECONCILE_INTERVAL_MS = 60 * 60_000;\nconst EVENT_PAGE_SIZE = 500;\nconst MIN_LEASE_TTL_MS = 30_000;\nconst CURSOR_ORG_ID = '__platform_github_event_worker__';\nconst CURSOR_USER_ID = 'worker';\nconst SUPPORTED_EVENTS = new Set([\n 'issues',\n 'issue_comment',\n 'pull_request',\n 'pull_request_review',\n 'pull_request_review_comment',\n // Pushes never reach the subscription dispatcher; they feed the factory\n // ingest path so environment templates rebuild on default-branch updates.\n 'push',\n]);\n// Kinds emitted by `classifyGithubWebhook` that carry untrusted sender-authored\n// content and must pass the sender authorization gate below.\nconst AUTHOR_GATED_KINDS = new Set([\n 'issue-comment-created',\n 'review-comment-created',\n 'review-approved',\n 'review-changes-requested',\n 'review-submitted',\n 'review-dismissed',\n]);\nconst AUTHORIZED_PERMISSIONS = new Set<GithubRepositoryPermission>(['admin', 'maintain', 'write']);\nconst PERMISSION_CHECK_TIMEOUT_MS = 5_000;\n\ntype EventCursor = { afterEventId: string } | { afterTimestamp: number };\ntype PlatformGithubEventWorkerSettings = {\n version: 1;\n repositories: Record<string, EventCursor>;\n};\n\nexport type PlatformGithubEventStorage = IntegrationStorageHandle<\n Record<string, unknown>,\n PlatformGithubEventWorkerSettings,\n Record<string, unknown>\n>;\n\ntype EventLogEntry = {\n id: string;\n deliveryId: string;\n event: string;\n payload: unknown;\n};\n\ntype Repository = {\n id: number;\n fullName?: string;\n installationId: number;\n projects: ExternalRepositoryProjectTarget[];\n};\n\nexport type PlatformGithubEventDispatchIntegration = GithubWebhookDispatchIntegration;\n\nexport interface PlatformGithubEventWorkerConfig {\n client: PlatformApiClient;\n controller: MountedMastraCode['controller'];\n github: PlatformGithubEventDispatchIntegration;\n storage: PlatformGithubEventStorage;\n /**\n * Source-control storage used to resolve the set of repositories the worker\n * should poll. The worker restricts itself to `(installation, repository)`\n * pairs linked to a factory project — the same set the reconciler uses —\n * so polling scales with Factory usage, not with the size of the underlying\n * GitHub org.\n */\n sourceControl: GithubReconcileRepositorySource;\n /**\n * Subscribes to changes of the linked repository set and returns the\n * unsubscribe. With it the worker reads the set from storage once, and again\n * only after a change, so a poll that finds no events costs no storage reads.\n * Without it every poll re-reads the set.\n */\n onRepositoriesChanged?: (listener: () => void) => () => void;\n /**\n * False while changes made on other replicas cannot reach this one; the\n * worker then re-reads the set on every poll. Defaults to true.\n */\n repositoryChangesShared?: () => boolean;\n ingestFactoryEvent?: (event: ParsedGithubWebhook) => Promise<unknown>;\n reconcileFactoryState?: GithubPullRequestReconciler;\n reconcileIssuesFactoryState?: GithubIssueReconciler;\n discoverPullRequests?: GithubPullRequestDiscovery;\n /** Files Dependabot alerts on linked repositories as cards. */\n syncDependabotAlerts?: DependabotSync;\n /** Defaults to fifteen minutes. */\n dependabotSyncIntervalMs?: number;\n /** When false the worker skips event tailing and only runs enabled reconciliation sweeps. */\n pollEventsEnabled?: boolean;\n intervalMs?: number;\n /** Legacy shared reconciliation cadence. */\n reconcileIntervalMs?: number;\n pullRequestReconcileIntervalMs?: number;\n issueReconcileIntervalMs?: number;\n /** Defaults to five minutes, or the pull request interval when that is shorter. */\n pullRequestDiscoveryIntervalMs?: number;\n now?: () => number;\n dispatch?: typeof dispatchGithubWebhook;\n}\n\nexport class PlatformGithubEventWorker extends MastraWorker {\n readonly name = 'platform-github-events';\n\n readonly #client: PlatformApiClient;\n readonly #controller: MountedMastraCode['controller'];\n readonly #github: PlatformGithubEventDispatchIntegration;\n readonly #storage: PlatformGithubEventStorage;\n readonly #ingestFactoryEvent: ((event: ParsedGithubWebhook) => Promise<unknown>) | undefined;\n readonly #reconcileFactoryState: GithubPullRequestReconciler | undefined;\n readonly #reconcileIssuesFactoryState: GithubIssueReconciler | undefined;\n readonly #discoverPullRequests: GithubPullRequestDiscovery | undefined;\n readonly #syncDependabotAlerts: DependabotSync | undefined;\n readonly #dependabotSyncIntervalMs: number;\n #lastDependabotSyncAt = Number.NEGATIVE_INFINITY;\n readonly #pollEventsEnabled: boolean;\n readonly #pullRequestReconcileIntervalMs: number;\n readonly #issueReconcileIntervalMs: number;\n readonly #pullRequestDiscoveryIntervalMs: number;\n readonly #intervalMs: number;\n readonly #now: () => number;\n readonly #dispatch: typeof dispatchGithubWebhook;\n readonly #sourceControl: GithubReconcileRepositorySource;\n readonly #onRepositoriesChanged: ((listener: () => void) => () => void) | undefined;\n readonly #repositoryChangesShared: () => boolean;\n readonly #leaseOwner = globalThis.crypto.randomUUID();\n\n #running = false;\n #timer: ReturnType<typeof setTimeout> | undefined;\n #leaseRenewalTimer: ReturnType<typeof setInterval> | undefined;\n #inFlight: Promise<void> | undefined;\n #leaseProvider: LeaseProvider = NoopLeaseProvider;\n #leaseTtlMs: number;\n #hasLease = false;\n #startedAt = 0;\n // Negative infinity so the first tick always sweeps, whatever the clock reads.\n #lastPullRequestReconcileAt = Number.NEGATIVE_INFINITY;\n #lastIssueReconcileAt = Number.NEGATIVE_INFINITY;\n #lastPullRequestDiscoveryAt = Number.NEGATIVE_INFINITY;\n #settings: PlatformGithubEventWorkerSettings = { version: 1, repositories: {} };\n #unsubscribeRepositoryChanges: (() => void) | undefined;\n #repositories: Repository[] | undefined;\n #repositoryChanges = 0;\n\n constructor(config: PlatformGithubEventWorkerConfig) {\n super();\n this.#client = config.client;\n this.#controller = config.controller;\n this.#github = config.github;\n this.#storage = config.storage;\n this.#ingestFactoryEvent = config.ingestFactoryEvent;\n this.#reconcileFactoryState = config.reconcileFactoryState;\n this.#reconcileIssuesFactoryState = config.reconcileIssuesFactoryState;\n this.#discoverPullRequests = config.discoverPullRequests;\n this.#syncDependabotAlerts = config.syncDependabotAlerts;\n this.#dependabotSyncIntervalMs = config.dependabotSyncIntervalMs ?? DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS;\n this.#pollEventsEnabled = config.pollEventsEnabled ?? true;\n const legacyReconcileIntervalMs = config.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS;\n this.#pullRequestReconcileIntervalMs = config.pullRequestReconcileIntervalMs ?? legacyReconcileIntervalMs;\n this.#issueReconcileIntervalMs = config.issueReconcileIntervalMs ?? legacyReconcileIntervalMs;\n this.#pullRequestDiscoveryIntervalMs =\n config.pullRequestDiscoveryIntervalMs ??\n Math.min(DEFAULT_GITHUB_PR_DISCOVERY_INTERVAL_MS, this.#pullRequestReconcileIntervalMs);\n this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {\n throw new Error('Platform GitHub event polling interval must be a positive number.');\n }\n if (!Number.isFinite(this.#pullRequestReconcileIntervalMs) || this.#pullRequestReconcileIntervalMs <= 0) {\n throw new Error('Platform GitHub pull request reconcile interval must be a positive number.');\n }\n if (!Number.isFinite(this.#issueReconcileIntervalMs) || this.#issueReconcileIntervalMs <= 0) {\n throw new Error('Platform GitHub issue reconcile interval must be a positive number.');\n }\n if (!Number.isFinite(this.#pullRequestDiscoveryIntervalMs) || this.#pullRequestDiscoveryIntervalMs <= 0) {\n throw new Error('Platform GitHub pull request discovery interval must be a positive number.');\n }\n this.#leaseTtlMs = Math.max(\n MIN_LEASE_TTL_MS,\n Math.min(\n this.#intervalMs,\n this.#pullRequestReconcileIntervalMs,\n this.#issueReconcileIntervalMs,\n this.#pullRequestDiscoveryIntervalMs,\n ) * 3,\n );\n this.#now = config.now ?? Date.now;\n this.#dispatch = config.dispatch ?? dispatchGithubWebhook;\n this.#sourceControl = config.sourceControl;\n this.#onRepositoriesChanged = config.onRepositoriesChanged;\n this.#repositoryChangesShared = config.repositoryChangesShared ?? (() => true);\n }\n\n async init(deps: WorkerDeps): Promise<void> {\n await super.init(deps);\n this.#leaseProvider = getLeaseProvider(deps.pubsub);\n }\n\n async start(): Promise<void> {\n if (this.#running) return;\n if (!this.deps) throw new Error('PlatformGithubEventWorker: call init() before start()');\n\n this.#startedAt = this.#now() - 1;\n this.#settings = normalizeSettings(await this.#storage.settings.get(CURSOR_ORG_ID, CURSOR_USER_ID));\n // Nothing was listening while stopped, and a read that was in flight\n // during stop() may have cached its result after stop() returned.\n this.#repositoryChanges += 1;\n this.#repositories = undefined;\n this.#unsubscribeRepositoryChanges = this.#onRepositoriesChanged?.(() => {\n this.#repositoryChanges += 1;\n this.#repositories = undefined;\n });\n this.#running = true;\n this.deps.logger.debug('Platform GitHub event polling started', {\n intervalMs: this.#intervalMs,\n leaseTtlMs: this.#leaseTtlMs,\n });\n this.#schedule(0);\n }\n\n async stop(): Promise<void> {\n if (!this.#running) return;\n this.#running = false;\n if (this.#timer) clearTimeout(this.#timer);\n this.#timer = undefined;\n this.#stopLeaseRenewal();\n this.#unsubscribeRepositoryChanges?.();\n this.#unsubscribeRepositoryChanges = undefined;\n await this.#inFlight;\n if (this.#hasLease) {\n await this.#leaseProvider.releaseLease(this.#leaseKey(), this.#leaseOwner).catch(() => undefined);\n this.#hasLease = false;\n }\n }\n\n get isRunning(): boolean {\n return this.#running;\n }\n\n #schedule(delayMs: number): void {\n if (!this.#running) return;\n this.#timer = setTimeout(() => {\n this.#timer = undefined;\n const run = this.#tick();\n this.#inFlight = run;\n void run.finally(() => {\n if (this.#inFlight === run) this.#inFlight = undefined;\n });\n }, delayMs);\n this.#timer.unref?.();\n }\n\n async #tick(): Promise<void> {\n let nextDelay = this.#intervalMs;\n try {\n if (!(await this.#ensureLease())) return;\n nextDelay = await this.#poll();\n } catch (error) {\n nextDelay = retryDelay(error, this.#intervalMs);\n this.deps?.logger.error('Platform GitHub event polling cycle failed', {\n error: error instanceof Error ? error.message : String(error),\n retryInMs: nextDelay,\n });\n } finally {\n this.#schedule(nextDelay);\n }\n }\n\n async #ensureLease(): Promise<boolean> {\n if (this.#hasLease) return true;\n const result = await this.#leaseProvider.acquireLease(this.#leaseKey(), this.#leaseOwner, this.#leaseTtlMs);\n this.#hasLease = result.acquired;\n if (this.#hasLease) this.#startLeaseRenewal();\n return this.#hasLease;\n }\n\n #startLeaseRenewal(): void {\n if (this.#leaseRenewalTimer) return;\n this.#leaseRenewalTimer = setInterval(\n () => {\n void this.#leaseProvider\n .renewLease(this.#leaseKey(), this.#leaseOwner, this.#leaseTtlMs)\n .then(renewed => {\n if (!renewed) {\n this.#hasLease = false;\n this.#stopLeaseRenewal();\n }\n })\n .catch(error => {\n this.#hasLease = false;\n this.#stopLeaseRenewal();\n this.deps?.logger.warn('Platform GitHub event polling lease renewal failed', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n },\n Math.floor(this.#leaseTtlMs / 3),\n );\n this.#leaseRenewalTimer.unref?.();\n }\n\n #stopLeaseRenewal(): void {\n if (this.#leaseRenewalTimer) clearInterval(this.#leaseRenewalTimer);\n this.#leaseRenewalTimer = undefined;\n }\n\n async #poll(): Promise<number> {\n const repositories = await this.#linkedRepositories();\n let retryInMs = this.#pollEventsEnabled ? this.#intervalMs : this.#reconcileCadence();\n\n if (this.#pollEventsEnabled) {\n for (const repository of repositories) {\n if (!this.#running || !this.#hasLease) break;\n try {\n await this.#pollRepository(repository.id);\n } catch (error) {\n const delay = retryDelay(error, this.#intervalMs);\n retryInMs = Math.max(retryInMs, delay);\n this.deps?.logger.error('Platform GitHub repository event polling failed', {\n repositoryId: repository.id,\n error: error instanceof Error ? error.message : String(error),\n retryInMs: delay,\n });\n if (error instanceof PlatformApiError && error.status === 429) break;\n }\n }\n }\n\n await this.#maybeReconcile(repositories);\n return retryInMs;\n }\n\n #reconcileCadence(): number {\n const cadences = [\n this.#reconcileFactoryState ? this.#pullRequestReconcileIntervalMs : undefined,\n this.#reconcileIssuesFactoryState ? this.#issueReconcileIntervalMs : undefined,\n this.#discoverPullRequests ? this.#pullRequestDiscoveryIntervalMs : undefined,\n this.#syncDependabotAlerts ? this.#dependabotSyncIntervalMs : undefined,\n ].filter((interval): interval is number => interval !== undefined);\n return cadences.length > 0 ? Math.min(...cadences) : this.#intervalMs;\n }\n\n async #maybeReconcile(repositories: Repository[]): Promise<void> {\n if (!this.#running || !this.#hasLease) return;\n const now = this.#now();\n const reconcilePullRequests = Boolean(\n this.#reconcileFactoryState && now - this.#lastPullRequestReconcileAt >= this.#pullRequestReconcileIntervalMs,\n );\n const reconcileIssues = Boolean(\n this.#reconcileIssuesFactoryState && now - this.#lastIssueReconcileAt >= this.#issueReconcileIntervalMs,\n );\n const discoverPullRequests = Boolean(\n this.#discoverPullRequests && now - this.#lastPullRequestDiscoveryAt >= this.#pullRequestDiscoveryIntervalMs,\n );\n const syncDependabot = Boolean(\n this.#syncDependabotAlerts && now - this.#lastDependabotSyncAt >= this.#dependabotSyncIntervalMs,\n );\n if (!reconcilePullRequests && !reconcileIssues && !discoverPullRequests && !syncDependabot) return;\n if (syncDependabot) this.#lastDependabotSyncAt = now;\n if (reconcilePullRequests) this.#lastPullRequestReconcileAt = now;\n if (reconcileIssues) this.#lastIssueReconcileAt = now;\n if (discoverPullRequests) this.#lastPullRequestDiscoveryAt = now;\n if (reconcilePullRequests || reconcileIssues) await this.#refreshRepositoryNames(repositories);\n\n const targets: ReconcileRepository[] = repositories.flatMap(repository =>\n repository.fullName\n ? [{ id: repository.id, fullName: repository.fullName, installationId: repository.installationId }]\n : [],\n );\n if (targets.length === 0) {\n this.deps?.logger.debug('Platform GitHub reconciliation skipped: no named repositories');\n return;\n }\n\n if (syncDependabot && this.#syncDependabotAlerts && this.#hasLease) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#syncDependabotAlerts(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub Dependabot sync completed with failures', { ...context, errors });\n } else {\n this.deps?.logger.info('Platform GitHub Dependabot sync completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub Dependabot sync failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (reconcilePullRequests && this.#reconcileFactoryState) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#reconcileFactoryState(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub pull request reconcile sweep completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.merged > 0 || counts.closed > 0) {\n this.deps?.logger.info('Platform GitHub pull request reconcile replayed missed merges/closes', context);\n } else {\n this.deps?.logger.info('Platform GitHub pull request reconcile sweep completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub pull request reconcile failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (discoverPullRequests && this.#discoverPullRequests && this.#hasLease) {\n const startedAt = Date.now();\n try {\n // With the projects it already read, so discovery doesn't read the links again.\n const linked = new Map(repositories.map(repository => [repository.id, repository.projects]));\n const { errors, ...counts } = await this.#discoverPullRequests(\n targets.map(target => ({ ...target, projects: linked.get(target.id) ?? [] })),\n );\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub pull request discovery completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.created > 0 || counts.repaired > 0) {\n this.deps?.logger.info('Platform GitHub pull request discovery replayed missed opens', context);\n } else {\n this.deps?.logger.debug('Platform GitHub pull request discovery completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub pull request discovery failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (reconcileIssues && this.#reconcileIssuesFactoryState && this.#hasLease) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#reconcileIssuesFactoryState(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub issue reconcile sweep completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.created > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile replayed missed opens', context);\n } else if (counts.closed > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile replayed closed work items', context);\n } else if (counts.updated > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile patched stale metadata', context);\n } else {\n this.deps?.logger.debug('Platform GitHub issue reconcile sweep completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub issue reconcile failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n async #linkedRepositories(): Promise<Repository[]> {\n const cacheable = Boolean(this.#unsubscribeRepositoryChanges) && this.#repositoryChangesShared();\n if (this.#repositories && cacheable) return this.#repositories;\n const changes = this.#repositoryChanges;\n const repositories = await this.#discoverRepositories();\n // A change announced during the read may be missing from it, so that read\n // is used for this poll only and the next poll reads again.\n this.#repositories = cacheable && changes === this.#repositoryChanges ? repositories : undefined;\n return repositories;\n }\n\n /**\n * Takes each repository's current name from the platform. A rename is not a\n * Factory write, so nothing announces it; the stored slug only catches up\n * when someone lists the installation's repositories again. Runs with the\n * hourly sweeps, one platform call per installation and no storage reads.\n */\n async #refreshRepositoryNames(repositories: Repository[]): Promise<void> {\n for (const installationId of new Set(repositories.map(repository => repository.installationId))) {\n try {\n const { repositories: current } = await this.#client.request<{\n repositories: Array<{ id: number; fullName: string }>;\n }>('GET', `${API_PREFIX}/installations/${installationId}/repositories`);\n const names = new Map(current.map(repository => [repository.id, repository.fullName]));\n for (const repository of repositories) {\n const name = repository.installationId === installationId ? names.get(repository.id) : undefined;\n if (name) repository.fullName = name;\n }\n } catch (error) {\n this.deps?.logger.warn('Platform GitHub repository name refresh failed', {\n installationId,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n /**\n * Configured `(installation, repository)` pairs — the same set the\n * reconciler sweeps — resolved to the numeric ids and slug the poll\n * addresses GitHub with. Repositories not linked to any factory project\n * cannot produce work for Factory, so polling and reconciling them is\n * wasted `/events` bandwidth and platform load.\n */\n async #discoverRepositories(): Promise<Repository[]> {\n const keys = await this.#sourceControl.projectRepositories.listConfiguredExternalKeys();\n const repositories = new Map<number, Repository>();\n for (const key of keys) {\n const installationId = Number(key.installationExternalId);\n const repositoryId = Number(key.repositoryExternalId);\n if (\n !Number.isSafeInteger(installationId) ||\n installationId <= 0 ||\n !Number.isSafeInteger(repositoryId) ||\n repositoryId <= 0\n ) {\n continue;\n }\n if (repositories.has(repositoryId)) continue;\n // A configured key exists per project link, so `listByExternalRepository`\n // always yields at least one row; the first row's orgId is enough to\n // look up the repository row for its slug.\n const projects = await this.#sourceControl.projectRepositories.listByExternalRepository(key);\n const orgId = projects[0]?.orgId;\n const repository = orgId\n ? await this.#sourceControl.repositories.findByExternalId({ orgId, externalId: key.repositoryExternalId })\n : null;\n repositories.set(repositoryId, {\n id: repositoryId,\n installationId,\n fullName: repository?.slug,\n projects,\n });\n }\n return [...repositories.values()];\n }\n\n async #pollRepository(repositoryId: number): Promise<void> {\n const key = String(repositoryId);\n if (!this.#settings.repositories[key]) {\n this.#settings.repositories[key] = { afterTimestamp: this.#startedAt };\n await this.#saveSettings();\n }\n\n while (this.#running && this.#hasLease) {\n const cursor: EventCursor = this.#settings.repositories[key]!;\n const query = new URLSearchParams({ limit: String(EVENT_PAGE_SIZE) });\n if ('afterEventId' in cursor) query.set('afterEventId', cursor.afterEventId);\n else query.set('afterTimestamp', String(cursor.afterTimestamp));\n\n const pollStartedAt = performance.now();\n const page = await this.#client.request<{ events: EventLogEntry[]; nextCursor: string | null }>(\n 'GET',\n `${API_PREFIX}/repositories/${repositoryId}/events?${query}`,\n );\n this.deps?.logger.debug('Platform GitHub repository event poll completed', {\n repositoryId,\n eventCount: page.events.length,\n latencyMs: Math.round(performance.now() - pollStartedAt),\n });\n if (page.events.length === 0 || !page.nextCursor) return;\n\n for (const event of page.events) {\n if (!this.#running || !this.#hasLease) return;\n const parsed = parseEvent(event);\n if (!parsed) {\n this.deps?.logger.warn('Platform GitHub event log returned a malformed event', {\n repositoryId,\n eventId: event.id,\n });\n continue;\n }\n if (isFactoryIngestedEvent(parsed)) {\n await this.#ingestFactoryEvent?.(parsed);\n } else {\n this.deps?.logger.debug('Platform GitHub event not forwarded to Factory ingress', {\n repositoryId,\n deliveryId: parsed.deliveryId,\n event: parsed.event,\n action: parsed.payload.action,\n });\n }\n const result = await this.#dispatch(parsed, {\n controller: this.#controller,\n listSubscriptions: (target, options) =>\n listPullRequestSubscriptionsForWebhook(target, options, this.#github.integrationStorage),\n retireSubscription: (id, status) =>\n retirePullRequestSubscription(id, status, this.#github.integrationStorage),\n github: this.#github,\n isAuthorizedSender: notification => this.#isAuthorizedSender(notification),\n onTargetSkipped: subscription => {\n // Routine when a subscription's thread belongs to another\n // deployment, so this stays at debug rather than warning on a loop.\n this.deps?.logger.debug('Platform GitHub event skipped: thread is not held here', {\n deliveryId: event.deliveryId,\n subscriptionId: subscription.id,\n threadId: subscription.threadId,\n });\n },\n onSenderRejected: notification => {\n this.deps?.logger.debug('Platform GitHub event dropped: sender not authorized', {\n deliveryId: event.deliveryId,\n repository: notification.metadata.repository,\n sender: notification.metadata.sender,\n kind: notification.kind,\n });\n },\n onTargetError: (subscription, error) => {\n this.deps?.logger.error('Platform GitHub event delivery failed for a subscription', {\n deliveryId: event.deliveryId,\n subscriptionId: subscription.id,\n resourceId: subscription.resourceId,\n threadId: subscription.threadId,\n error: error instanceof Error ? error.message : String(error),\n });\n },\n });\n if (result.failed > 0) {\n this.deps?.logger.warn('Platform GitHub event completed with failed subscription deliveries', {\n repositoryId,\n deliveryId: event.deliveryId,\n delivered: result.delivered,\n failed: result.failed,\n });\n }\n }\n\n if (page.nextCursor === ('afterEventId' in cursor ? cursor.afterEventId : undefined)) return;\n this.#settings.repositories[key] = { afterEventId: page.nextCursor };\n await this.#saveSettings();\n }\n }\n\n async #isAuthorizedSender(notification: GithubWebhookNotification): Promise<boolean> {\n if (!AUTHOR_GATED_KINDS.has(notification.kind)) return true;\n const sender = notification.metadata.sender;\n const repository = notification.metadata.repository;\n if (!sender || !repository) return false;\n // Factory's own app has to clear the gate before the bot rules below, which\n // fail closed for every bot that is not explicitly allowlisted. GitHub\n // forbids an app from reviewing its own pull request, so `factory-review`\n // posts its verdict as a comment under this login and that comment is the\n // handoff the authoring agent wakes on.\n if (this.#github.identity?.matches(sender)) return true;\n if (isFactoryAppSender(sender, this.#github.slug)) return true;\n const normalizedSender = sender.toLowerCase();\n const authorizedBots = resolveAuthorizedBots(this.#github.authorizedBots);\n if (authorizedBots.has(normalizedSender)) return true;\n // Any other bot is gated purely by the allowlist: a GitHub App never holds a\n // collaborator permission under its sender login, so falling through to the\n // permission lookup would only fail closed after a wasted API call.\n if (notification.metadata.senderType?.toLowerCase() === 'bot' || normalizedSender.endsWith('[bot]')) {\n return false;\n }\n\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), PERMISSION_CHECK_TIMEOUT_MS);\n try {\n const permission = await this.#github.getRepositoryCollaboratorPermission(\n notification.metadata.installationId,\n repository,\n sender,\n abortController.signal,\n );\n return permission !== undefined && AUTHORIZED_PERMISSIONS.has(permission);\n } catch {\n return false;\n } finally {\n clearTimeout(timeout);\n }\n }\n\n async #saveSettings(): Promise<void> {\n await this.#storage.settings.save(CURSOR_ORG_ID, CURSOR_USER_ID, this.#settings);\n }\n\n #leaseKey(): string {\n return `${this.name}:${this.#storage.integrationId}`;\n }\n}\n\nfunction getLeaseProvider(pubsub: PubSub): LeaseProvider {\n const getProvider = (pubsub as PubSub & { getLeaseProvider?: () => LeaseProvider | undefined }).getLeaseProvider;\n if (typeof getProvider === 'function') return getProvider.call(pubsub) ?? NoopLeaseProvider;\n return isLeaseProvider(pubsub) ? pubsub : NoopLeaseProvider;\n}\n\nfunction normalizeSettings(value: PlatformGithubEventWorkerSettings | null): PlatformGithubEventWorkerSettings {\n if (!value || value.version !== 1 || !value.repositories || typeof value.repositories !== 'object') {\n return { version: 1, repositories: {} };\n }\n return { version: 1, repositories: { ...value.repositories } };\n}\n\n// Events the polling worker forwards to the factory rules engine. Closures\n// let the reconciler finalize cards; `synchronize` and `review_requested` on a\n// pull request are the triggers the review board's re-review path listens for;\n// submitted reviews and pull request comments are how review feedback reaches\n// the agent that authored the branch. Direct-webhook consumers ingest every\n// parsed event; the platform path gates because the remaining events (issue\n// edits, comment edits and deletions) only interest the subscription\n// dispatcher, not the factory rules.\nconst ISSUE_INGESTED_ACTIONS = new Set(['opened', 'reopened', 'edited', 'labeled', 'unlabeled', 'assigned', 'unassigned']);\n\nfunction isFactoryIngestedEvent(event: ParsedGithubWebhook): boolean {\n if ((event.event === 'issues' || event.event === 'pull_request') && event.payload.action === 'closed') {\n return true;\n }\n if (event.event === 'pull_request') {\n const action = event.payload.action;\n // `opened` is what mints the Review card for a pull request. Without it a\n // factory-authored PR never gets reviewed on the polling path, which is the\n // only path a local deployment has.\n if (action === 'opened' || action === 'synchronize' || action === 'review_requested') return true;\n // A reopen, and a label or assignee change, reach the routes of the card the pull request belongs to.\n if (action === 'reopened' || ['labeled', 'unlabeled', 'assigned', 'unassigned'].includes(String(action))) return true;\n }\n // Issue opens, reopens, edits, label and assignee changes mint and update Work cards.\n // Without them a new issue never becomes a card on the polling path (#24972).\n if (event.event === 'issues' && ISSUE_INGESTED_ACTIONS.has(String(event.payload.action))) return true;\n if (event.event === 'pull_request_review' && event.payload.action === 'submitted') return true;\n if (event.event === 'issue_comment' && event.payload.action === 'created') return true;\n // `factory-review` edits its earlier verdict in place on a re-review. The rules\n // engine only acts on edits that leave a request-changes verdict behind.\n if (event.event === 'pull_request_review' && event.payload.action === 'edited') return true;\n if (event.event === 'issue_comment' && event.payload.action === 'edited') {\n const issue = event.payload.issue;\n if (issue && typeof issue === 'object' && 'pull_request' in issue && issue.pull_request) return true;\n }\n // Default-branch pushes reach the environment build hand-off\n // (`GithubRules` calls the `onRepositoryPush` hook).\n if (event.event === 'push') return true;\n return false;\n}\n\nfunction parseEvent(event: EventLogEntry): ParsedGithubWebhook | null {\n if (\n !event.id ||\n !event.deliveryId ||\n !SUPPORTED_EVENTS.has(event.event) ||\n !event.payload ||\n typeof event.payload !== 'object' ||\n Array.isArray(event.payload)\n ) {\n return null;\n }\n return {\n event: event.event,\n deliveryId: event.deliveryId,\n payload: event.payload as Record<string, unknown>,\n };\n}\n\nfunction retryDelay(error: unknown, fallbackMs: number): number {\n if (error instanceof PlatformApiError && error.status === 429 && error.retryAfterSeconds !== null) {\n return Math.max(fallbackMs, error.retryAfterSeconds * 1_000);\n }\n return fallbackMs;\n}\n"],"mappings":";;;;;;;;AA6BA,MAAM,aAAa;AACnB,MAAM,2BAA2B;AAGjC,MAAM,gCAAgC;AACtC,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CAGA;AACF,CAAC;AAGD,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,yCAAyB,IAAI,IAAgC;CAAC;CAAS;CAAY;AAAO,CAAC;AACjG,MAAM,8BAA8B;AA4EpC,IAAa,4BAAb,cAA+C,aAAa;CAC1D,OAAgB;CAEhB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,wBAAwB,OAAO;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,cAAuB,WAAW,OAAO,WAAW;CAEpD,WAAW;CACX;CACA;CACA;CACA,iBAAgC;CAChC;CACA,YAAY;CACZ,aAAa;CAEb,8BAA8B,OAAO;CACrC,wBAAwB,OAAO;CAC/B,8BAA8B,OAAO;CACrC,YAA+C;EAAE,SAAS;EAAG,cAAc,CAAC;CAAE;CAC9E;CACA;CACA,qBAAqB;CAErB,YAAY,QAAyC;EACnD,MAAM;EACN,KAA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,MAAM,SAAS,MAAM,QAAQ;EAI7B,IAAI,WAAW,YAAY,WAAW,iBAAiB,WAAW,oBAAoB,OAAO;EAE7F,IAAI,WAAW,cAAc;GAAC;GAAW;GAAa;GAAY;EAAY,CAAC,CAAC,SAAS,OAAO,MAAM,CAAC,GAAG,OAAO;CACnH;CAGA,IAAI,MAAM,UAAU,YAAY,uBAAuB,IAAI,OAAO,MAAM,QAAQ,MAAM,CAAC,GAAG,OAAO;CACjG,IAAI,MAAM,UAAU,yBAAyB,MAAM,QAAQ,WAAW,aAAa,OAAO;CAC1F,IAAI,MAAM,UAAU,mBAAmB,MAAM,QAAQ,WAAW,WAAW,OAAO;CAGlF,IAAI,MAAM,UAAU,yBAAyB,MAAM,QAAQ,WAAW,UAAU,OAAO;CACvF,IAAI,MAAM,UAAU,mBAAmB,MAAM,QAAQ,WAAW,UAAU;EACxE,MAAM,QAAQ,MAAM,QAAQ;EAC5B,IAAI,SAAS,OAAO,UAAU,YAAY,kBAAkB,SAAS,MAAM,cAAc,OAAO;CAClG;CAGA,IAAI,MAAM,UAAU,QAAQ,OAAO;CACnC,OAAO;AACT;AAEA,SAAS,WAAW,OAAkD;CACpE,IACE,CAAC,MAAM,MACP,CAAC,MAAM,cACP,CAAC,iBAAiB,IAAI,MAAM,KAAK,KACjC,CAAC,MAAM,WACP,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,MAAM,OAAO,GAE3B,OAAO;CAET,OAAO;EACL,OAAO,MAAM;EACb,YAAY,MAAM;EAClB,SAAS,MAAM;CACjB;AACF;AAEA,SAAS,WAAW,OAAgB,YAA4B;CAC9D,IAAI,iBAAiB,oBAAoB,MAAM,WAAW,OAAO,MAAM,sBAAsB,MAC3F,OAAO,KAAK,IAAI,YAAY,MAAM,oBAAoB,GAAK;CAE7D,OAAO;AACT"}
1
+ {"version":3,"file":"event-worker.js","names":[],"sources":["../../../../src/integrations/platform/github/event-worker.ts"],"sourcesContent":["import type { MountedMastraCode } from '@mastra/code-sdk';\nimport type { ConnectClient } from '@mastra/connect';\nimport { isLeaseProvider, NoopLeaseProvider } from '@mastra/core/events';\nimport type { LeaseProvider, PubSub } from '@mastra/core/events';\nimport { MastraWorker } from '@mastra/core/worker';\n\nimport type { WorkerDeps } from '@mastra/core/worker';\nimport type { IntegrationStorageHandle } from '../../../storage/domains/integrations/base.js';\nimport type { ExternalRepositoryProjectTarget } from '../../../storage/domains/source-control/base.js';\nimport { DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS } from '../../dependabot/sync.js';\nimport type { DependabotSync } from '../../dependabot/sync.js';\nimport type { GithubRepositoryPermission } from '../../github/integration.js';\nimport type { GithubIssueReconciler } from '../../github/issue-reconciler.js';\nimport { DEFAULT_GITHUB_PR_DISCOVERY_INTERVAL_MS } from '../../github/reconcile-worker.js';\nimport type { GithubReconcileRepositorySource } from '../../github/reconcile-worker.js';\nimport type {\n GithubPullRequestDiscovery,\n GithubPullRequestReconciler,\n ReconcileRepository,\n} from '../../github/rules.js';\nimport { listPullRequestSubscriptionsForWebhook, retirePullRequestSubscription } from '../../github/subscriptions.js';\nimport { dispatchGithubWebhook, isFactoryAppSender, resolveAuthorizedBots } from '../../github/webhook.js';\nimport type {\n GithubWebhookDispatchIntegration,\n GithubWebhookNotification,\n ParsedGithubWebhook,\n} from '../../github/webhook.js';\nimport { platformErrorStatus, platformRetryDelayMs } from '../platform-connect.js';\n\nconst API_PREFIX = '/v1/server/github-app';\nconst DEFAULT_POLL_INTERVAL_MS = 20_000;\n// Event polling is the primary sync; the sweeps only catch drift (missed\n// events, cards ingested before polling was linked), so they run hourly.\nconst DEFAULT_RECONCILE_INTERVAL_MS = 60 * 60_000;\nconst EVENT_PAGE_SIZE = 500;\nconst MIN_LEASE_TTL_MS = 30_000;\nconst CURSOR_ORG_ID = '__platform_github_event_worker__';\nconst CURSOR_USER_ID = 'worker';\nconst SUPPORTED_EVENTS = new Set([\n 'issues',\n 'issue_comment',\n 'pull_request',\n 'pull_request_review',\n 'pull_request_review_comment',\n // Pushes never reach the subscription dispatcher; they feed the factory\n // ingest path so environment templates rebuild on default-branch updates.\n 'push',\n]);\n// Kinds emitted by `classifyGithubWebhook` that carry untrusted sender-authored\n// content and must pass the sender authorization gate below.\nconst AUTHOR_GATED_KINDS = new Set([\n 'issue-comment-created',\n 'review-comment-created',\n 'review-approved',\n 'review-changes-requested',\n 'review-submitted',\n 'review-dismissed',\n]);\nconst AUTHORIZED_PERMISSIONS = new Set<GithubRepositoryPermission>(['admin', 'maintain', 'write']);\nconst PERMISSION_CHECK_TIMEOUT_MS = 5_000;\n\ntype EventCursor = { afterEventId: string } | { afterTimestamp: number };\ntype PlatformGithubEventWorkerSettings = {\n version: 1;\n repositories: Record<string, EventCursor>;\n};\n\nexport type PlatformGithubEventStorage = IntegrationStorageHandle<\n Record<string, unknown>,\n PlatformGithubEventWorkerSettings,\n Record<string, unknown>\n>;\n\ntype EventLogEntry = {\n id: string;\n deliveryId: string;\n event: string;\n payload: unknown;\n};\n\ntype Repository = {\n id: number;\n fullName?: string;\n installationId: number;\n projects: ExternalRepositoryProjectTarget[];\n};\n\nexport type PlatformGithubEventDispatchIntegration = GithubWebhookDispatchIntegration;\n\nexport interface PlatformGithubEventWorkerConfig {\n client: ConnectClient;\n controller: MountedMastraCode['controller'];\n github: PlatformGithubEventDispatchIntegration;\n storage: PlatformGithubEventStorage;\n /**\n * Source-control storage used to resolve the set of repositories the worker\n * should poll. The worker restricts itself to `(installation, repository)`\n * pairs linked to a factory project — the same set the reconciler uses —\n * so polling scales with Factory usage, not with the size of the underlying\n * GitHub org.\n */\n sourceControl: GithubReconcileRepositorySource;\n /**\n * Subscribes to changes of the linked repository set and returns the\n * unsubscribe. With it the worker reads the set from storage once, and again\n * only after a change, so a poll that finds no events costs no storage reads.\n * Without it every poll re-reads the set.\n */\n onRepositoriesChanged?: (listener: () => void) => () => void;\n /**\n * False while changes made on other replicas cannot reach this one; the\n * worker then re-reads the set on every poll. Defaults to true.\n */\n repositoryChangesShared?: () => boolean;\n ingestFactoryEvent?: (event: ParsedGithubWebhook) => Promise<unknown>;\n reconcileFactoryState?: GithubPullRequestReconciler;\n reconcileIssuesFactoryState?: GithubIssueReconciler;\n discoverPullRequests?: GithubPullRequestDiscovery;\n /** Files Dependabot alerts on linked repositories as cards. */\n syncDependabotAlerts?: DependabotSync;\n /** Defaults to fifteen minutes. */\n dependabotSyncIntervalMs?: number;\n /** When false the worker skips event tailing and only runs enabled reconciliation sweeps. */\n pollEventsEnabled?: boolean;\n intervalMs?: number;\n /** Legacy shared reconciliation cadence. */\n reconcileIntervalMs?: number;\n pullRequestReconcileIntervalMs?: number;\n issueReconcileIntervalMs?: number;\n /** Defaults to five minutes, or the pull request interval when that is shorter. */\n pullRequestDiscoveryIntervalMs?: number;\n now?: () => number;\n dispatch?: typeof dispatchGithubWebhook;\n}\n\nexport class PlatformGithubEventWorker extends MastraWorker {\n readonly name = 'platform-github-events';\n\n readonly #client: ConnectClient;\n readonly #controller: MountedMastraCode['controller'];\n readonly #github: PlatformGithubEventDispatchIntegration;\n readonly #storage: PlatformGithubEventStorage;\n readonly #ingestFactoryEvent: ((event: ParsedGithubWebhook) => Promise<unknown>) | undefined;\n readonly #reconcileFactoryState: GithubPullRequestReconciler | undefined;\n readonly #reconcileIssuesFactoryState: GithubIssueReconciler | undefined;\n readonly #discoverPullRequests: GithubPullRequestDiscovery | undefined;\n readonly #syncDependabotAlerts: DependabotSync | undefined;\n readonly #dependabotSyncIntervalMs: number;\n #lastDependabotSyncAt = Number.NEGATIVE_INFINITY;\n readonly #pollEventsEnabled: boolean;\n readonly #pullRequestReconcileIntervalMs: number;\n readonly #issueReconcileIntervalMs: number;\n readonly #pullRequestDiscoveryIntervalMs: number;\n readonly #intervalMs: number;\n readonly #now: () => number;\n readonly #dispatch: typeof dispatchGithubWebhook;\n readonly #sourceControl: GithubReconcileRepositorySource;\n readonly #onRepositoriesChanged: ((listener: () => void) => () => void) | undefined;\n readonly #repositoryChangesShared: () => boolean;\n readonly #leaseOwner = globalThis.crypto.randomUUID();\n\n #running = false;\n #timer: ReturnType<typeof setTimeout> | undefined;\n #leaseRenewalTimer: ReturnType<typeof setInterval> | undefined;\n #inFlight: Promise<void> | undefined;\n #leaseProvider: LeaseProvider = NoopLeaseProvider;\n #leaseTtlMs: number;\n #hasLease = false;\n #startedAt = 0;\n // Negative infinity so the first tick always sweeps, whatever the clock reads.\n #lastPullRequestReconcileAt = Number.NEGATIVE_INFINITY;\n #lastIssueReconcileAt = Number.NEGATIVE_INFINITY;\n #lastPullRequestDiscoveryAt = Number.NEGATIVE_INFINITY;\n #settings: PlatformGithubEventWorkerSettings = { version: 1, repositories: {} };\n #unsubscribeRepositoryChanges: (() => void) | undefined;\n #repositories: Repository[] | undefined;\n #repositoryChanges = 0;\n\n constructor(config: PlatformGithubEventWorkerConfig) {\n super();\n this.#client = config.client;\n this.#controller = config.controller;\n this.#github = config.github;\n this.#storage = config.storage;\n this.#ingestFactoryEvent = config.ingestFactoryEvent;\n this.#reconcileFactoryState = config.reconcileFactoryState;\n this.#reconcileIssuesFactoryState = config.reconcileIssuesFactoryState;\n this.#discoverPullRequests = config.discoverPullRequests;\n this.#syncDependabotAlerts = config.syncDependabotAlerts;\n this.#dependabotSyncIntervalMs = config.dependabotSyncIntervalMs ?? DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS;\n this.#pollEventsEnabled = config.pollEventsEnabled ?? true;\n const legacyReconcileIntervalMs = config.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS;\n this.#pullRequestReconcileIntervalMs = config.pullRequestReconcileIntervalMs ?? legacyReconcileIntervalMs;\n this.#issueReconcileIntervalMs = config.issueReconcileIntervalMs ?? legacyReconcileIntervalMs;\n this.#pullRequestDiscoveryIntervalMs =\n config.pullRequestDiscoveryIntervalMs ??\n Math.min(DEFAULT_GITHUB_PR_DISCOVERY_INTERVAL_MS, this.#pullRequestReconcileIntervalMs);\n this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {\n throw new Error('Platform GitHub event polling interval must be a positive number.');\n }\n if (!Number.isFinite(this.#pullRequestReconcileIntervalMs) || this.#pullRequestReconcileIntervalMs <= 0) {\n throw new Error('Platform GitHub pull request reconcile interval must be a positive number.');\n }\n if (!Number.isFinite(this.#issueReconcileIntervalMs) || this.#issueReconcileIntervalMs <= 0) {\n throw new Error('Platform GitHub issue reconcile interval must be a positive number.');\n }\n if (!Number.isFinite(this.#pullRequestDiscoveryIntervalMs) || this.#pullRequestDiscoveryIntervalMs <= 0) {\n throw new Error('Platform GitHub pull request discovery interval must be a positive number.');\n }\n this.#leaseTtlMs = Math.max(\n MIN_LEASE_TTL_MS,\n Math.min(\n this.#intervalMs,\n this.#pullRequestReconcileIntervalMs,\n this.#issueReconcileIntervalMs,\n this.#pullRequestDiscoveryIntervalMs,\n ) * 3,\n );\n this.#now = config.now ?? Date.now;\n this.#dispatch = config.dispatch ?? dispatchGithubWebhook;\n this.#sourceControl = config.sourceControl;\n this.#onRepositoriesChanged = config.onRepositoriesChanged;\n this.#repositoryChangesShared = config.repositoryChangesShared ?? (() => true);\n }\n\n async init(deps: WorkerDeps): Promise<void> {\n await super.init(deps);\n this.#leaseProvider = getLeaseProvider(deps.pubsub);\n }\n\n async start(): Promise<void> {\n if (this.#running) return;\n if (!this.deps) throw new Error('PlatformGithubEventWorker: call init() before start()');\n\n this.#startedAt = this.#now() - 1;\n this.#settings = normalizeSettings(await this.#storage.settings.get(CURSOR_ORG_ID, CURSOR_USER_ID));\n // Nothing was listening while stopped, and a read that was in flight\n // during stop() may have cached its result after stop() returned.\n this.#repositoryChanges += 1;\n this.#repositories = undefined;\n this.#unsubscribeRepositoryChanges = this.#onRepositoriesChanged?.(() => {\n this.#repositoryChanges += 1;\n this.#repositories = undefined;\n });\n this.#running = true;\n this.deps.logger.debug('Platform GitHub event polling started', {\n intervalMs: this.#intervalMs,\n leaseTtlMs: this.#leaseTtlMs,\n });\n this.#schedule(0);\n }\n\n async stop(): Promise<void> {\n if (!this.#running) return;\n this.#running = false;\n if (this.#timer) clearTimeout(this.#timer);\n this.#timer = undefined;\n this.#stopLeaseRenewal();\n this.#unsubscribeRepositoryChanges?.();\n this.#unsubscribeRepositoryChanges = undefined;\n await this.#inFlight;\n if (this.#hasLease) {\n await this.#leaseProvider.releaseLease(this.#leaseKey(), this.#leaseOwner).catch(() => undefined);\n this.#hasLease = false;\n }\n }\n\n get isRunning(): boolean {\n return this.#running;\n }\n\n #schedule(delayMs: number): void {\n if (!this.#running) return;\n this.#timer = setTimeout(() => {\n this.#timer = undefined;\n const run = this.#tick();\n this.#inFlight = run;\n void run.finally(() => {\n if (this.#inFlight === run) this.#inFlight = undefined;\n });\n }, delayMs);\n this.#timer.unref?.();\n }\n\n async #tick(): Promise<void> {\n let nextDelay = this.#intervalMs;\n try {\n if (!(await this.#ensureLease())) return;\n nextDelay = await this.#poll();\n } catch (error) {\n nextDelay = platformRetryDelayMs(error, this.#intervalMs);\n this.deps?.logger.error('Platform GitHub event polling cycle failed', {\n error: error instanceof Error ? error.message : String(error),\n retryInMs: nextDelay,\n });\n } finally {\n this.#schedule(nextDelay);\n }\n }\n\n async #ensureLease(): Promise<boolean> {\n if (this.#hasLease) return true;\n const result = await this.#leaseProvider.acquireLease(this.#leaseKey(), this.#leaseOwner, this.#leaseTtlMs);\n this.#hasLease = result.acquired;\n if (this.#hasLease) this.#startLeaseRenewal();\n return this.#hasLease;\n }\n\n #startLeaseRenewal(): void {\n if (this.#leaseRenewalTimer) return;\n this.#leaseRenewalTimer = setInterval(\n () => {\n void this.#leaseProvider\n .renewLease(this.#leaseKey(), this.#leaseOwner, this.#leaseTtlMs)\n .then(renewed => {\n if (!renewed) {\n this.#hasLease = false;\n this.#stopLeaseRenewal();\n }\n })\n .catch(error => {\n this.#hasLease = false;\n this.#stopLeaseRenewal();\n this.deps?.logger.warn('Platform GitHub event polling lease renewal failed', {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n },\n Math.floor(this.#leaseTtlMs / 3),\n );\n this.#leaseRenewalTimer.unref?.();\n }\n\n #stopLeaseRenewal(): void {\n if (this.#leaseRenewalTimer) clearInterval(this.#leaseRenewalTimer);\n this.#leaseRenewalTimer = undefined;\n }\n\n async #poll(): Promise<number> {\n const repositories = await this.#linkedRepositories();\n let retryInMs = this.#pollEventsEnabled ? this.#intervalMs : this.#reconcileCadence();\n\n if (this.#pollEventsEnabled) {\n for (const repository of repositories) {\n if (!this.#running || !this.#hasLease) break;\n try {\n await this.#pollRepository(repository.id);\n } catch (error) {\n const delay = platformRetryDelayMs(error, this.#intervalMs);\n retryInMs = Math.max(retryInMs, delay);\n this.deps?.logger.error('Platform GitHub repository event polling failed', {\n repositoryId: repository.id,\n error: error instanceof Error ? error.message : String(error),\n retryInMs: delay,\n });\n if (platformErrorStatus(error) === 429) break;\n }\n }\n }\n\n await this.#maybeReconcile(repositories);\n return retryInMs;\n }\n\n #reconcileCadence(): number {\n const cadences = [\n this.#reconcileFactoryState ? this.#pullRequestReconcileIntervalMs : undefined,\n this.#reconcileIssuesFactoryState ? this.#issueReconcileIntervalMs : undefined,\n this.#discoverPullRequests ? this.#pullRequestDiscoveryIntervalMs : undefined,\n this.#syncDependabotAlerts ? this.#dependabotSyncIntervalMs : undefined,\n ].filter((interval): interval is number => interval !== undefined);\n return cadences.length > 0 ? Math.min(...cadences) : this.#intervalMs;\n }\n\n async #maybeReconcile(repositories: Repository[]): Promise<void> {\n if (!this.#running || !this.#hasLease) return;\n const now = this.#now();\n const reconcilePullRequests = Boolean(\n this.#reconcileFactoryState && now - this.#lastPullRequestReconcileAt >= this.#pullRequestReconcileIntervalMs,\n );\n const reconcileIssues = Boolean(\n this.#reconcileIssuesFactoryState && now - this.#lastIssueReconcileAt >= this.#issueReconcileIntervalMs,\n );\n const discoverPullRequests = Boolean(\n this.#discoverPullRequests && now - this.#lastPullRequestDiscoveryAt >= this.#pullRequestDiscoveryIntervalMs,\n );\n const syncDependabot = Boolean(\n this.#syncDependabotAlerts && now - this.#lastDependabotSyncAt >= this.#dependabotSyncIntervalMs,\n );\n if (!reconcilePullRequests && !reconcileIssues && !discoverPullRequests && !syncDependabot) return;\n if (syncDependabot) this.#lastDependabotSyncAt = now;\n if (reconcilePullRequests) this.#lastPullRequestReconcileAt = now;\n if (reconcileIssues) this.#lastIssueReconcileAt = now;\n if (discoverPullRequests) this.#lastPullRequestDiscoveryAt = now;\n if (reconcilePullRequests || reconcileIssues) await this.#refreshRepositoryNames(repositories);\n\n const targets: ReconcileRepository[] = repositories.flatMap(repository =>\n repository.fullName\n ? [{ id: repository.id, fullName: repository.fullName, installationId: repository.installationId }]\n : [],\n );\n if (targets.length === 0) {\n this.deps?.logger.debug('Platform GitHub reconciliation skipped: no named repositories');\n return;\n }\n\n if (syncDependabot && this.#syncDependabotAlerts && this.#hasLease) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#syncDependabotAlerts(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub Dependabot sync completed with failures', { ...context, errors });\n } else {\n this.deps?.logger.info('Platform GitHub Dependabot sync completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub Dependabot sync failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (reconcilePullRequests && this.#reconcileFactoryState) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#reconcileFactoryState(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub pull request reconcile sweep completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.merged > 0 || counts.closed > 0) {\n this.deps?.logger.info('Platform GitHub pull request reconcile replayed missed merges/closes', context);\n } else {\n this.deps?.logger.info('Platform GitHub pull request reconcile sweep completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub pull request reconcile failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (discoverPullRequests && this.#discoverPullRequests && this.#hasLease) {\n const startedAt = Date.now();\n try {\n // With the projects it already read, so discovery doesn't read the links again.\n const linked = new Map(repositories.map(repository => [repository.id, repository.projects]));\n const { errors, ...counts } = await this.#discoverPullRequests(\n targets.map(target => ({ ...target, projects: linked.get(target.id) ?? [] })),\n );\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub pull request discovery completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.created > 0 || counts.repaired > 0) {\n this.deps?.logger.info('Platform GitHub pull request discovery replayed missed opens', context);\n } else {\n this.deps?.logger.debug('Platform GitHub pull request discovery completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub pull request discovery failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n if (reconcileIssues && this.#reconcileIssuesFactoryState && this.#hasLease) {\n const startedAt = Date.now();\n try {\n const { errors, ...counts } = await this.#reconcileIssuesFactoryState(targets);\n const context = { ...counts, candidateRepositories: targets.length, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn('Platform GitHub issue reconcile sweep completed with failures', {\n ...context,\n errors,\n });\n } else if (counts.created > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile replayed missed opens', context);\n } else if (counts.closed > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile replayed closed work items', context);\n } else if (counts.updated > 0) {\n this.deps?.logger.info('Platform GitHub issue reconcile patched stale metadata', context);\n } else {\n this.deps?.logger.debug('Platform GitHub issue reconcile sweep completed', context);\n }\n } catch (error) {\n this.deps?.logger.error('Platform GitHub issue reconcile failed', {\n repositories: targets.length,\n durationMs: Date.now() - startedAt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n async #linkedRepositories(): Promise<Repository[]> {\n const cacheable = Boolean(this.#unsubscribeRepositoryChanges) && this.#repositoryChangesShared();\n if (this.#repositories && cacheable) return this.#repositories;\n const changes = this.#repositoryChanges;\n const repositories = await this.#discoverRepositories();\n // A change announced during the read may be missing from it, so that read\n // is used for this poll only and the next poll reads again.\n this.#repositories = cacheable && changes === this.#repositoryChanges ? repositories : undefined;\n return repositories;\n }\n\n /**\n * Takes each repository's current name from the platform. A rename is not a\n * Factory write, so nothing announces it; the stored slug only catches up\n * when someone lists the installation's repositories again. Runs with the\n * hourly sweeps, one platform call per installation and no storage reads.\n */\n async #refreshRepositoryNames(repositories: Repository[]): Promise<void> {\n for (const installationId of new Set(repositories.map(repository => repository.installationId))) {\n try {\n const { repositories: current } = await this.#client.request<{\n repositories: Array<{ id: number; fullName: string }>;\n }>('GET', `${API_PREFIX}/installations/${installationId}/repositories`);\n const names = new Map(current.map(repository => [repository.id, repository.fullName]));\n for (const repository of repositories) {\n const name = repository.installationId === installationId ? names.get(repository.id) : undefined;\n if (name) repository.fullName = name;\n }\n } catch (error) {\n this.deps?.logger.warn('Platform GitHub repository name refresh failed', {\n installationId,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n /**\n * Configured `(installation, repository)` pairs — the same set the\n * reconciler sweeps — resolved to the numeric ids and slug the poll\n * addresses GitHub with. Repositories not linked to any factory project\n * cannot produce work for Factory, so polling and reconciling them is\n * wasted `/events` bandwidth and platform load.\n */\n async #discoverRepositories(): Promise<Repository[]> {\n const keys = await this.#sourceControl.projectRepositories.listConfiguredExternalKeys();\n const repositories = new Map<number, Repository>();\n for (const key of keys) {\n const installationId = Number(key.installationExternalId);\n const repositoryId = Number(key.repositoryExternalId);\n if (\n !Number.isSafeInteger(installationId) ||\n installationId <= 0 ||\n !Number.isSafeInteger(repositoryId) ||\n repositoryId <= 0\n ) {\n continue;\n }\n if (repositories.has(repositoryId)) continue;\n // A configured key exists per project link, so `listByExternalRepository`\n // always yields at least one row; the first row's orgId is enough to\n // look up the repository row for its slug.\n const projects = await this.#sourceControl.projectRepositories.listByExternalRepository(key);\n const orgId = projects[0]?.orgId;\n const repository = orgId\n ? await this.#sourceControl.repositories.findByExternalId({ orgId, externalId: key.repositoryExternalId })\n : null;\n repositories.set(repositoryId, {\n id: repositoryId,\n installationId,\n fullName: repository?.slug,\n projects,\n });\n }\n return [...repositories.values()];\n }\n\n async #pollRepository(repositoryId: number): Promise<void> {\n const key = String(repositoryId);\n if (!this.#settings.repositories[key]) {\n this.#settings.repositories[key] = { afterTimestamp: this.#startedAt };\n await this.#saveSettings();\n }\n\n while (this.#running && this.#hasLease) {\n const cursor: EventCursor = this.#settings.repositories[key]!;\n const query = new URLSearchParams({ limit: String(EVENT_PAGE_SIZE) });\n if ('afterEventId' in cursor) query.set('afterEventId', cursor.afterEventId);\n else query.set('afterTimestamp', String(cursor.afterTimestamp));\n\n const pollStartedAt = performance.now();\n const page = await this.#client.request<{ events: EventLogEntry[]; nextCursor: string | null }>(\n 'GET',\n `${API_PREFIX}/repositories/${repositoryId}/events?${query}`,\n );\n this.deps?.logger.debug('Platform GitHub repository event poll completed', {\n repositoryId,\n eventCount: page.events.length,\n latencyMs: Math.round(performance.now() - pollStartedAt),\n });\n if (page.events.length === 0 || !page.nextCursor) return;\n\n for (const event of page.events) {\n if (!this.#running || !this.#hasLease) return;\n const parsed = parseEvent(event);\n if (!parsed) {\n this.deps?.logger.warn('Platform GitHub event log returned a malformed event', {\n repositoryId,\n eventId: event.id,\n });\n continue;\n }\n if (isFactoryIngestedEvent(parsed)) {\n await this.#ingestFactoryEvent?.(parsed);\n } else {\n this.deps?.logger.debug('Platform GitHub event not forwarded to Factory ingress', {\n repositoryId,\n deliveryId: parsed.deliveryId,\n event: parsed.event,\n action: parsed.payload.action,\n });\n }\n const result = await this.#dispatch(parsed, {\n controller: this.#controller,\n listSubscriptions: (target, options) =>\n listPullRequestSubscriptionsForWebhook(target, options, this.#github.integrationStorage),\n retireSubscription: (id, status) =>\n retirePullRequestSubscription(id, status, this.#github.integrationStorage),\n github: this.#github,\n isAuthorizedSender: notification => this.#isAuthorizedSender(notification),\n onTargetSkipped: subscription => {\n // Routine when a subscription's thread belongs to another\n // deployment, so this stays at debug rather than warning on a loop.\n this.deps?.logger.debug('Platform GitHub event skipped: thread is not held here', {\n deliveryId: event.deliveryId,\n subscriptionId: subscription.id,\n threadId: subscription.threadId,\n });\n },\n onSenderRejected: notification => {\n this.deps?.logger.debug('Platform GitHub event dropped: sender not authorized', {\n deliveryId: event.deliveryId,\n repository: notification.metadata.repository,\n sender: notification.metadata.sender,\n kind: notification.kind,\n });\n },\n onTargetError: (subscription, error) => {\n this.deps?.logger.error('Platform GitHub event delivery failed for a subscription', {\n deliveryId: event.deliveryId,\n subscriptionId: subscription.id,\n resourceId: subscription.resourceId,\n threadId: subscription.threadId,\n error: error instanceof Error ? error.message : String(error),\n });\n },\n });\n if (result.failed > 0) {\n this.deps?.logger.warn('Platform GitHub event completed with failed subscription deliveries', {\n repositoryId,\n deliveryId: event.deliveryId,\n delivered: result.delivered,\n failed: result.failed,\n });\n }\n }\n\n if (page.nextCursor === ('afterEventId' in cursor ? cursor.afterEventId : undefined)) return;\n this.#settings.repositories[key] = { afterEventId: page.nextCursor };\n await this.#saveSettings();\n }\n }\n\n async #isAuthorizedSender(notification: GithubWebhookNotification): Promise<boolean> {\n if (!AUTHOR_GATED_KINDS.has(notification.kind)) return true;\n const sender = notification.metadata.sender;\n const repository = notification.metadata.repository;\n if (!sender || !repository) return false;\n // Factory's own app has to clear the gate before the bot rules below, which\n // fail closed for every bot that is not explicitly allowlisted. GitHub\n // forbids an app from reviewing its own pull request, so `factory-review`\n // posts its verdict as a comment under this login and that comment is the\n // handoff the authoring agent wakes on.\n if (this.#github.identity?.matches(sender)) return true;\n if (isFactoryAppSender(sender, this.#github.slug)) return true;\n const normalizedSender = sender.toLowerCase();\n const authorizedBots = resolveAuthorizedBots(this.#github.authorizedBots);\n if (authorizedBots.has(normalizedSender)) return true;\n // Any other bot is gated purely by the allowlist: a GitHub App never holds a\n // collaborator permission under its sender login, so falling through to the\n // permission lookup would only fail closed after a wasted API call.\n if (notification.metadata.senderType?.toLowerCase() === 'bot' || normalizedSender.endsWith('[bot]')) {\n return false;\n }\n\n const abortController = new AbortController();\n const timeout = setTimeout(() => abortController.abort(), PERMISSION_CHECK_TIMEOUT_MS);\n try {\n const permission = await this.#github.getRepositoryCollaboratorPermission(\n notification.metadata.installationId,\n repository,\n sender,\n abortController.signal,\n );\n return permission !== undefined && AUTHORIZED_PERMISSIONS.has(permission);\n } catch {\n return false;\n } finally {\n clearTimeout(timeout);\n }\n }\n\n async #saveSettings(): Promise<void> {\n await this.#storage.settings.save(CURSOR_ORG_ID, CURSOR_USER_ID, this.#settings);\n }\n\n #leaseKey(): string {\n return `${this.name}:${this.#storage.integrationId}`;\n }\n}\n\nfunction getLeaseProvider(pubsub: PubSub): LeaseProvider {\n const getProvider = (pubsub as PubSub & { getLeaseProvider?: () => LeaseProvider | undefined }).getLeaseProvider;\n if (typeof getProvider === 'function') return getProvider.call(pubsub) ?? NoopLeaseProvider;\n return isLeaseProvider(pubsub) ? pubsub : NoopLeaseProvider;\n}\n\nfunction normalizeSettings(value: PlatformGithubEventWorkerSettings | null): PlatformGithubEventWorkerSettings {\n if (!value || value.version !== 1 || !value.repositories || typeof value.repositories !== 'object') {\n return { version: 1, repositories: {} };\n }\n return { version: 1, repositories: { ...value.repositories } };\n}\n\n// Events the polling worker forwards to the factory rules engine. Closures\n// let the reconciler finalize cards; `synchronize` and `review_requested` on a\n// pull request are the triggers the review board's re-review path listens for;\n// submitted reviews and pull request comments are how review feedback reaches\n// the agent that authored the branch. Direct-webhook consumers ingest every\n// parsed event; the platform path gates because the remaining events (issue\n// edits, comment edits and deletions) only interest the subscription\n// dispatcher, not the factory rules.\nconst ISSUE_INGESTED_ACTIONS = new Set(['opened', 'reopened', 'edited', 'labeled', 'unlabeled', 'assigned', 'unassigned']);\n\nfunction isFactoryIngestedEvent(event: ParsedGithubWebhook): boolean {\n if ((event.event === 'issues' || event.event === 'pull_request') && event.payload.action === 'closed') {\n return true;\n }\n if (event.event === 'pull_request') {\n const action = event.payload.action;\n // `opened` is what mints the Review card for a pull request. Without it a\n // factory-authored PR never gets reviewed on the polling path, which is the\n // only path a local deployment has.\n if (action === 'opened' || action === 'synchronize' || action === 'review_requested') return true;\n // A reopen, and a label or assignee change, reach the routes of the card the pull request belongs to.\n if (action === 'reopened' || ['labeled', 'unlabeled', 'assigned', 'unassigned'].includes(String(action))) return true;\n }\n // Issue opens, reopens, edits, label and assignee changes mint and update Work cards.\n // Without them a new issue never becomes a card on the polling path (#24972).\n if (event.event === 'issues' && ISSUE_INGESTED_ACTIONS.has(String(event.payload.action))) return true;\n if (event.event === 'pull_request_review' && event.payload.action === 'submitted') return true;\n if (event.event === 'issue_comment' && event.payload.action === 'created') return true;\n // `factory-review` edits its earlier verdict in place on a re-review. The rules\n // engine only acts on edits that leave a request-changes verdict behind.\n if (event.event === 'pull_request_review' && event.payload.action === 'edited') return true;\n if (event.event === 'issue_comment' && event.payload.action === 'edited') {\n const issue = event.payload.issue;\n if (issue && typeof issue === 'object' && 'pull_request' in issue && issue.pull_request) return true;\n }\n // Default-branch pushes reach the environment build hand-off\n // (`GithubRules` calls the `onRepositoryPush` hook).\n if (event.event === 'push') return true;\n return false;\n}\n\nfunction parseEvent(event: EventLogEntry): ParsedGithubWebhook | null {\n if (\n !event.id ||\n !event.deliveryId ||\n !SUPPORTED_EVENTS.has(event.event) ||\n !event.payload ||\n typeof event.payload !== 'object' ||\n Array.isArray(event.payload)\n ) {\n return null;\n }\n return {\n event: event.event,\n deliveryId: event.deliveryId,\n payload: event.payload as Record<string, unknown>,\n };\n}\n"],"mappings":";;;;;;;;AA6BA,MAAM,aAAa;AACnB,MAAM,2BAA2B;AAGjC,MA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AW,UAAU,OAAO;CACvF,IAAI,MAAM,UAAU,mBAAmB,MAAM,QAAQ,WAAW,UAAU;EACxE,MAAM,QAAQ,MAAM,QAAQ;EAC5B,IAAI,SAAS,OAAO,UAAU,YAAY,kBAAkB,SAAS,MAAM,cAAc,OAAO;CAClG;CAGA,IAAI,MAAM,UAAU,QAAQ,OAAO;CACnC,OAAO;AACT;AAEA,SAAS,WAAW,OAAkD;CACpE,IACE,CAAC,MAAM,MACP,CAAC,MAAM,cACP,CAAC,iBAAiB,IAAI,MAAM,KAAK,KACjC,CAAC,MAAM,WACP,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,MAAM,OAAO,GAE3B,OAAO;CAET,OAAO;EACL,OAAO,MAAM;EACb,YAAY,MAAM;EAClB,SAAS,MAAM;CACjB;AACF"}
@@ -13,6 +13,7 @@ import type { GithubIntegration, GithubRepositoryPermission, GithubTriageComment
13
13
  import type { ReconcileIssueState, ReconcilePullRequestState } from '../../github/rules.js';
14
14
  import type { GitIdentity } from '../../github/sandbox.js';
15
15
  import type { GithubSubscriptionStorage } from '../../github/subscriptions.js';
16
+ import type { PlatformConnectOption } from '../platform-connect.js';
16
17
  export declare class PlatformGithubIntegration implements FactoryIntegration {
17
18
  #private;
18
19
  readonly id = "github";
@@ -46,6 +47,8 @@ export declare class PlatformGithubIntegration implements FactoryIntegration {
46
47
  rules?: GithubRuleOverrides;
47
48
  /** GitHub App slug used to recognize Factory's own webhook writes. */
48
49
  slug?: string;
50
+ /** Connect client, or options for one; defaults to the platform environment. */
51
+ connect?: PlatformConnectOption;
49
52
  });
50
53
  /** Commit authorship follows the Platform App's authoritative writer identity. */
51
54
  get gitIdentity(): GitIdentity | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../../src/integrations/platform/github/integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ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