@mastra/factory 0.28.0-alpha.4 → 0.28.0-alpha.6

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 (235) hide show
  1. package/README.md +52 -28
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +12 -6
  4. package/dist/auth.js.map +1 -1
  5. package/dist/boards/board-writes.d.ts.map +1 -1
  6. package/dist/boards/board-writes.js +6 -7
  7. package/dist/boards/board-writes.js.map +1 -1
  8. package/dist/boards/index.d.ts +1 -1
  9. package/dist/boards/index.d.ts.map +1 -1
  10. package/dist/boards/index.js +2 -2
  11. package/dist/boards/project-boards.d.ts +30 -4
  12. package/dist/boards/project-boards.d.ts.map +1 -1
  13. package/dist/boards/project-boards.js +71 -19
  14. package/dist/boards/project-boards.js.map +1 -1
  15. package/dist/boards/registry.d.ts +7 -1
  16. package/dist/boards/registry.d.ts.map +1 -1
  17. package/dist/boards/registry.js +16 -3
  18. package/dist/boards/registry.js.map +1 -1
  19. package/dist/boards/semantics.d.ts +5 -4
  20. package/dist/boards/semantics.d.ts.map +1 -1
  21. package/dist/boards/semantics.js +5 -4
  22. package/dist/boards/semantics.js.map +1 -1
  23. package/dist/boards/work-migrations.d.ts +4 -3
  24. package/dist/boards/work-migrations.d.ts.map +1 -1
  25. package/dist/boards/work-migrations.js +6 -5
  26. package/dist/boards/work-migrations.js.map +1 -1
  27. package/dist/boards/work-seeds.d.ts +9 -0
  28. package/dist/boards/work-seeds.d.ts.map +1 -0
  29. package/dist/boards/work-seeds.js +56 -0
  30. package/dist/boards/work-seeds.js.map +1 -0
  31. package/dist/boards/work.d.ts +2 -2
  32. package/dist/boards/work.d.ts.map +1 -1
  33. package/dist/boards/work.js +0 -16
  34. package/dist/boards/work.js.map +1 -1
  35. package/dist/factory.d.ts +8 -4
  36. package/dist/factory.d.ts.map +1 -1
  37. package/dist/factory.js +33 -73
  38. package/dist/factory.js.map +1 -1
  39. package/dist/feed-events.d.ts +4 -4
  40. package/dist/feed-events.d.ts.map +1 -1
  41. package/dist/feed-events.js +6 -6
  42. package/dist/feed-events.js.map +1 -1
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +3 -1
  46. package/dist/integrations/base.d.ts +0 -11
  47. package/dist/integrations/base.d.ts.map +1 -1
  48. package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
  49. package/dist/integrations/linear/agent-tools.js +1 -1
  50. package/dist/integrations/linear/agent-tools.js.map +1 -1
  51. package/dist/integrations/slack/integration.d.ts +0 -2
  52. package/dist/integrations/slack/integration.d.ts.map +1 -1
  53. package/dist/integrations/slack/integration.js +0 -5
  54. package/dist/integrations/slack/integration.js.map +1 -1
  55. package/dist/integrations/slack/run-error-card.js +1 -0
  56. package/dist/integrations/slack/run-error-card.js.map +1 -1
  57. package/dist/integrations/slack/slack.d.ts +3 -18
  58. package/dist/integrations/slack/slack.d.ts.map +1 -1
  59. package/dist/integrations/slack/slack.js +3 -74
  60. package/dist/integrations/slack/slack.js.map +1 -1
  61. package/dist/links.d.ts +1 -2
  62. package/dist/links.d.ts.map +1 -1
  63. package/dist/links.js +1 -2
  64. package/dist/links.js.map +1 -1
  65. package/dist/provider-display-name.d.ts.map +1 -1
  66. package/dist/provider-display-name.js +1 -0
  67. package/dist/provider-display-name.js.map +1 -1
  68. package/dist/routes/attention-providers.d.ts +0 -25
  69. package/dist/routes/attention-providers.d.ts.map +1 -1
  70. package/dist/routes/attention-providers.js +2 -150
  71. package/dist/routes/attention-providers.js.map +1 -1
  72. package/dist/routes/attention.d.ts +0 -2
  73. package/dist/routes/attention.d.ts.map +1 -1
  74. package/dist/routes/attention.js +2 -13
  75. package/dist/routes/attention.js.map +1 -1
  76. package/dist/routes/config.d.ts +7 -1
  77. package/dist/routes/config.d.ts.map +1 -1
  78. package/dist/routes/config.js +105 -22
  79. package/dist/routes/config.js.map +1 -1
  80. package/dist/routes/contracts.d.ts +6 -14
  81. package/dist/routes/contracts.d.ts.map +1 -1
  82. package/dist/routes/contracts.js +4 -2
  83. package/dist/routes/contracts.js.map +1 -1
  84. package/dist/routes/feed-events.d.ts +15 -0
  85. package/dist/routes/feed-events.d.ts.map +1 -0
  86. package/dist/routes/feed-events.js +68 -0
  87. package/dist/routes/feed-events.js.map +1 -0
  88. package/dist/routes/knowledge.js +1 -1
  89. package/dist/routes/mastra-gateway.d.ts +19 -0
  90. package/dist/routes/mastra-gateway.d.ts.map +1 -0
  91. package/dist/routes/mastra-gateway.js +120 -0
  92. package/dist/routes/mastra-gateway.js.map +1 -0
  93. package/dist/routes/projects.d.ts +1 -1
  94. package/dist/routes/projects.d.ts.map +1 -1
  95. package/dist/routes/projects.js +1 -1
  96. package/dist/routes/projects.js.map +1 -1
  97. package/dist/routes/provider-credentials.d.ts +6 -1
  98. package/dist/routes/provider-credentials.d.ts.map +1 -1
  99. package/dist/routes/provider-credentials.js +32 -2
  100. package/dist/routes/provider-credentials.js.map +1 -1
  101. package/dist/routes/route.d.ts +6 -0
  102. package/dist/routes/route.d.ts.map +1 -1
  103. package/dist/routes/route.js.map +1 -1
  104. package/dist/routes/surface.d.ts +0 -7
  105. package/dist/routes/surface.d.ts.map +1 -1
  106. package/dist/routes/surface.js +1 -5
  107. package/dist/routes/surface.js.map +1 -1
  108. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  109. package/dist/routes/tenant-credentials.js +5 -1
  110. package/dist/routes/tenant-credentials.js.map +1 -1
  111. package/dist/routes/work-items.d.ts +0 -3
  112. package/dist/routes/work-items.d.ts.map +1 -1
  113. package/dist/routes/work-items.js +0 -1
  114. package/dist/routes/work-items.js.map +1 -1
  115. package/dist/rules/dispatcher.d.ts +0 -3
  116. package/dist/rules/dispatcher.d.ts.map +1 -1
  117. package/dist/rules/dispatcher.js +5 -7
  118. package/dist/rules/dispatcher.js.map +1 -1
  119. package/dist/run-error.d.ts +1 -1
  120. package/dist/run-error.d.ts.map +1 -1
  121. package/dist/run-error.js +38 -5
  122. package/dist/run-error.js.map +1 -1
  123. package/dist/session/live-sessions.d.ts +11 -4
  124. package/dist/session/live-sessions.d.ts.map +1 -1
  125. package/dist/session/live-sessions.js +31 -10
  126. package/dist/session/live-sessions.js.map +1 -1
  127. package/dist/storage/domains/audit/actions.d.ts +1 -1
  128. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  129. package/dist/storage/domains/audit/actions.js +0 -4
  130. package/dist/storage/domains/audit/actions.js.map +1 -1
  131. package/dist/storage/domains/boards/base.d.ts +15 -1
  132. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  133. package/dist/storage/domains/boards/base.js +21 -5
  134. package/dist/storage/domains/boards/base.js.map +1 -1
  135. package/dist/storage/domains/channel-identity/base.d.ts +0 -4
  136. package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
  137. package/dist/storage/domains/channel-identity/base.js +0 -7
  138. package/dist/storage/domains/channel-identity/base.js.map +1 -1
  139. package/dist/storage/domains/work-items/base.d.ts +12 -17
  140. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  141. package/dist/storage/domains/work-items/base.js +42 -117
  142. package/dist/storage/domains/work-items/base.js.map +1 -1
  143. package/dist/storage/domains/work-items/board-version.d.ts +6 -2
  144. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
  145. package/dist/storage/domains/work-items/board-version.js +20 -9
  146. package/dist/storage/domains/work-items/board-version.js.map +1 -1
  147. package/dist/storage/domains/work-items/cards.d.ts +3 -3
  148. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  149. package/dist/storage/domains/work-items/cards.js +10 -10
  150. package/dist/storage/domains/work-items/cards.js.map +1 -1
  151. package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -2
  152. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  153. package/dist/storage/domains/work-items/work-item-schema.js +8 -8
  154. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  155. package/dist/tools/read-tools.d.ts +0 -2
  156. package/dist/tools/read-tools.d.ts.map +1 -1
  157. package/dist/tools/read-tools.js +3 -14
  158. package/dist/tools/read-tools.js.map +1 -1
  159. package/dist/tools/work-item-tools.d.ts +0 -3
  160. package/dist/tools/work-item-tools.d.ts.map +1 -1
  161. package/dist/tools/work-item-tools.js +8 -18
  162. package/dist/tools/work-item-tools.js.map +1 -1
  163. package/dist/work-items/create-work-item.d.ts.map +1 -1
  164. package/dist/work-items/create-work-item.js +3 -2
  165. package/dist/work-items/create-work-item.js.map +1 -1
  166. package/dist/work-items/description-context.d.ts +5 -0
  167. package/dist/work-items/description-context.d.ts.map +1 -0
  168. package/dist/work-items/description-context.js +17 -0
  169. package/dist/work-items/description-context.js.map +1 -0
  170. package/dist/work-items/split-migration.d.ts.map +1 -1
  171. package/dist/work-items/split-migration.js +1 -6
  172. package/dist/work-items/split-migration.js.map +1 -1
  173. package/factory-skills/configure-factory-rules/SKILL.md +3 -3
  174. package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
  175. package/factory-skills/factory-gitlab-review/SKILL.md +5 -5
  176. package/factory-skills/factory-rereview/SKILL.md +70 -24
  177. package/factory-skills/factory-review/SKILL.md +70 -24
  178. package/factory-skills/factory-self-review/SKILL.md +5 -6
  179. package/factory-skills/factory-triage/SKILL.md +11 -22
  180. package/package.json +8 -8
  181. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +0 -8
  182. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +0 -1
  183. package/dist/integrations/slack/emoji-shortcodes.generated.js +0 -1984
  184. package/dist/integrations/slack/emoji-shortcodes.generated.js.map +0 -1
  185. package/dist/integrations/slack/emoji.d.ts +0 -3
  186. package/dist/integrations/slack/emoji.d.ts.map +0 -1
  187. package/dist/integrations/slack/emoji.js +0 -11
  188. package/dist/integrations/slack/emoji.js.map +0 -1
  189. package/dist/integrations/slack/feed-publisher.d.ts +0 -26
  190. package/dist/integrations/slack/feed-publisher.d.ts.map +0 -1
  191. package/dist/integrations/slack/feed-publisher.js +0 -43
  192. package/dist/integrations/slack/feed-publisher.js.map +0 -1
  193. package/dist/routes/attention-activity.d.ts +0 -23
  194. package/dist/routes/attention-activity.d.ts.map +0 -1
  195. package/dist/routes/attention-activity.js +0 -154
  196. package/dist/routes/attention-activity.js.map +0 -1
  197. package/dist/storage/domains/comments/activity.d.ts +0 -40
  198. package/dist/storage/domains/comments/activity.d.ts.map +0 -1
  199. package/dist/storage/domains/comments/activity.js +0 -93
  200. package/dist/storage/domains/comments/activity.js.map +0 -1
  201. package/dist/storage/domains/comments/actor.d.ts +0 -51
  202. package/dist/storage/domains/comments/actor.d.ts.map +0 -1
  203. package/dist/storage/domains/comments/actor.js +0 -37
  204. package/dist/storage/domains/comments/actor.js.map +0 -1
  205. package/dist/storage/domains/comments/base.d.ts +0 -245
  206. package/dist/storage/domains/comments/base.d.ts.map +0 -1
  207. package/dist/storage/domains/comments/base.js +0 -539
  208. package/dist/storage/domains/comments/base.js.map +0 -1
  209. package/dist/storage/domains/comments/domain.d.ts +0 -135
  210. package/dist/storage/domains/comments/domain.d.ts.map +0 -1
  211. package/dist/storage/domains/comments/domain.js +0 -284
  212. package/dist/storage/domains/comments/domain.js.map +0 -1
  213. package/dist/storage/domains/comments/feed-context.d.ts +0 -22
  214. package/dist/storage/domains/comments/feed-context.d.ts.map +0 -1
  215. package/dist/storage/domains/comments/feed-context.js +0 -88
  216. package/dist/storage/domains/comments/feed-context.js.map +0 -1
  217. package/dist/storage/domains/comments/feed-sync.d.ts +0 -21
  218. package/dist/storage/domains/comments/feed-sync.d.ts.map +0 -1
  219. package/dist/storage/domains/comments/feed-sync.js +0 -1
  220. package/dist/storage/domains/comments/parse.d.ts +0 -23
  221. package/dist/storage/domains/comments/parse.d.ts.map +0 -1
  222. package/dist/storage/domains/comments/parse.js +0 -89
  223. package/dist/storage/domains/comments/parse.js.map +0 -1
  224. package/dist/storage/domains/comments/routes.d.ts +0 -24
  225. package/dist/storage/domains/comments/routes.d.ts.map +0 -1
  226. package/dist/storage/domains/comments/routes.js +0 -299
  227. package/dist/storage/domains/comments/routes.js.map +0 -1
  228. package/dist/storage/domains/comments/schema.d.ts +0 -5
  229. package/dist/storage/domains/comments/schema.d.ts.map +0 -1
  230. package/dist/storage/domains/comments/schema.js +0 -178
  231. package/dist/storage/domains/comments/schema.js.map +0 -1
  232. package/dist/storage/domains/comments/wire.d.ts +0 -40
  233. package/dist/storage/domains/comments/wire.d.ts.map +0 -1
  234. package/dist/storage/domains/comments/wire.js +0 -36
  235. package/dist/storage/domains/comments/wire.js.map +0 -1
