@executioncontrolprotocol/format-reactflow 0.12.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 +24 -0
- package/dist/extension.d.ts +3 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +94 -0
- package/dist/extension.js.map +1 -0
- package/dist/extract-data-edges.d.ts +17 -0
- package/dist/extract-data-edges.d.ts.map +1 -0
- package/dist/extract-data-edges.js +95 -0
- package/dist/extract-data-edges.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/io-from-schema.d.ts +36 -0
- package/dist/io-from-schema.d.ts.map +1 -0
- package/dist/io-from-schema.js +136 -0
- package/dist/io-from-schema.js.map +1 -0
- package/dist/layout.d.ts +7 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +67 -0
- package/dist/layout.js.map +1 -0
- package/dist/ports-from-zod.d.ts +28 -0
- package/dist/ports-from-zod.d.ts.map +1 -0
- package/dist/ports-from-zod.js +169 -0
- package/dist/ports-from-zod.js.map +1 -0
- package/dist/progress.d.ts +19 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +23 -0
- package/dist/progress.js.map +1 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/value-schema-hint.d.ts +31 -0
- package/dist/value-schema-hint.d.ts.map +1 -0
- package/dist/value-schema-hint.js +156 -0
- package/dist/value-schema-hint.js.map +1 -0
- package/dist/workflow-to-reactflow.d.ts +11 -0
- package/dist/workflow-to-reactflow.d.ts.map +1 -0
- package/dist/workflow-to-reactflow.js +207 -0
- package/dist/workflow-to-reactflow.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { introspectCapabilitySchema } from "@executioncontrolprotocol/core";
|
|
2
|
+
import { parseStateRef } from "./extract-data-edges.js";
|
|
3
|
+
import { valueSchemaFromEqlLabel, valueSchemasFromCapabilitySchema, } from "./value-schema-hint.js";
|
|
4
|
+
const LITERAL_PREVIEW_MAX = 56;
|
|
5
|
+
function typeLabelFor(eqlTypes, name, required) {
|
|
6
|
+
const raw = eqlTypes?.[name];
|
|
7
|
+
if (raw)
|
|
8
|
+
return raw;
|
|
9
|
+
return required ? "unknown!" : "unknown";
|
|
10
|
+
}
|
|
11
|
+
function attachValueSchema(port, schemas, typeLabel) {
|
|
12
|
+
const fromCap = schemas.get(port.name);
|
|
13
|
+
if (fromCap) {
|
|
14
|
+
port.valueSchema = fromCap;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const fromLabel = valueSchemaFromEqlLabel(typeLabel);
|
|
18
|
+
if (fromLabel)
|
|
19
|
+
port.valueSchema = fromLabel;
|
|
20
|
+
}
|
|
21
|
+
function isRefValue(value) {
|
|
22
|
+
return (typeof value === "object" &&
|
|
23
|
+
value !== null &&
|
|
24
|
+
"$ref" in value &&
|
|
25
|
+
typeof value.$ref === "string");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compact string form of a literal input value (for previews / editors).
|
|
29
|
+
* @category Encoding
|
|
30
|
+
*/
|
|
31
|
+
export function formatLiteralValue(value) {
|
|
32
|
+
if (typeof value === "string")
|
|
33
|
+
return value;
|
|
34
|
+
if (value === null)
|
|
35
|
+
return "null";
|
|
36
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
37
|
+
return String(value);
|
|
38
|
+
try {
|
|
39
|
+
return JSON.stringify(value);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return String(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Truncate a literal for port row display.
|
|
47
|
+
* @category Encoding
|
|
48
|
+
*/
|
|
49
|
+
export function truncateLiteralPreview(full, max = LITERAL_PREVIEW_MAX) {
|
|
50
|
+
if (full.length <= max)
|
|
51
|
+
return full;
|
|
52
|
+
return `${full.slice(0, Math.max(0, max - 1))}…`;
|
|
53
|
+
}
|
|
54
|
+
function applyInputBindings(inputs, step) {
|
|
55
|
+
if (!step.input)
|
|
56
|
+
return;
|
|
57
|
+
const byName = new Map(inputs.map((p) => [p.name, p]));
|
|
58
|
+
for (const [name, value] of Object.entries(step.input)) {
|
|
59
|
+
let port = byName.get(name);
|
|
60
|
+
if (!port) {
|
|
61
|
+
port = { id: name, name, typeLabel: "unknown", required: false };
|
|
62
|
+
inputs.push(port);
|
|
63
|
+
byName.set(name, port);
|
|
64
|
+
}
|
|
65
|
+
if (isRefValue(value)) {
|
|
66
|
+
const parsed = parseStateRef(value.$ref);
|
|
67
|
+
port.binding = "ref";
|
|
68
|
+
port.refPath = parsed
|
|
69
|
+
? parsed.fieldPath
|
|
70
|
+
? `${parsed.asKey}.${parsed.fieldPath}`
|
|
71
|
+
: parsed.asKey
|
|
72
|
+
: value.$ref.replace(/^state\./, "");
|
|
73
|
+
delete port.valuePreview;
|
|
74
|
+
delete port.valueTitle;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const full = formatLiteralValue(value);
|
|
78
|
+
port.binding = "literal";
|
|
79
|
+
port.valueTitle = full;
|
|
80
|
+
port.valuePreview = truncateLiteralPreview(full);
|
|
81
|
+
delete port.refPath;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Ensure an output port exists for a data-edge source handle.
|
|
86
|
+
* @category Encoding
|
|
87
|
+
*/
|
|
88
|
+
export function ensureOutputPort(outputs, handleId) {
|
|
89
|
+
if (outputs.some((p) => p.id === handleId))
|
|
90
|
+
return;
|
|
91
|
+
outputs.push({
|
|
92
|
+
id: handleId,
|
|
93
|
+
name: handleId,
|
|
94
|
+
typeLabel: "unknown",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build input/output ports from capability Zod schemas, with input-key fallback
|
|
99
|
+
* and literal / `$ref` binding metadata from `step.input`.
|
|
100
|
+
* @category Encoding
|
|
101
|
+
*/
|
|
102
|
+
export function portsForStep(step, registry) {
|
|
103
|
+
const cap = registry?.getCapability(String(step.uses));
|
|
104
|
+
const inputFields = introspectCapabilitySchema(cap?.inputSchema);
|
|
105
|
+
const outputFields = introspectCapabilitySchema(cap?.outputSchema);
|
|
106
|
+
const inputSchemas = valueSchemasFromCapabilitySchema(cap?.inputSchema);
|
|
107
|
+
const outputSchemas = valueSchemasFromCapabilitySchema(cap?.outputSchema);
|
|
108
|
+
const inputs = [];
|
|
109
|
+
const seenInputs = new Set();
|
|
110
|
+
for (const name of inputFields.required) {
|
|
111
|
+
seenInputs.add(name);
|
|
112
|
+
const typeLabel = typeLabelFor(inputFields.eqlTypes, name, true);
|
|
113
|
+
const port = {
|
|
114
|
+
id: name,
|
|
115
|
+
name,
|
|
116
|
+
typeLabel,
|
|
117
|
+
required: true,
|
|
118
|
+
};
|
|
119
|
+
attachValueSchema(port, inputSchemas, typeLabel);
|
|
120
|
+
inputs.push(port);
|
|
121
|
+
}
|
|
122
|
+
for (const name of inputFields.optional) {
|
|
123
|
+
seenInputs.add(name);
|
|
124
|
+
const typeLabel = typeLabelFor(inputFields.eqlTypes, name, false);
|
|
125
|
+
const port = {
|
|
126
|
+
id: name,
|
|
127
|
+
name,
|
|
128
|
+
typeLabel,
|
|
129
|
+
required: false,
|
|
130
|
+
};
|
|
131
|
+
attachValueSchema(port, inputSchemas, typeLabel);
|
|
132
|
+
inputs.push(port);
|
|
133
|
+
}
|
|
134
|
+
if (step.input) {
|
|
135
|
+
for (const name of Object.keys(step.input)) {
|
|
136
|
+
if (seenInputs.has(name))
|
|
137
|
+
continue;
|
|
138
|
+
const port = {
|
|
139
|
+
id: name,
|
|
140
|
+
name,
|
|
141
|
+
typeLabel: "unknown",
|
|
142
|
+
required: false,
|
|
143
|
+
};
|
|
144
|
+
attachValueSchema(port, inputSchemas, "unknown");
|
|
145
|
+
inputs.push(port);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
applyInputBindings(inputs, step);
|
|
149
|
+
const outputs = [];
|
|
150
|
+
for (const name of [...outputFields.required, ...outputFields.optional]) {
|
|
151
|
+
const typeLabel = typeLabelFor(outputFields.eqlTypes, name, outputFields.required.includes(name));
|
|
152
|
+
const port = {
|
|
153
|
+
id: name,
|
|
154
|
+
name,
|
|
155
|
+
typeLabel,
|
|
156
|
+
};
|
|
157
|
+
attachValueSchema(port, outputSchemas, typeLabel);
|
|
158
|
+
outputs.push(port);
|
|
159
|
+
}
|
|
160
|
+
if (outputs.length === 0 && step.as) {
|
|
161
|
+
outputs.push({
|
|
162
|
+
id: "output",
|
|
163
|
+
name: "output",
|
|
164
|
+
typeLabel: "unknown",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return { inputs, outputs };
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=ports-from-zod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports-from-zod.js","sourceRoot":"","sources":["../src/ports-from-zod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,EACL,uBAAuB,EACvB,gCAAgC,GAEjC,MAAM,wBAAwB,CAAA;AAE/B,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAE9B,SAAS,YAAY,CACnB,QAA4C,EAC5C,IAAY,EACZ,QAAiB;IAEjB,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAA;IAC5B,IAAI,GAAG;QAAE,OAAO,GAAG,CAAA;IACnB,OAAO,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1C,CAAC;AAED,SAAS,iBAAiB,CACxB,IAAmB,EACnB,OAAqC,EACrC,SAAiB;IAEjB,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EAAE,CAAA;IACnC,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxE,MAAM,SAAS,GAAG,YAAY,CAC5B,YAAY,CAAC,QAAQ,EACrB,IAAI,EACJ,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CACrC,CAAA;QACD,MAAM,IAAI,GAAkB;YAC1B,EAAE,EAAE,IAAI;YACR,IAAI;YACJ,SAAS;SACV,CAAA;QACD,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAA;QACjD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC;YACX,EAAE,EAAE,QAAQ;YACZ,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,SAAS;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactFlowRunLifecycleDetail, ReactFlowStepStatus } from "./types.js";
|
|
2
|
+
/** Progress event names. @category Encoding */
|
|
3
|
+
export type ReactFlowProgressEventName = "run:reset" | "step:status" | "run:done";
|
|
4
|
+
/**
|
|
5
|
+
* Browser-safe progress bus for React Flow run visualization.
|
|
6
|
+
* Listeners receive CustomEvent with typed detail.
|
|
7
|
+
* @category Encoding
|
|
8
|
+
*/
|
|
9
|
+
export declare class ReactFlowRunProgress extends EventTarget {
|
|
10
|
+
/** Emit run reset (all steps pending). */
|
|
11
|
+
emitReset(detail?: ReactFlowRunLifecycleDetail): void;
|
|
12
|
+
/** Emit a step status change. */
|
|
13
|
+
emitStepStatus(stepId: string, status: ReactFlowStepStatus): void;
|
|
14
|
+
/** Emit run completion. */
|
|
15
|
+
emitDone(detail?: ReactFlowRunLifecycleDetail): void;
|
|
16
|
+
}
|
|
17
|
+
/** Shared progress bus for the format-reactflow extension hooks. @category Encoding */
|
|
18
|
+
export declare const reactFlowRunProgress: ReactFlowRunProgress;
|
|
19
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EAEpB,MAAM,YAAY,CAAA;AAEnB,+CAA+C;AAC/C,MAAM,MAAM,0BAA0B,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAA;AAEjF;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,0CAA0C;IAC1C,SAAS,CAAC,MAAM,GAAE,2BAAgC,GAAG,IAAI;IAIzD,iCAAiC;IACjC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAKjE,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,GAAE,2BAAgC,GAAG,IAAI;CAGzD;AAED,uFAAuF;AACvF,eAAO,MAAM,oBAAoB,sBAA6B,CAAA"}
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe progress bus for React Flow run visualization.
|
|
3
|
+
* Listeners receive CustomEvent with typed detail.
|
|
4
|
+
* @category Encoding
|
|
5
|
+
*/
|
|
6
|
+
export class ReactFlowRunProgress extends EventTarget {
|
|
7
|
+
/** Emit run reset (all steps pending). */
|
|
8
|
+
emitReset(detail = {}) {
|
|
9
|
+
this.dispatchEvent(new CustomEvent("run:reset", { detail }));
|
|
10
|
+
}
|
|
11
|
+
/** Emit a step status change. */
|
|
12
|
+
emitStepStatus(stepId, status) {
|
|
13
|
+
const detail = { stepId, status };
|
|
14
|
+
this.dispatchEvent(new CustomEvent("step:status", { detail }));
|
|
15
|
+
}
|
|
16
|
+
/** Emit run completion. */
|
|
17
|
+
emitDone(detail = {}) {
|
|
18
|
+
this.dispatchEvent(new CustomEvent("run:done", { detail }));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Shared progress bus for the format-reactflow extension hooks. @category Encoding */
|
|
22
|
+
export const reactFlowRunProgress = new ReactFlowRunProgress();
|
|
23
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,0CAA0C;IAC1C,SAAS,CAAC,SAAsC,EAAE;QAChD,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,iCAAiC;IACjC,cAAc,CAAC,MAAc,EAAE,MAA2B;QACxD,MAAM,MAAM,GAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;QAC5D,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,2BAA2B;IAC3B,QAAQ,CAAC,SAAsC,EAAE;QAC/C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC;CACF;AAED,uFAAuF;AACvF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** How a step input is supplied on the graph. @category Encoding */
|
|
2
|
+
export type ReactFlowPortBinding = "literal" | "ref";
|
|
3
|
+
/** Port on a React Flow step node. @category Encoding */
|
|
4
|
+
export interface ReactFlowPort {
|
|
5
|
+
/** Handle id (matches edge sourceHandle / targetHandle). */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Parameter / field name. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Human-readable type (EQL-ish or `unknown`). */
|
|
10
|
+
typeLabel: string;
|
|
11
|
+
/**
|
|
12
|
+
* Portable JSON Schema hint for the port value (primitives + constraints).
|
|
13
|
+
* Never includes UI widget names — viewers map this to controls.
|
|
14
|
+
*/
|
|
15
|
+
valueSchema?: Record<string, unknown>;
|
|
16
|
+
/** Whether the field is required (inputs only). */
|
|
17
|
+
required?: boolean;
|
|
18
|
+
/** How this input is supplied (`literal` `.with()` value or `$ref`). */
|
|
19
|
+
binding?: ReactFlowPortBinding;
|
|
20
|
+
/** Truncated display for literal values. */
|
|
21
|
+
valuePreview?: string;
|
|
22
|
+
/** Full literal string for tooltip / editor seed. */
|
|
23
|
+
valueTitle?: string;
|
|
24
|
+
/** Short `$ref` path without `state.` (e.g. `summary.text`). */
|
|
25
|
+
refPath?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Step node payload. @category Encoding */
|
|
28
|
+
export interface ReactFlowStepData {
|
|
29
|
+
/** Display label. */
|
|
30
|
+
label: string;
|
|
31
|
+
/** Capability id (`uses`). */
|
|
32
|
+
uses?: string;
|
|
33
|
+
/** Commit key (`as`). */
|
|
34
|
+
as?: string;
|
|
35
|
+
/** Input handles. */
|
|
36
|
+
inputs: ReactFlowPort[];
|
|
37
|
+
/** Output handles. */
|
|
38
|
+
outputs: ReactFlowPort[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Group node payload (optional viewer type; encoder emits step nodes only).
|
|
42
|
+
* @category Encoding
|
|
43
|
+
*/
|
|
44
|
+
export interface ReactFlowGroupData {
|
|
45
|
+
/** Display label. */
|
|
46
|
+
label: string;
|
|
47
|
+
/** Structural kind. */
|
|
48
|
+
kind: "parallel" | "branch" | "loop" | "workflow";
|
|
49
|
+
}
|
|
50
|
+
/** Workflow I/O projection (`accepts` / `returns`) — not a capability step. @category Encoding */
|
|
51
|
+
export type ReactFlowIoKind = "accepts" | "returns";
|
|
52
|
+
/** Payload for projected Inputs / Outputs nodes. @category Encoding */
|
|
53
|
+
export interface ReactFlowIoData {
|
|
54
|
+
/** Display label (`Inputs` / `Outputs`). */
|
|
55
|
+
label: string;
|
|
56
|
+
/** Which workflow contract this node edits. */
|
|
57
|
+
kind: ReactFlowIoKind;
|
|
58
|
+
/** Input handles (Outputs node only). */
|
|
59
|
+
inputs: ReactFlowPort[];
|
|
60
|
+
/** Output handles (Inputs node only). */
|
|
61
|
+
outputs: ReactFlowPort[];
|
|
62
|
+
}
|
|
63
|
+
/** React Flow node. @category Encoding */
|
|
64
|
+
export interface ReactFlowNode {
|
|
65
|
+
/** Node id (typically a workflow step id). */
|
|
66
|
+
id: string;
|
|
67
|
+
/** Node type for the viewer. */
|
|
68
|
+
type: "ecp-step" | "ecp-group" | "ecp-io";
|
|
69
|
+
/** Layout position (absolute; canvas is the workflow surface). */
|
|
70
|
+
position: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
};
|
|
74
|
+
/** Node payload. */
|
|
75
|
+
data: ReactFlowStepData | ReactFlowGroupData | ReactFlowIoData;
|
|
76
|
+
/** Soft size hint for layout. */
|
|
77
|
+
style?: {
|
|
78
|
+
width?: number;
|
|
79
|
+
height?: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Edge kind. @category Encoding */
|
|
83
|
+
export type ReactFlowEdgeKind = "data" | "control";
|
|
84
|
+
/** React Flow edge. @category Encoding */
|
|
85
|
+
export interface ReactFlowEdge {
|
|
86
|
+
/** Edge id. */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Source node id. */
|
|
89
|
+
source: string;
|
|
90
|
+
/** Target node id. */
|
|
91
|
+
target: string;
|
|
92
|
+
/** Source handle id. */
|
|
93
|
+
sourceHandle?: string;
|
|
94
|
+
/** Target handle id. */
|
|
95
|
+
targetHandle?: string;
|
|
96
|
+
/** Edge metadata. */
|
|
97
|
+
data: {
|
|
98
|
+
kind: ReactFlowEdgeKind;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Encoded React Flow document. @category Encoding */
|
|
102
|
+
export interface ReactFlowDocument {
|
|
103
|
+
/** Nodes. */
|
|
104
|
+
nodes: ReactFlowNode[];
|
|
105
|
+
/** Edges. */
|
|
106
|
+
edges: ReactFlowEdge[];
|
|
107
|
+
}
|
|
108
|
+
/** Encode options. @category Encoding */
|
|
109
|
+
export interface ReactFlowEncodeOptions {
|
|
110
|
+
/** Rank direction for dagre. Default `LR`. */
|
|
111
|
+
direction?: "LR" | "TB";
|
|
112
|
+
/** Node width used for layout. */
|
|
113
|
+
nodeWidth?: number;
|
|
114
|
+
/** Node height used for layout. */
|
|
115
|
+
nodeHeight?: number;
|
|
116
|
+
}
|
|
117
|
+
/** Step run status for progress events. @category Encoding */
|
|
118
|
+
export type ReactFlowStepStatus = "idle" | "pending" | "running" | "completed" | "failed";
|
|
119
|
+
/** Detail for `step:status` progress events. @category Encoding */
|
|
120
|
+
export interface ReactFlowStepStatusDetail {
|
|
121
|
+
/** Workflow step id. */
|
|
122
|
+
stepId: string;
|
|
123
|
+
/** Status. */
|
|
124
|
+
status: ReactFlowStepStatus;
|
|
125
|
+
}
|
|
126
|
+
/** Detail for `run:reset` / `run:done`. @category Encoding */
|
|
127
|
+
export interface ReactFlowRunLifecycleDetail {
|
|
128
|
+
/** Run id when available. */
|
|
129
|
+
runId?: string;
|
|
130
|
+
/** Terminal outcome when done. */
|
|
131
|
+
outcome?: "completed" | "failed" | "cancelled";
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,MAAM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AkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,8DAA8D;AAC9D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;AAEzF,mEAAmE;AACnE,MAAM,WAAW,yBAAyB;IACxC,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc;IACd,MAAM,EAAE,mBAAmB,CAAA;CAC5B;AAED,8DAA8D;AAC9D,MAAM,WAAW,2BAA2B;IAC1C,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kCAAkC;IAClC,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;CAC/C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** JSON Schema fragment used as a portable port type hint. @category Encoding */
|
|
3
|
+
export type ValueSchemaHint = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Unwrap Zod wrappers that do not change the value shape for UI hints.
|
|
6
|
+
* @category Encoding
|
|
7
|
+
*/
|
|
8
|
+
export declare function unwrapZodType(type: z.ZodType): z.ZodType;
|
|
9
|
+
/**
|
|
10
|
+
* Project a Zod type to a primitive-centered JSON Schema hint.
|
|
11
|
+
* Enums stay `type: "string"` (or number) with an `enum` constraint — never a widget name.
|
|
12
|
+
* @category Encoding
|
|
13
|
+
*/
|
|
14
|
+
export declare function valueSchemaFromZod(type: z.ZodType): ValueSchemaHint | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Synthesize a minimal valueSchema from an EQL-ish type label (`string!`, `number`, …).
|
|
17
|
+
* @category Encoding
|
|
18
|
+
*/
|
|
19
|
+
export declare function valueSchemaFromEqlLabel(typeLabel: string): ValueSchemaHint | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Pass through a JSON Schema property node as a valueSchema hint (shallow clone).
|
|
22
|
+
* @category Encoding
|
|
23
|
+
*/
|
|
24
|
+
export declare function valueSchemaFromJsonSchemaProp(prop: unknown): ValueSchemaHint | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Build a name → valueSchema map from a capability input/output schema.
|
|
27
|
+
* Supports Zod objects and JSON Schema objects with `properties`.
|
|
28
|
+
* @category Encoding
|
|
29
|
+
*/
|
|
30
|
+
export declare function valueSchemasFromCapabilitySchema(schema: unknown): Map<string, ValueSchemaHint>;
|
|
31
|
+
//# sourceMappingURL=value-schema-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-schema-hint.d.ts","sourceRoot":"","sources":["../src/value-schema-hint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAErD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAWxD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,GAAG,eAAe,GAAG,SAAS,CAkE/E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAWtF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAGxF;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,OAAO,GACd,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAwB9B"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Unwrap Zod wrappers that do not change the value shape for UI hints.
|
|
4
|
+
* @category Encoding
|
|
5
|
+
*/
|
|
6
|
+
export function unwrapZodType(type) {
|
|
7
|
+
if (type instanceof z.ZodOptional) {
|
|
8
|
+
return unwrapZodType(type.unwrap());
|
|
9
|
+
}
|
|
10
|
+
if (type instanceof z.ZodDefault) {
|
|
11
|
+
return unwrapZodType(type.removeDefault());
|
|
12
|
+
}
|
|
13
|
+
if (type instanceof z.ZodNullable) {
|
|
14
|
+
return unwrapZodType(type.unwrap());
|
|
15
|
+
}
|
|
16
|
+
return type;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Project a Zod type to a primitive-centered JSON Schema hint.
|
|
20
|
+
* Enums stay `type: "string"` (or number) with an `enum` constraint — never a widget name.
|
|
21
|
+
* @category Encoding
|
|
22
|
+
*/
|
|
23
|
+
export function valueSchemaFromZod(type) {
|
|
24
|
+
const inner = unwrapZodType(type);
|
|
25
|
+
if (inner instanceof z.ZodString) {
|
|
26
|
+
return { type: "string" };
|
|
27
|
+
}
|
|
28
|
+
if (inner instanceof z.ZodNumber) {
|
|
29
|
+
return { type: "number" };
|
|
30
|
+
}
|
|
31
|
+
if (inner instanceof z.ZodBoolean) {
|
|
32
|
+
return { type: "boolean" };
|
|
33
|
+
}
|
|
34
|
+
if (inner instanceof z.ZodNull) {
|
|
35
|
+
return { type: "null" };
|
|
36
|
+
}
|
|
37
|
+
if (inner instanceof z.ZodEnum) {
|
|
38
|
+
const values = inner.options;
|
|
39
|
+
return { type: "string", enum: [...values] };
|
|
40
|
+
}
|
|
41
|
+
if (inner instanceof z.ZodNativeEnum) {
|
|
42
|
+
const raw = inner.enum;
|
|
43
|
+
const values = Object.values(raw).filter((v) => typeof v === "string" || typeof v === "number");
|
|
44
|
+
const allNumber = values.every((v) => typeof v === "number");
|
|
45
|
+
return {
|
|
46
|
+
type: allNumber ? "number" : "string",
|
|
47
|
+
enum: values,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (inner instanceof z.ZodLiteral) {
|
|
51
|
+
const value = inner.value;
|
|
52
|
+
if (typeof value === "string")
|
|
53
|
+
return { type: "string", enum: [value] };
|
|
54
|
+
if (typeof value === "number")
|
|
55
|
+
return { type: "number", enum: [value] };
|
|
56
|
+
if (typeof value === "boolean")
|
|
57
|
+
return { type: "boolean", enum: [value] };
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (inner instanceof z.ZodArray) {
|
|
61
|
+
const items = valueSchemaFromZod(inner.element);
|
|
62
|
+
return items ? { type: "array", items } : { type: "array" };
|
|
63
|
+
}
|
|
64
|
+
if (inner instanceof z.ZodObject) {
|
|
65
|
+
const properties = {};
|
|
66
|
+
for (const [name, field] of Object.entries(inner.shape)) {
|
|
67
|
+
const child = valueSchemaFromZod(field);
|
|
68
|
+
if (child)
|
|
69
|
+
properties[name] = child;
|
|
70
|
+
}
|
|
71
|
+
return Object.keys(properties).length > 0
|
|
72
|
+
? { type: "object", properties }
|
|
73
|
+
: { type: "object" };
|
|
74
|
+
}
|
|
75
|
+
if (inner instanceof z.ZodRecord) {
|
|
76
|
+
return { type: "object" };
|
|
77
|
+
}
|
|
78
|
+
if (inner instanceof z.ZodUnion || inner instanceof z.ZodDiscriminatedUnion) {
|
|
79
|
+
const options = inner.options
|
|
80
|
+
.map((opt) => valueSchemaFromZod(opt))
|
|
81
|
+
.filter((s) => Boolean(s));
|
|
82
|
+
if (options.length === 0)
|
|
83
|
+
return undefined;
|
|
84
|
+
if (options.length === 1)
|
|
85
|
+
return options[0];
|
|
86
|
+
return { oneOf: options };
|
|
87
|
+
}
|
|
88
|
+
if (inner instanceof z.ZodAny || inner instanceof z.ZodUnknown) {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Synthesize a minimal valueSchema from an EQL-ish type label (`string!`, `number`, …).
|
|
95
|
+
* @category Encoding
|
|
96
|
+
*/
|
|
97
|
+
export function valueSchemaFromEqlLabel(typeLabel) {
|
|
98
|
+
const base = typeLabel.replace(/!+$/, "").trim().toLowerCase();
|
|
99
|
+
if (!base || base === "unknown")
|
|
100
|
+
return undefined;
|
|
101
|
+
if (base === "string")
|
|
102
|
+
return { type: "string" };
|
|
103
|
+
if (base === "number" || base === "float")
|
|
104
|
+
return { type: "number" };
|
|
105
|
+
if (base === "int" || base === "integer")
|
|
106
|
+
return { type: "integer" };
|
|
107
|
+
if (base === "boolean" || base === "bool")
|
|
108
|
+
return { type: "boolean" };
|
|
109
|
+
if (base === "null")
|
|
110
|
+
return { type: "null" };
|
|
111
|
+
if (base === "array")
|
|
112
|
+
return { type: "array" };
|
|
113
|
+
if (base === "object" || base === "record" || base === "json")
|
|
114
|
+
return { type: "object" };
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Pass through a JSON Schema property node as a valueSchema hint (shallow clone).
|
|
119
|
+
* @category Encoding
|
|
120
|
+
*/
|
|
121
|
+
export function valueSchemaFromJsonSchemaProp(prop) {
|
|
122
|
+
if (prop === null || typeof prop !== "object" || Array.isArray(prop))
|
|
123
|
+
return undefined;
|
|
124
|
+
return { ...prop };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Build a name → valueSchema map from a capability input/output schema.
|
|
128
|
+
* Supports Zod objects and JSON Schema objects with `properties`.
|
|
129
|
+
* @category Encoding
|
|
130
|
+
*/
|
|
131
|
+
export function valueSchemasFromCapabilitySchema(schema) {
|
|
132
|
+
const out = new Map();
|
|
133
|
+
if (schema === null || schema === undefined)
|
|
134
|
+
return out;
|
|
135
|
+
if (schema instanceof z.ZodObject) {
|
|
136
|
+
for (const [name, field] of Object.entries(schema.shape)) {
|
|
137
|
+
const hint = valueSchemaFromZod(field);
|
|
138
|
+
if (hint)
|
|
139
|
+
out.set(name, hint);
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
if (typeof schema === "object" && !Array.isArray(schema)) {
|
|
144
|
+
const obj = schema;
|
|
145
|
+
const props = obj.properties;
|
|
146
|
+
if (props && typeof props === "object" && !Array.isArray(props)) {
|
|
147
|
+
for (const [name, prop] of Object.entries(props)) {
|
|
148
|
+
const hint = valueSchemaFromJsonSchemaProp(prop);
|
|
149
|
+
if (hint)
|
|
150
|
+
out.set(name, hint);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=value-schema-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-schema-hint.js","sourceRoot":"","sources":["../src/value-schema-hint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAe;IAC3C,IAAI,IAAI,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,EAAe,CAAC,CAAA;IAClD,CAAC;IACD,IAAI,IAAI,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,aAAa,CAAC,IAAI,CAAC,aAAa,EAAe,CAAC,CAAA;IACzD,CAAC;IACD,IAAI,IAAI,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,EAAe,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAe;IAChD,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IAEjC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI,EAA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CAAA;IACZ,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACzD,MAAM,GAAG,GAAG,MAAiC,CAAA;QAC7C,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAA;QAC5B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;gBAC5E,MAAM,IAAI,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAA;gBAChD,IAAI,IAAI;oBAAE,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Registry } from "@executioncontrolprotocol/core";
|
|
2
|
+
import type { WorkflowManifest } from "@executioncontrolprotocol/types";
|
|
3
|
+
import type { ReactFlowDocument, ReactFlowEncodeOptions } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convert a workflow manifest into a positioned React Flow document.
|
|
6
|
+
* Emits step nodes, projected Inputs / Outputs (`ecp-io`), and **data** edges.
|
|
7
|
+
* Sequential control edges are used internally for layout, then discarded.
|
|
8
|
+
* @category Encoding
|
|
9
|
+
*/
|
|
10
|
+
export declare function workflowToReactFlow(manifest: WorkflowManifest, registry?: Registry, options?: ReactFlowEncodeOptions): ReactFlowDocument;
|
|
11
|
+
//# sourceMappingURL=workflow-to-reactflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-to-reactflow.d.ts","sourceRoot":"","sources":["../src/workflow-to-reactflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,EAAY,gBAAgB,EAAgB,MAAM,iCAAiC,CAAA;AAW/F,OAAO,KAAK,EACV,iBAAiB,EAEjB,sBAAsB,EAGvB,MAAM,YAAY,CAAA;AAwLnB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,CAAC,EAAE,QAAQ,EACnB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,iBAAiB,CA4CnB"}
|