@mastra/factory 0.28.0-alpha.8 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +61 -42
  2. package/dist/boards/board-writes.d.ts +3 -3
  3. package/dist/boards/board-writes.d.ts.map +1 -1
  4. package/dist/boards/board-writes.js +24 -20
  5. package/dist/boards/board-writes.js.map +1 -1
  6. package/dist/boards/project-boards.d.ts +20 -0
  7. package/dist/boards/project-boards.d.ts.map +1 -1
  8. package/dist/boards/project-boards.js +35 -11
  9. package/dist/boards/project-boards.js.map +1 -1
  10. package/dist/boards/registry.d.ts.map +1 -1
  11. package/dist/boards/registry.js +0 -3
  12. package/dist/boards/registry.js.map +1 -1
  13. package/dist/capabilities/version-control.d.ts +6 -1
  14. package/dist/capabilities/version-control.d.ts.map +1 -1
  15. package/dist/environment/build-runner.d.ts +13 -2
  16. package/dist/environment/build-runner.d.ts.map +1 -1
  17. package/dist/environment/build-runner.js +42 -0
  18. package/dist/environment/build-runner.js.map +1 -1
  19. package/dist/environment/build-schedule.js +1 -1
  20. package/dist/environment/build-schedule.js.map +1 -1
  21. package/dist/environment/build-workflow.d.ts +6 -4
  22. package/dist/environment/build-workflow.d.ts.map +1 -1
  23. package/dist/environment/build-workflow.js +70 -66
  24. package/dist/environment/build-workflow.js.map +1 -1
  25. package/dist/environment/build.d.ts +22 -7
  26. package/dist/environment/build.d.ts.map +1 -1
  27. package/dist/environment/build.js +73 -15
  28. package/dist/environment/build.js.map +1 -1
  29. package/dist/environment/heads.d.ts +1 -1
  30. package/dist/environment/heads.d.ts.map +1 -1
  31. package/dist/environment/heads.js +4 -1
  32. package/dist/environment/heads.js.map +1 -1
  33. package/dist/environment/repository-access.d.ts +13 -0
  34. package/dist/environment/repository-access.d.ts.map +1 -0
  35. package/dist/environment/repository-access.js +55 -0
  36. package/dist/environment/repository-access.js.map +1 -0
  37. package/dist/factory.d.ts +5 -2
  38. package/dist/factory.d.ts.map +1 -1
  39. package/dist/factory.js +32 -26
  40. package/dist/factory.js.map +1 -1
  41. package/dist/integrations/github/sandbox-release.d.ts +12 -0
  42. package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
  43. package/dist/integrations/github/sandbox-release.js +16 -1
  44. package/dist/integrations/github/sandbox-release.js.map +1 -1
  45. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  46. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  47. package/dist/integrations/platform/github/integration.js +137 -105
  48. package/dist/integrations/platform/github/integration.js.map +1 -1
  49. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  50. package/dist/integrations/platform/jira/integration.js +5 -1
  51. package/dist/integrations/platform/jira/integration.js.map +1 -1
  52. package/dist/integrations/slack/integration.d.ts.map +1 -1
  53. package/dist/integrations/slack/integration.js +7 -4
  54. package/dist/integrations/slack/integration.js.map +1 -1
  55. package/dist/mcp/routes.d.ts.map +1 -1
  56. package/dist/mcp/routes.js +3 -5
  57. package/dist/mcp/routes.js.map +1 -1
  58. package/dist/routes/board-snapshot.d.ts +17 -1
  59. package/dist/routes/board-snapshot.d.ts.map +1 -1
  60. package/dist/routes/board-snapshot.js +54 -7
  61. package/dist/routes/board-snapshot.js.map +1 -1
  62. package/dist/routes/boards.d.ts +2 -3
  63. package/dist/routes/boards.d.ts.map +1 -1
  64. package/dist/routes/boards.js.map +1 -1
  65. package/dist/routes/contracts.d.ts +102 -0
  66. package/dist/routes/contracts.d.ts.map +1 -1
  67. package/dist/routes/contracts.js +96 -6
  68. package/dist/routes/contracts.js.map +1 -1
  69. package/dist/routes/projects.d.ts.map +1 -1
  70. package/dist/routes/projects.js +5 -0
  71. package/dist/routes/projects.js.map +1 -1
  72. package/dist/routes/sandbox-envs.d.ts +2 -0
  73. package/dist/routes/sandbox-envs.d.ts.map +1 -1
  74. package/dist/routes/sandbox-envs.js +3 -0
  75. package/dist/routes/sandbox-envs.js.map +1 -1
  76. package/dist/routes/source-control-settings.d.ts +2 -0
  77. package/dist/routes/source-control-settings.d.ts.map +1 -1
  78. package/dist/routes/source-control-settings.js +5 -0
  79. package/dist/routes/source-control-settings.js.map +1 -1
  80. package/dist/routes/surface.d.ts +2 -0
  81. package/dist/routes/surface.d.ts.map +1 -1
  82. package/dist/routes/surface.js +2 -1
  83. package/dist/routes/surface.js.map +1 -1
  84. package/dist/routes/work-item-activity.d.ts +11 -0
  85. package/dist/routes/work-item-activity.d.ts.map +1 -0
  86. package/dist/routes/work-item-activity.js +25 -0
  87. package/dist/routes/work-item-activity.js.map +1 -0
  88. package/dist/routes/work-item-selection.d.ts +18 -0
  89. package/dist/routes/work-item-selection.d.ts.map +1 -0
  90. package/dist/routes/work-item-selection.js +61 -0
  91. package/dist/routes/work-item-selection.js.map +1 -0
  92. package/dist/routes/work-item-starters.d.ts +29 -0
  93. package/dist/routes/work-item-starters.d.ts.map +1 -0
  94. package/dist/routes/work-item-starters.js +169 -0
  95. package/dist/routes/work-item-starters.js.map +1 -0
  96. package/dist/routes/work-items.d.ts.map +1 -1
  97. package/dist/routes/work-items.js +162 -15
  98. package/dist/routes/work-items.js.map +1 -1
  99. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  100. package/dist/rules/dispatch-errors.js +4 -0
  101. package/dist/rules/dispatch-errors.js.map +1 -1
  102. package/dist/rules/dispatcher.d.ts +2 -1
  103. package/dist/rules/dispatcher.d.ts.map +1 -1
  104. package/dist/rules/dispatcher.js +84 -16
  105. package/dist/rules/dispatcher.js.map +1 -1
  106. package/dist/rules/processor.d.ts +2 -0
  107. package/dist/rules/processor.d.ts.map +1 -1
  108. package/dist/rules/processor.js +18 -4
  109. package/dist/rules/processor.js.map +1 -1
  110. package/dist/rules/transition-service.d.ts +20 -2
  111. package/dist/rules/transition-service.d.ts.map +1 -1
  112. package/dist/rules/transition-service.js +40 -18
  113. package/dist/rules/transition-service.js.map +1 -1
  114. package/dist/sandbox/context-sandboxes.d.ts +70 -0
  115. package/dist/sandbox/context-sandboxes.d.ts.map +1 -0
  116. package/dist/sandbox/context-sandboxes.js +120 -0
  117. package/dist/sandbox/context-sandboxes.js.map +1 -0
  118. package/dist/sandbox/session-retirement.d.ts +11 -4
  119. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  120. package/dist/sandbox/session-retirement.js +39 -13
  121. package/dist/sandbox/session-retirement.js.map +1 -1
  122. package/dist/session/live-sessions.d.ts +1 -1
  123. package/dist/session/live-sessions.d.ts.map +1 -1
  124. package/dist/session/live-sessions.js +12 -2
  125. package/dist/session/live-sessions.js.map +1 -1
  126. package/dist/storage/domains/boards/base.d.ts +25 -5
  127. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  128. package/dist/storage/domains/boards/base.js +57 -20
  129. package/dist/storage/domains/boards/base.js.map +1 -1
  130. package/dist/storage/domains/projects/base.d.ts +8 -2
  131. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  132. package/dist/storage/domains/projects/base.js +21 -4
  133. package/dist/storage/domains/projects/base.js.map +1 -1
  134. package/dist/storage/domains/work-items/base.d.ts +47 -6
  135. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  136. package/dist/storage/domains/work-items/base.js +161 -17
  137. package/dist/storage/domains/work-items/base.js.map +1 -1
  138. package/dist/storage/domains/work-items/cards.d.ts +1 -0
  139. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  140. package/dist/storage/domains/work-items/cards.js +32 -8
  141. package/dist/storage/domains/work-items/cards.js.map +1 -1
  142. package/dist/storage/domains/work-items/legacy-review.d.ts +19 -1
  143. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -1
  144. package/dist/storage/domains/work-items/legacy-review.js +62 -3
  145. package/dist/storage/domains/work-items/legacy-review.js.map +1 -1
  146. package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -0
  147. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  148. package/dist/storage/domains/work-items/work-item-schema.js +46 -18
  149. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  150. package/dist/tools/annotations.d.ts.map +1 -1
  151. package/dist/tools/annotations.js +4 -0
  152. package/dist/tools/annotations.js.map +1 -1
  153. package/dist/tools/audit-events-tool.d.ts +29 -0
  154. package/dist/tools/audit-events-tool.d.ts.map +1 -0
  155. package/dist/tools/audit-events-tool.js +180 -0
  156. package/dist/tools/audit-events-tool.js.map +1 -0
  157. package/dist/tools/index.d.ts +2 -1
  158. package/dist/tools/index.d.ts.map +1 -1
  159. package/dist/tools/index.js +2 -0
  160. package/dist/tools/index.js.map +1 -1
  161. package/dist/tools/permissions.d.ts.map +1 -1
  162. package/dist/tools/permissions.js +1 -0
  163. package/dist/tools/permissions.js.map +1 -1
  164. package/dist/tools/sessions-state-processor.js +1 -1
  165. package/dist/tools/sessions-state-processor.js.map +1 -1
  166. package/dist/work-items/board-check.d.ts +11 -0
  167. package/dist/work-items/board-check.d.ts.map +1 -0
  168. package/dist/work-items/board-check.js +20 -0
  169. package/dist/work-items/board-check.js.map +1 -0
  170. package/dist/work-items/related-cards.d.ts +21 -0
  171. package/dist/work-items/related-cards.d.ts.map +1 -0
  172. package/dist/work-items/related-cards.js +45 -0
  173. package/dist/work-items/related-cards.js.map +1 -0
  174. package/dist/work-items/split-migration.d.ts.map +1 -1
  175. package/dist/work-items/split-migration.js +6 -2
  176. package/dist/work-items/split-migration.js.map +1 -1
  177. package/dist/workspace.d.ts +0 -1
  178. package/dist/workspace.d.ts.map +1 -1
  179. package/dist/workspace.js +49 -32
  180. package/dist/workspace.js.map +1 -1
  181. package/factory-skills/factory-build/SKILL.md +1 -1
  182. package/factory-skills/factory-self-review/SKILL.md +1 -1
  183. package/factory-skills/factory-triage/SKILL.md +4 -4
  184. package/package.json +16 -16
@@ -1,5 +1,5 @@
1
1
  import { findBoardSkillProblems } from "../skills/app-skills.js";
2
- import "../storage/domains/boards/base.js";
2
+ import { readStoredBoard } from "../storage/domains/boards/base.js";
3
3
  import { LEGACY_REVIEW_BOARD } from "../storage/domains/work-items/legacy-review.js";
4
4
  import { boardRegistryOf, createBoardRegistry, defaultBoards } from "./registry.js";
5
5
  import { reviewBoard } from "./review.js";
@@ -10,8 +10,6 @@ import { workSeedWithTriage } from "./work-seeds.js";
10
10
  import { workBoard } from "./work.js";
11
11
  // src/boards/project-boards.ts
12
12
  const DEFAULT_RECHECK_MS = 1e3;
13
- /** A row under the retired Review board's key is never served: the key is the Review board's alone. */
14
- const RESERVED_REVIEW_ROW = `Stored board "${LEGACY_REVIEW_BOARD}" isn't served: the key is reserved for the retired Review board.`;
15
13
  const PRELOAD_CONCURRENCY = 8;
16
14
  /** The phases every release seeded the Review board with; only runners and tools changed between them. */
