@mastra/factory 0.2.3-alpha.0 → 0.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +54 -6
- package/dist/auth.js.map +1 -1
- package/dist/factory.d.ts +10 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +35 -4
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/integrations/base.d.ts +25 -0
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +23 -8
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/sandbox-release.d.ts +38 -0
- package/dist/integrations/github/sandbox-release.d.ts.map +1 -0
- package/dist/integrations/github/sandbox-release.js +74 -0
- package/dist/integrations/github/sandbox-release.js.map +1 -0
- package/dist/integrations/github/sandbox.d.ts +10 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +44 -7
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +1 -1
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +4 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +9 -2
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +4 -0
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/surface.d.ts +3 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +2 -1
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +2 -0
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +43 -12
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +1 -0
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +13 -4
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/transition-service.d.ts +17 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +30 -1
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/sandbox/fleet.d.ts +12 -1
- package/dist/sandbox/fleet.d.ts.map +1 -1
- package/dist/sandbox/fleet.js +35 -1
- package/dist/sandbox/fleet.js.map +1 -1
- package/dist/spa-static.js +2 -1
- package/dist/spa-static.js.map +1 -1
- package/dist/state-signing.d.ts +16 -5
- package/dist/state-signing.d.ts.map +1 -1
- package/dist/state-signing.js +9 -3
- package/dist/state-signing.js.map +1 -1
- package/dist/storage/domains/channel-identity/base.d.ts +96 -0
- package/dist/storage/domains/channel-identity/base.d.ts.map +1 -0
- package/dist/storage/domains/channel-identity/base.js +149 -0
- package/dist/storage/domains/channel-identity/base.js.map +1 -0
- package/dist/storage/domains/projects/base.d.ts +3 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +7 -0
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +41 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +59 -0
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +8 -1
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +18 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +22 -4
- package/dist/workspace.js.map +1 -1
- package/factory-skills/factory-review/SKILL.md +87 -12
- package/package.json +4 -4
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { FactoryStorageDomain } from "@mastra/core/storage";
|
|
2
|
+
//#region src/storage/domains/channel-identity/base.ts
|
|
3
|
+
const CHANNEL_ACCOUNT_LINKS_SCHEMA = {
|
|
4
|
+
name: "channel_account_links",
|
|
5
|
+
columns: {
|
|
6
|
+
id: { type: "uuid-pk" },
|
|
7
|
+
platform: { type: "text" },
|
|
8
|
+
external_team_id: { type: "text" },
|
|
9
|
+
external_user_id: { type: "text" },
|
|
10
|
+
org_id: {
|
|
11
|
+
type: "text",
|
|
12
|
+
nullable: true
|
|
13
|
+
},
|
|
14
|
+
user_id: { type: "text" },
|
|
15
|
+
external_team_name: {
|
|
16
|
+
type: "text",
|
|
17
|
+
nullable: true
|
|
18
|
+
},
|
|
19
|
+
external_user_name: {
|
|
20
|
+
type: "text",
|
|
21
|
+
nullable: true
|
|
22
|
+
},
|
|
23
|
+
default_factory_project_id: {
|
|
24
|
+
type: "text",
|
|
25
|
+
nullable: true
|
|
26
|
+
},
|
|
27
|
+
linked_at: { type: "timestamp" }
|
|
28
|
+
},
|
|
29
|
+
uniqueIndexes: [{
|
|
30
|
+
name: "channel_account_links_sender_key",
|
|
31
|
+
columns: [
|
|
32
|
+
"platform",
|
|
33
|
+
"external_team_id",
|
|
34
|
+
"external_user_id"
|
|
35
|
+
]
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
function toLink(row) {
|
|
39
|
+
return {
|
|
40
|
+
...row.org_id ? { orgId: row.org_id } : {},
|
|
41
|
+
userId: row.user_id,
|
|
42
|
+
...row.default_factory_project_id ? { defaultFactoryProjectId: row.default_factory_project_id } : {},
|
|
43
|
+
linkedAt: row.linked_at
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function toEntry(row) {
|
|
47
|
+
return {
|
|
48
|
+
...toLink(row),
|
|
49
|
+
platform: row.platform,
|
|
50
|
+
externalTeamId: row.external_team_id,
|
|
51
|
+
externalUserId: row.external_user_id,
|
|
52
|
+
...row.external_team_name ? { externalTeamName: row.external_team_name } : {},
|
|
53
|
+
...row.external_user_name ? { externalUserName: row.external_user_name } : {}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var ChannelIdentityStorage = class extends FactoryStorageDomain {
|
|
57
|
+
constructor() {
|
|
58
|
+
super("channel-identity");
|
|
59
|
+
}
|
|
60
|
+
async init() {
|
|
61
|
+
await this.ensureCollections([CHANNEL_ACCOUNT_LINKS_SCHEMA]);
|
|
62
|
+
}
|
|
63
|
+
async dangerouslyClearAll() {
|
|
64
|
+
await this.ops.deleteMany("channel_account_links", {});
|
|
65
|
+
}
|
|
66
|
+
get #db() {
|
|
67
|
+
return this.ops;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Bind a platform sender identity to a Mastra tenant. Last-write-wins: a
|
|
71
|
+
* re-link (e.g. the same Slack user connecting a different tenant) replaces
|
|
72
|
+
* the stored tenant and refreshes `linkedAt`.
|
|
73
|
+
*/
|
|
74
|
+
async saveAccountLink({ platform, externalTeamId, externalUserId, orgId, userId, externalTeamName, externalUserName }) {
|
|
75
|
+
return toLink(await this.#db.upsertOne("channel_account_links", [
|
|
76
|
+
"platform",
|
|
77
|
+
"external_team_id",
|
|
78
|
+
"external_user_id"
|
|
79
|
+
], {
|
|
80
|
+
platform,
|
|
81
|
+
external_team_id: externalTeamId,
|
|
82
|
+
external_user_id: externalUserId,
|
|
83
|
+
org_id: orgId ?? null,
|
|
84
|
+
user_id: userId,
|
|
85
|
+
external_team_name: externalTeamName ?? null,
|
|
86
|
+
external_user_name: externalUserName ?? null,
|
|
87
|
+
linked_at: /* @__PURE__ */ new Date()
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Set (or clear, with `null`) which Factory project a link's channel runs
|
|
92
|
+
* route to. The `userId` guard makes this self-service only — a caller can
|
|
93
|
+
* never repoint another tenant's link. Returns whether a row was updated.
|
|
94
|
+
*
|
|
95
|
+
* Note: `saveAccountLink` deliberately omits this column from its upsert
|
|
96
|
+
* row, so a re-link keeps the stored default.
|
|
97
|
+
*/
|
|
98
|
+
async setDefaultFactory({ platform, externalTeamId, externalUserId, userId, factoryProjectId }) {
|
|
99
|
+
return await this.#db.updateMany("channel_account_links", {
|
|
100
|
+
user_id: userId,
|
|
101
|
+
platform,
|
|
102
|
+
external_team_id: externalTeamId,
|
|
103
|
+
external_user_id: externalUserId
|
|
104
|
+
}, { default_factory_project_id: factoryProjectId }) > 0;
|
|
105
|
+
}
|
|
106
|
+
/** Resolve the tenant a platform sender is linked to, or `null` if unlinked. */
|
|
107
|
+
async getAccountLink({ platform, externalTeamId, externalUserId }) {
|
|
108
|
+
const row = await this.#db.findOne("channel_account_links", {
|
|
109
|
+
platform,
|
|
110
|
+
external_team_id: externalTeamId,
|
|
111
|
+
external_user_id: externalUserId
|
|
112
|
+
});
|
|
113
|
+
return row ? toLink(row) : null;
|
|
114
|
+
}
|
|
115
|
+
/** Remove a platform sender's link. Returns whether a row was deleted. */
|
|
116
|
+
async deleteAccountLink({ platform, externalTeamId, externalUserId }) {
|
|
117
|
+
return await this.#db.deleteMany("channel_account_links", {
|
|
118
|
+
platform,
|
|
119
|
+
external_team_id: externalTeamId,
|
|
120
|
+
external_user_id: externalUserId
|
|
121
|
+
}) > 0;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* All platform identities linked to a tenant user, for the "Connected
|
|
125
|
+
* accounts" settings surface. Keyed by the tenant `userId` alone — a link
|
|
126
|
+
* belongs to the person, and their personal/org context at link time does
|
|
127
|
+
* not change who may see or sever it.
|
|
128
|
+
*/
|
|
129
|
+
async listAccountLinksForUser(userId) {
|
|
130
|
+
return (await this.#db.findMany("channel_account_links", { user_id: userId })).map(toEntry);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Remove one of the tenant user's own links, addressed by its sender key.
|
|
134
|
+
* The `userId` guard makes the delete self-service only: a caller can never
|
|
135
|
+
* sever another tenant's link even with a known sender key.
|
|
136
|
+
*/
|
|
137
|
+
async deleteAccountLinkForUser({ userId, platform, externalTeamId, externalUserId }) {
|
|
138
|
+
return await this.#db.deleteMany("channel_account_links", {
|
|
139
|
+
user_id: userId,
|
|
140
|
+
platform,
|
|
141
|
+
external_team_id: externalTeamId,
|
|
142
|
+
external_user_id: externalUserId
|
|
143
|
+
}) > 0;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
export { CHANNEL_ACCOUNT_LINKS_SCHEMA, ChannelIdentityStorage };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","names":["#db"],"sources":["../../../../src/storage/domains/channel-identity/base.ts"],"sourcesContent":["import { FactoryStorageDomain } from '@mastra/core/storage';\nimport type { CollectionSchema, FactoryStorageOps } from '@mastra/core/storage';\n\n/**\n * A reverse index from a platform sender identity to a Mastra tenant.\n *\n * Inbound channel events (a Slack DM, a Discord mention, ...) carry only the\n * platform-side sender ids — there is no Mastra `(orgId, userId)` on the event.\n * Model credentials, however, resolve **per-tenant**, so a channel run cannot\n * load the sender's stored model credentials until we know which tenant the\n * sender is. This domain holds that mapping: an authenticated web user links\n * their platform account, and the dispatch seam reads it back to stamp the\n * tenant onto the run's request context.\n *\n * One row per `(platform, external_team_id, external_user_id)` — the same\n * platform user in two workspaces (two team ids) is two independent links, so\n * multi-workspace falls out of the key. `platform` is generic (`'slack'` today,\n * reusable for Discord/Telegram later). The `external_` prefix disambiguates\n * the platform-side ids from the tenant ids (`org_id` / `user_id`) that cohabit\n * the row.\n */\nexport interface ChannelAccountLink {\n /** Undefined for personal accounts (no organization). */\n orgId?: string;\n userId: string;\n /**\n * Which Factory project this sender's channel runs route to. Unset until\n * the user picks one (or the dispatch path auto-stamps their only factory).\n */\n defaultFactoryProjectId?: string;\n linkedAt: Date;\n}\n\n/** The reverse-lookup key: a platform sender identity. */\nexport interface ChannelAccountLinkKey {\n platform: string;\n externalTeamId: string;\n externalUserId: string;\n}\n\n/**\n * Human-readable labels for a linked identity, captured at link time (e.g.\n * from Slack OIDC id_token claims). Display-only — never part of the key.\n */\nexport interface ChannelAccountLinkNames {\n externalTeamName?: string;\n externalUserName?: string;\n}\n\nexport const CHANNEL_ACCOUNT_LINKS_SCHEMA: CollectionSchema = {\n name: 'channel_account_links',\n columns: {\n id: { type: 'uuid-pk' },\n platform: { type: 'text' },\n external_team_id: { type: 'text' },\n external_user_id: { type: 'text' },\n org_id: { type: 'text', nullable: true },\n user_id: { type: 'text' },\n external_team_name: { type: 'text', nullable: true },\n external_user_name: { type: 'text', nullable: true },\n default_factory_project_id: { type: 'text', nullable: true },\n linked_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'channel_account_links_sender_key',\n columns: ['platform', 'external_team_id', 'external_user_id'],\n },\n ],\n};\n\ninterface ChannelAccountLinkDbRow extends Record<string, unknown> {\n id: string;\n platform: string;\n external_team_id: string;\n external_user_id: string;\n org_id: string | null;\n user_id: string;\n external_team_name: string | null;\n external_user_name: string | null;\n default_factory_project_id: string | null;\n linked_at: Date;\n}\n\nfunction toLink(row: ChannelAccountLinkDbRow): ChannelAccountLink {\n return {\n ...(row.org_id ? { orgId: row.org_id } : {}),\n userId: row.user_id,\n ...(row.default_factory_project_id ? { defaultFactoryProjectId: row.default_factory_project_id } : {}),\n linkedAt: row.linked_at,\n };\n}\n\n/** A link row with its platform sender key, as listed for a tenant user. */\nexport interface ChannelAccountLinkEntry extends ChannelAccountLink, ChannelAccountLinkKey, ChannelAccountLinkNames {}\n\nfunction toEntry(row: ChannelAccountLinkDbRow): ChannelAccountLinkEntry {\n return {\n ...toLink(row),\n platform: row.platform,\n externalTeamId: row.external_team_id,\n externalUserId: row.external_user_id,\n ...(row.external_team_name ? { externalTeamName: row.external_team_name } : {}),\n ...(row.external_user_name ? { externalUserName: row.external_user_name } : {}),\n };\n}\n\nexport class ChannelIdentityStorage extends FactoryStorageDomain {\n constructor() {\n super('channel-identity');\n }\n\n async init(): Promise<void> {\n await this.ensureCollections([CHANNEL_ACCOUNT_LINKS_SCHEMA]);\n }\n\n async dangerouslyClearAll(): Promise<void> {\n await this.ops.deleteMany('channel_account_links', {});\n }\n\n get #db(): FactoryStorageOps {\n return this.ops;\n }\n\n /**\n * Bind a platform sender identity to a Mastra tenant. Last-write-wins: a\n * re-link (e.g. the same Slack user connecting a different tenant) replaces\n * the stored tenant and refreshes `linkedAt`.\n */\n async saveAccountLink({\n platform,\n externalTeamId,\n externalUserId,\n orgId,\n userId,\n externalTeamName,\n externalUserName,\n }: ChannelAccountLinkKey &\n ChannelAccountLinkNames & { orgId?: string; userId: string }): Promise<ChannelAccountLink> {\n const row = await this.#db.upsertOne<ChannelAccountLinkDbRow>(\n 'channel_account_links',\n ['platform', 'external_team_id', 'external_user_id'],\n {\n platform,\n external_team_id: externalTeamId,\n external_user_id: externalUserId,\n org_id: orgId ?? null,\n user_id: userId,\n external_team_name: externalTeamName ?? null,\n external_user_name: externalUserName ?? null,\n linked_at: new Date(),\n },\n );\n return toLink(row);\n }\n\n /**\n * Set (or clear, with `null`) which Factory project a link's channel runs\n * route to. The `userId` guard makes this self-service only — a caller can\n * never repoint another tenant's link. Returns whether a row was updated.\n *\n * Note: `saveAccountLink` deliberately omits this column from its upsert\n * row, so a re-link keeps the stored default.\n */\n async setDefaultFactory({\n platform,\n externalTeamId,\n externalUserId,\n userId,\n factoryProjectId,\n }: ChannelAccountLinkKey & { userId: string; factoryProjectId: string | null }): Promise<boolean> {\n const updated = await this.#db.updateMany(\n 'channel_account_links',\n {\n user_id: userId,\n platform,\n external_team_id: externalTeamId,\n external_user_id: externalUserId,\n },\n { default_factory_project_id: factoryProjectId },\n );\n return updated > 0;\n }\n\n /** Resolve the tenant a platform sender is linked to, or `null` if unlinked. */\n async getAccountLink({\n platform,\n externalTeamId,\n externalUserId,\n }: ChannelAccountLinkKey): Promise<ChannelAccountLink | null> {\n const row = await this.#db.findOne<ChannelAccountLinkDbRow>('channel_account_links', {\n platform,\n external_team_id: externalTeamId,\n external_user_id: externalUserId,\n });\n return row ? toLink(row) : null;\n }\n\n /** Remove a platform sender's link. Returns whether a row was deleted. */\n async deleteAccountLink({ platform, externalTeamId, externalUserId }: ChannelAccountLinkKey): Promise<boolean> {\n const deleted = await this.#db.deleteMany('channel_account_links', {\n platform,\n external_team_id: externalTeamId,\n external_user_id: externalUserId,\n });\n return deleted > 0;\n }\n\n /**\n * All platform identities linked to a tenant user, for the \"Connected\n * accounts\" settings surface. Keyed by the tenant `userId` alone — a link\n * belongs to the person, and their personal/org context at link time does\n * not change who may see or sever it.\n */\n async listAccountLinksForUser(userId: string): Promise<ChannelAccountLinkEntry[]> {\n const rows = await this.#db.findMany<ChannelAccountLinkDbRow>('channel_account_links', { user_id: userId });\n return rows.map(toEntry);\n }\n\n /**\n * Remove one of the tenant user's own links, addressed by its sender key.\n * The `userId` guard makes the delete self-service only: a caller can never\n * sever another tenant's link even with a known sender key.\n */\n async deleteAccountLinkForUser({\n userId,\n platform,\n externalTeamId,\n externalUserId,\n }: ChannelAccountLinkKey & { userId: string }): Promise<boolean> {\n const deleted = await this.#db.deleteMany('channel_account_links', {\n user_id: userId,\n platform,\n external_team_id: externalTeamId,\n external_user_id: externalUserId,\n });\n return deleted > 0;\n }\n}\n"],"mappings":";;AAiDA,MAAa,+BAAiD;CAC5D,MAAM;CACN,SAAS;EACP,IAAI,EAAE,MAAM,UAAU;EACtB,UAAU,EAAE,MAAM,OAAO;EACzB,kBAAkB,EAAE,MAAM,OAAO;EACjC,kBAAkB,EAAE,MAAM,OAAO;EACjC,QAAQ;GAAE,MAAM;GAAQ,UAAU;EAAK;EACvC,SAAS,EAAE,MAAM,OAAO;EACxB,oBAAoB;GAAE,MAAM;GAAQ,UAAU;EAAK;EACnD,oBAAoB;GAAE,MAAM;GAAQ,UAAU;EAAK;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;;;;CAUA,MAAM,kBAAkB,EACtB,UACA,gBACA,gBACA,QACA,oBACgG;EAWhG,OAAO,MAVe,KAAKA,IAAI,WAC7B,yBACA;GACE,SAAS;GACT;GACA,kBAAkB;GAClB,kBAAkB;EACpB,GACA,EAAE,4BAA4B,iBAAiB,CACjD,IACiB;CACnB;;CAGA,MAAM,eAAe,EACnB,UACA,gBACA,kBAC4D;EAC5D,MAAM,MAAM,MAAM,KAAKA,IAAI,QAAiC,yBAAyB;GACnF;GACA,kBAAkB;GAClB,kBAAkB;EACpB,CAAC;EACD,OAAO,MAAM,OAAO,GAAG,IAAI;CAC7B;;CAGA,MAAM,kBAAkB,EAAE,UAAU,gBAAgB,kBAA2D;EAM7G,OAAO,MALe,KAAKA,IAAI,WAAW,yBAAyB;GACjE;GACA,kBAAkB;GAClB,kBAAkB;EACpB,CAAC,IACgB;CACnB;;;;;;;CAQA,MAAM,wBAAwB,QAAoD;EAEhF,QAAO,MADY,KAAKA,IAAI,SAAkC,yBAAyB,EAAE,SAAS,OAAO,CAAC,EAAA,CAC9F,IAAI,OAAO;CACzB;;;;;;CAOA,MAAM,yBAAyB,EAC7B,QACA,UACA,gBACA,kBAC+D;EAO/D,OAAO,MANe,KAAKA,IAAI,WAAW,yBAAyB;GACjE,SAAS;GACT;GACA,kBAAkB;GAClB,kBAAkB;EACpB,CAAC,IACgB;CACnB;AACF"}
|
|
@@ -8,6 +8,8 @@ export interface FactoryProject {
|
|
|
8
8
|
description: string | null;
|
|
9
9
|
/** Default model for sessions/runs started under this Factory (null = harness default). */
|
|
10
10
|
defaultModelId: string | null;
|
|
11
|
+
/** Whether new Slack sessions create Work-board items for this Factory. */
|
|
12
|
+
slackWorkItemsEnabled: boolean;
|
|
11
13
|
createdAt: Date;
|
|
12
14
|
updatedAt: Date;
|
|
13
15
|
}
|
|
@@ -20,6 +22,7 @@ export interface UpdateFactoryProjectInput {
|
|
|
20
22
|
name?: string;
|
|
21
23
|
description?: string | null;
|
|
22
24
|
defaultModelId?: string | null;
|
|
25
|
+
slackWorkItemsEnabled?: boolean;
|
|
23
26
|
}
|
|
24
27
|
export declare const FACTORY_PROJECTS_SCHEMA: CollectionSchema;
|
|
25
28
|
export declare class FactoryProjectsStorage extends FactoryStorageDomain {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/projects/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,2FAA2F;IAC3F,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/projects/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,c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E;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAKjF,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAK/D,MAAM,CAAC,EACX,KAAK,EACL,EAAE,EACF,KAAK,GACN,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,yBAAyB,CAAC;KAClC,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAW5B,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAM3F"}
|
|
@@ -15,6 +15,10 @@ const FACTORY_PROJECTS_SCHEMA = {
|
|
|
15
15
|
type: "text",
|
|
16
16
|
nullable: true
|
|
17
17
|
},
|
|
18
|
+
slack_work_items_enabled: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: false
|
|
21
|
+
},
|
|
18
22
|
created_at: { type: "timestamp" },
|
|
19
23
|
updated_at: { type: "timestamp" }
|
|
20
24
|
},
|
|
@@ -31,6 +35,7 @@ function toFactoryProject(row) {
|
|
|
31
35
|
name: row.name,
|
|
32
36
|
description: row.description,
|
|
33
37
|
defaultModelId: row.default_model_id,
|
|
38
|
+
slackWorkItemsEnabled: row.slack_work_items_enabled,
|
|
34
39
|
createdAt: row.created_at,
|
|
35
40
|
updatedAt: row.updated_at
|
|
36
41
|
};
|
|
@@ -56,6 +61,7 @@ var FactoryProjectsStorage = class extends FactoryStorageDomain {
|
|
|
56
61
|
name: input.name,
|
|
57
62
|
description: input.description ?? null,
|
|
58
63
|
default_model_id: input.defaultModelId ?? null,
|
|
64
|
+
slack_work_items_enabled: false,
|
|
59
65
|
created_at: now,
|
|
60
66
|
updated_at: now
|
|
61
67
|
}));
|
|
@@ -82,6 +88,7 @@ var FactoryProjectsStorage = class extends FactoryStorageDomain {
|
|
|
82
88
|
...input.name !== void 0 ? { name: input.name } : {},
|
|
83
89
|
...input.description !== void 0 ? { description: input.description } : {},
|
|
84
90
|
...input.defaultModelId !== void 0 ? { default_model_id: input.defaultModelId } : {},
|
|
91
|
+
...input.slackWorkItemsEnabled !== void 0 ? { slack_work_items_enabled: input.slackWorkItemsEnabled } : {},
|
|
85
92
|
updated_at: /* @__PURE__ */ new Date()
|
|
86
93
|
}));
|
|
87
94
|
return row ? toFactoryProject(row) : null;
|
|
@@ -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 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 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}\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 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 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 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 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 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 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":";;
|
|
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 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 new Slack sessions create Work-board items for this Factory. */\n slackWorkItemsEnabled: 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 slackWorkItemsEnabled?: 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 slack_work_items_enabled: { 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 slack_work_items_enabled: 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 slackWorkItemsEnabled: row.slack_work_items_enabled,\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 slack_work_items_enabled: 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 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.slackWorkItemsEnabled !== undefined ? { slack_work_items_enabled: input.slackWorkItemsEnabled } : {}),\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":";;AA8BA,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,0BAA0B;GAAE,MAAM;GAAW,SAAS;EAAM;EAC5D,YAAY,EAAE,MAAM,YAAY;EAChC,YAAY,EAAE,MAAM,YAAY;CAClC;CACA,SAAS,CAAC;EAAE,MAAM;EAAuC,SAAS,CAAC,UAAU,YAAY;CAAE,CAAC;AAC9F;AAcA,SAAS,iBAAiB,KAA0C;CAClE,OAAO;EACL,IAAI,IAAI;EACR,OAAO,IAAI;EACX,WAAW,IAAI;EACf,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,uBAAuB,IAAI;EAC3B,WAAW,IAAI;EACf,WAAW,IAAI;CACjB;AACF;AAEA,IAAa,yBAAb,cAA4C,qBAAqB;CAC/D,cAAc;EACZ,MAAM,UAAU;CAClB;CAEA,MAAM,O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,IAAI,CAAC;GAC5E,GAAI,MAAM,mBAAmB,KAAA,IAAY,EAAE,kBAAkB,MAAM,eAAe,IAAI,CAAC;GACvF,GAAI,MAAM,0BAA0B,KAAA,IAAY,EAAE,0BAA0B,MAAM,sBAAsB,IAAI,CAAC;GAC7G,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"}
|
|
@@ -99,6 +99,31 @@ export interface ProjectRepositorySandbox {
|
|
|
99
99
|
materializedAt: Date | null;
|
|
100
100
|
createdAt: Date;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* A provider sandbox that is no longer bound to any session and can be handed
|
|
104
|
+
* to the next session for the same project-repository link instead of
|
|
105
|
+
* provisioning a fresh VM. Pooling is per-repository, not per-user: no
|
|
106
|
+
* credentials are baked into the VM (tokens are injected per command), so any
|
|
107
|
+
* user's session can safely claim it. `userId` records who released it,
|
|
108
|
+
* purely as provenance.
|
|
109
|
+
*/
|
|
110
|
+
export interface PooledSandbox {
|
|
111
|
+
id: string;
|
|
112
|
+
orgId: string;
|
|
113
|
+
projectRepositoryId: string;
|
|
114
|
+
/** User whose session released this sandbox (provenance, not a claim key). */
|
|
115
|
+
userId: string;
|
|
116
|
+
sandboxId: string;
|
|
117
|
+
sandboxWorkdir: string;
|
|
118
|
+
releasedAt: Date;
|
|
119
|
+
}
|
|
120
|
+
export interface ReleasePooledSandboxInput {
|
|
121
|
+
orgId: string;
|
|
122
|
+
projectRepositoryId: string;
|
|
123
|
+
userId: string;
|
|
124
|
+
sandboxId: string;
|
|
125
|
+
sandboxWorkdir: string;
|
|
126
|
+
}
|
|
102
127
|
export interface SourceControlWorktree {
|
|
103
128
|
id: string;
|
|
104
129
|
projectRepositoryId: string;
|
|
@@ -263,6 +288,22 @@ export interface SourceControlStorageHandle {
|
|
|
263
288
|
id: string;
|
|
264
289
|
}): Promise<void>;
|
|
265
290
|
};
|
|
291
|
+
readonly sandboxPool: {
|
|
292
|
+
/**
|
|
293
|
+
* Return a sandbox to the reuse pool. Idempotent per provider sandbox ID —
|
|
294
|
+
* releasing the same sandbox twice keeps one pool row.
|
|
295
|
+
*/
|
|
296
|
+
release(args: ReleasePooledSandboxInput): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Atomically take one pooled sandbox for the given project-repository
|
|
299
|
+
* link, preferring the most recently released (warmest) VM. Returns
|
|
300
|
+
* `null` when the pool is empty. Each pooled sandbox is handed to exactly
|
|
301
|
+
* one claimer even under concurrent claims.
|
|
302
|
+
*/
|
|
303
|
+
claim(args: {
|
|
304
|
+
projectRepositoryId: string;
|
|
305
|
+
}): Promise<PooledSandbox | null>;
|
|
306
|
+
};
|
|
266
307
|
readonly worktrees: {
|
|
267
308
|
upsert(args: UpsertSourceControlWorktreeInput): Promise<void>;
|
|
268
309
|
list(args: {
|
|
@@ -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,EAAqB,MAAM,sBAAsB,CAAC;
|
|
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,EAAqB,MAAM,sBAAsB,CAAC;AAYhF,eAAO,MAAM,sBAAsB,EAAE,gBAAg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,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,EAAE,+BAA+B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC9E,UAAU,CAAC,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YAAC,cAAc,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAClG,gBAAgB,CAAC,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACnC,CAAC;CACH;AAsMD,qBAAa,oBAAqB,SAAQ,oBAAoB;;IAKtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAW1C,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,0BAA0B;CAijBlE"}
|
|
@@ -6,6 +6,7 @@ const REPOSITORIES = "source_control_repositories";
|
|
|
6
6
|
const CONNECTIONS = "factory_project_source_control_connections";
|
|
7
7
|
const PROJECT_REPOSITORIES = "factory_project_repositories";
|
|
8
8
|
const SANDBOXES = "source_control_project_repository_sandboxes";
|
|
9
|
+
const SANDBOX_POOL = "source_control_sandbox_pool";
|
|
9
10
|
const WORKTREES = "source_control_worktrees";
|
|
10
11
|
const SESSIONS = "source_control_sessions";
|
|
11
12
|
const SOURCE_CONTROL_SCHEMAS = [
|
|
@@ -135,6 +136,26 @@ const SOURCE_CONTROL_SCHEMAS = [
|
|
|
135
136
|
columns: ["project_repository_id", "user_id"]
|
|
136
137
|
}]
|
|
137
138
|
},
|
|
139
|
+
{
|
|
140
|
+
name: SANDBOX_POOL,
|
|
141
|
+
columns: {
|
|
142
|
+
id: { type: "uuid-pk" },
|
|
143
|
+
org_id: { type: "text" },
|
|
144
|
+
project_repository_id: { type: "text" },
|
|
145
|
+
user_id: { type: "text" },
|
|
146
|
+
sandbox_id: { type: "text" },
|
|
147
|
+
sandbox_workdir: { type: "text" },
|
|
148
|
+
released_at: { type: "timestamp" }
|
|
149
|
+
},
|
|
150
|
+
uniqueIndexes: [{
|
|
151
|
+
name: "source_control_sandbox_pool_sandbox_unique",
|
|
152
|
+
columns: ["sandbox_id"]
|
|
153
|
+
}],
|
|
154
|
+
indexes: [{
|
|
155
|
+
name: "source_control_sandbox_pool_repository_user_idx",
|
|
156
|
+
columns: ["project_repository_id", "user_id"]
|
|
157
|
+
}]
|
|
158
|
+
},
|
|
138
159
|
{
|
|
139
160
|
name: WORKTREES,
|
|
140
161
|
columns: {
|
|
@@ -253,6 +274,17 @@ function toSandbox(row) {
|
|
|
253
274
|
createdAt: row.created_at
|
|
254
275
|
};
|
|
255
276
|
}
|
|
277
|
+
function toPooledSandbox(row) {
|
|
278
|
+
return {
|
|
279
|
+
id: row.id,
|
|
280
|
+
orgId: row.org_id,
|
|
281
|
+
projectRepositoryId: row.project_repository_id,
|
|
282
|
+
userId: row.user_id,
|
|
283
|
+
sandboxId: row.sandbox_id,
|
|
284
|
+
sandboxWorkdir: row.sandbox_workdir,
|
|
285
|
+
releasedAt: row.released_at
|
|
286
|
+
};
|
|
287
|
+
}
|
|
256
288
|
function toWorktree(row) {
|
|
257
289
|
return {
|
|
258
290
|
id: row.id,
|
|
@@ -290,6 +322,7 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
290
322
|
async dangerouslyClearAll() {
|
|
291
323
|
await this.ops.deleteMany(SESSIONS, {});
|
|
292
324
|
await this.ops.deleteMany(WORKTREES, {});
|
|
325
|
+
await this.ops.deleteMany(SANDBOX_POOL, {});
|
|
293
326
|
await this.ops.deleteMany(SANDBOXES, {});
|
|
294
327
|
await this.ops.deleteMany(PROJECT_REPOSITORIES, {});
|
|
295
328
|
await this.ops.deleteMany(CONNECTIONS, {});
|
|
@@ -547,6 +580,7 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
547
580
|
for (const projectRepository of projectRepositories) {
|
|
548
581
|
await db().deleteMany(SESSIONS, { project_repository_id: projectRepository.id });
|
|
549
582
|
await db().deleteMany(WORKTREES, { project_repository_id: projectRepository.id });
|
|
583
|
+
await db().deleteMany(SANDBOX_POOL, { project_repository_id: projectRepository.id });
|
|
550
584
|
await db().deleteMany(SANDBOXES, { project_repository_id: projectRepository.id });
|
|
551
585
|
}
|
|
552
586
|
await db().deleteMany(PROJECT_REPOSITORIES, { connection_id: id });
|
|
@@ -665,6 +699,7 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
665
699
|
})) return false;
|
|
666
700
|
await db().deleteMany(SESSIONS, { project_repository_id: id });
|
|
667
701
|
await db().deleteMany(WORKTREES, { project_repository_id: id });
|
|
702
|
+
await db().deleteMany(SANDBOX_POOL, { project_repository_id: id });
|
|
668
703
|
await db().deleteMany(SANDBOXES, { project_repository_id: id });
|
|
669
704
|
await db().deleteMany(PROJECT_REPOSITORIES, { id });
|
|
670
705
|
return true;
|
|
@@ -718,6 +753,30 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
718
753
|
await db().updateMany(SANDBOXES, { id }, { materialized_at: /* @__PURE__ */ new Date() });
|
|
719
754
|
}
|
|
720
755
|
},
|
|
756
|
+
sandboxPool: {
|
|
757
|
+
release: async (input) => {
|
|
758
|
+
if (!await getProjectRepositoryById(input.projectRepositoryId)) return;
|
|
759
|
+
try {
|
|
760
|
+
await db().insertOne(SANDBOX_POOL, {
|
|
761
|
+
org_id: input.orgId,
|
|
762
|
+
project_repository_id: input.projectRepositoryId,
|
|
763
|
+
user_id: input.userId,
|
|
764
|
+
sandbox_id: input.sandboxId,
|
|
765
|
+
sandbox_workdir: input.sandboxWorkdir,
|
|
766
|
+
released_at: /* @__PURE__ */ new Date()
|
|
767
|
+
});
|
|
768
|
+
} catch (error) {
|
|
769
|
+
if (!(error instanceof UniqueViolationError)) throw error;
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
claim: async ({ projectRepositoryId }) => {
|
|
773
|
+
if (!await getProjectRepositoryById(projectRepositoryId)) return null;
|
|
774
|
+
const rows = await db().findMany(SANDBOX_POOL, { project_repository_id: projectRepositoryId });
|
|
775
|
+
rows.sort((left, right) => right.released_at.getTime() - left.released_at.getTime());
|
|
776
|
+
for (const row of rows) if (await db().deleteMany(SANDBOX_POOL, { id: row.id }) === 1) return toPooledSandbox(row);
|
|
777
|
+
return null;
|
|
778
|
+
}
|
|
779
|
+
},
|
|
721
780
|
worktrees: {
|
|
722
781
|
upsert: async (input) => {
|
|
723
782
|
await requireProjectRepositoryById(input.projectRepositoryId);
|