@x12i/graphenix-execute-envelope 1.0.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 +175 -0
- package/dist/adapter/build-graph-execution-request-from-studio-execute.d.ts +6 -0
- package/dist/adapter/build-graph-execution-request-from-studio-execute.d.ts.map +1 -0
- package/dist/adapter/build-graph-execution-request-from-studio-execute.js +38 -0
- package/dist/adapter/build-graph-execution-request-from-studio-execute.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/validators/validate-runtime-object.d.ts +10 -0
- package/dist/validators/validate-runtime-object.d.ts.map +1 -0
- package/dist/validators/validate-runtime-object.js +59 -0
- package/dist/validators/validate-runtime-object.js.map +1 -0
- package/dist/validators/validate-studio-execute-request.d.ts +5 -0
- package/dist/validators/validate-studio-execute-request.d.ts.map +1 -0
- package/dist/validators/validate-studio-execute-request.js +33 -0
- package/dist/validators/validate-studio-execute-request.js.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# @x12i/graphenix-execute-envelope
|
|
2
|
+
|
|
3
|
+
**Execute request envelope** — host-level adaptation for graph execution requests.
|
|
4
|
+
|
|
5
|
+
Validates incoming execute requests, builds the runtime object (excluding credentials), compiles the authoring graph into a plan, and returns `{ plan, runtime }` for the engine.
|
|
6
|
+
|
|
7
|
+
Optional package: engines and compilers do not need it; backend hosts and API gateways do.
|
|
8
|
+
|
|
9
|
+
**Finalization brief:** [EXECUTE-TRACE-FORMAT-FINALIZATION.md](../../docs/EXECUTE-TRACE-FORMAT-FINALIZATION.md) · compile: [COMPILE-FORMAT-FINALIZATION.md](../../docs/COMPILE-FORMAT-FINALIZATION.md).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Who should use this
|
|
14
|
+
|
|
15
|
+
| Role | Use this package? |
|
|
16
|
+
| ---- | ----------------- |
|
|
17
|
+
| Backend host / API gateway / Studio backend | **Yes** |
|
|
18
|
+
| Compiler service (already owns compile) | Usually **No** |
|
|
19
|
+
| Engine | **No** |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Lifecycle position
|
|
24
|
+
|
|
25
|
+
```txt
|
|
26
|
+
Studio execute request (authoring + input)
|
|
27
|
+
│ validateStudioExecuteRequest()
|
|
28
|
+
│ buildRuntimeObject()
|
|
29
|
+
│ compileExecutablePlan()
|
|
30
|
+
│ validateExecutablePlan()
|
|
31
|
+
▼
|
|
32
|
+
{ plan, runtime } → engine
|
|
33
|
+
│
|
|
34
|
+
▼
|
|
35
|
+
GraphExecutionTrace (@x12i/graphenix-trace-format)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Reference authoring: `createContentPipelineReferenceGraph()` — `graph:content-pipeline`.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @x12i/graphenix-execute-envelope
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Examples (JSON)
|
|
51
|
+
|
|
52
|
+
### Studio execute request (shape)
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"authoringGraph": { "id": "graph:content-pipeline", "formatVersion": "2.0.0", "graph": {} },
|
|
57
|
+
"input": {
|
|
58
|
+
"brief": "Launch campaign for eco-friendly water bottles",
|
|
59
|
+
"priority": "normal"
|
|
60
|
+
},
|
|
61
|
+
"options": {
|
|
62
|
+
"jobId": "job-001",
|
|
63
|
+
"mode": "live",
|
|
64
|
+
"environment": "prod"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Credentials stay on the request boundary — never copied into `GraphRuntimeObject`.
|
|
70
|
+
|
|
71
|
+
### Runtime object (compile input)
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"jobId": "job-001",
|
|
76
|
+
"mode": "live",
|
|
77
|
+
"environment": "prod",
|
|
78
|
+
"input": {
|
|
79
|
+
"brief": "Launch campaign for eco-friendly water bottles",
|
|
80
|
+
"priority": "normal"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Compile output handoff
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"plan": {
|
|
90
|
+
"format": "graphenix.executable-plan/v2",
|
|
91
|
+
"source": { "graphId": "graph:content-pipeline" },
|
|
92
|
+
"nodePlans": {
|
|
93
|
+
"node:audience-insights": {
|
|
94
|
+
"executionUnits": [
|
|
95
|
+
{ "unitKind": "externalPreUtility", "order": 0, "strategyKey": "synthesis" },
|
|
96
|
+
{ "unitKind": "mainSkill", "order": 1, "skillKey": "professional-answer" }
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"runtime": { "jobId": "job-001", "mode": "live", "input": { "priority": "normal" } }
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Embedded normalized graph in the plan has **no** `node.layout` — stripped at compile.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Example (API)
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { buildGraphExecutionRequestFromStudioExecute } from "@x12i/graphenix-execute-envelope";
|
|
113
|
+
|
|
114
|
+
const { plan, runtime } = buildGraphExecutionRequestFromStudioExecute(request);
|
|
115
|
+
// forward to engine — engine never sees the raw Studio request
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Lower-level building blocks
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import {
|
|
122
|
+
validateStudioExecuteRequest,
|
|
123
|
+
buildRuntimeObject,
|
|
124
|
+
validateRuntimeObject
|
|
125
|
+
} from "@x12i/graphenix-execute-envelope";
|
|
126
|
+
import { compileExecutablePlan } from "@x12i/graphenix-plan-compiler";
|
|
127
|
+
import { validateExecutablePlan } from "@x12i/graphenix-plan-format";
|
|
128
|
+
|
|
129
|
+
validateStudioExecuteRequest(request);
|
|
130
|
+
const runtime = buildRuntimeObject(request.input, request.options);
|
|
131
|
+
validateRuntimeObject(runtime);
|
|
132
|
+
|
|
133
|
+
const plan = compileExecutablePlan(request.authoringGraph, runtime);
|
|
134
|
+
validateExecutablePlan(plan);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Key exports
|
|
140
|
+
|
|
141
|
+
| API | Purpose |
|
|
142
|
+
| --- | ------- |
|
|
143
|
+
| `buildGraphExecutionRequestFromStudioExecute` | Full pipeline: validate → runtime → compile → validate plan |
|
|
144
|
+
| `validateStudioExecuteRequest` | Request envelope validation |
|
|
145
|
+
| `buildRuntimeObject` | Build `GraphRuntimeObject` from host input |
|
|
146
|
+
| `validateRuntimeObject` | Runtime shape + forbidden fields |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Security rules
|
|
151
|
+
|
|
152
|
+
- Credentials are **never** copied into the runtime object
|
|
153
|
+
- Request-level forbidden fields (e.g. `graphDefaultModel` in runtime) are rejected
|
|
154
|
+
- Runtime must not carry authoring-only config like `modelConfig`
|
|
155
|
+
- Engine receives only `{ plan, runtime }` — no Studio envelope, no API keys in runtime
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Dependencies
|
|
160
|
+
|
|
161
|
+
- `@x12i/graphenix-authoring-format` ^1.0.0
|
|
162
|
+
- `@x12i/graphenix-plan-compiler` ^1.0.0
|
|
163
|
+
- `@x12i/graphenix-plan-format` ^1.0.0
|
|
164
|
+
- `@x12i/graphenix-executable-contracts` ^1.0.0
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Related packages
|
|
169
|
+
|
|
170
|
+
| Package | Role |
|
|
171
|
+
| ------- | ---- |
|
|
172
|
+
| [`@x12i/graphenix-plan-compiler`](../plan-compiler) | Compilation step |
|
|
173
|
+
| [`@x12i/graphenix-trace-format`](../trace-format) | Run evidence after engine executes |
|
|
174
|
+
| [backend-host role guide](../../docs/roles/backend-host.md) | Client guide |
|
|
175
|
+
| [`@x12i/graphenix-executable-format`](../executable-format) | Umbrella that re-exports this package |
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GraphExecutionRequest, StudioGraphExecuteRequest } from "@x12i/graphenix-executable-contracts";
|
|
2
|
+
export declare function buildGraphExecutionRequestFromStudioExecute(request: StudioGraphExecuteRequest, options?: {
|
|
3
|
+
agentId?: string;
|
|
4
|
+
jobTypeId?: string;
|
|
5
|
+
}): GraphExecutionRequest;
|
|
6
|
+
//# sourceMappingURL=build-graph-execution-request-from-studio-execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-graph-execution-request-from-studio-execute.d.ts","sourceRoot":"","sources":["../../src/adapter/build-graph-execution-request-from-studio-execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAM9C,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,yBAAyB,EAClC,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,qBAAqB,CAyCvB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { validateStudioExecuteRequest } from "../validators/validate-studio-execute-request.js";
|
|
2
|
+
import { buildRuntimeObject } from "../validators/validate-runtime-object.js";
|
|
3
|
+
import { compileExecutablePlan } from "@x12i/graphenix-plan-compiler";
|
|
4
|
+
import { validateExecutablePlan } from "@x12i/graphenix-plan-format";
|
|
5
|
+
export function buildGraphExecutionRequestFromStudioExecute(request, options = {}) {
|
|
6
|
+
const validation = validateStudioExecuteRequest(request);
|
|
7
|
+
if (!validation.valid) {
|
|
8
|
+
const summary = validation.errors
|
|
9
|
+
.map((error) => `${error.path}: ${error.message}`)
|
|
10
|
+
.join("; ");
|
|
11
|
+
throw new Error(`Invalid studio execute request: ${summary}`);
|
|
12
|
+
}
|
|
13
|
+
const runtime = buildRuntimeObject({
|
|
14
|
+
jobId: request.jobId,
|
|
15
|
+
input: request.runtime?.input,
|
|
16
|
+
mode: request.graphExecution?.mode ?? request.runtime?.mode,
|
|
17
|
+
runLogMode: request.runLogMode ?? request.runtime?.runLogMode,
|
|
18
|
+
maxRunLogEntries: request.maxRunLogEntries ?? request.runtime?.maxRunLogEntries,
|
|
19
|
+
maxRunLogDataJsonChars: request.maxRunLogDataJsonChars ??
|
|
20
|
+
request.runtime?.maxRunLogDataJsonChars,
|
|
21
|
+
runTaskDiagnostics: request.runTaskDiagnostics ?? request.runtime?.runTaskDiagnostics,
|
|
22
|
+
variables: request.runtime?.variables,
|
|
23
|
+
job: request.runtime?.job
|
|
24
|
+
}, options);
|
|
25
|
+
const plan = compileExecutablePlan(request.graph, runtime);
|
|
26
|
+
const planValidation = validateExecutablePlan(plan);
|
|
27
|
+
if (!planValidation.valid) {
|
|
28
|
+
const summary = planValidation.errors
|
|
29
|
+
.map((error) => `${error.path}: ${error.message}`)
|
|
30
|
+
.join("; ");
|
|
31
|
+
throw new Error(`Invalid executable plan: ${summary}`);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
plan,
|
|
35
|
+
runtime
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=build-graph-execution-request-from-studio-execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-graph-execution-request-from-studio-execute.js","sourceRoot":"","sources":["../../src/adapter/build-graph-execution-request-from-studio-execute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,C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;IAEF,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM;aAClC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;aACjD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO;QACL,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { validateStudioExecuteRequest } from "./validators/validate-studio-execute-request.js";
|
|
2
|
+
export { validateRuntimeObject, buildRuntimeObject } from "./validators/validate-runtime-object.js";
|
|
3
|
+
export { buildGraphExecutionRequestFromStudioExecute } from "./adapter/build-graph-execution-request-from-studio-execute.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,2CAA2C,EAAE,MAAM,gEAAgE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { validateStudioExecuteRequest } from "./validators/validate-studio-execute-request.js";
|
|
2
|
+
export { validateRuntimeObject, buildRuntimeObject } from "./validators/validate-runtime-object.js";
|
|
3
|
+
export { buildGraphExecutionRequestFromStudioExecute } from "./adapter/build-graph-execution-request-from-studio-execute.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,2CAA2C,EAAE,MAAM,gEAAgE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecutableGraphValidationResult } from "@x12i/graphenix-executable-contracts";
|
|
2
|
+
import type { GraphRuntimeObject } from "@x12i/graphenix-executable-contracts";
|
|
3
|
+
export declare function validateRuntimeObject(runtime: unknown): ExecutableGraphValidationResult;
|
|
4
|
+
export declare function buildRuntimeObject(partial: Partial<GraphRuntimeObject> & {
|
|
5
|
+
jobId: string;
|
|
6
|
+
}, options?: {
|
|
7
|
+
agentId?: string;
|
|
8
|
+
jobTypeId?: string;
|
|
9
|
+
}): GraphRuntimeObject;
|
|
10
|
+
//# sourceMappingURL=validate-runtime-object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-runtime-object.d.ts","sourceRoot":"","sources":["../../src/validators/validate-runtime-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAY/E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,+BAA+B,CAoEjC;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACxD,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,kBAAkB,CAiBpB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { execError, isRecord } from "@x12i/graphenix-executable-contracts";
|
|
2
|
+
const FORBIDDEN_RUNTIME_FIELDS = [
|
|
3
|
+
"modelConfig",
|
|
4
|
+
"graphDefaultModel",
|
|
5
|
+
"preActionModel",
|
|
6
|
+
"skillModel",
|
|
7
|
+
"postActionModel",
|
|
8
|
+
"credentials"
|
|
9
|
+
];
|
|
10
|
+
export function validateRuntimeObject(runtime) {
|
|
11
|
+
const errors = [];
|
|
12
|
+
if (!isRecord(runtime)) {
|
|
13
|
+
return {
|
|
14
|
+
valid: false,
|
|
15
|
+
errors: [
|
|
16
|
+
execError("RUNTIME_OBJECT_INVALID", "Runtime must be an object.", "")
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (typeof runtime.jobId !== "string" || runtime.jobId.length === 0) {
|
|
21
|
+
errors.push(execError("RUNTIME_OBJECT_INVALID", "runtime.jobId is required.", "/jobId"));
|
|
22
|
+
}
|
|
23
|
+
if (!isRecord(runtime.job)) {
|
|
24
|
+
errors.push(execError("RUNTIME_OBJECT_INVALID", "runtime.job is required.", "/job"));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (typeof runtime.job.id !== "string") {
|
|
28
|
+
errors.push(execError("RUNTIME_OBJECT_INVALID", "runtime.job.id is required.", "/job/id"));
|
|
29
|
+
}
|
|
30
|
+
if (typeof runtime.job.jobId !== "string") {
|
|
31
|
+
errors.push(execError("RUNTIME_OBJECT_INVALID", "runtime.job.jobId is required.", "/job/jobId"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const field of FORBIDDEN_RUNTIME_FIELDS) {
|
|
35
|
+
if (field in runtime) {
|
|
36
|
+
errors.push(execError("RUNTIME_OBJECT_INVALID", `Runtime must not contain ${field}.`, `/${field}`));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { valid: errors.length === 0, errors };
|
|
40
|
+
}
|
|
41
|
+
export function buildRuntimeObject(partial, options = {}) {
|
|
42
|
+
return {
|
|
43
|
+
jobId: partial.jobId,
|
|
44
|
+
job: {
|
|
45
|
+
id: partial.job?.id ?? partial.jobId,
|
|
46
|
+
jobId: partial.job?.jobId ?? partial.jobId,
|
|
47
|
+
agentId: partial.job?.agentId ?? options.agentId,
|
|
48
|
+
jobTypeId: partial.job?.jobTypeId ?? options.jobTypeId
|
|
49
|
+
},
|
|
50
|
+
input: partial.input,
|
|
51
|
+
mode: partial.mode,
|
|
52
|
+
runLogMode: partial.runLogMode,
|
|
53
|
+
maxRunLogEntries: partial.maxRunLogEntries,
|
|
54
|
+
maxRunLogDataJsonChars: partial.maxRunLogDataJsonChars,
|
|
55
|
+
runTaskDiagnostics: partial.runTaskDiagnostics,
|
|
56
|
+
variables: partial.variables
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=validate-runtime-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-runtime-object.js","sourceRoot":"","sources":["../../src/validators/validate-runtime-object.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAE3E,MAAM,wBAAwB,GAAG;IAC/B,aAAa;IACb,mBAAmB;IACnB,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;IACjB,aAAa;CACL,CAAC;AAEX,MAAM,UAAU,qBAAqB,CACnC,OAAgB;IAEhB,MAAM,MAAM,GAAqC,EAAE,CAAC;IAEpD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN,SAAS,CACP,wBAAwB,EACxB,4BAA4B,EAC5B,EAAE,CACH;aACF;SACF,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OA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AE,IAAI,OAAO,CAAC,KAAK;YACpC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,IAAI,OAAO,CAAC,KAAK;YAC1C,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,IAAI,OAAO,CAAC,OAAO;YAChD,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,IAAI,OAAO,CAAC,SAAS;SACvD;QACD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;QACtD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecutableGraphValidationResult } from "@x12i/graphenix-executable-contracts";
|
|
2
|
+
import type { StudioGraphExecuteRequest } from "@x12i/graphenix-executable-contracts";
|
|
3
|
+
export declare function validateStudioExecuteRequest(request: unknown): ExecutableGraphValidationResult;
|
|
4
|
+
export declare function isStudioGraphExecuteRequest(value: unknown): value is StudioGraphExecuteRequest;
|
|
5
|
+
//# sourceMappingURL=validate-studio-execute-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-studio-execute-request.d.ts","sourceRoot":"","sources":["../../src/validators/validate-studio-execute-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAItF,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,OAAO,GACf,+BAA+B,CA6DjC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,yBAAyB,CAEpC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { execError, isRecord } from "@x12i/graphenix-executable-contracts";
|
|
2
|
+
import { validateExecutableGraph } from "@x12i/graphenix-authoring-format";
|
|
3
|
+
export function validateStudioExecuteRequest(request) {
|
|
4
|
+
const errors = [];
|
|
5
|
+
if (!isRecord(request)) {
|
|
6
|
+
return {
|
|
7
|
+
valid: false,
|
|
8
|
+
errors: [
|
|
9
|
+
execError("STUDIO_EXECUTE_REQUEST_INVALID", "Studio execute request must be an object.", "")
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (request.mode !== "graph") {
|
|
14
|
+
errors.push(execError("STUDIO_EXECUTE_REQUEST_INVALID", "Studio execute request mode must be graph.", "/mode"));
|
|
15
|
+
}
|
|
16
|
+
if (typeof request.jobId !== "string" || request.jobId.length === 0) {
|
|
17
|
+
errors.push(execError("STUDIO_EXECUTE_REQUEST_INVALID", "Studio execute request jobId is required.", "/jobId"));
|
|
18
|
+
}
|
|
19
|
+
if ("graphDefaultModel" in request) {
|
|
20
|
+
errors.push(execError("STUDIO_GRAPH_DEFAULT_MODEL_FORBIDDEN", "graphDefaultModel is forbidden; use graph.metadata.extensions executable profile modelConfig.", "/graphDefaultModel"));
|
|
21
|
+
}
|
|
22
|
+
if (request.graph === undefined) {
|
|
23
|
+
errors.push(execError("STUDIO_EXECUTE_REQUEST_INVALID", "Studio execute request graph is required.", "/graph"));
|
|
24
|
+
return { valid: false, errors };
|
|
25
|
+
}
|
|
26
|
+
const graphResult = validateExecutableGraph(request.graph);
|
|
27
|
+
errors.push(...graphResult.errors);
|
|
28
|
+
return { valid: errors.length === 0, errors };
|
|
29
|
+
}
|
|
30
|
+
export function isStudioGraphExecuteRequest(value) {
|
|
31
|
+
return validateStudioExecuteRequest(value).valid;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=validate-studio-execute-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-studio-execute-request.js","sourceRoot":"","sources":["../../src/validators/validate-studio-execute-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,MAAM,UAAU,4BAA4B,CAC1C,OAAgB;IAEhB,MAAM,MAAM,GAAqC,EAAE,CAAC;IAEpD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE;gBACN,SAAS,CACP,gCAAgC,EAChC,2CAA2C,EAC3C,EAAE,CACH;aACF;SACF,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CACT,SAAS,CACP,gCAAgC,EAChC,4CAA4C,EAC5C,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,IAAI,CACT,SAAS,CACP,gCAAgC,EAChC,2CAA2C,EAC3C,QAAQ,CACT,CACF,CAAC;IACJ,CAAC;IAED,IAAI,mBAAmB,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,CACT,SAAS,CACP,sCAAsC,EACtC,+FAA+F,EAC/F,oBAAoB,CACrB,CACF,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CACT,SAAS,CACP,gCAAgC,EAChC,2CAA2C,EAC3C,QAAQ,CACT,CACF,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,WAAW,GAAG,uBAAuB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x12i/graphenix-execute-envelope",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Execute request envelope: runtime building and graph execution request adaptation.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"clean": "rimraf dist"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"graph",
|
|
26
|
+
"graphenix",
|
|
27
|
+
"execute",
|
|
28
|
+
"envelope"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/x12i/graphenix-format.git",
|
|
33
|
+
"directory": "packages/execute-envelope"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/x12i/graphenix-format/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/x12i/graphenix-format/tree/master/packages/execute-envelope#readme",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"registry": "https://registry.npmjs.org/"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@x12i/graphenix-authoring-format": "^1.0.0",
|
|
45
|
+
"@x12i/graphenix-executable-contracts": "^1.0.0",
|
|
46
|
+
"@x12i/graphenix-plan-compiler": "^1.0.0",
|
|
47
|
+
"@x12i/graphenix-plan-format": "^1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^22.10.1",
|
|
51
|
+
"rimraf": "^6.0.1",
|
|
52
|
+
"typescript": "^5.6.3"
|
|
53
|
+
}
|
|
54
|
+
}
|