orchajs 0.19.0 → 0.20.1
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 +38 -9
- package/dist/compiler/build-project.js +15 -0
- package/dist/integrations/serverless.d.ts +27 -0
- package/dist/integrations/serverless.js +78 -0
- package/dist/orcha.js +5 -0
- package/dist/runtime/actions/execute.d.ts +5 -0
- package/dist/runtime/actions/execute.js +8 -1
- package/dist-cjs/compiler/build-project.js +19 -0
- package/dist-cjs/integrations/serverless.cjs +2 -0
- package/dist-cjs/integrations/serverless.js +125 -0
- package/dist-cjs/orcha.js +5 -0
- package/dist-cjs/runtime/actions/execute.js +13 -13
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -763,10 +763,41 @@ they need every judge result to finish and persist.
|
|
|
763
763
|
|
|
764
764
|
### Production and Serverless builds
|
|
765
765
|
|
|
766
|
-
For
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
766
|
+
For Serverless Framework projects, install `serverless-esbuild` and register
|
|
767
|
+
the Orcha integration after it:
|
|
768
|
+
|
|
769
|
+
```bash
|
|
770
|
+
npm install --save-dev serverless-esbuild
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
```yaml
|
|
774
|
+
plugins:
|
|
775
|
+
- serverless-esbuild
|
|
776
|
+
- orchajs/serverless
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
Serverless Framework v4 users must opt out of its built-in builder before
|
|
780
|
+
loading `serverless-esbuild`:
|
|
781
|
+
|
|
782
|
+
```yaml
|
|
783
|
+
build:
|
|
784
|
+
esbuild: false
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
No separate `orcha build` command or deployment script is required. During
|
|
788
|
+
`serverless package` and `serverless deploy`, the integration adds Orcha to the
|
|
789
|
+
existing esbuild pipeline. It preserves other esbuild plugins, compiles the
|
|
790
|
+
registry, and replaces exact `orchajs` imports with the generated production
|
|
791
|
+
runtime. It rejects configurations that externalize `orchajs`, because those
|
|
792
|
+
would copy the full development package into the Lambda artifact.
|
|
793
|
+
|
|
794
|
+
`serverless-plugin-typescript` and plain `tsc` do not bundle dependencies.
|
|
795
|
+
Remove that build plugin when switching the service to `serverless-esbuild`.
|
|
796
|
+
Keep `serverless-esbuild` before `orchajs/serverless` and before
|
|
797
|
+
`serverless-offline`.
|
|
798
|
+
|
|
799
|
+
For non-Serverless esbuild applications, add `orchaPlugin()` from
|
|
800
|
+
`orchajs/esbuild` to the build that bundles the application:
|
|
770
801
|
|
|
771
802
|
```js
|
|
772
803
|
const { orchaPlugin } = require("orchajs/esbuild");
|
|
@@ -777,11 +808,9 @@ module.exports = {
|
|
|
777
808
|
};
|
|
778
809
|
```
|
|
779
810
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
enough: `orcha build` creates `.orcha/dist/bundle.js`, but it does not rewrite
|
|
784
|
-
imports in already-built handlers.
|
|
811
|
+
Running `orcha build` separately is not enough: it creates
|
|
812
|
+
`.orcha/dist/bundle.js`, but does not rewrite imports in already-built
|
|
813
|
+
handlers.
|
|
785
814
|
|
|
786
815
|
Production CI should package the same way as deployment and verify that:
|
|
787
816
|
|
|
@@ -52,6 +52,9 @@ export async function buildProject(options = {}) {
|
|
|
52
52
|
const compiledBundle = orcha.getCompiledBundle();
|
|
53
53
|
const runtimeFactoryPath = resolve(dirname(fileURLToPath(import.meta.url)), "../runtime/create-orcha.js").replaceAll("\\", "/");
|
|
54
54
|
const providerDispatcherPath = resolve(dirname(fileURLToPath(import.meta.url)), "../providers/dispatcher.js").replaceAll("\\", "/");
|
|
55
|
+
const sandboxRuntimeSource = compiledBundle.actionRuntime === "sandbox"
|
|
56
|
+
? createSandboxRuntimeSource()
|
|
57
|
+
: "";
|
|
55
58
|
const includedProviders = [
|
|
56
59
|
...new Set(allCompiledAgents(compiledBundle.agents).flatMap((agent) => [
|
|
57
60
|
agent.provider,
|
|
@@ -68,6 +71,7 @@ export async function buildProject(options = {}) {
|
|
|
68
71
|
`import { createOrcha } from ${JSON.stringify(runtimeFactoryPath)};`,
|
|
69
72
|
`import { createProviderResponseGenerator } from ${JSON.stringify(providerDispatcherPath)};`,
|
|
70
73
|
providerRuntimeSource,
|
|
74
|
+
sandboxRuntimeSource,
|
|
71
75
|
`const compiledBundle = ${JSON.stringify(compiledBundle)};`,
|
|
72
76
|
"const generateProviderResponse = createProviderResponseGenerator(includedProviders);",
|
|
73
77
|
"export const orcha = createOrcha(() => compiledBundle, generateProviderResponse);",
|
|
@@ -107,6 +111,17 @@ export async function buildProject(options = {}) {
|
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
113
|
}
|
|
114
|
+
function createSandboxRuntimeSource() {
|
|
115
|
+
const runtimeDirectory = dirname(fileURLToPath(import.meta.url));
|
|
116
|
+
const executePath = resolve(runtimeDirectory, "../runtime/actions/execute.js").replaceAll("\\", "/");
|
|
117
|
+
const sandboxPath = resolve(runtimeDirectory, "../runtime/actions/sandbox.js").replaceAll("\\", "/");
|
|
118
|
+
return [
|
|
119
|
+
`import { setSandboxRuntimeLoader } from ${JSON.stringify(executePath)};`,
|
|
120
|
+
`import { executeSandboxedAction } from ${JSON.stringify(sandboxPath)};`,
|
|
121
|
+
"setSandboxRuntimeLoader(async () => ({ executeSandboxedAction }));",
|
|
122
|
+
"",
|
|
123
|
+
].join("\n");
|
|
124
|
+
}
|
|
110
125
|
function allCompiledAgents(agents) {
|
|
111
126
|
return Object.values(agents).flatMap((agent) => [
|
|
112
127
|
agent,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from "esbuild";
|
|
2
|
+
type ServerlessEsbuildOptions = {
|
|
3
|
+
config?: string;
|
|
4
|
+
exclude?: string[];
|
|
5
|
+
external?: string[];
|
|
6
|
+
plugins?: Plugin[] | string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
type ServerlessLike = {
|
|
10
|
+
config?: {
|
|
11
|
+
servicePath?: string;
|
|
12
|
+
};
|
|
13
|
+
service: {
|
|
14
|
+
custom?: {
|
|
15
|
+
esbuild?: ServerlessEsbuildOptions;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
plugins?: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare class OrchaServerlessPlugin {
|
|
22
|
+
private readonly serverless;
|
|
23
|
+
readonly hooks: Record<string, () => void>;
|
|
24
|
+
constructor(serverless: ServerlessLike);
|
|
25
|
+
private configureEsbuild;
|
|
26
|
+
}
|
|
27
|
+
export default OrchaServerlessPlugin;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { orchaPlugin } from "./esbuild.js";
|
|
4
|
+
export class OrchaServerlessPlugin {
|
|
5
|
+
serverless;
|
|
6
|
+
hooks;
|
|
7
|
+
constructor(serverless) {
|
|
8
|
+
this.serverless = serverless;
|
|
9
|
+
this.hooks = {
|
|
10
|
+
initialize: () => this.configureEsbuild(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
configureEsbuild() {
|
|
14
|
+
const servicePath = resolve(this.serverless.config?.servicePath ?? process.cwd());
|
|
15
|
+
const configuredPlugins = this.serverless.service.plugins ?? [];
|
|
16
|
+
if (!configuredPlugins.includes("serverless-esbuild")) {
|
|
17
|
+
throw new Error('The "orchajs/serverless" plugin requires "serverless-esbuild". Add "serverless-esbuild" before "orchajs/serverless" in the Serverless plugins list.');
|
|
18
|
+
}
|
|
19
|
+
const custom = this.serverless.service.custom ?? {};
|
|
20
|
+
const configuredEsbuild = custom.esbuild ?? {};
|
|
21
|
+
const esbuild = configuredEsbuild.config
|
|
22
|
+
? loadEsbuildConfig(configuredEsbuild.config, servicePath, this.serverless)
|
|
23
|
+
: { ...configuredEsbuild };
|
|
24
|
+
assertOrchaIsBundled(esbuild);
|
|
25
|
+
const existingPlugins = loadEsbuildPlugins(esbuild.plugins, servicePath, this.serverless);
|
|
26
|
+
if (!existingPlugins.some((plugin) => plugin.name === "orchajs")) {
|
|
27
|
+
existingPlugins.push(orchaPlugin({ projectRoot: servicePath }));
|
|
28
|
+
}
|
|
29
|
+
delete esbuild.config;
|
|
30
|
+
esbuild.plugins = existingPlugins;
|
|
31
|
+
custom.esbuild = esbuild;
|
|
32
|
+
this.serverless.service.custom = custom;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function loadEsbuildConfig(configPath, servicePath, serverless) {
|
|
36
|
+
const loaded = loadProjectModule(configPath, servicePath);
|
|
37
|
+
const config = unwrapDefault(loaded);
|
|
38
|
+
if (typeof config !== "function") {
|
|
39
|
+
throw new Error(`Serverless esbuild config "${configPath}" must export a function.`);
|
|
40
|
+
}
|
|
41
|
+
return config(serverless);
|
|
42
|
+
}
|
|
43
|
+
function loadEsbuildPlugins(plugins, servicePath, serverless) {
|
|
44
|
+
if (!plugins) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(plugins)) {
|
|
48
|
+
return [...plugins];
|
|
49
|
+
}
|
|
50
|
+
const loaded = unwrapDefault(loadProjectModule(plugins, servicePath));
|
|
51
|
+
const resolved = typeof loaded === "function"
|
|
52
|
+
? loaded(serverless)
|
|
53
|
+
: loaded;
|
|
54
|
+
if (!Array.isArray(resolved)) {
|
|
55
|
+
throw new Error(`Serverless esbuild plugins file "${plugins}" must export an array or a function that returns one.`);
|
|
56
|
+
}
|
|
57
|
+
return [...resolved];
|
|
58
|
+
}
|
|
59
|
+
function loadProjectModule(path, servicePath) {
|
|
60
|
+
const requireFromProject = createRequire(resolve(servicePath, "package.json"));
|
|
61
|
+
return requireFromProject(resolve(servicePath, path));
|
|
62
|
+
}
|
|
63
|
+
function unwrapDefault(value) {
|
|
64
|
+
if (typeof value === "object" &&
|
|
65
|
+
value !== null &&
|
|
66
|
+
"default" in value) {
|
|
67
|
+
return value.default;
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
function assertOrchaIsBundled(options) {
|
|
72
|
+
for (const key of ["exclude", "external"]) {
|
|
73
|
+
if (options[key]?.includes("orchajs")) {
|
|
74
|
+
throw new Error(`Remove "orchajs" from custom.esbuild.${key}. Orcha must be replaced during bundling, not copied into the Lambda package.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export default OrchaServerlessPlugin;
|
package/dist/orcha.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { compileRegistry } from "./compiler/compile.js";
|
|
3
3
|
import { generateProviderResponse } from "./providers/index.js";
|
|
4
|
+
import { setSandboxRuntimeLoader } from "./runtime/actions/execute.js";
|
|
4
5
|
import { createOrcha } from "./runtime/create-orcha.js";
|
|
6
|
+
setSandboxRuntimeLoader(async () => {
|
|
7
|
+
const modulePath = "./runtime/actions/sandbox.js";
|
|
8
|
+
return import(modulePath);
|
|
9
|
+
});
|
|
5
10
|
export const orcha = createOrcha((configuration) => {
|
|
6
11
|
if (process.env.NODE_ENV === "production" &&
|
|
7
12
|
process.env.ORCHA_COMPILING !== "1") {
|
|
@@ -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 &&
|
|
@@ -82,6 +82,7 @@ async function buildProject(options = {}) {
|
|
|
82
82
|
(0, import_path.dirname)((0, import_url.fileURLToPath)(__orchaImportMetaUrl)),
|
|
83
83
|
"../providers/dispatcher.js"
|
|
84
84
|
).replaceAll("\\", "/");
|
|
85
|
+
const sandboxRuntimeSource = compiledBundle.actionRuntime === "sandbox" ? createSandboxRuntimeSource() : "";
|
|
85
86
|
const includedProviders = [
|
|
86
87
|
...new Set(
|
|
87
88
|
allCompiledAgents(compiledBundle.agents).flatMap(
|
|
@@ -100,6 +101,7 @@ async function buildProject(options = {}) {
|
|
|
100
101
|
`import { createOrcha } from ${JSON.stringify(runtimeFactoryPath)};`,
|
|
101
102
|
`import { createProviderResponseGenerator } from ${JSON.stringify(providerDispatcherPath)};`,
|
|
102
103
|
providerRuntimeSource,
|
|
104
|
+
sandboxRuntimeSource,
|
|
103
105
|
`const compiledBundle = ${JSON.stringify(compiledBundle)};`,
|
|
104
106
|
"const generateProviderResponse = createProviderResponseGenerator(includedProviders);",
|
|
105
107
|
"export const orcha = createOrcha(() => compiledBundle, generateProviderResponse);",
|
|
@@ -140,6 +142,23 @@ async function buildProject(options = {}) {
|
|
|
140
142
|
});
|
|
141
143
|
}
|
|
142
144
|
}
|
|
145
|
+
function createSandboxRuntimeSource() {
|
|
146
|
+
const runtimeDirectory = (0, import_path.dirname)((0, import_url.fileURLToPath)(__orchaImportMetaUrl));
|
|
147
|
+
const executePath = (0, import_path.resolve)(
|
|
148
|
+
runtimeDirectory,
|
|
149
|
+
"../runtime/actions/execute.js"
|
|
150
|
+
).replaceAll("\\", "/");
|
|
151
|
+
const sandboxPath = (0, import_path.resolve)(
|
|
152
|
+
runtimeDirectory,
|
|
153
|
+
"../runtime/actions/sandbox.js"
|
|
154
|
+
).replaceAll("\\", "/");
|
|
155
|
+
return [
|
|
156
|
+
`import { setSandboxRuntimeLoader } from ${JSON.stringify(executePath)};`,
|
|
157
|
+
`import { executeSandboxedAction } from ${JSON.stringify(sandboxPath)};`,
|
|
158
|
+
"setSandboxRuntimeLoader(async () => ({ executeSandboxedAction }));",
|
|
159
|
+
""
|
|
160
|
+
].join("\n");
|
|
161
|
+
}
|
|
143
162
|
function allCompiledAgents(agents) {
|
|
144
163
|
return Object.values(agents).flatMap((agent) => [
|
|
145
164
|
agent,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict"; const __orchaImportMetaUrl = require("url").pathToFileURL(__filename).href;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var serverless_exports = {};
|
|
21
|
+
__export(serverless_exports, {
|
|
22
|
+
OrchaServerlessPlugin: () => OrchaServerlessPlugin,
|
|
23
|
+
default: () => serverless_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(serverless_exports);
|
|
26
|
+
var import_module = require("module");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_esbuild = require("./esbuild.js");
|
|
29
|
+
class OrchaServerlessPlugin {
|
|
30
|
+
constructor(serverless) {
|
|
31
|
+
this.serverless = serverless;
|
|
32
|
+
this.hooks = {
|
|
33
|
+
initialize: () => this.configureEsbuild()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
hooks;
|
|
37
|
+
configureEsbuild() {
|
|
38
|
+
const servicePath = (0, import_path.resolve)(
|
|
39
|
+
this.serverless.config?.servicePath ?? process.cwd()
|
|
40
|
+
);
|
|
41
|
+
const configuredPlugins = this.serverless.service.plugins ?? [];
|
|
42
|
+
if (!configuredPlugins.includes("serverless-esbuild")) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'The "orchajs/serverless" plugin requires "serverless-esbuild". Add "serverless-esbuild" before "orchajs/serverless" in the Serverless plugins list.'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const custom = this.serverless.service.custom ?? {};
|
|
48
|
+
const configuredEsbuild = custom.esbuild ?? {};
|
|
49
|
+
const esbuild = configuredEsbuild.config ? loadEsbuildConfig(
|
|
50
|
+
configuredEsbuild.config,
|
|
51
|
+
servicePath,
|
|
52
|
+
this.serverless
|
|
53
|
+
) : { ...configuredEsbuild };
|
|
54
|
+
assertOrchaIsBundled(esbuild);
|
|
55
|
+
const existingPlugins = loadEsbuildPlugins(
|
|
56
|
+
esbuild.plugins,
|
|
57
|
+
servicePath,
|
|
58
|
+
this.serverless
|
|
59
|
+
);
|
|
60
|
+
if (!existingPlugins.some((plugin) => plugin.name === "orchajs")) {
|
|
61
|
+
existingPlugins.push((0, import_esbuild.orchaPlugin)({ projectRoot: servicePath }));
|
|
62
|
+
}
|
|
63
|
+
delete esbuild.config;
|
|
64
|
+
esbuild.plugins = existingPlugins;
|
|
65
|
+
custom.esbuild = esbuild;
|
|
66
|
+
this.serverless.service.custom = custom;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function loadEsbuildConfig(configPath, servicePath, serverless) {
|
|
70
|
+
const loaded = loadProjectModule(
|
|
71
|
+
configPath,
|
|
72
|
+
servicePath
|
|
73
|
+
);
|
|
74
|
+
const config = unwrapDefault(loaded);
|
|
75
|
+
if (typeof config !== "function") {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Serverless esbuild config "${configPath}" must export a function.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return config(serverless);
|
|
81
|
+
}
|
|
82
|
+
function loadEsbuildPlugins(plugins, servicePath, serverless) {
|
|
83
|
+
if (!plugins) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(plugins)) {
|
|
87
|
+
return [...plugins];
|
|
88
|
+
}
|
|
89
|
+
const loaded = unwrapDefault(
|
|
90
|
+
loadProjectModule(plugins, servicePath)
|
|
91
|
+
);
|
|
92
|
+
const resolved = typeof loaded === "function" ? loaded(serverless) : loaded;
|
|
93
|
+
if (!Array.isArray(resolved)) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Serverless esbuild plugins file "${plugins}" must export an array or a function that returns one.`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return [...resolved];
|
|
99
|
+
}
|
|
100
|
+
function loadProjectModule(path, servicePath) {
|
|
101
|
+
const requireFromProject = (0, import_module.createRequire)(
|
|
102
|
+
(0, import_path.resolve)(servicePath, "package.json")
|
|
103
|
+
);
|
|
104
|
+
return requireFromProject((0, import_path.resolve)(servicePath, path));
|
|
105
|
+
}
|
|
106
|
+
function unwrapDefault(value) {
|
|
107
|
+
if (typeof value === "object" && value !== null && "default" in value) {
|
|
108
|
+
return value.default;
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
function assertOrchaIsBundled(options) {
|
|
113
|
+
for (const key of ["exclude", "external"]) {
|
|
114
|
+
if (options[key]?.includes("orchajs")) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Remove "orchajs" from custom.esbuild.${key}. Orcha must be replaced during bundling, not copied into the Lambda package.`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var serverless_default = OrchaServerlessPlugin;
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
OrchaServerlessPlugin
|
|
125
|
+
});
|
package/dist-cjs/orcha.js
CHANGED
|
@@ -25,7 +25,12 @@ module.exports = __toCommonJS(orcha_exports);
|
|
|
25
25
|
var import_path = require("path");
|
|
26
26
|
var import_compile = require("./compiler/compile.js");
|
|
27
27
|
var import_providers = require("./providers/index.js");
|
|
28
|
+
var import_execute = require("./runtime/actions/execute.js");
|
|
28
29
|
var import_create_orcha = require("./runtime/create-orcha.js");
|
|
30
|
+
(0, import_execute.setSandboxRuntimeLoader)(async () => {
|
|
31
|
+
const modulePath = "./runtime/actions/sandbox.js";
|
|
32
|
+
return import(modulePath);
|
|
33
|
+
});
|
|
29
34
|
const orcha = (0, import_create_orcha.createOrcha)(
|
|
30
35
|
(configuration) => {
|
|
31
36
|
if (process.env.NODE_ENV === "production" && process.env.ORCHA_COMPILING !== "1") {
|
|
@@ -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
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orchajs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "A filesystem-convention, stateful agent framework for JavaScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"import": "./dist/integrations/esbuild.js",
|
|
32
32
|
"require": "./dist-cjs/integrations/esbuild.js"
|
|
33
33
|
},
|
|
34
|
+
"./serverless": {
|
|
35
|
+
"types": "./dist/integrations/serverless.d.ts",
|
|
36
|
+
"import": "./dist/integrations/serverless.js",
|
|
37
|
+
"require": "./dist-cjs/integrations/serverless.cjs"
|
|
38
|
+
},
|
|
34
39
|
"./testing": {
|
|
35
40
|
"types": "./dist/testing.d.ts",
|
|
36
41
|
"import": "./dist/testing.js",
|
|
@@ -42,6 +47,9 @@
|
|
|
42
47
|
"esbuild": [
|
|
43
48
|
"dist/integrations/esbuild.d.ts"
|
|
44
49
|
],
|
|
50
|
+
"serverless": [
|
|
51
|
+
"dist/integrations/serverless.d.ts"
|
|
52
|
+
],
|
|
45
53
|
"testing": [
|
|
46
54
|
"dist/testing.d.ts"
|
|
47
55
|
]
|