@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
@@ -1,4 +1,4 @@
1
- export type RunErrorRecovery = 'continue' | 'credentials' | 'model' | 'new_session';
1
+ export type RunErrorRecovery = 'continue' | 'credentials' | 'credits' | 'model' | 'new_session';
2
2
  export interface RunErrorDescription {
3
3
  title: string;
4
4
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"run-error.d.ts","sourceRoot":"","sources":["../src/run-error.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,mBAAmB,CAE7E"}
1
+ {"version":3,"file":"run-error.d.ts","sourceRoot":"","sources":["../src/run-error.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEhG,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,mBAAmB,CAE7E"}
package/dist/run-error.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { MASTRA_GATEWAY_PREFIX } from "@mastra/code-sdk/providers/model-ids";
1
2
  import { PROVIDER_CALL_ERROR_NAME, classifyProviderError, providerErrorReason, providerModelId } from "@mastra/core/error";
2
3
  import { PROVIDER_AUTH_REQUIRED_ERROR } from "@mastra/code-sdk/auth/provider-auth-error";
3
4
  // src/run-error.ts
@@ -16,11 +17,21 @@ function explainRunError(error) {
16
17
  recoveries: ["credentials", "model"]
17
18
  };
18
19
  switch (classifyProviderError(error)) {
19
- case "quota": return {
20
- title: "Provider quota exhausted",
21
- message: afterProviderReason(error, "Check the provider account’s billing or usage allowance, or use another credential or model."),
22
- recoveries: ["credentials", "model"]
23
- };
20
+ case "quota":
21
+ if (isMastraGatewayError(error)) return {
22
+ title: "Out of Mastra Gateway credits",
23
+ message: "Your organization has no gateway credits left. Add credits, then continue the run, or choose another model.",
24
+ recoveries: [
25
+ "credits",
26
+ "continue",
27
+ "model"
28
+ ]
29
+ };
30
+ return {
31
+ title: "Provider quota exhausted",
32
+ message: afterProviderReason(error, "Check the provider account’s billing or usage allowance, or use another credential or model."),
33
+ recoveries: ["credentials", "model"]
34
+ };
24
35
  case "auth": return {
25
36
  title: "Provider access failed",
26
37
  message: afterProviderReason(error, "Review the credentials and model access configured for this session."),
@@ -68,6 +79,28 @@ function explainRunError(error) {
68
79
  case "unknown": return describeUnclassifiedError(error);
69
80
  }
70
81
  }
82
+ const MASTRA_GATEWAY_HOST = /(?:^|\.)gateway(?:-api)?\.mastra\.ai$/;
83
+ /**
84
+ * The Mastra Gateway answered: a `mastra/…` model, a request sent to its host, or its billing reply
85
+ * (which links to `gateway.mastra.ai`). The request reaches the gateway without the `mastra/` prefix.
86
+ */
87
+ function isMastraGatewayError(error) {
88
+ return providerModelId(error)?.startsWith(MASTRA_GATEWAY_PREFIX) === true || calledMastraGateway(error) || /gateway\.mastra\.ai/.test(providerErrorReason(error) ?? error.message);
89
+ }
90
+ /** Whether the request, or a provider error it wraps, went to the gateway's host. */
91
+ function calledMastraGateway(error, depth = 0) {
92
+ if (depth > 4 || typeof error !== "object" || error === null) return false;
93
+ const url = "url" in error ? error.url : void 0;
94
+ const cause = "cause" in error ? error.cause : void 0;
95
+ return typeof url === "string" && MASTRA_GATEWAY_HOST.test(hostOf(url)) || calledMastraGateway(cause, depth + 1);
96
+ }
97
+ function hostOf(url) {
98
+ try {
99
+ return new URL(url).hostname;
100
+ } catch {
101
+ return "";
102
+ }
103
+ }
71
104
  function afterProviderReason(error, next, fallback) {
72
105
  const reason = providerErrorReason(error) ?? fallback;
73
106
  return reason ? `${reason.replace(/\.?$/, ".")} ${next}` : next;
@@ -1 +1 @@
1
- {"version":3,"file":"run-error.js","names":[],"sources":["../src/run-error.ts"],"sourcesContent":["import { PROVIDER_AUTH_REQUIRED_ERROR } from '@mastra/code-sdk/auth/provider-auth-error';\nimport {\n classifyProviderError,\n PROVIDER_CALL_ERROR_NAME,\n providerErrorReason,\n providerModelId,\n} from '@mastra/core/error';\n\nexport type RunErrorRecovery = 'continue' | 'credentials' | 'model' | 'new_session';\n\nexport interface RunErrorDescription {\n title: string;\n message: string;\n recoveries: RunErrorRecovery[];\n model?: string;\n}\n\nexport interface RunErrorIdentity {\n name: string;\n message: string;\n}\n\nconst UNEXPECTED_ERROR = 'An unexpected error stopped the run. Copy the error details to investigate.';\nconst NO_REASON_AVAILABLE =\n 'The provider rejected the request. A specific reason isn’t available here. Copy the error details and check the server logs.';\n\nexport function describeRunError(error: RunErrorIdentity): RunErrorDescription {\n return { ...explainRunError(error), model: providerModelId(error) };\n}\n\nfunction explainRunError(error: RunErrorIdentity): Omit<RunErrorDescription, 'model'> {\n if (error.name === PROVIDER_AUTH_REQUIRED_ERROR) {\n return { title: 'Provider sign-in required', message: error.message, recoveries: ['credentials', 'model'] };\n }\n switch (classifyProviderError(error)) {\n case 'quota':\n return {\n title: 'Provider quota exhausted',\n message: afterProviderReason(\n error,\n 'Check the provider account’s billing or usage allowance, or use another credential or model.',\n ),\n recoveries: ['credentials', 'model'],\n };\n case 'auth':\n return {\n title: 'Provider access failed',\n message: afterProviderReason(error, 'Review the credentials and model access configured for this session.'),\n recoveries: ['credentials', 'model'],\n };\n case 'context_overflow':\n return {\n title: 'Conversation exceeds the model’s limit',\n message: 'Choose a model with a larger context window or start a new session with a shorter prompt.',\n recoveries: ['model', 'new_session'],\n };\n case 'model_rejected':\n return {\n title: 'Model not available',\n message: afterProviderReason(\n error,\n 'Choose another model for this session.',\n 'The provider rejected this model.',\n ),\n recoveries: ['model'],\n };\n case 'tool_history_rejected':\n return {\n title: 'Conversation history rejected',\n message:\n 'The provider could not match a tool call with its result. Start a new session to keep working, and copy the error details so this session can be investigated.',\n recoveries: ['new_session'],\n };\n case 'invalid_request':\n return {\n title: 'Model request rejected',\n message: providerErrorReason(error) ?? NO_REASON_AVAILABLE,\n recoveries: ['model'],\n };\n case 'timeout':\n return {\n title: 'Request timed out',\n message: 'The request took too long to complete. Send a message to continue the run.',\n recoveries: ['continue'],\n };\n case 'rate_limited':\n return {\n title: 'Provider rate limit reached',\n message:\n 'The provider account behind this session’s credential hit a rate or usage limit. Continue once it resets, or use another credential or model.',\n recoveries: ['continue', 'credentials', 'model'],\n };\n case 'unavailable':\n return {\n title: 'Model provider temporarily unavailable',\n message:\n 'The provider could not complete the request. Send a message to continue the run, or choose another model.',\n recoveries: ['continue', 'model'],\n };\n case 'unknown':\n return describeUnclassifiedError(error);\n }\n}\n\nfunction afterProviderReason(error: RunErrorIdentity, next: string, fallback?: string): string {\n const reason = providerErrorReason(error) ?? fallback;\n return reason ? `${reason.replace(/\\.?$/, '.')} ${next}` : next;\n}\n\nfunction describeUnclassifiedError(error: RunErrorIdentity): Omit<RunErrorDescription, 'model'> {\n const message = providerErrorReason(error) ?? (error.message || UNEXPECTED_ERROR);\n const providerCall = PROVIDER_CALL_ERROR_NAME.test(error.name);\n return {\n title: providerCall ? 'Model request failed' : 'Run stopped',\n message,\n recoveries: providerCall ? ['model'] : [],\n };\n}\n"],"mappings":";;;AAsBA,MAAM,mBAAmB;AACzB,MAAM,sBACJ;AAEF,SAAgB,iBAAiB,OAA8C;CAC7E,OAAO;EAAE,GAAG,gBAAgB,KAAK;EAAG,OAAO,gBAAgB,KAAK;CAAE;AACpE;AAEA,SAAS,gBAAgB,OAA6D;CACpF,IAAI,MAAM,SAAS,8BACjB,OAAO;EAAE,OAAO;EAA6B,SAAS,MAAM;EAAS,YAAY,CAAC,eAAe,OAAO;CAAE;CAE5G,QAAQ,sBAAsB,KAAK,GAAnC;EACE,KAAK,SACH,OAAO;GACL,OAAO;GACP,SAAS,oBACP,OACA,8FACF;GACA,YAAY,CAAC,eAAe,OAAO;EACrC;EACF,KAAK,QACH,OAAO;GACL,OAAO;GACP,SAAS,oBAAoB,OAAO,sEAAsE;GAC1G,YAAY,CAAC,eAAe,OAAO;EACrC;EACF,KAAK,oBACH,OAAO;GACL,OAAO;GACP,SAAS;GACT,YAAY,CAAC,SAAS,aAAa;EACrC;EACF,KAAK,kBACH,OAAO;GACL,OAAO;GACP,SAAS,oBACP,OACA,0CACA,mCACF;GACA,YAAY,CAAC,OAAO;EACtB;EACF,KAAK,yBACH,OAAO;GACL,OAAO;GACP,SACE;GACF,YAAY,CAAC,aAAa;EAC5B;EACF,KAAK,mBACH,OAAO;GACL,OAAO;GACP,SAAS,oBAAoB,KAAK,KAAK;GACvC,YAAY,CAAC,OAAO;EACtB;EACF,KAAK,WACH,OAAO;GACL,OAAO;GACP,SAAS;GACT,YAAY,CAAC,UAAU;EACzB;EACF,KAAK,gBACH,OAAO;GACL,OAAO;GACP,SACE;GACF,YAAY;IAAC;IAAY;IAAe;GAAO;EACjD;EACF,KAAK,eACH,OAAO;GACL,OAAO;GACP,SACE;GACF,YAAY,CAAC,YAAY,OAAO;EAClC;EACF,KAAK,WACH,OAAO,0BAA0B,KAAK;CAC1C;AACF;AAEA,SAAS,oBAAoB,OAAyB,MAAc,UAA2B;CAC7F,MAAM,SAAS,oBAAoB,KAAK,KAAK;CAC7C,OAAO,SAAS,GAAG,OAAO,QAAQ,QAAQ,GAAG,EAAE,GAAG,SAAS;AAC7D;AAEA,SAAS,0BAA0B,OAA6D;CAC9F,MAAM,UAAU,oBAAoB,KAAK,MAAM,MAAM,WAAW;CAChE,MAAM,eAAe,yBAAyB,KAAK,MAAM,IAAI;CAC7D,OAAO;EACL,OAAO,eAAe,yBAAyB;EAC/C;EACA,YAAY,eAAe,CAAC,OAAO,IAAI,CAAC;CAC1C;AACF"}
1
+ {"version":3,"file":"run-error.js","names":[],"sources":["../src/run-error.ts"],"sourcesContent":["import { PROVIDER_AUTH_REQUIRED_ERROR } from '@mastra/code-sdk/auth/provider-auth-error';\nimport { MASTRA_GATEWAY_PREFIX } from '@mastra/code-sdk/providers/model-ids';\nimport {\n classifyProviderError,\n PROVIDER_CALL_ERROR_NAME,\n providerErrorReason,\n providerModelId,\n} from '@mastra/core/error';\n\nexport type RunErrorRecovery = 'continue' | 'credentials' | 'credits' | 'model' | 'new_session';\n\nexport interface RunErrorDescription {\n title: string;\n message: string;\n recoveries: RunErrorRecovery[];\n model?: string;\n}\n\nexport interface RunErrorIdentity {\n name: string;\n message: string;\n}\n\nconst UNEXPECTED_ERROR = 'An unexpected error stopped the run. Copy the error details to investigate.';\nconst NO_REASON_AVAILABLE =\n 'The provider rejected the request. A specific reason isn’t available here. Copy the error details and check the server logs.';\n\nexport function describeRunError(error: RunErrorIdentity): RunErrorDescription {\n return { ...explainRunError(error), model: providerModelId(error) };\n}\n\nfunction explainRunError(error: RunErrorIdentity): Omit<RunErrorDescription, 'model'> {\n if (error.name === PROVIDER_AUTH_REQUIRED_ERROR) {\n return { title: 'Provider sign-in required', message: error.message, recoveries: ['credentials', 'model'] };\n }\n switch (classifyProviderError(error)) {\n case 'quota':\n if (isMastraGatewayError(error)) {\n return {\n title: 'Out of Mastra Gateway credits',\n message:\n 'Your organization has no gateway credits left. Add credits, then continue the run, or choose another model.',\n recoveries: ['credits', 'continue', 'model'],\n };\n }\n return {\n title: 'Provider quota exhausted',\n message: afterProviderReason(\n error,\n 'Check the provider account’s billing or usage allowance, or use another credential or model.',\n ),\n recoveries: ['credentials', 'model'],\n };\n case 'auth':\n return {\n title: 'Provider access failed',\n message: afterProviderReason(error, 'Review the credentials and model access configured for this session.'),\n recoveries: ['credentials', 'model'],\n };\n case 'context_overflow':\n return {\n title: 'Conversation exceeds the model’s limit',\n message: 'Choose a model with a larger context window or start a new session with a shorter prompt.',\n recoveries: ['model', 'new_session'],\n };\n case 'model_rejected':\n return {\n title: 'Model not available',\n message: afterProviderReason(\n error,\n 'Choose another model for this session.',\n 'The provider rejected this model.',\n ),\n recoveries: ['model'],\n };\n case 'tool_history_rejected':\n return {\n title: 'Conversation history rejected',\n message:\n 'The provider could not match a tool call with its result. Start a new session to keep working, and copy the error details so this session can be investigated.',\n recoveries: ['new_session'],\n };\n case 'invalid_request':\n return {\n title: 'Model request rejected',\n message: providerErrorReason(error) ?? NO_REASON_AVAILABLE,\n recoveries: ['model'],\n };\n case 'timeout':\n return {\n title: 'Request timed out',\n message: 'The request took too long to complete. Send a message to continue the run.',\n recoveries: ['continue'],\n };\n case 'rate_limited':\n return {\n title: 'Provider rate limit reached',\n message:\n 'The provider account behind this session’s credential hit a rate or usage limit. Continue once it resets, or use another credential or model.',\n recoveries: ['continue', 'credentials', 'model'],\n };\n case 'unavailable':\n return {\n title: 'Model provider temporarily unavailable',\n message:\n 'The provider could not complete the request. Send a message to continue the run, or choose another model.',\n recoveries: ['continue', 'model'],\n };\n case 'unknown':\n return describeUnclassifiedError(error);\n }\n}\n\nconst MASTRA_GATEWAY_HOST = /(?:^|\\.)gateway(?:-api)?\\.mastra\\.ai$/;\n\n/**\n * The Mastra Gateway answered: a `mastra/…` model, a request sent to its host, or its billing reply\n * (which links to `gateway.mastra.ai`). The request reaches the gateway without the `mastra/` prefix.\n */\nfunction isMastraGatewayError(error: RunErrorIdentity): boolean {\n return (\n providerModelId(error)?.startsWith(MASTRA_GATEWAY_PREFIX) === true ||\n calledMastraGateway(error) ||\n /gateway\\.mastra\\.ai/.test(providerErrorReason(error) ?? error.message)\n );\n}\n\n/** Whether the request, or a provider error it wraps, went to the gateway's host. */\nfunction calledMastraGateway(error: unknown, depth = 0): boolean {\n if (depth > 4 || typeof error !== 'object' || error === null) return false;\n const url = 'url' in error ? error.url : undefined;\n const cause = 'cause' in error ? error.cause : undefined;\n return (typeof url === 'string' && MASTRA_GATEWAY_HOST.test(hostOf(url))) || calledMastraGateway(cause, depth + 1);\n}\n\nfunction hostOf(url: string): string {\n try {\n return new URL(url).hostname;\n } catch {\n return '';\n }\n}\n\nfunction afterProviderReason(error: RunErrorIdentity, next: string, fallback?: string): string {\n const reason = providerErrorReason(error) ?? fallback;\n return reason ? `${reason.replace(/\\.?$/, '.')} ${next}` : next;\n}\n\nfunction describeUnclassifiedError(error: RunErrorIdentity): Omit<RunErrorDescription, 'model'> {\n const message = providerErrorReason(error) ?? (error.message || UNEXPECTED_ERROR);\n const providerCall = PROVIDER_CALL_ERROR_NAME.test(error.name);\n return {\n title: providerCall ? 'Model request failed' : 'Run stopped',\n message,\n recoveries: providerCall ? ['model'] : [],\n };\n}\n"],"mappings":";;;;AAuBA,MAAM,mBAAmB;AACzB,MAAM,sBACJ;AAEF,SAAgB,iBAAiB,OAA8C;CAC7E,OAAO;EAAE,GAAG,gBAAgB,KAAK;EAAG,OAAO,gBAAgB,KAAK;CAAE;AACpE;AAEA,SAAS,gBAAgB,OAA6D;CACpF,IAAI,MAAM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OAAO;AAE1E;;AAGA,SAAS,oBAAoB,OAAgB,QAAQ,GAAY;CAC/D,IAAI,QAAQ,KAAK,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACrE,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM,KAAA;CACzC,MAAM,QAAQ,WAAW,QAAQ,MAAM,QAAQ,KAAA;CAC/C,OAAQ,OAAO,QAAQ,YAAY,oBAAoB,KAAK,OAAO,GAAG,CAAC,KAAM,oBAAoB,OAAO,QAAQ,CAAC;AACnH;AAEA,SAAS,OAAO,KAAqB;CACnC,IAAI;EACF,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACtB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,oBAAoB,OAAyB,MAAc,UAA2B;CAC7F,MAAM,SAAS,oBAAoB,KAAK,KAAK;CAC7C,OAAO,SAAS,GAAG,OAAO,QAAQ,QAAQ,GAAG,EAAE,GAAG,SAAS;AAC7D;AAEA,SAAS,0BAA0B,OAA6D;CAC9F,MAAM,UAAU,oBAAoB,KAAK,MAAM,MAAM,WAAW;CAChE,MAAM,eAAe,yBAAyB,KAAK,MAAM,IAAI;CAC7D,OAAO;EACL,OAAO,eAAe,yBAAyB;EAC/C;EACA,YAAY,eAAe,CAAC,OAAO,IAAI,CAAC;CAC1C;AACF"}
@@ -1,4 +1,6 @@
1
1
  import type { AgentControllerEvent } from '@mastra/core/agent-controller';
2
+ import type { PubSub } from '@mastra/core/events';
3
+ import type { SourceControlSession } from '../storage/domains/source-control/base.js';
2
4
  /** The slice of a live session this registry needs: its id, its run, its parked tools, and who it works for. */
3
5
  export interface LiveSession {
4
6
  readonly identity: {
@@ -22,10 +24,14 @@ export interface LiveSession {
22
24
  };
23
25
  subscribe(listener: (event: AgentControllerEvent) => void): () => void;
24
26
  }
25
- interface SessionNotifier {
27
+ export interface SessionNotifier {
26
28
  onSessionCreated(listener: (session: LiveSession) => void): () => void;
27
29
  onSessionDeleted(listener: (session: LiveSession) => void): () => void;
28
30
  }
31
+ /** Where a session's Factory is written down for good: its live state can lose it, its row cannot. */
32
+ export interface SessionRows {
33
+ getBySessionId(sessionId: string): Promise<Pick<SourceControlSession, 'orgId' | 'factoryProjectId'> | null>;
34
+ }
29
35
  /** The tool a session has waited on longest, and since when (epoch ms). */
30
36
  export interface ParkedRun {
31
37
  toolName: string;
@@ -56,8 +62,9 @@ export declare class LiveSessions {
56
62
  sessionId: string;
57
63
  run: ParkedRun;
58
64
  }>;
59
- /** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */
60
- onParkedChanged(listener: (session: LiveSession) => void): () => void;
65
+ /** Fires when a session starts a run, parks, is answered, or finishes a turn: whoever shows runs re-reads. */
66
+ onRunChanged(listener: (session: LiveSession) => void): () => void;
61
67
  }
62
- export {};
68
+ /** A run starting, parking, being answered or ending changes what boards show, so the registry bumps the project's feed. */
69
+ export declare function liveSessionsTouchingTheFeed(controller: SessionNotifier, eventBus: PubSub, rows: SessionRows): LiveSessions;
63
70
  //# sourceMappingURL=live-sessions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"live-sessions.d.ts","sourceRoot":"","sources":["../../src/session/live-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,gHAAgH;AAChH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE;QAAE,KAAK,IAAI,MAAM,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE;QAAE,SAAS,IAAI,OAAO,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE;QAAE,GAAG,IAAI,QAAQ,CAAC;YAAE,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IAC1F,QAAQ,CAAC,YAAY,EAAE;QAAE,GAAG,IAAI;YAAE,kBAAkB,EAAE,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AAe,EAStC;IAmBD,gEAAgE;IAChE,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpC;IAED,0FAA0F;IAC1F,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAS/C;IAED,wFAAwF;IACxF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,CAQ/E;IAED,8GAA8G;IAC9G,YAAY,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAGjE;CACF;AAED,4HAA4H;AAC5H,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,WAAW,GAChB,YAAY,CAiBd"}
@@ -1,3 +1,4 @@
1
+ import { touchFeed } from "../feed-events.js";
1
2
  // src/session/live-sessions.ts
2
3
  /**
3
4
  * The sessions this process has materialized, by session id.
@@ -14,17 +15,16 @@
14
15
  */
15
16
  var LiveSessions = class {
16
17
  #byId = /* @__PURE__ */ new Map();
17
- #parkedListeners = /* @__PURE__ */ new Set();
18
+ #runListeners = /* @__PURE__ */ new Set();
18
19
  /** A park stamp doubles as the receipt key, so two suspensions in one millisecond must not share one. */
19
20
  #lastParkStamp = 0;
20
21
  constructor(controller) {
21
22
  controller.onSessionCreated((session) => this.#track(session));
22
23
  controller.onSessionDeleted((session) => {
23
24
  const id = session.identity.getId();
24
- const wasParked = this.parked(id) !== void 0;
25
25
  this.#byId.get(id)?.unsubscribe();
26
26
  this.#byId.delete(id);
27
- if (wasParked) for (const listener of this.#parkedListeners) listener(session);
27
+ for (const listener of this.#runListeners) listener(session);
28
28
  });
29
29
  }
30
30
  #nextParkStamp() {
@@ -37,8 +37,8 @@ var LiveSessions = class {
37
37
  if (event.type === "tool_suspended") suspendedAt.set(event.toolCallId, this.#nextParkStamp());
38
38
  else if (event.type === "tool_suspension_cancelled") suspendedAt.delete(event.toolCallId);
39
39
  else if (event.type === "agent_end" && event.reason !== "suspended") suspendedAt.clear();
40
- else return;
41
- for (const listener of this.#parkedListeners) listener(session);
40
+ else if (event.type !== "agent_start") return;
41
+ for (const listener of this.#runListeners) listener(session);
42
42
  });
43
43
  this.#byId.set(session.identity.getId(), {
44
44
  session,
@@ -78,12 +78,33 @@ var LiveSessions = class {
78
78
  }
79
79
  return parked;
80
80
  }
81
- /** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */
82
- onParkedChanged(listener) {
83
- this.#parkedListeners.add(listener);
84
- return () => this.#parkedListeners.delete(listener);
81
+ /** Fires when a session starts a run, parks, is answered, or finishes a turn: whoever shows runs re-reads. */
82
+ onRunChanged(listener) {
83
+ this.#runListeners.add(listener);
84
+ return () => this.#runListeners.delete(listener);
85
85
  }
86
86
  };
87
- export { LiveSessions };
87
+ /** A run starting, parking, being answered or ending changes what boards show, so the registry bumps the project's feed. */
88
+ function liveSessionsTouchingTheFeed(controller, eventBus, rows) {
89
+ const liveSessions = new LiveSessions(controller);
90
+ liveSessions.onRunChanged((session) => {
91
+ const { factoryOrgId, factoryProjectId } = session.state.get();
92
+ if (factoryOrgId && factoryProjectId) {
93
+ touchFeed(eventBus, {
94
+ orgId: factoryOrgId,
95
+ factoryProjectId
96
+ });
97
+ return;
98
+ }
99
+ rows.getBySessionId(session.identity.getId()).then((row) => {
100
+ if (row?.factoryProjectId) touchFeed(eventBus, {
101
+ orgId: row.orgId,
102
+ factoryProjectId: row.factoryProjectId
103
+ });
104
+ }).catch((error) => console.warn("[factory] Unable to find the board of a session run.", error));
105
+ });
106
+ return liveSessions;
107
+ }
108
+ export { LiveSessions, liveSessionsTouchingTheFeed };
88
109
 
89
110
  //# sourceMappingURL=live-sessions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"live-sessions.js","names":[],"sources":["../../src/session/live-sessions.ts"],"sourcesContent":["import type { AgentControllerEvent } from '@mastra/core/agent-controller';\n\n/** The slice of a live session this registry needs: its id, its run, its parked tools, and who it works for. */\nexport interface LiveSession {\n readonly identity: { getId(): string };\n readonly run: { isRunning(): boolean };\n readonly state: { get(): Readonly<{ factoryOrgId?: string; factoryProjectId?: string }> };\n readonly displayState: { get(): { pendingSuspensions: ReadonlyMap<string, { toolName: string }> } };\n subscribe(listener: (event: AgentControllerEvent) => void): () => void;\n}\n\ninterface SessionNotifier {\n onSessionCreated(listener: (session: LiveSession) => void): () => void;\n onSessionDeleted(listener: (session: LiveSession) => void): () => void;\n}\n\n/** The tool a session has waited on longest, and since when (epoch ms). */\nexport interface ParkedRun {\n toolName: string;\n suspendedAt: number;\n}\n\ninterface TrackedSession {\n session: LiveSession;\n seenAt: number;\n suspendedAt: Map<string, number>;\n unsubscribe: () => void;\n}\n\n/**\n * The sessions this process has materialized, by session id.\n *\n * Membership comes from the controller's notifications rather than\n * `getSession`, which hands back the pending creation — awaiting it\n * from a request blocks for as long as the session takes to materialize its\n * sandbox, minutes on a cold clone. Notifications only fire once a session\n * exists, so a read never waits.\n *\n * Whether a session is *running* or *parked* is read from the session itself,\n * never tracked here: no missed run event can leave the answer stuck. Only the\n * moment each suspension arrived is kept, since the session does not date them.\n */\nexport class LiveSessions {\n readonly #byId = new Map<string, TrackedSession>();\n readonly #parkedListeners = new Set<(session: LiveSession) => void>();\n /** A park stamp doubles as the receipt key, so two suspensions in one millisecond must not share one. */\n #lastParkStamp = 0;\n\n constructor(controller: SessionNotifier) {\n controller.onSessionCreated(session => this.#track(session));\n controller.onSessionDeleted(session => {\n const id = session.identity.getId();\n const wasParked = this.parked(id) !== undefined;\n this.#byId.get(id)?.unsubscribe();\n this.#byId.delete(id);\n if (wasParked) for (const listener of this.#parkedListeners) listener(session);\n });\n }\n\n #nextParkStamp(): number {\n this.#lastParkStamp = Math.max(Date.now(), this.#lastParkStamp + 1);\n return this.#lastParkStamp;\n }\n\n #track(session: LiveSession): void {\n const suspendedAt = new Map<string, number>();\n const unsubscribe = session.subscribe(event => {\n if (event.type === 'tool_suspended') suspendedAt.set(event.toolCallId, this.#nextParkStamp());\n else if (event.type === 'tool_suspension_cancelled') suspendedAt.delete(event.toolCallId);\n else if (event.type === 'agent_end' && event.reason !== 'suspended') suspendedAt.clear();\n else return;\n for (const listener of this.#parkedListeners) listener(session);\n });\n this.#byId.set(session.identity.getId(), { session, seenAt: Date.now(), suspendedAt, unsubscribe });\n }\n\n /** Whether the session has an agent run in flight right now. */\n isRunning(sessionId: string): boolean {\n return this.#byId.get(sessionId)?.session.run.isRunning() ?? false;\n }\n\n /** The tool the session is parked on, oldest first, or nothing when no answer is owed. */\n parked(sessionId: string): ParkedRun | undefined {\n const tracked = this.#byId.get(sessionId);\n if (!tracked) return undefined;\n let oldest: ParkedRun | undefined;\n for (const [toolCallId, { toolName }] of tracked.session.displayState.get().pendingSuspensions) {\n const suspendedAt = tracked.suspendedAt.get(toolCallId) ?? tracked.seenAt;\n if (!oldest || suspendedAt < oldest.suspendedAt) oldest = { toolName, suspendedAt };\n }\n return oldest;\n }\n\n /** Every parked session of a project, so the inbox reads no card when nothing waits. */\n parkedIn(factoryProjectId: string): Array<{ sessionId: string; run: ParkedRun }> {\n const parked: Array<{ sessionId: string; run: ParkedRun }> = [];\n for (const [sessionId, tracked] of this.#byId) {\n if (tracked.session.state.get().factoryProjectId !== factoryProjectId) continue;\n const run = this.parked(sessionId);\n if (run) parked.push({ sessionId, run });\n }\n return parked;\n }\n\n /** Fires when a session parks, is answered, or finishes a turn: whoever shows parked runs re-reads. */\n onParkedChanged(listener: (session: LiveSession) => void): () => void {\n this.#parkedListeners.add(listener);\n return () => this.#parkedListeners.delete(listener);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAa,eAAb,MAA0B;CACxB,wBAAiB,IAAI,IAA4B;CACjD,mCAA4B,IAAI,IAAoC;;CAEpE,iBAAiB;CAEjB,YAAY,YAA6B;EACvC,WAAW,kBAAi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GACnE,IAAI,CAAC,UAAU,cAAc,OAAO,aAAa,SAAS;IAAE;IAAU;GAAY;EACpF;EACA,OAAO;CACT;;CAGA,SAAS,kBAAwE;EAC/E,MAAM,SAAuD,CAAC;EAC9D,KAAK,MAAM,CAAC,WAAW,YAAY,KAAK,OAAO;GAC7C,IAAI,QAAQ,QAAQ,MAAM,IAAI,CAAC,CAAC,qBAAqB,kBAAkB;GACvE,MAAM,MAAM,KAAK,OAAO,SAAS;GACjC,IAAI,KAAK,OAAO,KAAK;IAAE;IAAW;GAAI,CAAC;EACzC;EACA,OAAO;CACT;;CAGA,gBAAgB,UAAsD;EACpE,KAAK,iBAAiB,IAAI,QAAQ;EAClC,aAAa,KAAK,iBAAiB,OAAO,QAAQ;CACpD;AACF"}
1
+ {"version":3,"file":"live-sessions.js","names":[],"sources":["../../src/session/live-sessions.ts"],"sourcesContent":["import type { AgentControllerEvent } from '@mastra/core/agent-controller';\nimport type { PubSub } from '@mastra/core/events';\n\nimport { touchFeed } from '../feed-events.js';\nimport type { SourceControlSession } from '../storage/domains/source-control/base.js';\n\n/** The slice of a live session this registry needs: its id, its run, its parked tools, and who it works for. */\nexport interface LiveSession {\n readonly identity: { getId(): string };\n readonly run: { isRunning(): boolean };\n readonly state: { get(): Readonly<{ factoryOrgId?: string; factoryProjectId?: string }> };\n readonly displayState: { get(): { pendingSuspensions: ReadonlyMap<string, { toolName: string }> } };\n subscribe(listener: (event: AgentControllerEvent) => void): () => void;\n}\n\nexport interface SessionNotifier {\n onSessionCreated(listener: (session: LiveSession) => void): () => void;\n onSessionDeleted(listener: (session: LiveSession) => void): () => void;\n}\n\n/** Where a session's Factory is written down for good: its live state can lose it, its row cannot. */\nexport interface SessionRows {\n getBySessionId(sessionId: string): Promise<Pick<SourceControlSession, 'orgId' | 'factoryProjectId'> | null>;\n}\n\n/** The tool a session has waited on longest, and since when (epoch ms). */\nexport interface ParkedRun {\n toolName: string;\n suspendedAt: number;\n}\n\ninterface TrackedSession {\n session: LiveSession;\n seenAt: number;\n suspendedAt: Map<string, number>;\n unsubscribe: () => void;\n}\n\n/**\n * The sessions this process has materialized, by session id.\n *\n * Membership comes from the controller's notifications rather than\n * `getSession`, which hands back the pending creation — awaiting it\n * from a request blocks for as long as the session takes to materialize its\n * sandbox, minutes on a cold clone. Notifications only fire once a session\n * exists, so a read never waits.\n *\n * Whether a session is *running* or *parked* is read from the session itself,\n * never tracked here: no missed run event can leave the answer stuck. Only the\n * moment each suspension arrived is kept, since the session does not date them.\n */\nexport class LiveSessions {\n readonly #byId = new Map<string, TrackedSession>();\n readonly #runListeners = new Set<(session: LiveSession) => void>();\n /** A park stamp doubles as the receipt key, so two suspensions in one millisecond must not share one. */\n #lastParkStamp = 0;\n\n constructor(controller: SessionNotifier) {\n controller.onSessionCreated(session => this.#track(session));\n controller.onSessionDeleted(session => {\n const id = session.identity.getId();\n this.#byId.get(id)?.unsubscribe();\n this.#byId.delete(id);\n // The controller resets the run before it reports the deletion, so the session can no longer say a board showed it.\n for (const listener of this.#runListeners) listener(session);\n });\n }\n\n #nextParkStamp(): number {\n this.#lastParkStamp = Math.max(Date.now(), this.#lastParkStamp + 1);\n return this.#lastParkStamp;\n }\n\n #track(session: LiveSession): void {\n const suspendedAt = new Map<string, number>();\n const unsubscribe = session.subscribe(event => {\n if (event.type === 'tool_suspended') suspendedAt.set(event.toolCallId, this.#nextParkStamp());\n else if (event.type === 'tool_suspension_cancelled') suspendedAt.delete(event.toolCallId);\n else if (event.type === 'agent_end' && event.reason !== 'suspended') suspendedAt.clear();\n else if (event.type !== 'agent_start') return;\n for (const listener of this.#runListeners) listener(session);\n });\n this.#byId.set(session.identity.getId(), { session, seenAt: Date.now(), suspendedAt, unsubscribe });\n }\n\n /** Whether the session has an agent run in flight right now. */\n isRunning(sessionId: string): boolean {\n return this.#byId.get(sessionId)?.session.run.isRunning() ?? false;\n }\n\n /** The tool the session is parked on, oldest first, or nothing when no answer is owed. */\n parked(sessionId: string): ParkedRun | undefined {\n const tracked = this.#byId.get(sessionId);\n if (!tracked) return undefined;\n let oldest: ParkedRun | undefined;\n for (const [toolCallId, { toolName }] of tracked.session.displayState.get().pendingSuspensions) {\n const suspendedAt = tracked.suspendedAt.get(toolCallId) ?? tracked.seenAt;\n if (!oldest || suspendedAt < oldest.suspendedAt) oldest = { toolName, suspendedAt };\n }\n return oldest;\n }\n\n /** Every parked session of a project, so the inbox reads no card when nothing waits. */\n parkedIn(factoryProjectId: string): Array<{ sessionId: string; run: ParkedRun }> {\n const parked: Array<{ sessionId: string; run: ParkedRun }> = [];\n for (const [sessionId, tracked] of this.#byId) {\n if (tracked.session.state.get().factoryProjectId !== factoryProjectId) continue;\n const run = this.parked(sessionId);\n if (run) parked.push({ sessionId, run });\n }\n return parked;\n }\n\n /** Fires when a session starts a run, parks, is answered, or finishes a turn: whoever shows runs re-reads. */\n onRunChanged(listener: (session: LiveSession) => void): () => void {\n this.#runListeners.add(listener);\n return () => this.#runListeners.delete(listener);\n }\n}\n\n/** A run starting, parking, being answered or ending changes what boards show, so the registry bumps the project's feed. */\nexport function liveSessionsTouchingTheFeed(\n controller: SessionNotifier,\n eventBus: PubSub,\n rows: SessionRows,\n): LiveSessions {\n const liveSessions = new LiveSessions(controller);\n liveSessions.onRunChanged(session => {\n const { factoryOrgId, factoryProjectId } = session.state.get();\n if (factoryOrgId && factoryProjectId) {\n touchFeed(eventBus, { orgId: factoryOrgId, factoryProjectId });\n return;\n }\n // Only a Factory run carries its project in state, and a recovered one can come back without it: its row names it.\n rows\n .getBySessionId(session.identity.getId())\n .then(row => {\n if (row?.factoryProjectId) touchFeed(eventBus, { orgId: row.orgId, factoryProjectId: row.factoryProjectId });\n })\n .catch(error => console.warn('[factory] Unable to find the board of a session run.', error));\n });\n return liveSessions;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmDA,IAAa,eAAb,MAA0B;CACxB,wBAAiB,IAAI,IAA4B;CACjD,gCAAyB,IAAI,IAAoC;;CAEjE,iBAAiB;CAEjB,YAAY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,CAAC,UAAU,cAAc,OAAO,aAAa,SAAS;IAAE;IAAU;GAAY;EACpF;EACA,OAAO;CACT;;CAGA,SAAS,kBAAwE;EAC/E,MAAM,SAAuD,CAAC;EAC9D,KAAK,MAAM,CAAC,WAAW,YAAY,KAAK,OAAO;GAC7C,IAAI,QAAQ,QAAQ,MAAM,IAAI,CAAC,CAAC,qBAAqB,kBAAkB;GACvE,MAAM,MAAM,KAAK,OAAO,SAAS;GACjC,IAAI,KAAK,OAAO,KAAK;IAAE;IAAW;GAAI,CAAC;EACzC;EACA,OAAO;CACT;;CAGA,aAAa,UAAsD;EACjE,KAAK,cAAc,IAAI,QAAQ;EAC/B,aAAa,KAAK,cAAc,OAAO,QAAQ;CACjD;AACF;;AAGA,SAAgB,4BACd,YACA,UACA,MACc;CACd,MAAM,eAAe,IAAI,aAAa,UAAU;CAChD,aAAa,cAAa,YAAW;EACnC,MAAM,EAAE,cAAc,qBAAqB,QAAQ,MAAM,IAAI;EAC7D,IAAI,gBAAgB,kBAAkB;GACpC,UAAU,UAAU;IAAE,OAAO;IAAc;GAAiB,CAAC;GAC7D;EACF;EAEA,KACG,eAAe,QAAQ,SAAS,MAAM,CAAC,CAAC,CACxC,MAAK,QAAO;GACX,IAAI,KAAK,kBAAkB,UAAU,UAAU;IAAE,OAAO,IAAI;IAAO,kBAAkB,IAAI;GAAiB,CAAC;EAC7G,CAAC,CAAC,CACD,OAAM,UAAS,QAAQ,KAAK,wDAAwD,KAAK,CAAC;CAC/F,CAAC;CACD,OAAO;AACT"}
@@ -3,7 +3,7 @@
3
3
  * WorkOS dashboard under Audit Logs → Events before the mirror accepts them.
4
4
  */
5
5
  export declare const AUDIT_ACTIONS: {
6
- readonly work_item: readonly ['created', 'updated', 'deleted', 'stage_moved', 'transition_rejected', 'comment_created', 'comment_edited', 'comment_deleted', 'comment_mentioned', 'labels_reconciled'];
6
+ readonly work_item: readonly ['created', 'updated', 'deleted', 'stage_moved', 'transition_rejected', 'labels_reconciled'];
7
7
  readonly run: readonly ['started', 'ended', 'approved', 'dismissed', 'retry', 'queued', 'rejected'];
8
8
  readonly git: readonly ['commit', 'push', 'pr_opened'];
9
9
  readonly agent: readonly ['commit', 'push', 'pr_opened', 'signaled'];
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/audit/actions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa;aACxB,SAAS,YACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB;aAErB,GAAG,YAAG,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU;aAChF,GAAG,YAAG,QAAQ,EAAE,MAAM,EAAE,WAAW;aACnC,KAAK,YAAG,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU;aACjD,MAAM,YAAG,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB;aACnE,OAAO,YAAG,mBAAmB;aAC7B,KAAK,YAAG,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO;aAChD,KAAK,YAAG,SAAS,EAAE,UAAU;aAC7B,YAAY,YAAG,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW;CACnD,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,aAAa,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;KACvB,SAAS,IAAI,cAAc,GAAG,WAAW,SAAS,IAAI,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE;CACnG,CAAC,cAAc,CAAC,CAAC;AAElB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED,wBAAgB,eAAe,IAAI,cAAc,EAAE,CAElD;AAED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AAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED,wBAAgB,eAAe,IAAI,cAAc,EAAE,CAElD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAIxG;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAGjE;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,EAAE,CAExF"}
@@ -10,10 +10,6 @@ const AUDIT_ACTIONS = {
10
10
  "deleted",
11
11
  "stage_moved",
12
12
  "transition_rejected",
13
- "comment_created",
14
- "comment_edited",
15
- "comment_deleted",
16
- "comment_mentioned",
17
13
  "labels_reconciled"
18
14
  ],
19
15
  run: [
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","names":[],"sources":["../../../../src/storage/domains/audit/actions.ts"],"sourcesContent":["/**\n * Every action the trail can hold, by namespace. Register new ones in the\n * WorkOS dashboard under Audit Logs → Events before the mirror accepts them.\n */\nexport const AUDIT_ACTIONS = {\n work_item: [\n 'created',\n 'updated',\n 'deleted',\n 'stage_moved',\n 'transition_rejected',\n 'comment_created',\n 'comment_edited',\n 'comment_deleted',\n 'comment_mentioned',\n 'labels_reconciled',\n ],\n run: ['started', 'ended', 'approved', 'dismissed', 'retry', 'queued', 'rejected'],\n git: ['commit', 'push', 'pr_opened'],\n agent: ['commit', 'push', 'pr_opened', 'signaled'],\n intake: ['config_updated', 'binding_updated', 'label_route_updated'],\n session: ['owner_transferred'],\n board: ['created', 'updated', 'deleted', 'reset'],\n skill: ['updated', 'reverted'],\n intake_route: ['created', 'updated', 'deleted', 'reordered'],\n} as const;\n\nexport type AuditNamespace = keyof typeof AUDIT_ACTIONS;\n\nexport type AuditAction = {\n [Namespace in AuditNamespace]: `factory.${Namespace}.${(typeof AUDIT_ACTIONS)[Namespace][number]}`;\n}[AuditNamespace];\n\nexport function isAuditNamespace(value: string): value is AuditNamespace {\n return Object.hasOwn(AUDIT_ACTIONS, value);\n}\n\nexport function auditNamespaces(): AuditNamespace[] {\n return Object.keys(AUDIT_ACTIONS).filter(isAuditNamespace);\n}\n\nexport function parseAuditAction(action: string): { namespace: AuditNamespace; leaf: string } | undefined {\n const [prefix, namespace, leaf, ...rest] = action.split('.');\n if (prefix !== 'factory' || namespace === undefined || leaf === undefined || rest.length > 0) return undefined;\n return isAuditNamespace(namespace) ? { namespace, leaf } : undefined;\n}\n\nexport function isAuditAction(value: string): value is AuditAction {\n const parsed = parseAuditAction(value);\n return parsed !== undefined && AUDIT_ACTIONS[parsed.namespace].some(leaf => leaf === parsed.leaf);\n}\n\nexport function auditActionsInNamespaces(namespaces: readonly AuditNamespace[]): string[] {\n return namespaces.flatMap(namespace => AUDIT_ACTIONS[namespace].map(leaf => `factory.${namespace}.${leaf}`));\n}\n"],"mappings":";;;;;AAIA,MAAa,gBAAgB;CAC3B,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,KAAK;EAAC;EAAW;EAAS;EAAY;EAAa;EAAS;EAAU;CAAU;CAChF,KAAK;EAAC;EAAU;EAAQ;CAAW;CACnC,OAAO;EAAC;EAAU;EAAQ;EAAa;CAAU;CACjD,QAAQ;EAAC;EAAkB;EAAmB;CAAqB;CACnE,SAAS,CAAC,mBAAmB;CAC7B,OAAO;EAAC;EAAW;EAAW;EAAW;CAAO;CAChD,OAAO,CAAC,WAAW,UAAU;CAC7B,cAAc;EAAC;EAAW;EAAW;EAAW;CAAW;AAC7D;AAQA,SAAgB,iBAAiB,OAAwC;CACvE,OAAO,OAAO,OAAO,eAAe,KAAK;AAC3C;AAEA,SAAgB,kBAAoC;CAClD,OAAO,OAAO,KAAK,aAAa,CAAC,CAAC,OAAO,gBAAgB;AAC3D;AAEA,SAAgB,iBAAiB,QAAyE;CACxG,MAAM,CAAC,QAAQ,WAAW,MAAM,GAAG,QAAQ,OAAO,MAAM,GAAG;CAC3D,IAAI,WAAW,aAAa,cAAc,KAAA,KAAa,SAAS,KAAA,KAAa,KAAK,SAAS,GAAG,OAAO,KAAA;CACrG,OAAO,iBAAiB,SAAS,IAAI;EAAE;EAAW;CAAK,IAAI,KAAA;AAC7D;AAEA,SAAgB,cAAc,OAAqC;CACjE,MAAM,SAAS,iBAAiB,KAAK;CACrC,OAAO,WAAW,KAAA,KAAa,cAAc,OAAO,UAAU,CAAC,MAAK,SAAQ,SAAS,OAAO,IAAI;AAClG;AAEA,SAAgB,yBAAyB,YAAiD;CACxF,OAAO,WAAW,SAAQ,cAAa,cAAc,UAAU,CAAC,KAAI,SAAQ,WAAW,UAAU,GAAG,MAAM,CAAC;AAC7G"}
1
+ {"version":3,"file":"actions.js","names":[],"sources":["../../../../src/storage/domains/audit/actions.ts"],"sourcesContent":["/**\n * Every action the trail can hold, by namespace. Register new ones in the\n * WorkOS dashboard under Audit Logs → Events before the mirror accepts them.\n */\nexport const AUDIT_ACTIONS = {\n work_item: ['created', 'updated', 'deleted', 'stage_moved', 'transition_rejected', 'labels_reconciled'],\n run: ['started', 'ended', 'approved', 'dismissed', 'retry', 'queued', 'rejected'],\n git: ['commit', 'push', 'pr_opened'],\n agent: ['commit', 'push', 'pr_opened', 'signaled'],\n intake: ['config_updated', 'binding_updated', 'label_route_updated'],\n session: ['owner_transferred'],\n board: ['created', 'updated', 'deleted', 'reset'],\n skill: ['updated', 'reverted'],\n intake_route: ['created', 'updated', 'deleted', 'reordered'],\n} as const;\n\nexport type AuditNamespace = keyof typeof AUDIT_ACTIONS;\n\nexport type AuditAction = {\n [Namespace in AuditNamespace]: `factory.${Namespace}.${(typeof AUDIT_ACTIONS)[Namespace][number]}`;\n}[AuditNamespace];\n\nexport function isAuditNamespace(value: string): value is AuditNamespace {\n return Object.hasOwn(AUDIT_ACTIONS, value);\n}\n\nexport function auditNamespaces(): AuditNamespace[] {\n return Object.keys(AUDIT_ACTIONS).filter(isAuditNamespace);\n}\n\nexport function parseAuditAction(action: string): { namespace: AuditNamespace; leaf: string } | undefined {\n const [prefix, namespace, leaf, ...rest] = action.split('.');\n if (prefix !== 'factory' || namespace === undefined || leaf === undefined || rest.length > 0) return undefined;\n return isAuditNamespace(namespace) ? { namespace, leaf } : undefined;\n}\n\nexport function isAuditAction(value: string): value is AuditAction {\n const parsed = parseAuditAction(value);\n return parsed !== undefined && AUDIT_ACTIONS[parsed.namespace].some(leaf => leaf === parsed.leaf);\n}\n\nexport function auditActionsInNamespaces(namespaces: readonly AuditNamespace[]): string[] {\n return namespaces.flatMap(namespace => AUDIT_ACTIONS[namespace].map(leaf => `factory.${namespace}.${leaf}`));\n}\n"],"mappings":";;;;;AAIA,MAAa,gBAAgB;CAC3B,WAAW;EAAC;EAAW;EAAW;EAAW;EAAe;EAAuB;CAAmB;CACtG,KAAK;EAAC;EAAW;EAAS;EAAY;EAAa;EAAS;EAAU;CAAU;CAChF,KAAK;EAAC;EAAU;EAAQ;CAAW;CACnC,OAAO;EAAC;EAAU;EAAQ;EAAa;CAAU;CACjD,QAAQ;EAAC;EAAkB;EAAmB;CAAqB;CACnE,SAAS,CAAC,mBAAmB;CAC7B,OAAO;EAAC;EAAW;EAAW;EAAW;CAAO;CAChD,OAAO,CAAC,WAAW,UAAU;CAC7B,cAAc;EAAC;EAAW;EAAW;EAAW;CAAW;AAC7D;AAQA,SAAgB,iBAAiB,OAAwC;CACvE,OAAO,OAAO,OAAO,eAAe,KAAK;AAC3C;AAEA,SAAgB,kBAAoC;CAClD,OAAO,OAAO,KAAK,aAAa,CAAC,CAAC,OAAO,gBAAgB;AAC3D;AAEA,SAAgB,iBAAiB,QAAyE;CACxG,MAAM,CAAC,QAAQ,WAAW,MAAM,GAAG,QAAQ,OAAO,MAAM,GAAG;CAC3D,IAAI,WAAW,aAAa,cAAc,KAAA,KAAa,SAAS,KAAA,KAAa,KAAK,SAAS,GAAG,OAAO,KAAA;CACrG,OAAO,iBAAiB,SAAS,IAAI;EAAE;EAAW;CAAK,IAAI,KAAA;AAC7D;AAEA,SAAgB,cAAc,OAAqC;CACjE,MAAM,SAAS,iBAAiB,KAAK;CACrC,OAAO,WAAW,KAAA,KAAa,cAAc,OAAO,UAAU,CAAC,MAAK,SAAQ,SAAS,OAAO,IAAI;AAClG;AAEA,SAAgB,yBAAyB,YAAiD;CACxF,OAAO,WAAW,SAAQ,cAAa,cAAc,UAAU,CAAC,KAAI,SAAQ,WAAW,UAAU,GAAG,MAAM,CAAC;AAC7G"}
@@ -197,8 +197,22 @@ export declare class StoredBoardsStorage extends FactoryStorageDomain {
197
197
  * project has had before is skipped even if its board was deleted since, and a stored board is
198
198
  * never rewritten. A project stored before the list was kept counts the boards it has as stored.
199
199
  * Reads one row when every key was stored before. Returns the keys it inserted.
200
+ *
201
+ * A key in `onlyIntoEmpty` is inserted only into a project that has no boards at all: one that
202
+ * already has any board, such as one an app stored under that key, is left as it is. The key
203
+ * is still recorded as stored, so it never goes in later, even after the project's boards are
204
+ * deleted: that project chose its boards, and Work is never added beside or after them. The
205
+ * `intoEmpty` boards (an app's, for every project) go first into a project with no boards, so
206
+ * Factory's own under the same key, or in `onlyIntoEmpty`, then stay out. `actor` is recorded
207
+ * as the inserted boards' creator.
200
208
  */
201
- seedBoards(scope: StoredBoardScope, boards: readonly StoredBoardInput[]): Promise<string[]>;
209
+ seedBoards(scope: StoredBoardScope, boards: readonly StoredBoardInput[], options?: {
210
+ actor?: string;
211
+ onlyIntoEmpty?: readonly string[];
212
+ intoEmpty?: readonly StoredBoardInput[];
213
+ }): Promise<string[]>;
214
+ /** The keys of the boards Factory stored in the project; null before it kept the list. */
215
+ seededBoardKeys(scope: StoredBoardScope): Promise<string[] | null>;
202
216
  /**
203
217
  * Inserts a board into the project unless one is stored under its key, and records the key as
204
218
  * stored, so seeding never adds it again. Unlike seeding, it inserts a key the project deleted.
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRo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AAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACnD,OAAO,CAAC,uBAAuB,CAAC,CAmBlC;IAED,8DAA8D;IACxD,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAejH;IAED,iGAAiG;IAC3F,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBnH;CAoFF"}
@@ -175,15 +175,29 @@ var StoredBoardsStorage = class extends FactoryStorageDomain {
175
175
  * project has had before is skipped even if its board was deleted since, and a stored board is
176
176
  * never rewritten. A project stored before the list was kept counts the boards it has as stored.
177
177
  * Reads one row when every key was stored before. Returns the keys it inserted.
178
+ *
179
+ * A key in `onlyIntoEmpty` is inserted only into a project that has no boards at all: one that
180
+ * already has any board, such as one an app stored under that key, is left as it is. The key
181
+ * is still recorded as stored, so it never goes in later, even after the project's boards are
182
+ * deleted: that project chose its boards, and Work is never added beside or after them. The
183
+ * `intoEmpty` boards (an app's, for every project) go first into a project with no boards, so
184
+ * Factory's own under the same key, or in `onlyIntoEmpty`, then stay out. `actor` is recorded
185
+ * as the inserted boards' creator.
178
186
  */
179
- async seedBoards(scope, boards) {
187
+ async seedBoards(scope, boards, options = {}) {
180
188
  const marker = await this.ops.findOne(VERSIONS, scopeWhere(scope));
181
189
  if (marker?.seeded_boards && boards.every((board) => marker.seeded_boards.includes(board.key))) return [];
182
190
  return this.#insertOnce(scope, boards, {
183
- actor: DEFAULT_INTAKE_ROUTE_ACTOR,
184
- skipSeeded: true
191
+ actor: options.actor ?? "factory",
192
+ skipSeeded: true,
193
+ onlyIntoEmpty: options.onlyIntoEmpty ?? [],
194
+ intoEmpty: options.intoEmpty ?? []
185
195
  });
186
196
  }
197
+ /** The keys of the boards Factory stored in the project; null before it kept the list. */
198
+ async seededBoardKeys(scope) {
199
+ return (await this.ops.findOne(VERSIONS, scopeWhere(scope)))?.seeded_boards ?? null;
200
+ }
187
201
  /**
188
202
  * Inserts a board into the project unless one is stored under its key, and records the key as
189
203
  * stored, so seeding never adds it again. Unlike seeding, it inserts a key the project deleted.
@@ -202,10 +216,12 @@ var StoredBoardsStorage = class extends FactoryStorageDomain {
202
216
  const rows = await ops.findMany(BOARDS, scopeWhere(scope));
203
217
  const present = new Set(rows.map((row) => row.board_key));
204
218
  const seeded = new Set(marker.seeded_boards ?? present);
219
+ const candidates = [...rows.length === 0 ? options.intoEmpty ?? [] : [], ...boards];
205
220
  let position = nextPosition(rows);
206
221
  const inserted = [];
207
- for (const board of boards) {
222
+ for (const board of candidates) {
208
223
  if (present.has(board.key) || options.skipSeeded && seeded.has(board.key)) continue;
224
+ if (present.size > 0 && options.onlyIntoEmpty?.includes(board.key)) continue;
209
225
  await insertBoard(ops, scope, board, {
210
226
  position: position++,
211
227
  actor: options.actor
@@ -213,7 +229,7 @@ var StoredBoardsStorage = class extends FactoryStorageDomain {
213
229
  present.add(board.key);
214
230
  inserted.push(board.key);
215
231
  }
216
- const next = [.../* @__PURE__ */ new Set([...seeded, ...boards.map((board) => board.key)])];
232
+ const next = [.../* @__PURE__ */ new Set([...seeded, ...candidates.map((board) => board.key)])];
217
233
  const unchanged = marker.seeded_boards !== null && next.length === marker.seeded_boards.length;
218
234
  if (inserted.length === 0 && unchanged) return inserted;
219
235
  if (await ops.updateMany(VERSIONS, {