orchajs 0.20.0 → 0.20.2
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 +21 -5
- package/dist/compiler/build-project.js +17 -0
- package/dist/orcha.js +47 -4
- package/dist/runtime/actions/execute.d.ts +5 -0
- package/dist/runtime/actions/execute.js +8 -1
- package/dist-cjs/compiler/build-project.js +29 -0
- package/dist-cjs/orcha.js +48 -5
- package/dist-cjs/runtime/actions/execute.js +13 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -808,13 +808,29 @@ module.exports = {
|
|
|
808
808
|
};
|
|
809
809
|
```
|
|
810
810
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
handlers.
|
|
811
|
+
For an unbundled production application built with plain `tsc` or
|
|
812
|
+
`serverless-plugin-typescript`, run:
|
|
814
813
|
|
|
815
|
-
|
|
814
|
+
```bash
|
|
815
|
+
npx orcha build
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
Package `.orcha/dist/manifest.json` with the application. AWS Lambda is
|
|
819
|
+
detected automatically; other unbundled environments should set
|
|
820
|
+
`NODE_ENV=production` or `ORCHA_USE_BUILD=1`. The normal `orchajs` import and
|
|
821
|
+
`orcha.init()` call then load the compiled manifest synchronously, so the
|
|
822
|
+
`orcha/` agent source folders do not need to be deployed.
|
|
823
|
+
|
|
824
|
+
This compatibility path still deploys the regular `orchajs` runtime and its
|
|
825
|
+
dependencies. Use the esbuild integration above when deployment size matters;
|
|
826
|
+
it replaces the package import with `.orcha/dist/bundle.js` and removes
|
|
827
|
+
compiler-only code.
|
|
828
|
+
|
|
829
|
+
Bundled production CI should package the same way as deployment and verify
|
|
830
|
+
that:
|
|
816
831
|
|
|
817
|
-
- the build generated `.orcha/dist/bundle.js
|
|
832
|
+
- the build generated `.orcha/dist/bundle.js` and
|
|
833
|
+
`.orcha/dist/manifest.json`;
|
|
818
834
|
- bundled handlers contain no unresolved bare `orchajs` import or require;
|
|
819
835
|
- the deployment archive does not contain `node_modules/orchajs`.
|
|
820
836
|
|
|
@@ -15,6 +15,7 @@ export async function buildProject(options = {}) {
|
|
|
15
15
|
const registryBundlePath = resolve(temporaryDirectory, "registry.mjs");
|
|
16
16
|
const productionEntryPath = resolve(temporaryDirectory, "production-entry.mjs");
|
|
17
17
|
const outputPath = resolve(projectRoot, ".orcha/dist/bundle.js");
|
|
18
|
+
const manifestPath = resolve(projectRoot, ".orcha/dist/manifest.json");
|
|
18
19
|
await mkdir(temporaryDirectory, { recursive: true });
|
|
19
20
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
20
21
|
try {
|
|
@@ -52,6 +53,9 @@ export async function buildProject(options = {}) {
|
|
|
52
53
|
const compiledBundle = orcha.getCompiledBundle();
|
|
53
54
|
const runtimeFactoryPath = resolve(dirname(fileURLToPath(import.meta.url)), "../runtime/create-orcha.js").replaceAll("\\", "/");
|
|
54
55
|
const providerDispatcherPath = resolve(dirname(fileURLToPath(import.meta.url)), "../providers/dispatcher.js").replaceAll("\\", "/");
|
|
56
|
+
const sandboxRuntimeSource = compiledBundle.actionRuntime === "sandbox"
|
|
57
|
+
? createSandboxRuntimeSource()
|
|
58
|
+
: "";
|
|
55
59
|
const includedProviders = [
|
|
56
60
|
...new Set(allCompiledAgents(compiledBundle.agents).flatMap((agent) => [
|
|
57
61
|
agent.provider,
|
|
@@ -68,6 +72,7 @@ export async function buildProject(options = {}) {
|
|
|
68
72
|
`import { createOrcha } from ${JSON.stringify(runtimeFactoryPath)};`,
|
|
69
73
|
`import { createProviderResponseGenerator } from ${JSON.stringify(providerDispatcherPath)};`,
|
|
70
74
|
providerRuntimeSource,
|
|
75
|
+
sandboxRuntimeSource,
|
|
71
76
|
`const compiledBundle = ${JSON.stringify(compiledBundle)};`,
|
|
72
77
|
"const generateProviderResponse = createProviderResponseGenerator(includedProviders);",
|
|
73
78
|
"export const orcha = createOrcha(() => compiledBundle, generateProviderResponse);",
|
|
@@ -98,6 +103,7 @@ export async function buildProject(options = {}) {
|
|
|
98
103
|
: {}),
|
|
99
104
|
logLevel: "silent",
|
|
100
105
|
});
|
|
106
|
+
await writeFile(manifestPath, `${JSON.stringify(compiledBundle)}\n`, "utf8");
|
|
101
107
|
return outputPath;
|
|
102
108
|
}
|
|
103
109
|
finally {
|
|
@@ -107,6 +113,17 @@ export async function buildProject(options = {}) {
|
|
|
107
113
|
});
|
|
108
114
|
}
|
|
109
115
|
}
|
|
116
|
+
function createSandboxRuntimeSource() {
|
|
117
|
+
const runtimeDirectory = dirname(fileURLToPath(import.meta.url));
|
|
118
|
+
const executePath = resolve(runtimeDirectory, "../runtime/actions/execute.js").replaceAll("\\", "/");
|
|
119
|
+
const sandboxPath = resolve(runtimeDirectory, "../runtime/actions/sandbox.js").replaceAll("\\", "/");
|
|
120
|
+
return [
|
|
121
|
+
`import { setSandboxRuntimeLoader } from ${JSON.stringify(executePath)};`,
|
|
122
|
+
`import { executeSandboxedAction } from ${JSON.stringify(sandboxPath)};`,
|
|
123
|
+
"setSandboxRuntimeLoader(async () => ({ executeSandboxedAction }));",
|
|
124
|
+
"",
|
|
125
|
+
].join("\n");
|
|
126
|
+
}
|
|
110
127
|
function allCompiledAgents(agents) {
|
|
111
128
|
return Object.values(agents).flatMap((agent) => [
|
|
112
129
|
agent,
|
package/dist/orcha.js
CHANGED
|
@@ -1,15 +1,58 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
1
2
|
import { resolve } from "node:path";
|
|
2
3
|
import { compileRegistry } from "./compiler/compile.js";
|
|
3
4
|
import { generateProviderResponse } from "./providers/index.js";
|
|
5
|
+
import { setSandboxRuntimeLoader } from "./runtime/actions/execute.js";
|
|
4
6
|
import { createOrcha } from "./runtime/create-orcha.js";
|
|
7
|
+
setSandboxRuntimeLoader(async () => {
|
|
8
|
+
const modulePath = "./runtime/actions/sandbox.js";
|
|
9
|
+
return import(modulePath);
|
|
10
|
+
});
|
|
5
11
|
export const orcha = createOrcha((configuration) => {
|
|
6
|
-
if (process.env.NODE_ENV === "production" &&
|
|
7
|
-
process.env.ORCHA_COMPILING !== "1") {
|
|
8
|
-
throw new Error("ORCHA_PRODUCTION_BUNDLE_MISSING: configure the Orcha integration in your application build.");
|
|
9
|
-
}
|
|
10
12
|
const projectRoot = resolve(configuration.root ??
|
|
11
13
|
process.env.ORCHA_PROJECT_ROOT ??
|
|
12
14
|
process.cwd());
|
|
15
|
+
if (process.env.ORCHA_COMPILING !== "1" &&
|
|
16
|
+
isPrecompiledRuntime()) {
|
|
17
|
+
return loadCompiledManifest(projectRoot, configuration);
|
|
18
|
+
}
|
|
13
19
|
const registryRoot = resolve(projectRoot, "orcha");
|
|
14
20
|
return compileRegistry(configuration.agents, registryRoot, configuration.actions?.runtime ?? "native");
|
|
15
21
|
}, generateProviderResponse);
|
|
22
|
+
function isPrecompiledRuntime() {
|
|
23
|
+
return (process.env.ORCHA_USE_BUILD === "1" ||
|
|
24
|
+
process.env.NODE_ENV === "production" ||
|
|
25
|
+
process.env.AWS_LAMBDA_FUNCTION_NAME !== undefined ||
|
|
26
|
+
process.env.AWS_EXECUTION_ENV?.startsWith("AWS_Lambda_") === true);
|
|
27
|
+
}
|
|
28
|
+
function loadCompiledManifest(projectRoot, configuration) {
|
|
29
|
+
const manifestPath = resolve(projectRoot, ".orcha/dist/manifest.json");
|
|
30
|
+
if (!existsSync(manifestPath)) {
|
|
31
|
+
throw new Error(`ORCHA_PRODUCTION_BUNDLE_MISSING: "${manifestPath}" was not found. Run "npx orcha build" before packaging, include ".orcha/dist" in the deployment, or configure the Orcha build integration.`);
|
|
32
|
+
}
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Orcha could not read the compiled manifest at "${manifestPath}". Run "npx orcha build" again.`, { cause: error });
|
|
39
|
+
}
|
|
40
|
+
if (typeof parsed !== "object" ||
|
|
41
|
+
parsed === null ||
|
|
42
|
+
!("schemaVersion" in parsed) ||
|
|
43
|
+
parsed.schemaVersion !== 1 ||
|
|
44
|
+
!("agents" in parsed) ||
|
|
45
|
+
typeof parsed.agents !== "object" ||
|
|
46
|
+
parsed.agents === null ||
|
|
47
|
+
Array.isArray(parsed.agents)) {
|
|
48
|
+
throw new Error(`Orcha compiled manifest "${manifestPath}" is invalid. Run "npx orcha build" again.`);
|
|
49
|
+
}
|
|
50
|
+
const bundle = parsed;
|
|
51
|
+
const registeredAgents = Object.keys(configuration.agents).sort();
|
|
52
|
+
const compiledAgents = Object.keys(bundle.agents).sort();
|
|
53
|
+
if (registeredAgents.length !== compiledAgents.length ||
|
|
54
|
+
registeredAgents.some((name, index) => name !== compiledAgents[index])) {
|
|
55
|
+
throw new Error(`Orcha compiled manifest does not match the registered agents. Run "npx orcha build" again. Expected [${registeredAgents.join(", ")}], found [${compiledAgents.join(", ")}].`);
|
|
56
|
+
}
|
|
57
|
+
return bundle;
|
|
58
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { CompiledActionManifest, LocalActionRuntimeConfiguration, SessionMetadata } from "../../types.js";
|
|
2
|
+
type SandboxRuntime = typeof import("./sandbox.js");
|
|
3
|
+
type SandboxRuntimeLoader = () => Promise<SandboxRuntime>;
|
|
4
|
+
/** @internal Supplies the statically bundled sandbox in production builds. */
|
|
5
|
+
export declare function setSandboxRuntimeLoader(loader: SandboxRuntimeLoader): void;
|
|
2
6
|
export declare function executeLocalAction(options: {
|
|
3
7
|
action: CompiledActionManifest;
|
|
4
8
|
parameters: Record<string, unknown>;
|
|
@@ -7,3 +11,4 @@ export declare function executeLocalAction(options: {
|
|
|
7
11
|
metadata: SessionMetadata;
|
|
8
12
|
idempotencyKey: string;
|
|
9
13
|
}): Promise<unknown>;
|
|
14
|
+
export {};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { createLocalActionContext } from "./context.js";
|
|
2
2
|
import { executeNativeAction } from "./native.js";
|
|
3
|
+
let loadConfiguredSandboxRuntime = async () => {
|
|
4
|
+
throw new Error("The QuickJS sandbox runtime was not included in this Orcha build.");
|
|
5
|
+
};
|
|
6
|
+
/** @internal Supplies the statically bundled sandbox in production builds. */
|
|
7
|
+
export function setSandboxRuntimeLoader(loader) {
|
|
8
|
+
loadConfiguredSandboxRuntime = loader;
|
|
9
|
+
}
|
|
3
10
|
export async function executeLocalAction(options) {
|
|
4
11
|
const context = createLocalActionContext(options);
|
|
5
12
|
if (options.configuration.runtime === "native") {
|
|
@@ -13,7 +20,7 @@ export async function executeLocalAction(options) {
|
|
|
13
20
|
}
|
|
14
21
|
async function loadSandboxRuntime() {
|
|
15
22
|
try {
|
|
16
|
-
return await
|
|
23
|
+
return await loadConfiguredSandboxRuntime();
|
|
17
24
|
}
|
|
18
25
|
catch (error) {
|
|
19
26
|
if (error instanceof Error &&
|
|
@@ -42,6 +42,10 @@ async function buildProject(options = {}) {
|
|
|
42
42
|
"production-entry.mjs"
|
|
43
43
|
);
|
|
44
44
|
const outputPath = (0, import_path.resolve)(projectRoot, ".orcha/dist/bundle.js");
|
|
45
|
+
const manifestPath = (0, import_path.resolve)(
|
|
46
|
+
projectRoot,
|
|
47
|
+
".orcha/dist/manifest.json"
|
|
48
|
+
);
|
|
45
49
|
await (0, import_promises.mkdir)(temporaryDirectory, { recursive: true });
|
|
46
50
|
await (0, import_promises.mkdir)((0, import_path.dirname)(outputPath), { recursive: true });
|
|
47
51
|
try {
|
|
@@ -82,6 +86,7 @@ async function buildProject(options = {}) {
|
|
|
82
86
|
(0, import_path.dirname)((0, import_url.fileURLToPath)(__orchaImportMetaUrl)),
|
|
83
87
|
"../providers/dispatcher.js"
|
|
84
88
|
).replaceAll("\\", "/");
|
|
89
|
+
const sandboxRuntimeSource = compiledBundle.actionRuntime === "sandbox" ? createSandboxRuntimeSource() : "";
|
|
85
90
|
const includedProviders = [
|
|
86
91
|
...new Set(
|
|
87
92
|
allCompiledAgents(compiledBundle.agents).flatMap(
|
|
@@ -100,6 +105,7 @@ async function buildProject(options = {}) {
|
|
|
100
105
|
`import { createOrcha } from ${JSON.stringify(runtimeFactoryPath)};`,
|
|
101
106
|
`import { createProviderResponseGenerator } from ${JSON.stringify(providerDispatcherPath)};`,
|
|
102
107
|
providerRuntimeSource,
|
|
108
|
+
sandboxRuntimeSource,
|
|
103
109
|
`const compiledBundle = ${JSON.stringify(compiledBundle)};`,
|
|
104
110
|
"const generateProviderResponse = createProviderResponseGenerator(includedProviders);",
|
|
105
111
|
"export const orcha = createOrcha(() => compiledBundle, generateProviderResponse);",
|
|
@@ -132,6 +138,12 @@ async function buildProject(options = {}) {
|
|
|
132
138
|
} : {},
|
|
133
139
|
logLevel: "silent"
|
|
134
140
|
});
|
|
141
|
+
await (0, import_promises.writeFile)(
|
|
142
|
+
manifestPath,
|
|
143
|
+
`${JSON.stringify(compiledBundle)}
|
|
144
|
+
`,
|
|
145
|
+
"utf8"
|
|
146
|
+
);
|
|
135
147
|
return outputPath;
|
|
136
148
|
} finally {
|
|
137
149
|
await (0, import_promises.rm)(temporaryDirectory, {
|
|
@@ -140,6 +152,23 @@ async function buildProject(options = {}) {
|
|
|
140
152
|
});
|
|
141
153
|
}
|
|
142
154
|
}
|
|
155
|
+
function createSandboxRuntimeSource() {
|
|
156
|
+
const runtimeDirectory = (0, import_path.dirname)((0, import_url.fileURLToPath)(__orchaImportMetaUrl));
|
|
157
|
+
const executePath = (0, import_path.resolve)(
|
|
158
|
+
runtimeDirectory,
|
|
159
|
+
"../runtime/actions/execute.js"
|
|
160
|
+
).replaceAll("\\", "/");
|
|
161
|
+
const sandboxPath = (0, import_path.resolve)(
|
|
162
|
+
runtimeDirectory,
|
|
163
|
+
"../runtime/actions/sandbox.js"
|
|
164
|
+
).replaceAll("\\", "/");
|
|
165
|
+
return [
|
|
166
|
+
`import { setSandboxRuntimeLoader } from ${JSON.stringify(executePath)};`,
|
|
167
|
+
`import { executeSandboxedAction } from ${JSON.stringify(sandboxPath)};`,
|
|
168
|
+
"setSandboxRuntimeLoader(async () => ({ executeSandboxedAction }));",
|
|
169
|
+
""
|
|
170
|
+
].join("\n");
|
|
171
|
+
}
|
|
143
172
|
function allCompiledAgents(agents) {
|
|
144
173
|
return Object.values(agents).flatMap((agent) => [
|
|
145
174
|
agent,
|
package/dist-cjs/orcha.js
CHANGED
|
@@ -22,20 +22,24 @@ __export(orcha_exports, {
|
|
|
22
22
|
orcha: () => orcha
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(orcha_exports);
|
|
25
|
+
var import_fs = require("fs");
|
|
25
26
|
var import_path = require("path");
|
|
26
27
|
var import_compile = require("./compiler/compile.js");
|
|
27
28
|
var import_providers = require("./providers/index.js");
|
|
29
|
+
var import_execute = require("./runtime/actions/execute.js");
|
|
28
30
|
var import_create_orcha = require("./runtime/create-orcha.js");
|
|
31
|
+
(0, import_execute.setSandboxRuntimeLoader)(async () => {
|
|
32
|
+
const modulePath = "./runtime/actions/sandbox.js";
|
|
33
|
+
return import(modulePath);
|
|
34
|
+
});
|
|
29
35
|
const orcha = (0, import_create_orcha.createOrcha)(
|
|
30
36
|
(configuration) => {
|
|
31
|
-
if (process.env.NODE_ENV === "production" && process.env.ORCHA_COMPILING !== "1") {
|
|
32
|
-
throw new Error(
|
|
33
|
-
"ORCHA_PRODUCTION_BUNDLE_MISSING: configure the Orcha integration in your application build."
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
37
|
const projectRoot = (0, import_path.resolve)(
|
|
37
38
|
configuration.root ?? process.env.ORCHA_PROJECT_ROOT ?? process.cwd()
|
|
38
39
|
);
|
|
40
|
+
if (process.env.ORCHA_COMPILING !== "1" && isPrecompiledRuntime()) {
|
|
41
|
+
return loadCompiledManifest(projectRoot, configuration);
|
|
42
|
+
}
|
|
39
43
|
const registryRoot = (0, import_path.resolve)(projectRoot, "orcha");
|
|
40
44
|
return (0, import_compile.compileRegistry)(
|
|
41
45
|
configuration.agents,
|
|
@@ -45,6 +49,45 @@ const orcha = (0, import_create_orcha.createOrcha)(
|
|
|
45
49
|
},
|
|
46
50
|
import_providers.generateProviderResponse
|
|
47
51
|
);
|
|
52
|
+
function isPrecompiledRuntime() {
|
|
53
|
+
return process.env.ORCHA_USE_BUILD === "1" || process.env.NODE_ENV === "production" || process.env.AWS_LAMBDA_FUNCTION_NAME !== void 0 || process.env.AWS_EXECUTION_ENV?.startsWith("AWS_Lambda_") === true;
|
|
54
|
+
}
|
|
55
|
+
function loadCompiledManifest(projectRoot, configuration) {
|
|
56
|
+
const manifestPath = (0, import_path.resolve)(
|
|
57
|
+
projectRoot,
|
|
58
|
+
".orcha/dist/manifest.json"
|
|
59
|
+
);
|
|
60
|
+
if (!(0, import_fs.existsSync)(manifestPath)) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`ORCHA_PRODUCTION_BUNDLE_MISSING: "${manifestPath}" was not found. Run "npx orcha build" before packaging, include ".orcha/dist" in the deployment, or configure the Orcha build integration.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
let parsed;
|
|
66
|
+
try {
|
|
67
|
+
parsed = JSON.parse((0, import_fs.readFileSync)(manifestPath, "utf8"));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Orcha could not read the compiled manifest at "${manifestPath}". Run "npx orcha build" again.`,
|
|
71
|
+
{ cause: error }
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (typeof parsed !== "object" || parsed === null || !("schemaVersion" in parsed) || parsed.schemaVersion !== 1 || !("agents" in parsed) || typeof parsed.agents !== "object" || parsed.agents === null || Array.isArray(parsed.agents)) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Orcha compiled manifest "${manifestPath}" is invalid. Run "npx orcha build" again.`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const bundle = parsed;
|
|
80
|
+
const registeredAgents = Object.keys(configuration.agents).sort();
|
|
81
|
+
const compiledAgents = Object.keys(bundle.agents).sort();
|
|
82
|
+
if (registeredAgents.length !== compiledAgents.length || registeredAgents.some(
|
|
83
|
+
(name, index) => name !== compiledAgents[index]
|
|
84
|
+
)) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Orcha compiled manifest does not match the registered agents. Run "npx orcha build" again. Expected [${registeredAgents.join(", ")}], found [${compiledAgents.join(", ")}].`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return bundle;
|
|
90
|
+
}
|
|
48
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
92
|
0 && (module.exports = {
|
|
50
93
|
orcha
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict"; const __orchaImportMetaUrl = require("url").pathToFileURL(__filename).href;
|
|
2
2
|
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,22 +16,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var execute_exports = {};
|
|
31
21
|
__export(execute_exports, {
|
|
32
|
-
executeLocalAction: () => executeLocalAction
|
|
22
|
+
executeLocalAction: () => executeLocalAction,
|
|
23
|
+
setSandboxRuntimeLoader: () => setSandboxRuntimeLoader
|
|
33
24
|
});
|
|
34
25
|
module.exports = __toCommonJS(execute_exports);
|
|
35
26
|
var import_context = require("./context.js");
|
|
36
27
|
var import_native = require("./native.js");
|
|
28
|
+
let loadConfiguredSandboxRuntime = async () => {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"The QuickJS sandbox runtime was not included in this Orcha build."
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
function setSandboxRuntimeLoader(loader) {
|
|
34
|
+
loadConfiguredSandboxRuntime = loader;
|
|
35
|
+
}
|
|
37
36
|
async function executeLocalAction(options) {
|
|
38
37
|
const context = (0, import_context.createLocalActionContext)(options);
|
|
39
38
|
if (options.configuration.runtime === "native") {
|
|
@@ -54,7 +53,7 @@ async function executeLocalAction(options) {
|
|
|
54
53
|
}
|
|
55
54
|
async function loadSandboxRuntime() {
|
|
56
55
|
try {
|
|
57
|
-
return await
|
|
56
|
+
return await loadConfiguredSandboxRuntime();
|
|
58
57
|
} catch (error) {
|
|
59
58
|
if (error instanceof Error && (error.message.includes("quickjs-emscripten-core") || error.message.includes(
|
|
60
59
|
"@jitl/quickjs-singlefile-cjs-release-sync"
|
|
@@ -69,5 +68,6 @@ async function loadSandboxRuntime() {
|
|
|
69
68
|
}
|
|
70
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
70
|
0 && (module.exports = {
|
|
72
|
-
executeLocalAction
|
|
71
|
+
executeLocalAction,
|
|
72
|
+
setSandboxRuntimeLoader
|
|
73
73
|
});
|