@mastra/github-signals 0.2.5 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/github-signals
2
2
 
3
+ ## 0.3.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added intent-aware GitHub pull request subscription modes. Review mode follows code revisions, authorized comments, review-thread state, and terminal PR state without CI or mergeability noise, while omitted modes retain working behavior. ([#21542](https://github.com/mastra-ai/mastra/pull/21542))
8
+
9
+ ```ts
10
+ await githubSignals.subscribeThreadToPR({ threadId, resourceId, pr, mode: 'review' });
11
+ ```
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8)]:
16
+ - @mastra/core@1.62.0-alpha.11
17
+
3
18
  ## 0.2.5
4
19
 
5
20
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -47,8 +47,8 @@ const DEFAULT_AUTHORIZED_PERMISSIONS = [
47
47
  ];
48
48
  const DEFAULT_AUTHORIZED_BOTS = ["coderabbitai[bot]", "devin-ai-integration[bot]"];
49
49
  const PERMISSION_CACHE_TTL_MS = 300 * 1e3;
50
- /** Notification kinds driven by comment/review activity that should be gated by author permission. */
51
- const AUTHOR_GATED_NOTIFICATION_KINDS = /* @__PURE__ */ new Set(["pull-request-activity", "pull-request-review-activity"]);
50
+ /** Notification kinds that include comment content and should be gated by author permission. */
51
+ const AUTHOR_GATED_NOTIFICATION_KINDS = /* @__PURE__ */ new Set(["pull-request-activity"]);
52
52
  const createGithubTool = _mastra_core_tools.createTool;
