@decaf-ts/as-graph 0.2.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -2
- package/dist/as-graph.cjs +1 -1
- package/dist/as-graph.cjs.map +1 -1
- package/dist/as-graph.js +1 -1
- package/dist/as-graph.js.map +1 -1
- package/lib/cjs/dagster/DagsterGraphEventBridge.cjs +344 -0
- package/lib/cjs/dagster/DagsterGraphEventBridge.cjs.map +1 -0
- package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +789 -0
- package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -0
- package/lib/cjs/dagster/DagsterGraphQLClient.cjs +738 -0
- package/lib/cjs/dagster/DagsterGraphQLClient.cjs.map +1 -0
- package/lib/cjs/dagster/DagsterResultMapper.cjs +56 -0
- package/lib/cjs/dagster/DagsterResultMapper.cjs.map +1 -0
- package/lib/cjs/dagster/DagsterTypes.cjs +4 -0
- package/lib/cjs/dagster/DagsterTypes.cjs.map +1 -0
- package/lib/cjs/dagster/capabilities.cjs +102 -0
- package/lib/cjs/dagster/capabilities.cjs.map +1 -0
- package/lib/cjs/dagster/constants.cjs +92 -0
- package/lib/cjs/dagster/constants.cjs.map +1 -0
- package/lib/cjs/dagster/index.cjs +33 -0
- package/lib/cjs/dagster/index.cjs.map +1 -0
- package/lib/cjs/engine/constants.cjs +6 -1
- package/lib/cjs/engine/constants.cjs.map +1 -1
- package/lib/cjs/engine/execution/GraphCodeMode.cjs +137 -0
- package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -0
- package/lib/cjs/engine/execution/GraphExecutionBackend.cjs +89 -0
- package/lib/cjs/engine/execution/GraphExecutionBackend.cjs.map +1 -0
- package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs +107 -0
- package/lib/cjs/engine/execution/GraphExecutionBackendRegistry.cjs.map +1 -0
- package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +250 -733
- package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
- package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs +804 -0
- package/lib/cjs/engine/execution/LocalGraphExecutionBackend.cjs.map +1 -0
- package/lib/cjs/engine/execution/index.cjs +4 -0
- package/lib/cjs/engine/execution/index.cjs.map +1 -1
- package/lib/cjs/engine/index.cjs +4 -0
- package/lib/cjs/engine/index.cjs.map +1 -1
- package/lib/cjs/engine/runs/GraphRunService.cjs +61 -0
- package/lib/cjs/engine/runs/GraphRunService.cjs.map +1 -1
- package/lib/cjs/engine/services/GraphWorkflowService.cjs +33 -14
- package/lib/cjs/engine/services/GraphWorkflowService.cjs.map +1 -1
- package/lib/cjs/mastra/MastraCapabilities.cjs +171 -0
- package/lib/cjs/mastra/MastraCapabilities.cjs.map +1 -0
- package/lib/cjs/mastra/MastraConditionBridge.cjs +39 -0
- package/lib/cjs/mastra/MastraConditionBridge.cjs.map +1 -0
- package/lib/cjs/mastra/MastraEventBridge.cjs +486 -0
- package/lib/cjs/mastra/MastraEventBridge.cjs.map +1 -0
- package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs +351 -0
- package/lib/cjs/mastra/MastraGraphExecutionBackend.cjs.map +1 -0
- package/lib/cjs/mastra/MastraResumeGuard.cjs +127 -0
- package/lib/cjs/mastra/MastraResumeGuard.cjs.map +1 -0
- package/lib/cjs/mastra/MastraSchemaConverter.cjs +124 -0
- package/lib/cjs/mastra/MastraSchemaConverter.cjs.map +1 -0
- package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +461 -0
- package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -0
- package/lib/cjs/mastra/MastraWorkflowManager.cjs +401 -0
- package/lib/cjs/mastra/MastraWorkflowManager.cjs.map +1 -0
- package/lib/cjs/mastra/index.cjs +35 -0
- package/lib/cjs/mastra/index.cjs.map +1 -0
- package/lib/cjs/mastra/types.cjs +34 -0
- package/lib/cjs/mastra/types.cjs.map +1 -0
- package/lib/cjs/nest/graph/GraphBackendHost.cjs +146 -0
- package/lib/cjs/nest/graph/GraphBackendHost.cjs.map +1 -0
- package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs +136 -0
- package/lib/cjs/nest/graph/GraphEngineCapabilityManifest.cjs.map +1 -0
- package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs +140 -0
- package/lib/cjs/nest/graph/GraphEngineCapabilityService.cjs.map +1 -0
- package/lib/cjs/nest/graph/GraphEngineController.cjs +227 -0
- package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -0
- package/lib/cjs/nest/graph/GraphExecutionModule.cjs +31 -2
- package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
- package/lib/cjs/nest/graph/index.cjs +4 -0
- package/lib/cjs/nest/graph/index.cjs.map +1 -1
- package/lib/cjs/nest/graph/main.cjs +139 -0
- package/lib/cjs/nest/graph/main.cjs.map +1 -0
- package/lib/cjs/nest/graph/servingErrors.cjs +3 -0
- package/lib/cjs/nest/graph/servingErrors.cjs.map +1 -1
- package/lib/cjs/node/utility/code/node.cjs +11 -3
- package/lib/cjs/node/utility/code/node.cjs.map +1 -1
- package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs +2 -3
- package/lib/cjs/shared/graph/catalog/GraphManifestCompiler.cjs.map +1 -1
- package/lib/cjs/shared/graph/constants.cjs +8 -0
- package/lib/cjs/shared/graph/constants.cjs.map +1 -1
- package/lib/cjs/shared/graph/index.cjs +2 -1
- package/lib/cjs/shared/graph/index.cjs.map +1 -1
- package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs +146 -0
- package/lib/cjs/shared/graph/layout/GraphWorkflowLayout.cjs.map +1 -0
- package/lib/cjs/shared/graph/layout/index.cjs +23 -0
- package/lib/cjs/shared/graph/layout/index.cjs.map +1 -0
- package/lib/cjs/shared/graph/layout/layout-options.cjs +93 -0
- package/lib/cjs/shared/graph/layout/layout-options.cjs.map +1 -0
- package/lib/cjs/shared/ui/index.cjs +8 -10
- package/lib/cjs/shared/ui/index.cjs.map +1 -1
- package/lib/esm/dagster/DagsterGraphEventBridge.js +339 -0
- package/lib/esm/dagster/DagsterGraphEventBridge.js.map +1 -0
- package/lib/esm/dagster/DagsterGraphExecutionBackend.js +781 -0
- package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -0
- package/lib/esm/dagster/DagsterGraphQLClient.js +733 -0
- package/lib/esm/dagster/DagsterGraphQLClient.js.map +1 -0
- package/lib/esm/dagster/DagsterResultMapper.js +51 -0
- package/lib/esm/dagster/DagsterResultMapper.js.map +1 -0
- package/lib/esm/dagster/DagsterTypes.js +2 -0
- package/lib/esm/dagster/DagsterTypes.js.map +1 -0
- package/lib/esm/dagster/capabilities.js +97 -0
- package/lib/esm/dagster/capabilities.js.map +1 -0
- package/lib/esm/dagster/constants.js +88 -0
- package/lib/esm/dagster/constants.js.map +1 -0
- package/lib/esm/dagster/index.js +16 -0
- package/lib/esm/dagster/index.js.map +1 -0
- package/lib/esm/engine/constants.js +5 -0
- package/lib/esm/engine/constants.js.map +1 -1
- package/lib/esm/engine/execution/GraphCodeMode.js +132 -0
- package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -0
- package/lib/esm/engine/execution/GraphExecutionBackend.js +83 -0
- package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -0
- package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js +102 -0
- package/lib/esm/engine/execution/GraphExecutionBackendRegistry.js.map +1 -0
- package/lib/esm/engine/execution/GraphExecutionEngine.js +232 -716
- package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
- package/lib/esm/engine/execution/LocalGraphExecutionBackend.js +799 -0
- package/lib/esm/engine/execution/LocalGraphExecutionBackend.js.map +1 -0
- package/lib/esm/engine/execution/index.js +4 -0
- package/lib/esm/engine/execution/index.js.map +1 -1
- package/lib/esm/engine/index.js +4 -0
- package/lib/esm/engine/index.js.map +1 -1
- package/lib/esm/engine/runs/GraphRunService.js +62 -1
- package/lib/esm/engine/runs/GraphRunService.js.map +1 -1
- package/lib/esm/engine/services/GraphWorkflowService.js +33 -14
- package/lib/esm/engine/services/GraphWorkflowService.js.map +1 -1
- package/lib/esm/mastra/MastraCapabilities.js +164 -0
- package/lib/esm/mastra/MastraCapabilities.js.map +1 -0
- package/lib/esm/mastra/MastraConditionBridge.js +34 -0
- package/lib/esm/mastra/MastraConditionBridge.js.map +1 -0
- package/lib/esm/mastra/MastraEventBridge.js +481 -0
- package/lib/esm/mastra/MastraEventBridge.js.map +1 -0
- package/lib/esm/mastra/MastraGraphExecutionBackend.js +346 -0
- package/lib/esm/mastra/MastraGraphExecutionBackend.js.map +1 -0
- package/lib/esm/mastra/MastraResumeGuard.js +123 -0
- package/lib/esm/mastra/MastraResumeGuard.js.map +1 -0
- package/lib/esm/mastra/MastraSchemaConverter.js +119 -0
- package/lib/esm/mastra/MastraSchemaConverter.js.map +1 -0
- package/lib/esm/mastra/MastraWorkflowCompiler.js +456 -0
- package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -0
- package/lib/esm/mastra/MastraWorkflowManager.js +396 -0
- package/lib/esm/mastra/MastraWorkflowManager.js.map +1 -0
- package/lib/esm/mastra/index.js +18 -0
- package/lib/esm/mastra/index.js.map +1 -0
- package/lib/esm/mastra/types.js +30 -0
- package/lib/esm/mastra/types.js.map +1 -0
- package/lib/esm/nest/graph/GraphBackendHost.js +138 -0
- package/lib/esm/nest/graph/GraphBackendHost.js.map +1 -0
- package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js +129 -0
- package/lib/esm/nest/graph/GraphEngineCapabilityManifest.js.map +1 -0
- package/lib/esm/nest/graph/GraphEngineCapabilityService.js +131 -0
- package/lib/esm/nest/graph/GraphEngineCapabilityService.js.map +1 -0
- package/lib/esm/nest/graph/GraphEngineController.js +218 -0
- package/lib/esm/nest/graph/GraphEngineController.js.map +1 -0
- package/lib/esm/nest/graph/GraphExecutionModule.js +31 -2
- package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
- package/lib/esm/nest/graph/index.js +4 -0
- package/lib/esm/nest/graph/index.js.map +1 -1
- package/lib/esm/nest/graph/main.js +103 -0
- package/lib/esm/nest/graph/main.js.map +1 -0
- package/lib/esm/nest/graph/servingErrors.js +3 -0
- package/lib/esm/nest/graph/servingErrors.js.map +1 -1
- package/lib/esm/node/utility/code/node.js +11 -3
- package/lib/esm/node/utility/code/node.js.map +1 -1
- package/lib/esm/shared/graph/GraphExecutionStateMapper.js.map +1 -1
- package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js +2 -3
- package/lib/esm/shared/graph/catalog/GraphManifestCompiler.js.map +1 -1
- package/lib/esm/shared/graph/constants.js +8 -0
- package/lib/esm/shared/graph/constants.js.map +1 -1
- package/lib/esm/shared/graph/index.js +2 -1
- package/lib/esm/shared/graph/index.js.map +1 -1
- package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js +107 -0
- package/lib/esm/shared/graph/layout/GraphWorkflowLayout.js.map +1 -0
- package/lib/esm/shared/graph/layout/index.js +6 -0
- package/lib/esm/shared/graph/layout/index.js.map +1 -0
- package/lib/esm/shared/graph/layout/layout-options.js +96 -0
- package/lib/esm/shared/graph/layout/layout-options.js.map +1 -0
- package/lib/esm/shared/ui/index.js +8 -10
- package/lib/esm/shared/ui/index.js.map +1 -1
- package/lib/types/dagster/DagsterGraphEventBridge.d.cts +142 -0
- package/lib/types/dagster/DagsterGraphEventBridge.d.mts +142 -0
- package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +323 -0
- package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +323 -0
- package/lib/types/dagster/DagsterGraphQLClient.d.cts +231 -0
- package/lib/types/dagster/DagsterGraphQLClient.d.mts +231 -0
- package/lib/types/dagster/DagsterResultMapper.d.cts +50 -0
- package/lib/types/dagster/DagsterResultMapper.d.mts +50 -0
- package/lib/types/dagster/DagsterTypes.d.cts +355 -0
- package/lib/types/dagster/DagsterTypes.d.mts +355 -0
- package/lib/types/dagster/capabilities.d.cts +34 -0
- package/lib/types/dagster/capabilities.d.mts +34 -0
- package/lib/types/dagster/constants.d.cts +87 -0
- package/lib/types/dagster/constants.d.mts +87 -0
- package/lib/types/dagster/index.d.cts +15 -0
- package/lib/types/dagster/index.d.mts +15 -0
- package/lib/types/engine/constants.d.cts +5 -0
- package/lib/types/engine/constants.d.mts +5 -0
- package/lib/types/engine/execution/GraphCodeMode.d.cts +52 -0
- package/lib/types/engine/execution/GraphCodeMode.d.mts +52 -0
- package/lib/types/engine/execution/GraphExecutionBackend.d.cts +306 -0
- package/lib/types/engine/execution/GraphExecutionBackend.d.mts +306 -0
- package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.cts +59 -0
- package/lib/types/engine/execution/GraphExecutionBackendRegistry.d.mts +59 -0
- package/lib/types/engine/execution/GraphExecutionEngine.d.cts +116 -135
- package/lib/types/engine/execution/GraphExecutionEngine.d.mts +116 -135
- package/lib/types/engine/execution/LocalGraphExecutionBackend.d.cts +232 -0
- package/lib/types/engine/execution/LocalGraphExecutionBackend.d.mts +232 -0
- package/lib/types/engine/execution/index.d.cts +4 -0
- package/lib/types/engine/execution/index.d.mts +4 -0
- package/lib/types/engine/index.d.cts +4 -0
- package/lib/types/engine/index.d.mts +4 -0
- package/lib/types/engine/runs/GraphRunService.d.cts +19 -0
- package/lib/types/engine/runs/GraphRunService.d.mts +19 -0
- package/lib/types/engine/services/GraphWorkflowService.d.cts +22 -0
- package/lib/types/engine/services/GraphWorkflowService.d.mts +22 -0
- package/lib/types/mastra/MastraCapabilities.d.cts +86 -0
- package/lib/types/mastra/MastraCapabilities.d.mts +86 -0
- package/lib/types/mastra/MastraConditionBridge.d.cts +38 -0
- package/lib/types/mastra/MastraConditionBridge.d.mts +38 -0
- package/lib/types/mastra/MastraEventBridge.d.cts +189 -0
- package/lib/types/mastra/MastraEventBridge.d.mts +189 -0
- package/lib/types/mastra/MastraGraphExecutionBackend.d.cts +119 -0
- package/lib/types/mastra/MastraGraphExecutionBackend.d.mts +119 -0
- package/lib/types/mastra/MastraResumeGuard.d.cts +58 -0
- package/lib/types/mastra/MastraResumeGuard.d.mts +58 -0
- package/lib/types/mastra/MastraSchemaConverter.d.cts +39 -0
- package/lib/types/mastra/MastraSchemaConverter.d.mts +39 -0
- package/lib/types/mastra/MastraWorkflowCompiler.d.cts +218 -0
- package/lib/types/mastra/MastraWorkflowCompiler.d.mts +218 -0
- package/lib/types/mastra/MastraWorkflowManager.d.cts +220 -0
- package/lib/types/mastra/MastraWorkflowManager.d.mts +220 -0
- package/lib/types/mastra/index.d.cts +17 -0
- package/lib/types/mastra/index.d.mts +17 -0
- package/lib/types/mastra/types.d.cts +222 -0
- package/lib/types/mastra/types.d.mts +222 -0
- package/lib/types/nest/graph/GraphBackendHost.d.cts +100 -0
- package/lib/types/nest/graph/GraphBackendHost.d.mts +100 -0
- package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.cts +87 -0
- package/lib/types/nest/graph/GraphEngineCapabilityManifest.d.mts +87 -0
- package/lib/types/nest/graph/GraphEngineCapabilityService.d.cts +98 -0
- package/lib/types/nest/graph/GraphEngineCapabilityService.d.mts +98 -0
- package/lib/types/nest/graph/GraphEngineController.d.cts +74 -0
- package/lib/types/nest/graph/GraphEngineController.d.mts +74 -0
- package/lib/types/nest/graph/GraphExecutionModule.d.cts +20 -0
- package/lib/types/nest/graph/GraphExecutionModule.d.mts +20 -0
- package/lib/types/nest/graph/index.d.cts +4 -0
- package/lib/types/nest/graph/index.d.mts +4 -0
- package/lib/types/nest/graph/main.d.cts +1 -0
- package/lib/types/nest/graph/main.d.mts +1 -0
- package/lib/types/nest/graph/servingErrors.d.cts +3 -1
- package/lib/types/nest/graph/servingErrors.d.mts +3 -1
- package/lib/types/node/utility/code/node.d.cts +1 -1
- package/lib/types/node/utility/code/node.d.mts +1 -1
- package/lib/types/shared/graph/GraphExecutionStateMapper.d.cts +5 -5
- package/lib/types/shared/graph/GraphExecutionStateMapper.d.mts +5 -5
- package/lib/types/shared/graph/constants.d.cts +8 -0
- package/lib/types/shared/graph/constants.d.mts +8 -0
- package/lib/types/shared/graph/index.d.cts +2 -1
- package/lib/types/shared/graph/index.d.mts +2 -1
- package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.cts +49 -0
- package/lib/types/shared/graph/layout/GraphWorkflowLayout.d.mts +49 -0
- package/lib/types/shared/graph/layout/index.d.cts +5 -0
- package/lib/types/shared/graph/layout/index.d.mts +5 -0
- package/lib/types/shared/graph/layout/layout-options.d.cts +46 -0
- package/lib/types/shared/graph/layout/layout-options.d.mts +46 -0
- package/lib/types/shared/graph/types.d.cts +4 -3
- package/lib/types/shared/graph/types.d.mts +4 -3
- package/lib/types/shared/ui/index.d.cts +8 -10
- package/lib/types/shared/ui/index.d.mts +8 -10
- package/package.json +55 -6
- package/lib/cjs/shared/ui/GraphNodeView.cjs +0 -114
- package/lib/cjs/shared/ui/GraphNodeView.cjs.map +0 -1
- package/lib/cjs/shared/ui/GraphRunView.cjs +0 -96
- package/lib/cjs/shared/ui/GraphRunView.cjs.map +0 -1
- package/lib/cjs/shared/ui/GraphWorkflowView.cjs +0 -78
- package/lib/cjs/shared/ui/GraphWorkflowView.cjs.map +0 -1
- package/lib/cjs/shared/ui/types.cjs +0 -4
- package/lib/cjs/shared/ui/types.cjs.map +0 -1
- package/lib/esm/shared/ui/GraphNodeView.js +0 -107
- package/lib/esm/shared/ui/GraphNodeView.js.map +0 -1
- package/lib/esm/shared/ui/GraphRunView.js +0 -90
- package/lib/esm/shared/ui/GraphRunView.js.map +0 -1
- package/lib/esm/shared/ui/GraphWorkflowView.js +0 -72
- package/lib/esm/shared/ui/GraphWorkflowView.js.map +0 -1
- package/lib/esm/shared/ui/types.js +0 -2
- package/lib/esm/shared/ui/types.js.map +0 -1
- package/lib/types/shared/ui/GraphNodeView.d.cts +0 -48
- package/lib/types/shared/ui/GraphNodeView.d.mts +0 -48
- package/lib/types/shared/ui/GraphRunView.d.cts +0 -88
- package/lib/types/shared/ui/GraphRunView.d.mts +0 -88
- package/lib/types/shared/ui/GraphWorkflowView.d.cts +0 -18
- package/lib/types/shared/ui/GraphWorkflowView.d.mts +0 -18
- package/lib/types/shared/ui/types.d.cts +0 -200
- package/lib/types/shared/ui/types.d.mts +0 -200
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { NotFoundError } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { GraphExecutionEventType, GraphExecutionStatus } from "./../shared/graph/constants.js";
|
|
3
|
+
import { GraphExecutionBackendRegistry } from "./../engine/execution/GraphExecutionBackendRegistry.js";
|
|
4
|
+
import { canAccessGraphResource } from "./../engine/runs/ownership.js";
|
|
5
|
+
import { graphWorkflowOwnerOf } from "./../engine/services/GraphWorkflowService.js";
|
|
6
|
+
import { GraphExecutionError } from "./../engine/errors/GraphExecutionError.js";
|
|
7
|
+
import { graphRunDocumentFingerprint } from "./../engine/runs/GraphRunFingerprint.js";
|
|
8
|
+
import { buildGraphExecutionResult } from "./../engine/execution/GraphExecutionResult.js";
|
|
9
|
+
import { MastraWorkflowCompiler } from "./MastraWorkflowCompiler.js";
|
|
10
|
+
import { MastraWorkflowManager } from "./MastraWorkflowManager.js";
|
|
11
|
+
import { MastraEventBridge } from "./MastraEventBridge.js";
|
|
12
|
+
import { assertMastraResumeAllowed } from "./MastraResumeGuard.js";
|
|
13
|
+
import { assertMastraResumeSchemaSafe } from "./MastraSchemaConverter.js";
|
|
14
|
+
import { resolveMastraCapabilities, } from "./MastraCapabilities.js";
|
|
15
|
+
import { GRAPH_MASTRA_AGENT_UNAVAILABLE, GRAPH_MASTRA_UNSUPPORTED_KIND, MASTRA_BACKEND_FLAVOUR, } from "./types.js";
|
|
16
|
+
const DEFAULT_MAX_RESUME_BYTES = 64 * 1024;
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Structural check for a Decaf execution {@link Context} inside a
|
|
22
|
+
* {@link MaybeContextualArg} argument list. Mirrors `@decaf-ts/core`'s own
|
|
23
|
+
* `isContextLike` realm-safe duck-typing (multiple linked core builds defeat
|
|
24
|
+
* `instanceof`).
|
|
25
|
+
*
|
|
26
|
+
* @param value - A candidate argument.
|
|
27
|
+
* @returns `true` when the value is a Decaf execution context.
|
|
28
|
+
*/
|
|
29
|
+
function isMastraContextLike(value) {
|
|
30
|
+
if (!value || typeof value !== "object")
|
|
31
|
+
return false;
|
|
32
|
+
const candidate = value;
|
|
33
|
+
return (typeof candidate.get === "function" &&
|
|
34
|
+
typeof candidate.accumulate === "function" &&
|
|
35
|
+
typeof candidate.override === "function" &&
|
|
36
|
+
typeof candidate.toOverrides === "function" &&
|
|
37
|
+
candidate.cache !== undefined);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves the caller owner from the forwarded contextual arguments (C23). The
|
|
41
|
+
* catalogue methods receive the same `...args` the facade forwards to every
|
|
42
|
+
* backend; the trailing context, when present, carries the authenticated principal
|
|
43
|
+
* the service layer resolves with {@link graphWorkflowOwnerOf}.
|
|
44
|
+
*
|
|
45
|
+
* @param args - The forwarded contextual arguments.
|
|
46
|
+
* @returns The caller owner, or `undefined` for owner-less callers.
|
|
47
|
+
*/
|
|
48
|
+
function mastraCallerOwnerOf(args) {
|
|
49
|
+
for (let index = args.length - 1; index >= 0; index -= 1) {
|
|
50
|
+
const candidate = args[index];
|
|
51
|
+
if (isMastraContextLike(candidate)) {
|
|
52
|
+
return graphWorkflowOwnerOf(candidate);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* `@mastra/core`-translated execution backend (SAA-196). Translates the
|
|
59
|
+
* canonical document into a Mastra workflow, runs it through the injected Mastra
|
|
60
|
+
* runtime, bridges Mastra's `fullStream` onto the facade event sink, and enforces
|
|
61
|
+
* the SAA-193 resume guard conditions. Code-mode surfaces are not executed:
|
|
62
|
+
* `codeMode` is `unsupported`, so the facade fails closed before delegating.
|
|
63
|
+
*/
|
|
64
|
+
export class MastraGraphExecutionBackend {
|
|
65
|
+
constructor() {
|
|
66
|
+
/** Translated backend: never executes in-process. */
|
|
67
|
+
this.local = false;
|
|
68
|
+
/** Code-mode surfaces are rejected by the facade gate (C3). */
|
|
69
|
+
this.codeMode = "unsupported";
|
|
70
|
+
this.compiler = new MastraWorkflowCompiler();
|
|
71
|
+
this.documents = new Map();
|
|
72
|
+
this.runWorkflows = new Map();
|
|
73
|
+
this.maxResumeBytes = DEFAULT_MAX_RESUME_BYTES;
|
|
74
|
+
this.initialized = false;
|
|
75
|
+
GraphExecutionBackendRegistry.register(MASTRA_BACKEND_FLAVOUR, this);
|
|
76
|
+
}
|
|
77
|
+
async initialize(config) {
|
|
78
|
+
this._config = config;
|
|
79
|
+
this.runtime = config.mastra;
|
|
80
|
+
// Re-initializing rewires the runtime/compiler, so a previously cached
|
|
81
|
+
// management surface must not survive the rebind (C7).
|
|
82
|
+
this.managementManager = undefined;
|
|
83
|
+
this.suspendStateReader = config.suspendStateReader;
|
|
84
|
+
if (typeof config.maxResumeBytes === "number" && config.maxResumeBytes > 0) {
|
|
85
|
+
this.maxResumeBytes = config.maxResumeBytes;
|
|
86
|
+
}
|
|
87
|
+
const stepHandlers = Array.isArray(config.stepHandlers)
|
|
88
|
+
? [...config.stepHandlers]
|
|
89
|
+
: [];
|
|
90
|
+
this.compiler = new MastraWorkflowCompiler({ stepHandlers });
|
|
91
|
+
this.initialized = true;
|
|
92
|
+
}
|
|
93
|
+
get capabilities() {
|
|
94
|
+
return resolveMastraCapabilities();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The workflow-management surface over the wired real `@mastra/core` runtime
|
|
98
|
+
* (SAA-346). The manager translates canonical documents through the same
|
|
99
|
+
* compiler the backend executes with, so a created/updated workflow is the one
|
|
100
|
+
* `execute` runs. Every operation fails closed when the wired runtime exposes
|
|
101
|
+
* no real Mastra method.
|
|
102
|
+
*/
|
|
103
|
+
get management() {
|
|
104
|
+
// Cache the manager per backend (C7): revisions recorded at `create` must
|
|
105
|
+
// survive the next `management` access, otherwise `get`/`serialize` silently
|
|
106
|
+
// drop the wrapper-tracked revision.
|
|
107
|
+
if (!this.managementManager) {
|
|
108
|
+
this.managementManager = new MastraWorkflowManager({
|
|
109
|
+
runtime: this.runtime,
|
|
110
|
+
compiler: this.compiler,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return this.managementManager;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Lists the translated workflows visible to the requesting caller (C23). The
|
|
117
|
+
* catalogue is ownership-filtered with the same
|
|
118
|
+
* {@link canAccessGraphResource} predicate the service layer uses: a document
|
|
119
|
+
* executed by a named owner is visible only to that owner, an owner-less
|
|
120
|
+
* document stays visible to every caller, and an anonymous caller sees only
|
|
121
|
+
* owner-less documents. The caller owner is resolved from the forwarded
|
|
122
|
+
* contextual arguments; a missing context denies foreign-owner rows.
|
|
123
|
+
*
|
|
124
|
+
* @param args - Optional decaf contextual arguments carrying the caller principal.
|
|
125
|
+
* @returns Workflow summaries visible to the caller.
|
|
126
|
+
*/
|
|
127
|
+
async listWorkflows(...args) {
|
|
128
|
+
const callerOwner = mastraCallerOwnerOf(args);
|
|
129
|
+
return [...this.documents.values()]
|
|
130
|
+
.filter((entry) => canAccessGraphResource({ owner: entry.owner }, callerOwner))
|
|
131
|
+
.map((entry) => ({
|
|
132
|
+
id: entry.document.id,
|
|
133
|
+
...(entry.document.name ? { name: entry.document.name } : {}),
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Reads a single translated workflow document, enforcing the C23 ownership
|
|
138
|
+
* predicate. An unknown id and a foreign-owner id both fail closed: an unknown
|
|
139
|
+
* id keeps the backend's existing translated-catalogue error, and a foreign-owner
|
|
140
|
+
* id is denied with a constant `NotFoundError` that maps to `404` and never
|
|
141
|
+
* carries `GraphExecutionError.details`, so a foreign caller cannot read
|
|
142
|
+
* another owner's canonical document.
|
|
143
|
+
*
|
|
144
|
+
* @param workflowId - The canonical workflow id to read.
|
|
145
|
+
* @param args - Optional decaf contextual arguments carrying the caller principal.
|
|
146
|
+
* @returns The canonical workflow document.
|
|
147
|
+
* @throws {GraphExecutionError} when no translated workflow exists for the id.
|
|
148
|
+
* @throws {NotFoundError} when the workflow is owned by another user.
|
|
149
|
+
*/
|
|
150
|
+
async getWorkflow(workflowId, ...args) {
|
|
151
|
+
const callerOwner = mastraCallerOwnerOf(args);
|
|
152
|
+
const entry = this.documents.get(workflowId);
|
|
153
|
+
if (!entry) {
|
|
154
|
+
throw new GraphExecutionError(`Mastra backend has no translated workflow '${workflowId}'`, GRAPH_MASTRA_UNSUPPORTED_KIND, { workflowId });
|
|
155
|
+
}
|
|
156
|
+
if (!canAccessGraphResource({ owner: entry.owner }, callerOwner)) {
|
|
157
|
+
throw new NotFoundError(`No graph workflow found for workflowId '${workflowId}'`);
|
|
158
|
+
}
|
|
159
|
+
return entry.document;
|
|
160
|
+
}
|
|
161
|
+
async execute(request, ...args) {
|
|
162
|
+
const sink = request.events;
|
|
163
|
+
const frame = sink.frame;
|
|
164
|
+
if (!frame) {
|
|
165
|
+
throw new GraphExecutionError("MastraGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine", GRAPH_MASTRA_UNSUPPORTED_KIND, { workflowId: request.document.id });
|
|
166
|
+
}
|
|
167
|
+
const runId = frame.runId;
|
|
168
|
+
const owner = this.callerOwnerOf(request, args);
|
|
169
|
+
this.documents.set(request.document.id, {
|
|
170
|
+
document: request.document,
|
|
171
|
+
...(owner ? { owner } : {}),
|
|
172
|
+
});
|
|
173
|
+
this.runWorkflows.set(runId, request.document.id);
|
|
174
|
+
const compiled = this.compiler.compile(request.document);
|
|
175
|
+
const workflow = compiled.workflow;
|
|
176
|
+
if (typeof workflow.createRun !== "function") {
|
|
177
|
+
throw new GraphExecutionError("Mastra backend received a workflow without a createRun method", GRAPH_MASTRA_AGENT_UNAVAILABLE, { workflowId: request.document.id });
|
|
178
|
+
}
|
|
179
|
+
const bridge = new MastraEventBridge({
|
|
180
|
+
runId,
|
|
181
|
+
parentRunId: request.options.parentRunId,
|
|
182
|
+
workflowId: request.document.id,
|
|
183
|
+
document: request.document,
|
|
184
|
+
sink,
|
|
185
|
+
path: [],
|
|
186
|
+
});
|
|
187
|
+
let status = GraphExecutionStatus.SUCCEEDED;
|
|
188
|
+
try {
|
|
189
|
+
const run = await workflow.createRun({ runId });
|
|
190
|
+
const stream = await run.stream({ inputData: request.inputs });
|
|
191
|
+
if (stream.fullStream) {
|
|
192
|
+
await bridge.attach(stream.fullStream);
|
|
193
|
+
}
|
|
194
|
+
if (typeof run.getResult === "function") {
|
|
195
|
+
await run.getResult();
|
|
196
|
+
}
|
|
197
|
+
else if (stream.result) {
|
|
198
|
+
await stream.result;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
status = GraphExecutionStatus.FAILED;
|
|
203
|
+
await sink.emit({
|
|
204
|
+
type: GraphExecutionEventType.WORKFLOW_FAILED,
|
|
205
|
+
status,
|
|
206
|
+
error: this.errorPayload(error),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
frame.finish();
|
|
210
|
+
return buildGraphExecutionResult(frame, request.document, request.inputs, status, { backend: MASTRA_BACKEND_FLAVOUR, documentFingerprint: compiled.fingerprint });
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Resumes a suspended Mastra run after enforcing the SAA-193 resume guard
|
|
214
|
+
* (C13/C15/C16/C17/C18). The Mastra run snapshot is authoritative for the
|
|
215
|
+
* suspended state; the current document fingerprint must match the snapshot
|
|
216
|
+
* (C17). Returns the C18 audit record, never the raw `resumeData`.
|
|
217
|
+
*/
|
|
218
|
+
async resume(runId, request, ..._args) {
|
|
219
|
+
const reader = this.suspendStateReader;
|
|
220
|
+
if (!reader) {
|
|
221
|
+
throw new GraphExecutionError("Mastra backend has no suspendStateReader configured; resume is not available", GRAPH_MASTRA_UNSUPPORTED_KIND, { runId });
|
|
222
|
+
}
|
|
223
|
+
const snapshot = await reader.readRunState(runId, ..._args);
|
|
224
|
+
if (!snapshot) {
|
|
225
|
+
throw new GraphExecutionError(`Mastra backend has no suspended snapshot for run '${runId}'`, "GRAPH_MASTRA_RESUME_STATE_INVALID", { runId });
|
|
226
|
+
}
|
|
227
|
+
const document = this.documents.get(snapshot.workflowId)?.document;
|
|
228
|
+
if (!document) {
|
|
229
|
+
throw new GraphExecutionError(`Mastra backend has no translated workflow '${snapshot.workflowId}'`, "GRAPH_MASTRA_RESUME_STATE_INVALID", { runId, workflowId: snapshot.workflowId });
|
|
230
|
+
}
|
|
231
|
+
const allowlistedSteps = snapshot.suspendedSteps;
|
|
232
|
+
const suspendedStep = request.step ?? snapshot.suspendedSteps[0] ?? "";
|
|
233
|
+
const suspendedNode = (document.nodes ?? []).find((node) => node.id === suspendedStep);
|
|
234
|
+
const declaredResumeSchema = suspendedNode?.parameters?.["resumeSchema"];
|
|
235
|
+
const resumeSchema = declaredResumeSchema
|
|
236
|
+
? assertMastraResumeSchemaSafe(declaredResumeSchema)
|
|
237
|
+
: undefined;
|
|
238
|
+
const audit = assertMastraResumeAllowed(request, {
|
|
239
|
+
runId,
|
|
240
|
+
workflowId: snapshot.workflowId,
|
|
241
|
+
documentFingerprint: snapshot.documentFingerprint,
|
|
242
|
+
status: snapshot.status,
|
|
243
|
+
step: request.step ?? snapshot.suspendedSteps[0] ?? "",
|
|
244
|
+
forEachIndex: request.forEachIndex ??
|
|
245
|
+
snapshot.suspendedForEachIndexes?.[request.step ?? snapshot.suspendedSteps[0] ?? ""],
|
|
246
|
+
state: snapshot,
|
|
247
|
+
}, {
|
|
248
|
+
maxResumeBytes: this.maxResumeBytes,
|
|
249
|
+
allowlistedSteps,
|
|
250
|
+
documentFingerprint: graphRunDocumentFingerprint(document),
|
|
251
|
+
...(resumeSchema ? { resumeSchema } : {}),
|
|
252
|
+
});
|
|
253
|
+
const run = await this.loadRun(runId);
|
|
254
|
+
if (!run || typeof run.resume !== "function") {
|
|
255
|
+
throw new GraphExecutionError(`Mastra backend cannot resume run '${runId}': no resumable run handle`, GRAPH_MASTRA_UNSUPPORTED_KIND, { runId });
|
|
256
|
+
}
|
|
257
|
+
await run.resume({
|
|
258
|
+
step: audit.step,
|
|
259
|
+
resumeData: request.resumeData,
|
|
260
|
+
...(audit.forEachIndex !== undefined
|
|
261
|
+
? { forEachIndex: audit.forEachIndex }
|
|
262
|
+
: {}),
|
|
263
|
+
});
|
|
264
|
+
return audit;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Resolves the owner recorded for a run (C23). The facade-resolved principal
|
|
268
|
+
* bound onto `options.auth` is authoritative; when absent (a direct backend call)
|
|
269
|
+
* the owner is resolved from the forwarded contextual arguments. Returns
|
|
270
|
+
* `undefined` for owner-less runs, matching the service-layer owner-less
|
|
271
|
+
* visibility rule.
|
|
272
|
+
*
|
|
273
|
+
* @param request - The execution request carrying the facade-resolved options.
|
|
274
|
+
* @param args - The forwarded contextual arguments.
|
|
275
|
+
* @returns The run's owner, or `undefined` when owner-less.
|
|
276
|
+
*/
|
|
277
|
+
callerOwnerOf(request, args) {
|
|
278
|
+
const authUser = request.options?.auth?.user;
|
|
279
|
+
if (typeof authUser === "string" && authUser.length > 0) {
|
|
280
|
+
return authUser;
|
|
281
|
+
}
|
|
282
|
+
return mastraCallerOwnerOf(args);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Releases the per-run catalogue state (C23). Removes the run's workflow
|
|
286
|
+
* association and drops the translated document once no other live run still
|
|
287
|
+
* references it, so the process-lifetime catalogue cannot grow unbounded and
|
|
288
|
+
* widen the BOLA surface over time.
|
|
289
|
+
*
|
|
290
|
+
* @param runId - The completed run whose resources are released.
|
|
291
|
+
*/
|
|
292
|
+
async release(runId) {
|
|
293
|
+
const workflowId = this.runWorkflows.get(runId);
|
|
294
|
+
if (workflowId === undefined)
|
|
295
|
+
return;
|
|
296
|
+
this.runWorkflows.delete(runId);
|
|
297
|
+
const stillReferenced = [...this.runWorkflows.values()].includes(workflowId);
|
|
298
|
+
if (!stillReferenced) {
|
|
299
|
+
this.documents.delete(workflowId);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async dispose() {
|
|
303
|
+
this.compiler.clear();
|
|
304
|
+
this.documents.clear();
|
|
305
|
+
this.runWorkflows.clear();
|
|
306
|
+
this.runtime = undefined;
|
|
307
|
+
this.managementManager = undefined;
|
|
308
|
+
this.initialized = false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The configuration most recently resolved by {@link initialize}. Exposed so
|
|
312
|
+
* `GraphExecutionEngine.initialize` can merge its facade-owned collaborators
|
|
313
|
+
* over the host's keys (`mastra`, `stepHandlers`, `suspendStateReader`, ...)
|
|
314
|
+
* instead of dropping them when it re-initializes the backend at boot.
|
|
315
|
+
*/
|
|
316
|
+
get config() {
|
|
317
|
+
return this._config;
|
|
318
|
+
}
|
|
319
|
+
/** Whether {@link initialize} has resolved. */
|
|
320
|
+
get ready() {
|
|
321
|
+
return this.initialized;
|
|
322
|
+
}
|
|
323
|
+
async loadRun(runId) {
|
|
324
|
+
const runtime = this.runtime;
|
|
325
|
+
if (!isRecord(runtime))
|
|
326
|
+
return undefined;
|
|
327
|
+
const getRun = runtime["getRun"];
|
|
328
|
+
if (typeof getRun !== "function")
|
|
329
|
+
return undefined;
|
|
330
|
+
const run = await getRun.call(runtime, runId);
|
|
331
|
+
return isRecord(run) ? run : undefined;
|
|
332
|
+
}
|
|
333
|
+
errorPayload(error) {
|
|
334
|
+
if (error instanceof Error) {
|
|
335
|
+
return {
|
|
336
|
+
name: error.name,
|
|
337
|
+
message: error.message,
|
|
338
|
+
...(typeof error.code === "string"
|
|
339
|
+
? { code: error.code }
|
|
340
|
+
: {}),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return { name: "MastraError", message: String(error) };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
//# sourceMappingURL=MastraGraphExecutionBackend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MastraGraphExecutionBackend.js","sourceRoot":"","sources":["../../../src/mastra/MastraGraphExecutionBackend.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,uCAAkC;AAO1F,OAAO,EAAE,6BAA6B,EAAE,+DAA0D;AAClG,OAAO,EAAE,sBAAsB,EAAE,sCAAiC;AAClE,OAAO,EAAE,oBAAoB,EAAE,qDAAgD;AAE/E,OAAO,EAAE,mBAAmB,EAAE,kDAA6C;AAC3E,OAAO,EAAE,2BAA2B,EAAE,gDAA2C;AACjF,OAAO,EAAE,yBAAyB,EAAE,sDAAiD;AACrF,OAAO,EAAE,sBAAsB,EAAE,oCAAiC;AAClE,OAAO,EAAE,qBAAqB,EAAE,mCAAgC;AAChE,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AACxD,OAAO,EAAE,yBAAyB,EAAE,+BAA4B;AAChE,OAAO,EAAE,4BAA4B,EAAE,mCAAgC;AACvE,OAAO,EACL,yBAAyB,GAE1B,gCAA6B;AAC9B,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,sBAAsB,GAMvB,mBAAgB;AAEjB,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,CAAC;AAY3C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAiBD;;;;;;;;GAQG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,O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SAAS,CAAC;QACzC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,OAAO,MAAM,KAAK,UAAU;YAAE,OAAO,SAAS,CAAC;QACnD,MAAM,GAAG,GAAG,MAAO,MAAkC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,GAAgC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,CAAC;IAEO,YAAY,CAAC,KAAc;QAKjC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,CAAC,OAAQ,KAAuC,CAAC,IAAI,KAAK,QAAQ;oBACnE,CAAC,CAAC,EAAE,IAAI,EAAG,KAAqC,CAAC,IAAI,EAAE;oBACvD,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module as-graph/mastra/MastraResumeGuard
|
|
3
|
+
* @summary Untrusted-resume validation for the Mastra backend (SAA-193
|
|
4
|
+
* C13/C15/C16/C17/C18).
|
|
5
|
+
* @description Every resume request is validated against the Mastra-authoritative
|
|
6
|
+
* snapshot of the suspended run and the current document fingerprint before any
|
|
7
|
+
* state is handed back to Mastra. Rejections carry specific error codes and the
|
|
8
|
+
* returned audit record carries only identity and provenance — the raw
|
|
9
|
+
* `resumeData` is never logged or echoed.
|
|
10
|
+
*/
|
|
11
|
+
import { GraphExecutionError } from "./../engine/errors/GraphExecutionError.js";
|
|
12
|
+
import { isGraphJsonSafeValue } from "./../shared/graph/document/GraphJsonValue.js";
|
|
13
|
+
import { GRAPH_MASTRA_RESUME_INVALID, GRAPH_MASTRA_RESUME_STATE_INVALID, GRAPH_MASTRA_RESUME_STEP_UNKNOWN, } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Measures the serialised byte size of a value, treating non-serialisable
|
|
16
|
+
* values as unbounded.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to measure.
|
|
19
|
+
* @returns The serialised size in bytes, or infinity when not serialisable.
|
|
20
|
+
*/
|
|
21
|
+
function serializedSize(value) {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
return 0;
|
|
24
|
+
try {
|
|
25
|
+
return new TextEncoder().encode(JSON.stringify(value)).length;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return Number.POSITIVE_INFINITY;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Computes a stable, non-reversible FNV-1a hash of a value for the C18 audit
|
|
33
|
+
* record; the raw value is never logged.
|
|
34
|
+
*
|
|
35
|
+
* @param value - The value to hash.
|
|
36
|
+
* @returns The `fnv1a` hash string with the serialised length.
|
|
37
|
+
*/
|
|
38
|
+
function stableHash(value) {
|
|
39
|
+
const text = JSON.stringify(value ?? null);
|
|
40
|
+
let hash = 0x811c9dc5;
|
|
41
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
42
|
+
hash ^= text.charCodeAt(index);
|
|
43
|
+
hash = Math.imul(hash, 0x01000193);
|
|
44
|
+
}
|
|
45
|
+
return `fnv1a:${(hash >>> 0).toString(16).padStart(8, "0")}:${text.length}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validates an untrusted resume request against the Mastra-authoritative
|
|
49
|
+
* snapshot and the current document, enforcing C13/C15/C16/C17 before any state
|
|
50
|
+
* is handed back to Mastra. On success it returns the C18 audit record; the raw
|
|
51
|
+
* `resumeData` is never logged or echoed.
|
|
52
|
+
*
|
|
53
|
+
* @param request - The untrusted resume request to validate.
|
|
54
|
+
* @param snapshot - The Mastra-authoritative suspended-run snapshot.
|
|
55
|
+
* @param options - Document-derived validation options (byte cap, allowlist,
|
|
56
|
+
* fingerprint, and the suspended step's resume schema).
|
|
57
|
+
* @returns The C18 audit record for the accepted resume.
|
|
58
|
+
* @throws {GraphExecutionError} `GRAPH_MASTRA_RESUME_INVALID` for non-JSON-safe or
|
|
59
|
+
* oversized `resumeData`; `GRAPH_MASTRA_RESUME_STEP_UNKNOWN` when the suspended
|
|
60
|
+
* step or iteration is not allowlisted; `GRAPH_MASTRA_RESUME_STATE_INVALID`
|
|
61
|
+
* when the snapshot is not suspended or its fingerprint does not match.
|
|
62
|
+
*/
|
|
63
|
+
export function assertMastraResumeAllowed(request, snapshot, options) {
|
|
64
|
+
if (!request || typeof request !== "object") {
|
|
65
|
+
throw new GraphExecutionError("Mastra resume request must be an object", GRAPH_MASTRA_RESUME_INVALID, { runId: snapshot.runId });
|
|
66
|
+
}
|
|
67
|
+
const size = serializedSize(request.resumeData);
|
|
68
|
+
if (size > options.maxResumeBytes || !isGraphJsonSafeValue(request.resumeData)) {
|
|
69
|
+
throw new GraphExecutionError("Mastra resume data is not JSON-safe or exceeds the byte cap", GRAPH_MASTRA_RESUME_INVALID, {
|
|
70
|
+
runId: snapshot.runId,
|
|
71
|
+
step: snapshot.step,
|
|
72
|
+
size,
|
|
73
|
+
maxBytes: options.maxResumeBytes,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (options.resumeSchema &&
|
|
77
|
+
!options.resumeSchema.safeParse(request.resumeData).success) {
|
|
78
|
+
throw new GraphExecutionError("Mastra resume data does not satisfy the suspended step's resume schema", GRAPH_MASTRA_RESUME_INVALID, { runId: snapshot.runId, step: snapshot.step });
|
|
79
|
+
}
|
|
80
|
+
const allowlisted = new Set(options.allowlistedSteps);
|
|
81
|
+
if (!allowlisted.has(snapshot.step)) {
|
|
82
|
+
throw new GraphExecutionError(`Mastra resume step '${snapshot.step}' is not resumable in the current document`, GRAPH_MASTRA_RESUME_STEP_UNKNOWN, { runId: snapshot.runId, step: snapshot.step });
|
|
83
|
+
}
|
|
84
|
+
const step = request.step ?? snapshot.step;
|
|
85
|
+
if (step !== snapshot.step || !allowlisted.has(step)) {
|
|
86
|
+
throw new GraphExecutionError(`Mastra resume step '${String(step)}' does not match the suspended step`, GRAPH_MASTRA_RESUME_STEP_UNKNOWN, { runId: snapshot.runId, step, suspendedStep: snapshot.step });
|
|
87
|
+
}
|
|
88
|
+
const forEachIndex = request.forEachIndex;
|
|
89
|
+
if (forEachIndex !== undefined) {
|
|
90
|
+
if (!Number.isInteger(forEachIndex) ||
|
|
91
|
+
forEachIndex < 0 ||
|
|
92
|
+
(typeof snapshot.forEachCount === "number" &&
|
|
93
|
+
forEachIndex >= snapshot.forEachCount)) {
|
|
94
|
+
throw new GraphExecutionError("Mastra resume iteration index is out of range", GRAPH_MASTRA_RESUME_STEP_UNKNOWN, {
|
|
95
|
+
runId: snapshot.runId,
|
|
96
|
+
step: snapshot.step,
|
|
97
|
+
forEachIndex,
|
|
98
|
+
forEachCount: snapshot.forEachCount,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (snapshot.status !== "suspended" ||
|
|
103
|
+
snapshot.documentFingerprint !== options.documentFingerprint ||
|
|
104
|
+
snapshot.state === undefined ||
|
|
105
|
+
snapshot.state === null) {
|
|
106
|
+
throw new GraphExecutionError("Mastra resume snapshot is not a suspended run of the current document", GRAPH_MASTRA_RESUME_STATE_INVALID, {
|
|
107
|
+
runId: snapshot.runId,
|
|
108
|
+
status: snapshot.status,
|
|
109
|
+
snapshotFingerprint: snapshot.documentFingerprint,
|
|
110
|
+
documentFingerprint: options.documentFingerprint,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
runId: snapshot.runId,
|
|
115
|
+
workflowId: snapshot.workflowId,
|
|
116
|
+
step: snapshot.step,
|
|
117
|
+
forEachIndex,
|
|
118
|
+
resumeDataHash: stableHash(request.resumeData),
|
|
119
|
+
resumeDataBytes: size,
|
|
120
|
+
at: new Date().toISOString(),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=MastraResumeGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MastraResumeGuard.js","sourceRoot":"","sources":["../../../src/mastra/MastraResumeGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,mBAAmB,EAAE,kDAA6C;AAC3E,OAAO,EAAE,oBAAoB,EAAE,qDAAgD;AAC/E,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,EACjC,gCAAgC,GAGjC,mBAAgB;AAwCjB;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC;QACH,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,iBAAiB,CAAC;IAClC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CA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S;QAC5B,QAAQ,CAAC,KAAK,KAAK,IAAI,EACvB,CAAC;QACD,MAAM,IAAI,mBAAmB,CAC3B,uEAAuE,EACvE,iCAAiC,EACjC;YACE,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;YACjD,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SACjD,CACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,YAAY;QACZ,cAAc,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;QAC9C,eAAe,EAAE,IAAI;QACrB,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module as-graph/mastra/MastraSchemaConverter
|
|
3
|
+
* @summary Converts canonical {@link GraphValueSchema} declarations into Zod
|
|
4
|
+
* schemas for the Mastra backend (SAA-196).
|
|
5
|
+
* @description Mastra workflows are built on Zod schemas. The converter maps
|
|
6
|
+
* every canonical schema shape to its closest Zod equivalent, tracking whether
|
|
7
|
+
* the conversion degraded (or collapsed to `any`), so suspendable steps can be
|
|
8
|
+
* required to declare a strict, non-degraded resume schema before translation.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { GraphExecutionError } from "./../engine/errors/GraphExecutionError.js";
|
|
12
|
+
import { GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Recursively converts one canonical schema node into a Zod schema.
|
|
15
|
+
*
|
|
16
|
+
* @param schema - The canonical schema node to convert.
|
|
17
|
+
* @returns The conversion result with its degradation flags.
|
|
18
|
+
*/
|
|
19
|
+
function convertValue(schema) {
|
|
20
|
+
switch (schema.type) {
|
|
21
|
+
case "string":
|
|
22
|
+
return { schema: z.string(), degraded: false, any: false };
|
|
23
|
+
case "number": {
|
|
24
|
+
let value = z.number();
|
|
25
|
+
if (schema.integer === true)
|
|
26
|
+
value = value.int();
|
|
27
|
+
if (schema.min !== undefined)
|
|
28
|
+
value = value.min(schema.min);
|
|
29
|
+
if (schema.max !== undefined)
|
|
30
|
+
value = value.max(schema.max);
|
|
31
|
+
return { schema: value, degraded: false, any: false };
|
|
32
|
+
}
|
|
33
|
+
case "boolean":
|
|
34
|
+
return { schema: z.boolean(), degraded: false, any: false };
|
|
35
|
+
case "array": {
|
|
36
|
+
const items = convertValue(schema.items);
|
|
37
|
+
let value = z.array(items.schema);
|
|
38
|
+
if (schema.minItems !== undefined)
|
|
39
|
+
value = value.min(schema.minItems);
|
|
40
|
+
if (schema.maxItems !== undefined)
|
|
41
|
+
value = value.max(schema.maxItems);
|
|
42
|
+
return { schema: value, degraded: items.degraded, any: false };
|
|
43
|
+
}
|
|
44
|
+
case "object": {
|
|
45
|
+
const shape = {};
|
|
46
|
+
let degraded = false;
|
|
47
|
+
for (const [key, property] of Object.entries(schema.properties ?? {})) {
|
|
48
|
+
const converted = convertValue(property);
|
|
49
|
+
shape[key] = converted.schema;
|
|
50
|
+
degraded = degraded || converted.degraded;
|
|
51
|
+
}
|
|
52
|
+
let value = z.object(shape);
|
|
53
|
+
if (schema.additionalProperties === true) {
|
|
54
|
+
value = value.catchall(z.any());
|
|
55
|
+
}
|
|
56
|
+
return { schema: value, degraded, any: false };
|
|
57
|
+
}
|
|
58
|
+
case "enum": {
|
|
59
|
+
const values = schema.values ?? [];
|
|
60
|
+
if (values.length === 0) {
|
|
61
|
+
return { schema: z.any(), degraded: true, any: true };
|
|
62
|
+
}
|
|
63
|
+
if (values.every((entry) => typeof entry === "string")) {
|
|
64
|
+
return {
|
|
65
|
+
schema: z.enum(values),
|
|
66
|
+
degraded: false,
|
|
67
|
+
any: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const literals = values.map((entry) => z.literal(entry));
|
|
71
|
+
const union = literals.length === 1 ? literals[0] : z.union(literals);
|
|
72
|
+
return { schema: union, degraded: false, any: false };
|
|
73
|
+
}
|
|
74
|
+
case "model": {
|
|
75
|
+
const shape = {};
|
|
76
|
+
let degraded = false;
|
|
77
|
+
for (const [key, property] of Object.entries(schema.properties ?? {})) {
|
|
78
|
+
const converted = convertValue(property);
|
|
79
|
+
shape[key] = converted.schema;
|
|
80
|
+
degraded = degraded || converted.degraded;
|
|
81
|
+
}
|
|
82
|
+
return { schema: z.object(shape), degraded, any: false };
|
|
83
|
+
}
|
|
84
|
+
case "any":
|
|
85
|
+
default:
|
|
86
|
+
return { schema: z.any(), degraded: true, any: true };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts a canonical schema (or the absence of one) into a Zod schema.
|
|
91
|
+
* A missing schema converts to a degraded `any` schema.
|
|
92
|
+
*
|
|
93
|
+
* @param schema - The canonical schema to convert, if declared.
|
|
94
|
+
* @returns The conversion result with its degradation flags.
|
|
95
|
+
*/
|
|
96
|
+
export function toMastraZodSchema(schema) {
|
|
97
|
+
if (!schema) {
|
|
98
|
+
return { schema: z.any(), degraded: true, any: true };
|
|
99
|
+
}
|
|
100
|
+
return convertValue(schema);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Requires that a suspendable Mastra step declares a strict resume schema: the
|
|
104
|
+
* conversion must be neither degraded nor collapsed to `any`, otherwise resume
|
|
105
|
+
* payloads could not be validated (C15).
|
|
106
|
+
*
|
|
107
|
+
* @param schema - The declared resume schema of the suspended step.
|
|
108
|
+
* @returns The validated Zod resume schema.
|
|
109
|
+
* @throws {GraphExecutionError} {@link GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE} when
|
|
110
|
+
* the schema is missing, degraded, or collapsed to `any`.
|
|
111
|
+
*/
|
|
112
|
+
export function assertMastraResumeSchemaSafe(schema) {
|
|
113
|
+
const converted = toMastraZodSchema(schema);
|
|
114
|
+
if (converted.any || converted.degraded) {
|
|
115
|
+
throw new GraphExecutionError("A suspendable Mastra step requires a declared, non-degraded resume schema", GRAPH_MASTRA_RESUME_SCHEMA_UNSAFE);
|
|
116
|
+
}
|
|
117
|
+
return converted.schema;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=MastraSchemaConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MastraSchemaConverter.js","sourceRoot":"","sources":["../../../src/mastra/MastraSchemaConverter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,kDAA6C;AAC3E,OAAO,EAAE,iCAAiC,EAAE,mBAAgB;AAY5D;;;;;GAKG;AACH,SAAS,YAAY,CAAC,MAAwB;IAC5C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAC7D,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACvB,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI;gBAAE,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YACjD,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS;gBAAE,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5D,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS;gBAAE,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5D,OAAO,EAAE,MA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