@mastra/factory 0.25.0-alpha.8 → 0.26.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/factory.d.ts +1 -1
  2. package/dist/factory.d.ts.map +1 -1
  3. package/dist/factory.js +27 -3
  4. package/dist/factory.js.map +1 -1
  5. package/dist/integrations/slack/integration.d.ts +7 -8
  6. package/dist/integrations/slack/integration.d.ts.map +1 -1
  7. package/dist/integrations/slack/integration.js +11 -3
  8. package/dist/integrations/slack/integration.js.map +1 -1
  9. package/dist/integrations/slack/run-error-card.d.ts.map +1 -1
  10. package/dist/integrations/slack/run-error-card.js +25 -8
  11. package/dist/integrations/slack/run-error-card.js.map +1 -1
  12. package/dist/integrations/slack/slack.d.ts +3 -1
  13. package/dist/integrations/slack/slack.d.ts.map +1 -1
  14. package/dist/integrations/slack/slack.js.map +1 -1
  15. package/dist/routes/config.d.ts +4 -1
  16. package/dist/routes/config.d.ts.map +1 -1
  17. package/dist/routes/config.js +153 -56
  18. package/dist/routes/config.js.map +1 -1
  19. package/dist/routes/provider-credentials.d.ts +6 -1
  20. package/dist/routes/provider-credentials.d.ts.map +1 -1
  21. package/dist/routes/provider-credentials.js +2 -2
  22. package/dist/routes/provider-credentials.js.map +1 -1
  23. package/dist/run-error.d.ts +1 -1
  24. package/dist/run-error.d.ts.map +1 -1
  25. package/dist/run-error.js +16 -11
  26. package/dist/run-error.js.map +1 -1
  27. package/dist/session/reply-credential-processor.d.ts +8 -0
  28. package/dist/session/reply-credential-processor.d.ts.map +1 -1
  29. package/dist/session/reply-credential-processor.js +20 -11
  30. package/dist/session/reply-credential-processor.js.map +1 -1
  31. package/dist/storage/domains/audit/domain.d.ts.map +1 -1
  32. package/dist/storage/domains/audit/domain.js +10 -3
  33. package/dist/storage/domains/audit/domain.js.map +1 -1
  34. package/package.json +15 -15
package/dist/factory.d.ts CHANGED
@@ -232,7 +232,7 @@ export declare class MastraFactory {
232
232
  * has run `new Mastra(prepare()'s args)`.
233
233
  */
234
234
  finalize(): Promise<void>;
235
- /** Stop Factory-owned background dispatch before the host process shuts down. */
235
+ /** Stop Factory-owned background work and channel transports before the host process shuts down. */
236
236
  shutdown(): Promise<void>;
237
237
  }
238
238
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAiC,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,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;AAExD,OAAO,KAAK,EAAkB,yBAAyB,EAAoB,MAAM,wBAAwB,CAAC;AAY1G,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKvE,OAAO,KAAK,EAAE,kBAAkB,EAAgD,MAAM,wBAAwB,CAAC;AAE/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAclF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAgCxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AA0DtE,OAAO,KAAK,EAAE,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AAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuGD,qBAAa,aAAa;;gBAmBZ,MAAM,EAAE,mBAAmB;IAsBvC;;;;OAIG;IACH,IAAI,kBAAkB,IAAI,yBAAyB,GAAG,SAAS,CAI9D;IAED;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAiiDpC;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB/B,oGAAoG;IAC9F,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAuBhC"}
package/dist/factory.js CHANGED
@@ -210,6 +210,8 @@ var MastraFactory = class {
210
210
  #dispatcher;
211
211
  #startCoordinator;
212
212
  #factoryProcessor;
213
+ #channelShutdowns = [];
214
+ #shutdownPromise;
213
215
  /** Environment builds through the sandbox's `builds`; undefined when the sandbox has none. */
214
216
  #environmentBuilds;
215
217
  /** The background session resource migration; resolves `true` when it moved run bindings. */
@@ -1259,6 +1261,7 @@ var MastraFactory = class {
1259
1261
  this.#factoryProcessor = factoryProcessor;
1260
1262
  const channelRegistrations = integrationRegistrations.filter(({ integration, ready }) => ready && integration.channels);
1261
1263
  if (channelRegistrations.length > 1) throw new Error(`MastraFactory: integrations [${channelRegistrations.map(({ integration }) => integration.id).join(", ")}] all provide channels, but only one may. Remove all but one.`);
1264
+ this.#channelShutdowns = [];
1262
1265
  for (const { integration } of channelRegistrations) {
1263
1266
  const context = buildIntegrationContext({
1264
1267
  controller: prepared.base.controller,
@@ -1277,7 +1280,12 @@ var MastraFactory = class {
1277
1280
  feed: commentsDomain,
1278
1281
  ...githubIntegration ? { sourceControlOwnerId: "github" } : {}
1279
1282
  }, integration.id);
1280
- prepared.base.controller.setChannels(new AgentControllerChannels(integration.channels(context)));
1283
+ const channels = new AgentControllerChannels(integration.channels(context));
1284
+ prepared.base.controller.setChannels(channels);
1285
+ for (const adapter of Object.values(channels.adapters)) {
1286
+ const disconnect = adapter.disconnect;
1287
+ if (disconnect) this.#channelShutdowns.push(() => disconnect.call(adapter));
1288
+ }
1281
1289
  }
1282
1290
  for (const { integration } of integrationRegistrations.filter(({ integration, ready }) => ready && integration.feedPublisher)) {
1283
1291
  const context = buildIntegrationContext({
@@ -1337,9 +1345,25 @@ var MastraFactory = class {
1337
1345
  this.#sessionResourceMigration?.then((movedRunBindings) => movedRunBindings ? this.#factoryProcessor?.reconcileAllBoundThreads() : void 0).catch((error) => console.warn(`[factory] reconciling bound threads after the session resource migration failed: ${error instanceof Error ? error.message : error}`));
1338
1346
  this.#dispatcher?.start();
1339
1347
  }
1340
- /** Stop Factory-owned background dispatch before the host process shuts down. */
1348
+ /** Stop Factory-owned background work and channel transports before the host process shuts down. */
1341
1349
  async shutdown() {
1342
- await this.#dispatcher?.stop();
1350
+ if (this.#shutdownPromise) return this.#shutdownPromise;
1351
+ const channelShutdowns = this.#channelShutdowns;
1352
+ this.#channelShutdowns = [];
1353
+ const shutdownPromise = (async () => {
1354
+ const results = await Promise.allSettled([this.#dispatcher?.stop() ?? Promise.resolve(), ...channelShutdowns.map(async (shutdown) => shutdown())]);
1355
+ results.slice(1).forEach((result, index) => {
1356
+ if (result.status === "rejected") this.#channelShutdowns.push(channelShutdowns[index]);
1357
+ });
1358
+ const failure = results.find((result) => result.status === "rejected");
1359
+ if (failure) throw failure.reason;
1360
+ })();
1361
+ this.#shutdownPromise = shutdownPromise;
1362
+ try {
1363
+ await shutdownPromise;
1364
+ } finally {
1365
+ if (this.#shutdownPromise === shutdownPromise) this.#shutdownPromise = void 0;
1366
+ }
1343
1367
  }
1344
1368
  };
1345
1369
  export { MastraFactory };