@mastra/factory 0.11.1 → 0.12.0-alpha.1

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 (157) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/factory.d.ts +2 -22
  3. package/dist/factory.d.ts.map +1 -1
  4. package/dist/factory.js +21 -59
  5. package/dist/factory.js.map +1 -1
  6. package/dist/feed-events.d.ts +13 -0
  7. package/dist/feed-events.d.ts.map +1 -0
  8. package/dist/feed-events.js +25 -0
  9. package/dist/feed-events.js.map +1 -0
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/integrations/base.d.ts +5 -13
  13. package/dist/integrations/base.d.ts.map +1 -1
  14. package/dist/integrations/github/config.d.ts +4 -4
  15. package/dist/integrations/github/config.d.ts.map +1 -1
  16. package/dist/integrations/github/config.js +3 -3
  17. package/dist/integrations/github/config.js.map +1 -1
  18. package/dist/integrations/github/integration.d.ts.map +1 -1
  19. package/dist/integrations/github/integration.js +2 -4
  20. package/dist/integrations/github/integration.js.map +1 -1
  21. package/dist/integrations/github/reconcile-worker.d.ts +0 -5
  22. package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
  23. package/dist/integrations/github/reconcile-worker.js +1 -8
  24. package/dist/integrations/github/reconcile-worker.js.map +1 -1
  25. package/dist/integrations/github/routes.d.ts +6 -5
  26. package/dist/integrations/github/routes.d.ts.map +1 -1
  27. package/dist/integrations/github/routes.js +36 -263
  28. package/dist/integrations/github/routes.js.map +1 -1
  29. package/dist/integrations/github/sandbox-release.d.ts +17 -47
  30. package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
  31. package/dist/integrations/github/sandbox-release.js +24 -103
  32. package/dist/integrations/github/sandbox-release.js.map +1 -1
  33. package/dist/integrations/github/sandbox.d.ts +25 -139
  34. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  35. package/dist/integrations/github/sandbox.js +24 -212
  36. package/dist/integrations/github/sandbox.js.map +1 -1
  37. package/dist/integrations/github/webhook.d.ts.map +1 -1
  38. package/dist/integrations/github/webhook.js +1 -2
  39. package/dist/integrations/github/webhook.js.map +1 -1
  40. package/dist/integrations/issue-reconcile-worker.js +1 -1
  41. package/dist/integrations/platform/github/event-worker.d.ts +0 -2
  42. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  43. package/dist/integrations/platform/github/event-worker.js +1 -8
  44. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  45. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  46. package/dist/integrations/platform/github/integration.js +5 -7
  47. package/dist/integrations/platform/github/integration.js.map +1 -1
  48. package/dist/integrations/platform/linear/event-worker.js +1 -1
  49. package/dist/routes/attention-activity.d.ts +24 -0
  50. package/dist/routes/attention-activity.d.ts.map +1 -0
  51. package/dist/routes/attention-activity.js +143 -0
  52. package/dist/routes/attention-activity.js.map +1 -0
  53. package/dist/routes/attention-providers.d.ts +31 -1
  54. package/dist/routes/attention-providers.d.ts.map +1 -1
  55. package/dist/routes/attention-providers.js +4 -4
  56. package/dist/routes/attention-providers.js.map +1 -1
  57. package/dist/routes/attention.d.ts.map +1 -1
  58. package/dist/routes/attention.js +39 -11
  59. package/dist/routes/attention.js.map +1 -1
  60. package/dist/routes/config.d.ts.map +1 -1
  61. package/dist/routes/config.js +3 -1
  62. package/dist/routes/config.js.map +1 -1
  63. package/dist/routes/fs.d.ts +4 -6
  64. package/dist/routes/fs.d.ts.map +1 -1
  65. package/dist/routes/fs.js +28 -34
  66. package/dist/routes/fs.js.map +1 -1
  67. package/dist/routes/skills.d.ts.map +1 -1
  68. package/dist/routes/skills.js +6 -3
  69. package/dist/routes/skills.js.map +1 -1
  70. package/dist/routes/surface.d.ts +4 -9
  71. package/dist/routes/surface.d.ts.map +1 -1
  72. package/dist/routes/surface.js +3 -5
  73. package/dist/routes/surface.js.map +1 -1
  74. package/dist/sandbox/materialization.d.ts +36 -0
  75. package/dist/sandbox/materialization.d.ts.map +1 -0
  76. package/dist/sandbox/materialization.js +18 -0
  77. package/dist/sandbox/materialization.js.map +1 -0
  78. package/dist/sandbox/session-retirement.d.ts +8 -6
  79. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  80. package/dist/sandbox/session-retirement.js +28 -123
  81. package/dist/sandbox/session-retirement.js.map +1 -1
  82. package/dist/sandbox/session-sandbox.d.ts +117 -0
  83. package/dist/sandbox/session-sandbox.d.ts.map +1 -0
  84. package/dist/sandbox/session-sandbox.js +132 -0
  85. package/dist/sandbox/session-sandbox.js.map +1 -0
  86. package/dist/sandbox/workdir.d.ts +30 -0
  87. package/dist/sandbox/workdir.d.ts.map +1 -0
  88. package/dist/sandbox/workdir.js +48 -0
  89. package/dist/sandbox/workdir.js.map +1 -0
  90. package/dist/session/filesystem-capture.d.ts +2 -1
  91. package/dist/session/filesystem-capture.d.ts.map +1 -1
  92. package/dist/session/filesystem-capture.js +45 -4
  93. package/dist/session/filesystem-capture.js.map +1 -1
  94. package/dist/session/first-exec-capture.d.ts +1 -0
  95. package/dist/session/first-exec-capture.d.ts.map +1 -1
  96. package/dist/session/first-exec-capture.js +1 -1
  97. package/dist/session/first-exec-capture.js.map +1 -1
  98. package/dist/storage/domains/comments/activity.d.ts +40 -0
  99. package/dist/storage/domains/comments/activity.d.ts.map +1 -0
  100. package/dist/storage/domains/comments/activity.js +94 -0
  101. package/dist/storage/domains/comments/activity.js.map +1 -0
  102. package/dist/storage/domains/comments/base.d.ts +13 -1
  103. package/dist/storage/domains/comments/base.d.ts.map +1 -1
  104. package/dist/storage/domains/comments/base.js +41 -3
  105. package/dist/storage/domains/comments/base.js.map +1 -1
  106. package/dist/storage/domains/comments/domain.d.ts +4 -1
  107. package/dist/storage/domains/comments/domain.d.ts.map +1 -1
  108. package/dist/storage/domains/comments/domain.js +17 -5
  109. package/dist/storage/domains/comments/domain.js.map +1 -1
  110. package/dist/storage/domains/comments/parse.d.ts +1 -0
  111. package/dist/storage/domains/comments/parse.d.ts.map +1 -1
  112. package/dist/storage/domains/comments/parse.js +2 -2
  113. package/dist/storage/domains/comments/parse.js.map +1 -1
  114. package/dist/storage/domains/comments/routes.d.ts +2 -0
  115. package/dist/storage/domains/comments/routes.d.ts.map +1 -1
  116. package/dist/storage/domains/comments/routes.js +49 -3
  117. package/dist/storage/domains/comments/routes.js.map +1 -1
  118. package/dist/storage/domains/comments/schema.d.ts +1 -0
  119. package/dist/storage/domains/comments/schema.d.ts.map +1 -1
  120. package/dist/storage/domains/comments/schema.js +45 -1
  121. package/dist/storage/domains/comments/schema.js.map +1 -1
  122. package/dist/storage/domains/integrations/base.d.ts +1 -1
  123. package/dist/storage/domains/integrations/base.js +1 -1
  124. package/dist/storage/domains/integrations/base.js.map +1 -1
  125. package/dist/storage/domains/source-control/base.d.ts +0 -144
  126. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  127. package/dist/storage/domains/source-control/base.js +3 -290
  128. package/dist/storage/domains/source-control/base.js.map +1 -1
  129. package/dist/storage/domains/source-control/inmemory.d.ts +1 -63
  130. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  131. package/dist/storage/domains/source-control/inmemory.js +0 -89
  132. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  133. package/dist/storage/domains/work-items/base.d.ts +14 -1
  134. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  135. package/dist/storage/domains/work-items/base.js +60 -11
  136. package/dist/storage/domains/work-items/base.js.map +1 -1
  137. package/dist/workspace.d.ts +5 -37
  138. package/dist/workspace.d.ts.map +1 -1
  139. package/dist/workspace.js +107 -245
  140. package/dist/workspace.js.map +1 -1
  141. package/package.json +6 -6
  142. package/dist/sandbox/base-checkpoint-triggers.d.ts +0 -77
  143. package/dist/sandbox/base-checkpoint-triggers.d.ts.map +0 -1
  144. package/dist/sandbox/base-checkpoint-triggers.js +0 -137
  145. package/dist/sandbox/base-checkpoint-triggers.js.map +0 -1
  146. package/dist/sandbox/base-checkpoint.d.ts +0 -59
  147. package/dist/sandbox/base-checkpoint.d.ts.map +0 -1
  148. package/dist/sandbox/base-checkpoint.js +0 -145
  149. package/dist/sandbox/base-checkpoint.js.map +0 -1
  150. package/dist/sandbox/fleet.d.ts +0 -258
  151. package/dist/sandbox/fleet.d.ts.map +0 -1
  152. package/dist/sandbox/fleet.js +0 -356
  153. package/dist/sandbox/fleet.js.map +0 -1
  154. package/dist/sandbox/reattach.d.ts +0 -3
  155. package/dist/sandbox/reattach.d.ts.map +0 -1
  156. package/dist/sandbox/reattach.js +0 -16
  157. package/dist/sandbox/reattach.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # @mastra/factory