17
15
  const REVIEW_SEED_PHASES = boardDefinitionOf(reviewBoard).phases.map(({ key, name, kind }) => ({
@@ -29,6 +27,19 @@ function isUntouchedReviewSeed(row) {
29
27
  const phases = [...row.phases].sort((a, b) => a.position - b.position);
30
28
  return phases.length === REVIEW_SEED_PHASES.length && phases.every((phase, index) => phase.key === REVIEW_SEED_PHASES[index].key && phase.name === REVIEW_SEED_PHASES[index].name && phase.kind === REVIEW_SEED_PHASES[index].kind);
31
29
  }
30
+ /**
31
+ * Whether a project has a board of its own under `review`: a stored row other than the seed an
32
+ * earlier release left behind. Cards stored on it are its own; anywhere else they are the retired
33
+ * Review board's. An app that defines the board owns it in a project from when its row is stored
34
+ * there. Without stored boards (`stored: false`) the app's boards are served as they are.
35
+ */
36
+ function ownReviewBoard(codeRegistry, { stored = true } = {}) {
37
+ if (!stored) return async () => codeRegistry.has(LEGACY_REVIEW_BOARD);
38
+ return async (ops, scope) => {
39
+ const row = await readStoredBoard(ops, scope, LEGACY_REVIEW_BOARD);
40
+ return row !== null && !isUntouchedReviewSeed(row);
41
+ };
42
+ }
32
43
  const SNAPSHOT_ATTEMPTS = 3;
33
44
  /**
34
45
  * The creator Factory records on the Work board it stores in a project as the project is
@@ -101,11 +112,13 @@ var ProjectBoardCache = class {
101
112
  /** Boards the app upserted for every project, which a project with no boards gets before Factory's. */
102
113
  #appBoards = /* @__PURE__ */ new Map();
103
114
  #reviewBoardInUse;
115
+ #releaseReviewCards;
104
116
  #occupiedPhases;
105
117
  constructor(options) {
106
118
  this.codeRegistry = options.codeRegistry;
107
119
  this.#storage = options.storage;
108
120
  this.#reviewBoardInUse = options.reviewBoardInUse;
121
+ this.#releaseReviewCards = options.releaseReviewCards;
109
122
  this.#occupiedPhases = options.occupiedPhases;
110
123
  this.#projects = options.projects;
111
124
  this.#codeSkills = options.codeSkills ?? [];
@@ -261,9 +274,18 @@ var ProjectBoardCache = class {
261
274
  if (this.#seeded.has(key)) return;
262
275
  try {
263
276
  const seeded = await this.#storage.seededBoardKeys(scope);
277
+ const release = this.#releaseReviewCards;
278
+ const review = this.#seeds.get(LEGACY_REVIEW_BOARD);
264
279
  if (this.#seeds.size > 0 || this.#appBoards.size > 0) await this.#storage.seedBoards(scope, this.seeds(), {
265
280
  onlyIntoEmpty: this.#onlyIntoEmpty(),
266
- intoEmpty: [...this.#appBoards.values()]
281
+ intoEmpty: [...this.#appBoards.values()],
282
+ before: async (ops, board) => {
283
+ if (board === "review") await release?.(ops, scope);
284
+ }
285
+ });
286
+ if (review) await this.#storage.adoptSeed(scope, review, {
287
+ when: isUntouchedReviewSeed,
288
+ before: (ops) => release?.(ops, scope) ?? Promise.resolve()
267
289
  });
268
290
  await this.#migrate(scope, seeded);
269
291
  this.#seeded.add(key);
@@ -313,6 +335,10 @@ var ProjectBoardCache = class {
313
335
  const boards = [];
314
336
  for (const code of this.codeRegistry.values()) {
315
337
  const row = byKey.get(code.id);
338
+ if (row && code.id === "review" && isUntouchedReviewSeed(row)) {
339
+ details.delete(code.id);
340
+ continue;
341
+ }
316
342
  if (!row) {
317
343
  details.delete(code.id);
318
344
  if (!this.#seeded.has(scopeKey(scope))) problems.push(`Board "${code.id}" isn't stored in this project yet; Factory stores it on the next load.`);
@@ -332,7 +358,9 @@ var ProjectBoardCache = class {
332
358
  });
333
359
  boards.push(merged.board);
334
360
  }
335
- if (reviewInUse) {
361
+ const reviewRow = byKey.get(LEGACY_REVIEW_BOARD);
362
+ const ownsReview = reviewRow !== void 0 && !isUntouchedReviewSeed(reviewRow);
363
+ if (reviewInUse && !ownsReview) {
336
364
  boards.push(reviewBoard);
337
365
  details.set(reviewBoard.id, {
338
366
  source: "builtin",
@@ -342,11 +370,7 @@ var ProjectBoardCache = class {
342
370
  }
343
371
  for (const row of rows) {
344
372
  if (this.codeRegistry.has(row.key)) continue;
345
- if (row.key === "review") {
346
- if (isUntouchedReviewSeed(row)) continue;
347
- report(row, [reviewInUse ? `Stored board "${row.key}" is hidden by the code board with the same key.` : RESERVED_REVIEW_ROW]);
348
- continue;
349
- }
373
+ if (row.key === "review" && !ownsReview) continue;
350
374
  let board;
351
375
  try {
352
376
  board = compileStoredBoard(row);
@@ -380,6 +404,6 @@ var ProjectBoardCache = class {
380
404
  this.#warn(message);
381
405
  }
382
406
  };
383
- export { NEW_PROJECT_SEED_ACTOR, ProjectBoardCache, occupiedPhasesOf, toBoardSource };
407
+ export { NEW_PROJECT_SEED_ACTOR, ProjectBoardCache, isUntouchedReviewSeed, occupiedPhasesOf, ownReviewBoard, toBoardSource };
384
408
 
385
409
  //# sourceMappingURL=project-boards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-boards.js","names":[],"sources":["../../src/boards/project-boards.ts"],"sourcesContent":["import type { InlineSkill } from '@mastra/core/skills';\nimport type { FactoryStorageOps } from '@mastra/core/storage';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type {\n BoardMigrationContext,\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n} from '../storage/domains/boards/base.js';\nimport { DEFAULT_INTAKE_ROUTE_ACTOR } from '../storage/domains/boards/base.js';\nimport type { RetiredAutomationSettings } from '../storage/domains/projects/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport { boardRegistryOf, createBoardRegistry, defaultBoards } from './registry.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { boardForWorkItem } from './semantics.js';\nimport { boardDefinitionOf, compileStoredBoard, mergeCodeBehaviour } from './stored-board.js';\nimport { BOARD_MIGRATIONS } from './work-migrations.js';\nimport { workSeedWithTriage } from './work-seeds.js';\nimport { workBoard } from './work.js';\n\nconst DEFAULT_RECHECK_MS = 1000;\n/** A row under the retired Review board's key is never served: the key is the Review board's alone. */\nconst RESERVED_REVIEW_ROW = `Stored board \"${LEGACY_REVIEW_BOARD}\" isn't served: the key is reserved for the retired Review board.`;\nconst PRELOAD_CONCURRENCY = 8;\n/** The phases every release seeded the Review board with; only runners and tools changed between them. */\nconst REVIEW_SEED_PHASES = boardDefinitionOf(reviewBoard).phases.map(({ key, name, kind }) => ({ key, name, kind }));\n\n/**\n * Whether `row` is the Review board as Factory seeded it: written once by Factory, never\n * revised, and shaped like the seed. The actor alone is not proof, as any caller can pass it.\n */\nfunction isUntouchedReviewSeed(row: StoredBoardRecord): boolean {\n if (row.revision !== 1 || row.createdBy !== DEFAULT_INTAKE_ROUTE_ACTOR) return false;\n if (row.updatedBy !== DEFAULT_INTAKE_ROUTE_ACTOR || row.name !== reviewBoard.name) return false;\n const phases = [...row.phases].sort((a, b) => a.position - b.position);\n return (\n phases.length === REVIEW_SEED_PHASES.length &&\n phases.every(\n (phase, index) =>\n phase.key === REVIEW_SEED_PHASES[index]!.key &&\n phase.name === REVIEW_SEED_PHASES[index]!.name &&\n phase.kind === REVIEW_SEED_PHASES[index]!.kind,\n )\n );\n}\nconst SNAPSHOT_ATTEMPTS = 3;\n\n/**\n * The creator Factory records on the Work board it stores in a project as the project is\n * created: that board is today's Work, and reset gives it back. Any other Work row Factory stored\n * is the one with Triage. Only Factory writes this id; a person's writes carry their user id.\n */\nexport const NEW_PROJECT_SEED_ACTOR = 'factory:new-project';\n\n/** Where a board in a project's catalog came from. */\nexport type BoardSourceKind = 'builtin' | 'app' | 'stored';\n\nexport interface StoredBoardDetails {\n source: BoardSourceKind;\n /** Stored boards, the built-in Work board and app boards can all be edited; the retired Review board can't. */\n editable: boolean;\n problems: string[];\n}\n\n/** A project's boards: the code boards plus its stored boards, and what to report about each board. */\nexport interface ProjectBoards {\n readonly registry: BoardRegistry;\n readonly details: ReadonlyMap<string, StoredBoardDetails>;\n /** Problems with stored boards that are left out of the registry. */\n readonly problems: readonly string[];\n}\n\nconst PROJECT_BOARD_SOURCE = Symbol('ProjectBoardSource');\n\n/**\n * Serves each project its boards. `load` is the async entry point that brings a project's\n * boards up to date; `forProject` is the sync read for code that already loaded the project.\n */\nexport interface ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE]: true;\n /** The code boards: built-in and app boards, served to every project as code built them. */\n readonly codeRegistry: BoardRegistry;\n load(scope: StoredBoardScope): Promise<BoardRegistry>;\n forProject(scope: StoredBoardScope): BoardRegistry;\n describe?(scope: StoredBoardScope): Promise<ProjectBoards>;\n}\n\n/** Accepts either a fixed registry (tests, standalone services) or a per-project source. */\nexport function toBoardSource(boards: BoardRegistry | ProjectBoardSource | undefined): ProjectBoardSource {\n const source = boards ?? createBoardRegistry();\n if (isBoardSource(source)) return source;\n return {\n [PROJECT_BOARD_SOURCE]: true,\n codeRegistry: source,\n load: async () => source,\n forProject: () => source,\n };\n}\n\nfunction isBoardSource(boards: BoardRegistry | ProjectBoardSource): boards is ProjectBoardSource {\n return PROJECT_BOARD_SOURCE in boards;\n}\n\ninterface CacheEntry {\n boards: ProjectBoards;\n version: string | null;\n reviewInUse: boolean;\n checkedAt: number;\n}\n\nexport interface ProjectBoardCacheOptions {\n /** The code boards, built-ins included when enabled. */\n codeRegistry: BoardRegistry;\n storage: StoredBoardsStorage;\n /**\n * Lists every project, to warm them at boot, and reads the retired switches the board\n * migrations carry into each project's boards.\n */\n projects?: {\n listAll(): Promise<readonly { orgId: string; id: string }[]>;\n retiredAutomationSettings?(\n project: { orgId: string; id: string },\n ops: FactoryStorageOps,\n ): Promise<RetiredAutomationSettings | null>;\n };\n /** The phases cards sit in on each of the project's boards, which a board migration must not remove. */\n occupiedPhases?: (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ) => Promise<ReadonlyMap<string, ReadonlySet<string>> | null>;\n codeSkills?: readonly InlineSkill[];\n /**\n * Whether the project still uses the retired Review board (an open card is stored on it). Such\n * a project is served Review alongside its boards; without this, no project is.\n */\n reviewBoardInUse?: (scope: StoredBoardScope) => Promise<boolean>;\n recheckMs?: number;\n now?: () => number;\n warn?: (message: string) => void;\n}\n\nfunction scopeKey(scope: StoredBoardScope): string {\n return `${scope.orgId}\\0${scope.factoryProjectId}`;\n}\n\n/**\n * Reads the phases cards sit in on each of a project's boards, for `occupiedPhases`. Null while\n * cards from before the work-item split are still being copied: `listWith` can't see those yet.\n */\nexport function occupiedPhasesOf(workItems: Pick<WorkItemsStorage, 'listWith' | 'legacyBackfillPending'>) {\n return async (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ): Promise<ReadonlyMap<string, ReadonlySet<string>> | null> => {\n if (workItems.legacyBackfillPending) return null;\n const occupied = new Map<string, Set<string>>();\n for (const item of await workItems.listWith(ops, scope)) {\n const board = boardForWorkItem(item);\n const phases = occupied.get(board) ?? new Set<string>();\n for (const stage of item.stages) phases.add(stage);\n occupied.set(board, phases);\n }\n return occupied;\n };\n}\n\n/**\n * The per-project board cache. A project's boards are its rows: the Work and app boards Factory\n * stored in it, in code order, then the others. A Work or app board's row runs with the code\n * behaviour of its board and phase keys that still fits it ({@link mergeCodeBehaviour}). A project\n * that still uses the retired Review board is served it from code, never stored, until its last\n * open card there finishes. The first load of each project in a process stores the\n * boards Factory hasn't stored in it yet, each once ({@link StoredBoardsStorage.seedBoards}); a\n * release never rewrites them. Loads recheck the project's board version at most every\n * `recheckMs` and recompile when it changed, so stored edits on other replicas arrive within that\n * delay.\n */\nexport class ProjectBoardCache implements ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE] = true;\n readonly codeRegistry: BoardRegistry;\n readonly #codeDetails: ReadonlyMap<string, StoredBoardDetails>;\n readonly #storage: StoredBoardsStorage;\n readonly #projects: ProjectBoardCacheOptions['projects'];\n readonly #recheckMs: number;\n readonly #now: () => number;\n readonly #warn: (message: string) => void;\n readonly #entries = new Map<string, CacheEntry>();\n readonly #loading = new Map<string, Promise<ProjectBoards>>();\n readonly #generations = new Map<string, number>();\n readonly #warned = new Set<string>();\n readonly #seeded = new Set<string>();\n readonly #codeSkills: readonly InlineSkill[];\n readonly #seeds: ReadonlyMap<string, StoredBoardInput>;\n /** Boards the app upserted for every project, which a project with no boards gets before Factory's. */\n readonly #appBoards = new Map<string, StoredBoardInput>();\n readonly #reviewBoardInUse: ProjectBoardCacheOptions['reviewBoardInUse'];\n readonly #occupiedPhases: ProjectBoardCacheOptions['occupiedPhases'];\n\n constructor(options: ProjectBoardCacheOptions) {\n this.codeRegistry = options.codeRegistry;\n this.#storage = options.storage;\n this.#reviewBoardInUse = options.reviewBoardInUse;\n this.#occupiedPhases = options.occupiedPhases;\n this.#projects = options.projects;\n this.#codeSkills = options.codeSkills ?? [];\n this.#recheckMs = options.recheckMs ?? DEFAULT_RECHECK_MS;\n this.#now = options.now ?? Date.now;\n this.#warn = options.warn ?? (message => console.warn(`[factory] ${message}`));\n this.#codeDetails = new Map(\n [...this.codeRegistry.values()].map(board => [\n board.id,\n {\n source: defaultBoards.includes(board) ? 'builtin' : 'app',\n editable: true,\n problems: this.#skillProblems(board),\n },\n ]),\n );\n this.#seeds = new Map([...this.codeRegistry.values()].map(board => [board.id, boardDefinitionOf(board)]));\n }\n\n /**\n * The boards Factory stores once in a project it didn't create: Work as it was with Triage, so a\n * project from an older release keeps the phases its cards know, then the app boards, in order.\n */\n seeds(): StoredBoardInput[] {\n return [...this.#seeds.values()].map(seed => (this.#isFactoryWork(seed.key) ? workSeedWithTriage() : seed));\n }\n\n /**\n * The definition reset restores for `key`; undefined when there is none. A board the app upserted\n * for every project comes first, so reset never swaps an app's Work for Factory's. Factory's Work\n * is today's Work for a project Factory created with it (`row` created by\n * {@link NEW_PROJECT_SEED_ACTOR}), and Work with Triage for every other project.\n */\n seedFor(key: string, row?: Pick<StoredBoardRecord, 'createdBy'>): StoredBoardInput | undefined {\n const app = this.#appBoards.get(key);\n if (app) return app;\n const seed = this.#seeds.get(key);\n if (!seed || !this.#isFactoryWork(key) || row?.createdBy === NEW_PROJECT_SEED_ACTOR) return seed;\n return workSeedWithTriage();\n }\n\n /**\n * Stores Factory's boards in a project that was just created, with today's Work (no Triage).\n * Only the project-creation route calls this; every other load stores {@link seeds}.\n */\n async seedNewProject(scope: StoredBoardScope): Promise<ProjectBoards> {\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, [...this.#seeds.values()], {\n actor: NEW_PROJECT_SEED_ACTOR,\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n return this.describe(scope);\n }\n\n /**\n * Remembers a board the app upserted for every project, so a project that has no boards yet (one\n * created later, or one that never loaded) gets it on its first load before Factory's own boards;\n * having it, the project then gets no Work from Factory. Kept for this process: an app upserts\n * its boards at every startup.\n */\n rememberBoardForAllProjects(board: StoredBoardInput): void {\n this.#appBoards.set(board.key, board);\n }\n\n /** Whether `key` is Factory's own Work board, rather than none or an app board under its key. */\n #isFactoryWork(key: string): boolean {\n return key === workBoard.id && this.codeRegistry.get(key) === workBoard;\n }\n\n /** Work is stored only into a project with no boards: one that has any keeps what it has. */\n #onlyIntoEmpty(): string[] {\n return this.#isFactoryWork(workBoard.id) ? [workBoard.id] : [];\n }\n\n async load(scope: StoredBoardScope): Promise<BoardRegistry> {\n return (await this.describe(scope)).registry;\n }\n\n /** The project's boards with their source, whether they can be edited, and problems, brought up to date. */\n async describe(scope: StoredBoardScope): Promise<ProjectBoards> {\n const key = scopeKey(scope);\n const entry = this.#entries.get(key);\n if (entry && this.#now() - entry.checkedAt < this.#recheckMs) return entry.boards;\n const inFlight = this.#loading.get(key);\n if (inFlight) return inFlight;\n const generation = this.#generations.get(key) ?? 0;\n const loading = this.#refresh(scope, key, generation).finally(() => {\n if (this.#loading.get(key) === loading) this.#loading.delete(key);\n });\n this.#loading.set(key, loading);\n return loading;\n }\n\n /**\n * The project's loaded boards. Before the project's first load (boot preload not finished, or a\n * project created on another replica) this is the code boards alone, without the project's\n * stored boards.\n */\n forProject(scope: StoredBoardScope): BoardRegistry {\n // Storage asks about a row it is about to insert by its board and stages alone, with no\n // project to look up; the code boards answer for it.\n if (!scope.orgId || !scope.factoryProjectId) return this.codeRegistry;\n const entry = this.#entries.get(scopeKey(scope));\n if (entry) return entry.boards.registry;\n // Warm the project so the next sync read sees its stored boards.\n void this.load(scope).catch(() => {});\n this.#warnOnce(\n `cold:${scopeKey(scope)}`,\n `Boards for project ${scope.factoryProjectId} were read before they were loaded; using the code boards.`,\n true,\n );\n return this.codeRegistry;\n }\n\n /** The code skills stored runners may name. */\n get codeSkills(): readonly InlineSkill[] {\n return this.#codeSkills;\n }\n\n /** Makes the next load reread the project. The loaded boards keep serving sync reads until then. */\n invalidate(scope: StoredBoardScope): void {\n const key = scopeKey(scope);\n this.#generations.set(key, (this.#generations.get(key) ?? 0) + 1);\n this.#loading.delete(key);\n const entry = this.#entries.get(key);\n if (entry) entry.checkedAt = Number.NEGATIVE_INFINITY;\n }\n\n /** Loads every project, a few at a time, so sync reads find them warm and each has its boards stored. */\n async preload(): Promise<void> {\n const projects = (await this.#projects?.listAll()) ?? [];\n let next = 0;\n const worker = async () => {\n while (next < projects.length) {\n const project = projects[next++]!;\n // A project that fails to load here loads on first use; the others still load now.\n await this.load({ orgId: project.orgId, factoryProjectId: project.id }).catch(error =>\n this.#warn(\n `Boards for project ${project.id} did not load at startup; they load on first use: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n await Promise.all(Array.from({ length: Math.min(PRELOAD_CONCURRENCY, projects.length) }, worker));\n }\n\n async #refresh(scope: StoredBoardScope, key: string, generation: number): Promise<ProjectBoards> {\n await this.#seed(scope, key);\n const current = this.#entries.get(key);\n const version = await this.#storage.readVersion(scope);\n const reviewInUse = (await this.#reviewBoardInUse?.(scope)) ?? false;\n if (current && current.version === version && current.reviewInUse === reviewInUse) {\n if ((this.#generations.get(key) ?? 0) === generation) current.checkedAt = this.#now();\n return current.boards;\n }\n const snapshot = await this.#consistentSnapshot(scope);\n const boards = this.#compile(scope, snapshot.boards, reviewInUse);\n if ((this.#generations.get(key) ?? 0) === generation) {\n this.#entries.set(key, { boards, version: snapshot.version, reviewInUse, checkedAt: this.#now() });\n }\n return boards;\n }\n\n /** Boards and phases are read in two statements; reread when a write landed between them. */\n async #consistentSnapshot(scope: StoredBoardScope) {\n let snapshot = await this.#storage.snapshot(scope);\n for (let attempt = 1; attempt < SNAPSHOT_ATTEMPTS; attempt++) {\n if ((await this.#storage.readVersion(scope)) === snapshot.version) break;\n snapshot = await this.#storage.snapshot(scope);\n }\n return snapshot;\n }\n\n /**\n * Stores the boards Factory hasn't stored in the project yet, once per process. A failure is\n * logged and retried on the next load; the boards it didn't store aren't served meanwhile.\n */\n async #seed(scope: StoredBoardScope, key: string): Promise<void> {\n if (this.#seeded.has(key)) return;\n try {\n // Read before seeding records Work's key: a project whose list lacked it has no Work of Factory's.\n const seeded = await this.#storage.seededBoardKeys(scope);\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, this.seeds(), {\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n await this.#migrate(scope, seeded);\n this.#seeded.add(key);\n } catch (error) {\n this.#warnOnce(\n `seed:${key}`,\n `Boards for project ${scope.factoryProjectId} could not be stored; Factory stores them on the next load: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Runs the board migrations of the boards Factory stores here that the project hasn't had yet. */\n async #migrate(scope: StoredBoardScope, seededBefore: readonly string[] | null): Promise<void> {\n // A migration of one board rewrites Factory's own board; an app board under the same key keeps\n // its settings. One that carries a project setting into every board rewrites them all. A board\n // Factory never stored in the project (an app wrote the row first), or one the app upserts for\n // every project, is an app's: its one-board migrations are recorded as applied without running.\n const migrations = BOARD_MIGRATIONS.filter(migration => {\n if (migration.boardKey === null) return true;\n const code = this.codeRegistry.get(migration.boardKey);\n return code !== undefined && defaultBoards.includes(code);\n }).map(migration =>\n migration.boardKey !== null &&\n (this.#appBoards.has(migration.boardKey) || (seededBefore !== null && !seededBefore.includes(migration.boardKey)))\n ? { ...migration, migrate: () => undefined }\n : migration,\n );\n const changed = await this.#storage.applyBoardMigrations(scope, migrations, ops =>\n this.#migrationContext(scope, ops),\n );\n if (changed.length === 0) return;\n const filled = changed.map(({ boardKey, filled }) => `${boardKey}: ${filled.join(', ')}`).join('; ');\n console.info(`[factory] Migrated the boards of project ${scope.factoryProjectId} (${filled}).`);\n }\n\n /** Read through the migration transaction's `ops`, so card moves can't slip in unseen on LibSQL. */\n async #migrationContext(scope: StoredBoardScope, ops: FactoryStorageOps): Promise<BoardMigrationContext> {\n const retiredSettings =\n (await this.#projects?.retiredAutomationSettings?.({ orgId: scope.orgId, id: scope.factoryProjectId }, ops)) ??\n null;\n return {\n retiredSettings,\n occupiedPhases: retiredSettings && this.#occupiedPhases ? await this.#occupiedPhases(scope, ops) : null,\n codePhases: boardKey => {\n const code = this.codeRegistry.get(boardKey);\n return code ? new Set(Object.keys(code.phases)) : undefined;\n },\n warn: message =>\n this.#warnOnce(`migration:${scopeKey(scope)}:${message}`, `${message} (project ${scope.factoryProjectId})`),\n };\n }\n\n #compile(scope: StoredBoardScope, rows: readonly StoredBoardRecord[], reviewInUse: boolean): ProjectBoards {\n const byKey = new Map(rows.map(row => [row.key, row]));\n const details = new Map(this.#codeDetails);\n const problems: string[] = [];\n const report = (row: StoredBoardRecord, messages: readonly string[]) => {\n problems.push(...messages);\n for (const message of messages) {\n this.#warnOnce(\n `row:${scopeKey(scope)}:${row.key}:${row.revision}:${message}`,\n `${message} (project ${scope.factoryProjectId})`,\n );\n }\n };\n const boards: InstalledBoard[] = [];\n // Work and app boards keep their code order, each served from its row.\n for (const code of this.codeRegistry.values()) {\n const row = byKey.get(code.id);\n if (!row) {\n details.delete(code.id);\n // Stored once and deleted since, or not stored because storing failed.\n if (!this.#seeded.has(scopeKey(scope))) {\n problems.push(`Board \"${code.id}\" isn't stored in this project yet; Factory stores it on the next load.`);\n }\n continue;\n }\n let merged: ReturnType<typeof mergeCodeBehaviour>;\n try {\n merged = mergeCodeBehaviour(row, code);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n report(row, merged.problems);\n details.set(code.id, {\n ...details.get(code.id)!,\n problems: [...merged.problems, ...this.#skillProblems(merged.board)],\n });\n boards.push(merged.board);\n }\n // Served from code and never stored, so nobody edits a board on its way out.\n if (reviewInUse) {\n boards.push(reviewBoard);\n details.set(reviewBoard.id, { source: 'builtin', editable: false, problems: [] });\n }\n for (const row of rows) {\n if (this.codeRegistry.has(row.key)) continue;\n if (row.key === LEGACY_REVIEW_BOARD) {\n // Factory seeded this row while Review was a built-in board and nobody edited it since:\n // there is nothing in it to lose, so it is no problem. A person's edits are reported.\n if (isUntouchedReviewSeed(row)) continue;\n report(row, [\n reviewInUse\n ? `Stored board \"${row.key}\" is hidden by the code board with the same key.`\n : RESERVED_REVIEW_ROW,\n ]);\n continue;\n }\n let board: InstalledBoard;\n try {\n board = compileStoredBoard(row);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n boards.push(board);\n details.set(row.key, { source: 'stored', editable: true, problems: this.#skillProblems(board) });\n }\n return {\n registry: boardRegistryOf(boards),\n details,\n problems,\n };\n }\n\n #skillProblems(board: InstalledBoard): string[] {\n return findBoardSkillProblems(boardRegistryOf([board]), this.#codeSkills);\n }\n\n #warnOnce(key: string, message: string, debug = false): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n if (debug) {\n console.debug(`[factory] ${message}`);\n return;\n }\n this.#warn(message);\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBAAqB;;AAE3B,MAAM,sBAAsB,iBAAiB,oBAAoB;AACjE,MAAM,sBAAsB;;AAE5B,MAAM,qBAAqB,kBAAkB,WAAW,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,MAAM,YAAY;CAAE;CAAK;CAAM;AAAK,EAAE;;;;;AAMnH,SAAS,sBAAsB,KAAiC;CAC9D,IAAI,IAAI,aAAa,KAAK,IAAI,cAAA,WAA0C,OAAO;CAC/E,IAAI,IAAI,cAAA,aAA4C,IAAI,SAAS,YAAY,MAAM,OAAO;CAC1F,MAAM,SAAS,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;CACrE,OACE,OAAO,WAAW,mBAAmB,UACrC,OAAO,OACJ,OAAO,UACN,MAAM,QAAQ,mBAAmB,MAAM,CAAE,OACzC,MAAM,SAAS,mBAAmB,MAAM,CAAE,QAC1C,MAAM,SAAS,mBAAmB,MAAM,CAAE,IAC9C;AAEJ;AACA,MAAM,oBAAoB;;;;;;AAO1B,MAAa,yBAAyB;AAoBtC,MAAM,uBAAuB,OAAO,oBAAoB;;AAgBxD,SAAgB,cAAc,QAA4E;CACxG,MAAM,SAAS,UAAU,oBAAoB;CAC7C,IAAI,cAAc,MAAM,GAAG,OAAO;CAClC,OAAO;GACJ,uBAAuB;EACxB,cAAc;EACd,MAAM,YAAY;EAClB,kBAAkB;CACpB;AACF;AAEA,SAAS,cAAc,QAA0E;CAC/F,OAAO,wBAAwB;AACjC;AAwCA,SAAS,SAAS,OAAiC;CACjD,OAAO,GAAG,MAAM,MAAM,IAAI,MAAM;AAClC;;;;;AAMA,SAAgB,iBAAiB,WAAyE;CACxG,OAAO,OACL,OAC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AAO;GACT,QAAQ,MAAM,aAAa,SAAS;GACpC;EACF;EACA,KAAK,MAAM,OAAO;CACpB;AACF"}
1
+ {"version":3,"file":"project-boards.js","names":[],"sources":["../../src/boards/project-boards.ts"],"sourcesContent":["import type { InlineSkill } from '@mastra/core/skills';\nimport type { FactoryStorageOps } from '@mastra/core/storage';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type {\n BoardMigrationContext,\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n} from '../storage/domains/boards/base.js';\nimport { DEFAULT_INTAKE_ROUTE_ACTOR, readStoredBoard } from '../storage/domains/boards/base.js';\nimport type { RetiredAutomationSettings } from '../storage/domains/projects/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport type { ReviewBoardInUse } from '../storage/domains/work-items/legacy-review.js';\nimport { boardRegistryOf, createBoardRegistry, defaultBoards } from './registry.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { boardForWorkItem } from './semantics.js';\nimport { boardDefinitionOf, compileStoredBoard, mergeCodeBehaviour } from './stored-board.js';\nimport { BOARD_MIGRATIONS } from './work-migrations.js';\nimport { workSeedWithTriage } from './work-seeds.js';\nimport { workBoard } from './work.js';\n\nconst DEFAULT_RECHECK_MS = 1000;\nconst PRELOAD_CONCURRENCY = 8;\n/** The phases every release seeded the Review board with; only runners and tools changed between them. */\nconst REVIEW_SEED_PHASES = boardDefinitionOf(reviewBoard).phases.map(({ key, name, kind }) => ({ key, name, kind }));\n\n/**\n * Whether `row` is the Review board as Factory seeded it: written once by Factory, never\n * revised, and shaped like the seed. The actor alone is not proof, as any caller can pass it.\n */\nexport function isUntouchedReviewSeed(row: StoredBoardRecord): boolean {\n if (row.revision !== 1 || row.createdBy !== DEFAULT_INTAKE_ROUTE_ACTOR) return false;\n if (row.updatedBy !== DEFAULT_INTAKE_ROUTE_ACTOR || row.name !== reviewBoard.name) return false;\n const phases = [...row.phases].sort((a, b) => a.position - b.position);\n return (\n phases.length === REVIEW_SEED_PHASES.length &&\n phases.every(\n (phase, index) =>\n phase.key === REVIEW_SEED_PHASES[index]!.key &&\n phase.name === REVIEW_SEED_PHASES[index]!.name &&\n phase.kind === REVIEW_SEED_PHASES[index]!.kind,\n )\n );\n}\n\n/**\n * Whether a project has a board of its own under `review`: a stored row other than the seed an\n * earlier release left behind. Cards stored on it are its own; anywhere else they are the retired\n * Review board's. An app that defines the board owns it in a project from when its row is stored\n * there. Without stored boards (`stored: false`) the app's boards are served as they are.\n */\nexport function ownReviewBoard(codeRegistry: BoardRegistry, { stored = true } = {}): ReviewBoardInUse {\n if (!stored) return async () => codeRegistry.has(LEGACY_REVIEW_BOARD);\n return async (ops, scope) => {\n const row = await readStoredBoard(ops, scope, LEGACY_REVIEW_BOARD);\n return row !== null && !isUntouchedReviewSeed(row);\n };\n}\n\nconst SNAPSHOT_ATTEMPTS = 3;\n\n/**\n * The creator Factory records on the Work board it stores in a project as the project is\n * created: that board is today's Work, and reset gives it back. Any other Work row Factory stored\n * is the one with Triage. Only Factory writes this id; a person's writes carry their user id.\n */\nexport const NEW_PROJECT_SEED_ACTOR = 'factory:new-project';\n\n/** Where a board in a project's catalog came from. */\nexport type BoardSourceKind = 'builtin' | 'app' | 'stored';\n\nexport interface StoredBoardDetails {\n source: BoardSourceKind;\n /** Stored boards, the built-in Work board and app boards can all be edited; the retired Review board can't. */\n editable: boolean;\n problems: string[];\n}\n\n/** A project's boards: the code boards plus its stored boards, and what to report about each board. */\nexport interface ProjectBoards {\n readonly registry: BoardRegistry;\n readonly details: ReadonlyMap<string, StoredBoardDetails>;\n /** Problems with stored boards that are left out of the registry. */\n readonly problems: readonly string[];\n}\n\nconst PROJECT_BOARD_SOURCE = Symbol('ProjectBoardSource');\n\n/**\n * Serves each project its boards. `load` is the async entry point that brings a project's\n * boards up to date; `forProject` is the sync read for code that already loaded the project.\n */\nexport interface ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE]: true;\n /** The code boards: built-in and app boards, served to every project as code built them. */\n readonly codeRegistry: BoardRegistry;\n load(scope: StoredBoardScope): Promise<BoardRegistry>;\n forProject(scope: StoredBoardScope): BoardRegistry;\n describe?(scope: StoredBoardScope): Promise<ProjectBoards>;\n}\n\n/** Accepts either a fixed registry (tests, standalone services) or a per-project source. */\nexport function toBoardSource(boards: BoardRegistry | ProjectBoardSource | undefined): ProjectBoardSource {\n const source = boards ?? createBoardRegistry();\n if (isBoardSource(source)) return source;\n return {\n [PROJECT_BOARD_SOURCE]: true,\n codeRegistry: source,\n load: async () => source,\n forProject: () => source,\n };\n}\n\nfunction isBoardSource(boards: BoardRegistry | ProjectBoardSource): boards is ProjectBoardSource {\n return PROJECT_BOARD_SOURCE in boards;\n}\n\ninterface CacheEntry {\n boards: ProjectBoards;\n version: string | null;\n reviewInUse: boolean;\n checkedAt: number;\n}\n\nexport interface ProjectBoardCacheOptions {\n /** The code boards, built-ins included when enabled. */\n codeRegistry: BoardRegistry;\n storage: StoredBoardsStorage;\n /**\n * Lists every project, to warm them at boot, and reads the retired switches the board\n * migrations carry into each project's boards.\n */\n projects?: {\n listAll(): Promise<readonly { orgId: string; id: string }[]>;\n retiredAutomationSettings?(\n project: { orgId: string; id: string },\n ops: FactoryStorageOps,\n ): Promise<RetiredAutomationSettings | null>;\n };\n /** The phases cards sit in on each of the project's boards, which a board migration must not remove. */\n occupiedPhases?: (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ) => Promise<ReadonlyMap<string, ReadonlySet<string>> | null>;\n codeSkills?: readonly InlineSkill[];\n /**\n * Whether the project still uses the retired Review board (an open card is stored on it). Such\n * a project is served Review alongside its boards; without this, no project is.\n */\n reviewBoardInUse?: (scope: StoredBoardScope) => Promise<boolean>;\n /**\n * Stores the Work placement of every card the retired Review board left on `review`, through\n * `ops`. Run in the transaction that stores an app's board under that key in a project.\n */\n releaseReviewCards?: (ops: FactoryStorageOps, scope: StoredBoardScope) => Promise<void>;\n recheckMs?: number;\n now?: () => number;\n warn?: (message: string) => void;\n}\n\nfunction scopeKey(scope: StoredBoardScope): string {\n return `${scope.orgId}\\0${scope.factoryProjectId}`;\n}\n\n/**\n * Reads the phases cards sit in on each of a project's boards, for `occupiedPhases`. Null while\n * cards from before the work-item split are still being copied: `listWith` can't see those yet.\n */\nexport function occupiedPhasesOf(workItems: Pick<WorkItemsStorage, 'listWith' | 'legacyBackfillPending'>) {\n return async (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ): Promise<ReadonlyMap<string, ReadonlySet<string>> | null> => {\n if (workItems.legacyBackfillPending) return null;\n const occupied = new Map<string, Set<string>>();\n for (const item of await workItems.listWith(ops, scope)) {\n const board = boardForWorkItem(item);\n const phases = occupied.get(board) ?? new Set<string>();\n for (const stage of item.stages) phases.add(stage);\n occupied.set(board, phases);\n }\n return occupied;\n };\n}\n\n/**\n * The per-project board cache. A project's boards are its rows: the Work and app boards Factory\n * stored in it, in code order, then the others. A Work or app board's row runs with the code\n * behaviour of its board and phase keys that still fits it ({@link mergeCodeBehaviour}). A project\n * that still uses the retired Review board is served it from code, never stored, until its last\n * open card there finishes. The first load of each project in a process stores the\n * boards Factory hasn't stored in it yet, each once ({@link StoredBoardsStorage.seedBoards}); a\n * release never rewrites them. Loads recheck the project's board version at most every\n * `recheckMs` and recompile when it changed, so stored edits on other replicas arrive within that\n * delay.\n */\nexport class ProjectBoardCache implements ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE] = true;\n readonly codeRegistry: BoardRegistry;\n readonly #codeDetails: ReadonlyMap<string, StoredBoardDetails>;\n readonly #storage: StoredBoardsStorage;\n readonly #projects: ProjectBoardCacheOptions['projects'];\n readonly #recheckMs: number;\n readonly #now: () => number;\n readonly #warn: (message: string) => void;\n readonly #entries = new Map<string, CacheEntry>();\n readonly #loading = new Map<string, Promise<ProjectBoards>>();\n readonly #generations = new Map<string, number>();\n readonly #warned = new Set<string>();\n readonly #seeded = new Set<string>();\n readonly #codeSkills: readonly InlineSkill[];\n readonly #seeds: ReadonlyMap<string, StoredBoardInput>;\n /** Boards the app upserted for every project, which a project with no boards gets before Factory's. */\n readonly #appBoards = new Map<string, StoredBoardInput>();\n readonly #reviewBoardInUse: ProjectBoardCacheOptions['reviewBoardInUse'];\n readonly #releaseReviewCards: ProjectBoardCacheOptions['releaseReviewCards'];\n readonly #occupiedPhases: ProjectBoardCacheOptions['occupiedPhases'];\n\n constructor(options: ProjectBoardCacheOptions) {\n this.codeRegistry = options.codeRegistry;\n this.#storage = options.storage;\n this.#reviewBoardInUse = options.reviewBoardInUse;\n this.#releaseReviewCards = options.releaseReviewCards;\n this.#occupiedPhases = options.occupiedPhases;\n this.#projects = options.projects;\n this.#codeSkills = options.codeSkills ?? [];\n this.#recheckMs = options.recheckMs ?? DEFAULT_RECHECK_MS;\n this.#now = options.now ?? Date.now;\n this.#warn = options.warn ?? (message => console.warn(`[factory] ${message}`));\n this.#codeDetails = new Map(\n [...this.codeRegistry.values()].map(board => [\n board.id,\n {\n source: defaultBoards.includes(board) ? 'builtin' : 'app',\n editable: true,\n problems: this.#skillProblems(board),\n },\n ]),\n );\n this.#seeds = new Map([...this.codeRegistry.values()].map(board => [board.id, boardDefinitionOf(board)]));\n }\n\n /**\n * The boards Factory stores once in a project it didn't create: Work as it was with Triage, so a\n * project from an older release keeps the phases its cards know, then the app boards, in order.\n */\n seeds(): StoredBoardInput[] {\n return [...this.#seeds.values()].map(seed => (this.#isFactoryWork(seed.key) ? workSeedWithTriage() : seed));\n }\n\n /**\n * The definition reset restores for `key`; undefined when there is none. A board the app upserted\n * for every project comes first, so reset never swaps an app's Work for Factory's. Factory's Work\n * is today's Work for a project Factory created with it (`row` created by\n * {@link NEW_PROJECT_SEED_ACTOR}), and Work with Triage for every other project.\n */\n seedFor(key: string, row?: Pick<StoredBoardRecord, 'createdBy'>): StoredBoardInput | undefined {\n const app = this.#appBoards.get(key);\n if (app) return app;\n const seed = this.#seeds.get(key);\n if (!seed || !this.#isFactoryWork(key) || row?.createdBy === NEW_PROJECT_SEED_ACTOR) return seed;\n return workSeedWithTriage();\n }\n\n /**\n * Stores Factory's boards in a project that was just created, with today's Work (no Triage).\n * Only the project-creation route calls this; every other load stores {@link seeds}.\n */\n async seedNewProject(scope: StoredBoardScope): Promise<ProjectBoards> {\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, [...this.#seeds.values()], {\n actor: NEW_PROJECT_SEED_ACTOR,\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n return this.describe(scope);\n }\n\n /**\n * Remembers a board the app upserted for every project, so a project that has no boards yet (one\n * created later, or one that never loaded) gets it on its first load before Factory's own boards;\n * having it, the project then gets no Work from Factory. Kept for this process: an app upserts\n * its boards at every startup.\n */\n rememberBoardForAllProjects(board: StoredBoardInput): void {\n this.#appBoards.set(board.key, board);\n }\n\n /** Whether `key` is Factory's own Work board, rather than none or an app board under its key. */\n #isFactoryWork(key: string): boolean {\n return key === workBoard.id && this.codeRegistry.get(key) === workBoard;\n }\n\n /** Work is stored only into a project with no boards: one that has any keeps what it has. */\n #onlyIntoEmpty(): string[] {\n return this.#isFactoryWork(workBoard.id) ? [workBoard.id] : [];\n }\n\n async load(scope: StoredBoardScope): Promise<BoardRegistry> {\n return (await this.describe(scope)).registry;\n }\n\n /** The project's boards with their source, whether they can be edited, and problems, brought up to date. */\n async describe(scope: StoredBoardScope): Promise<ProjectBoards> {\n const key = scopeKey(scope);\n const entry = this.#entries.get(key);\n if (entry && this.#now() - entry.checkedAt < this.#recheckMs) return entry.boards;\n const inFlight = this.#loading.get(key);\n if (inFlight) return inFlight;\n const generation = this.#generations.get(key) ?? 0;\n const loading = this.#refresh(scope, key, generation).finally(() => {\n if (this.#loading.get(key) === loading) this.#loading.delete(key);\n });\n this.#loading.set(key, loading);\n return loading;\n }\n\n /**\n * The project's loaded boards. Before the project's first load (boot preload not finished, or a\n * project created on another replica) this is the code boards alone, without the project's\n * stored boards.\n */\n forProject(scope: StoredBoardScope): BoardRegistry {\n // Storage asks about a row it is about to insert by its board and stages alone, with no\n // project to look up; the code boards answer for it.\n if (!scope.orgId || !scope.factoryProjectId) return this.codeRegistry;\n const entry = this.#entries.get(scopeKey(scope));\n if (entry) return entry.boards.registry;\n // Warm the project so the next sync read sees its stored boards.\n void this.load(scope).catch(() => {});\n this.#warnOnce(\n `cold:${scopeKey(scope)}`,\n `Boards for project ${scope.factoryProjectId} were read before they were loaded; using the code boards.`,\n true,\n );\n return this.codeRegistry;\n }\n\n /** The code skills stored runners may name. */\n get codeSkills(): readonly InlineSkill[] {\n return this.#codeSkills;\n }\n\n /** Makes the next load reread the project. The loaded boards keep serving sync reads until then. */\n invalidate(scope: StoredBoardScope): void {\n const key = scopeKey(scope);\n this.#generations.set(key, (this.#generations.get(key) ?? 0) + 1);\n this.#loading.delete(key);\n const entry = this.#entries.get(key);\n if (entry) entry.checkedAt = Number.NEGATIVE_INFINITY;\n }\n\n /** Loads every project, a few at a time, so sync reads find them warm and each has its boards stored. */\n async preload(): Promise<void> {\n const projects = (await this.#projects?.listAll()) ?? [];\n let next = 0;\n const worker = async () => {\n while (next < projects.length) {\n const project = projects[next++]!;\n // A project that fails to load here loads on first use; the others still load now.\n await this.load({ orgId: project.orgId, factoryProjectId: project.id }).catch(error =>\n this.#warn(\n `Boards for project ${project.id} did not load at startup; they load on first use: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n await Promise.all(Array.from({ length: Math.min(PRELOAD_CONCURRENCY, projects.length) }, worker));\n }\n\n async #refresh(scope: StoredBoardScope, key: string, generation: number): Promise<ProjectBoards> {\n await this.#seed(scope, key);\n const current = this.#entries.get(key);\n const version = await this.#storage.readVersion(scope);\n const reviewInUse = (await this.#reviewBoardInUse?.(scope)) ?? false;\n if (current && current.version === version && current.reviewInUse === reviewInUse) {\n if ((this.#generations.get(key) ?? 0) === generation) current.checkedAt = this.#now();\n return current.boards;\n }\n const snapshot = await this.#consistentSnapshot(scope);\n const boards = this.#compile(scope, snapshot.boards, reviewInUse);\n if ((this.#generations.get(key) ?? 0) === generation) {\n this.#entries.set(key, { boards, version: snapshot.version, reviewInUse, checkedAt: this.#now() });\n }\n return boards;\n }\n\n /** Boards and phases are read in two statements; reread when a write landed between them. */\n async #consistentSnapshot(scope: StoredBoardScope) {\n let snapshot = await this.#storage.snapshot(scope);\n for (let attempt = 1; attempt < SNAPSHOT_ATTEMPTS; attempt++) {\n if ((await this.#storage.readVersion(scope)) === snapshot.version) break;\n snapshot = await this.#storage.snapshot(scope);\n }\n return snapshot;\n }\n\n /**\n * Stores the boards Factory hasn't stored in the project yet, once per process. A failure is\n * logged and retried on the next load; the boards it didn't store aren't served meanwhile.\n */\n async #seed(scope: StoredBoardScope, key: string): Promise<void> {\n if (this.#seeded.has(key)) return;\n try {\n // Read before seeding records Work's key: a project whose list lacked it has no Work of Factory's.\n const seeded = await this.#storage.seededBoardKeys(scope);\n const release = this.#releaseReviewCards;\n const review = this.#seeds.get(LEGACY_REVIEW_BOARD);\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, this.seeds(), {\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n // An app's board under `review` starts without the cards the retired Review board left there.\n before: async (ops, board) => {\n if (board === LEGACY_REVIEW_BOARD) await release?.(ops, scope);\n },\n });\n }\n // The row an earlier release seeded for the retired board becomes the app's board.\n if (review) {\n await this.#storage.adoptSeed(scope, review, {\n when: isUntouchedReviewSeed,\n before: ops => release?.(ops, scope) ?? Promise.resolve(),\n });\n }\n await this.#migrate(scope, seeded);\n this.#seeded.add(key);\n } catch (error) {\n this.#warnOnce(\n `seed:${key}`,\n `Boards for project ${scope.factoryProjectId} could not be stored; Factory stores them on the next load: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Runs the board migrations of the boards Factory stores here that the project hasn't had yet. */\n async #migrate(scope: StoredBoardScope, seededBefore: readonly string[] | null): Promise<void> {\n // A migration of one board rewrites Factory's own board; an app board under the same key keeps\n // its settings. One that carries a project setting into every board rewrites them all. A board\n // Factory never stored in the project (an app wrote the row first), or one the app upserts for\n // every project, is an app's: its one-board migrations are recorded as applied without running.\n const migrations = BOARD_MIGRATIONS.filter(migration => {\n if (migration.boardKey === null) return true;\n const code = this.codeRegistry.get(migration.boardKey);\n return code !== undefined && defaultBoards.includes(code);\n }).map(migration =>\n migration.boardKey !== null &&\n (this.#appBoards.has(migration.boardKey) || (seededBefore !== null && !seededBefore.includes(migration.boardKey)))\n ? { ...migration, migrate: () => undefined }\n : migration,\n );\n const changed = await this.#storage.applyBoardMigrations(scope, migrations, ops =>\n this.#migrationContext(scope, ops),\n );\n if (changed.length === 0) return;\n const filled = changed.map(({ boardKey, filled }) => `${boardKey}: ${filled.join(', ')}`).join('; ');\n console.info(`[factory] Migrated the boards of project ${scope.factoryProjectId} (${filled}).`);\n }\n\n /** Read through the migration transaction's `ops`, so card moves can't slip in unseen on LibSQL. */\n async #migrationContext(scope: StoredBoardScope, ops: FactoryStorageOps): Promise<BoardMigrationContext> {\n const retiredSettings =\n (await this.#projects?.retiredAutomationSettings?.({ orgId: scope.orgId, id: scope.factoryProjectId }, ops)) ??\n null;\n return {\n retiredSettings,\n occupiedPhases: retiredSettings && this.#occupiedPhases ? await this.#occupiedPhases(scope, ops) : null,\n codePhases: boardKey => {\n const code = this.codeRegistry.get(boardKey);\n return code ? new Set(Object.keys(code.phases)) : undefined;\n },\n warn: message =>\n this.#warnOnce(`migration:${scopeKey(scope)}:${message}`, `${message} (project ${scope.factoryProjectId})`),\n };\n }\n\n #compile(scope: StoredBoardScope, rows: readonly StoredBoardRecord[], reviewInUse: boolean): ProjectBoards {\n const byKey = new Map(rows.map(row => [row.key, row]));\n const details = new Map(this.#codeDetails);\n const problems: string[] = [];\n const report = (row: StoredBoardRecord, messages: readonly string[]) => {\n problems.push(...messages);\n for (const message of messages) {\n this.#warnOnce(\n `row:${scopeKey(scope)}:${row.key}:${row.revision}:${message}`,\n `${message} (project ${scope.factoryProjectId})`,\n );\n }\n };\n const boards: InstalledBoard[] = [];\n // Work and app boards keep their code order, each served from its row.\n for (const code of this.codeRegistry.values()) {\n const row = byKey.get(code.id);\n // Still the retired board's seed: the app's board is served once its row replaces it.\n if (row && code.id === LEGACY_REVIEW_BOARD && isUntouchedReviewSeed(row)) {\n details.delete(code.id);\n continue;\n }\n if (!row) {\n details.delete(code.id);\n // Stored once and deleted since, or not stored because storing failed.\n if (!this.#seeded.has(scopeKey(scope))) {\n problems.push(`Board \"${code.id}\" isn't stored in this project yet; Factory stores it on the next load.`);\n }\n continue;\n }\n let merged: ReturnType<typeof mergeCodeBehaviour>;\n try {\n merged = mergeCodeBehaviour(row, code);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n report(row, merged.problems);\n details.set(code.id, {\n ...details.get(code.id)!,\n problems: [...merged.problems, ...this.#skillProblems(merged.board)],\n });\n boards.push(merged.board);\n }\n // A board of the project's own under the retired Review board's key is served like any other.\n const reviewRow = byKey.get(LEGACY_REVIEW_BOARD);\n const ownsReview = reviewRow !== undefined && !isUntouchedReviewSeed(reviewRow);\n // Served from code and never stored, so nobody edits a board on its way out.\n if (reviewInUse && !ownsReview) {\n boards.push(reviewBoard);\n details.set(reviewBoard.id, { source: 'builtin', editable: false, problems: [] });\n }\n for (const row of rows) {\n if (this.codeRegistry.has(row.key)) continue;\n // Factory seeded this row while Review was a built-in board and nobody edited it since:\n // it is not a board the project made, so it is not served.\n if (row.key === LEGACY_REVIEW_BOARD && !ownsReview) continue;\n let board: InstalledBoard;\n try {\n board = compileStoredBoard(row);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n boards.push(board);\n details.set(row.key, { source: 'stored', editable: true, problems: this.#skillProblems(board) });\n }\n return {\n registry: boardRegistryOf(boards),\n details,\n problems,\n };\n }\n\n #skillProblems(board: InstalledBoard): string[] {\n return findBoardSkillProblems(boardRegistryOf([board]), this.#codeSkills);\n }\n\n #warnOnce(key: string, message: string, debug = false): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n if (debug) {\n console.debug(`[factory] ${message}`);\n return;\n }\n this.#warn(message);\n }\n}\n"],"mappings":";;;;;;;;;;;AAyBA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;;AAE5B,MAAM,qBAAqB,kBAAkB,WAAW,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,MAAM,YAAY;CAAE;CAAK;CAAM;AAAK,EAAE;;;;;AAMnH,SAAgB,sBAAsB,KAAiC;CACrE,IAAI,IAAI,aAAa,KAAK,IAAI,cAAA,WAA0C,OAAO;CAC/E,IAAI,IAAI,cAAA,aAA4C,IAAI,SAAS,YAAY,MAAM,OAAO;CAC1F,MAAM,SAAS,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;CACrE,OACE,OAAO,WAAW,mBAAmB,UACrC,OAAO,OACJ,OAAO,UACN,MAAM,QAAQ,mBAAmB,MAAM,CAAE,OACzC,MAAM,SAAS,mBAAmB,MAAM,CAAE,QAC1C,MAAM,SAAS,mBAAmB,MAAM,CAAE,IAC9C;AAEJ;;;;;;;AAQA,SAAgB,eAAe,cAA6B,EAAE,SAAS,SAAS,CAAC,GAAqB;CACpG,IAAI,CAAC,QAAQ,OAAO,YAAY,aAAa,IAAI,mBAAmB;CACpE,OAAO,OAAO,KAAK,UAAU;EAC3B,MAAM,MAAM,MAAM,gBAAgB,KAAK,OAAO,mBAAmB;EACjE,OAAO,QAAQ,QAAQ,CAAC,sBAAsB,GAAG;CACnD;AACF;AAEA,MAAM,oBAAoB;;;;;;A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C,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,EAAiC,SAAS,cAAc,EAAE,CAAC;AAErF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;CAAO,GAAG,aAAa,CAYvG;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,aAAa,CAmBhF"}
@@ -1,5 +1,3 @@
1
- import { LEGACY_REVIEW_BOARD } from "../storage/domains/work-items/legacy-review.js";
2
- import { reviewBoard } from "./review.js";
3
1
  import { workBoard } from "./work.js";
4
2
  // src/boards/registry.ts
5
3
  const defaultBoards = Object.freeze([workBoard]);
@@ -20,7 +18,6 @@ function createBoardRegistry(options = {}) {
20
18
  function boardRegistryOf(boards) {
21
19
  const registry = /* @__PURE__ */ new Map();
22
20
  for (const board of boards) {
23
- if (board.id === "review" && board !== reviewBoard) throw new Error(`MastraFactory: board id '${LEGACY_REVIEW_BOARD}' is reserved for the retired Review board.`);
24
21
  if (registry.has(board.id)) throw new Error(`MastraFactory: duplicate board id '${board.id}' in 'boards'.`);
25
22
  registry.set(board.id, board);
26
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":[],"sources":["../../src/boards/registry.ts"],"sourcesContent":["import { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport type { BoardDefinition } from './define-board.js';\nimport { reviewBoard } from './review.js';\nimport { workBoard } from './work.js';\n\nexport type InstalledBoard = BoardDefinition<string, string>;\nexport interface BoardRegistry extends Iterable<[string, InstalledBoard]> {\n readonly size: number;\n get(id: string): InstalledBoard | undefined;\n has(id: string): boolean;\n keys(): MapIterator<string>;\n values(): MapIterator<InstalledBoard>;\n entries(): MapIterator<[string, InstalledBoard]>;\n}\n\nexport const defaultBoards = Object.freeze([workBoard]) as readonly InstalledBoard[];\n\n/**\n * Factory's boards: its Work board, then `boards`. Work is always installed; to run another Work,\n * store it under the `work` key with `factory.upsertBoard()`. The exported `workBoard` itself is\n * accepted in `boards` and installed once.\n */\nexport function createBoardRegistry(options: { boards?: readonly InstalledBoard[] } = {}): BoardRegistry {\n const boards = (options.boards ?? []).filter(board => !defaultBoards.includes(board));\n for (const board of boards) {\n const builtIn = defaultBoards.find(candidate => candidate.id === board.id);\n if (builtIn) {\n throw new Error(\n `MastraFactory: board id '${board.id}' is Factory's ${builtIn.name} board, which every project has. ` +\n `To run your own, store it under '${board.id}' with factory.upsertBoard(board, { projects: 'all' }).`,\n );\n }\n }\n return boardRegistryOf([...defaultBoards, ...boards]);\n}\n\n/** A registry of exactly `boards`, in order, such as the boards a project stored. */\nexport function boardRegistryOf(boards: readonly InstalledBoard[]): BoardRegistry {\n const registry = new Map<string, InstalledBoard>();\n\n for (const board of boards) {\n // The retired Review board is served only as itself, to projects still using it; a new board\n // under its id would take over the cards stored there.\n if (board.id === LEGACY_REVIEW_BOARD && board !== reviewBoard) {\n throw new Error(`MastraFactory: board id '${LEGACY_REVIEW_BOARD}' is reserved for the retired Review board.`);\n }\n if (registry.has(board.id)) {\n throw new Error(`MastraFactory: duplicate board id '${board.id}' in 'boards'.`);\n }\n registry.set(board.id, board);\n }\n\n return Object.freeze({\n size: registry.size,\n get: registry.get.bind(registry),\n has: registry.has.bind(registry),\n keys: registry.keys.bind(registry),\n values: registry.values.bind(registry),\n entries: registry.entries.bind(registry),\n [Symbol.iterator]: registry[Symbol.iterator].bind(registry),\n });\n}\n"],"mappings":";;;;AAeA,MAAa,gBAAgB,OAAO,OAAO,CAAC,SAAS,CAAC;;;;;;AAOtD,SAAgB,oBAAoB,UAAkD,CAAC,GAAkB;CACvG,MAAM,UAAU,QAAQ,UAAU,CAAC,EAAA,CAAG,QAAO,UAAS,CAAC,cAAc,SAAS,KAAK,CAAC;CACpF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,cAAc,MAAK,cAAa,UAAU,OAAO,MAAM,EAAE;EACzE,IAAI,SACF,MAAM,IAAI,MACR,4BAA4B,MAAM,GAAG,iBAAiB,QAAQ,KAAK,oEAC7B,MAAM,GAAG,wDACjD;CAEJ;CACA,OAAO,gBAAgB,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC;AACtD;;AAGA,SAAgB,gBAAgB,QAAkD;CAChF,MAAM,2BAAW,IAAI,IAA4B;CAEjD,KAAK,MAAM,SAAS,QAAQ;EAG1B,IAAI,MAAM,OAAA,YAA8B,UAAU,aAChD,MAAM,IAAI,MAAM,4BAA4B,oBAAoB,4CAA4C;EAE9G,IAAI,SAAS,IAAI,MAAM,EAAE,GACvB,MAAM,IAAI,MAAM,sCAAsC,MAAM,GAAG,eAAe;EAEhF,SAAS,IAAI,MAAM,IAAI,KAAK;CAC9B;CAEA,OAAO,OAAO,OAAO;EACnB,MAAM,SAAS;EACf,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,MAAM,SAAS,KAAK,KAAK,QAAQ;EACjC,QAAQ,SAAS,OAAO,KAAK,QAAQ;EACrC,SAAS,SAAS,QAAQ,KAAK,QAAQ;GACtC,OAAO,WAAW,SAAS,OAAO,SAAS,CAAC,KAAK,QAAQ;CAC5D,CAAC;AACH"}
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../src/boards/registry.ts"],"sourcesContent":["import type { BoardDefinition } from './define-board.js';\nimport { workBoard } from './work.js';\n\nexport type InstalledBoard = BoardDefinition<string, string>;\nexport interface BoardRegistry extends Iterable<[string, InstalledBoard]> {\n readonly size: number;\n get(id: string): InstalledBoard | undefined;\n has(id: string): boolean;\n keys(): MapIterator<string>;\n values(): MapIterator<InstalledBoard>;\n entries(): MapIterator<[string, InstalledBoard]>;\n}\n\nexport const defaultBoards = Object.freeze([workBoard]) as readonly InstalledBoard[];\n\n/**\n * Factory's boards: its Work board, then `boards`. Work is always installed; to run another Work,\n * store it under the `work` key with `factory.upsertBoard()`. The exported `workBoard` itself is\n * accepted in `boards` and installed once.\n */\nexport function createBoardRegistry(options: { boards?: readonly InstalledBoard[] } = {}): BoardRegistry {\n const boards = (options.boards ?? []).filter(board => !defaultBoards.includes(board));\n for (const board of boards) {\n const builtIn = defaultBoards.find(candidate => candidate.id === board.id);\n if (builtIn) {\n throw new Error(\n `MastraFactory: board id '${board.id}' is Factory's ${builtIn.name} board, which every project has. ` +\n `To run your own, store it under '${board.id}' with factory.upsertBoard(board, { projects: 'all' }).`,\n );\n }\n }\n return boardRegistryOf([...defaultBoards, ...boards]);\n}\n\n/** A registry of exactly `boards`, in order, such as the boards a project stored. */\nexport function boardRegistryOf(boards: readonly InstalledBoard[]): BoardRegistry {\n const registry = new Map<string, InstalledBoard>();\n\n for (const board of boards) {\n if (registry.has(board.id)) {\n throw new Error(`MastraFactory: duplicate board id '${board.id}' in 'boards'.`);\n }\n registry.set(board.id, board);\n }\n\n return Object.freeze({\n size: registry.size,\n get: registry.get.bind(registry),\n has: registry.has.bind(registry),\n keys: registry.keys.bind(registry),\n values: registry.values.bind(registry),\n entries: registry.entries.bind(registry),\n [Symbol.iterator]: registry[Symbol.iterator].bind(registry),\n });\n}\n"],"mappings":";;AAaA,MAAa,gBAAgB,OAAO,OAAO,CAAC,SAAS,CAAC;;;;;;AAOtD,SAAgB,oBAAoB,UAAkD,CAAC,GAAkB;CACvG,MAAM,UAAU,QAAQ,UAAU,CAAC,EAAA,CAAG,QAAO,UAAS,CAAC,cAAc,SAAS,KAAK,CAAC;CACpF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,cAAc,MAAK,cAAa,UAAU,OAAO,MAAM,EAAE;EACzE,IAAI,SACF,MAAM,IAAI,MACR,4BAA4B,MAAM,GAAG,iBAAiB,QAAQ,KAAK,oEAC7B,MAAM,GAAG,wDACjD;CAEJ;CACA,OAAO,gBAAgB,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC;AACtD;;AAGA,SAAgB,gBAAgB,QAAkD;CAChF,MAAM,2BAAW,IAAI,IAA4B;CAEjD,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,SAAS,IAAI,MAAM,EAAE,GACvB,MAAM,IAAI,MAAM,sCAAsC,MAAM,GAAG,eAAe;EAEhF,SAAS,IAAI,MAAM,IAAI,KAAK;CAC9B;CAEA,OAAO,OAAO,OAAO;EACnB,MAAM,SAAS;EACf,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,MAAM,SAAS,KAAK,KAAK,QAAQ;EACjC,QAAQ,SAAS,OAAO,KAAK,QAAQ;EACrC,SAAS,SAAS,QAAQ,KAAK,QAAQ;GACtC,OAAO,WAAW,SAAS,OAAO,SAAS,CAAC,KAAK,QAAQ;CAC5D,CAAC;AACH"}
@@ -14,6 +14,11 @@ export interface RepositoryInput {
14
14
  metadata?: Record<string, unknown>;
15
15
  }
16
16
  export type RepositoryAccess = FactoryRepositoryAccess;
17
+ /** One credential for a set of repositories, plus each repository's own access under it. */
18
+ export type RepositoriesAccess = RepositoryAccess & {
19
+ /** Keyed by repository id: that repository's clone URL with the shared credential. */
20
+ repositories?: Record<string, RepositoryAccess>;
21
+ };
17
22
  export interface RepositoryTarget {
18
23
  connection: IntegrationConnection;
19
24
  sourceId: string;
@@ -260,7 +265,7 @@ export interface VersionControl {
260
265
  getRepositoriesAccess?(input: {
261
266
  orgId: string;
262
267
  repositoryIds: string[];
263
- }): Promise<RepositoryAccess | undefined>;
268
+ }): Promise<RepositoriesAccess | undefined>;
264
269
  listPullRequests(input: ListPullRequestsInput): Promise<PullRequestPage>;
265
270
  getPullRequest(input: PullRequestRef): Promise<PullRequest | null>;
266
271
  createPullRequest(input: CreatePullRequestInput): Promise<PullRequest>;
@@ -1 +1 @@
1
- {"version":3,"file":"version-control.d.ts","sourceRoot":"","sources":["../../src/capabilities/version-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,C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,CAAC,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/E,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7E,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7E,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC3E,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC3E,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnF,0FAA0F;IAC1F,kBAAkB,CAAC,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3E"}
@@ -10,7 +10,7 @@ import type { ScheduleService } from './build-schedule.js';
10
10
  import type { EnvironmentBuildWorkflowOptions } from './build-workflow.js';
11
11
  import type { EnvironmentBuildDeps, EnvironmentBuildOutcome, EnvironmentBuildTrigger } from './build.js';
12
12
  export type StartEnvironmentBuild = (projectId: string, trigger: EnvironmentBuildTrigger) => Promise<EnvironmentBuildOutcome>;
13
- export interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart'> {
13
+ export interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart' | 'onSettled'> {
14
14
  /** The booted instance; `undefined` until the host finished `finalize()`. */
15
15
  getMastra: () => Mastra | undefined;
16
16
  logger?: {
@@ -26,7 +26,7 @@ export declare class EnvironmentBuildRunner {
26
26
  #private;
27
27
  readonly workflow: import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "factory-environment-build", unknown, {
28
28
  projectId: string;
29
- trigger: "manual" | "push" | "schedule";
29
+ trigger: "manual" | "push" | "schedule" | "settings";
30
30
  }, {
31
31
  outcome: "failed" | "skipped" | "started" | "unavailable";
32
32
  buildId?: string | undefined;
@@ -60,6 +60,17 @@ export declare class EnvironmentBuildRunner {
60
60
  * builds. Fire and forget: the webhook never waits on it.
61
61
  */
62
62
  readonly onRepositoryPush: (event: RepositoryPushEvent) => void;
63
+ /**
64
+ * A saved change to a project's environment (settings, setup commands,
65
+ * repositories, Build variables) starts a `settings` run, which builds only
66
+ * when the template inputs changed. A run skipped because another one
67
+ * holds the build-start lease or its build is running (either may have read
68
+ * the environment before this save) stays pending until that run is over.
69
+ * A lease held by another process is retried, a second apart and doubling
70
+ * up to `SETTINGS_RETRY_MAX_MS`, until it is released or lapses. Fire and
71
+ * forget: the save never waits on it or fails because of it.
72
+ */
73
+ readonly onEnvironmentSaved: (projectId: string) => void;
63
74
  /**
64
75
  * Start a run and resolve with the first step's answer; the poll step keeps
65
76
  * running in the background. Resolves `unavailable` before the host booted
@@ -1 +1 @@
1
- {"version":3,"file":"build-runner.d.ts","sourceRoot":"","sources":["../../src/environment/build-runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,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I,OAAO,CAE/B;IAED,gGAAgG;IAC1F,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAIvC;IAED;;;;;OAKG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAsBrF;IAED;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,UAAW,mBAAmB,KAAG,IAAI,CAa5D;IAEF;;;;;;;;;OASG;IACH,QAAQ,CAAC,kBAAkB,cAAe,MAAM,KAAG,IAAI,CAmBrD;IAEF;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAqCnC;CACH"}
@@ -3,23 +3,38 @@ import { probeSchedulesAvailable } from "./build-schedule.js";
3
3
  import { ENVIRONMENT_BUILD_WORKFLOW_ID, createEnvironmentBuildWorkflow } from "./build-workflow.js";
4
4
  import { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from "./build.js";
5
5
  // src/environment/build-runner.ts
6
+ /** Longest wait between `settings` runs that find another process holding the build-start lease. */
7
+ const SETTINGS_RETRY_MAX_MS = 3e4;
6
8
  var EnvironmentBuildRunner = class {
7
9
  workflow;
8
10
  #deps;
9
11
  #getMastra;
10
12
  #logger;
11
13
  #pending = /* @__PURE__ */ new Map();
14
+ #sleep;
15
+ /** Projects with a saved change that a run of theirs skipped; that run's end builds it. */
16
+ #awaitingRun = /* @__PURE__ */ new Set();
12
17
  #scheduleAvailable = false;
13
18
  constructor(deps, options) {
14
19
  const { getMastra, logger, ...workflowOptions } = options;
15
20
  this.#deps = deps;
16
21
  this.#getMastra = getMastra;
17
22
  this.#logger = logger;
23
+ this.#sleep = workflowOptions.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
18
24
  this.workflow = createEnvironmentBuildWorkflow(deps, {
19
25
  ...workflowOptions,
20
26
  onStart: (runId, outcome) => {
21
27
  this.#pending.get(runId)?.(outcome);
22
28
  this.#pending.delete(runId);
29
+ },
30
+ onSettled: (projectId, result) => {
31
+ if (result.outcome === "started") {
32
+ this.#awaitingRun.delete(projectId);
33
+ this.onEnvironmentSaved(projectId);
34
+ return;
35
+ }
36
+ if (result.outcome === "skipped" && (result.reason === "starting" || result.reason === "in_progress")) return;
37
+ if (this.#awaitingRun.delete(projectId)) this.onEnvironmentSaved(projectId);
23
38
  }
24
39
  });
25
40
  }
@@ -72,6 +87,33 @@ var EnvironmentBuildRunner = class {
72
87
  });
73
88
  };
74
89
  /**
90
+ * A saved change to a project's environment (settings, setup commands,
91
+ * repositories, Build variables) starts a `settings` run, which builds only
92
+ * when the template inputs changed. A run skipped because another one
93
+ * holds the build-start lease or its build is running (either may have read
94
+ * the environment before this save) stays pending until that run is over.
95
+ * A lease held by another process is retried, a second apart and doubling
96
+ * up to `SETTINGS_RETRY_MAX_MS`, until it is released or lapses. Fire and
97
+ * forget: the save never waits on it or fails because of it.
98
+ */
99
+ onEnvironmentSaved = (projectId) => {
100
+ (async () => {
101
+ for (let delay = 1e3;; delay = Math.min(delay * 2, SETTINGS_RETRY_MAX_MS)) {
102
+ const outcome = await this.start(projectId, "settings");
103
+ if (outcome.outcome !== "skipped" || outcome.reason !== "starting" && outcome.reason !== "in_progress") return;
104
+ this.#awaitingRun.add(projectId);
105
+ if (outcome.reason === "in_progress") return;
106
+ await this.#sleep(delay);
107
+ if (!this.#awaitingRun.has(projectId)) return;
108
+ }
109
+ })().catch((error) => {
110
+ this.#logger?.info("environment build settings hand-off failed", {
111
+ factoryProjectId: projectId,
112
+ reason: errorReason(error)
113
+ });
114
+ });
115
+ };
116
+ /**
75
117
  * Start a run and resolve with the first step's answer; the poll step keeps
76
118
  * running in the background. Resolves `unavailable` before the host booted
77
119
  * or when the host never registered the workflow, and `failed` when the run
@@ -1 +1 @@
1
- {"version":3,"file":"build-runner.js","names":[],"sources":["../../src/environment/build-runner.ts"],"sourcesContent":["/**\n * Starts `factory-environment-build` runs on the booted `Mastra`. Every\n * trigger goes through a workflow run so the start decision and the poll are\n * recorded the same way whether a route, the scheduler or a webhook asked.\n */\n\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\nimport type { RepositoryPushEvent } from '../integrations/base.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport { probeSchedulesAvailable } from './build-schedule.js';\nimport type { ScheduleService } from './build-schedule.js';\nimport { createEnvironmentBuildWorkflow, ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\nimport type { EnvironmentBuildWorkflowOptions } from './build-workflow.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome, EnvironmentBuildTrigger } from './build.js';\nimport { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from './build.js';\n\nexport type StartEnvironmentBuild = (\n projectId: string,\n trigger: EnvironmentBuildTrigger,\n) => Promise<EnvironmentBuildOutcome>;\n\nexport interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart'> {\n /** The booted instance; `undefined` until the host finished `finalize()`. */\n getMastra: () => Mastra | undefined;\n logger?: { info: (msg: string, meta?: Record<string, unknown>) => void };\n}\n\n/** What a read of a build's status or history hands the provider. */\nexport interface EnvironmentBuildReadContext {\n ctx: FactorySandboxContext;\n settings: Record<string, unknown>;\n}\n\nexport class EnvironmentBuildRunner {\n readonly workflow;\n readonly #deps: EnvironmentBuildDeps;\n readonly #getMastra: () => Mastra | undefined;\n readonly #logger: EnvironmentBuildRunnerOptions['logger'];\n readonly #pending = new Map<string, (outcome: EnvironmentBuildOutcome) => void>();\n #scheduleAvailable = false;\n\n constructor(deps: EnvironmentBuildDeps, options: EnvironmentBuildRunnerOptions) {\n const { getMastra, logger, ...workflowOptions } = options;\n this.#deps = deps;\n this.#getMastra = getMastra;\n this.#logger = logger;\n this.workflow = createEnvironmentBuildWorkflow(deps, {\n ...workflowOptions,\n onStart: (runId, outcome) => {\n this.#pending.get(runId)?.(outcome);\n this.#pending.delete(runId);\n },\n });\n }\n\n /** The schedule service of the booted host, `undefined` before boot. */\n schedules(): ScheduleService | undefined {\n return this.#getMastra()?.schedules;\n }\n\n /** Whether the host's storage implements schedules; false until `probeSchedules()` ran. */\n get scheduleAvailable(): boolean {\n return this.#scheduleAvailable;\n }\n\n /** Probe once after the host booted; a storage without the domain disables the cron trigger. */\n async probeSchedules(): Promise<boolean> {\n const schedules = this.schedules();\n this.#scheduleAvailable = schedules ? await probeSchedulesAvailable(schedules) : false;\n return this.#scheduleAvailable;\n }\n\n /**\n * The context a status or history read hands the provider. Heads come from\n * the stored last attempt (the build being read was pinned to them), else\n * the active template, so a read never calls GitHub; before the first build\n * they are resolved live once.\n */\n async readContext(projectId: string): Promise<EnvironmentBuildReadContext | undefined> {\n const sourceControl = this.#deps.sourceControl;\n if (!sourceControl) return undefined;\n const project = await this.#deps.projects.getById({ id: projectId });\n if (!project) return undefined;\n const environment = await resolveProjectEnvironment(sourceControl.storage, project);\n const heads =\n project.lastBuildHeads ??\n project.activeTemplateHeads ??\n (await resolveEnvironmentHeads(sourceControl, project, environment));\n return {\n ctx: (\n await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n sourceControl.versionControl,\n this.#deps.sandboxEnvs,\n )\n ).ctx,\n settings: environment.settings,\n };\n }\n\n /**\n * A push to an environment repository's default branch starts a `push` run\n * when the project opted in; the run's debounce claim decides whether it\n * builds. Fire and forget: the webhook never waits on it.\n */\n readonly onRepositoryPush = (event: RepositoryPushEvent): void => {\n if (!event.projectRepository.inEnvironment) return;\n const branch = event.defaultBranch;\n if (event.ref !== `refs/heads/${branch}`) return;\n void this.#deps.projects\n .getById({ id: event.factoryProjectId })\n .then(project => (project?.buildOnPushEnabled ? this.start(project.id, 'push') : undefined))\n .catch((error: unknown) => {\n this.#logger?.info('environment build push hand-off failed', {\n factoryProjectId: event.factoryProjectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * Start a run and resolve with the first step's answer; the poll step keeps\n * running in the background. Resolves `unavailable` before the host booted\n * or when the host never registered the workflow, and `failed` when the run\n * could not be created; a caller that already saved its own change must not\n * fail on the build it merely requested.\n */\n readonly start: StartEnvironmentBuild = async (projectId, trigger) => {\n const mastra = this.#getMastra();\n if (!mastra) return { outcome: 'unavailable', reason: 'not_ready' };\n let run: Awaited<ReturnType<typeof this.workflow.createRun>>;\n try {\n run = await mastra.getWorkflow(ENVIRONMENT_BUILD_WORKFLOW_ID).createRun();\n } catch (error) {\n const reason = errorReason(error);\n this.#logger?.info('environment build run could not be created', { factoryProjectId: projectId, reason });\n return mastra.listWorkflows()[ENVIRONMENT_BUILD_WORKFLOW_ID]\n ? { outcome: 'failed', reason }\n : { outcome: 'unavailable', reason: 'no_workflow' };\n }\n const outcome = new Promise<EnvironmentBuildOutcome>(resolve => this.#pending.set(run.runId, resolve));\n run\n .start({ inputData: { projectId, trigger } })\n .then(result => {\n if (result.status !== 'success') {\n this.#logger?.info('environment build run did not succeed', {\n factoryProjectId: projectId,\n runId: run.runId,\n });\n }\n })\n .catch((error: unknown) => {\n this.#logger?.info('environment build run threw', {\n factoryProjectId: projectId,\n runId: run.runId,\n reason: errorReason(error),\n });\n })\n .finally(() => {\n // A run that failed before its first step answered must not hang the caller.\n this.#pending.get(run.runId)?.({ outcome: 'failed', reason: 'The build run ended before it started a build.' });\n this.#pending.delete(run.runId);\n });\n return outcome;\n };\n}\n"],"mappings":";;;;;AAkCA,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA;CACA;CACA,2BAAoB,IAAI,IAAwD;CAChF,qBAAqB;CAErB,YAAY,MAA4B,SAAwC;EAC9E,MAAM,EAAE,WAAW,QAAQ,GAAG,oBAAoB;EAClD,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,WAAW,+BAA+B,MAAM;GACnD,GAAG;GACH,UAAU,OAAO,YAAY;IAC3B,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,OAAO;IAClC,KAAK,SAAS,OAAO,KAAK;GAC5B;EACF,CAAC;CACH;;CAGA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E,IAAI;EACJ,IAAI;GACF,MAAM,MAAM,OAAO,YAAY,6BAA6B,CAAC,CAAC,UAAU;EAC1E,SAAS,OAAO;GACd,MAAM,SAAS,YAAY,KAAK;GAChC,KAAK,SAAS,KAAK,8CAA8C;IAAE,kBAAkB;IAAW;GAAO,CAAC;GACxG,OAAO,OAAO,cAAc,CAAC,CAAA,+BACzB;IAAE,SAAS;IAAU;GAAO,IAC5B;IAAE,SAAS;IAAe,QAAQ;GAAc;EACtD;EACA,MAAM,UAAU,IAAI,SAAiC,YAAW,KAAK,SAAS,IAAI,IAAI,OAAO,OAAO,CAAC;EACrG,IACG,MAAM,EAAE,WAAW;GAAE;GAAW;EAAQ,EAAE,CAAC,CAAC,CAC5C,MAAK,WAAU;GACd,IAAI,OAAO,WAAW,WACpB,KAAK,SAAS,KAAK,yCAAyC;IAC1D,kBAAkB;IAClB,OAAO,IAAI;GACb,CAAC;EAEL,CAAC,CAAC,CACD,OAAO,UAAmB;GACzB,KAAK,SAAS,KAAK,+BAA+B;IAChD,kBAAkB;IAClB,OAAO,IAAI;IACX,QAAQ,YAAY,KAAK;GAC3B,CAAC;EACH,CAAC,CAAC,CACD,cAAc;GAEb,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC,GAAG;IAAE,SAAS;IAAU,QAAQ;GAAiD,CAAC;GAC9G,KAAK,SAAS,OAAO,IAAI,KAAK;EAChC,CAAC;EACH,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"build-runner.js","names":[],"sources":["../../src/environment/build-runner.ts"],"sourcesContent":["/**\n * Starts `factory-environment-build` runs on the booted `Mastra`. Every\n * trigger goes through a workflow run so the start decision and the poll are\n * recorded the same way whether a route, the scheduler or a webhook asked.\n */\n\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\nimport type { RepositoryPushEvent } from '../integrations/base.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport { probeSchedulesAvailable } from './build-schedule.js';\nimport type { ScheduleService } from './build-schedule.js';\nimport { createEnvironmentBuildWorkflow, ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\nimport type { EnvironmentBuildWorkflowOptions } from './build-workflow.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome, EnvironmentBuildTrigger } from './build.js';\nimport { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from './build.js';\n\n/** Longest wait between `settings` runs that find another process holding the build-start lease. */\nconst SETTINGS_RETRY_MAX_MS = 30_000;\n\nexport type StartEnvironmentBuild = (\n projectId: string,\n trigger: EnvironmentBuildTrigger,\n) => Promise<EnvironmentBuildOutcome>;\n\nexport interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart' | 'onSettled'> {\n /** The booted instance; `undefined` until the host finished `finalize()`. */\n getMastra: () => Mastra | undefined;\n logger?: { info: (msg: string, meta?: Record<string, unknown>) => void };\n}\n\n/** What a read of a build's status or history hands the provider. */\nexport interface EnvironmentBuildReadContext {\n ctx: FactorySandboxContext;\n settings: Record<string, unknown>;\n}\n\nexport class EnvironmentBuildRunner {\n readonly workflow;\n readonly #deps: EnvironmentBuildDeps;\n readonly #getMastra: () => Mastra | undefined;\n readonly #logger: EnvironmentBuildRunnerOptions['logger'];\n readonly #pending = new Map<string, (outcome: EnvironmentBuildOutcome) => void>();\n readonly #sleep: (ms: number) => Promise<void>;\n /** Projects with a saved change that a run of theirs skipped; that run's end builds it. */\n readonly #awaitingRun = new Set<string>();\n #scheduleAvailable = false;\n\n constructor(deps: EnvironmentBuildDeps, options: EnvironmentBuildRunnerOptions) {\n const { getMastra, logger, ...workflowOptions } = options;\n this.#deps = deps;\n this.#getMastra = getMastra;\n this.#logger = logger;\n this.#sleep = workflowOptions.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)));\n this.workflow = createEnvironmentBuildWorkflow(deps, {\n ...workflowOptions,\n onStart: (runId, outcome) => {\n this.#pending.get(runId)?.(outcome);\n this.#pending.delete(runId);\n },\n // Fires for every run of the registered workflow, scheduled ones included.\n // A started build always checks once more, since a save (here or in\n // another process) may have been skipped against it; a run that held the\n // lease without building hands back a save skipped meanwhile. A run that\n // was itself skipped against the lease or a running build hands back\n // nothing: the run it deferred to is still going.\n onSettled: (projectId, result) => {\n if (result.outcome === 'started') {\n this.#awaitingRun.delete(projectId);\n this.onEnvironmentSaved(projectId);\n return;\n }\n if (result.outcome === 'skipped' && (result.reason === 'starting' || result.reason === 'in_progress')) return;\n if (this.#awaitingRun.delete(projectId)) this.onEnvironmentSaved(projectId);\n },\n });\n }\n\n /** The schedule service of the booted host, `undefined` before boot. */\n schedules(): ScheduleService | undefined {\n return this.#getMastra()?.schedules;\n }\n\n /** Whether the host's storage implements schedules; false until `probeSchedules()` ran. */\n get scheduleAvailable(): boolean {\n return this.#scheduleAvailable;\n }\n\n /** Probe once after the host booted; a storage without the domain disables the cron trigger. */\n async probeSchedules(): Promise<boolean> {\n const schedules = this.schedules();\n this.#scheduleAvailable = schedules ? await probeSchedulesAvailable(schedules) : false;\n return this.#scheduleAvailable;\n }\n\n /**\n * The context a status or history read hands the provider. Heads come from\n * the stored last attempt (the build being read was pinned to them), else\n * the active template, so a read never calls GitHub; before the first build\n * they are resolved live once.\n */\n async readContext(projectId: string): Promise<EnvironmentBuildReadContext | undefined> {\n const sourceControl = this.#deps.sourceControl;\n if (!sourceControl) return undefined;\n const project = await this.#deps.projects.getById({ id: projectId });\n if (!project) return undefined;\n const environment = await resolveProjectEnvironment(sourceControl.storage, project);\n const heads =\n project.lastBuildHeads ??\n project.activeTemplateHeads ??\n (await resolveEnvironmentHeads(sourceControl, project, environment));\n return {\n ctx: (\n await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n sourceControl.versionControl,\n this.#deps.sandboxEnvs,\n )\n ).ctx,\n settings: environment.settings,\n };\n }\n\n /**\n * A push to an environment repository's default branch starts a `push` run\n * when the project opted in; the run's debounce claim decides whether it\n * builds. Fire and forget: the webhook never waits on it.\n */\n readonly onRepositoryPush = (event: RepositoryPushEvent): void => {\n if (!event.projectRepository.inEnvironment) return;\n const branch = event.defaultBranch;\n if (event.ref !== `refs/heads/${branch}`) return;\n void this.#deps.projects\n .getById({ id: event.factoryProjectId })\n .then(project => (project?.buildOnPushEnabled ? this.start(project.id, 'push') : undefined))\n .catch((error: unknown) => {\n this.#logger?.info('environment build push hand-off failed', {\n factoryProjectId: event.factoryProjectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * A saved change to a project's environment (settings, setup commands,\n * repositories, Build variables) starts a `settings` run, which builds only\n * when the template inputs changed. A run skipped because another one\n * holds the build-start lease or its build is running (either may have read\n * the environment before this save) stays pending until that run is over.\n * A lease held by another process is retried, a second apart and doubling\n * up to `SETTINGS_RETRY_MAX_MS`, until it is released or lapses. Fire and\n * forget: the save never waits on it or fails because of it.\n */\n readonly onEnvironmentSaved = (projectId: string): void => {\n void (async () => {\n for (let delay = 1000; ; delay = Math.min(delay * 2, SETTINGS_RETRY_MAX_MS)) {\n const outcome = await this.start(projectId, 'settings');\n if (outcome.outcome !== 'skipped' || (outcome.reason !== 'starting' && outcome.reason !== 'in_progress')) {\n return;\n }\n this.#awaitingRun.add(projectId);\n if (outcome.reason === 'in_progress') return;\n await this.#sleep(delay);\n // A run of this process ended meanwhile and handed the save back.\n if (!this.#awaitingRun.has(projectId)) return;\n }\n })().catch((error: unknown) => {\n this.#logger?.info('environment build settings hand-off failed', {\n factoryProjectId: projectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * Start a run and resolve with the first step's answer; the poll step keeps\n * running in the background. Resolves `unavailable` before the host booted\n * or when the host never registered the workflow, and `failed` when the run\n * could not be created; a caller that already saved its own change must not\n * fail on the build it merely requested.\n */\n readonly start: StartEnvironmentBuild = async (projectId, trigger) => {\n const mastra = this.#getMastra();\n if (!mastra) return { outcome: 'unavailable', reason: 'not_ready' };\n let run: Awaited<ReturnType<typeof this.workflow.createRun>>;\n try {\n run = await mastra.getWorkflow(ENVIRONMENT_BUILD_WORKFLOW_ID).createRun();\n } catch (error) {\n const reason = errorReason(error);\n this.#logger?.info('environment build run could not be created', { factoryProjectId: projectId, reason });\n return mastra.listWorkflows()[ENVIRONMENT_BUILD_WORKFLOW_ID]\n ? { outcome: 'failed', reason }\n : { outcome: 'unavailable', reason: 'no_workflow' };\n }\n const outcome = new Promise<EnvironmentBuildOutcome>(resolve => this.#pending.set(run.runId, resolve));\n run\n .start({ inputData: { projectId, trigger } })\n .then(result => {\n if (result.status !== 'success') {\n this.#logger?.info('environment build run did not succeed', {\n factoryProjectId: projectId,\n runId: run.runId,\n });\n }\n })\n .catch((error: unknown) => {\n this.#logger?.info('environment build run threw', {\n factoryProjectId: projectId,\n runId: run.runId,\n reason: errorReason(error),\n });\n })\n .finally(() => {\n // A run that failed before its first step answered must not hang the caller.\n this.#pending.get(run.runId)?.({ outcome: 'failed', reason: 'The build run ended before it started a build.' });\n this.#pending.delete(run.runId);\n });\n return outcome;\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB;AAmB9B,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA;CACA;CACA,2BAAoB,IAAI,IAAwD;CAChF;;CAEA,+BAAwB,IAAI,IAAY;CACxC,qBAAqB;CAErB,YAAY,MAA4B,SAAwC;EAC9E,MAAM,EAAE,WAAW,QAAQ,GAAG,oBAAoB;EAClD,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,SAAS,gBAAgB,WAAU,OAAM,IAAI,SAAc,YAAW,WAAW,SAAS,EAAE,CAAC;EAClG,KAAK,WAAW,+BAA+B,MAAM;GACnD,GAAG;GACH,UAAU,OAAO,YAAY;IAC3B,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,OAAO;IAClC,KAAK,SAAS,OAAO,KAAK;GAC5B;GAOA,YAAY,WAAW,WAAW;IAChC,IAAI,OAAO,YAAY,WAAW;KAChC,KAAK,aAAa,OAAO,SAAS;KAClC,KAA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AS,KAAK,yCAAyC;IAC1D,kBAAkB;IAClB,OAAO,IAAI;GACb,CAAC;EAEL,CAAC,CAAC,CACD,OAAO,UAAmB;GACzB,KAAK,SAAS,KAAK,+BAA+B;IAChD,kBAAkB;IAClB,OAAO,IAAI;IACX,QAAQ,YAAY,KAAK;GAC3B,CAAC;EACH,CAAC,CAAC,CACD,cAAc;GAEb,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC,GAAG;IAAE,SAAS;IAAU,QAAQ;GAAiD,CAAC;GAC9G,KAAK,SAAS,OAAO,IAAI,KAAK;EAChC,CAAC;EACH,OAAO;CACT;AACF"}
@@ -47,7 +47,7 @@ function toView(schedule) {
47
47
  };
48
48
  return {
49
49
  enabled: schedule.status === "active",
50
- cron: schedule.cron,
50
+ cron: schedule.cron ?? null,
51
51
  timezone: schedule.timezone ?? null
52
52
  };
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-schedule.js","names":[],"sources":["../../src/environment/build-schedule.ts"],"sourcesContent":["/**\n * The per-project cron that fires the `factory-environment-build` workflow,\n * kept in core `Schedules` (one row per project) rather than a factory\n * column: the scheduler owns firing, claims and the run trigger log, factory\n * only creates, pauses, resumes and reads the row.\n */\n\nimport type { AnySchedule, Schedules, WorkflowSchedule } from '@mastra/core/schedules';\nimport { validateCron } from '@mastra/core/workflows';\nimport { ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\n\nexport const SCHEDULES_UNAVAILABLE_ERROR_ID = 'SCHEDULES_NO_SCHEDULES_STORAGE';\n\n/**\n * The project's schedule id in its stored form. Core normalizes a created\n * id to `schedule_<slug>` and resolves a bare id to `agent_<slug>` on reads,\n * so factory always addresses the row by the normalized id (a project id is\n * a lower-case uuid, which slugifies to itself).\n */\nexport function scheduleIdFor(projectId: string): string {\n return `schedule_factory-environment-build-${projectId}`;\n}\n\nexport interface EnvironmentBuildSchedule {\n enabled: boolean;\n cron: string | null;\n timezone: string | null;\n}\n\nexport type ScheduleService = Pick<Schedules, 'create' | 'get' | 'list' | 'update' | 'pause' | 'resume' | 'delete'>;\n\nfunction isSchedulesUnavailable(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { id?: unknown }).id === SCHEDULES_UNAVAILABLE_ERROR_ID\n );\n}\n\n/**\n * Whether the host's storage implements the schedules domain. `mastra.schedules`\n * never throws on access; the missing store surfaces on the first call.\n */\nexport async function probeSchedulesAvailable(schedules: ScheduleService): Promise<boolean> {\n try {\n await schedules.list({ workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID });\n return true;\n } catch (error) {\n if (isSchedulesUnavailable(error)) return false;\n throw error;\n }\n}\n\n/** `undefined` when the cron parses; otherwise the validator's message. */\nexport function invalidCronMessage(cron: string, timezone?: string): string | undefined {\n try {\n validateCron(cron, timezone);\n return undefined;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n }\n}\n\nfunction isWorkflowSchedule(schedule: AnySchedule | null): schedule is WorkflowSchedule {\n return schedule !== null && schedule.agentId === undefined;\n}\n\nfunction toView(schedule: WorkflowSchedule | null): EnvironmentBuildSchedule {\n if (!schedule) return { enabled: false, cron: null, timezone: null };\n return { enabled: schedule.status === 'active', cron: schedule.cron, timezone: schedule.timezone ?? null };\n}\n\n/** The project's build schedule as the environment reports it. */\nexport async function readSchedule(schedules: ScheduleService, projectId: string): Promise<EnvironmentBuildSchedule> {\n const schedule = await schedules.get(scheduleIdFor(projectId));\n return toView(isWorkflowSchedule(schedule) ? schedule : null);\n}\n\n/**\n * Create, update, pause or resume the project's schedule so it matches\n * `input`. Disabling a project that never had a schedule creates nothing.\n */\nexport async function ensureSchedule(\n schedules: ScheduleService,\n projectId: string,\n input: { enabled: boolean; cron: string; timezone?: string },\n): Promise<EnvironmentBuildSchedule> {\n const id = scheduleIdFor(projectId);\n const existing = await schedules.get(id);\n const current = isWorkflowSchedule(existing) ? existing : null;\n if (!current) {\n if (!input.enabled) return toView(null);\n const created = await schedules.create({\n id,\n workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID,\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n inputData: { projectId, trigger: 'schedule' },\n resourceId: projectId,\n });\n return toView(created);\n }\n const timingChanged = current.cron !== input.cron || (current.timezone ?? undefined) !== input.timezone;\n let next: AnySchedule = current;\n if (timingChanged) {\n next = await schedules.update(current.id, {\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n });\n }\n if (input.enabled && next.status === 'paused') next = await schedules.resume(current.id);\n if (!input.enabled && next.status === 'active') next = await schedules.pause(current.id);\n return toView(isWorkflowSchedule(next) ? next : null);\n}\n"],"mappings":";;;AAWA,MAAa,iCAAiC;;;;;;;AAQ9C,SAAgB,cAAc,WAA2B;CACvD,OAAO,sCAAsC;AAC/C;AAUA,SAAS,uBAAuB,OAAyB;CACvD,OACE,OAAO,UAAU,YAAY,UAAU,QAAS,MAA2B,OAAA;AAE/E;;;;;AAMA,eAAsB,wBAAwB,WAA8C;CAC1F,IAAI;EACF,MAAM,UAAU,KAAK,EAAE,YAAY,8BAA8B,CAAC;EAClE,OAAO;CACT,SAAS,OAAO;EACd,IAAI,uBAAuB,KAAK,GAAG,OAAO;EAC1C,MAAM;CACR;AACF;;AAGA,SAAgB,mBAAmB,MAAc,UAAuC;CACtF,IAAI;EACF,aAAa,MAAM,QAAQ;EAC3B;CACF,SAAS,OAAO;EACd,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC9D;AACF;AAEA,SAAS,mBAAmB,UAA4D;CACtF,OAAO,aAAa,QAAQ,SAAS,YAAY,KAAA;AACnD;AAEA,SAAS,OAAO,UAA6D;CAC3E,IAAI,CAAC,UAAU,OAAO;EAAE,SAAS;EAAO,MAAM;EAAM,UAAU;CAAK;CACnE,OAAO;EAAE,SAAS,SAAS,WAAW;EAAU,MAAM,SAAS;EAAM,UAAU,SAAS,YAAY;CAAK;AAC3G;;AAGA,eAAsB,aAAa,WAA4B,WAAsD;CACnH,MAAM,WAAW,MAAM,UAAU,IAAI,cAAc,SAAS,CAAC;CAC7D,OAAO,OAAO,mBAAmB,QAAQ,IAAI,WAAW,IAAI;AAC9D;;;;;AAMA,eAAsB,eACpB,WACA,WACA,OACmC;CACnC,MAAM,KAAK,cAAc,SAAS;CAClC,MAAM,WAAW,MAAM,UAAU,IAAI,EAAE;CACvC,MAAM,UAAU,mBAAmB,QAAQ,IAAI,WAAW;CAC1D,IAAI,CAAC,SAAS;EACZ,IAAI,CAAC,MAAM,SAAS,OAAO,OAAO,IAAI;EAStC,OAAO,OAAO,MARQ,UAAU,OAAO;GACrC;GACA,YAAY;GACZ,MAAM,MAAM;GACZ,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;GACrD,WAAW;IAAE;IAAW,SAAS;GAAW;GAC5C,YAAY;EACd,CAAC,CACoB;CACvB;CACA,MAAM,gBAAgB,QAAQ,SAAS,MAAM,SAAS,QAAQ,YAAY,KAAA,OAAe,MAAM;CAC/F,IAAI,OAAoB;CACxB,IAAI,eACF,OAAO,MAAM,UAAU,OAAO,QAAQ,IAAI;EACxC,MAAM,MAAM;EACZ,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;CACvD,CAAC;CAEH,IAAI,MAAM,WAAW,KAAK,WAAW,UAAU,OAAO,MAAM,UAAU,OAAO,QAAQ,EAAE;CACvF,IAAI,CAAC,MAAM,WAAW,KAAK,WAAW,UAAU,OAAO,MAAM,UAAU,MAAM,QAAQ,EAAE;CACvF,OAAO,OAAO,mBAAmB,IAAI,IAAI,OAAO,IAAI;AACtD"}
1
+ {"version":3,"file":"build-schedule.js","names":[],"sources":["../../src/environment/build-schedule.ts"],"sourcesContent":["/**\n * The per-project cron that fires the `factory-environment-build` workflow,\n * kept in core `Schedules` (one row per project) rather than a factory\n * column: the scheduler owns firing, claims and the run trigger log, factory\n * only creates, pauses, resumes and reads the row.\n */\n\nimport type { AnySchedule, Schedules, WorkflowSchedule } from '@mastra/core/schedules';\nimport { validateCron } from '@mastra/core/workflows';\nimport { ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\n\nexport const SCHEDULES_UNAVAILABLE_ERROR_ID = 'SCHEDULES_NO_SCHEDULES_STORAGE';\n\n/**\n * The project's schedule id in its stored form. Core normalizes a created\n * id to `schedule_<slug>` and resolves a bare id to `agent_<slug>` on reads,\n * so factory always addresses the row by the normalized id (a project id is\n * a lower-case uuid, which slugifies to itself).\n */\nexport function scheduleIdFor(projectId: string): string {\n return `schedule_factory-environment-build-${projectId}`;\n}\n\nexport interface EnvironmentBuildSchedule {\n enabled: boolean;\n cron: string | null;\n timezone: string | null;\n}\n\nexport type ScheduleService = Pick<Schedules, 'create' | 'get' | 'list' | 'update' | 'pause' | 'resume' | 'delete'>;\n\nfunction isSchedulesUnavailable(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { id?: unknown }).id === SCHEDULES_UNAVAILABLE_ERROR_ID\n );\n}\n\n/**\n * Whether the host's storage implements the schedules domain. `mastra.schedules`\n * never throws on access; the missing store surfaces on the first call.\n */\nexport async function probeSchedulesAvailable(schedules: ScheduleService): Promise<boolean> {\n try {\n await schedules.list({ workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID });\n return true;\n } catch (error) {\n if (isSchedulesUnavailable(error)) return false;\n throw error;\n }\n}\n\n/** `undefined` when the cron parses; otherwise the validator's message. */\nexport function invalidCronMessage(cron: string, timezone?: string): string | undefined {\n try {\n validateCron(cron, timezone);\n return undefined;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n }\n}\n\nfunction isWorkflowSchedule(schedule: AnySchedule | null): schedule is WorkflowSchedule {\n return schedule !== null && schedule.agentId === undefined;\n}\n\nfunction toView(schedule: WorkflowSchedule | null): EnvironmentBuildSchedule {\n if (!schedule) return { enabled: false, cron: null, timezone: null };\n return { enabled: schedule.status === 'active', cron: schedule.cron ?? null, timezone: schedule.timezone ?? null };\n}\n\n/** The project's build schedule as the environment reports it. */\nexport async function readSchedule(schedules: ScheduleService, projectId: string): Promise<EnvironmentBuildSchedule> {\n const schedule = await schedules.get(scheduleIdFor(projectId));\n return toView(isWorkflowSchedule(schedule) ? schedule : null);\n}\n\n/**\n * Create, update, pause or resume the project's schedule so it matches\n * `input`. Disabling a project that never had a schedule creates nothing.\n */\nexport async function ensureSchedule(\n schedules: ScheduleService,\n projectId: string,\n input: { enabled: boolean; cron: string; timezone?: string },\n): Promise<EnvironmentBuildSchedule> {\n const id = scheduleIdFor(projectId);\n const existing = await schedules.get(id);\n const current = isWorkflowSchedule(existing) ? existing : null;\n if (!current) {\n if (!input.enabled) return toView(null);\n const created = await schedules.create({\n id,\n workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID,\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n inputData: { projectId, trigger: 'schedule' },\n resourceId: projectId,\n });\n return toView(created);\n }\n const timingChanged = current.cron !== input.cron || (current.timezone ?? undefined) !== input.timezone;\n let next: AnySchedule = current;\n if (timingChanged) {\n next = await schedules.update(current.id, {\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n });\n }\n if (input.enabled && next.status === 'paused') next = await schedules.resume(current.id);\n if (!input.enabled && next.status === 'active') next = await schedules.pause(current.id);\n return toView(isWorkflowSchedule(next) ? next : null);\n}\n"],"mappings":";;;AAWA,MAAa,iCAAiC;;;;;;;AAQ9C,SAAgB,cAAc,WAA2B;CACvD,OAAO,sCAAsC;AAC/C;AAUA,SAAS,uBAAuB,OAAyB;CACvD,OACE,OAAO,UAAU,YAAY,UAAU,QAAS,MAA2B,OAAA;AAE/E;;;;;AAMA,eAAsB,wBAAwB,WAA8C;CAC1F,IAAI;EACF,MAAM,UAAU,KAAK,EAAE,YAAY,8BAA8B,CAAC;EAClE,OAAO;CACT,SAAS,OAAO;EACd,IAAI,uBAAuB,KAAK,GAAG,OAAO;EAC1C,MAAM;CACR;AACF;;AAGA,SAAgB,mBAAmB,MAAc,UAAuC;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