@ultrst-armada/kloks 2.2.3 → 2.2.5
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/package.json +14 -2
- package/packages/aiko/dist/index.d.ts +95 -2
- package/packages/aiko/dist/index.js +277 -45
- package/packages/backend/dist/ai-inference/index.js +1 -1
- package/packages/backend/dist/ai-inference/inferenceExecutor.test.d.ts +1 -0
- package/packages/backend/dist/ai-models/index.js +2 -2
- package/packages/backend/dist/ai-routing/index.js +3 -3
- package/packages/backend/dist/auth/OidcBff.d.ts +50 -0
- package/packages/backend/dist/auth/OidcBff.test.d.ts +1 -0
- package/packages/backend/dist/auth/OidcBffEnv.d.ts +23 -0
- package/packages/backend/dist/auth/index.d.ts +2 -0
- package/packages/backend/dist/auth/index.js +6 -1
- package/packages/backend/dist/{chunk-RFPGUJAZ.js → chunk-26NAKO4V.js} +7 -7
- package/packages/backend/dist/{chunk-NIP22V2G.js → chunk-E2I7D52V.js} +22 -1
- package/packages/backend/dist/{chunk-5E6JRFUH.js → chunk-HX5TN27Y.js} +294 -4
- package/packages/backend/dist/{chunk-GCTQY24J.js → chunk-MK4ZRBFI.js} +7 -6
- package/packages/backend/dist/{chunk-LMAU62ZG.js → chunk-PT6J6UEU.js} +4 -4
- package/packages/backend/dist/chunk-SEKPSCWP.js +350 -0
- package/packages/backend/dist/{chunk-N7OUR5R5.js → chunk-YDGW7PXM.js} +1 -1
- package/packages/backend/dist/client/index.js +2 -2
- package/packages/backend/dist/connectivity/FrontendSession.d.ts +1 -0
- package/packages/backend/dist/connectivity/FrontendSession.dispose.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/HTTPTransport.d.ts +1 -0
- package/packages/backend/dist/connectivity/HTTPTransport.operation.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/InProcessExecutor.session.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/RemoteExecutor.error.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/facadeInvocation.adversarial_replay.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/facadeInvocation.d.ts +101 -0
- package/packages/backend/dist/connectivity/facadeInvocation.oneUseLuthContract.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/facadeInvocation.test.d.ts +1 -0
- package/packages/backend/dist/connectivity/index.d.ts +2 -0
- package/packages/backend/dist/connectivity/index.js +8 -4
- package/packages/backend/dist/index.js +7 -3
- package/packages/backend/dist/krnl-ai-services.js +6 -6
- package/packages/backend/dist/node.js +34 -25
- package/packages/backend/package.json +1 -1
- package/packages/client/dist/auth.d.ts +1 -1
- package/packages/client/dist/auth.js +5 -1
- package/packages/client/dist/{chunk-ATLIA7AJ.js → chunk-WYC7RG32.js} +5 -1
- package/packages/client/dist/index.d.ts +1 -1
- package/packages/client/dist/index.js +5 -1
- package/packages/client/package.json +1 -1
- package/packages/fod/dist/chunk-Q4OLPORH.js +111 -0
- package/packages/fod/dist/chunk-SMWRWNEW.js +81 -0
- package/packages/fod/dist/index.d.ts +12 -95
- package/packages/fod/dist/index.js +34 -11
- package/packages/fod/dist/quickJsAdapter-BRj8ixha.d.ts +34 -0
- package/packages/fod/dist/quickjs-node.d.ts +6 -0
- package/packages/fod/dist/quickjs-node.js +73 -0
- package/packages/fod/dist/quickjs-worker.d.ts +8 -0
- package/packages/fod/dist/quickjs-worker.js +51 -0
- package/packages/fod/dist/smallScript-wzJ-VayJ.d.ts +130 -0
- package/packages/fod/package.json +11 -3
- package/packages/backend/dist/chunk-JQKKMUCT.js +0 -0
- package/packages/backend/dist/{chunk-EREYT3WJ.js → chunk-LMWXONZG.js} +3 -3
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createQuickJsSmallScriptExecutor
|
|
3
|
+
} from "./chunk-Q4OLPORH.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_SMALL_SCRIPT_LIMITS,
|
|
6
|
+
SMALL_SCRIPT_NODE,
|
|
7
|
+
SmallScriptLimitError,
|
|
8
|
+
executeSmallScript,
|
|
9
|
+
jsonBoundary
|
|
10
|
+
} from "./chunk-SMWRWNEW.js";
|
|
11
|
+
|
|
1
12
|
// src/endpointNodeProvider.ts
|
|
2
13
|
function portsFromSchema(schema, direction) {
|
|
3
14
|
if (!schema || schema.type !== "object") {
|
|
@@ -108,7 +119,7 @@ var FodFlowStore = class {
|
|
|
108
119
|
};
|
|
109
120
|
|
|
110
121
|
// src/executor.ts
|
|
111
|
-
async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
122
|
+
async function executeFodFlow(flow, endpoints, onEvent, initialInput, options = {}) {
|
|
112
123
|
const events = [];
|
|
113
124
|
const errors = [];
|
|
114
125
|
const emit = (event) => {
|
|
@@ -116,7 +127,7 @@ async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
|
116
127
|
onEvent?.(event);
|
|
117
128
|
};
|
|
118
129
|
emit({ type: "flow-started", timestamp: Date.now(), flowId: flow.id });
|
|
119
|
-
const outputs =
|
|
130
|
+
const outputs = /* @__PURE__ */ Object.create(null);
|
|
120
131
|
const incoming = (nodeId) => flow.edges.filter((edge) => edge.target === nodeId);
|
|
121
132
|
const remaining = new Set(flow.nodes.map((node) => node.id));
|
|
122
133
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -129,13 +140,18 @@ async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
|
129
140
|
break;
|
|
130
141
|
}
|
|
131
142
|
for (const node of ready) {
|
|
143
|
+
if (options.signal?.aborted) {
|
|
144
|
+
errors.push({ nodeId: node.id, message: "Execution cancelled.", code: "CANCELLED" });
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
132
147
|
remaining.delete(node.id);
|
|
133
148
|
emit({ type: "node-started", timestamp: Date.now(), flowId: flow.id, nodeId: node.id });
|
|
134
149
|
try {
|
|
135
150
|
const endpointId = String(node.data?.endpointId ?? node.data?.apiId ?? node.type.replace(/^(host|gutts)\//, ""));
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
const isJavaScript = node.type === "system/javascript" || node.type === "custom/js-block";
|
|
152
|
+
const endpoint = isJavaScript ? void 0 : endpoints.get(endpointId);
|
|
153
|
+
if (!isJavaScript && !endpoint) throw new Error(`No executable endpoint registered for node '${node.type}'.`);
|
|
154
|
+
const input = /* @__PURE__ */ Object.create(null);
|
|
139
155
|
if (incoming(node.id).length === 0 && initialInput !== void 0) {
|
|
140
156
|
if (typeof initialInput === "object" && initialInput !== null) {
|
|
141
157
|
Object.assign(input, initialInput);
|
|
@@ -148,7 +164,7 @@ async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
|
148
164
|
}
|
|
149
165
|
const configured = node.data?.inputs ?? {};
|
|
150
166
|
Object.assign(input, configured);
|
|
151
|
-
const result = await endpoint.invoke(input);
|
|
167
|
+
const result = isJavaScript ? await executeSmallScript(options.scriptExecutor, node.data?.code, input, options.signal) : await endpoint.invoke(input);
|
|
152
168
|
outputs[node.id] = result;
|
|
153
169
|
values.set(`${node.id}:result`, result);
|
|
154
170
|
if (result && typeof result === "object") {
|
|
@@ -157,8 +173,9 @@ async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
|
157
173
|
emit({ type: "node-completed", timestamp: Date.now(), flowId: flow.id, nodeId: node.id, data: result });
|
|
158
174
|
} catch (error) {
|
|
159
175
|
const message = error instanceof Error ? error.message : String(error);
|
|
160
|
-
|
|
161
|
-
|
|
176
|
+
const code = error instanceof SmallScriptLimitError ? error.code : void 0;
|
|
177
|
+
errors.push({ nodeId: node.id, message, ...code && { code } });
|
|
178
|
+
emit({ type: "node-failed", timestamp: Date.now(), flowId: flow.id, nodeId: node.id, data: message, ...code && { code } });
|
|
162
179
|
break;
|
|
163
180
|
}
|
|
164
181
|
}
|
|
@@ -185,7 +202,7 @@ var FodRuntime = class {
|
|
|
185
202
|
this.nodes = nodes;
|
|
186
203
|
}
|
|
187
204
|
getNodeDefinitions() {
|
|
188
|
-
return [...this.nodes];
|
|
205
|
+
return [SMALL_SCRIPT_NODE, ...this.nodes.filter((node) => node.type !== SMALL_SCRIPT_NODE.type)];
|
|
189
206
|
}
|
|
190
207
|
getEndpoints() {
|
|
191
208
|
return [...this.endpoints.values()];
|
|
@@ -202,10 +219,10 @@ var FodRuntime = class {
|
|
|
202
219
|
async deleteFlow(flowId) {
|
|
203
220
|
return this.flowStore.delete(this.options.workspaceId, flowId);
|
|
204
221
|
}
|
|
205
|
-
async executeFlow(flowId, input) {
|
|
222
|
+
async executeFlow(flowId, input, options = {}) {
|
|
206
223
|
const flow = await this.getFlow(flowId);
|
|
207
224
|
if (!flow) throw new Error(`FOD flow '${flowId}' not found.`);
|
|
208
|
-
return executeFodFlow(flow, this.endpoints, this.options.onEvent, input);
|
|
225
|
+
return executeFodFlow(flow, this.endpoints, this.options.onEvent, input, { scriptExecutor: this.options.scriptExecutor, signal: options.signal });
|
|
209
226
|
}
|
|
210
227
|
};
|
|
211
228
|
|
|
@@ -251,13 +268,19 @@ function createFodServiceFacadeForWorkspace(buildRuntime) {
|
|
|
251
268
|
}
|
|
252
269
|
var FodServiceFacade = createFodServiceFacade(new FodRuntime({ workspaceId: "default", workspaceService: null }));
|
|
253
270
|
export {
|
|
271
|
+
DEFAULT_SMALL_SCRIPT_LIMITS,
|
|
254
272
|
FodFlowStore,
|
|
255
273
|
FodRuntime,
|
|
256
274
|
FodServiceFacade,
|
|
275
|
+
SMALL_SCRIPT_NODE,
|
|
276
|
+
SmallScriptLimitError,
|
|
257
277
|
createFodServiceFacade,
|
|
258
278
|
createFodServiceFacadeForWorkspace,
|
|
279
|
+
createQuickJsSmallScriptExecutor,
|
|
259
280
|
endpointToNode,
|
|
260
281
|
executeFodFlow,
|
|
282
|
+
executeSmallScript,
|
|
283
|
+
jsonBoundary,
|
|
261
284
|
scanBackendFacade,
|
|
262
285
|
scanBackendFacadeToNodes
|
|
263
286
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { S as SmallScriptExecutor } from './smallScript-wzJ-VayJ.js';
|
|
2
|
+
|
|
3
|
+
/** Structural QuickJS API, intentionally independent of any WASM package.
|
|
4
|
+
* A runtime-specific host loader supplies a precompiled WASM module:
|
|
5
|
+
* - Cloudflare: use the bundler-imported WebAssembly.Module variant.
|
|
6
|
+
* - Vercel Node/Edge: use a target-supported variant and verify host limits.
|
|
7
|
+
* Bundling this module does not load QuickJS or any WASM until explicitly enabled.
|
|
8
|
+
*/
|
|
9
|
+
interface QuickJsModule {
|
|
10
|
+
newRuntime(): QuickJsRuntime;
|
|
11
|
+
}
|
|
12
|
+
interface QuickJsHandle {
|
|
13
|
+
dispose(): void;
|
|
14
|
+
}
|
|
15
|
+
interface QuickJsContext {
|
|
16
|
+
evalCode(code: string): {
|
|
17
|
+
value?: QuickJsHandle;
|
|
18
|
+
error?: QuickJsHandle;
|
|
19
|
+
};
|
|
20
|
+
typeof(handle: QuickJsHandle): string;
|
|
21
|
+
getString(handle: QuickJsHandle): string;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
interface QuickJsRuntime {
|
|
25
|
+
setMemoryLimit(bytes: number): void;
|
|
26
|
+
setMaxStackSize(bytes: number): void;
|
|
27
|
+
setInterruptHandler(handler: () => boolean): void;
|
|
28
|
+
newContext(): QuickJsContext;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
/** The host clock must advance during synchronous Wasm execution. */
|
|
32
|
+
declare function createQuickJsSmallScriptExecutor(load: () => Promise<QuickJsModule>, now?: () => number): SmallScriptExecutor;
|
|
33
|
+
|
|
34
|
+
export { type QuickJsModule as Q, createQuickJsSmallScriptExecutor as c };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { S as SmallScriptExecutor } from './smallScript-wzJ-VayJ.js';
|
|
2
|
+
|
|
3
|
+
/** Opt-in adapter for Node.js hosts with Worker thread support. */
|
|
4
|
+
declare function createNodeQuickJsSmallScriptExecutor(): SmallScriptExecutor;
|
|
5
|
+
|
|
6
|
+
export { createNodeQuickJsSmallScriptExecutor };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SmallScriptLimitError
|
|
3
|
+
} from "./chunk-SMWRWNEW.js";
|
|
4
|
+
|
|
5
|
+
// src/quickjs-node.ts
|
|
6
|
+
import { Worker } from "worker_threads";
|
|
7
|
+
function createNodeQuickJsSmallScriptExecutor() {
|
|
8
|
+
return {
|
|
9
|
+
execute({ signal, ...request }) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const unavailable = () => new SmallScriptLimitError("EXECUTOR_UNAVAILABLE", "Isolated JavaScript worker is unavailable.");
|
|
12
|
+
const cancelled = () => new SmallScriptLimitError("CANCELLED", "Execution was cancelled.");
|
|
13
|
+
if (signal?.aborted) {
|
|
14
|
+
reject(cancelled());
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (globalThis.navigator?.userAgent?.includes("Cloudflare-Workers")) {
|
|
18
|
+
reject(unavailable());
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let worker;
|
|
22
|
+
try {
|
|
23
|
+
worker = new Worker(new URL("./quickjs-worker.js", import.meta.url), { env: {}, execArgv: [] });
|
|
24
|
+
} catch {
|
|
25
|
+
reject(unavailable());
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let settled = false;
|
|
29
|
+
let running = false;
|
|
30
|
+
let timer = setTimeout(() => finish(unavailable()), 5e3);
|
|
31
|
+
const abort = () => finish(cancelled());
|
|
32
|
+
function finish(error, value) {
|
|
33
|
+
if (settled) return;
|
|
34
|
+
settled = true;
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
signal?.removeEventListener("abort", abort);
|
|
37
|
+
void worker.terminate().then(
|
|
38
|
+
() => error ? reject(error) : resolve(value),
|
|
39
|
+
() => reject(unavailable())
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
worker.on("error", () => finish(unavailable()));
|
|
43
|
+
worker.on("exit", () => finish(unavailable()));
|
|
44
|
+
worker.on("message", (reply) => {
|
|
45
|
+
if (settled) return;
|
|
46
|
+
if (reply.type === "ready" && !running) {
|
|
47
|
+
running = true;
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
timer = setTimeout(
|
|
50
|
+
() => finish(new SmallScriptLimitError("SCRIPT_INTERRUPTED", "JavaScript execution budget exhausted.")),
|
|
51
|
+
request.limits.wallMs
|
|
52
|
+
);
|
|
53
|
+
try {
|
|
54
|
+
worker.postMessage(request);
|
|
55
|
+
} catch {
|
|
56
|
+
finish(new SmallScriptLimitError("INVALID_JSON", "JavaScript input must be valid JSON."));
|
|
57
|
+
}
|
|
58
|
+
} else if (reply.type === "success" && running) {
|
|
59
|
+
finish(void 0, reply.value);
|
|
60
|
+
} else if (reply.type === "failure") {
|
|
61
|
+
finish(new SmallScriptLimitError(reply.code, reply.message));
|
|
62
|
+
} else {
|
|
63
|
+
finish(unavailable());
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createNodeQuickJsSmallScriptExecutor
|
|
73
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Q as QuickJsModule } from './quickJsAdapter-BRj8ixha.js';
|
|
2
|
+
import { S as SmallScriptExecutor } from './smallScript-wzJ-VayJ.js';
|
|
3
|
+
|
|
4
|
+
declare function loadInterpreter(): Promise<QuickJsModule>;
|
|
5
|
+
/** Opt-in adapter for Node.js hosts, including Vercel's Node.js function target. */
|
|
6
|
+
declare function createWorkerQuickJsSmallScriptExecutor(): SmallScriptExecutor;
|
|
7
|
+
|
|
8
|
+
export { createWorkerQuickJsSmallScriptExecutor, loadInterpreter };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createQuickJsSmallScriptExecutor
|
|
3
|
+
} from "./chunk-Q4OLPORH.js";
|
|
4
|
+
import {
|
|
5
|
+
SmallScriptLimitError
|
|
6
|
+
} from "./chunk-SMWRWNEW.js";
|
|
7
|
+
|
|
8
|
+
// src/quickjs-worker.ts
|
|
9
|
+
import { performance } from "perf_hooks";
|
|
10
|
+
import { parentPort } from "worker_threads";
|
|
11
|
+
import releaseSync from "@jitl/quickjs-wasmfile-release-sync";
|
|
12
|
+
import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core";
|
|
13
|
+
var interpreter;
|
|
14
|
+
async function loadInterpreter() {
|
|
15
|
+
if (globalThis.navigator?.userAgent?.includes("Cloudflare-Workers")) {
|
|
16
|
+
throw new SmallScriptLimitError("EXECUTOR_UNAVAILABLE", "The Node.js sandbox requires a host clock that advances during computation.");
|
|
17
|
+
}
|
|
18
|
+
interpreter ??= newQuickJSWASMModuleFromVariant(releaseSync);
|
|
19
|
+
try {
|
|
20
|
+
return await interpreter;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
interpreter = void 0;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function createWorkerQuickJsSmallScriptExecutor() {
|
|
27
|
+
return createQuickJsSmallScriptExecutor(loadInterpreter, () => performance.now());
|
|
28
|
+
}
|
|
29
|
+
var port = parentPort;
|
|
30
|
+
if (port) {
|
|
31
|
+
const executor = createWorkerQuickJsSmallScriptExecutor();
|
|
32
|
+
void loadInterpreter().then(() => {
|
|
33
|
+
port.once("message", async (request) => {
|
|
34
|
+
try {
|
|
35
|
+
const value = await executor.execute(request);
|
|
36
|
+
port.postMessage({ type: "success", value });
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const code = error instanceof SmallScriptLimitError ? error.code : "SCRIPT_ERROR";
|
|
39
|
+
const message = error instanceof SmallScriptLimitError ? error.message : "JavaScript execution failed.";
|
|
40
|
+
port.postMessage({ type: "failure", code, message });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
port.postMessage({ type: "ready" });
|
|
44
|
+
}, () => {
|
|
45
|
+
port.postMessage({ type: "failure", code: "EXECUTOR_UNAVAILABLE", message: "Could not load QuickJS-WASM." });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
createWorkerQuickJsSmallScriptExecutor,
|
|
50
|
+
loadInterpreter
|
|
51
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
type FodPortDirection = 'input' | 'output';
|
|
2
|
+
type FodNodeCategory = 'host-app' | 'gutts' | 'flow' | 'system';
|
|
3
|
+
interface FodPort {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
direction: FodPortDirection;
|
|
7
|
+
dataType: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
description?: string;
|
|
10
|
+
schema?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface FodNodeDefinition {
|
|
13
|
+
type: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description: string;
|
|
16
|
+
category: FodNodeCategory;
|
|
17
|
+
group: string;
|
|
18
|
+
inputs: FodPort[];
|
|
19
|
+
outputs: FodPort[];
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
interface FodEndpointDescriptor {
|
|
23
|
+
id: string;
|
|
24
|
+
serviceId: string;
|
|
25
|
+
serviceName: string;
|
|
26
|
+
operationId: string;
|
|
27
|
+
operationName: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
runtime?: string;
|
|
30
|
+
deployment?: string;
|
|
31
|
+
inputSchema?: Record<string, unknown>;
|
|
32
|
+
outputSchema?: Record<string, unknown>;
|
|
33
|
+
invoke: (input: unknown) => Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
interface FodFlowNode {
|
|
36
|
+
id: string;
|
|
37
|
+
type: string;
|
|
38
|
+
position: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
42
|
+
data: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface FodFlowEdge {
|
|
45
|
+
id: string;
|
|
46
|
+
source: string;
|
|
47
|
+
sourceHandle?: string;
|
|
48
|
+
target: string;
|
|
49
|
+
targetHandle?: string;
|
|
50
|
+
}
|
|
51
|
+
interface FodFlow {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
version: number;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
nodes: FodFlowNode[];
|
|
59
|
+
edges: FodFlowEdge[];
|
|
60
|
+
viewport?: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
zoom: number;
|
|
64
|
+
};
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
interface FodExecutionEvent {
|
|
68
|
+
type: 'flow-started' | 'node-started' | 'node-completed' | 'node-failed' | 'flow-completed';
|
|
69
|
+
timestamp: number;
|
|
70
|
+
flowId: string;
|
|
71
|
+
nodeId?: string;
|
|
72
|
+
code?: string;
|
|
73
|
+
data?: unknown;
|
|
74
|
+
}
|
|
75
|
+
interface FodExecutionResult {
|
|
76
|
+
success: boolean;
|
|
77
|
+
flowId: string;
|
|
78
|
+
output: unknown;
|
|
79
|
+
outputs: Record<string, unknown>;
|
|
80
|
+
errors: Array<{
|
|
81
|
+
nodeId?: string;
|
|
82
|
+
message: string;
|
|
83
|
+
code?: string;
|
|
84
|
+
}>;
|
|
85
|
+
events: FodExecutionEvent[];
|
|
86
|
+
}
|
|
87
|
+
interface FodRuntimeOptions {
|
|
88
|
+
workspaceId: string;
|
|
89
|
+
workspaceService: any;
|
|
90
|
+
endpoints?: FodEndpointDescriptor[];
|
|
91
|
+
nodes?: FodNodeDefinition[];
|
|
92
|
+
onEvent?: (event: FodExecutionEvent) => void;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Host-independent contract for the opt-in small-JavaScript workflow node.
|
|
96
|
+
* No host eval/Function, Node APIs, or interpreter payload is imported here.
|
|
97
|
+
* The interpreter must interrupt itself; a Promise timeout cannot stop a JS loop.
|
|
98
|
+
*/
|
|
99
|
+
interface SmallScriptLimits {
|
|
100
|
+
sourceBytes: number;
|
|
101
|
+
inputBytes: number;
|
|
102
|
+
outputBytes: number;
|
|
103
|
+
heapBytes: number;
|
|
104
|
+
wallMs: number;
|
|
105
|
+
maxInterruptChecks: number;
|
|
106
|
+
maxAttempts: 1;
|
|
107
|
+
}
|
|
108
|
+
declare const DEFAULT_SMALL_SCRIPT_LIMITS: Readonly<SmallScriptLimits>;
|
|
109
|
+
declare class SmallScriptLimitError extends Error {
|
|
110
|
+
readonly code: string;
|
|
111
|
+
constructor(code: string, message: string);
|
|
112
|
+
}
|
|
113
|
+
interface SmallScriptRequest {
|
|
114
|
+
code: string;
|
|
115
|
+
inputs: Record<string, unknown>;
|
|
116
|
+
limits: Readonly<SmallScriptLimits>;
|
|
117
|
+
signal?: AbortSignal;
|
|
118
|
+
}
|
|
119
|
+
interface SmallScriptExecutor {
|
|
120
|
+
/** Trusted host adapter; must enforce heap, time, and interrupt limits itself. */
|
|
121
|
+
execute(request: SmallScriptRequest): Promise<unknown>;
|
|
122
|
+
}
|
|
123
|
+
/** Sanitizes values through the JSON boundary; functions, cycles and oversized values are rejected. */
|
|
124
|
+
declare function jsonBoundary(value: unknown, maxBytes: number, label: string): unknown;
|
|
125
|
+
/** Does not execute untrusted code when the host has no verified interpreter. */
|
|
126
|
+
declare function executeSmallScript(executor: SmallScriptExecutor | undefined, code: unknown, input: Record<string, unknown>, signal?: AbortSignal, limits?: Readonly<SmallScriptLimits>): Promise<unknown>;
|
|
127
|
+
/** Built-in node descriptor. Execution remains disabled until an isolated adapter is provided. */
|
|
128
|
+
declare const SMALL_SCRIPT_NODE: FodNodeDefinition;
|
|
129
|
+
|
|
130
|
+
export { DEFAULT_SMALL_SCRIPT_LIMITS as D, type FodEndpointDescriptor as F, type SmallScriptExecutor as S, type FodNodeDefinition as a, type FodFlow as b, type FodExecutionEvent as c, type FodExecutionResult as d, type FodFlowEdge as e, type FodFlowNode as f, type FodNodeCategory as g, type FodPort as h, type FodPortDirection as i, type FodRuntimeOptions as j, SMALL_SCRIPT_NODE as k, SmallScriptLimitError as l, type SmallScriptLimits as m, type SmallScriptRequest as n, executeSmallScript as o, jsonBoundary as p };
|
|
@@ -16,21 +16,29 @@
|
|
|
16
16
|
"import": "./dist/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./quickjs-node": {
|
|
21
|
+
"types": "./dist/quickjs-node.d.ts",
|
|
22
|
+
"import": "./dist/quickjs-node.js",
|
|
23
|
+
"default": "./dist/quickjs-node.js"
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts --format esm --dts --clean --external @ultrst-armada/krnl",
|
|
27
|
+
"build": "tsup src/index.ts src/quickjs-node.ts src/quickjs-worker.ts --format esm --dts --clean --external @ultrst-armada/krnl",
|
|
23
28
|
"typecheck": "tsc --noEmit",
|
|
24
29
|
"test": "vitest run",
|
|
25
30
|
"clean": "rm -rf dist"
|
|
26
31
|
},
|
|
27
32
|
"dependencies": {
|
|
28
|
-
"@
|
|
33
|
+
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
|
|
34
|
+
"@ultrst-armada/kloks": "workspace:*",
|
|
35
|
+
"quickjs-emscripten-core": "0.32.0"
|
|
29
36
|
},
|
|
30
37
|
"devDependencies": {
|
|
31
38
|
"@ultrst-armada/krnl": "^1.0.9",
|
|
32
39
|
"tsup": "^8.4.0",
|
|
33
40
|
"typescript": "^5.7.3",
|
|
34
|
-
"vitest": "^3.1.0"
|
|
41
|
+
"vitest": "^3.1.0",
|
|
42
|
+
"@types/node": "^22.15.0"
|
|
35
43
|
}
|
|
36
44
|
}
|
|
File without changes
|