@mastra/factory 0.1.0-alpha.2 → 0.1.0-alpha.3

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 (41) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/factory.d.ts.map +1 -1
  3. package/dist/factory.js +40 -3
  4. package/dist/factory.js.map +1 -1
  5. package/dist/index.js +40 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/integrations/github/integration.js +2 -0
  8. package/dist/integrations/github/integration.js.map +1 -1
  9. package/dist/integrations/github/routes.d.ts.map +1 -1
  10. package/dist/integrations/github/routes.js +2 -0
  11. package/dist/integrations/github/routes.js.map +1 -1
  12. package/dist/integrations/platform/github/event-worker.d.ts +2 -0
  13. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  14. package/dist/integrations/platform/github/event-worker.js +8 -0
  15. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  16. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  17. package/dist/integrations/platform/github/integration.js +11 -0
  18. package/dist/integrations/platform/github/integration.js.map +1 -1
  19. package/dist/routes/surface.d.ts.map +1 -1
  20. package/dist/routes/surface.js +16 -1
  21. package/dist/routes/surface.js.map +1 -1
  22. package/dist/routes/work-items.js.map +1 -1
  23. package/dist/rules/defaults.d.ts.map +1 -1
  24. package/dist/rules/defaults.js +8 -2
  25. package/dist/rules/defaults.js.map +1 -1
  26. package/dist/rules/dispatcher.js.map +1 -1
  27. package/dist/rules/github-service.d.ts +2 -0
  28. package/dist/rules/github-service.d.ts.map +1 -1
  29. package/dist/rules/github-service.js +15 -1
  30. package/dist/rules/github-service.js.map +1 -1
  31. package/dist/rules/index.js +8 -2
  32. package/dist/rules/index.js.map +1 -1
  33. package/dist/rules/linear-service.js.map +1 -1
  34. package/dist/rules/processor.js.map +1 -1
  35. package/dist/rules/tools.js.map +1 -1
  36. package/dist/rules/transition-service.js.map +1 -1
  37. package/dist/rules/types.d.ts +5 -0
  38. package/dist/rules/types.d.ts.map +1 -1
  39. package/dist/rules/types.js.map +1 -1
  40. package/dist/rules/validation.js.map +1 -1
  41. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mastra/factory
2
2
 
