@mastra/factory 0.8.0-alpha.12 → 0.8.0-alpha.14

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 (116) hide show
  1. package/CHANGELOG.md +252 -0
  2. package/dist/factory.d.ts.map +1 -1
  3. package/dist/factory.js +11 -1
  4. package/dist/factory.js.map +1 -1
  5. package/dist/integrations/github/app-identity.d.ts +43 -0
  6. package/dist/integrations/github/app-identity.d.ts.map +1 -0
  7. package/dist/integrations/github/app-identity.js +62 -0
  8. package/dist/integrations/github/app-identity.js.map +1 -0
  9. package/dist/integrations/github/routes.js +4 -3
  10. package/dist/integrations/github/routes.js.map +1 -1
  11. package/dist/integrations/github/rules.d.ts +8 -0
  12. package/dist/integrations/github/rules.d.ts.map +1 -1
  13. package/dist/integrations/github/rules.js +30 -8
  14. package/dist/integrations/github/rules.js.map +1 -1
  15. package/dist/integrations/github/sandbox.d.ts +8 -5
  16. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  17. package/dist/integrations/github/sandbox.js +36 -8
  18. package/dist/integrations/github/sandbox.js.map +1 -1
  19. package/dist/integrations/github/webhook.d.ts +20 -0
  20. package/dist/integrations/github/webhook.d.ts.map +1 -1
  21. package/dist/integrations/github/webhook.js +32 -5
  22. package/dist/integrations/github/webhook.js.map +1 -1
  23. package/dist/integrations/linear/rules.d.ts.map +1 -1
  24. package/dist/integrations/linear/rules.js +2 -1
  25. package/dist/integrations/linear/rules.js.map +1 -1
  26. package/dist/integrations/platform/github/event-worker.d.ts +11 -0
  27. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  28. package/dist/integrations/platform/github/event-worker.js +53 -14
  29. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  30. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  31. package/dist/integrations/platform/github/integration.js +8 -1
  32. package/dist/integrations/platform/github/integration.js.map +1 -1
  33. package/dist/integrations/slack/slack.d.ts.map +1 -1
  34. package/dist/integrations/slack/slack.js +2 -1
  35. package/dist/integrations/slack/slack.js.map +1 -1
  36. package/dist/routes/config.d.ts +4 -0
  37. package/dist/routes/config.d.ts.map +1 -1
  38. package/dist/routes/config.js +6 -0
  39. package/dist/routes/config.js.map +1 -1
  40. package/dist/routes/knowledge.d.ts +152 -0
  41. package/dist/routes/knowledge.d.ts.map +1 -0
  42. package/dist/routes/knowledge.js +442 -0
  43. package/dist/routes/knowledge.js.map +1 -0
  44. package/dist/routes/surface.d.ts +1 -0
  45. package/dist/routes/surface.d.ts.map +1 -1
  46. package/dist/routes/surface.js +7 -0
  47. package/dist/routes/surface.js.map +1 -1
  48. package/dist/routes/work-items.d.ts.map +1 -1
  49. package/dist/routes/work-items.js +3 -1
  50. package/dist/routes/work-items.js.map +1 -1
  51. package/dist/rules/binding-context.d.ts.map +1 -1
  52. package/dist/rules/binding-context.js +4 -1
  53. package/dist/rules/binding-context.js.map +1 -1
  54. package/dist/rules/defaults.d.ts.map +1 -1
  55. package/dist/rules/defaults.js +87 -4
  56. package/dist/rules/defaults.js.map +1 -1
  57. package/dist/rules/dispatcher.d.ts +6 -0
  58. package/dist/rules/dispatcher.d.ts.map +1 -1
  59. package/dist/rules/dispatcher.js +118 -16
  60. package/dist/rules/dispatcher.js.map +1 -1
  61. package/dist/rules/processor.d.ts.map +1 -1
  62. package/dist/rules/processor.js +20 -7
  63. package/dist/rules/processor.js.map +1 -1
  64. package/dist/rules/resolve.d.ts +1 -0
  65. package/dist/rules/resolve.d.ts.map +1 -1
  66. package/dist/rules/resolve.js +3 -2
  67. package/dist/rules/resolve.js.map +1 -1
  68. package/dist/rules/start-coordinator.d.ts +2 -0
  69. package/dist/rules/start-coordinator.d.ts.map +1 -1
  70. package/dist/rules/start-coordinator.js +3 -1
  71. package/dist/rules/start-coordinator.js.map +1 -1
  72. package/dist/rules/terminal-cleanup.d.ts +23 -0
  73. package/dist/rules/terminal-cleanup.d.ts.map +1 -0
  74. package/dist/rules/terminal-cleanup.js +43 -0
  75. package/dist/rules/terminal-cleanup.js.map +1 -0
  76. package/dist/rules/tools.d.ts.map +1 -1
  77. package/dist/rules/tools.js +24 -2
  78. package/dist/rules/tools.js.map +1 -1
  79. package/dist/rules/transition-service.d.ts +3 -0
  80. package/dist/rules/transition-service.d.ts.map +1 -1
  81. package/dist/rules/transition-service.js +10 -6
  82. package/dist/rules/transition-service.js.map +1 -1
  83. package/dist/rules/types.d.ts +32 -3
  84. package/dist/rules/types.d.ts.map +1 -1
  85. package/dist/rules/types.js +2 -0
  86. package/dist/rules/types.js.map +1 -1
  87. package/dist/rules/validation.d.ts.map +1 -1
  88. package/dist/rules/validation.js +8 -3
  89. package/dist/rules/validation.js.map +1 -1
  90. package/dist/session/factory-session.d.ts.map +1 -1
  91. package/dist/session/factory-session.js +2 -1
  92. package/dist/session/factory-session.js.map +1 -1
  93. package/dist/skills/service.d.ts +9 -0
  94. package/dist/skills/service.d.ts.map +1 -1
  95. package/dist/skills/service.js +10 -1
  96. package/dist/skills/service.js.map +1 -1
  97. package/dist/storage/domains/source-control/base.d.ts +19 -1
  98. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  99. package/dist/storage/domains/source-control/base.js +8 -5
  100. package/dist/storage/domains/source-control/base.js.map +1 -1
  101. package/dist/storage/domains/source-control/inmemory.d.ts +2 -2
  102. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  103. package/dist/storage/domains/source-control/inmemory.js +2 -1
  104. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  105. package/dist/storage/domains/work-items/base.d.ts +67 -1
  106. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  107. package/dist/storage/domains/work-items/base.js +140 -12
  108. package/dist/storage/domains/work-items/base.js.map +1 -1
  109. package/dist/workspace.d.ts.map +1 -1
  110. package/dist/workspace.js +1 -1
  111. package/dist/workspace.js.map +1 -1
  112. package/factory-skills/factory-plan/SKILL.md +1 -1
  113. package/factory-skills/factory-rereview/SKILL.md +3 -3
  114. package/factory-skills/factory-review/SKILL.md +3 -3
  115. package/factory-skills/factory-triage/SKILL.md +2 -0
  116. package/package.json +6 -6
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Factory's own GitHub identity.
3
+ *
4
+ * Factory must recognise its own writes, or it wakes itself: a handoff comment
5
+ * arrives back through ingress, fires the rule that authored it, and cancels the
6
+ * run mid-flight. Every self-loop guard depends on answering "is this me?".
7
+ *
8
+ * The answer is not free. On a Platform deployment the credentials that post as
9
+ * `mastra-platform[bot]` do not carry that login, and `GITHUB_APP_SLUG`
10
+ * describes a *different*, self-hosted App — so it is legitimately unset. A bare
11
+ * `login === `${slug}[bot]`` therefore compares against `undefined[bot]`, never
12
+ * matches, and silently disables every guard while looking correct.
13
+ *
14
+ * Two sources, in order of trust:
15
+ *
16
+ * 1. **Observed.** Every comment Factory creates comes back with its author.
17
+ * That is authoritative, costs no extra request, and needs no configuration —
18
+ * Factory learns its own name the first time it speaks.
19
+ * 2. **Configured.** `slug` from a self-hosted GitHub App, when present.
20
+ *
21
+ * When neither is available the identity is *unknown*, which is distinct from
22
+ * "not Factory". Callers must handle it explicitly rather than inherit a `false`.
23
+ */
24
+ export declare class GithubAppIdentity {
25
+ #private;
26
+ constructor(slug?: string);
27
+ /** The login Factory posts as, or `undefined` when it cannot be determined. */
28
+ get login(): string | undefined;
29
+ /** True once Factory can recognise its own writes. */
30
+ get known(): boolean;
31
+ /**
32
+ * Record the author GitHub reported for a write Factory just made. Observed
33
+ * identity wins over configuration: it is what GitHub actually attributes the
34
+ * write to, whereas the slug is a claim about a possibly-different App.
35
+ */
36
+ observeSelfAuthor(login: string | null | undefined): void;
37
+ /**
38
+ * Whether `login` is Factory. Returns `false` when the identity is unknown —
39
+ * callers that must not fail open should check {@link known} first.
40
+ */
41
+ matches(login: string | null | undefined): boolean;
42
+ }
43
+ //# sourceMappingURL=app-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-identity.d.ts","sourceRoot":"","sources":["../../../src/integrations/github/app-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,iBAAiB;;gBAIhB,IAAI,CAAC,EAAE,MAAM;IAKzB,+EAA+E;IAC/E,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,sDAAsD;IACtD,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED;;;;OAIG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAKzD;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;CAKnD"}
@@ -0,0 +1,62 @@
1
+ //#region src/integrations/github/app-identity.ts
2
+ /**
3
+ * Factory's own GitHub identity.
4
+ *
5
+ * Factory must recognise its own writes, or it wakes itself: a handoff comment
6
+ * arrives back through ingress, fires the rule that authored it, and cancels the
7
+ * run mid-flight. Every self-loop guard depends on answering "is this me?".
8
+ *
9
+ * The answer is not free. On a Platform deployment the credentials that post as
10
+ * `mastra-platform[bot]` do not carry that login, and `GITHUB_APP_SLUG`
11
+ * describes a *different*, self-hosted App — so it is legitimately unset. A bare
12
+ * `login === `${slug}[bot]`` therefore compares against `undefined[bot]`, never
13
+ * matches, and silently disables every guard while looking correct.
14
+ *
15
+ * Two sources, in order of trust:
16
+ *
17
+ * 1. **Observed.** Every comment Factory creates comes back with its author.
18
+ * That is authoritative, costs no extra request, and needs no configuration —
19
+ * Factory learns its own name the first time it speaks.
20
+ * 2. **Configured.** `slug` from a self-hosted GitHub App, when present.
21
+ *
22
+ * When neither is available the identity is *unknown*, which is distinct from
23
+ * "not Factory". Callers must handle it explicitly rather than inherit a `false`.
24
+ */
25
+ var GithubAppIdentity = class {
26
+ #configuredLogin;
27
+ #observedLogin;
28
+ constructor(slug) {
29
+ const trimmed = slug?.trim();
30
+ this.#configuredLogin = trimmed ? `${trimmed.toLowerCase()}[bot]` : void 0;
31
+ }
32
+ /** The login Factory posts as, or `undefined` when it cannot be determined. */
33
+ get login() {
34
+ return this.#observedLogin ?? this.#configuredLogin;
35
+ }
36
+ /** True once Factory can recognise its own writes. */
37
+ get known() {
38
+ return this.login !== void 0;
39
+ }
40
+ /**
41
+ * Record the author GitHub reported for a write Factory just made. Observed
42
+ * identity wins over configuration: it is what GitHub actually attributes the
43
+ * write to, whereas the slug is a claim about a possibly-different App.
44
+ */
45
+ observeSelfAuthor(login) {
46
+ const trimmed = login?.trim().toLowerCase();
47
+ if (trimmed) this.#observedLogin = trimmed;
48
+ }
49
+ /**
50
+ * Whether `login` is Factory. Returns `false` when the identity is unknown —
51
+ * callers that must not fail open should check {@link known} first.
52
+ */
53
+ matches(login) {
54
+ const self = this.login;
55
+ if (!self || !login) return false;
56
+ return login.trim().toLowerCase() === self;
57
+ }
58
+ };
59
+ //#endregion
60
+ export { GithubAppIdentity };
61
+
62
+ //# sourceMappingURL=app-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-identity.js","names":["#configuredLogin","#observedLogin"],"sources":["../../../src/integrations/github/app-identity.ts"],"sourcesContent":["/**\n * Factory's own GitHub identity.\n *\n * Factory must recognise its own writes, or it wakes itself: a handoff comment\n * arrives back through ingress, fires the rule that authored it, and cancels the\n * run mid-flight. Every self-loop guard depends on answering \"is this me?\".\n *\n * The answer is not free. On a Platform deployment the credentials that post as\n * `mastra-platform[bot]` do not carry that login, and `GITHUB_APP_SLUG`\n * describes a *different*, self-hosted App — so it is legitimately unset. A bare\n * `login === `${slug}[bot]`` therefore compares against `undefined[bot]`, never\n * matches, and silently disables every guard while looking correct.\n *\n * Two sources, in order of trust:\n *\n * 1. **Observed.** Every comment Factory creates comes back with its author.\n * That is authoritative, costs no extra request, and needs no configuration —\n * Factory learns its own name the first time it speaks.\n * 2. **Configured.** `slug` from a self-hosted GitHub App, when present.\n *\n * When neither is available the identity is *unknown*, which is distinct from\n * \"not Factory\". Callers must handle it explicitly rather than inherit a `false`.\n */\nexport class GithubAppIdentity {\n #configuredLogin: string | undefined;\n #observedLogin: string | undefined;\n\n constructor(slug?: string) {\n const trimmed = slug?.trim();\n this.#configuredLogin = trimmed ? `${trimmed.toLowerCase()}[bot]` : undefined;\n }\n\n /** The login Factory posts as, or `undefined` when it cannot be determined. */\n get login(): string | undefined {\n return this.#observedLogin ?? this.#configuredLogin;\n }\n\n /** True once Factory can recognise its own writes. */\n get known(): boolean {\n return this.login !== undefined;\n }\n\n /**\n * Record the author GitHub reported for a write Factory just made. Observed\n * identity wins over configuration: it is what GitHub actually attributes the\n * write to, whereas the slug is a claim about a possibly-different App.\n */\n observeSelfAuthor(login: string | null | undefined): void {\n const trimmed = login?.trim().toLowerCase();\n if (trimmed) this.#observedLogin = trimmed;\n }\n\n /**\n * Whether `login` is Factory. Returns `false` when the identity is unknown —\n * callers that must not fail open should check {@link known} first.\n */\n matches(login: string | null | undefined): boolean {\n const self = this.login;\n if (!self || !login) return false;\n return login.trim().toLowerCase() === self;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,oBAAb,MAA+B;CAC7B;CACA;CAEA,YAAY,MAAe;EACzB,MAAM,UAAU,MAAM,KAAK;EAC3B,KAAKA,mBAAmB,UAAU,GAAG,QAAQ,YAAY,EAAE,SAAS,KAAA;CACtE;;CAGA,IAAI,QAA4B;EAC9B,OAAO,KAAKC,kBAAkB,KAAKD;CACrC;;CAGA,IAAI,QAAiB;EACnB,OAAO,KAAK,UAAU,KAAA;CACxB;;;;;;CAOA,kBAAkB,OAAwC;EACxD,MAAM,UAAU,OAAO,KAAK,CAAC,CAAC,YAAY;EAC1C,IAAI,SAAS,KAAKC,iBAAiB;CACrC;;;;;CAMA,QAAQ,OAA2C;EACjD,MAAM,OAAO,KAAK;EAClB,IAAI,CAAC,QAAQ,CAAC,OAAO,OAAO;EAC5B,OAAO,MAAM,KAAK,CAAC,CAAC,YAAY,MAAM;CACxC;AACF"}
@@ -908,7 +908,7 @@ function buildProjectGitRoutes({ github, auth, fleet, controller, emitAudit, ses
908
908
  if (!project) return c.json({ error: "Project repository not found" }, 404);
909
909
  const sessions = await github.sourceControlStorage.sessions.list({
910
910
  projectRepositoryId: project.id,
911
- userId
911
+ viewerUserId: userId
912
912
  });
913
913
  return c.json({ sessions });
914
914
  }
@@ -963,7 +963,8 @@ function buildProjectGitRoutes({ github, auth, fleet, controller, emitAudit, ses
963
963
  userId,
964
964
  branch,
965
965
  baseBranch,
966
- title: normalizedTitle
966
+ title: normalizedTitle,
967
+ visibility: "org"
967
968
  }).catch(async (error) => {
968
969
  if (!(error instanceof UniqueViolationError) || requestedSessionId === void 0) throw error;
969
970
  const conflict = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
@@ -981,7 +982,7 @@ function buildProjectGitRoutes({ github, auth, fleet, controller, emitAudit, ses
981
982
  const resolved = await resolveOrgTenant(loose(c), auth);
982
983
  if ("response" in resolved) return resolved.response;
983
984
  const session = await github.sourceControlStorage.sessions.getBySessionId(c.req.param("sessionId"));
984
- if (!session || session.orgId !== resolved.tenant.orgId || session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
985
+ if (!session || session.orgId !== resolved.tenant.orgId || session.visibility === "private" && session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
985
986
  return c.json({ session });
986
987
  }
987
988
  }),