@mastra/factory 0.21.1-alpha.3 → 0.22.0-alpha.4
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/dist/capabilities/version-control.d.ts +13 -8
- package/dist/capabilities/version-control.d.ts.map +1 -1
- package/dist/environment/build-runner.d.ts +72 -0
- package/dist/environment/build-runner.d.ts.map +1 -0
- package/dist/environment/build-runner.js +131 -0
- package/dist/environment/build-runner.js.map +1 -0
- package/dist/environment/build-schedule.d.ts +40 -0
- package/dist/environment/build-schedule.d.ts.map +1 -0
- package/dist/environment/build-schedule.js +94 -0
- package/dist/environment/build-schedule.js.map +1 -0
- package/dist/environment/build-workflow.d.ts +62 -0
- package/dist/environment/build-workflow.d.ts.map +1 -0
- package/dist/environment/build-workflow.js +149 -0
- package/dist/environment/build-workflow.js.map +1 -0
- package/dist/environment/build.d.ts +111 -0
- package/dist/environment/build.d.ts.map +1 -0
- package/dist/environment/build.js +344 -0
- package/dist/environment/build.js.map +1 -0
- package/dist/environment/heads.d.ts +36 -0
- package/dist/environment/heads.d.ts.map +1 -0
- package/dist/environment/heads.js +60 -0
- package/dist/environment/heads.js.map +1 -0
- package/dist/factory.d.ts +18 -4
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +89 -15
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/integrations/base.d.ts +17 -2
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/commits.d.ts +11 -0
- package/dist/integrations/github/commits.d.ts.map +1 -1
- package/dist/integrations/github/commits.js +20 -1
- package/dist/integrations/github/commits.js.map +1 -1
- package/dist/integrations/github/config.d.ts +3 -3
- package/dist/integrations/github/config.d.ts.map +1 -1
- package/dist/integrations/github/config.js +1 -1
- package/dist/integrations/github/config.js.map +1 -1
- package/dist/integrations/github/routes.d.ts +2 -2
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +6 -5
- 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 +31 -1
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +35 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +203 -2
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.d.ts.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +117 -62
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.d.ts +7 -0
- package/dist/integrations/github/token-refresh.d.ts.map +1 -1
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/github/webhook.js.map +1 -1
- package/dist/integrations/gitlab/agent-tools.js +1 -1
- package/dist/integrations/gitlab/routes.d.ts +2 -2
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.d.ts.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +8 -7
- package/dist/integrations/gitlab/session-subscriptions.js.map +1 -1
- package/dist/integrations/incidentio/agent-tools.js +1 -1
- package/dist/integrations/jira/agent-tools.js +1 -1
- package/dist/integrations/linear/agent-tools.js +1 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +46 -2
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +15 -16
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/subscription-session.js +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +21 -1
- package/dist/packages/_internals/workspace/dist/index.js.map +1 -1
- package/dist/routes/contracts.d.ts +386 -2
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +166 -1
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/fs.d.ts +25 -0
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +142 -46
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/projects.d.ts +6 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +344 -1
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts +2 -0
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +36 -1
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/supervisor.js +1 -1
- package/dist/routes/surface.d.ts +6 -3
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +21 -34
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/binding-context.d.ts +1 -1
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +1 -1
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/review-source-tool.js +1 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +7 -2
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +1 -1
- package/dist/sandbox/callback-factory-sandbox.d.ts +15 -0
- package/dist/sandbox/callback-factory-sandbox.d.ts.map +1 -0
- package/dist/sandbox/callback-factory-sandbox.js +22 -0
- package/dist/sandbox/callback-factory-sandbox.js.map +1 -0
- package/dist/sandbox/local-factory-sandbox.d.ts +20 -0
- package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -0
- package/dist/sandbox/local-factory-sandbox.js +27 -0
- package/dist/sandbox/local-factory-sandbox.js.map +1 -0
- package/dist/sandbox/session-retirement.d.ts.map +1 -1
- package/dist/sandbox/session-retirement.js +23 -3
- package/dist/sandbox/session-retirement.js.map +1 -1
- package/dist/sandbox/session-sandbox.d.ts +82 -40
- package/dist/sandbox/session-sandbox.d.ts.map +1 -1
- package/dist/sandbox/session-sandbox.js +130 -13
- package/dist/sandbox/session-sandbox.js.map +1 -1
- package/dist/sandbox/workdir.d.ts +10 -0
- package/dist/sandbox/workdir.d.ts.map +1 -1
- package/dist/sandbox/workdir.js +10 -1
- package/dist/sandbox/workdir.js.map +1 -1
- package/dist/session/environment-repositories.d.ts +31 -0
- package/dist/session/environment-repositories.d.ts.map +1 -0
- package/dist/session/environment-repositories.js +89 -0
- package/dist/session/environment-repositories.js.map +1 -0
- package/dist/session/environment-state-processor.d.ts +59 -0
- package/dist/session/environment-state-processor.d.ts.map +1 -0
- package/dist/session/environment-state-processor.js +105 -0
- package/dist/session/environment-state-processor.js.map +1 -0
- package/dist/session/factory-session.d.ts +26 -35
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +34 -71
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/filesystem-capture.d.ts +13 -0
- package/dist/session/filesystem-capture.d.ts.map +1 -1
- package/dist/session/filesystem-capture.js +73 -14
- package/dist/session/filesystem-capture.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +1 -1
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +144 -71
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/spa-static.js +2 -2
- package/dist/storage/domains/audit/agent-audit.d.ts +6 -1
- package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -1
- package/dist/storage/domains/audit/agent-audit.js +31 -13
- package/dist/storage/domains/audit/agent-audit.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +115 -2
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +219 -12
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +123 -7
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +406 -33
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +19 -6
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +90 -2
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +12 -5
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/supervisor/read-tools.js +1 -1
- package/dist/supervisor/write-tools.js +1 -1
- package/dist/workspace.d.ts +50 -7
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +344 -24
- package/dist/workspace.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FactoryStorageDomain } from "@mastra/core/storage";
|
|
2
2
|
//#region src/storage/domains/projects/base.ts
|
|
3
|
+
const DEFAULT_BUILD_PUSH_DEBOUNCE_MINUTES = 10;
|
|
3
4
|
const FACTORY_MODEL_SCOPES = ["factory", "user"];
|
|
4
5
|
const FACTORY_PROJECTS_SCHEMA = {
|
|
5
6
|
name: "factory_projects",
|
|
@@ -32,6 +33,71 @@ const FACTORY_PROJECTS_SCHEMA = {
|
|
|
32
33
|
type: "boolean",
|
|
33
34
|
default: false
|
|
34
35
|
},
|
|
36
|
+
sandbox_working_directory: {
|
|
37
|
+
type: "text",
|
|
38
|
+
nullable: true
|
|
39
|
+
},
|
|
40
|
+
sandbox_settings: {
|
|
41
|
+
type: "json",
|
|
42
|
+
nullable: true
|
|
43
|
+
},
|
|
44
|
+
workspace_setup_command: {
|
|
45
|
+
type: "text",
|
|
46
|
+
nullable: true
|
|
47
|
+
},
|
|
48
|
+
active_template_id: {
|
|
49
|
+
type: "text",
|
|
50
|
+
nullable: true
|
|
51
|
+
},
|
|
52
|
+
active_template_heads: {
|
|
53
|
+
type: "json",
|
|
54
|
+
nullable: true
|
|
55
|
+
},
|
|
56
|
+
last_build_id: {
|
|
57
|
+
type: "text",
|
|
58
|
+
nullable: true
|
|
59
|
+
},
|
|
60
|
+
last_build_heads: {
|
|
61
|
+
type: "json",
|
|
62
|
+
nullable: true
|
|
63
|
+
},
|
|
64
|
+
last_build_inputs: {
|
|
65
|
+
type: "text",
|
|
66
|
+
nullable: true
|
|
67
|
+
},
|
|
68
|
+
last_build_attempted_at: {
|
|
69
|
+
type: "timestamp",
|
|
70
|
+
nullable: true
|
|
71
|
+
},
|
|
72
|
+
last_push_build_at: {
|
|
73
|
+
type: "timestamp",
|
|
74
|
+
nullable: true
|
|
75
|
+
},
|
|
76
|
+
build_start_uncertain: {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
build_start_claim: {
|
|
81
|
+
type: "text",
|
|
82
|
+
nullable: true
|
|
83
|
+
},
|
|
84
|
+
build_start_claim_expires_at: {
|
|
85
|
+
type: "timestamp",
|
|
86
|
+
nullable: true
|
|
87
|
+
},
|
|
88
|
+
build_on_push_enabled: {
|
|
89
|
+
type: "boolean",
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
build_push_debounce_minutes: {
|
|
93
|
+
type: "integer",
|
|
94
|
+
default: 10
|
|
95
|
+
},
|
|
96
|
+
/** Set once the source-control domain has backfilled repository positions and environment membership. */
|
|
97
|
+
environment_backfilled_at: {
|
|
98
|
+
type: "timestamp",
|
|
99
|
+
nullable: true
|
|
100
|
+
},
|
|
35
101
|
created_at: { type: "timestamp" },
|
|
36
102
|
updated_at: { type: "timestamp" }
|
|
37
103
|
},
|
|
@@ -52,6 +118,19 @@ function toFactoryProject(row) {
|
|
|
52
118
|
slackWorkItemsEnabled: row.slack_work_items_enabled,
|
|
53
119
|
autoRunEnabled: row.auto_run_enabled,
|
|
54
120
|
autoApprovePlans: row.auto_approve_plans ?? false,
|
|
121
|
+
sandboxWorkingDirectory: row.sandbox_working_directory ?? null,
|
|
122
|
+
sandboxSettings: row.sandbox_settings ?? null,
|
|
123
|
+
workspaceSetupCommand: row.workspace_setup_command ?? null,
|
|
124
|
+
activeTemplateId: row.active_template_id ?? null,
|
|
125
|
+
activeTemplateHeads: row.active_template_heads ?? null,
|
|
126
|
+
lastBuildId: row.last_build_id ?? null,
|
|
127
|
+
lastBuildHeads: row.last_build_heads ?? null,
|
|
128
|
+
lastBuildInputs: row.last_build_inputs ?? null,
|
|
129
|
+
lastBuildAttemptedAt: row.last_build_attempted_at ?? null,
|
|
130
|
+
lastPushBuildAt: row.last_push_build_at ?? null,
|
|
131
|
+
buildStartUncertain: row.build_start_uncertain ?? false,
|
|
132
|
+
buildOnPushEnabled: row.build_on_push_enabled ?? false,
|
|
133
|
+
buildPushDebounceMinutes: row.build_push_debounce_minutes ?? 10,
|
|
55
134
|
createdAt: row.created_at,
|
|
56
135
|
updatedAt: row.updated_at
|
|
57
136
|
};
|
|
@@ -103,21 +182,149 @@ var FactoryProjectsStorage = class extends FactoryStorageDomain {
|
|
|
103
182
|
return row ? toFactoryProject(row) : null;
|
|
104
183
|
}
|
|
105
184
|
async update({ orgId, id, input }) {
|
|
106
|
-
const
|
|
185
|
+
const update = (ops) => ops.updateAtomic("factory_projects", {
|
|
107
186
|
org_id: orgId,
|
|
108
187
|
id
|
|
109
|
-
}, () =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
188
|
+
}, async (current) => {
|
|
189
|
+
const changes = typeof input === "function" ? await input(toFactoryProject(current), ops) : input;
|
|
190
|
+
if (changes === null) return null;
|
|
191
|
+
return {
|
|
192
|
+
...changes.name !== void 0 ? { name: changes.name } : {},
|
|
193
|
+
...changes.description !== void 0 ? { description: changes.description } : {},
|
|
194
|
+
...changes.defaultModelId !== void 0 ? { default_model_id: changes.defaultModelId } : {},
|
|
195
|
+
...changes.modelScope !== void 0 ? { model_scope: changes.modelScope } : {},
|
|
196
|
+
...changes.slackWorkItemsEnabled !== void 0 ? { slack_work_items_enabled: changes.slackWorkItemsEnabled } : {},
|
|
197
|
+
...changes.autoRunEnabled !== void 0 ? { auto_run_enabled: changes.autoRunEnabled } : {},
|
|
198
|
+
...changes.autoApprovePlans !== void 0 ? { auto_approve_plans: changes.autoApprovePlans } : {},
|
|
199
|
+
...changes.sandboxWorkingDirectory !== void 0 ? { sandbox_working_directory: changes.sandboxWorkingDirectory } : {},
|
|
200
|
+
...changes.sandboxSettings !== void 0 ? { sandbox_settings: changes.sandboxSettings } : {},
|
|
201
|
+
...changes.workspaceSetupCommand !== void 0 ? { workspace_setup_command: changes.workspaceSetupCommand } : {},
|
|
202
|
+
...changes.activeTemplateId !== void 0 ? { active_template_id: changes.activeTemplateId } : {},
|
|
203
|
+
...changes.activeTemplateHeads !== void 0 ? { active_template_heads: changes.activeTemplateHeads } : {},
|
|
204
|
+
...changes.lastBuildId !== void 0 ? { last_build_id: changes.lastBuildId } : {},
|
|
205
|
+
...changes.lastBuildHeads !== void 0 ? { last_build_heads: changes.lastBuildHeads } : {},
|
|
206
|
+
...changes.lastBuildInputs !== void 0 ? { last_build_inputs: changes.lastBuildInputs } : {},
|
|
207
|
+
...changes.lastBuildAttemptedAt !== void 0 ? { last_build_attempted_at: changes.lastBuildAttemptedAt } : {},
|
|
208
|
+
...changes.buildOnPushEnabled !== void 0 ? { build_on_push_enabled: changes.buildOnPushEnabled } : {},
|
|
209
|
+
...changes.buildPushDebounceMinutes !== void 0 ? { build_push_debounce_minutes: changes.buildPushDebounceMinutes } : {},
|
|
210
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
const row = typeof input === "function" ? await this.storage.withTransaction(update) : await update(this.#db);
|
|
119
214
|
return row ? toFactoryProject(row) : null;
|
|
120
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Leading-edge debounce for push-triggered builds: stamps
|
|
218
|
+
* `last_push_build_at = now` and resolves true when no push started a build
|
|
219
|
+
* within the last `debounceMinutes`, else writes nothing and resolves
|
|
220
|
+
* false. Taken right before the provider start, so a push that skips
|
|
221
|
+
* (another run starting, a build in progress) never closes the window. The read and the write run in one transaction, so two concurrent
|
|
222
|
+
* webhooks never both win, even on different database connections.
|
|
223
|
+
*/
|
|
224
|
+
async claimBuildAttempt({ id, debounceMinutes, now = /* @__PURE__ */ new Date() }) {
|
|
225
|
+
let claimed = false;
|
|
226
|
+
await this.storage.withTransaction((ops) => ops.updateAtomic("factory_projects", { id }, (current) => {
|
|
227
|
+
const last = current.last_push_build_at;
|
|
228
|
+
if (last && now.getTime() - last.getTime() < debounceMinutes * 6e4) return null;
|
|
229
|
+
claimed = true;
|
|
230
|
+
return {
|
|
231
|
+
last_push_build_at: now,
|
|
232
|
+
updated_at: now
|
|
233
|
+
};
|
|
234
|
+
}));
|
|
235
|
+
return claimed;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Takes the project's build-start lease for `token`. Every trigger (manual,
|
|
239
|
+
* schedule, push) takes it before reading build state and holds it through
|
|
240
|
+
* `builds.start` and recording the result, so two runs never both start a
|
|
241
|
+
* build. `claimed` is false while another run holds an unexpired lease. The
|
|
242
|
+
* holder renews the lease while it works (`renewBuildStart`), so a lease
|
|
243
|
+
* only expires when its run died or stalled. Taking over an expired lease
|
|
244
|
+
* marks the start uncertain (that run's build may have reached the provider
|
|
245
|
+
* unrecorded), and the mark stays until a release resolves it; `uncertain`
|
|
246
|
+
* reports it. Only the claim is transactional; provider calls run outside it.
|
|
247
|
+
*/
|
|
248
|
+
async claimBuildStart({ id, token, leaseMs, now = /* @__PURE__ */ new Date() }) {
|
|
249
|
+
const result = {
|
|
250
|
+
claimed: false,
|
|
251
|
+
uncertain: false
|
|
252
|
+
};
|
|
253
|
+
await this.storage.withTransaction((ops) => ops.updateAtomic("factory_projects", { id }, (current) => {
|
|
254
|
+
const expiresAt = current.build_start_claim_expires_at;
|
|
255
|
+
if (current.build_start_claim && expiresAt && expiresAt.getTime() > now.getTime()) return null;
|
|
256
|
+
result.claimed = true;
|
|
257
|
+
result.uncertain = Boolean(current.build_start_claim) || current.build_start_uncertain === true;
|
|
258
|
+
return {
|
|
259
|
+
build_start_claim: token,
|
|
260
|
+
build_start_claim_expires_at: new Date(now.getTime() + leaseMs),
|
|
261
|
+
...result.uncertain ? { build_start_uncertain: true } : {},
|
|
262
|
+
updated_at: now
|
|
263
|
+
};
|
|
264
|
+
}));
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Extends the build-start lease held by `token` to `now + leaseMs`. Resolves
|
|
269
|
+
* false, writing nothing, when `token` no longer holds it.
|
|
270
|
+
*/
|
|
271
|
+
async renewBuildStart({ id, token, leaseMs, now = /* @__PURE__ */ new Date() }) {
|
|
272
|
+
let renewed = false;
|
|
273
|
+
await this.storage.withTransaction((ops) => ops.updateAtomic("factory_projects", { id }, (current) => {
|
|
274
|
+
if (current.build_start_claim !== token) return null;
|
|
275
|
+
renewed = true;
|
|
276
|
+
return {
|
|
277
|
+
build_start_claim_expires_at: new Date(now.getTime() + leaseMs),
|
|
278
|
+
updated_at: now
|
|
279
|
+
};
|
|
280
|
+
}));
|
|
281
|
+
return renewed;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Releases the build-start lease taken with `token` and writes `changes` in
|
|
285
|
+
* the same transaction, but only while `token` still holds the lease. A run
|
|
286
|
+
* whose lease expired and was taken by a newer run writes nothing, so it
|
|
287
|
+
* never clears or overwrites that run's build. `resolved` clears an
|
|
288
|
+
* uncertain start. Resolves false when skipped.
|
|
289
|
+
*/
|
|
290
|
+
async releaseBuildStart({ id, token, changes = {}, resolved = false, now = /* @__PURE__ */ new Date() }) {
|
|
291
|
+
let released = false;
|
|
292
|
+
await this.storage.withTransaction((ops) => ops.updateAtomic("factory_projects", { id }, (current) => {
|
|
293
|
+
if (current.build_start_claim !== token) return null;
|
|
294
|
+
released = true;
|
|
295
|
+
return {
|
|
296
|
+
...changes.lastBuildId !== void 0 ? { last_build_id: changes.lastBuildId } : {},
|
|
297
|
+
...changes.lastBuildHeads !== void 0 ? { last_build_heads: changes.lastBuildHeads } : {},
|
|
298
|
+
...changes.lastBuildInputs !== void 0 ? { last_build_inputs: changes.lastBuildInputs } : {},
|
|
299
|
+
...changes.lastBuildAttemptedAt !== void 0 ? { last_build_attempted_at: changes.lastBuildAttemptedAt } : {},
|
|
300
|
+
...resolved ? { build_start_uncertain: false } : {},
|
|
301
|
+
build_start_claim: null,
|
|
302
|
+
build_start_claim_expires_at: null,
|
|
303
|
+
updated_at: now
|
|
304
|
+
};
|
|
305
|
+
}));
|
|
306
|
+
return released;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Pins the active template to a finished build, but only while that build is
|
|
310
|
+
* still the project's last one. Overlapping runs (Build now during a push
|
|
311
|
+
* build) can finish out of order; the write and the `last_build_id` check
|
|
312
|
+
* run in one transaction so a stale run never overwrites a newer build's
|
|
313
|
+
* pin. Resolves false when the pin was skipped.
|
|
314
|
+
*/
|
|
315
|
+
async pinActiveTemplate({ id, buildId, templateId, heads, now = /* @__PURE__ */ new Date() }) {
|
|
316
|
+
let pinned = false;
|
|
317
|
+
await this.storage.withTransaction((ops) => ops.updateAtomic("factory_projects", { id }, (current) => {
|
|
318
|
+
if (current.last_build_id !== buildId) return null;
|
|
319
|
+
pinned = true;
|
|
320
|
+
return {
|
|
321
|
+
active_template_id: templateId,
|
|
322
|
+
active_template_heads: heads,
|
|
323
|
+
updated_at: now
|
|
324
|
+
};
|
|
325
|
+
}));
|
|
326
|
+
return pinned;
|
|
327
|
+
}
|
|
121
328
|
async delete({ orgId, id }) {
|
|
122
329
|
const project = await this.get({
|
|
123
330
|
orgId,
|
|
@@ -131,6 +338,6 @@ var FactoryProjectsStorage = class extends FactoryStorageDomain {
|
|
|
131
338
|
}
|
|
132
339
|
};
|
|
133
340
|
//#endregion
|
|
134
|
-
export { FACTORY_MODEL_SCOPES, FACTORY_PROJECTS_SCHEMA, FactoryProjectsStorage };
|
|
341
|
+
export { DEFAULT_BUILD_PUSH_DEBOUNCE_MINUTES, FACTORY_MODEL_SCOPES, FACTORY_PROJECTS_SCHEMA, FactoryProjectsStorage };
|
|
135
342
|
|
|
136
343
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":["#db"],"sources":["../../../../src/storage/domains/projects/base.ts"],"sourcesContent":["import { FactoryStorageDomain } from '@mastra/core/storage';\nimport type { CollectionSchema, FactoryStorageOps } from '@mastra/core/storage';\n\nexport const FACTORY_MODEL_SCOPES = ['factory', 'user'] as const;\nexport type FactoryModelScope = (typeof FACTORY_MODEL_SCOPES)[number];\n\nexport interface FactoryProject {\n id: string;\n orgId: string;\n createdBy: string;\n name: string;\n description: string | null;\n /** Default model for sessions/runs started under this Factory (null = harness default). */\n defaultModelId: string | null;\n /** Whether sessions use the Factory's model and credentials or the current user's. */\n modelScope: FactoryModelScope;\n /** Whether new Slack sessions create Work-board items for this Factory. */\n slackWorkItemsEnabled: boolean;\n /** Whether rules may start agent runs on their own; off, a run waits for approval on its card. */\n autoRunEnabled: boolean;\n /** Whether the Factory answers a run's plan itself instead of waiting for a person. */\n autoApprovePlans: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface CreateFactoryProjectInput {\n name: string;\n description?: string | null;\n defaultModelId?: string | null;\n}\n\nexport interface UpdateFactoryProjectInput {\n name?: string;\n description?: string | null;\n defaultModelId?: string | null;\n modelScope?: FactoryModelScope;\n slackWorkItemsEnabled?: boolean;\n autoRunEnabled?: boolean;\n autoApprovePlans?: boolean;\n}\n\nexport const FACTORY_PROJECTS_SCHEMA: CollectionSchema = {\n name: 'factory_projects',\n columns: {\n id: { type: 'uuid-pk' },\n org_id: { type: 'text' },\n created_by: { type: 'text' },\n name: { type: 'text' },\n description: { type: 'text', nullable: true },\n default_model_id: { type: 'text', nullable: true },\n model_scope: { type: 'text', default: 'factory' },\n slack_work_items_enabled: { type: 'boolean', default: false },\n auto_run_enabled: { type: 'boolean', default: false },\n auto_approve_plans: { type: 'boolean', default: false },\n created_at: { type: 'timestamp' },\n updated_at: { type: 'timestamp' },\n },\n indexes: [{ name: 'factory_projects_org_updated_at_idx', columns: ['org_id', 'updated_at'] }],\n};\n\ninterface FactoryProjectDbRow extends Record<string, unknown> {\n id: string;\n org_id: string;\n created_by: string;\n name: string;\n description: string | null;\n default_model_id: string | null;\n model_scope: string;\n slack_work_items_enabled: boolean;\n auto_run_enabled: boolean;\n auto_approve_plans: boolean;\n created_at: Date;\n updated_at: Date;\n}\n\nfunction toFactoryProject(row: FactoryProjectDbRow): FactoryProject {\n return {\n id: row.id,\n orgId: row.org_id,\n createdBy: row.created_by,\n name: row.name,\n description: row.description,\n defaultModelId: row.default_model_id,\n modelScope: row.model_scope === 'user' ? 'user' : 'factory',\n slackWorkItemsEnabled: row.slack_work_items_enabled,\n autoRunEnabled: row.auto_run_enabled,\n autoApprovePlans: row.auto_approve_plans ?? false,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nexport class FactoryProjectsStorage extends FactoryStorageDomain {\n constructor() {\n super('projects');\n }\n\n async init(): Promise<void> {\n await this.ensureCollections([FACTORY_PROJECTS_SCHEMA]);\n }\n\n async dangerouslyClearAll(): Promise<void> {\n await this.ops.deleteMany('factory_projects', {});\n }\n\n get #db(): FactoryStorageOps {\n return this.ops;\n }\n\n async create({\n orgId,\n userId,\n input,\n }: {\n orgId: string;\n userId: string;\n input: CreateFactoryProjectInput;\n }): Promise<FactoryProject> {\n const now = new Date();\n const row = await this.#db.insertOne<FactoryProjectDbRow>('factory_projects', {\n org_id: orgId,\n created_by: userId,\n name: input.name,\n description: input.description ?? null,\n default_model_id: input.defaultModelId ?? null,\n model_scope: 'factory',\n slack_work_items_enabled: false,\n auto_run_enabled: false,\n auto_approve_plans: false,\n created_at: now,\n updated_at: now,\n });\n return toFactoryProject(row);\n }\n\n async list({ orgId }: { orgId: string }): Promise<FactoryProject[]> {\n const rows = await this.#db.findMany<FactoryProjectDbRow>(\n 'factory_projects',\n { org_id: orgId },\n { orderBy: [['updated_at', 'desc']] },\n );\n return rows.map(toFactoryProject);\n }\n\n async listAll(): Promise<FactoryProject[]> {\n const rows = await this.#db.findMany<FactoryProjectDbRow>(\n 'factory_projects',\n {},\n { orderBy: [['updated_at', 'desc']] },\n );\n return rows.map(toFactoryProject);\n }\n\n async get({ orgId, id }: { orgId: string; id: string }): Promise<FactoryProject | null> {\n const row = await this.#db.findOne<FactoryProjectDbRow>('factory_projects', { org_id: orgId, id });\n return row ? toFactoryProject(row) : null;\n }\n\n async getById({ id }: { id: string }): Promise<FactoryProject | null> {\n const row = await this.#db.findOne<FactoryProjectDbRow>('factory_projects', { id });\n return row ? toFactoryProject(row) : null;\n }\n\n async update({\n orgId,\n id,\n input,\n }: {\n orgId: string;\n id: string;\n input: UpdateFactoryProjectInput;\n }): Promise<FactoryProject | null> {\n const row = await this.#db.updateAtomic<FactoryProjectDbRow>('factory_projects', { org_id: orgId, id }, () => ({\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.description !== undefined ? { description: input.description } : {}),\n ...(input.defaultModelId !== undefined ? { default_model_id: input.defaultModelId } : {}),\n ...(input.modelScope !== undefined ? { model_scope: input.modelScope } : {}),\n ...(input.slackWorkItemsEnabled !== undefined ? { slack_work_items_enabled: input.slackWorkItemsEnabled } : {}),\n ...(input.autoRunEnabled !== undefined ? { auto_run_enabled: input.autoRunEnabled } : {}),\n ...(input.autoApprovePlans !== undefined ? { auto_approve_plans: input.autoApprovePlans } : {}),\n updated_at: new Date(),\n }));\n return row ? toFactoryProject(row) : null;\n }\n\n async delete({ orgId, id }: { orgId: string; id: string }): Promise<FactoryProject | null> {\n const project = await this.get({ orgId, id });\n if (!project) return null;\n const deleted = await this.#db.deleteMany('factory_projects', { org_id: orgId, id });\n return deleted > 0 ? project : null;\n }\n}\n"],"mappings":";;AAGA,MAAa,uBAAuB,CAAC,WAAW,MAAM;AAuC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AAM,eAAe,IAAI,CAAC;GACvF,GAAI,MAAM,eAAe,KAAA,IAAY,EAAE,aAAa,MAAM,WAAW,IAAI,CAAC;GAC1E,GAAI,MAAM,0BAA0B,KAAA,IAAY,EAAE,0BAA0B,MAAM,sBAAsB,IAAI,CAAC;GAC7G,GAAI,MAAM,mBAAmB,KAAA,IAAY,EAAE,kBAAkB,MAAM,eAAe,IAAI,CAAC;GACvF,GAAI,MAAM,qBAAqB,KAAA,IAAY,EAAE,oBAAoB,MAAM,iBAAiB,IAAI,CAAC;GAC7F,4BAAY,IAAI,KAAK;EACvB,EAAE;EACF,OAAO,MAAM,iBAAiB,GAAG,IAAI;CACvC;CAEA,MAAM,OAAO,EAAE,OAAO,MAAqE;EACzF,MAAM,UAAU,MAAM,KAAK,IAAI;GAAE;GAAO;EAAG,CAAC;EAC5C,IAAI,CAAC,SAAS,OAAO;EAErB,OAAO,MADe,KAAKA,IAAI,WAAW,oBAAoB;GAAE,QAAQ;GAAO;EAAG,CAAC,IAClE,IAAI,UAAU;CACjC;AACF"}
|
|
1
|
+
{"version":3,"file":"base.js","names":["#db"],"sources":["../../../../src/storage/domains/projects/base.ts"],"sourcesContent":["import { FactoryStorageDomain } from '@mastra/core/storage';\nimport type { CollectionSchema, FactoryStorageOps } from '@mastra/core/storage';\n\nexport const DEFAULT_BUILD_PUSH_DEBOUNCE_MINUTES = 10;\nexport const FACTORY_MODEL_SCOPES = ['factory', 'user'] as const;\nexport type FactoryModelScope = (typeof FACTORY_MODEL_SCOPES)[number];\n\nexport interface FactoryProject {\n id: string;\n orgId: string;\n createdBy: string;\n name: string;\n description: string | null;\n /** Default model for sessions/runs started under this Factory (null = harness default). */\n defaultModelId: string | null;\n /** Whether sessions use the Factory's model and credentials or the current user's. */\n modelScope: FactoryModelScope;\n /** Whether new Slack sessions create Work-board items for this Factory. */\n slackWorkItemsEnabled: boolean;\n /** Whether rules may start agent runs on their own; off, a run waits for approval on its card. */\n autoRunEnabled: boolean;\n /** Whether the Factory answers a run's plan itself instead of waiting for a person. */\n autoApprovePlans: boolean;\n /** Workspace root in the sandbox; linked repositories are checked out beneath it. */\n sandboxWorkingDirectory: string | null;\n /** Provider settings document validated by the configured FactorySandbox. Only keys the user set. */\n sandboxSettings: Record<string, unknown> | null;\n /** Command run once in the workspace root after every repository's own setup. */\n workspaceSetupCommand: string | null;\n /** Template id of the environment's current build, written by the build path. */\n activeTemplateId: string | null;\n /** Repository slug → commit the active template was built at. */\n activeTemplateHeads: Record<string, string> | null;\n /** Provider build id of the most recent build attempt; its status is read live from the provider. */\n lastBuildId: string | null;\n /** Repository slug → commit the most recent build attempt pinned, so its status can be read back. */\n lastBuildHeads: Record<string, string> | null;\n /** Fingerprint of the settings, repositories and setup commands the most recent build attempt used. */\n lastBuildInputs: string | null;\n /** When the most recent build attempt started, whatever triggered it. */\n lastBuildAttemptedAt: Date | null;\n /** When a push last started a build: the leading edge of the push debounce window. */\n lastPushBuildAt: Date | null;\n /**\n * A run's build-start lease lapsed, so a build it may have started is not\n * on record. Cleared once a run reconciles it with a provider that lists builds.\n */\n buildStartUncertain: boolean;\n /** Whether a push to an environment repository's default branch starts a build. */\n buildOnPushEnabled: boolean;\n /** Minutes after a push-triggered attempt during which further pushes do not build. */\n buildPushDebounceMinutes: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface CreateFactoryProjectInput {\n name: string;\n description?: string | null;\n defaultModelId?: string | null;\n}\n\nexport interface UpdateFactoryProjectInput {\n name?: string;\n description?: string | null;\n defaultModelId?: string | null;\n modelScope?: FactoryModelScope;\n slackWorkItemsEnabled?: boolean;\n autoRunEnabled?: boolean;\n autoApprovePlans?: boolean;\n sandboxWorkingDirectory?: string | null;\n sandboxSettings?: Record<string, unknown> | null;\n workspaceSetupCommand?: string | null;\n activeTemplateId?: string | null;\n activeTemplateHeads?: Record<string, string> | null;\n lastBuildId?: string | null;\n lastBuildHeads?: Record<string, string> | null;\n lastBuildInputs?: string | null;\n lastBuildAttemptedAt?: Date | null;\n buildOnPushEnabled?: boolean;\n buildPushDebounceMinutes?: number;\n}\n\nexport const FACTORY_PROJECTS_SCHEMA: CollectionSchema = {\n name: 'factory_projects',\n columns: {\n id: { type: 'uuid-pk' },\n org_id: { type: 'text' },\n created_by: { type: 'text' },\n name: { type: 'text' },\n description: { type: 'text', nullable: true },\n default_model_id: { type: 'text', nullable: true },\n model_scope: { type: 'text', default: 'factory' },\n slack_work_items_enabled: { type: 'boolean', default: false },\n auto_run_enabled: { type: 'boolean', default: false },\n auto_approve_plans: { type: 'boolean', default: false },\n sandbox_working_directory: { type: 'text', nullable: true },\n sandbox_settings: { type: 'json', nullable: true },\n workspace_setup_command: { type: 'text', nullable: true },\n active_template_id: { type: 'text', nullable: true },\n active_template_heads: { type: 'json', nullable: true },\n last_build_id: { type: 'text', nullable: true },\n last_build_heads: { type: 'json', nullable: true },\n last_build_inputs: { type: 'text', nullable: true },\n last_build_attempted_at: { type: 'timestamp', nullable: true },\n last_push_build_at: { type: 'timestamp', nullable: true },\n build_start_uncertain: { type: 'boolean', default: false },\n build_start_claim: { type: 'text', nullable: true },\n build_start_claim_expires_at: { type: 'timestamp', nullable: true },\n build_on_push_enabled: { type: 'boolean', default: false },\n build_push_debounce_minutes: { type: 'integer', default: DEFAULT_BUILD_PUSH_DEBOUNCE_MINUTES },\n /** Set once the source-control domain has backfilled repository positions and environment membership. */\n environment_backfilled_at: { type: 'timestamp', nullable: true },\n created_at: { type: 'timestamp' },\n updated_at: { type: 'timestamp' },\n },\n indexes: [{ name: 'factory_projects_org_updated_at_idx', columns: ['org_id', 'updated_at'] }],\n};\n\ninterface FactoryProjectDbRow extends Record<string, unknown> {\n id: string;\n org_id: string;\n created_by: string;\n name: string;\n description: string | null;\n default_model_id: string | null;\n model_scope: string;\n slack_work_items_enabled: boolean;\n auto_run_enabled: boolean;\n auto_approve_plans: boolean;\n sandbox_working_directory: string | null;\n sandbox_settings: Record<string, unknown> | null;\n workspace_setup_command: string | null;\n active_template_id: string | null;\n active_template_heads: Record<string, string> | null;\n last_build_id: string | null;\n last_build_heads: Record<string, string> | null;\n last_build_inputs: string | null;\n last_build_attempted_at: Date | null;\n last_push_build_at: Date | null;\n build_start_uncertain: boolean | null;\n build_start_claim: string | null;\n build_start_claim_expires_at: Date | null;\n build_on_push_enabled: boolean | null;\n build_push_debounce_minutes: number | null;\n environment_backfilled_at: Date | null;\n created_at: Date;\n updated_at: Date;\n}\n\nfunction toFactoryProject(row: FactoryProjectDbRow): FactoryProject {\n return {\n id: row.id,\n orgId: row.org_id,\n createdBy: row.created_by,\n name: row.name,\n description: row.description,\n defaultModelId: row.default_model_id,\n modelScope: row.model_scope === 'user' ? 'user' : 'factory',\n slackWorkItemsEnabled: row.slack_work_items_enabled,\n autoRunEnabled: row.auto_run_enabled,\n autoApprovePlans: row.auto_approve_plans ?? false,\n sandboxWorkingDirectory: row.sandbox_working_directory ?? null,\n sandboxSettings: row.sandbox_settings ?? null,\n workspaceSetupCommand: row.workspace_setup_command ?? null,\n activeTemplateId: row.active_template_id ?? null,\n activeTemplateHeads: row.active_template_heads ?? null,\n lastBuildId: row.last_build_id ?? null,\n lastBuildHeads: row.last_build_heads ?? null,\n lastBuildInputs: row.last_build_inputs ?? null,\n lastBuildAttemptedAt: row.last_build_attempted_at ?? null,\n lastPushBuildAt: row.last_push_build_at ?? null,\n buildStartUncertain: row.build_start_uncertain ?? false,\n buildOnPushEnabled: row.build_on_push_enabled ?? false,\n buildPushDebounceMinutes: row.build_push_debounce_minutes ?? DEFAULT_BUILD_PUSH_DEBOUNCE_MINUTES,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nexport class FactoryProjectsStorage extends FactoryStorageDomain {\n constructor() {\n super('projects');\n }\n\n async init(): Promise<void> {\n await this.ensureCollections([FACTORY_PROJECTS_SCHEMA]);\n }\n\n async dangerouslyClearAll(): Promise<void> {\n await this.ops.deleteMany('factory_projects', {});\n }\n\n get #db(): FactoryStorageOps {\n return this.ops;\n }\n\n async create({\n orgId,\n userId,\n input,\n }: {\n orgId: string;\n userId: string;\n input: CreateFactoryProjectInput;\n }): Promise<FactoryProject> {\n const now = new Date();\n const row = await this.#db.insertOne<FactoryProjectDbRow>('factory_projects', {\n org_id: orgId,\n created_by: userId,\n name: input.name,\n description: input.description ?? null,\n default_model_id: input.defaultModelId ?? null,\n model_scope: 'factory',\n slack_work_items_enabled: false,\n auto_run_enabled: false,\n auto_approve_plans: false,\n created_at: now,\n updated_at: now,\n });\n return toFactoryProject(row);\n }\n\n async list({ orgId }: { orgId: string }): Promise<FactoryProject[]> {\n const rows = await this.#db.findMany<FactoryProjectDbRow>(\n 'factory_projects',\n { org_id: orgId },\n { orderBy: [['updated_at', 'desc']] },\n );\n return rows.map(toFactoryProject);\n }\n\n async listAll(): Promise<FactoryProject[]> {\n const rows = await this.#db.findMany<FactoryProjectDbRow>(\n 'factory_projects',\n {},\n { orderBy: [['updated_at', 'desc']] },\n );\n return rows.map(toFactoryProject);\n }\n\n async get({ orgId, id }: { orgId: string; id: string }): Promise<FactoryProject | null> {\n const row = await this.#db.findOne<FactoryProjectDbRow>('factory_projects', { org_id: orgId, id });\n return row ? toFactoryProject(row) : null;\n }\n\n async getById({ id }: { id: string }): Promise<FactoryProject | null> {\n const row = await this.#db.findOne<FactoryProjectDbRow>('factory_projects', { id });\n return row ? toFactoryProject(row) : null;\n }\n\n async update({\n orgId,\n id,\n input,\n }: {\n orgId: string;\n id: string;\n /** A function input runs in a transaction; writes through its `ops` commit or roll back with the project. */\n input:\n | UpdateFactoryProjectInput\n | ((current: FactoryProject, ops: FactoryStorageOps) => Promise<UpdateFactoryProjectInput | null>);\n }): Promise<FactoryProject | null> {\n const update = (ops: FactoryStorageOps) =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { org_id: orgId, id }, async current => {\n const changes = typeof input === 'function' ? await input(toFactoryProject(current), ops) : input;\n if (changes === null) return null;\n return {\n ...(changes.name !== undefined ? { name: changes.name } : {}),\n ...(changes.description !== undefined ? { description: changes.description } : {}),\n ...(changes.defaultModelId !== undefined ? { default_model_id: changes.defaultModelId } : {}),\n ...(changes.modelScope !== undefined ? { model_scope: changes.modelScope } : {}),\n ...(changes.slackWorkItemsEnabled !== undefined\n ? { slack_work_items_enabled: changes.slackWorkItemsEnabled }\n : {}),\n ...(changes.autoRunEnabled !== undefined ? { auto_run_enabled: changes.autoRunEnabled } : {}),\n ...(changes.autoApprovePlans !== undefined ? { auto_approve_plans: changes.autoApprovePlans } : {}),\n ...(changes.sandboxWorkingDirectory !== undefined\n ? { sandbox_working_directory: changes.sandboxWorkingDirectory }\n : {}),\n ...(changes.sandboxSettings !== undefined ? { sandbox_settings: changes.sandboxSettings } : {}),\n ...(changes.workspaceSetupCommand !== undefined\n ? { workspace_setup_command: changes.workspaceSetupCommand }\n : {}),\n ...(changes.activeTemplateId !== undefined ? { active_template_id: changes.activeTemplateId } : {}),\n ...(changes.activeTemplateHeads !== undefined ? { active_template_heads: changes.activeTemplateHeads } : {}),\n ...(changes.lastBuildId !== undefined ? { last_build_id: changes.lastBuildId } : {}),\n ...(changes.lastBuildHeads !== undefined ? { last_build_heads: changes.lastBuildHeads } : {}),\n ...(changes.lastBuildInputs !== undefined ? { last_build_inputs: changes.lastBuildInputs } : {}),\n ...(changes.lastBuildAttemptedAt !== undefined\n ? { last_build_attempted_at: changes.lastBuildAttemptedAt }\n : {}),\n ...(changes.buildOnPushEnabled !== undefined ? { build_on_push_enabled: changes.buildOnPushEnabled } : {}),\n ...(changes.buildPushDebounceMinutes !== undefined\n ? { build_push_debounce_minutes: changes.buildPushDebounceMinutes }\n : {}),\n updated_at: new Date(),\n };\n });\n // LibSQL's standalone updateAtomic only serializes one client; a transaction\n // also protects a read-dependent update against other database connections.\n const row = typeof input === 'function' ? await this.storage.withTransaction(update) : await update(this.#db);\n return row ? toFactoryProject(row) : null;\n }\n\n /**\n * Leading-edge debounce for push-triggered builds: stamps\n * `last_push_build_at = now` and resolves true when no push started a build\n * within the last `debounceMinutes`, else writes nothing and resolves\n * false. Taken right before the provider start, so a push that skips\n * (another run starting, a build in progress) never closes the window. The read and the write run in one transaction, so two concurrent\n * webhooks never both win, even on different database connections.\n */\n async claimBuildAttempt({\n id,\n debounceMinutes,\n now = new Date(),\n }: {\n id: string;\n debounceMinutes: number;\n now?: Date;\n }): Promise<boolean> {\n let claimed = false;\n await this.storage.withTransaction(ops =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { id }, current => {\n const last = current.last_push_build_at;\n if (last && now.getTime() - last.getTime() < debounceMinutes * 60_000) return null;\n claimed = true;\n return { last_push_build_at: now, updated_at: now };\n }),\n );\n return claimed;\n }\n\n /**\n * Takes the project's build-start lease for `token`. Every trigger (manual,\n * schedule, push) takes it before reading build state and holds it through\n * `builds.start` and recording the result, so two runs never both start a\n * build. `claimed` is false while another run holds an unexpired lease. The\n * holder renews the lease while it works (`renewBuildStart`), so a lease\n * only expires when its run died or stalled. Taking over an expired lease\n * marks the start uncertain (that run's build may have reached the provider\n * unrecorded), and the mark stays until a release resolves it; `uncertain`\n * reports it. Only the claim is transactional; provider calls run outside it.\n */\n async claimBuildStart({\n id,\n token,\n leaseMs,\n now = new Date(),\n }: {\n id: string;\n token: string;\n leaseMs: number;\n now?: Date;\n }): Promise<{ claimed: boolean; uncertain: boolean }> {\n const result = { claimed: false, uncertain: false };\n await this.storage.withTransaction(ops =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { id }, current => {\n const expiresAt = current.build_start_claim_expires_at;\n if (current.build_start_claim && expiresAt && expiresAt.getTime() > now.getTime()) return null;\n result.claimed = true;\n result.uncertain = Boolean(current.build_start_claim) || current.build_start_uncertain === true;\n return {\n build_start_claim: token,\n build_start_claim_expires_at: new Date(now.getTime() + leaseMs),\n ...(result.uncertain ? { build_start_uncertain: true } : {}),\n updated_at: now,\n };\n }),\n );\n return result;\n }\n\n /**\n * Extends the build-start lease held by `token` to `now + leaseMs`. Resolves\n * false, writing nothing, when `token` no longer holds it.\n */\n async renewBuildStart({\n id,\n token,\n leaseMs,\n now = new Date(),\n }: {\n id: string;\n token: string;\n leaseMs: number;\n now?: Date;\n }): Promise<boolean> {\n let renewed = false;\n await this.storage.withTransaction(ops =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { id }, current => {\n if (current.build_start_claim !== token) return null;\n renewed = true;\n return { build_start_claim_expires_at: new Date(now.getTime() + leaseMs), updated_at: now };\n }),\n );\n return renewed;\n }\n\n /**\n * Releases the build-start lease taken with `token` and writes `changes` in\n * the same transaction, but only while `token` still holds the lease. A run\n * whose lease expired and was taken by a newer run writes nothing, so it\n * never clears or overwrites that run's build. `resolved` clears an\n * uncertain start. Resolves false when skipped.\n */\n async releaseBuildStart({\n id,\n token,\n changes = {},\n resolved = false,\n now = new Date(),\n }: {\n id: string;\n token: string;\n resolved?: boolean;\n changes?: Pick<\n UpdateFactoryProjectInput,\n 'lastBuildId' | 'lastBuildHeads' | 'lastBuildInputs' | 'lastBuildAttemptedAt'\n >;\n now?: Date;\n }): Promise<boolean> {\n let released = false;\n await this.storage.withTransaction(ops =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { id }, current => {\n if (current.build_start_claim !== token) return null;\n released = true;\n return {\n ...(changes.lastBuildId !== undefined ? { last_build_id: changes.lastBuildId } : {}),\n ...(changes.lastBuildHeads !== undefined ? { last_build_heads: changes.lastBuildHeads } : {}),\n ...(changes.lastBuildInputs !== undefined ? { last_build_inputs: changes.lastBuildInputs } : {}),\n ...(changes.lastBuildAttemptedAt !== undefined\n ? { last_build_attempted_at: changes.lastBuildAttemptedAt }\n : {}),\n ...(resolved ? { build_start_uncertain: false } : {}),\n build_start_claim: null,\n build_start_claim_expires_at: null,\n updated_at: now,\n };\n }),\n );\n return released;\n }\n\n /**\n * Pins the active template to a finished build, but only while that build is\n * still the project's last one. Overlapping runs (Build now during a push\n * build) can finish out of order; the write and the `last_build_id` check\n * run in one transaction so a stale run never overwrites a newer build's\n * pin. Resolves false when the pin was skipped.\n */\n async pinActiveTemplate({\n id,\n buildId,\n templateId,\n heads,\n now = new Date(),\n }: {\n id: string;\n buildId: string;\n templateId: string;\n heads: Record<string, string>;\n now?: Date;\n }): Promise<boolean> {\n let pinned = false;\n await this.storage.withTransaction(ops =>\n ops.updateAtomic<FactoryProjectDbRow>('factory_projects', { id }, current => {\n if (current.last_build_id !== buildId) return null;\n pinned = true;\n return { active_template_id: templateId, active_template_heads: heads, updated_at: now };\n }),\n );\n return pinned;\n }\n\n async delete({ orgId, id }: { orgId: string; id: string }): Promise<FactoryProject | null> {\n const project = await this.get({ orgId, id });\n if (!project) return null;\n const deleted = await this.#db.deleteMany('factory_projects', { org_id: orgId, id });\n return deleted > 0 ? project : null;\n }\n}\n"],"mappings":";;AAGA,MAAa,sCAAsC;AACnD,MAAa,uBAAuB,CAAC,WAAW,MAAM;AA+EtD,MAAa,0BAA4C;CACvD,MAAM;CACN,SAAS;EACP,IAAI,EAAE,MAAM,UAAU;EACtB,QAAQ,EAAE,MAAM,OAAO;EACvB,YAAY,EAAE,MAAM,OAAO;EAC3B,MAAM,EAAE,MAAM,OAAO;EACrB,aAAa;GAAE,MAAM;GAAQ,UAAU;EAAK;EAC5C,kBAAkB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACjD,aAAa;GAAE,MAAM;GAAQ,SAAS;EAAU;EAChD,0BAA0B;GAAE,MAAM;GAAW,SAAS;EAAM;EAC5D,kBAAkB;GAAE,MAAM;GAAW,SAAS;EAAM;EACpD,oBAAoB;GAAE,MAAM;GAAW,SAAS;EAAM;EACtD,2BAA2B;GAAE,MAAM;GAAQ,UAAU;EAAK;EAC1D,kBAAkB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACjD,yBAAyB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACxD,oBAAoB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACnD,uBAAuB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACtD,eAAe;GAAE,MAAM;GAAQ,UAAU;EAA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AQ,oBAAoB,KAAA,IAAY,EAAE,mBAAmB,QAAQ,gBAAgB,IAAI,CAAC;IAC9F,GAAI,QAAQ,yBAAyB,KAAA,IACjC,EAAE,yBAAyB,QAAQ,qBAAqB,IACxD,CAAC;IACL,GAAI,WAAW,EAAE,uBAAuB,MAAM,IAAI,CAAC;IACnD,mBAAmB;IACnB,8BAA8B;IAC9B,YAAY;GACd;EACF,CAAC,CACH;EACA,OAAO;CACT;;;;;;;;CASA,MAAM,kBAAkB,EACtB,IACA,SACA,YACA,OACA,sBAAM,IAAI,KAAK,KAOI;EACnB,IAAI,SAAS;EACb,MAAM,KAAK,QAAQ,iBAAgB,QACjC,IAAI,aAAkC,oBAAoB,EAAE,GAAG,IAAG,YAAW;GAC3E,IAAI,QAAQ,kBAAkB,SAAS,OAAO;GAC9C,SAAS;GACT,OAAO;IAAE,oBAAoB;IAAY,uBAAuB;IAAO,YAAY;GAAI;EACzF,CAAC,CACH;EACA,OAAO;CACT;CAEA,MAAM,OAAO,EAAE,OAAO,MAAqE;EACzF,MAAM,UAAU,MAAM,KAAK,IAAI;GAAE;GAAO;EAAG,CAAC;EAC5C,IAAI,CAAC,SAAS,OAAO;EAErB,OAAO,MADe,KAAKA,IAAI,WAAW,oBAAoB;GAAE,QAAQ;GAAO;EAAG,CAAC,IAClE,IAAI,UAAU;CACjC;AACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { FactoryStorageDomain } from '@mastra/core/storage';
|
|
2
|
-
import type { CollectionSchema } from '@mastra/core/storage';
|
|
2
|
+
import type { CollectionSchema, FactoryStorageOps } from '@mastra/core/storage';
|
|
3
|
+
/**
|
|
4
|
+
* The user already holds the branch on this link in a session without this
|
|
5
|
+
* factory's ownership, left by the factory migration. It is never reused and
|
|
6
|
+
* cannot be replaced while it holds the branch.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SessionOwnershipMismatchError extends Error {
|
|
9
|
+
readonly sessionId: string;
|
|
10
|
+
constructor(sessionId: string);
|
|
11
|
+
}
|
|
3
12
|
export declare class SourceControlConnectionNotFoundError extends Error {
|
|
4
13
|
constructor();
|
|
5
14
|
}
|
|
@@ -55,6 +64,7 @@ export interface CreateProjectSourceControlConnectionInput {
|
|
|
55
64
|
installationId: string;
|
|
56
65
|
createdByUserId: string;
|
|
57
66
|
}
|
|
67
|
+
export type ProjectRepositoryBuildStatus = 'unbuilt' | 'configured' | 'failed';
|
|
58
68
|
export interface ProjectRepository {
|
|
59
69
|
id: string;
|
|
60
70
|
connectionId: string;
|
|
@@ -65,6 +75,13 @@ export interface ProjectRepository {
|
|
|
65
75
|
sandboxWorkdir: string;
|
|
66
76
|
setupCommand: string | null;
|
|
67
77
|
teardownCommand: string | null;
|
|
78
|
+
/** 1-based order within the project's environment (display and setup order only). */
|
|
79
|
+
position: number;
|
|
80
|
+
/** Whether the repository is part of the project's sandbox environment. */
|
|
81
|
+
inEnvironment: boolean;
|
|
82
|
+
lastBuildStatus: ProjectRepositoryBuildStatus;
|
|
83
|
+
lastBuildError: string | null;
|
|
84
|
+
lastBuiltAt: Date | null;
|
|
68
85
|
createdAt: Date;
|
|
69
86
|
updatedAt: Date;
|
|
70
87
|
}
|
|
@@ -95,6 +112,15 @@ export interface UpdateProjectRepositoryInput {
|
|
|
95
112
|
sandboxWorkdir?: string;
|
|
96
113
|
setupCommand?: string | null;
|
|
97
114
|
teardownCommand?: string | null;
|
|
115
|
+
position?: number;
|
|
116
|
+
inEnvironment?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface SetProjectRepositoryBuildStatusInput {
|
|
119
|
+
orgId: string;
|
|
120
|
+
id: string;
|
|
121
|
+
status: ProjectRepositoryBuildStatus;
|
|
122
|
+
error?: string | null;
|
|
123
|
+
builtAt?: Date | null;
|
|
98
124
|
}
|
|
99
125
|
/**
|
|
100
126
|
* Who can open a session: 'org' sessions are visible to every member of the
|
|
@@ -105,7 +131,17 @@ export type SourceControlSessionVisibility = 'org' | 'private';
|
|
|
105
131
|
export interface SourceControlSession {
|
|
106
132
|
id: string;
|
|
107
133
|
sessionId: string;
|
|
108
|
-
|
|
134
|
+
/**
|
|
135
|
+
* The repository link the session is filed under (the position-1 link by
|
|
136
|
+
* default). The PR tools default to it, and subscriptions, audit and the
|
|
137
|
+
* work-item check still read it; `sessionRepositories` records each
|
|
138
|
+
* repository the session pushed to or opened a change request in, but
|
|
139
|
+
* nothing reads those rows back yet. Moving the readers to them is a
|
|
140
|
+
* follow-up; nullable now so that deletion is a column change only.
|
|
141
|
+
*/
|
|
142
|
+
projectRepositoryId: string | null;
|
|
143
|
+
/** The factory the session belongs to. Null only on rows the backfill could not resolve. */
|
|
144
|
+
factoryProjectId: string | null;
|
|
109
145
|
orgId: string;
|
|
110
146
|
userId: string;
|
|
111
147
|
branch: string;
|
|
@@ -125,6 +161,13 @@ export interface SourceControlSession {
|
|
|
125
161
|
export interface CreateSourceControlSessionInput {
|
|
126
162
|
sessionId: string;
|
|
127
163
|
projectRepositoryId: string;
|
|
164
|
+
/**
|
|
165
|
+
* The factory the link's connection belongs to. It must match the link, so a
|
|
166
|
+
* caller cannot file a session under another project. The stored value is
|
|
167
|
+
* always read from the connection, so a fixture that omits it still gets the
|
|
168
|
+
* right one.
|
|
169
|
+
*/
|
|
170
|
+
factoryProjectId: string;
|
|
128
171
|
orgId: string;
|
|
129
172
|
userId: string;
|
|
130
173
|
branch: string;
|
|
@@ -133,6 +176,43 @@ export interface CreateSourceControlSessionInput {
|
|
|
133
176
|
visibility?: SourceControlSessionVisibility;
|
|
134
177
|
baseBranch: string;
|
|
135
178
|
}
|
|
179
|
+
/** One repository a session pushed to; the branch and change request it holds there. */
|
|
180
|
+
export interface SourceControlSessionRepository {
|
|
181
|
+
id: string;
|
|
182
|
+
sessionId: string;
|
|
183
|
+
projectRepositoryId: string;
|
|
184
|
+
branch: string;
|
|
185
|
+
changeRequestId: string | null;
|
|
186
|
+
changeRequestUrl: string | null;
|
|
187
|
+
pushedAt: Date;
|
|
188
|
+
createdAt: Date;
|
|
189
|
+
updatedAt: Date;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Every optional field keeps the stored value when omitted, so a push after a
|
|
193
|
+
* change request keeps the change request and a change request recorded after
|
|
194
|
+
* a push keeps the pushed branch. `fallbackBranch` only matters on insert: the
|
|
195
|
+
* column is not nullable, so a caller that records a change request for a
|
|
196
|
+
* session with no row yet (raw `git push` + `gh pr create`) passes the head ref.
|
|
197
|
+
*/
|
|
198
|
+
export interface UpsertSessionRepositoryInput {
|
|
199
|
+
sessionId: string;
|
|
200
|
+
projectRepositoryId: string;
|
|
201
|
+
branch?: string;
|
|
202
|
+
fallbackBranch?: string;
|
|
203
|
+
changeRequestId?: string | null;
|
|
204
|
+
changeRequestUrl?: string | null;
|
|
205
|
+
pushedAt?: Date;
|
|
206
|
+
}
|
|
207
|
+
export type SessionBranchKey = {
|
|
208
|
+
projectRepositoryId: string;
|
|
209
|
+
userId: string;
|
|
210
|
+
branch: string;
|
|
211
|
+
} | {
|
|
212
|
+
factoryProjectId: string;
|
|
213
|
+
userId: string;
|
|
214
|
+
branch: string;
|
|
215
|
+
};
|
|
136
216
|
export interface SourceControlStorageHandle {
|
|
137
217
|
readonly integrationId: string;
|
|
138
218
|
readonly installations: {
|
|
@@ -216,6 +296,11 @@ export interface SourceControlStorageHandle {
|
|
|
216
296
|
* without probing every repository an installation can see.
|
|
217
297
|
*/
|
|
218
298
|
listConfiguredExternalKeys(): Promise<ConfiguredExternalRepositoryKey[]>;
|
|
299
|
+
/** Every link of this integration's connections to the project, ordered by `position`. */
|
|
300
|
+
listByProject(args: {
|
|
301
|
+
orgId: string;
|
|
302
|
+
factoryProjectId: string;
|
|
303
|
+
}): Promise<ProjectRepository[]>;
|
|
219
304
|
get(args: {
|
|
220
305
|
orgId: string;
|
|
221
306
|
id: string;
|
|
@@ -226,6 +311,8 @@ export interface SourceControlStorageHandle {
|
|
|
226
311
|
id: string;
|
|
227
312
|
input: UpdateProjectRepositoryInput;
|
|
228
313
|
}): Promise<ProjectRepository | null>;
|
|
314
|
+
/** Record the outcome of the last environment build for this repository. */
|
|
315
|
+
setBuildStatus(args: SetProjectRepositoryBuildStatusInput): Promise<ProjectRepository | null>;
|
|
229
316
|
unlink(args: {
|
|
230
317
|
orgId: string;
|
|
231
318
|
id: string;
|
|
@@ -248,17 +335,23 @@ export interface SourceControlStorageHandle {
|
|
|
248
335
|
listByProjectRepository(args: {
|
|
249
336
|
projectRepositoryId: string;
|
|
250
337
|
}): Promise<SourceControlSession[]>;
|
|
338
|
+
/**
|
|
339
|
+
* Viewer-aware listing of the project's sessions reachable through this
|
|
340
|
+
* integration, across all of its links. Same visibility rule as `list`.
|
|
341
|
+
*/
|
|
342
|
+
listByProject(args: {
|
|
343
|
+
orgId: string;
|
|
344
|
+
factoryProjectId: string;
|
|
345
|
+
viewerUserId: string;
|
|
346
|
+
}): Promise<SourceControlSession[]>;
|
|
251
347
|
getBySessionId(sessionId: string): Promise<SourceControlSession | null>;
|
|
252
348
|
/** Overwrite the session's display title. Keyed by the controller-facing `sessionId`. */
|
|
253
349
|
rename(args: {
|
|
254
350
|
sessionId: string;
|
|
255
351
|
title: string;
|
|
256
352
|
}): Promise<void>;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
userId: string;
|
|
260
|
-
branch: string;
|
|
261
|
-
}): Promise<SourceControlSession | null>;
|
|
353
|
+
/** Keyed by the link (today's callers) or by the factory. */
|
|
354
|
+
getForBranch(args: SessionBranchKey): Promise<SourceControlSession | null>;
|
|
262
355
|
create(input: CreateSourceControlSessionInput): Promise<SourceControlSession>;
|
|
263
356
|
setSandbox(args: {
|
|
264
357
|
id: string;
|
|
@@ -294,12 +387,35 @@ export interface SourceControlStorageHandle {
|
|
|
294
387
|
markFirstMeaningfulExec(args: {
|
|
295
388
|
sessionId: string;
|
|
296
389
|
}): Promise<void>;
|
|
390
|
+
/** Removes the session and its repository rows. */
|
|
297
391
|
delete(id: string): Promise<void>;
|
|
298
392
|
};
|
|
393
|
+
readonly sessionRepositories: {
|
|
394
|
+
/** Insert, or on `(session, link)` conflict update branch, change request and push time. */
|
|
395
|
+
upsert(input: UpsertSessionRepositoryInput): Promise<SourceControlSessionRepository>;
|
|
396
|
+
listBySession(args: {
|
|
397
|
+
sessionId: string;
|
|
398
|
+
}): Promise<SourceControlSessionRepository[]>;
|
|
399
|
+
};
|
|
299
400
|
}
|
|
300
401
|
export declare class SourceControlStorage extends FactoryStorageDomain {
|
|
402
|
+
#private;
|
|
301
403
|
constructor();
|
|
302
404
|
init(): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Applies environment patches to a project's repository links through `ops`,
|
|
407
|
+
* normally a transaction that also holds the project row. Validates against
|
|
408
|
+
* the links as they are inside that transaction: every id must belong to the
|
|
409
|
+
* project, and a reorder must list every link so no two share a position.
|
|
410
|
+
* Nothing is written when validation fails.
|
|
411
|
+
*/
|
|
412
|
+
updateEnvironmentRepositories(ops: FactoryStorageOps, args: {
|
|
413
|
+
factoryProjectId: string;
|
|
414
|
+
integrationIds: string[];
|
|
415
|
+
patches: Array<UpdateProjectRepositoryInput & {
|
|
416
|
+
projectRepositoryId: string;
|
|
417
|
+
}>;
|
|
418
|
+
}): Promise<'updated' | 'not_found' | 'incomplete_reorder'>;
|
|
303
419
|
dangerouslyClearAll(): Promise<void>;
|
|
304
420
|
forIntegration(integrationId: string): SourceControlStorageHandle;
|
|
305
421
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/source-control/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/source-control/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,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