3
+ ## 0.1.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Forwarded closed Platform GitHub event-log deliveries into Factory governance before dispatching repository subscriptions, and kept default GitHub rules from auto-starting issues or pull requests created before the Factory. ([#19988](https://github.com/mastra-ai/mastra/pull/19988))
8
+
9
+ - Deployed factories now authenticate API and Studio requests with the same provider, so Studio sessions work without extra configuration. ([#19966](https://github.com/mastra-ai/mastra/pull/19966))
10
+
11
+ - Fixed cloned session threads reading from a previous storage instance. The dynamic memory cache now invalidates when the storage or vector instance changes, so thread cloning always uses the current database. ([#19966](https://github.com/mastra-ai/mastra/pull/19966))
12
+
13
+ - Updated dependencies [[`cc656b9`](https://github.com/mastra-ai/mastra/commit/cc656b92cc8fe40af3e2ea8bb796a6b406e96791), [`cc656b9`](https://github.com/mastra-ai/mastra/commit/cc656b92cc8fe40af3e2ea8bb796a6b406e96791), [`337d41d`](https://github.com/mastra-ai/mastra/commit/337d41d8aae0399d2bf42d42ebddac0c21953891)]:
14
+ - @mastra/code-sdk@1.0.0-alpha.15
15
+
3
16
  ## 0.1.0-alpha.2
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,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,KAA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;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,OAAO,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAwFD,qBAAa,aAAa;;gBAOZ,MAAM,EAAE,mBAAmB;IAWvC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAqbpC;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,iFAAiF;IAC3E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
package/dist/factory.js CHANGED
@@ -26073,6 +26073,7 @@ function polledIssueEvent(project, issue) {
26073
26073
  number: issue.number,
26074
26074
  title: issue.title,
26075
26075
  html_url: issue.url,
26076
+ created_at: issue.createdAt,
26076
26077
  labels: issue.labels.map((name) => ({ name }))
26077
26078
  }
26078
26079
  }
@@ -26092,6 +26093,7 @@ function polledPullRequestEvent(project, pullRequest) {
26092
26093
  number: pullRequest.number,
26093
26094
  title: pullRequest.title,
26094
26095
  html_url: pullRequest.url,
26096
+ created_at: pullRequest.createdAt,
26095
26097
  state: "open",
26096
26098
  merged: false,
26097
26099
  head: { ref: pullRequest.headBranch },
@@ -27240,6 +27242,7 @@ var PlatformGithubEventWorker = class extends MastraWorker {
27240
27242
  #controller;
27241
27243
  #github;
27242
27244
  #storage;
27245
+ #ingestFactoryEvent;
27243
27246
  #intervalMs;
27244
27247
  #now;
27245
27248
  #dispatch;
@@ -27259,6 +27262,7 @@ var PlatformGithubEventWorker = class extends MastraWorker {
27259
27262
  this.#controller = config.controller;
27260
27263
  this.#github = config.github;
27261
27264
  this.#storage = config.storage;
27265
+ this.#ingestFactoryEvent = config.ingestFactoryEvent;
27262
27266
  this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
27263
27267
  if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {
27264
27268
  throw new Error("Platform GitHub event polling interval must be a positive number.");
@@ -27416,6 +27420,9 @@ var PlatformGithubEventWorker = class extends MastraWorker {
27416
27420
  });
27417
27421
  continue;
27418
27422
  }
27423
+ if (isFactoryClosureEvent(parsed)) {
27424
+ await this.#ingestFactoryEvent?.(parsed);
27425
+ }
27419
27426
  const result = await this.#dispatch(parsed, {
27420
27427
  controller: this.#controller,
27421
27428
  listSubscriptions: (target, options) => listPullRequestSubscriptionsForWebhook(target, options, this.#github.integrationStorage),
@@ -27481,6 +27488,9 @@ function normalizeSettings(value) {
27481
27488
  }
27482
27489
  return { version: 1, repositories: { ...value.repositories } };
27483
27490
  }
27491
+ function isFactoryClosureEvent(event) {
27492
+ return (event.event === "issues" || event.event === "pull_request") && event.payload.action === "closed";
27493
+ }
27484
27494
  function parseEvent(event) {
27485
27495
  if (!event.id || !event.deliveryId || !SUPPORTED_EVENTS.has(event.event) || !event.payload || typeof event.payload !== "object" || Array.isArray(event.payload)) {
27486
27496
  return null;
@@ -27829,6 +27839,7 @@ var PlatformGithubIntegration = class {
27829
27839
  controller: ctx.controller,
27830
27840
  github: this,
27831
27841
  storage: ctx.storage.generic,
27842
+ ingestFactoryEvent: ctx.hooks?.ingestGithubEvent,
27832
27843
  intervalMs: this.#pollingIntervalMs
27833
27844
  })
27834
27845
  ];
@@ -29931,6 +29942,11 @@ var FactoryGithubEventService = class {
29931
29942
  return results[0] ?? { status: "ignored" };
29932
29943
  }
29933
29944
  async #ingestProject(parsed, event, installationId, repositoryId, repositoryName, login, project) {
29945
+ const factoryProject = await this.options.projects.get({
29946
+ orgId: project.orgId,
29947
+ id: project.factoryProjectId
29948
+ });
29949
+ if (!factoryProject) return { status: "missing" };
29934
29950
  const issue = object(parsed.payload.issue);
29935
29951
  const pullRequest = object(parsed.payload.pull_request);
29936
29952
  const issueNumber = number(issue?.number);
@@ -29975,13 +29991,22 @@ var FactoryGithubEventService = class {
29975
29991
  } : {},
29976
29992
  event,
29977
29993
  deliveryId: parsed.deliveryId,
29994
+ factory: { createdAt: factoryProject.createdAt.toISOString() },
29978
29995
  repository: { id: repositoryId, fullName: repositoryName },
29979
- ...issueNumber && string(issue?.title) && string(issue?.html_url) ? { issue: { number: issueNumber, title: string(issue?.title), url: string(issue?.html_url) } } : {},
29996
+ ...issueNumber && string(issue?.title) && string(issue?.html_url) ? {
29997
+ issue: {
29998
+ number: issueNumber,
29999
+ title: string(issue?.title),
30000
+ url: string(issue?.html_url),
30001
+ ...string(issue?.created_at) ? { createdAt: string(issue?.created_at) } : {}
30002
+ }
30003
+ } : {},
29980
30004
  ...pullRequestNumber && string(pullRequest?.title) && string(pullRequest?.html_url) ? {
29981
30005
  pullRequest: {
29982
30006
  number: pullRequestNumber,
29983
30007
  title: string(pullRequest?.title),
29984
30008
  url: string(pullRequest?.html_url),
30009
+ ...string(pullRequest?.created_at) ? { createdAt: string(pullRequest?.created_at) } : {},
29985
30010
  state: string(pullRequest?.state) === "closed" ? "closed" : "open",
29986
30011
  merged: boolean(pullRequest?.merged) ?? false,
29987
30012
  headBranch: string(object(pullRequest?.head)?.ref) ?? "",
@@ -34813,6 +34838,7 @@ function assembleFactoryApiRoutes(deps) {
34813
34838
  github: githubIntegration,
34814
34839
  sourceControl: githubStorage,
34815
34840
  integrationStorage: deps.integrationStorage.forIntegration("github"),
34841
+ projects: deps.domains.projects,
34816
34842
  storage: workItems,
34817
34843
  rules: deps.rules
34818
34844
  }) : void 0;
@@ -34950,6 +34976,12 @@ function advanceApprovedPlan(context) {
34950
34976
  stage: "execute"
34951
34977
  };
34952
34978
  }
34979
+ function createdAfterFactory(createdAt, factoryCreatedAt) {
34980
+ if (!createdAt) return false;
34981
+ const sourceCreatedAt = Date.parse(createdAt);
34982
+ const projectCreatedAt = Date.parse(factoryCreatedAt);
34983
+ return Number.isFinite(sourceCreatedAt) && Number.isFinite(projectCreatedAt) && sourceCreatedAt > projectCreatedAt;
34984
+ }
34953
34985
  function issueOpened(context) {
34954
34986
  if (!context.issue) return;
34955
34987
  return {
@@ -34960,7 +34992,7 @@ function issueOpened(context) {
34960
34992
  sourceKey: `github-issue:${context.issue.number}`,
34961
34993
  title: context.issue.title,
34962
34994
  url: context.issue.url,
34963
- stage: trustedGithubActor(context) ? "triage" : "intake",
34995
+ stage: trustedGithubActor(context) && createdAfterFactory(context.issue.createdAt, context.factory.createdAt) ? "triage" : "intake",
34964
34996
  metadata: {
34965
34997
  githubRepositoryId: context.repository.id,
34966
34998
  githubIssueNumber: context.issue.number
@@ -34977,7 +35009,7 @@ function pullRequestOpened(context) {
34977
35009
  sourceKey: `github-pr:${context.pullRequest.number}`,
34978
35010
  title: context.pullRequest.title,
34979
35011
  url: context.pullRequest.url,
34980
- stage: trustedGithubActor(context) ? "review" : "intake",
35012
+ stage: trustedGithubActor(context) && createdAfterFactory(context.pullRequest.createdAt, context.factory.createdAt) ? "review" : "intake",
34981
35013
  metadata: {
34982
35014
  githubRepositoryId: context.repository.id,
34983
35015
  githubPullRequestNumber: context.pullRequest.number,
@@ -38149,6 +38181,7 @@ var MastraFactory = class {
38149
38181
  return { ...spa.length ? { middleware: spa } : {}, ...cors, ...onError };
38150
38182
  }
38151
38183
  return {
38184
+ auth,
38152
38185
  middleware: [
38153
38186
  createFactoryAuthGate(auth),
38154
38187
  createTenantCredentialPrimer({ auth: routeAuth, credentials: modelCredentialsStorage }),
@@ -38181,6 +38214,10 @@ var MastraFactory = class {
38181
38214
  );
38182
38215
  return {
38183
38216
  ...prepared.mastraArgs,
38217
+ // Same provider on `studio.auth` as on `server.auth` (buildServerConfig):
38218
+ // deployed factories must authenticate BOTH plain API callers and Studio
38219
+ // requests (`x-mastra-client-type: studio` routes to `studio.auth`).
38220
+ ...auth ? { studio: { auth } } : {},
38184
38221
  ...integrationWorkers.length > 0 ? { workers: integrationWorkers } : {}
38185
38222
  };
38186
38223
  }