@@ -5,9 +5,9 @@ export interface FeedScope {
5
5
  }
6
6
  export declare function feedTopic(orgId: string, factoryProjectId: string): string;
7
7
  /**
8
- * One frame for the whole project: `workItemId` names the item whose comments
9
- * moved, and its absence means only the project's attention did. Never awaited
10
- * — a slow or dead broker must not hold up the write it describes.
8
+ * One frame for the whole project: something on the board moved — a card, a
9
+ * decision, a run, or the attention list. Never awaited — a slow or dead broker
10
+ * must not hold up the write it describes.
11
11
  */
12
- export declare function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void;
12
+ export declare function touchFeed(pubsub: PubSub, scope: FeedScope): void;
13
13
  //# sourceMappingURL=feed-events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAarF"}
1
+ {"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAahE"}
@@ -3,15 +3,15 @@ function feedTopic(orgId, factoryProjectId) {
3
3
  return `factory.feed.${orgId}.${factoryProjectId}`;
4
4
  }
5
5
  /**
6
- * One frame for the whole project: `workItemId` names the item whose comments
7
- * moved, and its absence means only the project's attention did. Never awaited
8
- * — a slow or dead broker must not hold up the write it describes.
6
+ * One frame for the whole project: something on the board moved — a card, a
7
+ * decision, a run, or the attention list. Never awaited — a slow or dead broker
8
+ * must not hold up the write it describes.
9
9
  */