2
2
 
3
+ ## 0.12.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Attention now rides the project feed stream: an automation failure, a proposal parked for approval, an approval, a dismissal, a retry, a supersede or a work-item deletion reaches every open page as it happens, and the attention list falls back to polling only while its stream is down. ([#22604](https://github.com/mastra-ai/mastra/pull/22604))
8
+
9
+ Marking your own list read stays local — a read receipt changes nobody else's view, so it is not broadcast.
10
+
11
+ - Commenting on a work item now notifies everyone already in that discussion, not just the people it names. Participants land in a separate `activity` tier of `GET /web/factory/projects/:id/attention`, counted apart under `activityUnreadCount` so the notification badge and sound stay reserved for mentions and failures. The attention inbox also refreshes while open now: comment-driven entries arrive over the feed stream, and the list polls every 5s for the rest. The sidebar popover asks the server for the badge tier (`?tier=badge`), so busy discussions can no longer crowd mentions and failures out of its five slots. ([#22571](https://github.com/mastra-ai/mastra/pull/22571))
12
+
13
+ - Work item comment feeds now update live instead of on a five-second poll: while a browser holds its feed stream, a new comment shows up the moment it lands, and a browser whose stream dropped falls back to the old poll until it reconnects. ([#22570](https://github.com/mastra-ai/mastra/pull/22570))
14
+
15
+ Delivery rides the factory's `pubsub`, so reaching browsers across replicas takes a shared broker — the in-process default only serves readers held by the replica that took the write:
16
+
17
+ ```ts
18
+ import { MastraFactory } from '@mastra/factory';
19
+ import { RedisStreamsPubSub } from '@mastra/redis-streams';
20
+
21
+ export const factory = new MastraFactory({
22
+ pubsub: new RedisStreamsPubSub({ url: process.env.REDIS_URL }),
23
+ });
24
+ ```
25
+
26
+ ### Patch Changes
27
+
28
+ - The completion chime is lower and longer. It swells into a soft tail that rings out over about two and a half seconds, instead of the short ding that stopped dead almost as soon as it started. ([#22566](https://github.com/mastra-ai/mastra/pull/22566))
29
+
30
+ It is also much louder than the chime it replaces. If you leave the completion sound on, check your volume after this release.
31
+
32
+ ## 0.12.0-alpha.0
33
+
34
+ ### Minor Changes
35
+
36
+ - **BREAKING: `sandbox` is now a callback that constructs the session's sandbox** ([#22065](https://github.com/mastra-ai/mastra/pull/22065))
37
+
38
+ ```ts
39
+ // Before — no longer accepted
40
+ sandbox: { machine: new RailwaySandbox({ apiToken }), workdir: '/workspace', maxSandboxes: 4 }
41
+
42
+ // After
43
+ sandbox: ctx => new E2BSandbox({ id: ctx.sessionId })
44
+ ```
45
+
46
+ A factory still configured with the old options object fails at `prepare()` with a message showing the replacement: `machine` becomes the provider instance you construct inside the callback, `workdir` is gone (remote providers clone into the VM's home directory, local providers use their own `workingDirectory`), and `maxSandboxes` is gone with the fleet. Omit `sandbox` entirely to run without sandboxes. `ctx.getRepositoryAccess` resolves the session repository's clone URL plus a fresh short-lived credential (`undefined` when the session has no repository), so providers can authenticate work such as private-repo template builds.
47
+
48
+ Session sandboxes now boot lazily at the first real command instead of being provisioned up front. The sandbox fleet (pooling, budgets, reattach/revival, base checkpoints) is deleted, and the `/ensure` endpoint and the session UI's "preparing sandbox" step go with it — opening a thread provisions nothing. To check whether a sandbox is configured, read `sandboxEnabled` from `GET /web/github/status`.
49
+
50
+ A failing setup command no longer wedges the session. The first failure surfaces loudly in the tool result that triggered it, then later starts skip the known-bad command — the clone and branch checkout still run, so the agent can repair or rerun setup itself. Infrastructure failures (clone, checkout, transport) keep failing hard and retry in full.
51
+
52
+ Existing databases keep the fleet-era tables and columns as untouched orphans; dropping them is a manual operation.
53
+
54
+ ### Patch Changes
55
+
56
+ - Hosted sessions no longer leak the host process's environment into the system prompt. The dynamic instructions builder drops its `process.cwd()` fallback: a session without a `projectPath` gets no working directory, no host git-branch probe, and loads no instruction files at all (project locations would resolve against the server's cwd and global locations against the server's homedir). Factory additionally blanks the SDK's default project identity seed (`projectPath`/`projectName`/`gitBranch` from the host's own checkout) so chat-only sessions show "(no workspace attached)" instead of the server's repo and branch; repo-backed sessions keep getting their real session workdir pinned by workspace resolution. ([#22065](https://github.com/mastra-ai/mastra/pull/22065))
57
+
58
+ - Updated dependencies [[`3910c77`](https://github.com/mastra-ai/mastra/commit/3910c77413a3058ab270c6dbc74a59bc3cdf67ea), [`c80547a`](https://github.com/mastra-ai/mastra/commit/c80547aa7ef33adbb08435ff847e77fa404bafbf), [`c80547a`](https://github.com/mastra-ai/mastra/commit/c80547aa7ef33adbb08435ff847e77fa404bafbf), [`c80547a`](https://github.com/mastra-ai/mastra/commit/c80547aa7ef33adbb08435ff847e77fa404bafbf)]:
59
+ - @mastra/core@1.63.3-alpha.0
60
+ - @mastra/code-sdk@1.6.0-alpha.0
61
+
3
62
  ## 0.11.1
4
63
 
5
64
  ### Patch Changes
package/dist/factory.d.ts CHANGED
@@ -22,9 +22,9 @@ import type { Mastra } from '@mastra/core/mastra';
22
22
  import type { IMastraAuthProvider } from '@mastra/core/server';
23
23
  import type { FactoryStorage } from '@mastra/core/storage';
24
24
  import type { MastraVector } from '@mastra/core/vector';
25
- import type { WorkspaceSandbox } from '@mastra/core/workspace';
26
25
  import type { FactoryIntegration } from './integrations/base.js';
27
26
  import type { FactoryRules } from './rules/types.js';
27
+ import type { MastraFactorySandboxConfig } from './sandbox/session-sandbox.js';
28
28
  import type { FactorySecretEncryption } from './secret-encryption.js';
29
29
  /** Constructor args for the `new Mastra(...)` literal in the deploy entry. */
30
30
  export type MastraArgs = NonNullable<ConstructorParameters<typeof Mastra>[0]>;
@@ -121,27 +121,7 @@ export interface MastraFactoryConfig {
121
121
  githubAppSlug?: string;
122
122
  };
123
123
  }
124
- export interface MastraFactorySandboxConfig {
125
- /**
126
- * Template machine — `RailwaySandbox` (`@mastra/railway`), core
127
- * `LocalSandbox` (`@mastra/core/workspace`), or any `WorkspaceSandbox` that
128
- * implements `clone()`. Each project-repository execution environment gets
129
- * its own sandbox cloned from this machine; the machine itself is never
130
- * started. `prepare()` fails fast when the instance lacks `clone()`.
131
- */
132
- machine: WorkspaceSandbox;
133
- /**
134
- * In-sandbox base directory repos check out under (nested `owner/name` per
135
- * repo). Default: the machine's own `workingDirectory` when it exposes one
136
- * (core `LocalSandbox` does), else `/workspace`.
137
- */
138
- workdir?: string;
139
- /**
140
- * Per-replica cap on concurrently provisioned sandboxes. `0`/omitted means
141
- * unlimited. A lightweight per-process budget, not a cross-replica scheduler.
142
- */
143
- maxSandboxes?: number;
144
- }
124
+ export type { MastraFactorySandboxConfig } from './sandbox/session-sandbox.js';
145
125
  /**
146
126
  * Per-process cap on concurrent background Factory dispatches. Omitted means
147
127
  * the dispatcher default; this is a local replica budget, not a global queue
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAS/D,OAAO,KAAK,EAAE,kBAAkB,EAAgD,MAAM,wBAAwB,CAAC;AAwB/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAS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,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,mDAAmD;IACnD,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,YAAY,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE/E;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAyED,qBAAa,aAAa;;gBAOZ,MAAM,EAAE,mBAAmB;IAWvC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAmrBpC;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAY/B,iFAAiF;IAC3E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
package/dist/factory.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import { timedPhase } from "./timing.js";
2
2
  import { buildAuthRoutes, createFactoryAuthGate, createFactoryRouteAuth, getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from "./auth.js";
3
+ import { touchFeed } from "./feed-events.js";
3
4
  import { recordFactoryPullRequestProvenance, resolveFactoryPullRequestParentWorkItemId } from "./integrations/github/provenance.js";
4
- import { SandboxFleet } from "./sandbox/fleet.js";
5
- import { BaseCheckpointBuilder } from "./sandbox/base-checkpoint.js";
6
- import { createBaseCheckpointTriggers } from "./sandbox/base-checkpoint-triggers.js";
7
5
  import { assertFactoryRules } from "./rules/validation.js";
8
6
  import { WorkItemsStorage } from "./storage/domains/work-items/base.js";
9
7
  import { PlatformGithubIntegration } from "./integrations/platform/github/integration.js";
@@ -16,6 +14,7 @@ import { FactoryFeedReader } from "./storage/domains/comments/feed-context.js";
16
14
  import { FactoryTransitionService } from "./rules/transition-service.js";
17
15
  import { SourceControlStorage } from "./storage/domains/source-control/base.js";
18
16
  import { hydrateSessionModelPack } from "./session/model-pack-hydration.js";
17
+ import { observeSessionFirstExec } from "./session/first-exec-capture.js";
19
18
  import { observeSessionFilesystem } from "./session/filesystem-capture.js";
20
19
  import { createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
21
20
  import { ModelCredentialsStorage } from "./storage/domains/credentials/base.js";
@@ -28,11 +27,9 @@ import { FactoryDecisionDispatcher } from "./rules/dispatcher.js";
28
27
  import { FactoryPhaseStateProcessor } from "./rules/processor.js";
29
28
  import { createTerminalStageCleanup } from "./rules/terminal-cleanup.js";
30
29
  import { createFactoryTransitionTools } from "./rules/tools.js";
31
- import { registerSandboxReattach } from "./sandbox/reattach.js";
32
30
  import { SessionRetirementCoordinator } from "./sandbox/session-retirement.js";
33
31
  import { handleServerError } from "./server-error.js";
34
32
  import { observeSessionCheckpoint } from "./session/checkpoint-capture.js";
35
- import { observeSessionFirstExec } from "./session/first-exec-capture.js";
36
33
  import { observeSessionFirstMessage } from "./session/first-message-capture.js";
37
34
  import { observeSessionThreadTitle } from "./session/thread-title-mirror.js";
38
35
  import { createSpaStaticMiddleware, resolveUiDistDir } from "./spa-static.js";
@@ -53,6 +50,7 @@ import { hasAuthInit, isUserProvider } from "@mastra/core/server";
53
50
  import { MastraAuthStudio } from "@mastra/auth-studio";
54
51
  import { prepareAgentControllerMount } from "@mastra/code-sdk";
55
52
  import { AgentControllerChannels } from "@mastra/core/channels";
53
+ import { EventEmitterPubSub } from "@mastra/core/events";
56
54
  //#region src/factory.ts
57
55
  /**
58
56
  * `MastraFactory` — the single entry point to the whole Mastra Software Factory.
@@ -78,20 +76,6 @@ function hasPlatformCredentials() {
78
76
  return Boolean(process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim());
79
77
  }
80
78
  /**
81
- * The template sandbox's own working directory, when it exposes one as a
82
- * string (core `LocalSandbox` does; remote providers generally don't).
83
- * Used as the default checkout base so a local template rooted at a host
84
- * directory checks repos out under that same root.
85
- */
86
- function templateWorkingDirectory(sandbox) {
87
- const wd = sandbox.workingDirectory;
88
- return typeof wd === "string" && wd.length > 0 ? wd : void 0;
89
- }
90
- function resolveSandboxWorkdirBase(machine, configuredWorkdir) {
91
- const machineWorkdir = templateWorkingDirectory(machine);
92
- return ((configuredWorkdir === "/workspace" && machineWorkdir ? machineWorkdir : configuredWorkdir ?? machineWorkdir) ?? "/workspace").replace(/\/+$/, "");
93
- }
94
- /**
95
79
  * Default auth provider — `MastraAuthStudio`, which proxies identity to the
96
80
  * shared Mastra platform API. `MastraAuthStudio` resolves `MASTRA_SHARED_API_URL`,
97
81
  * `MASTRA_ORGANIZATION_ID`, and `MASTRA_COOKIE_DOMAIN` from env on its own —
@@ -164,6 +148,7 @@ var MastraFactory = class {
164
148
  const storage = this.#config.storage;
165
149
  const vector = this.#config.vector;
166
150
  const pubsub = this.#config.pubsub;
151
+ const eventBus = pubsub ?? new EventEmitterPubSub();
167
152
  const configuredAuth = this.#config.auth;
168
153
  const auth = configuredAuth === null ? void 0 : configuredAuth ?? buildDefaultStudioAuth(publicOrigin);
169
154
  if (auth && !this.#config.secretEncryption) console.warn("[factory] auth is enabled but 'secretEncryption' is not configured. Persisted model credentials, custom-provider API keys, and integration secrets will be stored as plaintext. Provide 'secretEncryption' (e.g. via FACTORY_CREDENTIAL_ENCRYPTION_KEY) to encrypt them at rest.");
@@ -184,6 +169,7 @@ var MastraFactory = class {
184
169
  const intakeStorage = storage.registerDomain(new IntakeStorage());
185
170
  const auditStorage = storage.registerDomain(new AuditStorage());
186
171
  const workItemsStorage = storage.registerDomain(new WorkItemsStorage());
172
+ workItemsStorage.onAttentionChanged((scope) => touchFeed(eventBus, scope));
187
173
  const modelCredentialsStorage = storage.registerDomain(new ModelCredentialsStorage(secretEncryption));
188
174
  const modelPacksStorage = storage.registerDomain(new ModelPacksStorage());
189
175
  const memorySettingsStorage = storage.registerDomain(new MemorySettingsStorage());
@@ -208,7 +194,6 @@ var MastraFactory = class {
208
194
  channelIdentity: channelIdentityStorage,
209
195
  comments: workItemCommentsStorage
210
196
  };
211
- let baseCheckpoints;
212
197
  const auditDomain = new AuditDomain({
213
198
  auth: routeAuth,
214
199
  audit: auditStorage,
@@ -229,17 +214,14 @@ var MastraFactory = class {
229
214
  workItems: workItemsStorage,
230
215
  projects: factoryProjectsStorage,
231
216
  channelIdentity: channelIdentityStorage,
232
- audit: auditDomain
217
+ audit: auditDomain,
218
+ pubsub: eventBus
233
219
  });
234
220
  const sandboxConfig = this.#config.sandbox;
235
- const machine = sandboxConfig?.machine;
236
- if (machine && typeof machine.clone !== "function") throw new Error(`MastraFactory: the configured sandbox machine (provider '${machine.provider}') does not implement clone(). Project repositories each get their own sandbox cloned from the configured machine. Pass a machine that implements clone() — e.g. RailwaySandbox (@mastra/railway) or LocalSandbox (@mastra/core/workspace)or omit 'sandbox' to disable sandboxes.`);
237
- const fleet = new SandboxFleet(machine ? {
238
- machine,
239
- workdirBase: resolveSandboxWorkdirBase(machine, sandboxConfig?.workdir),
240
- maxSandboxes: sandboxConfig?.maxSandboxes
241
- } : void 0);
242
- registerSandboxReattach(fleet);
221
+ if (sandboxConfig !== void 0 && typeof sandboxConfig !== "function") {
222
+ if (typeof sandboxConfig === "object" && sandboxConfig !== null) throw new Error("MastraFactory: 'sandbox' is now a callback, not an options object. It receives a FactorySandboxContext and returns a MastraSandbox, so the host chooses the provider per session:\n sandbox: ctx => new E2BSandbox({ id: ctx.sessionId })\nThe old options map three ways: 'machine' becomes the provider instance you construct inside the callback (one per session instead of one cloned template); 'workdir' is gone remote providers clone into the VM's home directory and local providers check out under their own workingDirectory; 'maxSandboxes' is gone with the sandbox fleet there is one sandbox per session and no pool to cap. Omit 'sandbox' entirely to disable sandboxes.");
223
+ throw new Error(`MastraFactory: 'sandbox' must be a function constructing a MastraSandbox from a FactorySandboxContext.`);
224
+ }
243
225
  const workspaceRegistry = new FactoryWorkspaceRegistry();
244
226
  const stateSigner = createStateSigner(this.#config.stateSecret);
245
227
  if (auth && hasAuthInit(auth)) await timedPhase("prepare.auth.init", () => auth.init({
@@ -279,26 +261,8 @@ var MastraFactory = class {
279
261
  const factoryReady = storage.isDomainReady("projects") && storage.isDomainReady("work-items");
280
262
  const knowledgeEnabled = process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === "1";
281
263
  const githubIntegration = integrations.find((integration) => integration.id === "github");
282
- if (githubIntegration && fleet.enabled && storage.isDomainReady("source-control")) {
283
- const checkpointLogger = { warn: (message) => console.warn(`[factory] ${message}`) };
284
- baseCheckpoints = createBaseCheckpointTriggers({
285
- builder: new BaseCheckpointBuilder({
286
- fleet,
287
- logger: checkpointLogger
288
- }),
289
- fleet,
290
- github: {
291
- sourceControlStorage: sourceControlStorage.forIntegration("github"),
292
- ...githubIntegration.versionControl ? { versionControl: githubIntegration.versionControl } : {}
293
- },
294
- logger: checkpointLogger
295
- });
296
- }
297
264
  const workItemsReady = storage.isDomainReady("work-items");
298
- const sessionRetirement = machine && storage.isDomainReady("source-control") ? new SessionRetirementCoordinator({
299
- fleet,
300
- invalidateSession: (sessionId) => workspaceRegistry.invalidateSession(sessionId)
301
- }) : void 0;
265
+ const sessionRetirement = sandboxConfig && storage.isDomainReady("source-control") ? new SessionRetirementCoordinator({ invalidateSession: (sessionId) => workspaceRegistry.invalidateSession(sessionId) }) : void 0;
302
266
  const retireTerminalSessions = sessionRetirement && githubIntegration && workItemsReady ? async ({ orgId, workItemId }) => sessionRetirement.retireWorkItemSessions({
303
267
  workItems: workItemsStorage,
304
268
  sourceControl: sourceControlStorage.forIntegration(githubIntegration.id),
@@ -323,8 +287,7 @@ var MastraFactory = class {
323
287
  sourceControl: sourceControlStorage,
324
288
  versionControlIntegrationIds: integrations.filter((integration) => integration.versionControl).map((integration) => integration.id),
325
289
  ...sessionRetirement ? { sessionRetirement } : {},
326
- ...workItemsReady ? { workItems: workItemsStorage } : {},
327
- onProjectRepositoryLinked: (args) => baseCheckpoints?.onProjectRepositoryLinked(args)
290
+ ...workItemsReady ? { workItems: workItemsStorage } : {}
328
291
  });
329
292
  const factoryProcessor = workItemsReady ? new FactoryPhaseStateProcessor({
330
293
  rules,
@@ -350,17 +313,19 @@ var MastraFactory = class {
350
313
  const prepared = await timedPhase("prepare.controllerMount", () => prepareAgentControllerMount({
351
314
  controllerId: CONTROLLER_ID,
352
315
  workspace: createWorkspaceFactory({
353
- ...this.#config.sandbox ? { sandbox: this.#config.sandbox } : {},
316
+ ...sandboxConfig ? { sandbox: sandboxConfig } : {},
354
317
  ...githubIntegration ? { github: githubIntegration } : {},
355
318
  ...workItemsStorage ? { workItems: workItemsStorage } : {},
356
- fleet,
357
319
  workspaceRegistry
358
320
  }),
359
321
  disableGithubSignals: true,
360
322
  disableSettingsOmSeed: true,
361
323
  initialState: {
362
324
  skipGlobalInstructions: true,
363
- factoryOrgUnresolved: true
325
+ factoryOrgUnresolved: true,
326
+ projectPath: "",
327
+ projectName: "",
328
+ gitBranch: ""
364
329
  },
365
330
  storage: storage.getMastraStorage(),
366
331
  ...mastraStorageBackend ? { storageBackend: mastraStorageBackend } : {},
@@ -430,8 +395,7 @@ var MastraFactory = class {
430
395
  audit: auditDomain,
431
396
  publicOrigin,
432
397
  stateSigner,
433
- fleet,
434
- ...baseCheckpoints ? { baseCheckpoints } : {},
398
+ sandbox: sandboxConfig,
435
399
  sessionRetirement,
436
400
  factoryStorage: storage,
437
401
  integrationStorage,
@@ -546,8 +510,7 @@ var MastraFactory = class {
546
510
  publicOrigin,
547
511
  auth: routeAuth,
548
512
  stateSigner,
549
- fleet,
550
- ...baseCheckpoints ? { baseCheckpoints } : {},
513
+ sandbox: sandboxConfig,
551
514
  factoryStorage: storage,
552
515
  integrationStorage,
553
516
  sourceControlStorage,
@@ -561,8 +524,7 @@ var MastraFactory = class {
561
524
  publicOrigin,
562
525
  auth: routeAuth,
563
526
  stateSigner,
564
- fleet,
565
- ...baseCheckpoints ? { baseCheckpoints } : {},
527
+ sandbox: sandboxConfig,
566
528
  factoryStorage: storage,
567
529
  integrationStorage,
568
530
  sourceControlStorage,