@mastra/factory 0.12.1-alpha.0 → 0.13.0-alpha.10
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.
- package/README.md +163 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +35 -3
- package/dist/auth.js.map +1 -1
- package/dist/boards/define-board.d.ts +42 -0
- package/dist/boards/define-board.d.ts.map +1 -0
- package/dist/boards/define-board.js +53 -0
- package/dist/boards/define-board.js.map +1 -0
- package/dist/boards/index.d.ts +12 -0
- package/dist/boards/index.d.ts.map +1 -0
- package/dist/boards/index.js +20 -0
- package/dist/boards/index.js.map +1 -0
- package/dist/boards/registry.d.ts +16 -0
- package/dist/boards/registry.d.ts.map +1 -0
- package/dist/boards/registry.js +27 -0
- package/dist/boards/registry.js.map +1 -0
- package/dist/boards/review.d.ts +4 -0
- package/dist/boards/review.d.ts.map +1 -0
- package/dist/boards/review.js +76 -0
- package/dist/boards/review.js.map +1 -0
- package/dist/boards/transition-policy.d.ts +63 -0
- package/dist/boards/transition-policy.d.ts.map +1 -0
- package/dist/boards/transition-policy.js +36 -0
- package/dist/boards/transition-policy.js.map +1 -0
- package/dist/boards/work-transition-policy.d.ts +3 -0
- package/dist/boards/work-transition-policy.d.ts.map +1 -0
- package/dist/boards/work-transition-policy.js +31 -0
- package/dist/boards/work-transition-policy.js.map +1 -0
- package/dist/boards/work.d.ts +4 -0
- package/dist/boards/work.d.ts.map +1 -0
- package/dist/boards/work.js +154 -0
- package/dist/boards/work.js.map +1 -0
- package/dist/factory.d.ts +6 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +101 -10
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/integrations/github/acceptance-labels.d.ts +0 -1
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +2 -2
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +194 -0
- package/dist/integrations/github/default-rules.d.ts.map +1 -0
- package/dist/integrations/github/default-rules.js +230 -0
- package/dist/integrations/github/default-rules.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +4 -0
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +6 -0
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/provenance.d.ts +2 -0
- package/dist/integrations/github/provenance.d.ts.map +1 -1
- package/dist/integrations/github/provenance.js +3 -2
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +15 -41
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +3 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +36 -7
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/webhook.d.ts.map +1 -1
- package/dist/integrations/github/webhook.js +35 -3
- package/dist/integrations/github/webhook.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts +3 -3
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +5 -3
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +44 -0
- package/dist/integrations/linear/default-rules.d.ts.map +1 -0
- package/dist/integrations/linear/default-rules.js +65 -0
- package/dist/integrations/linear/default-rules.js.map +1 -0
- package/dist/integrations/linear/integration.d.ts +5 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +7 -1
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -1
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +5 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +5 -4
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +4 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +6 -0
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +5 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +9 -3
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts +3 -1
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +20 -2
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/routes/attention-proposed.d.ts +3 -0
- package/dist/routes/attention-proposed.d.ts.map +1 -0
- package/dist/routes/attention-proposed.js +21 -0
- package/dist/routes/attention-proposed.js.map +1 -0
- package/dist/routes/attention-providers.d.ts +33 -4
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +180 -47
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +31 -30
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/config.d.ts +2 -0
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +3 -2
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/projects.d.ts +9 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +26 -5
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/supervisor.d.ts +23 -0
- package/dist/routes/supervisor.d.ts.map +1 -0
- package/dist/routes/supervisor.js +34 -0
- package/dist/routes/supervisor.js.map +1 -0
- package/dist/routes/surface.d.ts +3 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +11 -6
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-items.d.ts +3 -0
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +60 -53
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/defaults.d.ts.map +1 -1
- package/dist/rules/defaults.js +2 -418
- package/dist/rules/defaults.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +1 -0
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +87 -26
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/index.d.ts +2 -2
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -2
- package/dist/rules/processor.d.ts +2 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +10 -7
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/resolve.d.ts +4 -5
- package/dist/rules/resolve.d.ts.map +1 -1
- package/dist/rules/resolve.js +4 -9
- package/dist/rules/resolve.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +3 -16
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +12 -43
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/terminal-cleanup.d.ts +3 -1
- package/dist/rules/terminal-cleanup.d.ts.map +1 -1
- package/dist/rules/terminal-cleanup.js +5 -0
- package/dist/rules/terminal-cleanup.js.map +1 -1
- package/dist/rules/transition-service.d.ts +3 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +56 -31
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -17
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +10 -2
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +2 -38
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/session-retirement.js +1 -1
- package/dist/session/org-seed.d.ts +1 -1
- package/dist/session/org-seed.js +1 -1
- package/dist/session/org-seed.js.map +1 -1
- package/dist/storage/domains/comments/domain.js +1 -1
- package/dist/storage/domains/comments/routes.js +1 -1
- package/dist/storage/domains/work-items/base.d.ts +54 -19
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +215 -38
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/supervisor/health-worker.d.ts +17 -0
- package/dist/supervisor/health-worker.d.ts.map +1 -0
- package/dist/supervisor/health-worker.js +72 -0
- package/dist/supervisor/health-worker.js.map +1 -0
- package/dist/supervisor/health.d.ts +81 -0
- package/dist/supervisor/health.d.ts.map +1 -0
- package/dist/supervisor/health.js +244 -0
- package/dist/supervisor/health.js.map +1 -0
- package/dist/supervisor/instructions.d.ts +6 -0
- package/dist/supervisor/instructions.d.ts.map +1 -0
- package/dist/supervisor/instructions.js +64 -0
- package/dist/supervisor/instructions.js.map +1 -0
- package/dist/supervisor/read-tools.d.ts +41 -0
- package/dist/supervisor/read-tools.d.ts.map +1 -0
- package/dist/supervisor/read-tools.js +338 -0
- package/dist/supervisor/read-tools.js.map +1 -0
- package/dist/supervisor/session.d.ts +38 -0
- package/dist/supervisor/session.d.ts.map +1 -0
- package/dist/supervisor/session.js +63 -0
- package/dist/supervisor/session.js.map +1 -0
- package/dist/supervisor/write-tools.d.ts +26 -0
- package/dist/supervisor/write-tools.d.ts.map +1 -0
- package/dist/supervisor/write-tools.js +227 -0
- package/dist/supervisor/write-tools.js.map +1 -0
- package/dist/work-item-branch.d.ts +6 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +15 -9
- package/dist/work-item-branch.js.map +1 -1
- package/dist/workspace.d.ts +3 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +15 -5
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +42 -11
- package/factory-skills/factory-triage/SKILL.md +1 -1
- package/package.json +13 -7
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL } from "../../rules/types.js";
|
|
1
2
|
import { clearGithubPat, getGithubPatStatus, setGithubPat } from "./pat.js";
|
|
2
3
|
import { listPullRequestSubscriptionsForThread, subscribeToPullRequest } from "./subscriptions.js";
|
|
4
|
+
import { MaterializeError, SetupCommandError, commitAll, isValidGitRef, pushBranch } from "./sandbox.js";
|
|
3
5
|
import { requireExec } from "../../sandbox/materialization.js";
|
|
4
6
|
import { sanitizeSegment } from "../../sandbox/workdir.js";
|
|
5
7
|
import { peekSessionSandbox } from "../../sandbox/session-sandbox.js";
|
|
@@ -7,13 +9,12 @@ import { normalizeSessionTitle } from "../../session/session-title.js";
|
|
|
7
9
|
import { listRepositoryCommits } from "./commits.js";
|
|
8
10
|
import { getGithubFeatureDiagnostics, isGithubFeatureEnabled } from "./config.js";
|
|
9
11
|
import { reclaimDeletedSessionSandbox } from "./sandbox-release.js";
|
|
10
|
-
import { MaterializeError, SetupCommandError, commitAll, isValidGitRef as isValidGitRef$1, pushBranch } from "./sandbox.js";
|
|
11
12
|
import { handleGithubWebhook } from "./webhook.js";
|
|
13
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
12
14
|
import { registerApiRoute } from "@mastra/core/server";
|
|
13
15
|
import { randomUUID } from "crypto";
|
|
14
16
|
import { UniqueViolationError } from "@mastra/core/storage";
|
|
15
17
|
import { resolveModel } from "@mastra/code-sdk/agents/model";
|
|
16
|
-
import { RequestContext } from "@mastra/core/request-context";
|
|
17
18
|
//#region src/integrations/github/routes.ts
|
|
18
19
|
/**
|
|
19
20
|
* Mastra `apiRoutes` for the GitHub App project feature.
|
|
@@ -60,15 +61,6 @@ function pullRequestNumberFromUrl(value, expectedRepo) {
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Validate a git branch/ref name against a strict whitelist. The value is later
|
|
65
|
-
* interpolated into a shell `git clone --branch` command, so it must never
|
|
66
|
-
* contain shell metacharacters. We accept only git-ref-safe characters and
|
|
67
|
-
* reject anything else rather than relying on shell quoting alone.
|
|
68
|
-
*/
|
|
69
|
-
function isValidGitRef(value) {
|
|
70
|
-
return typeof value === "string" && value.length > 0 && value.length <= 255 && /^[A-Za-z0-9_./-]+$/.test(value);
|
|
71
|
-
}
|
|
72
64
|
function isJsonObject(value) {
|
|
73
65
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
74
66
|
}
|
|
@@ -113,7 +105,7 @@ function parseResourceNumber(raw) {
|
|
|
113
105
|
const parsed = Number(raw);
|
|
114
106
|
return parsed > 0 ? parsed : null;
|
|
115
107
|
}
|
|
116
|
-
const VALID_ISSUE_LABEL_FILTERS = /* @__PURE__ */ new Set([
|
|
108
|
+
const VALID_ISSUE_LABEL_FILTERS = /* @__PURE__ */ new Set([AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL]);
|
|
117
109
|
function parseIssueLabelFilter(raw) {
|
|
118
110
|
if (raw === void 0 || raw === "") return void 0;
|
|
119
111
|
if (VALID_ISSUE_LABEL_FILTERS.has(raw)) return raw;
|
|
@@ -404,29 +396,11 @@ function buildGithubRoutes(options) {
|
|
|
404
396
|
repo
|
|
405
397
|
});
|
|
406
398
|
}
|
|
407
|
-
const repos =
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
input: {
|
|
413
|
-
installationId: inst.id,
|
|
414
|
-
externalId: repo.id.toString(),
|
|
415
|
-
slug: repo.fullName,
|
|
416
|
-
defaultBranch: isValidGitRef(repo.defaultBranch) ? repo.defaultBranch : "main",
|
|
417
|
-
providerMetadata: {
|
|
418
|
-
private: repo.private,
|
|
419
|
-
owner: repo.owner
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
repos[start + offset] = {
|
|
424
|
-
...repo,
|
|
425
|
-
installationStorageId: inst.id,
|
|
426
|
-
repositoryStorageId: repository.id,
|
|
427
|
-
sandboxProvider: sandbox ? "custom" : "none",
|
|
428
|
-
sandboxWorkdir: `~/${sanitizeSegment(repo.fullName.split("/", 2)[1] || "repo")}`
|
|
429
|
-
};
|
|
399
|
+
const repos = matches.map(({ inst, repo }) => ({
|
|
400
|
+
...repo,
|
|
401
|
+
installationStorageId: inst.id,
|
|
402
|
+
sandboxProvider: sandbox ? "custom" : "none",
|
|
403
|
+
sandboxWorkdir: `~/${sanitizeSegment(repo.fullName.split("/", 2)[1] || "repo")}`
|
|
430
404
|
}));
|
|
431
405
|
return c.json({ repos });
|
|
432
406
|
}
|
|
@@ -944,7 +918,7 @@ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memor
|
|
|
944
918
|
const requestedBaseBranch = body.baseBranch;
|
|
945
919
|
if (requestedBaseBranch !== void 0 && typeof requestedBaseBranch !== "string") return c.json({ error: "Invalid baseBranch" }, 400);
|
|
946
920
|
const baseBranch = requestedBaseBranch ?? project.defaultBranch;
|
|
947
|
-
if (!isValidGitRef
|
|
921
|
+
if (!isValidGitRef(baseBranch)) return c.json({ error: "Invalid baseBranch" }, 400);
|
|
948
922
|
const requestedSessionId = body.sessionId;
|
|
949
923
|
if (requestedSessionId !== void 0 && (typeof requestedSessionId !== "string" || !UUID_PATTERN.test(requestedSessionId))) return c.json({ error: "Invalid sessionId" }, 400);
|
|
950
924
|
const sessionId = requestedSessionId ?? randomUUID();
|
|
@@ -954,7 +928,7 @@ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memor
|
|
|
954
928
|
const requestedBranch = body.branch;
|
|
955
929
|
let branch;
|
|
956
930
|
if (requestedBranch === void 0) branch = `${USER_SESSION_BRANCH_PREFIX}${sessionId}`;
|
|
957
|
-
else if (typeof requestedBranch === "string" && isValidGitRef
|
|
931
|
+
else if (typeof requestedBranch === "string" && isValidGitRef(requestedBranch)) branch = requestedBranch;
|
|
958
932
|
else return c.json({ error: "Invalid branch" }, 400);
|
|
959
933
|
if (requestedSessionId !== void 0) {
|
|
960
934
|
const existing = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
|
|
@@ -1133,7 +1107,7 @@ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memor
|
|
|
1133
1107
|
if ("response" in loaded) return loaded.response;
|
|
1134
1108
|
const { orgId, project } = loaded;
|
|
1135
1109
|
const branch = c.req.query("branch") ?? project.defaultBranch;
|
|
1136
|
-
if (!isValidGitRef
|
|
1110
|
+
if (!isValidGitRef(branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1137
1111
|
const limit = Math.min(Math.max(Math.floor(Number(c.req.query("limit") ?? DEFAULT_COMMIT_PAGE)) || DEFAULT_COMMIT_PAGE, 1), MAX_COMMIT_PAGE);
|
|
1138
1112
|
try {
|
|
1139
1113
|
const commits = await listRepositoryCommits(github, {
|
|
@@ -1169,7 +1143,7 @@ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memor
|
|
|
1169
1143
|
} catch {
|
|
1170
1144
|
return c.json({ error: "Invalid JSON body" }, 400);
|
|
1171
1145
|
}
|
|
1172
|
-
if (!isValidGitRef
|
|
1146
|
+
if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1173
1147
|
const branch = body.branch;
|
|
1174
1148
|
const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
|
|
1175
1149
|
if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
|
|
@@ -1226,9 +1200,9 @@ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memor
|
|
|
1226
1200
|
} catch {
|
|
1227
1201
|
return c.json({ error: "Invalid JSON body" }, 400);
|
|
1228
1202
|
}
|
|
1229
|
-
if (!isValidGitRef
|
|
1203
|
+
if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
|
|
1230
1204
|
const base = body.base === void 0 ? project.defaultBranch : body.base;
|
|
1231
|
-
if (!isValidGitRef
|
|
1205
|
+
if (!isValidGitRef(base)) return c.json({ error: "Invalid base" }, 400);
|
|
1232
1206
|
if (typeof body.title !== "string" || body.title.trim().length === 0 || body.title.length > 256) return c.json({ error: "Invalid title" }, 400);
|
|
1233
1207
|
if (body.body !== void 0 && (typeof body.body !== "string" || body.body.length > 65536)) return c.json({ error: "Invalid body" }, 400);
|
|
1234
1208
|
const head = body.branch;
|