53
53
  function isPlainObject(value) {
54
54
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -60,6 +60,12 @@ function readNumber(value) {
60
60
  if (typeof value === "number" && Number.isInteger(value) && value > 0) return value;
61
61
  if (typeof value === "string" && /^\d+$/.test(value)) return Number(value);
62
62
  }
63
+ function normalizeGithubSubscriptionMode(value) {
64
+ return value === "review" ? "review" : "working";
65
+ }
66
+ function getGithubTerminalState(snapshot) {
67
+ return snapshot?.state === "closed" || snapshot?.state === "merged" ? snapshot.state : void 0;
68
+ }
63
69
  function stableJson(value) {
64
70
  if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
65
71
  if (isPlainObject(value)) return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableJson(value[key])}`).join(",")}}`;
@@ -120,6 +126,7 @@ function getGithubMetadata(threadMetadata) {
120
126
  owner,
121
127
  repo,
122
128
  number,
129
+ mode: normalizeGithubSubscriptionMode(rawSubscription.mode),
123
130
  subscribedAt,
124
131
  updatedAt,
125
132
  lastSubscribeSignalId,
@@ -174,8 +181,11 @@ function getPrLabel(subscription, snapshot) {
174
181
  const pr = `${subscription.owner}/${subscription.repo}#${subscription.number}`;
175
182
  return snapshot?.title ? `${pr}: ${snapshot.title}` : pr;
176
183
  }
184
+ function getTerminalNotificationSummary(label, terminalState) {
185
+ return `${label} was ${terminalState}. This thread has been automatically unsubscribed from this PR. Resubscribe if you still need updates.`;
186
+ }
177
187
  function getMergedNotificationSummary(label) {
178
- return `${label} was merged. This thread has been automatically unsubscribed from this PR. Resubscribe if you still need updates.`;
188
+ return getTerminalNotificationSummary(label, "merged");
179
189
  }
180
190
  /**
181
191
  * Removes a hidden block (its delimiters *and* its content) starting at every `open` marker.
@@ -273,7 +283,10 @@ const githubActivityNotificationPriority = {
273
283
  medium: 1
274
284
  };
275
285
  function getGithubActivityNotificationRank(notification) {
276
- return notification.kind === "pull-request-activity" ? 0 : 1;
286
+ if (notification.kind === "pull-request-activity") return 0;
287
+ if (notification.kind === "pull-request-code-activity") return 1;
288
+ if (notification.kind === "pull-request-review-activity") return 2;
289
+ return 3;
277
290
  }
278
291
  function compareGithubActivityNotifications(a, b) {
279
292
  if (!a && !b) return 0;
@@ -293,6 +306,28 @@ function classifyGithubCommentActivityNotification(input) {
293
306
  summary
294
307
  };
295
308
  }
309
+ function classifyGithubTerminalActivityNotification(input) {
310
+ return {
311
+ kind: input.terminalState === "merged" ? "pull-request-merged" : "pull-request-closed",
312
+ priority: "high",
313
+ summary: getTerminalNotificationSummary(getPrLabel(input.subscription, input.snapshot), input.terminalState)
314
+ };
315
+ }
316
+ function classifyGithubHeadActivityNotification(input) {
317
+ return {
318
+ kind: "pull-request-code-activity",
319
+ priority: "medium",
320
+ summary: `New head revision for ${getPrLabel(input.subscription, input.snapshot)}.`
321
+ };
322
+ }
323
+ function classifyGithubReviewStateActivityNotification(input) {
324
+ const count = input.snapshot.unresolvedReviewThreads ?? 0;
325
+ return {
326
+ kind: "pull-request-review-activity",
327
+ priority: "medium",
328
+ summary: count === 0 ? `All review threads are resolved for ${getPrLabel(input.subscription, input.snapshot)}.` : `${getPrLabel(input.subscription, input.snapshot)} has ${count} unresolved review ${count === 1 ? "thread" : "threads"}.`
329
+ };
330
+ }
296
331
  function getCheckUpdatedTime(check) {
297
332
  const value = check.updatedAt ? Date.parse(check.updatedAt) : NaN;
298
333
  return Number.isFinite(value) ? value : 0;
@@ -703,6 +738,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
703
738
  static signals = {
704
739
  subscribeToPR(input) {
705
740
  const normalized = typeof input === "number" ? { number: input } : input;
741
+ const mode = normalizeGithubSubscriptionMode(normalized.mode);
706
742
  return {
707
743
  type: "reactive",
708
744
  tagName: GITHUB_SUBSCRIBE_PR_TAG,
@@ -710,11 +746,13 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
710
746
  attributes: {
711
747
  ...normalized.owner ? { owner: normalized.owner } : {},
712
748
  ...normalized.repo ? { repo: normalized.repo } : {},
713
- number: normalized.number
749
+ number: normalized.number,
750
+ mode
714
751
  },
715
752
  metadata: { github: {
716
753
  action: "subscribeToPR",
717
- ...normalized
754
+ ...normalized,
755
+ mode
718
756
  } }
719
757
  };
720
758
  },
@@ -794,6 +832,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
794
832
  return this.#subscribe({
795
833
  id: `github-command-subscribe-${(0, crypto.randomUUID)()}`,
796
834
  ...pr,
835
+ mode: normalizeGithubSubscriptionMode(input.mode),
797
836
  threadId: input.threadId,
798
837
  resourceId: input.resourceId
799
838
  });
@@ -898,10 +937,11 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
898
937
  abortSignal: args.abortSignal
899
938
  });
900
939
  if (result.alreadyProcessed) return { tools };
940
+ const terminalMessage = result.terminalState ? `Not subscribed to ${result.owner}/${result.repo}#${result.number} in review mode because it is already ${result.terminalState}.` : void 0;
901
941
  await this.#sendStatus(args, result, {
902
- status: result.syncResult?.ok === false ? "sync_error" : "subscribed",
942
+ status: result.terminalState ? "not_subscribed_terminal" : result.syncResult?.ok === false ? "sync_error" : "subscribed",
903
943
  action: "subscribeToPR",
904
- message: result.syncResult?.ok === false ? `Subscribed to ${result.owner}/${result.repo}#${result.number}, but gitcrawl sync failed: ${result.syncResult.error}` : `Subscribed to ${result.owner}/${result.repo}#${result.number}.`
944
+ message: terminalMessage ?? (result.syncResult?.ok === false ? `Subscribed to ${result.owner}/${result.repo}#${result.number} in ${result.mode} mode, but gitcrawl sync failed: ${result.syncResult.error}` : `Subscribed to ${result.owner}/${result.repo}#${result.number} in ${result.mode} mode.`)
905
945
  });
906
946
  return { tools };
907
947
  }
@@ -941,8 +981,12 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
941
981
  await args.sendSignal?.({
942
982
  type: "reactive",
943
983
  tagName: "system-reminder",
944
- contents: `Looks like you're working with ${repository.owner}/${repository.repo}#${evidence.number}. Use /github subscribe ${evidence.number} or the github_subscribe_pr tool to follow updates.`,
945
- attributes: { type: "github-subscription-hint" },
984
+ contents: `Choose whether to follow ${repository.owner}/${repository.repo}#${evidence.number}: use /github subscribe ${evidence.number} --mode review for new commits, authorized latest PR comments, review-thread-state changes including all threads resolved, and PR close or merge updates; use --mode working for all actionable PR activity. Do not subscribe for a one-off inspection.`,
985
+ attributes: {
986
+ type: "github-subscription-hint",
987
+ availableModes: "review,working",
988
+ defaultMode: null
989
+ },
946
990
  metadata: { github: {
947
991
  action: "subscriptionHint",
948
992
  owner: repository.owner,
@@ -973,11 +1017,12 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
973
1017
  ...args.tools,
974
1018
  github_subscribe_pr: createGithubTool({
975
1019
  id: "github_subscribe_pr",
976
- description: "Subscribe this thread to a GitHub pull request. Syncs only the requested PR with gitcrawl and stores the subscription on the thread.",
1020
+ description: "Subscribe this thread to a GitHub pull request. Use review mode for new commits, authorized latest PR comments, review-thread-state changes including all threads resolved, and PR close or merge updates. Use working mode for all actionable PR activity. Omitted mode defaults to working. Do not subscribe for a one-off inspection.",
977
1021
  inputSchema: zod.default.object({
978
1022
  number: zod.default.number().int().positive(),
979
1023
  owner: zod.default.string().optional(),
980
- repo: zod.default.string().optional()
1024
+ repo: zod.default.string().optional(),
1025
+ mode: zod.default.enum(["working", "review"]).optional()
981
1026
  }),
982
1027
  execute: async (input, context) => {
983
1028
  const executionThreadContext = getExecutionThreadContext(context);
@@ -986,16 +1031,28 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
986
1031
  owner: input.owner,
987
1032
  repo: input.repo,
988
1033
  number: input.number,
1034
+ mode: normalizeGithubSubscriptionMode(input.mode),
989
1035
  threadId: executionThreadContext.threadId,
990
1036
  resourceId: executionThreadContext.resourceId
991
1037
  });
1038
+ if (result.terminalState) return {
1039
+ subscribed: false,
1040
+ mode: result.mode,
1041
+ terminalState: result.terminalState,
1042
+ reason: "terminal",
1043
+ owner: result.owner,
1044
+ repo: result.repo,
1045
+ number: result.number,
1046
+ message: `Not subscribed to ${result.owner}/${result.repo}#${result.number} in review mode because it is already ${result.terminalState}.`
1047
+ };
992
1048
  return {
993
1049
  subscribed: true,
1050
+ mode: result.mode,
994
1051
  owner: result.owner,
995
1052
  repo: result.repo,
996
1053
  number: result.number,
997
1054
  syncStatus: result.syncResult?.ok === false ? "error" : result.syncResult ? "success" : void 0,
998
- message: result.syncResult?.ok === false ? `Subscribed to ${result.owner}/${result.repo}#${result.number}, but gitcrawl sync failed: ${result.syncResult.error}` : `Subscribed to ${result.owner}/${result.repo}#${result.number}.`
1055
+ message: result.syncResult?.ok === false ? `Subscribed to ${result.owner}/${result.repo}#${result.number} in ${result.mode} mode, but gitcrawl sync failed: ${result.syncResult.error}` : `Subscribed to ${result.owner}/${result.repo}#${result.number} in ${result.mode} mode.`
999
1056
  };
1000
1057
  }
1001
1058
  }),
@@ -1135,15 +1192,19 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1135
1192
  const previousContentHash = subscription.lastObservedContentHash;
1136
1193
  const previousThreadContentHash = subscription.lastObservedThreadContentHash;
1137
1194
  const previousHeadSha = subscription.lastObservedHeadSha;
1195
+ const previousReviewStateHash = subscription.lastObservedReviewStateHash;
1138
1196
  const latestCommentTimestampChanged = !!previousGithubUpdatedAt && !!snapshot?.latestCommentUpdatedAt && Date.parse(snapshot.latestCommentUpdatedAt) > Date.parse(previousGithubUpdatedAt);
1139
1197
  const existingBotCommentEdited = latestCommentTimestampChanged && !!snapshot && isExistingBotCommentEdit(subscription, snapshot);
1140
1198
  const latestCommentChanged = latestCommentTimestampChanged && !existingBotCommentEdited;
1199
+ const headChanged = !!previousHeadSha && !!snapshot?.headSha && previousHeadSha !== snapshot.headSha;
1200
+ const reviewStateChanged = !!previousReviewStateHash && !!snapshot?.reviewStateHash && previousReviewStateHash !== snapshot.reviewStateHash;
1141
1201
  if (snapshot) applySnapshotCursor(nextSubscription, snapshot);
1142
1202
  const isFirstObservation = syncResult.ok && snapshot && !previousGithubUpdatedAt && !previousContentHash;
1143
1203
  const legacyAggregateChanged = previousContentHash && snapshot?.contentHash && previousContentHash !== snapshot.contentHash && !previousThreadContentHash && !previousHeadSha;
1144
- const changed = isFirstObservation || syncResult.ok && snapshot && (legacyAggregateChanged || latestCommentChanged || previousThreadContentHash && snapshot.threadContentHash && previousThreadContentHash !== snapshot.threadContentHash && !existingBotCommentEdited || previousHeadSha && snapshot.headSha && previousHeadSha !== snapshot.headSha || subscription.lastObservedState && snapshot.state && subscription.lastObservedState !== snapshot.state || hasMeaningfulMergeableStateChange(subscription.lastObservedMergeableState, snapshot.mergeableState) || subscription.lastObservedCiState && snapshot.ciState && subscription.lastObservedCiState !== snapshot.ciState || subscription.lastObservedReviewStateHash && snapshot.reviewStateHash && subscription.lastObservedReviewStateHash !== snapshot.reviewStateHash);
1145
- let shouldKeepSubscription = true;
1146
- if (changed && snapshot && isCurrentGeneration()) {
1204
+ const changed = isFirstObservation || syncResult.ok && snapshot && (legacyAggregateChanged || latestCommentChanged || previousThreadContentHash && snapshot.threadContentHash && previousThreadContentHash !== snapshot.threadContentHash && !existingBotCommentEdited || headChanged || subscription.lastObservedState && snapshot.state && subscription.lastObservedState !== snapshot.state || hasMeaningfulMergeableStateChange(subscription.lastObservedMergeableState, snapshot.mergeableState) || subscription.lastObservedCiState && snapshot.ciState && subscription.lastObservedCiState !== snapshot.ciState || reviewStateChanged);
1205
+ const terminalState = subscription.mode === "review" ? getGithubTerminalState(snapshot) : void 0;
1206
+ let shouldKeepSubscription = !terminalState;
1207
+ if ((changed || terminalState) && snapshot && !(subscription.mode === "review" && isFirstObservation && !terminalState) && isCurrentGeneration()) {
1147
1208
  const notifications = await this.#sendActivityNotifications({
1148
1209
  polling: input,
1149
1210
  subscription,
@@ -1151,6 +1212,9 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1151
1212
  previousGithubUpdatedAt,
1152
1213
  previousContentHash,
1153
1214
  latestCommentChanged,
1215
+ headChanged,
1216
+ reviewStateChanged,
1217
+ terminalState,
1154
1218
  isCurrentGeneration
1155
1219
  });
1156
1220
  if (!isCurrentGeneration()) return 0;
@@ -1160,7 +1224,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1160
1224
  nextSubscription.lastNotificationKind = primaryNotification.kind;
1161
1225
  nextSubscription.lastNotificationPriority = primaryNotification.priority;
1162
1226
  nextSubscription.lastNotificationSummary = primaryNotification.summary;
1163
- shouldKeepSubscription = notifications.every((notification) => notification.kind !== "pull-request-merged");
1227
+ if (!terminalState) shouldKeepSubscription = notifications.every((notification) => notification.kind !== "pull-request-merged");
1164
1228
  }
1165
1229
  }
1166
1230
  if (shouldKeepSubscription) subscriptions.push(nextSubscription);
@@ -1210,6 +1274,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1210
1274
  owner: input.subscription.owner,
1211
1275
  repo: input.subscription.repo,
1212
1276
  number: input.subscription.number,
1277
+ mode: input.subscription.mode,
1213
1278
  ...input.snapshot.title ? { title: input.snapshot.title } : {},
1214
1279
  ...input.snapshot.state ? { state: input.snapshot.state } : {},
1215
1280
  ...input.snapshot.htmlUrl ? { url: input.snapshot.htmlUrl } : {},
@@ -1229,6 +1294,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1229
1294
  owner: input.subscription.owner,
1230
1295
  repo: input.subscription.repo,
1231
1296
  number: input.subscription.number,
1297
+ mode: input.subscription.mode,
1232
1298
  title: input.snapshot.title,
1233
1299
  state: input.snapshot.state,
1234
1300
  htmlUrl: input.snapshot.htmlUrl,
@@ -1371,14 +1437,36 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1371
1437
  async #sendActivityNotifications(input) {
1372
1438
  const agent = this.#getNotificationAgent(input.polling);
1373
1439
  if (!agent?.sendNotificationSignal) return [];
1374
- const notifications = [classifyGithubActivityNotification({
1375
- subscription: input.subscription,
1376
- snapshot: input.snapshot
1377
- })];
1378
- if (input.latestCommentChanged && notifications[0]?.kind !== "pull-request-activity") notifications.push(classifyGithubCommentActivityNotification({
1440
+ const notifications = [];
1441
+ if (input.subscription.mode === "review") if (input.terminalState) notifications.push(classifyGithubTerminalActivityNotification({
1379
1442
  subscription: input.subscription,
1380
- snapshot: input.snapshot
1443
+ snapshot: input.snapshot,
1444
+ terminalState: input.terminalState
1381
1445
  }));
1446
+ else {
1447
+ if (input.latestCommentChanged) notifications.push(classifyGithubCommentActivityNotification({
1448
+ subscription: input.subscription,
1449
+ snapshot: input.snapshot
1450
+ }));
1451
+ if (input.headChanged) notifications.push(classifyGithubHeadActivityNotification({
1452
+ subscription: input.subscription,
1453
+ snapshot: input.snapshot
1454
+ }));
1455
+ if (input.reviewStateChanged) notifications.push(classifyGithubReviewStateActivityNotification({
1456
+ subscription: input.subscription,
1457
+ snapshot: input.snapshot
1458
+ }));
1459
+ }
1460
+ else {
1461
+ notifications.push(classifyGithubActivityNotification({
1462
+ subscription: input.subscription,
1463
+ snapshot: input.snapshot
1464
+ }));
1465
+ if (input.latestCommentChanged && notifications[0]?.kind !== "pull-request-activity") notifications.push(classifyGithubCommentActivityNotification({
1466
+ subscription: input.subscription,
1467
+ snapshot: input.snapshot
1468
+ }));
1469
+ }
1382
1470
  const sent = [];
1383
1471
  const notificationInputs = [];
1384
1472
  for (const notification of notifications.sort(compareGithubActivityNotifications)) {
@@ -1418,6 +1506,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1418
1506
  return sent;
1419
1507
  }
1420
1508
  async #subscribe(input) {
1509
+ const mode = normalizeGithubSubscriptionMode(input.mode);
1421
1510
  const { owner, repo } = await this.#resolveRepository(input);
1422
1511
  const { threadStore, loadedThread } = await this.#loadThread(input);
1423
1512
  const githubMetadata = getGithubMetadata(loadedThread.metadata);
@@ -1427,6 +1516,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1427
1516
  owner,
1428
1517
  repo,
1429
1518
  number: input.number,
1519
+ mode: existing.mode,
1430
1520
  subscription: existing,
1431
1521
  alreadyProcessed: true
1432
1522
  };
@@ -1435,6 +1525,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1435
1525
  owner,
1436
1526
  repo,
1437
1527
  number: input.number,
1528
+ mode,
1438
1529
  subscribedAt: existing?.subscribedAt ?? now,
1439
1530
  updatedAt: now,
1440
1531
  lastSubscribeSignalId: input.id,
@@ -1478,6 +1569,35 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1478
1569
  baselineSnapshot = snapshot;
1479
1570
  if (snapshot) applySnapshotCursor(subscription, snapshot);
1480
1571
  } else subscription.lastSyncStatus = "skipped";
1572
+ const terminalState = mode === "review" ? getGithubTerminalState(baselineSnapshot) : void 0;
1573
+ if (terminalState) {
1574
+ const subscriptions = githubMetadata.subscriptions.filter((candidate) => !(candidate.owner === owner && candidate.repo === repo && candidate.number === input.number));
1575
+ await threadStore.saveThread({ thread: {
1576
+ ...loadedThread,
1577
+ id: input.threadId,
1578
+ resourceId: input.resourceId,
1579
+ createdAt: loadedThread.createdAt ?? /* @__PURE__ */ new Date(),
1580
+ updatedAt: /* @__PURE__ */ new Date(),
1581
+ metadata: setGithubMetadata(loadedThread.metadata, { subscriptions })
1582
+ } });
1583
+ this.#notifySubscriptionsChanged({
1584
+ threadId: input.threadId,
1585
+ resourceId: input.resourceId,
1586
+ subscriptions
1587
+ });
1588
+ if (subscriptions.length === 0) this.stopPollingForThread({
1589
+ threadId: input.threadId,
1590
+ resourceId: input.resourceId
1591
+ });
1592
+ return {
1593
+ owner,
1594
+ repo,
1595
+ number: input.number,
1596
+ mode,
1597
+ terminalState,
1598
+ syncResult
1599
+ };
1600
+ }
1481
1601
  const subscriptions = [subscription];
