@mastra/factory 0.24.0-alpha.12 → 0.24.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +33 -4
- package/dist/factory.js.map +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +5 -2
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/routes/fs.d.ts +31 -23
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +214 -61
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/session-access.d.ts +55 -0
- package/dist/routes/session-access.d.ts.map +1 -0
- package/dist/routes/session-access.js +165 -0
- package/dist/routes/session-access.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +5 -0
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +86 -9
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +5 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +2 -2
- package/dist/routes/surface.js.map +1 -1
- package/dist/session/resource-migration.d.ts +18 -0
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js +33 -1
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/session-threads.d.ts +9 -0
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +24 -4
- package/dist/session/session-threads.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +15 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +29 -0
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +5 -1
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +7 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +1 -1
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/workspace.d.ts +5 -2
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +11 -1
- package/dist/workspace.js.map +1 -1
- package/package.json +8 -8
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAiC,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGlG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAkB,yBAAyB,EAAoB,MAAM,wBAAwB,CAAC;AAa1G,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKvE,OAAO,KAAK,EAAE,kBAAkB,EAAgD,MAAM,wBAAwB,CAAC;AAE/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAkBlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAiC,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGlG,OAAO,KAAK,E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EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuHD,qBAAa,aAAa;;gBAiBZ,MAAM,EAAE,mBAAmB;IAsBvC;;;;OAIG;IACH,IAAI,kBAAkB,IAAI,yBAAyB,GAAG,SAAS,CAI9D;IAED;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAq/CpC;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB/B,iFAAiF;IAC3E,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
package/dist/factory.js
CHANGED
|
@@ -19,6 +19,7 @@ import { recordFactoryPullRequestProvenance, resolveFactoryPullRequestParentWork
|
|
|
19
19
|
import { dismissStaleFactoryReviews } from "./integrations/github/stale-reviews.js";
|
|
20
20
|
import { PlatformApiClient, platformApiClientConfigFromEnv } from "./integrations/platform/api-client.js";
|
|
21
21
|
import { buildPlatformConnectRoutes } from "./integrations/platform/connect/routes.js";
|
|
22
|
+
import { createSessionAccessGuard } from "./routes/session-access.js";
|
|
22
23
|
import { observeSessionFirstExec } from "./session/first-exec-capture.js";
|
|
23
24
|
import { observeSessionFilesystem } from "./session/filesystem-capture.js";
|
|
24
25
|
import { sessionMemoryResourceId, sessionStampCounts } from "./session/session-threads.js";
|
|
@@ -71,7 +72,7 @@ import { hydrateSessionDefaultModel } from "./session/default-model-hydration.js
|
|
|
71
72
|
import { observeSessionFirstMessage } from "./session/first-message-capture.js";
|
|
72
73
|
import { LiveSessions } from "./session/live-sessions.js";
|
|
73
74
|
import { FactoryReplyCredentialProcessor } from "./session/reply-credential-processor.js";
|
|
74
|
-
import { migrateSessionResources } from "./session/resource-migration.js";
|
|
75
|
+
import { migrateSessionResources, privatizeOwnerResourceSessions } from "./session/resource-migration.js";
|
|
75
76
|
import { createSourceControlTools } from "./session/source-control-tools.js";
|
|
76
77
|
import { readFactoryThinkingLevel, resolveFactoryThinkingLevel } from "./session/thinking-default.js";
|
|
77
78
|
import { observeSessionThreadStamp } from "./session/thread-session-stamp.js";
|
|
@@ -226,6 +227,8 @@ var MastraFactory = class {
|
|
|
226
227
|
#factoryProcessor;
|
|
227
228
|
/** Environment builds through the sandbox's `builds`; undefined when the sandbox has none. */
|
|
228
229
|
#environmentBuilds;
|
|
230
|
+
/** The background session resource migration; resolves `true` when it moved run bindings. */
|
|
231
|
+
#sessionResourceMigration;
|
|
229
232
|
#preparing = false;
|
|
230
233
|
constructor(config) {
|
|
231
234
|
if (!config?.storage) throw new Error("MastraFactory: 'storage' is required. Pass a FactoryStorage backend — e.g. new PgFactoryStorage({ connectionString }) from '@mastra/pg' for deployments, or new LibSQLFactoryStorage({ url }) from '@mastra/libsql' for local dev.");
|
|
@@ -398,13 +401,13 @@ var MastraFactory = class {
|
|
|
398
401
|
});
|
|
399
402
|
const intakeReady = integrations.some((integration) => integration.intake !== void 0) && storage.isDomainReady("intake");
|
|
400
403
|
const factoryReady = storage.isDomainReady("projects") && storage.isDomainReady("work-items");
|
|
401
|
-
if (storage.isDomainReady("source-control") && storage.isDomainReady("work-items"))
|
|
404
|
+
if (storage.isDomainReady("source-control") && storage.isDomainReady("work-items")) this.#sessionResourceMigration = timedPhase("background.migrate.sessionResources", async () => {
|
|
402
405
|
try {
|
|
403
406
|
const mastraStorage = storage.getMastraStorage();
|
|
404
407
|
const memory = await mastraStorage.getStore("memory");
|
|
405
|
-
if (!memory) return;
|
|
408
|
+
if (!memory) return false;
|
|
406
409
|
const sessionMemory = getDynamicMemory(mastraStorage, vector);
|
|
407
|
-
await migrateSessionResources({
|
|
410
|
+
const report = await migrateSessionResources({
|
|
408
411
|
sessions: sourceControlStorage,
|
|
409
412
|
workItems: workItemsStorage,
|
|
410
413
|
...storage.isDomainReady("integrations") ? { integrations: integrationStorage } : {},
|
|
@@ -412,8 +415,15 @@ var MastraFactory = class {
|
|
|
412
415
|
threads: sessionMemory({ requestContext: new RequestContext() })
|
|
413
416
|
});
|
|
414
417
|
await sessionMemory.settled();
|
|
418
|
+
await privatizeOwnerResourceSessions({
|
|
419
|
+
sessions: sourceControlStorage,
|
|
420
|
+
workItems: workItemsStorage,
|
|
421
|
+
memory
|
|
422
|
+
});
|
|
423
|
+
return report.runBindings > 0;
|
|
415
424
|
} catch (error) {
|
|
416
425
|
console.warn(`[factory] session resource migration stopped early: ${error instanceof Error ? error.message : error}`);
|
|
426
|
+
return false;
|
|
417
427
|
}
|
|
418
428
|
});
|
|
419
429
|
const knowledgeEnabled = this.#config.knowledge !== void 0 || process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === "1";
|
|
@@ -1040,6 +1050,14 @@ var MastraFactory = class {
|
|
|
1040
1050
|
sandbox: sandboxConfig,
|
|
1041
1051
|
...environmentBuilds ? { onRepositoryPush: environmentBuilds.onRepositoryPush } : {},
|
|
1042
1052
|
sessionRetirement,
|
|
1053
|
+
moveThread: async ({ threadId, resourceId }) => {
|
|
1054
|
+
const sessionMemory = getDynamicMemory(storage.getMastraStorage(), vector);
|
|
1055
|
+
await sessionMemory({ requestContext: new RequestContext() }).updateThreadResourceId({
|
|
1056
|
+
threadId,
|
|
1057
|
+
resourceId
|
|
1058
|
+
});
|
|
1059
|
+
await sessionMemory.settled();
|
|
1060
|
+
},
|
|
1043
1061
|
factoryStorage: storage,
|
|
1044
1062
|
integrationStorage,
|
|
1045
1063
|
sourceControlStorage,
|
|
@@ -1146,6 +1164,16 @@ var MastraFactory = class {
|
|
|
1146
1164
|
middleware: [
|
|
1147
1165
|
...timing,
|
|
1148
1166
|
createFactoryAuthGate(auth),
|
|
1167
|
+
createSessionAccessGuard({
|
|
1168
|
+
auth: routeAuth,
|
|
1169
|
+
sessions: sourceControlSessions,
|
|
1170
|
+
projects: { get: async (args) => {
|
|
1171
|
+
if (!storage.isDomainReady("projects")) return null;
|
|
1172
|
+
await factoryProjectsStorage.ensureReady();
|
|
1173
|
+
return factoryProjectsStorage.get(args);
|
|
1174
|
+
} },
|
|
1175
|
+
controller: () => this.#prepared?.base.controller
|
|
1176
|
+
}),
|
|
1149
1177
|
createTenantCredentialPrimer({
|
|
1150
1178
|
auth: routeAuth,
|
|
1151
1179
|
credentials: modelCredentialsStorage
|
|
@@ -1271,6 +1299,7 @@ var MastraFactory = class {
|
|
|
1271
1299
|
await timedPhase("finalize.controller", () => this.#prepared.finalize());
|
|
1272
1300
|
await this.#environmentBuilds?.probeSchedules();
|
|
1273
1301
|
await timedPhase("finalize.reconcileBoundThreads", () => this.#factoryProcessor?.reconcileAllBoundThreads() ?? Promise.resolve());
|
|
1302
|
+
this.#sessionResourceMigration?.then((movedRunBindings) => movedRunBindings ? this.#factoryProcessor?.reconcileAllBoundThreads() : void 0).catch((error) => console.warn(`[factory] reconciling bound threads after the session resource migration failed: ${error instanceof Error ? error.message : error}`));
|
|
1274
1303
|
this.#dispatcher?.start();
|
|
1275
1304
|
}
|
|
1276
1305
|
/** Stop Factory-owned background dispatch before the host process shuts down. */
|