10
- function touchFeed(pubsub, scope, workItemId) {
10
+ function touchFeed(pubsub, scope) {
11
11
  pubsub.publish(feedTopic(scope.orgId, scope.factoryProjectId), {
12
12
  type: "factory.feed.touched",
13
- runId: workItemId ?? scope.factoryProjectId,
14
- data: workItemId ? { workItemId } : {}
13
+ runId: scope.factoryProjectId,
14
+ data: {}
15
15
  }).catch((error) => {
16
16
  console.warn("[Factory] Failed to publish a feed touch", {
17
17
  factoryProjectId: scope.factoryProjectId,
@@ -1 +1 @@
1
- {"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: `workItemId` names the item whose comments\n * moved, and its absence means only the project's attention did. Never awaited\n * — a slow or dead broker must not hold up the write it describes.\n */\nexport function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void {\n pubsub\n .publish(feedTopic(scope.orgId, scope.factoryProjectId), {\n type: 'factory.feed.touched',\n runId: workItemId ?? scope.factoryProjectId,\n data: workItemId ? { workItemId } : {},\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a feed touch', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n"],"mappings":";AAOA,SAAgB,UAAU,OAAe,kBAAkC;CACzE,OAAO,gBAAgB,MAAM,GAAG;AAClC;;;;;;AAOA,SAAgB,UAAU,QAAgB,OAAkB,YAA2B;CACrF,OACG,QAAQ,UAAU,MAAM,OAAO,MAAM,gBAAgB,GAAG;EACvD,MAAM;EACN,OAAO,cAAc,MAAM;EAC3B,MAAM,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,4CAA4C;GACvD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL"}
1
+ {"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: something on the board moved — a card, a\n * decision, a run, or the attention list. Never awaited — a slow or dead broker\n * must not hold up the write it describes.\n */\nexport function touchFeed(pubsub: PubSub, scope: FeedScope): void {\n pubsub\n .publish(feedTopic(scope.orgId, scope.factoryProjectId), {\n type: 'factory.feed.touched',\n runId: scope.factoryProjectId,\n data: {},\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a feed touch', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n"],"mappings":";AAOA,SAAgB,UAAU,OAAe,kBAAkC;CACzE,OAAO,gBAAgB,MAAM,GAAG;AAClC;;;;;;AAOA,SAAgB,UAAU,QAAgB,OAAwB;CAChE,OACG,QAAQ,UAAU,MAAM,OAAO,MAAM,gBAAgB,GAAG;EACvD,MAAM;EACN,OAAO,MAAM;EACb,MAAM,CAAC;CACT,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,4CAA4C;GACvD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { BoardDefinitionError, createBoardRegistry, DEFAULT_PHASE_CONTEXT, defaultBoards, defineBoard, FACTORY_AGENT_ID, workBoard, } from './boards/index.js';
2
2
  export type { BoardDefinition, BoardEventIntegration, BoardEventRules, BoardPhase, BoardPhaseDefinition, BoardPhaseExitTool, BoardPhaseRunner, BoardRegistry, BoardSourceClosed, BoardTransition, BoardTransitionPolicy, BoardTransitionPolicyContext, BoardTransitionPolicyResult, InstalledBoard, WorkBoardPhase, } from './boards/index.js';
3
3
  export { BoardWriteError } from './boards/board-writes.js';
4
+ export { boardDefinitionOf } from './boards/stored-board.js';
5
+ export { workSeedWithTriage } from './boards/work-seeds.js';
4
6
  export type { StoredBoardInput, StoredBoardScope, StoredPhaseInput } from './storage/domains/boards/base.js';
5
7
  export type { RuleCondition, RuleGroup, RuleOperator } from './rules/rule-group.js';
6
8
  export { MastraFactory } from './factory.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,SA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V,WAAW,EACX,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,sCAAsC,EAAE,MAAM,wBAAwB,CAAC;AAC/G,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAChH,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC"}
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ import { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, defineBo
3
3
  import { BoardWriteError } from "./boards/board-writes.js";
4
4
  import { workBoard } from "./boards/work.js";
5
5
  import { createBoardRegistry, defaultBoards } from "./boards/registry.js";
6
+ import { boardDefinitionOf } from "./boards/stored-board.js";
7
+ import { workSeedWithTriage } from "./boards/work-seeds.js";
6
8
  import { MastraFactory } from "./factory.js";
7
9
  import { waitForPendingFilesystemCapture } from "./session/filesystem-capture.js";
8
10
  import { LocalFactorySandbox } from "./sandbox/local-factory-sandbox.js";
@@ -14,4 +16,4 @@ import { createStateSigner } from "./state-signing.js";
14
16
  import { createFactorySecretEncryption, createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
15
17
  import { createFactoryRouteAuth } from "./auth.js";
16
18
  import { platformConnectTools } from "./integrations/platform/connect/session-tools.js";
17
- export { BoardDefinitionError, BoardWriteError, ChannelIdentityStorage, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, FactoryProjectsStorage, LocalFactorySandbox, MastraFactory, WorkItemsStorage, createBoardRegistry, createFactoryRouteAuth, createFactorySecretEncryption, createPlaintextFactorySecretEncryption, createStateSigner, defaultBoards, defineBoard, platformConnectTools, primarySource, waitForPendingFilesystemCapture, workBoard };
19
+ export { BoardDefinitionError, BoardWriteError, ChannelIdentityStorage, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, FactoryProjectsStorage, LocalFactorySandbox, MastraFactory, WorkItemsStorage, boardDefinitionOf, createBoardRegistry, createFactoryRouteAuth, createFactorySecretEncryption, createPlaintextFactorySecretEncryption, createStateSigner, defaultBoards, defineBoard, platformConnectTools, primarySource, waitForPendingFilesystemCapture, workBoard, workSeedWithTriage };
@@ -34,8 +34,6 @@ import type { StateSigner } from '../state-signing.js';
34
34
  import type { AuditEventRow } from '../storage/domains/audit/base.js';
35
35
  import type { AuditEmitter } from '../storage/domains/audit/domain.js';
36
36
  import type { ChannelIdentityStorage } from '../storage/domains/channel-identity/base.js';
37
- import type { CommentsDomain } from '../storage/domains/comments/domain.js';
38
- import type { WorkItemFeedPublisher } from '../storage/domains/comments/feed-sync.js';
39
37
  import type { ModelCredentialsStorage } from '../storage/domains/credentials/base.js';
40
38
  import type { IntakeStorage } from '../storage/domains/intake/base.js';
41
39
  import type { IntegrationStorageHandle } from '../storage/domains/integrations/base.js';
@@ -110,8 +108,6 @@ export interface IntegrationContext {
110
108
  sessionRetirement?: SessionRetirementCoordinator;
111
109
  /** Work-items domain slice — deleting a session strips the refs work items hold on it. */
112
110
  workItems?: Pick<WorkItemsStorage, 'clearSessionReferences' | 'hasRunBindingForSession'>;
113
- /** Feed slice for ingesting platform messages; present once work items are ready. */
114
- feed?: Pick<CommentsDomain, 'createComment'>;
115
111
  /** Persistence handles pre-scoped to this integration's stable id. */
116
112
  storage: {
117
113
  generic: IntegrationStorageHandle;
@@ -295,13 +291,6 @@ export interface FactoryIntegration {
295
291
  * loser would silently never receive a message.
296
292
  */
297
293
  channels?(ctx: IntegrationContext): FactoryChannelsConfig;
298
- /**
299
- * Mirrors web feed comments outward — to the platform thread a work item is
300
- * bound to, a webhook, or an issue tracker. Collected from every READY
301
- * integration independent of `channels()`: an integration may publish without
302
- * owning a chat channel.
303
- */
304
- feedPublisher?(ctx: IntegrationContext): WorkItemFeedPublisher;
305
294
  /**
306
295
  * Non-secret config snapshot (booleans + names only, never values). The
307
296
  * factory merges it into system diagnostics/startup logs.
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/integrations/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,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AAC,IAAI,CAAC,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../../src/integrations/linear/agent-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,iBAAS,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;;yIAkCzG;AAED,iBAAS,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;;8IAsCxE;AAED,iBAAS,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;6IAwC7E;AAED,iBAAS,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;;;2IA4C3E;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,gEAAgE;IAChE,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,OAAO,CACT,MAAM,CACJ,MAAM,EACJ,UAAU,CAAC,OAAO,wBAAwB,CAAC,GAC3C,UAAU,CAAC,OAAO,uBAAuB,CAAC,GAC1C,UAAU,CAAC,OAAO,4BAA4B,CAAC,GAC/C,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAChD,CACF,CA2BA"}
1
+ {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../../src/integrations/linear/agent-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,iBAAS,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;;yIAkCzG;AAED,iBAAS,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;;8IAwCxE;AAED,iBAAS,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;6IAwC7E;AAED,iBAAS,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM;;;;2IA4C3E;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,gEAAgE;IAChE,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,OAAO,CACT,MAAM,CACJ,MAAM,EACJ,UAAU,CAAC,OAAO,wBAAwB,CAAC,GAC3C,UAAU,CAAC,OAAO,uBAAuB,CAAC,GAC1C,UAAU,CAAC,OAAO,4BAA4B,CAAC,GAC/C,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAChD,CACF,CA2BA"}
@@ -35,7 +35,7 @@ function createLinearCommentTool(linear, orgId) {
35
35
  description: "Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.",
36
36
  inputSchema: z.object({
37
37
  issue: z.string().min(1).describe("The Linear issue identifier (e.g. \"ENG-123\") or issue UUID."),
38
- body: z.string().min(1).describe("The comment body, as Linear-flavored markdown.")
38
+ body: z.string().min(1).describe("The comment body, as Linear-flavored markdown. Linear does not render HTML (no <details>, <summary> or <!-- comments -->); for a collapsible section, open it with a \"+++ Section title\" line and close it with a lone \"+++\" line.")
39
39
  }),
40
40
  execute: async ({ issue, body }) => {
41
41
  const connection = await linear.loadConnection(orgId);
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.js","names":[],"sources":["../../../src/integrations/linear/agent-tools.ts"],"sourcesContent":["/**\n * Linear tools exposed to the coding agent.\n *\n * Wired into the agent through the SDK's async `extraTools` provider: on each\n * tool-set resolution we map the session's factory project to its owning org\n * and only expose the Linear tools when that org has a Linear connection.\n * Projects whose org never connected Linear (or when the\n * feature is disabled) see no Linear tools at all — the model is never shown\n * tools it can't use.\n *\n * Tenancy mirrors the Linear API routes: everything is scoped by the org that\n * owns the project, and tokens are refreshed through the integration's shared\n * connection lifecycle.\n */\n\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { LinearIntegration } from './integration.js';\nimport { LinearReauthRequiredError } from './integration.js';\n\nfunction createLinearGetIssueTool(linear: LinearIntegration, orgId: string, workspaceUrlKey: string | null) {\n // The URL pattern lets the agent link a ticket it mentions without fetching it first.\n const linkHint = workspaceUrlKey\n ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).`\n : ' To link an issue, use the `url` field of the fetched issue.';\n return createTool({\n id: 'linear_get_issue',\n description: `Fetch a Linear issue's full details — title, description, state, assignee, labels, priority, and discussion comments. Use this whenever you're working on a Linear issue (e.g. ENG-123) to get its complete context.${linkHint}`,\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n }),\n execute: async ({ issue }: { issue: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to fetch issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const detail = await linear.intake.getIssue({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n });\n if (!detail) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return detail;\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to fetch Linear issue: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearCommentTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_create_comment',\n description:\n 'Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.',\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n body: z.string().min(1).describe('The comment body, as Linear-flavored markdown.'),\n }),\n execute: async ({ issue, body }: { issue: string; body: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to post comments.' };\n }\n if (!linear.canPostComments(connection)) {\n return {\n error: 'The Linear connection does not have comment permissions. Reconnect Linear in Settings to grant them.',\n };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const comment = await linear.intake.createComment({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n body,\n });\n if (!comment) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return { posted: true, url: comment.url };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to post Linear comment: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListProjectsTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_projects',\n description:\n 'List the Linear projects and teams in the connected workspace, with the source id linear_list_issues needs. Use this to find a project (e.g. from a linear.app/<workspace>/project/<name-slug>-<id> URL, by matching its name; drop the trailing id from the slug) before listing its issues.',\n inputSchema: z.object({\n query: z.string().optional().describe('Case-insensitive text to match against project and team names.'),\n }),\n execute: async ({ query }: { query?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list projects.' };\n }\n try {\n // Linear sources are scoped by org alone; no Linear implementation reads userId.\n const sources = await linear.intake.listSources({ orgId, userId: '' });\n // Fold hyphens into spaces so a URL slug like \"agent-browser\" matches \"Agent Browser\".\n const normalize = (text: string) =>\n text\n .toLowerCase()\n .replace(/[\\s-]+/g, ' ')\n .trim();\n const needle = normalize(query ?? '');\n const matches = needle ? sources.filter(source => normalize(source.name).includes(needle)) : sources;\n return {\n projects: matches\n .filter(source => source.type === 'project')\n .map(source => ({ sourceId: source.id, name: source.name })),\n teams: matches\n .filter(source => source.type === 'team')\n .map(source => ({ sourceId: source.id, name: source.name, key: source.metadata?.teamKey ?? null })),\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear projects: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListIssuesTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_issues',\n description:\n 'List the open issues (triage, backlog, todo and in progress; completed and canceled are left out) in one Linear project or team, most recently updated first. Get the source id from linear_list_projects, and read an issue in full with linear_get_issue. Pass nextCursor back as cursor for the next page.',\n inputSchema: z.object({\n source: z.string().min(1).describe('The project or team source id returned by linear_list_projects.'),\n labels: z.array(z.string().trim().min(1)).optional().describe('Only return issues carrying one of these label names.'),\n cursor: z.string().optional().describe('The nextCursor from a previous call, to fetch the next page.'),\n }),\n execute: async ({ source, labels, cursor }: { source: string; labels?: string[]; cursor?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const page = await linear.intake.listIssues({\n connection: { type: 'oauth', accessToken },\n sourceIds: [source.trim()],\n ...(labels?.length ? { labels } : {}),\n ...(cursor ? { cursor } : {}),\n });\n return {\n issues: page.issues.map(issue => ({\n identifier: issue.identifier,\n title: issue.title,\n url: issue.url,\n state: issue.state,\n priority: issue.priority,\n assignee: issue.assignee,\n labels: issue.labels,\n updatedAt: issue.updatedAt,\n })),\n nextCursor: page.nextCursor,\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear issues: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\n/**\n * Async `extraTools` provider: expose Linear tools only when the session's\n * project belongs to an org with an active Linear connection.\n */\nexport async function buildLinearAgentTools({\n requestContext,\n linear,\n}: {\n requestContext: RequestContext;\n /** The integration instance providing the Linear API client. */\n linear: LinearIntegration;\n}): Promise<\n Record<\n string,\n | ReturnType<typeof createLinearGetIssueTool>\n | ReturnType<typeof createLinearCommentTool>\n | ReturnType<typeof createLinearListProjectsTool>\n | ReturnType<typeof createLinearListIssuesTool>\n >\n> {\n if (!linear.authEnabled) return {};\n\n const ctx = requestContext.get('controller') as\n AgentControllerRequestContext<{ factoryProjectId?: string }> | undefined;\n if (!ctx) return {};\n\n // Prefer the Factory recorded on the session. Factory sessions run under the\n // Factory as their resource, so the resource is the fallback; a legacy\n // session whose resource is its own id resolves to no project.\n const projectId = ctx.getState().factoryProjectId ?? ctx.resourceId;\n if (!projectId) return {};\n\n const orgId = await linear.resolveOrgId(projectId);\n if (!orgId) return {};\n const check = await linear.checkConnection(orgId);\n if (!check.connected) return {};\n\n return {\n linear_get_issue: createLinearGetIssueTool(linear, orgId, check.workspaceUrlKey),\n linear_list_projects: createLinearListProjectsTool(linear, orgId),\n linear_list_issues: createLinearListIssuesTool(linear, orgId),\n // Only offered when the granted OAuth scope allows posting comments —\n // connections made before `comments:create` was requested are read-only\n // until the org reconnects Linear.\n ...(check.canComment ? { linear_create_comment: createLinearCommentTool(linear, orgId) } : {}),\n };\n}\n"],"mappings":";;;;AAuBA,SAAS,yBAAyB,QAA2B,OAAe,iBAAgC;CAE1G,MAAM,WAAW,kBACb,wDAAwD,gBA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AW,MAAM;KACnB,EAAE;KACF,YAAY,KAAK;IACnB;GACF,SAAS,KAAK;IACZ,IAAI,eAAe,2BACjB,OAAO,EAAE,OAAO,IAAI,QAAQ;IAE9B,OAAO,EAAE,OAAO,iCAAiC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,IAAI;GACtG;EACF;CACF,CAAC;AACH;;;;;AAMA,eAAsB,sBAAsB,EAC1C,gBACA,UAaA;CACA,IAAI,CAAC,OAAO,aAAa,OAAO,CAAC;CAEjC,MAAM,MAAM,eAAe,IAAI,YAAY;CAE3C,IAAI,CAAC,KAAK,OAAO,CAAC;CAKlB,MAAM,YAAY,IAAI,SAAS,CAAC,CAAC,oBAAoB,IAAI;CACzD,IAAI,CAAC,WAAW,OAAO,CAAC;CAExB,MAAM,QAAQ,MAAM,OAAO,aAAa,SAAS;CACjD,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,QAAQ,MAAM,OAAO,gBAAgB,KAAK;CAChD,IAAI,CAAC,MAAM,WAAW,OAAO,CAAC;CAE9B,OAAO;EACL,kBAAkB,yBAAyB,QAAQ,OAAO,MAAM,eAAe;EAC/E,sBAAsB,6BAA6B,QAAQ,KAAK;EAChE,oBAAoB,2BAA2B,QAAQ,KAAK;EAI5D,GAAI,MAAM,aAAa,EAAE,uBAAuB,wBAAwB,QAAQ,KAAK,EAAE,IAAI,CAAC;CAC9F;AACF"}
1
+ {"version":3,"file":"agent-tools.js","names":[],"sources":["../../../src/integrations/linear/agent-tools.ts"],"sourcesContent":["/**\n * Linear tools exposed to the coding agent.\n *\n * Wired into the agent through the SDK's async `extraTools` provider: on each\n * tool-set resolution we map the session's factory project to its owning org\n * and only expose the Linear tools when that org has a Linear connection.\n * Projects whose org never connected Linear (or when the\n * feature is disabled) see no Linear tools at all — the model is never shown\n * tools it can't use.\n *\n * Tenancy mirrors the Linear API routes: everything is scoped by the org that\n * owns the project, and tokens are refreshed through the integration's shared\n * connection lifecycle.\n */\n\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { LinearIntegration } from './integration.js';\nimport { LinearReauthRequiredError } from './integration.js';\n\nfunction createLinearGetIssueTool(linear: LinearIntegration, orgId: string, workspaceUrlKey: string | null) {\n // The URL pattern lets the agent link a ticket it mentions without fetching it first.\n const linkHint = workspaceUrlKey\n ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).`\n : ' To link an issue, use the `url` field of the fetched issue.';\n return createTool({\n id: 'linear_get_issue',\n description: `Fetch a Linear issue's full details — title, description, state, assignee, labels, priority, and discussion comments. Use this whenever you're working on a Linear issue (e.g. ENG-123) to get its complete context.${linkHint}`,\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n }),\n execute: async ({ issue }: { issue: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to fetch issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const detail = await linear.intake.getIssue({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n });\n if (!detail) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return detail;\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to fetch Linear issue: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearCommentTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_create_comment',\n description:\n 'Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.',\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n body: z.string().min(1).describe(\n 'The comment body, as Linear-flavored markdown. Linear does not render HTML (no <details>, <summary> or <!-- comments -->); for a collapsible section, open it with a \"+++ Section title\" line and close it with a lone \"+++\" line.',\n ),\n }),\n execute: async ({ issue, body }: { issue: string; body: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to post comments.' };\n }\n if (!linear.canPostComments(connection)) {\n return {\n error: 'The Linear connection does not have comment permissions. Reconnect Linear in Settings to grant them.',\n };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const comment = await linear.intake.createComment({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n body,\n });\n if (!comment) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return { posted: true, url: comment.url };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to post Linear comment: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListProjectsTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_projects',\n description:\n 'List the Linear projects and teams in the connected workspace, with the source id linear_list_issues needs. Use this to find a project (e.g. from a linear.app/<workspace>/project/<name-slug>-<id> URL, by matching its name; drop the trailing id from the slug) before listing its issues.',\n inputSchema: z.object({\n query: z.string().optional().describe('Case-insensitive text to match against project and team names.'),\n }),\n execute: async ({ query }: { query?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list projects.' };\n }\n try {\n // Linear sources are scoped by org alone; no Linear implementation reads userId.\n const sources = await linear.intake.listSources({ orgId, userId: '' });\n // Fold hyphens into spaces so a URL slug like \"agent-browser\" matches \"Agent Browser\".\n const normalize = (text: string) =>\n text\n .toLowerCase()\n .replace(/[\\s-]+/g, ' ')\n .trim();\n const needle = normalize(query ?? '');\n const matches = needle ? sources.filter(source => normalize(source.name).includes(needle)) : sources;\n return {\n projects: matches\n .filter(source => source.type === 'project')\n .map(source => ({ sourceId: source.id, name: source.name })),\n teams: matches\n .filter(source => source.type === 'team')\n .map(source => ({ sourceId: source.id, name: source.name, key: source.metadata?.teamKey ?? null })),\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear projects: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListIssuesTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_issues',\n description:\n 'List the open issues (triage, backlog, todo and in progress; completed and canceled are left out) in one Linear project or team, most recently updated first. Get the source id from linear_list_projects, and read an issue in full with linear_get_issue. Pass nextCursor back as cursor for the next page.',\n inputSchema: z.object({\n source: z.string().min(1).describe('The project or team source id returned by linear_list_projects.'),\n labels: z.array(z.string().trim().min(1)).optional().describe('Only return issues carrying one of these label names.'),\n cursor: z.string().optional().describe('The nextCursor from a previous call, to fetch the next page.'),\n }),\n execute: async ({ source, labels, cursor }: { source: string; labels?: string[]; cursor?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const page = await linear.intake.listIssues({\n connection: { type: 'oauth', accessToken },\n sourceIds: [source.trim()],\n ...(labels?.length ? { labels } : {}),\n ...(cursor ? { cursor } : {}),\n });\n return {\n issues: page.issues.map(issue => ({\n identifier: issue.identifier,\n title: issue.title,\n url: issue.url,\n state: issue.state,\n priority: issue.priority,\n assignee: issue.assignee,\n labels: issue.labels,\n updatedAt: issue.updatedAt,\n })),\n nextCursor: page.nextCursor,\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear issues: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\n/**\n * Async `extraTools` provider: expose Linear tools only when the session's\n * project belongs to an org with an active Linear connection.\n */\nexport async function buildLinearAgentTools({\n requestContext,\n linear,\n}: {\n requestContext: RequestContext;\n /** The integration instance providing the Linear API client. */\n linear: LinearIntegration;\n}): Promise<\n Record<\n string,\n | ReturnType<typeof createLinearGetIssueTool>\n | ReturnType<typeof createLinearCommentTool>\n | ReturnType<typeof createLinearListProjectsTool>\n | ReturnType<typeof createLinearListIssuesTool>\n >\n> {\n if (!linear.authEnabled) return {};\n\n const ctx = requestContext.get('controller') as\n AgentControllerRequestContext<{ factoryProjectId?: string }> | undefined;\n if (!ctx) return {};\n\n // Prefer the Factory recorded on the session. Factory sessions run under the\n // Factory as their resource, so the resource is the fallback; a legacy\n // session whose resource is its own id resolves to no project.\n const projectId = ctx.getState().factoryProjectId ?? ctx.resourceId;\n if (!projectId) return {};\n\n const orgId = await linear.resolveOrgId(projectId);\n if (!orgId) return {};\n const check = await linear.checkConnection(orgId);\n if (!check.connected) return {};\n\n return {\n linear_get_issue: createLinearGetIssueTool(linear, orgId, check.workspaceUrlKey),\n linear_list_projects: createLinearListProjectsTool(linear, orgId),\n linear_list_issues: createLinearListIssuesTool(linear, orgId),\n // Only offered when the granted OAuth scope allows posting comments —\n // connections made before `comments:create` was requested are read-only\n // until the org reconnects Linear.\n ...(check.canComment ? { linear_create_comment: createLinearCommentTool(linear, orgId) } : {}),\n };\n}\n"],"mappings":";;;;AAuBA,SAAS,yBAAyB,QAA2B,OAAe,iBAAgC;CAE1G,MAAM,WAAW,kBACb,wDAAwD,gBAAgB,+CAA+C,gBAAgB,oBACvI;CACJ,OAAO,WAAW;EAChB,IAAI;EACJ,aAAa,uNAAuN;EACpO,aAAa,EAAE,OAAO,EACpB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,+DAA6D,EACjG,CAAC;EACD,SAAS,OAAO,EAAE,YAA+B;GAC/C,MAAM,aAAa,MAAM,OAAO,eAAe,KAAK;GACpD,IAAI,CAAC,YACH,OAAO,EAAE,OAAO,2FAA2F;GAE7G,I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AM,eAAe,IAAI,YAAY;CAE3C,IAAI,CAAC,KAAK,OAAO,CAAC;CAKlB,MAAM,YAAY,IAAI,SAAS,CAAC,CAAC,oBAAoB,IAAI;CACzD,IAAI,CAAC,WAAW,OAAO,CAAC;CAExB,MAAM,QAAQ,MAAM,OAAO,aAAa,SAAS;CACjD,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,QAAQ,MAAM,OAAO,gBAAgB,KAAK;CAChD,IAAI,CAAC,MAAM,WAAW,OAAO,CAAC;CAE9B,OAAO;EACL,kBAAkB,yBAAyB,QAAQ,OAAO,MAAM,eAAe;EAC/E,sBAAsB,6BAA6B,QAAQ,KAAK;EAChE,oBAAoB,2BAA2B,QAAQ,KAAK;EAI5D,GAAI,MAAM,aAAa,EAAE,uBAAuB,wBAAwB,QAAQ,KAAK,EAAE,IAAI,CAAC;CAC9F;AACF"}
@@ -22,7 +22,6 @@ import type { InputProcessor, OutputProcessor } from '@mastra/core/processors';
22
22
  import type { RequestContext } from '@mastra/core/request-context';
23
23
  import type { ApiRoute } from '@mastra/core/server';
24
24
  import type { SlackAdapterChannelConfig } from '@mastra/slack';
25
- import type { WorkItemFeedPublisher } from '../../storage/domains/comments/feed-sync.js';
26
25
  import type { FactoryChannelsConfig, FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js';
27
26
  import type { SlackToolSettings } from './tool-settings.js';
28
27
  /** Slack app credentials, read from env ONCE by the deploy entry. */
@@ -117,7 +116,6 @@ export declare class SlackIntegration implements FactoryIntegration {
117
116
  */
118
117
  postToolObserver({ toolContext, requestContext, }: Parameters<NonNullable<FactoryIntegration['postToolObserver']>>[0]): Promise<void>;
119
118
  channels(ctx: IntegrationContext): FactoryChannelsConfig;
120
- feedPublisher(ctx: IntegrationContext): WorkItemFeedPublisher;
121
119
  routes(ctx: IntegrationContext): ApiRoute[];
122
120
  diagnostics(): Record<string, unknown>;
123
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":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QAAE,QAAQ,CAAC,EAAE,MAAM,aAAa,GAAG,IAAI,GAAG,SAAS,CAAA;KAAE,GAAG,IAAI,CAE5E;IAED;;;;;OAKG;IACG,UAAU,CAAC,EAAE,cAAc,EAAE,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAUlG;IAED;;;OAGG;IACG,gBAAgB,CAAC,EACrB,WAAW,EACX,cAAc,GACf,EAAE,UAAU,CAAC,WAAW,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpF;IAED,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,qBAAqB,CA0BvD;IAED,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE,CAY1C;IAED,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQrC;CACF"}
@@ -4,7 +4,6 @@ import { FactoryChannelReplyProcessor } from "./channel-reply-processor.js";
4
4
  import { FactoryChannelSessionLinkProcessor } from "./channel-session-link-processor.js";
5
5
  import { createSlackChatTools } from "./chat-tools.js";
6
6
  import { createSlackConnectRoutes } from "./connect-route.js";
7
- import { SlackFeedPublisher } from "./feed-publisher.js";
8
7
  import { FactoryReplyReminderProcessor } from "./reply-reminder-processor.js";
9
8
  import { FactoryReplyStreamProcessor, createReplyTool } from "./reply-tool.js";
10
9
  import { createShareFileTool, isSlackThread, slackThreadOf } from "./share-file-tool.js";
@@ -171,13 +170,9 @@ var SlackIntegration = class {
171
170
  modelCredentials: ctx.storage.modelCredentials,
172
171
  voiceSettings: ctx.storage.voiceSettings,
173
172
  workItems: ctx.runtime?.workItems,
174
- feed: ctx.feed,
175
173
  adapterOptions: this.#adapterOptions
176
174
  });
177
175
  }
178
- feedPublisher(ctx) {
179
- return new SlackFeedPublisher({ controller: ctx.controller });
180
- }
181
176
  routes(ctx) {
182
177
  const { clientId, clientSecret, oidcRedirectBaseUrl, uiOrigin } = this.#config;
183
178
  return createSlackConnectRoutes({
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","names":[],"sources":["../../../src/integrations/slack/integration.ts"],"sourcesContent":["/**\n * `SlackIntegration` — Slack as a `FactoryIntegration`.\n *\n * Slack contributes two things to a factory: the chat channels that carry\n * inbound messages into agent runs (`channels()`), and the browser-facing\n * account-link routes that bind a Slack sender to a Mastra tenant (`routes()`).\n * Both used to be assembled by hand in the deploy entry, which had to reach\n * into the prepared agent controller by string key, resolve storage domains\n * itself, mint its own state signer, and splice routes onto the factory's\n * assembled server config. Implementing the integration interface instead means\n * the factory does all of that the same way it already does for GitHub and\n * Linear, and the entry's job shrinks to reading Slack's env vars once.\n *\n * Slack ships as a factory built-in alongside GitHub and Linear (it originally\n * lived in `mastracode/web` to keep `@mastra/slack`/`chat` out of this package;\n * the team reversed that so `create-factory` consumers get Slack channels out\n * of the box). The integration interface remains open — third parties still add\n * capabilities by implementing `FactoryIntegration` from outside the package.\n */\n\nimport type { AgentChannels, TypingStatusFn } from '@mastra/core/channels';\nimport type { InputProcessor, OutputProcessor } from '@mastra/core/processors';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { SlackAdapterChannelConfig } from '@mastra/slack';\n\nimport type { WorkItemFeedPublisher } from '../../storage/domains/comments/feed-sync.js';\n\nimport type { FactoryChannelsConfig, FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js';\nimport { announcePullRequest } from '../channel-thread-announcements.js';\nimport { parseCreatedPullRequest } from '../github/session-subscriptions.js';\nimport { FactoryChannelReplyProcessor } from './channel-reply-processor.js';\nimport { FactoryChannelSessionLinkProcessor } from './channel-session-link-processor.js';\nimport { createSlackChatTools } from './chat-tools.js';\nimport { createSlackConnectRoutes } from './connect-route.js';\nimport { SlackFeedPublisher } from './feed-publisher.js';\nimport { FactoryReplyReminderProcessor } from './reply-reminder-processor.js';\nimport { createReplyTool, FactoryReplyStreamProcessor, REPLY_TOOL_NAME } from './reply-tool.js';\nimport { createShareFileTool, isSlackThread, slackThreadOf } from './share-file-tool.js';\nimport type { ShareFileToolDeps } from './share-file-tool.js';\nimport { createSlackChannelsConfig } from './slack.js';\nimport { DEFAULT_SLACK_TOOL_SETTINGS, slackToolSettingsSchema } from './tool-settings.js';\nimport type { SlackToolSettings } from './tool-settings.js';\n\n/** Slack app credentials, read from env ONCE by the deploy entry. */\nexport interface SlackIntegrationConfig {\n /** Slack event transport. Defaults to webhook mode. */\n mode?: 'webhook' | 'socket';\n /** Verifies inbound Slack request signatures. Required in webhook mode. */\n signingSecret?: string;\n /** App-level token used to connect to Slack. Required in socket mode. */\n appToken?: string;\n /** Bot token used to post replies and ephemeral cards. */\n botToken?: string;\n /**\n * OAuth client credentials. Required for account linking: \"Sign in with\n * Slack\" (OIDC) is the only flow that writes a link, so without these the\n * settings surface reports `canConnect: false` and no sender can link.\n */\n clientId?: string;\n clientSecret?: string;\n /**\n * HTTPS origin Slack redirects back to. Slack requires HTTPS, so locally this\n * is the tunnel origin rather than the app's own public URL.\n */\n oidcRedirectBaseUrl?: string;\n /** SPA origin the post-connect redirect returns to. */\n uiOrigin?: string;\n /**\n * Overrides for the Slack channel adapter entry.\n *\n * @example\n * ```ts\n * new SlackIntegration({\n * signingSecret,\n * adapterOptions: {\n * streaming: true,\n * toolDisplay: 'grouped',\n * },\n * });\n * ```\n */\n adapterOptions?: SlackAdapterChannelConfig;\n /**\n * What sessions started from Slack may do with the Slack tools. By default a\n * session can read and post only in its own channel, and can't send DMs.\n *\n * @example\n * ```ts\n * new SlackIntegration({\n * signingSecret,\n * // Any channel the app is in, and DMs to anyone in the workspace.\n * tools: { channels: 'all', directMessages: 'anyone' },\n * });\n * ```\n */\n tools?: Partial<SlackToolSettings>;\n}\n\n/** Slack renders the status inline next to the app name; keep it to one short line. */\nconst MAX_STATUS_LENGTH = 80;\n\n/**\n * Turns a tool's `description` arg (\"Listing the repo root\") into a status\n * line that reads after the app name (\"<App> is listing the repo root…\").\n * Only the first line counts: issue/PR creators carry whole bodies there.\n */\nfunction describeToolCall(args: unknown): string | undefined {\n if (!args || typeof args !== 'object') return undefined;\n const { description } = args as { description?: unknown };\n if (typeof description !== 'string') return undefined;\n const line = description\n .split('\\n')\n .map(part => part.replace(/\\s+/g, ' ').trim())\n .find(Boolean);\n if (!line) return undefined;\n const text = line.length > MAX_STATUS_LENGTH ? `${line.slice(0, MAX_STATUS_LENGTH - 1)}…` : line;\n // Drop the sentence-case capital (\"Listing\" → \"listing\") but leave acronyms\n // and identifiers (\"PR lookup\", \"CI status\") alone.\n return `is ${/^[A-Z][a-z]/.test(text) ? text.charAt(0).toLowerCase() + text.slice(1) : text}`;\n}\n\n/**\n * With reply text hidden, streamed text never reaches the thread, so it gets\n * no status: an \"is typing...\" set after the reply tool's post would sit on\n * the thread with nothing coming, and race the clear at the end of the run.\n */\nconst factoryTypingStatus =\n (textDisplay: SlackAdapterChannelConfig['textDisplay']): TypingStatusFn =>\n chunk => {\n switch (chunk.type) {\n case 'reasoning-delta':\n return 'is thinking...';\n case 'text-delta':\n return textDisplay === 'hidden' ? undefined : 'is typing...';\n // The reply tool's text streams into the thread as the model writes it.\n case 'tool-call-input-streaming-start':\n return chunk.payload.toolName === REPLY_TOOL_NAME ? 'is typing...' : undefined;\n case 'tool-call':\n // Still finishing the streamed reply; don't flip to \"is working...\".\n if (chunk.payload.toolName === REPLY_TOOL_NAME) return 'is typing...';\n return describeToolCall(chunk.payload.args) ?? 'is working...';\n default:\n return undefined;\n }\n};\n\n/**\n * Drops keys the caller set to `undefined` so spreading the overrides cannot\n * erase the Factory defaults they sit on top of.\n */\nfunction adapterOverrides(options: SlackAdapterChannelConfig | undefined): SlackAdapterChannelConfig {\n return Object.fromEntries(\n Object.entries(options ?? {}).filter(([, value]) => value !== undefined),\n ) as SlackAdapterChannelConfig;\n}\n\n/**\n * Factory defaults under the caller's overrides. Tool calls stay out of the\n * thread: a Factory session runs hundreds of them, and a row per call (or a\n * card per call) buries the reply. Progress shows through the typing status\n * instead, which names the tool's current step; the session link carries the\n * full trace. `grouped` remains available via `adapterOptions` for callers\n * who want Slack's \"Thinking Steps\" widget.\n */\nfunction factoryAdapterOptions(overrides: SlackAdapterChannelConfig): SlackAdapterChannelConfig {\n const textDisplay = overrides.textDisplay ?? 'hidden';\n return { typingStatus: factoryTypingStatus(textDisplay), toolDisplay: 'hidden', textDisplay, ...overrides };\n}\n\nexport class SlackIntegration implements FactoryIntegration {\n readonly id = 'slack';\n /**\n * The OIDC connect flow round-trips a signed `state` through Slack, so the\n * replica handling the callback must be able to verify a state a different\n * replica signed.\n */\n readonly requiresStableStateSigner = true;\n\n readonly #config: SlackIntegrationConfig;\n readonly #toolSettings: SlackToolSettings;\n readonly #adapterOptions: SlackAdapterChannelConfig;\n /** Bound in `initialize()`; the controller mounts after integrations are built. */\n #channels: ShareFileToolDeps['channels'];\n readonly #deps: ShareFileToolDeps = { channels: () => this.#channels?.() };\n /**\n * With reply text hidden (the Factory default) the agent speaks through\n * `reply_in_thread`, so the prompt, reminder and live streaming for that\n * tool come with it. The setting is fixed for the deployment, so it is\n * decided once here rather than on every run.\n */\n readonly processors: { input: InputProcessor[]; output: OutputProcessor[] };\n /**\n * Whether `channels()` found a source-control owner on the context and wired\n * repo-backed sessions. Set at the channels() attach path, which runs once at\n * boot before diagnostics are served.\n */\n #repoBackedSessions = false;\n\n constructor(config: SlackIntegrationConfig) {\n const mode = config.mode ?? 'webhook';\n if (mode === 'webhook' && !config.signingSecret) {\n throw new Error(\n \"SlackIntegration: 'signingSecret' is required in webhook mode — Slack cannot verify inbound requests without it.\",\n );\n }\n if (mode === 'socket' && !config.appToken) {\n throw new Error(\"SlackIntegration: 'appToken' is required in socket mode — Slack cannot open a Socket Mode connection without it.\");\n }\n if (mode === 'socket' && !config.botToken) {\n throw new Error(\"SlackIntegration: 'botToken' is required in socket mode — Factory cannot reply without it.\");\n }\n this.#config = config;\n // An explicit `undefined` means \"use the default\", not \"unset it\".\n const granted = Object.fromEntries(Object.entries(config.tools ?? {}).filter(([, value]) => value !== undefined));\n this.#toolSettings = slackToolSettingsSchema.parse({ ...DEFAULT_SLACK_TOOL_SETTINGS, ...granted });\n this.#adapterOptions = factoryAdapterOptions(adapterOverrides(config.adapterOptions));\n const textHidden = this.#textHidden;\n this.processors = {\n input: [\n new FactoryChannelReplyProcessor(),\n ...(textHidden ? [new FactoryReplyReminderProcessor()] : []),\n ],\n output: [\n new FactoryChannelSessionLinkProcessor(),\n ...(textHidden ? [new FactoryReplyStreamProcessor(this.#deps)] : []),\n ],\n };\n }\n\n get #textHidden(): boolean {\n return this.#adapterOptions.textDisplay === 'hidden';\n }\n\n initialize(args: { channels?: () => AgentChannels | null | undefined }): void {\n this.#channels = args.channels;\n }\n\n /**\n * On runs whose session is linked to a Slack thread: `attach_file`,\n * `reply_in_thread` when reply text is hidden, and the Slack read, post,\n * search, lookup and DM tools. The tools find the thread to post into when\n * they are called.\n */\n async agentTools({ requestContext }: { requestContext: RequestContext }): Promise<IntegrationTools> {\n const slackThread = await slackThreadOf(requestContext, this.#deps);\n if (!slackThread) return {};\n const chat = this.#channels?.()?.sdk;\n const sessionThreadId = slackThread.threadId;\n return {\n ...createShareFileTool(requestContext, this.#deps),\n ...(this.#textHidden ? createReplyTool(requestContext, this.#deps) : {}),\n ...(chat && sessionThreadId ? createSlackChatTools({ chat, sessionThreadId, settings: this.#toolSettings }) : {}),\n };\n }\n\n /**\n * When a run opens a pull request, post its link into the session's Slack\n * thread.\n */\n async postToolObserver({\n toolContext,\n requestContext,\n }: Parameters<NonNullable<FactoryIntegration['postToolObserver']>>[0]): Promise<void> {\n const url = parseCreatedPullRequest(toolContext);\n const threadId = (requestContext?.get('controller') as { threadId?: string } | undefined)?.threadId;\n if (!url || !requestContext || !threadId || !(await isSlackThread(requestContext, this.#deps))) return;\n // Not awaited: the tool call must not wait on Slack.\n void announcePullRequest(this.#channels?.(), threadId, 'opened', url).catch(error =>\n console.warn('[slack] pull request opened announcement failed', error),\n );\n }\n\n channels(ctx: IntegrationContext): FactoryChannelsConfig {\n // Repo-backed sessions select the source-control provider from the linked\n // repository on each Factory project.\n const sourceControls =\n ctx.storage.sourceControls ?? (ctx.storage.sourceControlOwner ? [ctx.storage.sourceControlOwner] : []);\n this.#repoBackedSessions = sourceControls.length > 0;\n const mode = this.#config.mode ?? 'webhook';\n return createSlackChannelsConfig({\n slack: {\n mode: this.#config.mode,\n ...(mode === 'webhook'\n ? { clientId: this.#config.clientId, clientSecret: this.#config.clientSecret }\n : {}),\n signingSecret: this.#config.signingSecret,\n appToken: this.#config.appToken,\n botToken: this.#config.botToken,\n },\n accountLinks: ctx.storage.channelIdentity,\n projects: ctx.storage.projects,\n sourceControls,\n modelDefaults: ctx.storage.modelDefaults,\n modelCredentials: ctx.storage.modelCredentials,\n voiceSettings: ctx.storage.voiceSettings,\n workItems: ctx.runtime?.workItems,\n feed: ctx.feed,\n adapterOptions: this.#adapterOptions,\n });\n }\n\n feedPublisher(ctx: IntegrationContext): WorkItemFeedPublisher {\n return new SlackFeedPublisher({ controller: ctx.controller });\n }\n\n routes(ctx: IntegrationContext): ApiRoute[] {\n const { clientId, clientSecret, oidcRedirectBaseUrl, uiOrigin } = this.#config;\n return createSlackConnectRoutes({\n auth: ctx.auth,\n accountLinks: ctx.storage.channelIdentity,\n tenantStateSigner: ctx.stateSigner,\n oidc:\n clientId && clientSecret && oidcRedirectBaseUrl\n ? { clientId, clientSecret, redirectBaseUrl: oidcRedirectBaseUrl, uiOrigin }\n : undefined,\n projects: ctx.storage.projects,\n });\n }\n\n diagnostics(): Record<string, unknown> {\n const { clientId, clientSecret, botToken, oidcRedirectBaseUrl } = this.#config;\n return {\n configured: true,\n botTokenConfigured: Boolean(botToken),\n oidcConfigured: Boolean(clientId && clientSecret && oidcRedirectBaseUrl),\n repoBackedSessions: this.#repoBackedSessions,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA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AW,CAAC;CAC9D;CAEA,OAAO,KAAqC;EAC1C,MAAM,EAAE,UAAU,cAAc,qBAAqB,aAAa,KAAK;EACvE,OAAO,yBAAyB;GAC9B,MAAM,IAAI;GACV,cAAc,IAAI,QAAQ;GAC1B,mBAAmB,IAAI;GACvB,MACE,YAAY,gBAAgB,sBACxB;IAAE;IAAU;IAAc,iBAAiB;IAAqB;GAAS,IACzE,KAAA;GACN,UAAU,IAAI,QAAQ;EACxB,CAAC;CACH;CAEA,cAAuC;EACrC,MAAM,EAAE,UAAU,cAAc,UAAU,wBAAwB,KAAK;EACvE,OAAO;GACL,YAAY;GACZ,oBAAoB,QAAQ,QAAQ;GACpC,gBAAgB,QAAQ,YAAY,gBAAgB,mBAAmB;GACvE,oBAAoB,KAAK;EAC3B;CACF;AACF"}
1
+ {"version":3,"file":"integration.js","names":[],"sources":["../../../src/integrations/slack/integration.ts"],"sourcesContent":["/**\n * `SlackIntegration` — Slack as a `FactoryIntegration`.\n *\n * Slack contributes two things to a factory: the chat channels that carry\n * inbound messages into agent runs (`channels()`), and the browser-facing\n * account-link routes that bind a Slack sender to a Mastra tenant (`routes()`).\n * Both used to be assembled by hand in the deploy entry, which had to reach\n * into the prepared agent controller by string key, resolve storage domains\n * itself, mint its own state signer, and splice routes onto the factory's\n * assembled server config. Implementing the integration interface instead means\n * the factory does all of that the same way it already does for GitHub and\n * Linear, and the entry's job shrinks to reading Slack's env vars once.\n *\n * Slack ships as a factory built-in alongside GitHub and Linear (it originally\n * lived in `mastracode/web` to keep `@mastra/slack`/`chat` out of this package;\n * the team reversed that so `create-factory` consumers get Slack channels out\n * of the box). The integration interface remains open — third parties still add\n * capabilities by implementing `FactoryIntegration` from outside the package.\n */\n\nimport type { AgentChannels, TypingStatusFn } from '@mastra/core/channels';\nimport type { InputProcessor, OutputProcessor } from '@mastra/core/processors';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { SlackAdapterChannelConfig } from '@mastra/slack';\n\n\nimport type { FactoryChannelsConfig, FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js';\nimport { announcePullRequest } from '../channel-thread-announcements.js';\nimport { parseCreatedPullRequest } from '../github/session-subscriptions.js';\nimport { FactoryChannelReplyProcessor } from './channel-reply-processor.js';\nimport { FactoryChannelSessionLinkProcessor } from './channel-session-link-processor.js';\nimport { createSlackChatTools } from './chat-tools.js';\nimport { createSlackConnectRoutes } from './connect-route.js';\nimport { FactoryReplyReminderProcessor } from './reply-reminder-processor.js';\nimport { createReplyTool, FactoryReplyStreamProcessor, REPLY_TOOL_NAME } from './reply-tool.js';\nimport { createShareFileTool, isSlackThread, slackThreadOf } from './share-file-tool.js';\nimport type { ShareFileToolDeps } from './share-file-tool.js';\nimport { createSlackChannelsConfig } from './slack.js';\nimport { DEFAULT_SLACK_TOOL_SETTINGS, slackToolSettingsSchema } from './tool-settings.js';\nimport type { SlackToolSettings } from './tool-settings.js';\n\n/** Slack app credentials, read from env ONCE by the deploy entry. */\nexport interface SlackIntegrationConfig {\n /** Slack event transport. Defaults to webhook mode. */\n mode?: 'webhook' | 'socket';\n /** Verifies inbound Slack request signatures. Required in webhook mode. */\n signingSecret?: string;\n /** App-level token used to connect to Slack. Required in socket mode. */\n appToken?: string;\n /** Bot token used to post replies and ephemeral cards. */\n botToken?: string;\n /**\n * OAuth client credentials. Required for account linking: \"Sign in with\n * Slack\" (OIDC) is the only flow that writes a link, so without these the\n * settings surface reports `canConnect: false` and no sender can link.\n */\n clientId?: string;\n clientSecret?: string;\n /**\n * HTTPS origin Slack redirects back to. Slack requires HTTPS, so locally this\n * is the tunnel origin rather than the app's own public URL.\n */\n oidcRedirectBaseUrl?: string;\n /** SPA origin the post-connect redirect returns to. */\n uiOrigin?: string;\n /**\n * Overrides for the Slack channel adapter entry.\n *\n * @example\n * ```ts\n * new SlackIntegration({\n * signingSecret,\n * adapterOptions: {\n * streaming: true,\n * toolDisplay: 'grouped',\n * },\n * });\n * ```\n */\n adapterOptions?: SlackAdapterChannelConfig;\n /**\n * What sessions started from Slack may do with the Slack tools. By default a\n * session can read and post only in its own channel, and can't send DMs.\n *\n * @example\n * ```ts\n * new SlackIntegration({\n * signingSecret,\n * // Any channel the app is in, and DMs to anyone in the workspace.\n * tools: { channels: 'all', directMessages: 'anyone' },\n * });\n * ```\n */\n tools?: Partial<SlackToolSettings>;\n}\n\n/** Slack renders the status inline next to the app name; keep it to one short line. */\nconst MAX_STATUS_LENGTH = 80;\n\n/**\n * Turns a tool's `description` arg (\"Listing the repo root\") into a status\n * line that reads after the app name (\"<App> is listing the repo root…\").\n * Only the first line counts: issue/PR creators carry whole bodies there.\n */\nfunction describeToolCall(args: unknown): string | undefined {\n if (!args || typeof args !== 'object') return undefined;\n const { description } = args as { description?: unknown };\n if (typeof description !== 'string') return undefined;\n const line = description\n .split('\\n')\n .map(part => part.replace(/\\s+/g, ' ').trim())\n .find(Boolean);\n if (!line) return undefined;\n const text = line.length > MAX_STATUS_LENGTH ? `${line.slice(0, MAX_STATUS_LENGTH - 1)}…` : line;\n // Drop the sentence-case capital (\"Listing\" → \"listing\") but leave acronyms\n // and identifiers (\"PR lookup\", \"CI status\") alone.\n return `is ${/^[A-Z][a-z]/.test(text) ? text.charAt(0).toLowerCase() + text.slice(1) : text}`;\n}\n\n/**\n * With reply text hidden, streamed text never reaches the thread, so it gets\n * no status: an \"is typing...\" set after the reply tool's post would sit on\n * the thread with nothing coming, and race the clear at the end of the run.\n */\nconst factoryTypingStatus =\n (textDisplay: SlackAdapterChannelConfig['textDisplay']): TypingStatusFn =>\n chunk => {\n switch (chunk.type) {\n case 'reasoning-delta':\n return 'is thinking...';\n case 'text-delta':\n return textDisplay === 'hidden' ? undefined : 'is typing...';\n // The reply tool's text streams into the thread as the model writes it.\n case 'tool-call-input-streaming-start':\n return chunk.payload.toolName === REPLY_TOOL_NAME ? 'is typing...' : undefined;\n case 'tool-call':\n // Still finishing the streamed reply; don't flip to \"is working...\".\n if (chunk.payload.toolName === REPLY_TOOL_NAME) return 'is typing...';\n return describeToolCall(chunk.payload.args) ?? 'is working...';\n default:\n return undefined;\n }\n};\n\n/**\n * Drops keys the caller set to `undefined` so spreading the overrides cannot\n * erase the Factory defaults they sit on top of.\n */\nfunction adapterOverrides(options: SlackAdapterChannelConfig | undefined): SlackAdapterChannelConfig {\n return Object.fromEntries(\n Object.entries(options ?? {}).filter(([, value]) => value !== undefined),\n ) as SlackAdapterChannelConfig;\n}\n\n/**\n * Factory defaults under the caller's overrides. Tool calls stay out of the\n * thread: a Factory session runs hundreds of them, and a row per call (or a\n * card per call) buries the reply. Progress shows through the typing status\n * instead, which names the tool's current step; the session link carries the\n * full trace. `grouped` remains available via `adapterOptions` for callers\n * who want Slack's \"Thinking Steps\" widget.\n */\nfunction factoryAdapterOptions(overrides: SlackAdapterChannelConfig): SlackAdapterChannelConfig {\n const textDisplay = overrides.textDisplay ?? 'hidden';\n return { typingStatus: factoryTypingStatus(textDisplay), toolDisplay: 'hidden', textDisplay, ...overrides };\n}\n\nexport class SlackIntegration implements FactoryIntegration {\n readonly id = 'slack';\n /**\n * The OIDC connect flow round-trips a signed `state` through Slack, so the\n * replica handling the callback must be able to verify a state a different\n * replica signed.\n */\n readonly requiresStableStateSigner = true;\n\n readonly #config: SlackIntegrationConfig;\n readonly #toolSettings: SlackToolSettings;\n readonly #adapterOptions: SlackAdapterChannelConfig;\n /** Bound in `initialize()`; the controller mounts after integrations are built. */\n #channels: ShareFileToolDeps['channels'];\n readonly #deps: ShareFileToolDeps = { channels: () => this.#channels?.() };\n /**\n * With reply text hidden (the Factory default) the agent speaks through\n * `reply_in_thread`, so the prompt, reminder and live streaming for that\n * tool come with it. The setting is fixed for the deployment, so it is\n * decided once here rather than on every run.\n */\n readonly processors: { input: InputProcessor[]; output: OutputProcessor[] };\n /**\n * Whether `channels()` found a source-control owner on the context and wired\n * repo-backed sessions. Set at the channels() attach path, which runs once at\n * boot before diagnostics are served.\n */\n #repoBackedSessions = false;\n\n constructor(config: SlackIntegrationConfig) {\n const mode = config.mode ?? 'webhook';\n if (mode === 'webhook' && !config.signingSecret) {\n throw new Error(\n \"SlackIntegration: 'signingSecret' is required in webhook mode — Slack cannot verify inbound requests without it.\",\n );\n }\n if (mode === 'socket' && !config.appToken) {\n throw new Error(\"SlackIntegration: 'appToken' is required in socket mode — Slack cannot open a Socket Mode connection without it.\");\n }\n if (mode === 'socket' && !config.botToken) {\n throw new Error(\"SlackIntegration: 'botToken' is required in socket mode — Factory cannot reply without it.\");\n }\n this.#config = config;\n // An explicit `undefined` means \"use the default\", not \"unset it\".\n const granted = Object.fromEntries(Object.entries(config.tools ?? {}).filter(([, value]) => value !== undefined));\n this.#toolSettings = slackToolSettingsSchema.parse({ ...DEFAULT_SLACK_TOOL_SETTINGS, ...granted });\n this.#adapterOptions = factoryAdapterOptions(adapterOverrides(config.adapterOptions));\n const textHidden = this.#textHidden;\n this.processors = {\n input: [\n new FactoryChannelReplyProcessor(),\n ...(textHidden ? [new FactoryReplyReminderProcessor()] : []),\n ],\n output: [\n new FactoryChannelSessionLinkProcessor(),\n ...(textHidden ? [new FactoryReplyStreamProcessor(this.#deps)] : []),\n ],\n };\n }\n\n get #textHidden(): boolean {\n return this.#adapterOptions.textDisplay === 'hidden';\n }\n\n initialize(args: { channels?: () => AgentChannels | null | undefined }): void {\n this.#channels = args.channels;\n }\n\n /**\n * On runs whose session is linked to a Slack thread: `attach_file`,\n * `reply_in_thread` when reply text is hidden, and the Slack read, post,\n * search, lookup and DM tools. The tools find the thread to post into when\n * they are called.\n */\n async agentTools({ requestContext }: { requestContext: RequestContext }): Promise<IntegrationTools> {\n const slackThread = await slackThreadOf(requestContext, this.#deps);\n if (!slackThread) return {};\n const chat = this.#channels?.()?.sdk;\n const sessionThreadId = slackThread.threadId;\n return {\n ...createShareFileTool(requestContext, this.#deps),\n ...(this.#textHidden ? createReplyTool(requestContext, this.#deps) : {}),\n ...(chat && sessionThreadId ? createSlackChatTools({ chat, sessionThreadId, settings: this.#toolSettings }) : {}),\n };\n }\n\n /**\n * When a run opens a pull request, post its link into the session's Slack\n * thread.\n */\n async postToolObserver({\n toolContext,\n requestContext,\n }: Parameters<NonNullable<FactoryIntegration['postToolObserver']>>[0]): Promise<void> {\n const url = parseCreatedPullRequest(toolContext);\n const threadId = (requestContext?.get('controller') as { threadId?: string } | undefined)?.threadId;\n if (!url || !requestContext || !threadId || !(await isSlackThread(requestContext, this.#deps))) return;\n // Not awaited: the tool call must not wait on Slack.\n void announcePullRequest(this.#channels?.(), threadId, 'opened', url).catch(error =>\n console.warn('[slack] pull request opened announcement failed', error),\n );\n }\n\n channels(ctx: IntegrationContext): FactoryChannelsConfig {\n // Repo-backed sessions select the source-control provider from the linked\n // repository on each Factory project.\n const sourceControls =\n ctx.storage.sourceControls ?? (ctx.storage.sourceControlOwner ? [ctx.storage.sourceControlOwner] : []);\n this.#repoBackedSessions = sourceControls.length > 0;\n const mode = this.#config.mode ?? 'webhook';\n return createSlackChannelsConfig({\n slack: {\n mode: this.#config.mode,\n ...(mode === 'webhook'\n ? { clientId: this.#config.clientId, clientSecret: this.#config.clientSecret }\n : {}),\n signingSecret: this.#config.signingSecret,\n appToken: this.#config.appToken,\n botToken: this.#config.botToken,\n },\n accountLinks: ctx.storage.channelIdentity,\n projects: ctx.storage.projects,\n sourceControls,\n modelDefaults: ctx.storage.modelDefaults,\n modelCredentials: ctx.storage.modelCredentials,\n voiceSettings: ctx.storage.voiceSettings,\n workItems: ctx.runtime?.workItems,\n adapterOptions: this.#adapterOptions,\n });\n }\n\n routes(ctx: IntegrationContext): ApiRoute[] {\n const { clientId, clientSecret, oidcRedirectBaseUrl, uiOrigin } = this.#config;\n return createSlackConnectRoutes({\n auth: ctx.auth,\n accountLinks: ctx.storage.channelIdentity,\n tenantStateSigner: ctx.stateSigner,\n oidc:\n clientId && clientSecret && oidcRedirectBaseUrl\n ? { clientId, clientSecret, redirectBaseUrl: oidcRedirectBaseUrl, uiOrigin }\n : undefined,\n projects: ctx.storage.projects,\n });\n }\n\n diagnostics(): Record<string, unknown> {\n const { clientId, clientSecret, botToken, oidcRedirectBaseUrl } = this.#config;\n return {\n configured: true,\n botTokenConfigured: Boolean(botToken),\n oidcConfigured: Boolean(clientId && clientSecret && oidcRedirectBaseUrl),\n repoBackedSessions: this.#repoBackedSessions,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkGA,MAAM,oBAAoB;;;;;;AAO1B,SAAS,iBAAiB,MAAmC;CAC3D,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO,KAAA;CAC9C,MAAM,EAAE,gBAAgB;CACxB,IAAI,OAAO,gBAAgB,UAAU,OAAO,KAAA;CAC5C,MAAM,OAAO,YACV,MAAM,IAAI,CAAC,CACX,KAAI,SAAQ,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAC7C,KAAK,OAAO;CACf,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,MAAM,OAAO,KAAK,SAAS,oBAAoB,GAAG,KAAK,MAAM,GAAG,EAAqB,EAAE,KAAK;CAG5F,OAAO,MAAM,cAAc,KAAK,IAAI,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC,IAAI;AACzF;;;;;;AAOA,MAAM,uBACH,iBACD,UAAS;CACT,QAAQ,MAAM,MAAd;EACE,KAAK,mBACH,OAAO;EACT,KAAK,cACH,OAAO,gBAAgB,WAAW,KAAA,IAAY;EAEhD,KAAK,mCACH,OAAO,MAAM,QAAQ,aAAA,oBAA+B,iBAAiB,KAAA;EACvE,KAAK;GAEH,IAAI,MAAM,QAAQ,aAAA,mBAA8B,OAAO;GACvD,OAAO,iBAAiB,MAAM,QAAQ,IAAI,KAAK;EACjD,SACE;CACJ;AACF;;;;;AAMA,SAAS,iBAAiB,SAA2E;CACnG,OAAO,OAAO,YACZ,OAAO,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,WAA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,QAAQ;GACtB;GACA,eAAe,IAAI,QAAQ;GAC3B,kBAAkB,IAAI,QAAQ;GAC9B,eAAe,IAAI,QAAQ;GAC3B,WAAW,IAAI,SAAS;GACxB,gBAAgB,KAAK;EACvB,CAAC;CACH;CAEA,OAAO,KAAqC;EAC1C,MAAM,EAAE,UAAU,cAAc,qBAAqB,aAAa,KAAK;EACvE,OAAO,yBAAyB;GAC9B,MAAM,IAAI;GACV,cAAc,IAAI,QAAQ;GAC1B,mBAAmB,IAAI;GACvB,MACE,YAAY,gBAAgB,sBACxB;IAAE;IAAU;IAAc,iBAAiB;IAAqB;GAAS,IACzE,KAAA;GACN,UAAU,IAAI,QAAQ;EACxB,CAAC;CACH;CAEA,cAAuC;EACrC,MAAM,EAAE,UAAU,cAAc,UAAU,wBAAwB,KAAK;EACvE,OAAO;GACL,YAAY;GACZ,oBAAoB,QAAQ,QAAQ;GACpC,gBAAgB,QAAQ,YAAY,gBAAgB,mBAAmB;GACvE,oBAAoB,KAAK;EAC3B;CACF;AACF"}
@@ -46,6 +46,7 @@ function recoveryLinks(requestContext, recoveries) {
46
46
  url: sessionUrl,
47
47
  label: "Change model"
48
48
  }] : [];
49
+ case "credits": return [];
49
50
  case "continue":
50
51
  case "new_session": return [];
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"run-error-card.js","names":[],"sources":["../../../src/integrations/slack/run-error-card.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { ChannelErrorContext } from '@mastra/core/channels';\nimport { providerRequestId } from '@mastra/core/error';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { Actions, Card, CardText, LinkButton } from 'chat';\n\nimport { readFactorySessionScope } from '../../rules/binding-context.js';\nimport type { RunErrorRecovery } from '../../run-error.js';\nimport { describeRunError } from '../../run-error.js';\nimport { runCredential } from '../../session/reply-credential-processor.js';\nimport { modelSettingsLink } from './channel-reply-processor.js';\nimport { sessionLinkFromRequest } from './channel-session-link-processor.js';\n\nexport function slackRunErrorCard(error: Error, { requestContext }: ChannelErrorContext) {\n const { title, message, recoveries, model } = describeRunError(error);\n const requestId = providerRequestId(error);\n const facts = [model && `Model: ${model}`, requestId && `Request id: ${requestId}`].filter(Boolean).join(' · ');\n const credential = model && recoveries.includes('credentials') ? credentialLine(requestContext, model) : undefined;\n const links = requestContext ? recoveryLinks(requestContext, recoveries) : [];\n return Card({\n title: `❌ ${title}`,\n children: [\n CardText(message),\n ...(credential ? [CardText(credential, { style: 'muted' })] : []),\n ...(facts ? [CardText(facts, { style: 'muted' })] : []),\n ...(links.length ? [Actions(links.map(link => LinkButton(link)))] : []),\n ],\n });\n}\n\n/** Only while the session's model is the one that failed: its provider is what names the credential. */\nfunction credentialLine(requestContext: RequestContext | undefined, failedModel: string): string | undefined {\n const controller = requestContext?.get('controller') as AgentControllerRequestContext | undefined;\n const sessionModelId = controller?.session?.modelId;\n if (!sessionModelId) return undefined;\n const slash = sessionModelId.indexOf('/');\n if (slash <= 0 || (sessionModelId !== failedModel && sessionModelId.slice(slash + 1) !== failedModel))\n return undefined;\n const credential = runCredential(requestContext, sessionModelId.slice(0, slash));\n if (!credential) return undefined;\n return `Runs on ${credential.label} · ${credential.ownerId ? 'Personal credential' : 'Shared by the organization'}`;\n}\n\nfunction recoveryLinks(requestContext: RequestContext, recoveries: RunErrorRecovery[]) {\n const factoryProjectId = readFactorySessionScope(requestContext)?.factoryProjectId;\n const settingsUrl = factoryProjectId && modelSettingsLink(factoryProjectId);\n const sessionUrl = sessionLinkFromRequest(requestContext);\n const links = recoveries.flatMap(recovery => {\n switch (recovery) {\n case 'credentials':\n return settingsUrl ? [{ url: settingsUrl, label: 'Review credentials' }] : [];\n case 'model':\n return sessionUrl ? [{ url: sessionUrl, label: 'Change model' }] : [];\n // A reply in the thread continues the run; a mention in a new thread starts a new session.\n case 'continue':\n case 'new_session':\n return [];\n }\n });\n if (links.length || !sessionUrl) return links;\n return [{ url: sessionUrl, label: 'Open session' }];\n}\n"],"mapp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AAC,EAAE;CAClE,MAAM,cAAc,oBAAoB,kBAAkB,gBAAgB;CAC1E,MAAM,aAAa,uBAAuB,cAAc;CACxD,MAAM,QAAQ,WAAW,SAAQ,aAAY;EAC3C,QAAQ,UAAR;GACE,KAAK,eACH,OAAO,cAAc,CAAC;IAAE,KAAK;IAAa,OAAO;GAAqB,CAAC,IAAI,CAAC;GAC9E,KAAK,SACH,OAAO,aAAa,CAAC;IAAE,KAAK;IAAY,OAAO;GAAe,CAAC,IAAI,CAAC;GAEtE,KAAK;GACL,KAAK,eACH,OAAO,CAAC;EACZ;CACF,CAAC;CACD,IAAI,MAAM,UAAU,CAAC,YAAY,OAAO;CACxC,OAAO,CAAC;EAAE,KAAK;EAAY,OAAO;CAAe,CAAC;AACpD"}
1
+ {"version":3,"file":"run-error-card.js","names":[],"sources":["../../../src/integrations/slack/run-error-card.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { ChannelErrorContext } from '@mastra/core/channels';\nimport { providerRequestId } from '@mastra/core/error';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { Actions, Card, CardText, LinkButton } from 'chat';\n\nimport { readFactorySessionScope } from '../../rules/binding-context.js';\nimport type { RunErrorRecovery } from '../../run-error.js';\nimport { describeRunError } from '../../run-error.js';\nimport { runCredential } from '../../session/reply-credential-processor.js';\nimport { modelSettingsLink } from './channel-reply-processor.js';\nimport { sessionLinkFromRequest } from './channel-session-link-processor.js';\n\nexport function slackRunErrorCard(error: Error, { requestContext }: ChannelErrorContext) {\n const { title, message, recoveries, model } = describeRunError(error);\n const requestId = providerRequestId(error);\n const facts = [model && `Model: ${model}`, requestId && `Request id: ${requestId}`].filter(Boolean).join(' · ');\n const credential = model && recoveries.includes('credentials') ? credentialLine(requestContext, model) : undefined;\n const links = requestContext ? recoveryLinks(requestContext, recoveries) : [];\n return Card({\n title: `❌ ${title}`,\n children: [\n CardText(message),\n ...(credential ? [CardText(credential, { style: 'muted' })] : []),\n ...(facts ? [CardText(facts, { style: 'muted' })] : []),\n ...(links.length ? [Actions(links.map(link => LinkButton(link)))] : []),\n ],\n });\n}\n\n/** Only while the session's model is the one that failed: its provider is what names the credential. */\nfunction credentialLine(requestContext: RequestContext | undefined, failedModel: string): string | undefined {\n const controller = requestContext?.get('controller') as AgentControllerRequestContext | undefined;\n const sessionModelId = controller?.session?.modelId;\n if (!sessionModelId) return undefined;\n const slash = sessionModelId.indexOf('/');\n if (slash <= 0 || (sessionModelId !== failedModel && sessionModelId.slice(slash + 1) !== failedModel))\n return undefined;\n const credential = runCredential(requestContext, sessionModelId.slice(0, slash));\n if (!credential) return undefined;\n return `Runs on ${credential.label} · ${credential.ownerId ? 'Personal credential' : 'Shared by the organization'}`;\n}\n\nfunction recoveryLinks(requestContext: RequestContext, recoveries: RunErrorRecovery[]) {\n const factoryProjectId = readFactorySessionScope(requestContext)?.factoryProjectId;\n const settingsUrl = factoryProjectId && modelSettingsLink(factoryProjectId);\n const sessionUrl = sessionLinkFromRequest(requestContext);\n const links = recoveries.flatMap(recovery => {\n switch (recovery) {\n case 'credentials':\n return settingsUrl ? [{ url: settingsUrl, label: 'Review credentials' }] : [];\n case 'model':\n return sessionUrl ? [{ url: sessionUrl, label: 'Change model' }] : [];\n case 'credits':\n return [];\n // A reply in the thread continues the run; a mention in a new thread starts a new session.\n case 'continue':\n case 'new_session':\n return [];\n }\n });\n if (links.length || !sessionUrl) return links;\n return [{ url: sessionUrl, label: 'Open session' }];\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,kBAAkB,OAAc,EAAE,kBAAuC;CACvF,MAAM,EAAE,OAAO,SAAS,YAAY,UAAU,iBAAiB,KAAK;CACpE,MAAM,YAAY,kBAAkB,KAAK;CACzC,MAAM,QAAQ,CAAC,SAAS,UAAU,SAAS,aAAa,eAAe,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KAAK;CAC9G,MAAM,aAAa,SAAS,WAAW,SAAS,aAAa,IAAI,eAAe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,CAAC;GACtE,KAAK,WACH,OAAO,CAAC;GAEV,KAAK;GACL,KAAK,eACH,OAAO,CAAC;EACZ;CACF,CAAC;CACD,IAAI,MAAM,UAAU,CAAC,YAAY,OAAO;CACxC,OAAO,CAAC;EAAE,KAAK;EAAY,OAAO;CAAe,CAAC;AACpD"}
@@ -1,11 +1,10 @@
1
1
  import type { ChannelHandler, ChannelHandlers, ChannelSessionResolve, ChannelSessionStart, ResolveResourceId, ResolveThreadId } from '@mastra/core/channels';
2
2
  import type { SlackAdapterChannelConfig } from '@mastra/slack';
3
3
  import type { ChannelAccountLink, ChannelAccountLinkKey, ChannelIdentityStorage } from '../../storage/domains/channel-identity/base.js';
4
- import type { CommentsDomain } from '../../storage/domains/comments/domain.js';
5
4
  import type { ModelDefaultsStorage } from '../../storage/domains/model-defaults/base.js';
6
5
  import type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';
7
6
  import type { SourceControlStorageHandle } from '../../storage/domains/source-control/base.js';
8
- import type { ExternalWorkItemSource, WorkItemsStorage } from '../../storage/domains/work-items/base.js';
7
+ import type { WorkItemsStorage } from '../../storage/domains/work-items/base.js';
9
8
  import type { FactoryChannelsConfig } from '../base.js';
10
9
  import type { VoiceClipDeps } from './voice-clips.js';
11
10
  type HandlerThread = Parameters<ChannelHandler>[0];
@@ -41,10 +40,7 @@ interface SlackChannelDeps extends VoiceClipDeps {
41
40
  * on the thread and never re-resolved. Unset → the factory default, as before.
42
41
  */
43
42
  modelDefaults?: ModelDefaultsStorage;
44
- /**
45
- * Factory work-items domain, used to find the card a Slack thread already
46
- * has so an `aside` can land on it. New threads never create cards.
47
- */
43
+ /** Factory work-items domain, used to resolve which run binding owns a Slack thread. */
48
44
  workItems?: WorkItemsStorage;
49
45
  /**
50
46
  * Factory projects domain. When provided (alongside `accountLinks`), a
@@ -56,11 +52,6 @@ interface SlackChannelDeps extends VoiceClipDeps {
56
52
  * transcribe a voice clip.
57
53
  */
58
54
  projects?: FactoryProjectsStorage;
59
- /**
60
- * Work-item feed. With it (and `workItems`), an `aside` lands as a comment on
61
- * the card the thread already has. Unset → asides stay ignored, as before.
62
- */
63
- feed?: Pick<CommentsDomain, 'createComment'>;
64
55
  /** Overrides applied to the Slack channel adapter entry. */
65
56
  adapterOptions?: SlackAdapterChannelConfig;
66
57
  }
@@ -184,7 +175,7 @@ export declare function createChannelSessionResolver(deps: SlackChannelDeps): Ch
184
175
  * its thread reaches the controller.
185
176
  *
186
177
  * Without this a Slack session runs on the SDK's built-in mode default
187
- * (`openai/gpt-5.5`), so a factory configured for any other provider fails every
178
+ * (`openai/gpt-5.6-sol`), so a factory configured for any other provider fails every
188
179
  * message with a missing-credentials error. The web kickoff has always applied
189
180
  * the factory default; this brings Slack to the same footing.
190
181
  *
@@ -203,12 +194,6 @@ export declare function createChannelSessionResolver(deps: SlackChannelDeps): Ch
203
194
  * over it would undo the user's selection every time the process restarts.
204
195
  */
205
196
  export declare function createChannelSessionStartHook(deps: SlackChannelDeps): ChannelSessionStart;
206
- /**
207
- * A channel id and a `ts` name a thread only inside the workspace that issued
208
- * them, so the team scopes the card's key — without it two workspaces could
209
- * hold one key and an aside would land on another tenant's card.
210
- */
211
- export declare function slackThreadSource(thread: HandlerThread, teamId?: string): ExternalWorkItemSource;
212
197
  export declare const createHandlers: (deps: SlackChannelDeps) => ChannelHandlers;
213
198
  /** Slack app credentials, passed in explicitly rather than read from env here. */
214
199
  interface SlackCredentials {
@@ -1 +1 @@
1
- {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/integrations/slack/slack.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAmB/D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM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