1482
1602
  await threadStore.saveThread({ thread: {
1483
1603
  ...loadedThread,
@@ -1492,7 +1612,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1492
1612
  resourceId: input.resourceId,
1493
1613
  subscriptions
1494
1614
  });
1495
- if (baselineSnapshot) await this.#sendBaselineNotification({
1615
+ if (baselineSnapshot && mode === "working") await this.#sendBaselineNotification({
1496
1616
  threadId: input.threadId,
1497
1617
  resourceId: input.resourceId,
1498
1618
  subscription,
@@ -1506,6 +1626,7 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1506
1626
  owner,
1507
1627
  repo,
1508
1628
  number: input.number,
1629
+ mode,
1509
1630
  subscription,
1510
1631
  syncResult
1511
1632
  };
@@ -1558,7 +1679,8 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1558
1679
  id: readString(signal.id) ?? message.id,
1559
1680
  owner: readString(attributes.owner) ?? readString(github.owner),
1560
1681
  repo: readString(attributes.repo) ?? readString(github.repo),
1561
- number
1682
+ number,
1683
+ ...signal.tagName === "github-subscribe-pr" ? { mode: normalizeGithubSubscriptionMode(attributes.mode ?? github.mode) } : {}
1562
1684
  };
1563
1685
  }
1564
1686
  async #sendStatus(args, signal, status) {
@@ -1570,14 +1692,18 @@ var GithubSignals = class extends _mastra_core_signals.SignalProvider {
1570
1692
  status: status.status,
1571
1693
  owner: signal.owner,
1572
1694
  repo: signal.repo,
1573
- number: signal.number
1695
+ number: signal.number,
1696
+ ...signal.mode ? { mode: signal.mode } : {},
1697
+ ...signal.terminalState ? { terminalState: signal.terminalState } : {}
1574
1698
  },
1575
1699
  metadata: { github: {
1576
1700
  action: status.action,
1577
1701
  status: status.status,
1578
1702
  owner: signal.owner,
1579
1703
  repo: signal.repo,
1580
- number: signal.number
1704
+ number: signal.number,
1705
+ ...signal.mode ? { mode: signal.mode } : {},
1706
+ ...signal.terminalState ? { terminalState: signal.terminalState } : {}
1581
1707
  } }
1582
1708
  });
1583
1709
  }