@ultrst-armada/floks 2.0.7 → 2.0.9
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/.krusbl-release-attestation.json +3 -3
- package/package.json +4 -4
- package/packages/canvas-ui/dist/aiko/AgentWorkspace.d.ts +8 -0
- package/packages/canvas-ui/dist/aiko/AikoModule.d.ts +11 -3
- package/packages/canvas-ui/dist/aiko/EmbeddedAikoModule.test.d.ts +1 -0
- package/packages/canvas-ui/dist/aiko/index.js +5 -3
- package/packages/canvas-ui/dist/chunk-DAAI7BIG.js +625 -0
- package/packages/canvas-ui/dist/{chunk-OHAFLB3O.js → chunk-OH7S4XFZ.js} +40 -27
- package/packages/canvas-ui/dist/fod/FodAuthorizedRemoteNodes.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/FodModule.authorization.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/FodModule.d.ts +28 -2
- package/packages/canvas-ui/dist/fod/FodPassiveNavigationAdversarial.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/FodRemoteExecution.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/FodWorkflowDraft.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/index.d.ts +3 -0
- package/packages/canvas-ui/dist/fod/index.js +25 -3
- package/packages/canvas-ui/dist/fod/remoteAuthorizationFingerprint.d.ts +10 -0
- package/packages/canvas-ui/dist/fod/remoteAuthorizationFingerprint.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/remoteGraphConnections.d.ts +40 -0
- package/packages/canvas-ui/dist/fod/remoteGraphConnections.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/remoteGraphContract.d.ts +37 -0
- package/packages/canvas-ui/dist/fod/remoteGraphContract.test.d.ts +1 -0
- package/packages/canvas-ui/dist/fod/remoteKloksInvocation.d.ts +29 -0
- package/packages/canvas-ui/dist/fod/remoteKloksInvocation.test.d.ts +1 -0
- package/packages/canvas-ui/dist/index.js +34 -10
- package/packages/canvas-ui/package.json +1 -1
- package/packages/ui/dist/chunk-5Y2HGI37.js +443 -0
- package/packages/ui/dist/{chunk-XMRSW4TL.js → chunk-6J5J56YO.js} +31 -79
- package/packages/ui/dist/{chunk-KIFQA7L6.js → chunk-CIH4FVXM.js} +22 -34
- package/packages/ui/dist/chunk-F5XUUMSI.js +14 -0
- package/packages/ui/dist/{chunk-MYXPGPI3.js → chunk-KMVDLACR.js} +25 -2
- package/packages/ui/dist/{chunk-FA6GHJKU.js → chunk-SJPSY27C.js} +163 -5
- package/packages/ui/dist/components/ai/chat/AgentChatDock.d.ts +12 -0
- package/packages/ui/dist/components/ai/chat/AgentChatPanel.d.ts +11 -0
- package/packages/ui/dist/components/ai/chat/AgentChatPanel.test.d.ts +1 -0
- package/packages/ui/dist/components/ai/chat/AgentChatTypes.d.ts +39 -0
- package/packages/ui/dist/components/ai/chat/index.d.ts +3 -0
- package/packages/ui/dist/components/ai/index.js +17 -4
- package/packages/ui/dist/components/auth/LuthOidcGate.d.ts +29 -0
- package/packages/ui/dist/components/auth/index.d.ts +1 -0
- package/packages/ui/dist/components/auth/index.js +5 -1
- package/packages/ui/dist/components/base/index.js +4 -2
- package/packages/ui/dist/components/layout/AppShell.d.ts +2 -0
- package/packages/ui/dist/components/layout/index.js +3 -1
- package/packages/ui/dist/components/workspace/WorkspaceGate.contract.test.d.ts +1 -0
- package/packages/ui/dist/index.js +24 -6
- package/packages/ui/package.json +2 -2
- package/packages/canvas-ui/dist/chunk-TKOMIUCU.js +0 -139
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FrnlEditableNodeGraph
|
|
3
|
+
} from "./chunk-SRGVIYC5.js";
|
|
4
|
+
|
|
5
|
+
// src/fod/FodModule.tsx
|
|
6
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
|
|
8
|
+
// src/fod/remoteGraphContract.ts
|
|
9
|
+
var fields = ["appId", "targetWorkspaceId", "operationId", "operationVersion"];
|
|
10
|
+
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
11
|
+
var text = (v) => typeof v === "string" && v.length > 0 && v.trim() === v;
|
|
12
|
+
function readRemoteHandle(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
14
|
+
const record = value;
|
|
15
|
+
if (!fields.every((field) => text(record[field]))) return null;
|
|
16
|
+
return {
|
|
17
|
+
appId: record.appId,
|
|
18
|
+
targetWorkspaceId: record.targetWorkspaceId,
|
|
19
|
+
operationId: record.operationId,
|
|
20
|
+
operationVersion: record.operationVersion
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function isRemoteGraphNode(node) {
|
|
24
|
+
return node.type.startsWith("remote.") || Boolean(node.data && fields.some((field) => own(node.data, field) && node.data[field] != null));
|
|
25
|
+
}
|
|
26
|
+
function isLiveFrontendDefinition(definition) {
|
|
27
|
+
return definition.metadata?.surface === "raw.frontend.session" || definition.category === "frontend-session" || definition.category === "frontend-operation";
|
|
28
|
+
}
|
|
29
|
+
function leaseCurrent(metadata) {
|
|
30
|
+
const expiration = metadata?.leaseExpiresAt ?? metadata?.expiresAt;
|
|
31
|
+
if (expiration === void 0) return true;
|
|
32
|
+
if (typeof expiration !== "string") return false;
|
|
33
|
+
const timestamp = Date.parse(expiration);
|
|
34
|
+
return Number.isFinite(timestamp) && timestamp > Date.now();
|
|
35
|
+
}
|
|
36
|
+
function portsValid(ports, direction) {
|
|
37
|
+
return Array.isArray(ports) && ports.every((port) => port && text(port.id) && text(port.dataType) && text(port.name) && port.direction === direction) && new Set(ports.map((port) => port.id)).size === ports.length;
|
|
38
|
+
}
|
|
39
|
+
function filterRemoteDefinitions(definitions, localTypes = []) {
|
|
40
|
+
const seen = new Set(localTypes);
|
|
41
|
+
const counts = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const definition of definitions) if (definition && typeof definition.type === "string")
|
|
43
|
+
counts.set(definition.type, (counts.get(definition.type) ?? 0) + 1);
|
|
44
|
+
const result = [];
|
|
45
|
+
if (!Array.isArray(definitions)) return result;
|
|
46
|
+
for (const definition of definitions) {
|
|
47
|
+
if (!definition || !text(definition.type) || seen.has(definition.type) || counts.get(definition.type) !== 1 || !readRemoteHandle(definition.metadata) || !leaseCurrent(definition.metadata) || !portsValid(definition.inputs, "input") || !portsValid(definition.outputs, "output")) continue;
|
|
48
|
+
seen.add(definition.type);
|
|
49
|
+
result.push(definition);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function sameHandle(a, b) {
|
|
54
|
+
return fields.every((key) => a[key] === b[key]);
|
|
55
|
+
}
|
|
56
|
+
function inputIsType(value, type) {
|
|
57
|
+
switch (type.toLowerCase()) {
|
|
58
|
+
case "string":
|
|
59
|
+
return typeof value === "string";
|
|
60
|
+
case "number":
|
|
61
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
62
|
+
case "boolean":
|
|
63
|
+
return typeof value === "boolean";
|
|
64
|
+
case "object":
|
|
65
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
66
|
+
case "array":
|
|
67
|
+
return Array.isArray(value);
|
|
68
|
+
default:
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function validateRemoteGraph(nodes, definitions) {
|
|
73
|
+
const handles = [];
|
|
74
|
+
let requiresWindowConsent = false;
|
|
75
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
76
|
+
const ambiguous = /* @__PURE__ */ new Set();
|
|
77
|
+
for (const definition of definitions) {
|
|
78
|
+
if (!definition || !text(definition.type)) continue;
|
|
79
|
+
if (descriptors.has(definition.type)) ambiguous.add(definition.type);
|
|
80
|
+
descriptors.set(definition.type, definition);
|
|
81
|
+
}
|
|
82
|
+
const deny = (message) => ({ ok: false, handles: [], requiresWindowConsent, message });
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
if (!isRemoteGraphNode(node)) continue;
|
|
85
|
+
const saved = readRemoteHandle(node.data);
|
|
86
|
+
if (!saved) return deny(`Remote node ${node.id}: missing immutable app/workspace/operation/version handle`);
|
|
87
|
+
if (ambiguous.has(node.type)) return deny(`Remote node ${node.id}: ambiguous operation definition`);
|
|
88
|
+
const descriptor = descriptors.get(node.type);
|
|
89
|
+
const live = descriptor && readRemoteHandle(descriptor.metadata);
|
|
90
|
+
if (!descriptor || !live) return deny(`Remote node ${node.id}: operation unavailable or permission revoked`);
|
|
91
|
+
if (!sameHandle(saved, live)) return deny(`Remote node ${node.id}: operation version or authorized target changed`);
|
|
92
|
+
if (!portsValid(descriptor.inputs, "input") || !portsValid(descriptor.outputs, "output"))
|
|
93
|
+
return deny(`Remote node ${node.id}: typed port contract changed`);
|
|
94
|
+
const configured = node.data?.configuredInputs;
|
|
95
|
+
if (configured !== void 0) {
|
|
96
|
+
if (!configured || typeof configured !== "object" || Array.isArray(configured))
|
|
97
|
+
return deny(`Remote node ${node.id}: invalid typed input payload`);
|
|
98
|
+
const inputs = new Map(descriptor.inputs.map((port) => [port.id, port]));
|
|
99
|
+
for (const [key, value] of Object.entries(configured)) {
|
|
100
|
+
const port = inputs.get(key);
|
|
101
|
+
if (!port || !inputIsType(value, port.dataType))
|
|
102
|
+
return deny(`Remote node ${node.id}: invalid typed input ${key}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
requiresWindowConsent ||= isLiveFrontendDefinition(descriptor);
|
|
106
|
+
handles.push(saved);
|
|
107
|
+
}
|
|
108
|
+
return { ok: true, handles, requiresWindowConsent };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/fod/remoteGraphConnections.ts
|
|
112
|
+
var nonEmpty = (value) => typeof value === "string" && value.trim().length > 0 && value === value.trim();
|
|
113
|
+
var portValid = (port, direction) => {
|
|
114
|
+
if (!port || typeof port !== "object" || Array.isArray(port)) return false;
|
|
115
|
+
const item = port;
|
|
116
|
+
return nonEmpty(item.id) && nonEmpty(item.name) && nonEmpty(item.dataType) && item.direction === direction;
|
|
117
|
+
};
|
|
118
|
+
var validPorts = (ports, direction) => Array.isArray(ports) && ports.every((port) => portValid(port, direction)) && new Set(ports.map((port) => port.id)).size === ports.length;
|
|
119
|
+
function snapshotRemotePorts(definition) {
|
|
120
|
+
return {
|
|
121
|
+
inputs: definition.inputs.map(({ id, name, direction, dataType }) => ({ id, name, direction, dataType })),
|
|
122
|
+
outputs: definition.outputs.map(({ id, name, direction, dataType }) => ({ id, name, direction, dataType }))
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function readRemotePortSnapshot(value) {
|
|
126
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
127
|
+
const snapshot = value;
|
|
128
|
+
if (!validPorts(snapshot.inputs, "input") || !validPorts(snapshot.outputs, "output")) return null;
|
|
129
|
+
return { inputs: snapshot.inputs, outputs: snapshot.outputs };
|
|
130
|
+
}
|
|
131
|
+
function remotePortFingerprint(definition) {
|
|
132
|
+
const ports = (items) => items.map(({ id, direction, dataType }) => [id, direction, dataType]).sort((a, b) => a[0].localeCompare(b[0]));
|
|
133
|
+
return JSON.stringify({ inputs: ports(definition.inputs), outputs: ports(definition.outputs) });
|
|
134
|
+
}
|
|
135
|
+
function matchingPort(ports, handle, legacyDefault) {
|
|
136
|
+
if (nonEmpty(handle)) {
|
|
137
|
+
const exact = ports.find((port) => port.id === handle);
|
|
138
|
+
if (exact) return exact;
|
|
139
|
+
if (handle !== legacyDefault) return void 0;
|
|
140
|
+
}
|
|
141
|
+
return ports.length === 1 ? ports[0] : void 0;
|
|
142
|
+
}
|
|
143
|
+
function validateRemoteConnections(nodes, edges, definitions) {
|
|
144
|
+
const deny = (message) => ({ ok: false, connections: [], message });
|
|
145
|
+
if (!Array.isArray(nodes) || !Array.isArray(edges) || !Array.isArray(definitions))
|
|
146
|
+
return deny("Graph nodes, edges or operation definitions are malformed");
|
|
147
|
+
const byId = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const node of nodes) {
|
|
149
|
+
if (!node || !nonEmpty(node.id) || !nonEmpty(node.type) || byId.has(node.id))
|
|
150
|
+
return deny("Graph contains an invalid or duplicate node ID");
|
|
151
|
+
byId.set(node.id, node);
|
|
152
|
+
}
|
|
153
|
+
const byType = /* @__PURE__ */ new Map();
|
|
154
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
155
|
+
for (const definition of definitions) {
|
|
156
|
+
if (!definition || !nonEmpty(definition.type)) continue;
|
|
157
|
+
if (byType.has(definition.type)) duplicates.add(definition.type);
|
|
158
|
+
byType.set(definition.type, definition);
|
|
159
|
+
}
|
|
160
|
+
for (const node of nodes) {
|
|
161
|
+
if (!isRemoteGraphNode(node)) continue;
|
|
162
|
+
const descriptor = byType.get(node.type);
|
|
163
|
+
const saved = readRemoteHandle(node.data);
|
|
164
|
+
const authorized = descriptor && readRemoteHandle(descriptor.metadata);
|
|
165
|
+
if (!saved || !authorized || duplicates.has(node.type))
|
|
166
|
+
return deny(`Remote node ${node.id}: operation unavailable or ambiguous`);
|
|
167
|
+
if (Object.keys(saved).some((key) => saved[key] !== authorized[key]))
|
|
168
|
+
return deny(`Remote node ${node.id}: authorized workspace or version changed`);
|
|
169
|
+
const snapshot = node.data?.remotePorts;
|
|
170
|
+
const signature = node.data?.remotePortSignature;
|
|
171
|
+
if (snapshot !== void 0 && !readRemotePortSnapshot(snapshot))
|
|
172
|
+
return deny(`Remote node ${node.id}: stored port snapshot is invalid`);
|
|
173
|
+
if (signature !== void 0 && (!nonEmpty(signature) || signature !== remotePortFingerprint(descriptor)))
|
|
174
|
+
return deny(`Remote node ${node.id}: typed port contract changed`);
|
|
175
|
+
if (snapshot !== void 0 && remotePortFingerprint(snapshot) !== remotePortFingerprint(descriptor))
|
|
176
|
+
return deny(`Remote node ${node.id}: saved port types changed`);
|
|
177
|
+
}
|
|
178
|
+
const connections = [];
|
|
179
|
+
const edgeIds = /* @__PURE__ */ new Set();
|
|
180
|
+
const remoteInputs = /* @__PURE__ */ new Set();
|
|
181
|
+
for (const edge of edges) {
|
|
182
|
+
if (!edge || !nonEmpty(edge.id) || edgeIds.has(edge.id))
|
|
183
|
+
return deny("Graph contains a duplicate or invalid edge ID");
|
|
184
|
+
edgeIds.add(edge.id);
|
|
185
|
+
const source = byId.get(edge.source);
|
|
186
|
+
const target = byId.get(edge.target);
|
|
187
|
+
if (!source || !target)
|
|
188
|
+
return deny(`Edge ${edge.id}: source or target node is missing`);
|
|
189
|
+
if (!isRemoteGraphNode(source) && !isRemoteGraphNode(target)) continue;
|
|
190
|
+
const sourceDef = byType.get(source.type);
|
|
191
|
+
const targetDef = byType.get(target.type);
|
|
192
|
+
if (!sourceDef || !targetDef || duplicates.has(source.type) || duplicates.has(target.type))
|
|
193
|
+
return deny(`Edge ${edge.id}: endpoint port definition unavailable`);
|
|
194
|
+
if (!validPorts(sourceDef.outputs, "output") || !validPorts(targetDef.inputs, "input"))
|
|
195
|
+
return deny(`Edge ${edge.id}: endpoint ports are invalid`);
|
|
196
|
+
const output = matchingPort(sourceDef.outputs, edge.sourceHandle, "result");
|
|
197
|
+
const input = matchingPort(targetDef.inputs, edge.targetHandle, "input");
|
|
198
|
+
if (!output || !input)
|
|
199
|
+
return deny(`Edge ${edge.id}: source or destination port unavailable`);
|
|
200
|
+
if (output.dataType !== input.dataType)
|
|
201
|
+
return deny(`Edge ${edge.id}: incompatible port types (${output.dataType} -> ${input.dataType})`);
|
|
202
|
+
if (isRemoteGraphNode(target)) {
|
|
203
|
+
const inputKey = `${target.id}\0${input.id}`;
|
|
204
|
+
if (remoteInputs.has(inputKey))
|
|
205
|
+
return deny(`Edge ${edge.id}: remote input ${input.id} has more than one producer`);
|
|
206
|
+
remoteInputs.add(inputKey);
|
|
207
|
+
const configured = target.data?.configuredInputs;
|
|
208
|
+
if (configured && typeof configured === "object" && Object.prototype.hasOwnProperty.call(configured, input.id))
|
|
209
|
+
return deny(`Edge ${edge.id}: remote input ${input.id} has both an edge and a constant`);
|
|
210
|
+
}
|
|
211
|
+
connections.push({
|
|
212
|
+
edgeId: edge.id,
|
|
213
|
+
sourceNodeId: source.id,
|
|
214
|
+
sourcePortId: output.id,
|
|
215
|
+
targetNodeId: target.id,
|
|
216
|
+
targetPortId: input.id,
|
|
217
|
+
dataType: input.dataType
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return { ok: true, connections };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/fod/remoteAuthorizationFingerprint.ts
|
|
224
|
+
function remoteAuthorizationFingerprint(definitions) {
|
|
225
|
+
const identity = definitions.map((definition) => {
|
|
226
|
+
const metadata = definition.metadata ?? {};
|
|
227
|
+
const relevantMetadata = Object.keys(metadata).filter((key) => key !== "leaseExpiresAt" && key !== "expiresAt").sort().map((key) => [key, metadata[key]]);
|
|
228
|
+
return {
|
|
229
|
+
type: definition.type,
|
|
230
|
+
category: definition.category,
|
|
231
|
+
handle: readRemoteHandle(metadata),
|
|
232
|
+
ports: remotePortFingerprint(definition),
|
|
233
|
+
metadata: relevantMetadata
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
identity.sort((a, b) => a.type.localeCompare(b.type));
|
|
237
|
+
return JSON.stringify(identity);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/fod/FodModule.tsx
|
|
241
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
242
|
+
function toGraphNodes(flow, nodeDefinitions) {
|
|
243
|
+
const defs = new Map(nodeDefinitions.map((def) => [def.type, def]));
|
|
244
|
+
return flow.nodes.map((node) => {
|
|
245
|
+
const candidate = defs.get(node.type);
|
|
246
|
+
const saved = isRemoteGraphNode(node) ? readRemoteHandle(node.data) : null;
|
|
247
|
+
const current = candidate && isRemoteGraphNode(node) ? readRemoteHandle(candidate.metadata) : null;
|
|
248
|
+
const incompatiblePorts = Boolean(saved && candidate && node.data?.remotePortSignature && node.data.remotePortSignature !== remotePortFingerprint(candidate));
|
|
249
|
+
const def = saved && (!current || incompatiblePorts || Object.keys(saved).some((key) => saved[key] !== current[key])) ? void 0 : candidate;
|
|
250
|
+
const retained = saved ? readRemotePortSnapshot(node.data?.remotePorts) : null;
|
|
251
|
+
const inputs = def?.inputs ?? retained?.inputs ?? [];
|
|
252
|
+
const outputs = def?.outputs ?? retained?.outputs ?? [];
|
|
253
|
+
return {
|
|
254
|
+
id: node.id,
|
|
255
|
+
type: node.type,
|
|
256
|
+
label: def?.label ?? (isRemoteGraphNode(node) ? "Unavailable remote operation (permission/version/ports changed)" : String(node.data?.label ?? node.type)),
|
|
257
|
+
position: node.position,
|
|
258
|
+
data: node.data,
|
|
259
|
+
inputs: inputs.map((port) => ({ id: port.id, label: port.name, type: "input", dataType: port.dataType })),
|
|
260
|
+
outputs: outputs.map((port) => ({ id: port.id, label: port.name, type: "output", dataType: port.dataType })),
|
|
261
|
+
width: 190,
|
|
262
|
+
height: Math.max(90, 60 + Math.max(inputs.length, outputs.length) * 24)
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function toGraphEdges(flow) {
|
|
267
|
+
return flow.edges.map((edge) => ({ id: edge.id, source: edge.source, sourceSocket: edge.sourceHandle ?? "result", target: edge.target, targetSocket: edge.targetHandle ?? "input" }));
|
|
268
|
+
}
|
|
269
|
+
function FodModule(props) {
|
|
270
|
+
return /* @__PURE__ */ jsx(WorkspaceFlows, { ...props }, `${props.workspaceId}:${props.scopeKey ?? ""}`);
|
|
271
|
+
}
|
|
272
|
+
function WorkspaceFlows({ runtime, nodeDefinitions, workspaceId, className, scopeKey }) {
|
|
273
|
+
const drafts = useRef(/* @__PURE__ */ new Map());
|
|
274
|
+
const [flows, setFlows] = useState([]);
|
|
275
|
+
const [activeId, setActiveId] = useState(null);
|
|
276
|
+
const [flow, setFlow] = useState(null);
|
|
277
|
+
const [selected, setSelected] = useState(/* @__PURE__ */ new Set());
|
|
278
|
+
const [message, setMessage] = useState("");
|
|
279
|
+
const [running, setRunning] = useState(false);
|
|
280
|
+
const [authorizedNodes, setAuthorizedNodes] = useState([]);
|
|
281
|
+
const [remoteAppFilter, setRemoteAppFilter] = useState("");
|
|
282
|
+
const [remoteWorkspaceFilter, setRemoteWorkspaceFilter] = useState("");
|
|
283
|
+
const permissionEpoch = useRef(0);
|
|
284
|
+
const runningAbort = useRef(null);
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
let alive = true;
|
|
287
|
+
let revision = 0;
|
|
288
|
+
let authorizationFingerprint = null;
|
|
289
|
+
const revoke = () => {
|
|
290
|
+
permissionEpoch.current++;
|
|
291
|
+
runningAbort.current?.abort();
|
|
292
|
+
setAuthorizedNodes([]);
|
|
293
|
+
};
|
|
294
|
+
const refresh2 = (invalidation = false) => {
|
|
295
|
+
const request = ++revision;
|
|
296
|
+
if (invalidation) {
|
|
297
|
+
authorizationFingerprint = null;
|
|
298
|
+
revoke();
|
|
299
|
+
}
|
|
300
|
+
if (!scopeKey) {
|
|
301
|
+
revoke();
|
|
302
|
+
setMessage("Authenticated graph scope required for remote discovery");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (!runtime.listAuthorizedNodeDefinitions) {
|
|
306
|
+
revoke();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
void runtime.listAuthorizedNodeDefinitions(workspaceId).then((definitions) => {
|
|
310
|
+
if (!alive || request !== revision) return;
|
|
311
|
+
if (!Array.isArray(definitions)) {
|
|
312
|
+
authorizationFingerprint = null;
|
|
313
|
+
revoke();
|
|
314
|
+
setMessage("Authorized app operations unavailable");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const current = filterRemoteDefinitions(definitions, nodeDefinitions.map((definition) => definition.type));
|
|
318
|
+
const fingerprint = remoteAuthorizationFingerprint(current);
|
|
319
|
+
if (authorizationFingerprint !== null && fingerprint !== authorizationFingerprint) revoke();
|
|
320
|
+
authorizationFingerprint = fingerprint;
|
|
321
|
+
setAuthorizedNodes(current);
|
|
322
|
+
}).catch(() => {
|
|
323
|
+
if (alive && request === revision) {
|
|
324
|
+
authorizationFingerprint = null;
|
|
325
|
+
revoke();
|
|
326
|
+
setMessage("Authorized app operations unavailable");
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
refresh2();
|
|
331
|
+
const unsubscribe = runtime.subscribeAuthorizedNodeChanges?.(workspaceId, () => refresh2(true));
|
|
332
|
+
const fallbackRefresh = scopeKey ? setInterval(() => refresh2(), 3e4) : null;
|
|
333
|
+
return () => {
|
|
334
|
+
alive = false;
|
|
335
|
+
++revision;
|
|
336
|
+
permissionEpoch.current++;
|
|
337
|
+
runningAbort.current?.abort();
|
|
338
|
+
if (fallbackRefresh !== null) clearInterval(fallbackRefresh);
|
|
339
|
+
unsubscribe?.();
|
|
340
|
+
};
|
|
341
|
+
}, [runtime, workspaceId, nodeDefinitions, scopeKey]);
|
|
342
|
+
const visibleNodeDefinitions = useMemo(
|
|
343
|
+
() => [...nodeDefinitions, ...authorizedNodes],
|
|
344
|
+
[nodeDefinitions, authorizedNodes]
|
|
345
|
+
);
|
|
346
|
+
const refresh = async () => {
|
|
347
|
+
const saved = await runtime.listFlows();
|
|
348
|
+
const merged = new Map(saved.map((item) => [item.id, item]));
|
|
349
|
+
for (const [id, draft] of drafts.current) merged.set(id, draft);
|
|
350
|
+
const next = [...merged.values()];
|
|
351
|
+
setFlows(next);
|
|
352
|
+
setActiveId((current) => current ?? next[0]?.id ?? null);
|
|
353
|
+
};
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
void refresh().catch((error) => setMessage(String(error)));
|
|
356
|
+
}, [runtime]);
|
|
357
|
+
useEffect(() => {
|
|
358
|
+
let current = true;
|
|
359
|
+
const draft = activeId ? drafts.current.get(activeId) : void 0;
|
|
360
|
+
setFlow(draft ?? null);
|
|
361
|
+
if (activeId && !draft) {
|
|
362
|
+
void runtime.getFlow(activeId).then((saved) => {
|
|
363
|
+
if (current) setFlow(saved);
|
|
364
|
+
}).catch((error) => {
|
|
365
|
+
if (current) setMessage(String(error));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return () => {
|
|
369
|
+
current = false;
|
|
370
|
+
};
|
|
371
|
+
}, [activeId, runtime]);
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
if (flow && drafts.current.has(flow.id)) drafts.current.set(flow.id, flow);
|
|
374
|
+
}, [flow]);
|
|
375
|
+
const graphNodes = useMemo(() => flow ? toGraphNodes(flow, visibleNodeDefinitions) : [], [flow, visibleNodeDefinitions]);
|
|
376
|
+
const graphEdges = useMemo(() => flow ? toGraphEdges(flow) : [], [flow]);
|
|
377
|
+
const updateNodes = (next) => {
|
|
378
|
+
if (!flow) return;
|
|
379
|
+
const nextFlow = { ...flow, nodes: next.map((node) => {
|
|
380
|
+
const prior = flow.nodes.find((item) => item.id === node.id);
|
|
381
|
+
const data = prior && isRemoteGraphNode(prior) ? { ...node.data ?? {}, ...prior.data ?? {} } : node.data;
|
|
382
|
+
return { ...prior, id: node.id, type: prior && isRemoteGraphNode(prior) ? prior.type : node.type, position: node.position, data };
|
|
383
|
+
}) };
|
|
384
|
+
setFlow(nextFlow);
|
|
385
|
+
};
|
|
386
|
+
const updateEdges = (next) => {
|
|
387
|
+
if (!flow) return;
|
|
388
|
+
const nextFlow = { ...flow, edges: next.map((edge) => ({ id: edge.id, source: edge.source, sourceHandle: edge.sourceSocket, target: edge.target, targetHandle: edge.targetSocket })) };
|
|
389
|
+
setFlow(nextFlow);
|
|
390
|
+
};
|
|
391
|
+
const createFlow = () => {
|
|
392
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
393
|
+
const next = { id: `flow-${crypto.randomUUID()}`, name: "New Flow", version: 1, createdAt: now, updatedAt: now, nodes: [], edges: [], metadata: { workspaceId } };
|
|
394
|
+
drafts.current.set(next.id, next);
|
|
395
|
+
setFlows((current) => [...current, next]);
|
|
396
|
+
setActiveId(next.id);
|
|
397
|
+
setFlow(next);
|
|
398
|
+
};
|
|
399
|
+
const save = async () => {
|
|
400
|
+
if (!flow) return;
|
|
401
|
+
const saved = await runtime.saveFlow(flow);
|
|
402
|
+
drafts.current.delete(flow.id);
|
|
403
|
+
setFlow((current) => current?.id === flow.id ? saved : current);
|
|
404
|
+
await refresh();
|
|
405
|
+
setMessage("Saved");
|
|
406
|
+
};
|
|
407
|
+
const addMagneticEdge = (trace) => {
|
|
408
|
+
if (!flow) return;
|
|
409
|
+
const id = `edge-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
410
|
+
const exists = flow.edges.some((edge) => edge.source === trace.sourceNodeId && edge.target === trace.targetNodeId && edge.sourceHandle === trace.sourceHandleId && edge.targetHandle === trace.targetHandleId);
|
|
411
|
+
if (!exists) setFlow({ ...flow, edges: [...flow.edges, { id, source: trace.sourceNodeId, sourceHandle: trace.sourceHandleId, target: trace.targetNodeId, targetHandle: trace.targetHandleId }] });
|
|
412
|
+
};
|
|
413
|
+
const solidifyGhost = (ghost) => {
|
|
414
|
+
if (!flow || !ghost?.prototypeNode) return;
|
|
415
|
+
const node = ghost.prototypeNode;
|
|
416
|
+
const exists = flow.nodes.some((item) => item.id === ghost.id);
|
|
417
|
+
let next = flow;
|
|
418
|
+
if (!exists) next = { ...next, nodes: [...next.nodes, { id: ghost.id, type: node.type, position: { x: Number(ghost.worldPosition?.[0] ?? node.position?.x ?? 0), y: Number(ghost.worldPosition?.[2] ?? node.position?.y ?? 0) }, data: node.data ?? {} }] };
|
|
419
|
+
const edge = { id: `edge-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, source: ghost.parentSocketPolarity === "input" ? ghost.id : ghost.parentNodeId, sourceHandle: ghost.parentSocketPolarity === "input" ? ghost.matchingSocketId : ghost.parentSocketId, target: ghost.parentSocketPolarity === "input" ? ghost.parentNodeId : ghost.id, targetHandle: ghost.parentSocketPolarity === "input" ? ghost.parentSocketId : ghost.matchingSocketId };
|
|
420
|
+
if (!next.edges.some((item) => item.source === edge.source && item.target === edge.target && item.sourceHandle === edge.sourceHandle && item.targetHandle === edge.targetHandle)) next = { ...next, edges: [...next.edges, edge] };
|
|
421
|
+
setFlow(next);
|
|
422
|
+
};
|
|
423
|
+
const run = async () => {
|
|
424
|
+
if (!flow) return;
|
|
425
|
+
const epoch = permissionEpoch.current;
|
|
426
|
+
const abort = new AbortController();
|
|
427
|
+
runningAbort.current = abort;
|
|
428
|
+
setRunning(true);
|
|
429
|
+
try {
|
|
430
|
+
await save();
|
|
431
|
+
if (abort.signal.aborted || epoch !== permissionEpoch.current) throw new Error("Authorization changed; retry");
|
|
432
|
+
const remoteNodes = flow.nodes.filter(isRemoteGraphNode);
|
|
433
|
+
let result;
|
|
434
|
+
if (remoteNodes.length) {
|
|
435
|
+
if (!scopeKey || !runtime.listAuthorizedNodeDefinitions || !runtime.executeAuthorizedRemoteFlow)
|
|
436
|
+
throw new Error("Remote execution unavailable: authenticated Kloks BackendFacade required");
|
|
437
|
+
const fresh = await runtime.listAuthorizedNodeDefinitions(workspaceId);
|
|
438
|
+
if (abort.signal.aborted || epoch !== permissionEpoch.current) throw new Error("Authorization changed; retry");
|
|
439
|
+
const scoped = filterRemoteDefinitions(fresh, nodeDefinitions.map((definition) => definition.type));
|
|
440
|
+
const check = validateRemoteGraph(flow.nodes, scoped);
|
|
441
|
+
if (!check.ok) throw new Error(check.message ?? "Remote operation denied");
|
|
442
|
+
const wiring = validateRemoteConnections(flow.nodes, flow.edges, [...nodeDefinitions, ...scoped]);
|
|
443
|
+
if (!wiring.ok) throw new Error(wiring.message ?? "Remote graph connections denied");
|
|
444
|
+
if (check.requiresWindowConsent) {
|
|
445
|
+
if (!runtime.authorizeActiveFrontendWindow || !await runtime.authorizeActiveFrontendWindow({ sourceWorkspaceId: workspaceId, handles: check.handles }, { signal: abort.signal }))
|
|
446
|
+
throw new Error("Active frontend window consent required");
|
|
447
|
+
}
|
|
448
|
+
if (abort.signal.aborted || epoch !== permissionEpoch.current) throw new Error("Authorization changed; retry");
|
|
449
|
+
result = await runtime.executeAuthorizedRemoteFlow(
|
|
450
|
+
{ flowId: flow.id, sourceWorkspaceId: workspaceId, handles: check.handles },
|
|
451
|
+
{ signal: abort.signal }
|
|
452
|
+
);
|
|
453
|
+
} else {
|
|
454
|
+
result = await runtime.executeFlow(flow.id);
|
|
455
|
+
}
|
|
456
|
+
if (abort.signal.aborted || epoch !== permissionEpoch.current) throw new Error("Authorization changed; retry");
|
|
457
|
+
setMessage(result.success ? "Execution completed" : result.errors?.[0]?.message ?? "Execution failed");
|
|
458
|
+
} catch (error) {
|
|
459
|
+
setMessage(String(error));
|
|
460
|
+
} finally {
|
|
461
|
+
if (runningAbort.current === abort) runningAbort.current = null;
|
|
462
|
+
setRunning(false);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
const selectedRemote = flow?.nodes.find((node) => selected.has(node.id) && isRemoteGraphNode(node));
|
|
466
|
+
const selectedDefinition = selectedRemote && visibleNodeDefinitions.find((definition) => {
|
|
467
|
+
if (definition.type !== selectedRemote.type) return false;
|
|
468
|
+
const stored = readRemoteHandle(selectedRemote.data), live = readRemoteHandle(definition.metadata);
|
|
469
|
+
return !!stored && !!live && Object.keys(stored).every((key) => stored[key] === live[key]) && (!selectedRemote.data?.remotePortSignature || selectedRemote.data.remotePortSignature === remotePortFingerprint(definition));
|
|
470
|
+
});
|
|
471
|
+
const configureInput = (key, value) => {
|
|
472
|
+
if (!flow || !selectedRemote) return;
|
|
473
|
+
const configured = { ...selectedRemote.data?.configuredInputs ?? {} };
|
|
474
|
+
if (value === void 0) delete configured[key];
|
|
475
|
+
else configured[key] = value;
|
|
476
|
+
setFlow({ ...flow, nodes: flow.nodes.map((node) => node.id === selectedRemote.id ? { ...node, data: { ...node.data, configuredInputs: configured } } : node) });
|
|
477
|
+
};
|
|
478
|
+
const remoteApps = useMemo(() => [...new Set(authorizedNodes.map((node) => String(node.metadata?.appId ?? "")))].filter(Boolean).sort(), [authorizedNodes]);
|
|
479
|
+
const remoteWorkspaces = useMemo(() => [...new Set(authorizedNodes.filter((node) => !remoteAppFilter || node.metadata?.appId === remoteAppFilter).map((node) => String(node.metadata?.targetWorkspaceId ?? "")))].filter(Boolean).sort(), [authorizedNodes, remoteAppFilter]);
|
|
480
|
+
const selectedApp = remoteApps.includes(remoteAppFilter) ? remoteAppFilter : "";
|
|
481
|
+
const selectedWorkspace = remoteWorkspaces.includes(remoteWorkspaceFilter) ? remoteWorkspaceFilter : "";
|
|
482
|
+
const grouped = useMemo(() => {
|
|
483
|
+
const groups = /* @__PURE__ */ new Map();
|
|
484
|
+
for (const node of visibleNodeDefinitions) {
|
|
485
|
+
const appId = node.metadata?.appId;
|
|
486
|
+
const targetWorkspaceId = node.metadata?.targetWorkspaceId;
|
|
487
|
+
if (typeof appId === "string" && (selectedApp && appId !== selectedApp || selectedWorkspace && targetWorkspaceId !== selectedWorkspace)) continue;
|
|
488
|
+
const group = typeof appId === "string" && appId.trim() ? `App ${appId} / workspace ${targetWorkspaceId} / ${node.group} / ${node.category}` : node.group;
|
|
489
|
+
const current = groups.get(group) ?? [];
|
|
490
|
+
current.push(node);
|
|
491
|
+
groups.set(group, current);
|
|
492
|
+
}
|
|
493
|
+
return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
494
|
+
}, [visibleNodeDefinitions, selectedApp, selectedWorkspace]);
|
|
495
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { display: "grid", gridTemplateColumns: "220px 1fr", gridTemplateRows: "44px 1fr", height: "100%", minHeight: 500 }, children: [
|
|
496
|
+
/* @__PURE__ */ jsxs("div", { style: { gridColumn: "1 / -1", display: "flex", alignItems: "center", gap: 8, padding: "6px 10px", borderBottom: "1px solid var(--skipo-border,#333)", background: "var(--skipo-matte-bg,#111)" }, children: [
|
|
497
|
+
/* @__PURE__ */ jsx("strong", { children: "FOD" }),
|
|
498
|
+
/* @__PURE__ */ jsxs("select", { value: activeId ?? "", onChange: (e) => setActiveId(e.target.value || null), children: [
|
|
499
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select flow" }),
|
|
500
|
+
flows.map((item) => /* @__PURE__ */ jsx("option", { value: item.id, children: item.name }, item.id))
|
|
501
|
+
] }),
|
|
502
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: createFlow, children: "New flow" }),
|
|
503
|
+
flow && /* @__PURE__ */ jsx("input", { "aria-label": "Workflow name", value: flow.name, onChange: (event) => setFlow({ ...flow, name: event.target.value }) }),
|
|
504
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => void save().catch((error) => setMessage(String(error))), disabled: !flow?.name.trim(), children: "Save as App Workflow" }),
|
|
505
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => void run(), disabled: !flow || running, children: running ? "Running\u2026" : "Run" }),
|
|
506
|
+
/* @__PURE__ */ jsx("span", { children: message })
|
|
507
|
+
] }),
|
|
508
|
+
/* @__PURE__ */ jsxs("aside", { style: { overflow: "auto", padding: 10, borderRight: "1px solid var(--skipo-border,#333)" }, children: [
|
|
509
|
+
/* @__PURE__ */ jsxs("label", { style: { display: "block", fontSize: 12 }, children: [
|
|
510
|
+
"Remote application",
|
|
511
|
+
/* @__PURE__ */ jsxs("select", { "aria-label": "Remote application", value: selectedApp, onChange: (event) => {
|
|
512
|
+
setRemoteAppFilter(event.target.value);
|
|
513
|
+
setRemoteWorkspaceFilter("");
|
|
514
|
+
}, children: [
|
|
515
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "All authorized apps" }),
|
|
516
|
+
remoteApps.map((app) => /* @__PURE__ */ jsx("option", { value: app, children: app }, app))
|
|
517
|
+
] })
|
|
518
|
+
] }),
|
|
519
|
+
/* @__PURE__ */ jsxs("label", { style: { display: "block", fontSize: 12 }, children: [
|
|
520
|
+
"Target workspace",
|
|
521
|
+
/* @__PURE__ */ jsxs("select", { "aria-label": "Target workspace", value: selectedWorkspace, onChange: (event) => setRemoteWorkspaceFilter(event.target.value), children: [
|
|
522
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "All authorized workspaces" }),
|
|
523
|
+
remoteWorkspaces.map((workspace) => /* @__PURE__ */ jsx("option", { value: workspace, children: workspace }, workspace))
|
|
524
|
+
] })
|
|
525
|
+
] }),
|
|
526
|
+
grouped.map(([group, nodes]) => /* @__PURE__ */ jsxs("section", { children: [
|
|
527
|
+
/* @__PURE__ */ jsx("h4", { style: { margin: "8px 0" }, children: group }),
|
|
528
|
+
nodes.map((node) => /* @__PURE__ */ jsx("button", { type: "button", style: { display: "block", width: "100%", textAlign: "left", marginBottom: 4 }, onClick: () => {
|
|
529
|
+
if (!flow) return;
|
|
530
|
+
const id = `${node.type}-${Date.now()}`;
|
|
531
|
+
const remoteHandle = readRemoteHandle(node.metadata);
|
|
532
|
+
setFlow({ ...flow, nodes: [...flow.nodes, { id, type: node.type, position: { x: 100 + flow.nodes.length * 24, y: 100 + flow.nodes.length * 24 }, data: { endpointId: node.metadata?.endpointId, apiId: node.metadata?.apiId, ...remoteHandle ? { ...remoteHandle, remotePortSignature: remotePortFingerprint(node), remotePorts: snapshotRemotePorts(node) } : {} } }] });
|
|
533
|
+
}, children: node.label }, node.type))
|
|
534
|
+
] }, group)),
|
|
535
|
+
selectedRemote && /* @__PURE__ */ jsxs("section", { "aria-label": "Remote node configuration", style: { borderTop: "1px solid var(--skipo-border,#333)", paddingTop: 10, marginTop: 12 }, children: [
|
|
536
|
+
/* @__PURE__ */ jsx("strong", { children: "Remote operation" }),
|
|
537
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 12, overflowWrap: "anywhere" }, children: [
|
|
538
|
+
selectedRemote.data?.appId,
|
|
539
|
+
" / ",
|
|
540
|
+
selectedRemote.data?.operationId,
|
|
541
|
+
" @ ",
|
|
542
|
+
selectedRemote.data?.operationVersion
|
|
543
|
+
] }),
|
|
544
|
+
!selectedDefinition ? /* @__PURE__ */ jsx("p", { children: "Operation unavailable or contract changed. Saved node data is retained." }) : selectedDefinition.inputs.map((port) => /* @__PURE__ */ jsxs("label", { style: { display: "block", marginTop: 8 }, children: [
|
|
545
|
+
port.name,
|
|
546
|
+
" (",
|
|
547
|
+
port.dataType,
|
|
548
|
+
")",
|
|
549
|
+
port.dataType === "boolean" ? /* @__PURE__ */ jsxs("select", { "aria-label": port.name, value: String(selectedRemote.data?.configuredInputs?.[port.id] ?? ""), onChange: (e) => configureInput(port.id, e.target.value === "" ? void 0 : e.target.value === "true"), children: [
|
|
550
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Unset" }),
|
|
551
|
+
/* @__PURE__ */ jsx("option", { value: "true", children: "True" }),
|
|
552
|
+
/* @__PURE__ */ jsx("option", { value: "false", children: "False" })
|
|
553
|
+
] }) : port.dataType === "object" || port.dataType === "array" ? /* @__PURE__ */ jsx(
|
|
554
|
+
"textarea",
|
|
555
|
+
{
|
|
556
|
+
"aria-label": port.name,
|
|
557
|
+
defaultValue: JSON.stringify(selectedRemote.data?.configuredInputs?.[port.id] ?? (port.dataType === "array" ? [] : {})),
|
|
558
|
+
onBlur: (e) => {
|
|
559
|
+
try {
|
|
560
|
+
configureInput(port.id, JSON.parse(e.target.value));
|
|
561
|
+
} catch {
|
|
562
|
+
setMessage("Invalid JSON input for " + port.name);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
) : /* @__PURE__ */ jsx(
|
|
567
|
+
"input",
|
|
568
|
+
{
|
|
569
|
+
"aria-label": port.name,
|
|
570
|
+
type: port.dataType === "number" ? "number" : "text",
|
|
571
|
+
value: String(selectedRemote.data?.configuredInputs?.[port.id] ?? ""),
|
|
572
|
+
onChange: (e) => configureInput(port.id, e.target.value === "" ? void 0 : port.dataType === "number" ? Number(e.target.value) : e.target.value)
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
] }, port.id))
|
|
576
|
+
] })
|
|
577
|
+
] }),
|
|
578
|
+
/* @__PURE__ */ jsx("main", { style: { minWidth: 0, minHeight: 0 }, children: flow ? /* @__PURE__ */ jsx(FrnlEditableNodeGraph, { nodes: graphNodes, edges: graphEdges, selectedNodeIds: selected, onSelectionChange: setSelected, onNodesChange: updateNodes, onEdgesChange: updateEdges, magneticEnabled: true, autoSolidifyEnabled: false, signalTelemetryEnabled: true, onMagneticTraceSolidify: addMagneticEdge, onPredictiveSolidify: (_id, ghost) => solidifyGhost(ghost), onPredictiveSolidifyAll: (ghosts) => ghosts?.forEach(solidifyGhost), onPredictiveSolidifyAllForNode: (_nodeId, ghosts) => ghosts?.forEach(solidifyGhost) }) : /* @__PURE__ */ jsx("div", { style: { padding: 30 }, children: "Create or select a flow." }) })
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
FodModule.displayName = "FodModule";
|
|
582
|
+
|
|
583
|
+
// src/fod/remoteKloksInvocation.ts
|
|
584
|
+
var validApp = (value) => /^[a-z][a-z0-9-]{0,62}$/.test(value);
|
|
585
|
+
var validWorkflow = (value) => value !== "." && value !== ".." && !value.includes("/") && !value.includes("\\");
|
|
586
|
+
function toKloksPublishedWorkflowCall(candidate, input) {
|
|
587
|
+
const handle = readRemoteHandle(candidate);
|
|
588
|
+
if (!handle || !validApp(handle.appId) || !validWorkflow(handle.operationId) || !/^[1-9][0-9]*$/.test(handle.operationVersion)) {
|
|
589
|
+
throw new Error("Invalid published workflow graph handle");
|
|
590
|
+
}
|
|
591
|
+
const version = Number(handle.operationVersion);
|
|
592
|
+
if (!Number.isSafeInteger(version) || version < 1)
|
|
593
|
+
throw new Error("Invalid published workflow revision");
|
|
594
|
+
return {
|
|
595
|
+
targetAppId: handle.appId,
|
|
596
|
+
targetWorkspaceId: handle.targetWorkspaceId,
|
|
597
|
+
workflowId: handle.operationId,
|
|
598
|
+
version,
|
|
599
|
+
...input === void 0 ? {} : { input }
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
async function invokeKloksPublishedWorkflow(client, handle, input) {
|
|
603
|
+
if (!client || typeof client.domain !== "function")
|
|
604
|
+
throw new Error("Authenticated Kloks BackendClient is required");
|
|
605
|
+
const call = toKloksPublishedWorkflowCall(handle, input);
|
|
606
|
+
const facade = client.domain("fod");
|
|
607
|
+
if (!facade || typeof facade.execute !== "function")
|
|
608
|
+
throw new Error("Kloks FOD BackendFacade command is unavailable");
|
|
609
|
+
return await facade.execute("executePublishedWorkflow", call);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export {
|
|
613
|
+
readRemoteHandle,
|
|
614
|
+
isRemoteGraphNode,
|
|
615
|
+
isLiveFrontendDefinition,
|
|
616
|
+
filterRemoteDefinitions,
|
|
617
|
+
validateRemoteGraph,
|
|
618
|
+
snapshotRemotePorts,
|
|
619
|
+
readRemotePortSnapshot,
|
|
620
|
+
remotePortFingerprint,
|
|
621
|
+
validateRemoteConnections,
|
|
622
|
+
FodModule,
|
|
623
|
+
toKloksPublishedWorkflowCall,
|
|
624
|
+
invokeKloksPublishedWorkflow
|
|
625
|
+
};
|