orchajs 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +13 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +12 -0
- package/dist/cli-agents-template.d.ts +1 -1
- package/dist/cli-agents-template.js +22 -0
- package/dist/cli.js +35 -9
- package/dist/compiler/build-project.d.ts +1 -0
- package/dist/compiler/build-project.js +75 -8
- package/dist/compiler/compile.d.ts +1 -1
- package/dist/compiler/compile.js +11 -9
- package/dist/file-content.js +42 -6
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -2
- package/dist/integrations/esbuild.js +5 -2
- package/dist/integrations/expo.d.ts +1 -0
- package/dist/integrations/expo.js +1 -0
- package/dist/integrations/metro.d.ts +15 -0
- package/dist/integrations/metro.js +25 -0
- package/dist/integrations/next.d.ts +23 -0
- package/dist/integrations/next.js +53 -0
- package/dist/integrations/runtime-build.d.ts +4 -0
- package/dist/integrations/runtime-build.js +32 -0
- package/dist/integrations/vite.d.ts +23 -0
- package/dist/integrations/vite.js +32 -0
- package/dist/integrations/webpack.d.ts +24 -0
- package/dist/integrations/webpack.js +21 -0
- package/dist/orcha.js +17 -8
- package/dist/playground/server.js +57 -7
- package/dist/project-loader.js +3 -0
- package/dist/providers/browser.d.ts +2 -0
- package/dist/providers/browser.js +20 -0
- package/dist/react-native.d.ts +2 -0
- package/dist/react-native.js +12 -0
- package/dist/runtime/actions/browser-native.d.ts +3 -0
- package/dist/runtime/actions/browser-native.js +28 -0
- package/dist/runtime/actions/execute.d.ts +7 -0
- package/dist/runtime/actions/execute.js +9 -2
- package/dist/runtime/agent.d.ts +1 -0
- package/dist/runtime/agent.js +8 -5
- package/dist/runtime/compiler-hook.d.ts +5 -0
- package/dist/runtime/compiler-hook.js +8 -0
- package/dist/runtime/create-orcha.d.ts +2 -1
- package/dist/runtime/create-orcha.js +15 -19
- package/dist/runtime/platform-browser.d.ts +2 -0
- package/dist/runtime/platform-browser.js +15 -0
- package/dist/runtime/platform-node.d.ts +2 -0
- package/dist/runtime/platform-node.js +31 -0
- package/dist/runtime/platform-react-native.d.ts +2 -0
- package/dist/runtime/platform-react-native.js +15 -0
- package/dist/runtime/platform.d.ts +15 -0
- package/dist/runtime/platform.js +1 -0
- package/dist/runtime/random-id.d.ts +1 -0
- package/dist/runtime/random-id.js +26 -0
- package/dist/runtime-entry.d.ts +5 -0
- package/dist/runtime-entry.js +2 -0
- package/dist/storage/browser-indexeddb.d.ts +7 -16
- package/dist/storage/browser-indexeddb.js +102 -19
- package/dist/storage/react-native-jsonl.d.ts +7 -16
- package/dist/storage/react-native-jsonl.js +65 -19
- package/dist/types.d.ts +3 -1
- package/dist-cjs/browser.js +48 -0
- package/dist-cjs/cli-agents-template.js +22 -0
- package/dist-cjs/compiler/build-project.js +97 -8
- package/dist-cjs/compiler/compile.js +17 -9
- package/dist-cjs/file-content.js +42 -7
- package/dist-cjs/index.js +4 -9
- package/dist-cjs/integrations/esbuild.js +6 -2
- package/dist-cjs/integrations/expo.js +29 -0
- package/dist-cjs/integrations/metro.js +51 -0
- package/dist-cjs/integrations/next.js +75 -0
- package/dist-cjs/integrations/runtime-build.js +70 -0
- package/dist-cjs/integrations/vite.js +57 -0
- package/dist-cjs/integrations/webpack.js +51 -0
- package/dist-cjs/orcha.js +17 -12
- package/dist-cjs/playground/server.js +62 -9
- package/dist-cjs/project-loader.js +10 -0
- package/dist-cjs/providers/browser.js +61 -0
- package/dist-cjs/react-native.js +48 -0
- package/dist-cjs/runtime/actions/browser-native.js +68 -0
- package/dist-cjs/runtime/actions/execute.js +12 -2
- package/dist-cjs/runtime/agent.js +8 -6
- package/dist-cjs/runtime/compiler-hook.js +37 -0
- package/dist-cjs/runtime/create-orcha.js +18 -21
- package/dist-cjs/runtime/platform-browser.js +48 -0
- package/dist-cjs/runtime/platform-node.js +59 -0
- package/dist-cjs/runtime/platform-react-native.js +45 -0
- package/dist-cjs/runtime/platform.js +17 -0
- package/dist-cjs/runtime/random-id.js +55 -0
- package/dist-cjs/runtime-entry.js +34 -0
- package/dist-cjs/storage/browser-indexeddb.js +102 -5
- package/dist-cjs/storage/react-native-jsonl.js +73 -5
- package/dist-cjs/types/react-native-async-storage.d.js +2 -0
- package/package.json +69 -9
- package/dist/playground/public/app.css +0 -1
- package/dist/playground/public/app.js +0 -31
- package/dist/playground/public/index.html +0 -15
- package/dist/playground/public/orcha-logo.svg +0 -4
|
@@ -27,9 +27,19 @@ var import_promises = require("fs/promises");
|
|
|
27
27
|
var import_path = require("path");
|
|
28
28
|
var import_url = require("url");
|
|
29
29
|
var import_esbuild = require("esbuild");
|
|
30
|
+
var import_compile = require("./compiler/compile.js");
|
|
30
31
|
var import_env = require("./env.js");
|
|
31
32
|
var import_orcha = require("./orcha.js");
|
|
33
|
+
var import_compiler_hook = require("./runtime/compiler-hook.js");
|
|
32
34
|
async function loadProject(projectRoot) {
|
|
35
|
+
(0, import_compiler_hook.setRegistryCompiler)(
|
|
36
|
+
(configuration, compilerProjectRoot) => (0, import_compile.compileRegistry)(
|
|
37
|
+
configuration.agents,
|
|
38
|
+
(0, import_path.resolve)(compilerProjectRoot, "orcha"),
|
|
39
|
+
configuration.actions?.runtime ?? "native",
|
|
40
|
+
"node"
|
|
41
|
+
)
|
|
42
|
+
);
|
|
33
43
|
(0, import_env.loadProjectEnvironment)(projectRoot);
|
|
34
44
|
const registryPath = (0, import_path.resolve)(projectRoot, "orcha/index.ts");
|
|
35
45
|
if (!(0, import_fs.existsSync)(registryPath)) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict"; const __orchaImportMetaUrl = require("url").pathToFileURL(__filename).href;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var browser_exports = {};
|
|
31
|
+
__export(browser_exports, {
|
|
32
|
+
generateBrowserProviderResponse: () => generateBrowserProviderResponse
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(browser_exports);
|
|
35
|
+
var import_errors = require("../errors.js");
|
|
36
|
+
const loadedProviders = /* @__PURE__ */ new Map();
|
|
37
|
+
const loaders = {
|
|
38
|
+
anthropic: () => import("./anthropic.js").then((module2) => module2.anthropicProvider),
|
|
39
|
+
deepseek: () => import("./deepseek.js").then((module2) => module2.deepSeekProvider),
|
|
40
|
+
googlegenai: () => import("./google-genai.js").then((module2) => module2.googleGenAIProvider),
|
|
41
|
+
openai: () => import("./openai.js").then((module2) => module2.openAIProvider)
|
|
42
|
+
};
|
|
43
|
+
const generateBrowserProviderResponse = async (name, configuration, request) => {
|
|
44
|
+
const loader = loaders[name];
|
|
45
|
+
if (!loader) {
|
|
46
|
+
throw new import_errors.OrchaError(
|
|
47
|
+
"provider_error",
|
|
48
|
+
`Provider "${name}" is not available in browser or React Native runtimes.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
let provider = loadedProviders.get(name);
|
|
52
|
+
if (!provider) {
|
|
53
|
+
provider = loader();
|
|
54
|
+
loadedProviders.set(name, provider);
|
|
55
|
+
}
|
|
56
|
+
return (await provider).generate(configuration, request);
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
generateBrowserProviderResponse
|
|
61
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var react_native_exports = {};
|
|
22
|
+
__export(react_native_exports, {
|
|
23
|
+
orcha: () => orcha
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(react_native_exports);
|
|
26
|
+
var import_browser = require("./providers/browser.js");
|
|
27
|
+
var import_execute = require("./runtime/actions/execute.js");
|
|
28
|
+
var import_create_orcha = require("./runtime/create-orcha.js");
|
|
29
|
+
var import_platform_react_native = require("./runtime/platform-react-native.js");
|
|
30
|
+
__reExport(react_native_exports, require("./runtime-entry.js"), module.exports);
|
|
31
|
+
(0, import_execute.setNativeRuntimeLoader)(async () => {
|
|
32
|
+
const modulePath = "./runtime/actions/browser-native.js";
|
|
33
|
+
return import(modulePath);
|
|
34
|
+
});
|
|
35
|
+
const orcha = (0, import_create_orcha.createOrcha)(
|
|
36
|
+
() => {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"The React Native runtime requires a precompiled Orcha bundle. Configure the Orcha Metro integration."
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
import_browser.generateBrowserProviderResponse,
|
|
42
|
+
import_platform_react_native.reactNativeRuntimePlatform
|
|
43
|
+
);
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
orcha,
|
|
47
|
+
...require("./runtime-entry.js")
|
|
48
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
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 browser_native_exports = {};
|
|
21
|
+
__export(browser_native_exports, {
|
|
22
|
+
executeNativeAction: () => executeNativeAction
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(browser_native_exports);
|
|
25
|
+
async function executeNativeAction(action, parameters, context) {
|
|
26
|
+
if (!action.source) {
|
|
27
|
+
throw new Error(`Action "${action.name}" has no compiled source.`);
|
|
28
|
+
}
|
|
29
|
+
if (/\brequire\s*\(/.test(action.source)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Browser action "${action.name}" contains a Node.js require() call. Rebuild it for the browser target.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const loadAction = new Function(
|
|
35
|
+
`"use strict";
|
|
36
|
+
${action.source}
|
|
37
|
+
return __orchaActionModule.default;`
|
|
38
|
+
);
|
|
39
|
+
const executable = loadAction();
|
|
40
|
+
if (typeof executable !== "function") {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Action "${action.name}" index.js must export a default function.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const timeoutMs = action.timeoutMs ?? 1e4;
|
|
46
|
+
let timeout;
|
|
47
|
+
try {
|
|
48
|
+
return await Promise.race([
|
|
49
|
+
Promise.resolve(
|
|
50
|
+
executable(parameters, context)
|
|
51
|
+
),
|
|
52
|
+
new Promise((_resolve, reject) => {
|
|
53
|
+
timeout = setTimeout(
|
|
54
|
+
() => reject(new Error(`Action timed out after ${timeoutMs}ms.`)),
|
|
55
|
+
timeoutMs
|
|
56
|
+
);
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
59
|
+
} finally {
|
|
60
|
+
if (timeout) {
|
|
61
|
+
clearTimeout(timeout);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
executeNativeAction
|
|
68
|
+
});
|
|
@@ -20,11 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var execute_exports = {};
|
|
21
21
|
__export(execute_exports, {
|
|
22
22
|
executeLocalAction: () => executeLocalAction,
|
|
23
|
+
setNativeRuntimeLoader: () => setNativeRuntimeLoader,
|
|
23
24
|
setSandboxRuntimeLoader: () => setSandboxRuntimeLoader
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(execute_exports);
|
|
26
27
|
var import_context = require("./context.js");
|
|
27
|
-
|
|
28
|
+
let loadConfiguredNativeRuntime = async () => {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"The native action runtime was not included in this Orcha build."
|
|
31
|
+
);
|
|
32
|
+
};
|
|
28
33
|
let loadConfiguredSandboxRuntime = async () => {
|
|
29
34
|
throw new Error(
|
|
30
35
|
"The QuickJS sandbox runtime was not included in this Orcha build."
|
|
@@ -33,10 +38,14 @@ let loadConfiguredSandboxRuntime = async () => {
|
|
|
33
38
|
function setSandboxRuntimeLoader(loader) {
|
|
34
39
|
loadConfiguredSandboxRuntime = loader;
|
|
35
40
|
}
|
|
41
|
+
function setNativeRuntimeLoader(loader) {
|
|
42
|
+
loadConfiguredNativeRuntime = loader;
|
|
43
|
+
}
|
|
36
44
|
async function executeLocalAction(options) {
|
|
37
45
|
const context = (0, import_context.createLocalActionContext)(options);
|
|
38
46
|
if (options.configuration.runtime === "native") {
|
|
39
|
-
|
|
47
|
+
const { executeNativeAction } = await loadConfiguredNativeRuntime();
|
|
48
|
+
return executeNativeAction(options.action, options.parameters, context);
|
|
40
49
|
}
|
|
41
50
|
if (process.env.ORCHA_INCLUDE_SANDBOX !== "0") {
|
|
42
51
|
const { executeSandboxedAction } = await loadSandboxRuntime();
|
|
@@ -69,5 +78,6 @@ async function loadSandboxRuntime() {
|
|
|
69
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
79
|
0 && (module.exports = {
|
|
71
80
|
executeLocalAction,
|
|
81
|
+
setNativeRuntimeLoader,
|
|
72
82
|
setSandboxRuntimeLoader
|
|
73
83
|
});
|
|
@@ -22,13 +22,13 @@ __export(agent_exports, {
|
|
|
22
22
|
RuntimeAgent: () => RuntimeAgent
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(agent_exports);
|
|
25
|
-
var import_crypto = require("crypto");
|
|
26
25
|
var import_errors = require("../errors.js");
|
|
27
26
|
var import_file_content = require("../file-content.js");
|
|
28
27
|
var import_session_events = require("./session-events.js");
|
|
29
28
|
var import_structured_output = require("./structured-output.js");
|
|
30
29
|
var import_execute = require("./actions/execute.js");
|
|
31
30
|
var import_execution = require("./execution.js");
|
|
31
|
+
var import_random_id = require("./random-id.js");
|
|
32
32
|
const LOAD_SKILL_TOOL_NAME = "load_skill";
|
|
33
33
|
const RUN_AGENT_TOOL_NAME = "run_agent";
|
|
34
34
|
const RESUME_AGENT_TOOL_NAME = "resume_agent";
|
|
@@ -51,6 +51,7 @@ class RuntimeAgent {
|
|
|
51
51
|
#agentKey;
|
|
52
52
|
#sessionIdPrefix;
|
|
53
53
|
#projectRoot;
|
|
54
|
+
#randomUUID;
|
|
54
55
|
#evaluationTasks = /* @__PURE__ */ new Map();
|
|
55
56
|
#sessionIdleWaiters = /* @__PURE__ */ new Map();
|
|
56
57
|
constructor(options) {
|
|
@@ -64,7 +65,8 @@ class RuntimeAgent {
|
|
|
64
65
|
this.#delegatedOnly = options.delegatedOnly ?? false;
|
|
65
66
|
this.#agentKey = options.manifest.key ?? options.manifest.name;
|
|
66
67
|
this.#sessionIdPrefix = options.sessionIdPrefix ?? "ses_";
|
|
67
|
-
this.#projectRoot = options.projectRoot ??
|
|
68
|
+
this.#projectRoot = options.projectRoot ?? ".";
|
|
69
|
+
this.#randomUUID = options.randomUUID ?? import_random_id.portableRandomUUID;
|
|
68
70
|
}
|
|
69
71
|
get agent() {
|
|
70
72
|
return this.#agentKey;
|
|
@@ -91,7 +93,7 @@ class RuntimeAgent {
|
|
|
91
93
|
return this.#run(input);
|
|
92
94
|
}
|
|
93
95
|
createDelegatedSessionId() {
|
|
94
|
-
return createSessionId(this.#sessionIdPrefix);
|
|
96
|
+
return createSessionId(this.#sessionIdPrefix, this.#randomUUID);
|
|
95
97
|
}
|
|
96
98
|
runAsChild(sessionId, input, lineage) {
|
|
97
99
|
const normalized = typeof input === "string" ? { content: input } : input;
|
|
@@ -106,7 +108,7 @@ class RuntimeAgent {
|
|
|
106
108
|
}
|
|
107
109
|
#run(input, lineage, requestedSessionId) {
|
|
108
110
|
const normalized = typeof input === "string" ? { content: input } : input;
|
|
109
|
-
const sessionId = requestedSessionId ?? createSessionId(this.#sessionIdPrefix);
|
|
111
|
+
const sessionId = requestedSessionId ?? createSessionId(this.#sessionIdPrefix, this.#randomUUID);
|
|
110
112
|
if (typeof normalized === "object" && normalized !== null && "sessionId" in normalized) {
|
|
111
113
|
return this.#createExecution(
|
|
112
114
|
sessionId,
|
|
@@ -2126,9 +2128,9 @@ function normalizeMetadata(metadata) {
|
|
|
2126
2128
|
}
|
|
2127
2129
|
return normalized;
|
|
2128
2130
|
}
|
|
2129
|
-
function createSessionId(prefix) {
|
|
2131
|
+
function createSessionId(prefix, randomUUID) {
|
|
2130
2132
|
const utcTimestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "").replace("T", "_");
|
|
2131
|
-
return `${prefix}${utcTimestamp}_${
|
|
2133
|
+
return `${prefix}${utcTimestamp}_${randomUUID()}`;
|
|
2132
2134
|
}
|
|
2133
2135
|
function normalizeVariables(variables) {
|
|
2134
2136
|
if (variables === void 0) {
|
|
@@ -0,0 +1,37 @@
|
|
|
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 compiler_hook_exports = {};
|
|
21
|
+
__export(compiler_hook_exports, {
|
|
22
|
+
getRegistryCompiler: () => getRegistryCompiler,
|
|
23
|
+
setRegistryCompiler: () => setRegistryCompiler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(compiler_hook_exports);
|
|
26
|
+
let registryCompiler;
|
|
27
|
+
function setRegistryCompiler(compiler) {
|
|
28
|
+
registryCompiler = compiler;
|
|
29
|
+
}
|
|
30
|
+
function getRegistryCompiler() {
|
|
31
|
+
return registryCompiler;
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
getRegistryCompiler,
|
|
36
|
+
setRegistryCompiler
|
|
37
|
+
});
|
|
@@ -22,10 +22,7 @@ __export(create_orcha_exports, {
|
|
|
22
22
|
createOrcha: () => createOrcha
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(create_orcha_exports);
|
|
25
|
-
var import_path = require("path");
|
|
26
25
|
var import_agent = require("./agent.js");
|
|
27
|
-
var import_create_store = require("../storage/create-store.js");
|
|
28
|
-
var import_sync = require("../amarsia/sync.js");
|
|
29
26
|
var import_context = require("./context.js");
|
|
30
27
|
class OrchaRuntimeCore {
|
|
31
28
|
#agents = /* @__PURE__ */ new Map();
|
|
@@ -35,22 +32,21 @@ class OrchaRuntimeCore {
|
|
|
35
32
|
#sessionControls = /* @__PURE__ */ new Map();
|
|
36
33
|
#resolveBundle;
|
|
37
34
|
#generateProviderResponse;
|
|
38
|
-
|
|
35
|
+
#platform;
|
|
36
|
+
constructor(resolveBundle, generateProviderResponse, platform) {
|
|
39
37
|
this.#resolveBundle = resolveBundle;
|
|
40
38
|
this.#generateProviderResponse = generateProviderResponse;
|
|
39
|
+
this.#platform = platform;
|
|
41
40
|
}
|
|
42
41
|
attachClient(client) {
|
|
43
42
|
this.#client = client;
|
|
44
43
|
}
|
|
45
44
|
init(configuration) {
|
|
46
|
-
const projectRoot = (
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(0, import_sync.syncAmarsiaProject)({
|
|
52
|
-
key: configuration.amarsia.key,
|
|
53
|
-
endpoint: configuration.amarsia.endpoint,
|
|
45
|
+
const projectRoot = this.#platform.projectRoot(configuration);
|
|
46
|
+
const bundle = configuration.bundle ?? this.#resolveBundle(configuration);
|
|
47
|
+
if (configuration.amarsia?.key && this.#platform.syncProject) {
|
|
48
|
+
this.#platform.syncProject({
|
|
49
|
+
configuration,
|
|
54
50
|
bundle,
|
|
55
51
|
projectRoot
|
|
56
52
|
});
|
|
@@ -73,12 +69,10 @@ class OrchaRuntimeCore {
|
|
|
73
69
|
`Production bundle expects local action runtime "${bundle.actionRuntime}".`
|
|
74
70
|
);
|
|
75
71
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
strategy: configuration.storage?.strategy,
|
|
79
|
-
directory: storageDirectory,
|
|
72
|
+
const createStore = (manifest) => this.#platform.createSessionStore({
|
|
73
|
+
configuration,
|
|
80
74
|
projectRoot,
|
|
81
|
-
|
|
75
|
+
manifest
|
|
82
76
|
});
|
|
83
77
|
const agents = /* @__PURE__ */ new Map();
|
|
84
78
|
for (const [name, manifest] of Object.entries(bundle.agents)) {
|
|
@@ -94,7 +88,8 @@ class OrchaRuntimeCore {
|
|
|
94
88
|
sessionControls: this.#sessionControls,
|
|
95
89
|
generateProviderResponse: this.#generateProviderResponse,
|
|
96
90
|
delegatedOnly: true,
|
|
97
|
-
projectRoot
|
|
91
|
+
projectRoot,
|
|
92
|
+
randomUUID: this.#platform.randomUUID
|
|
98
93
|
})
|
|
99
94
|
]
|
|
100
95
|
)
|
|
@@ -109,7 +104,8 @@ class OrchaRuntimeCore {
|
|
|
109
104
|
sessionControls: this.#sessionControls,
|
|
110
105
|
generateProviderResponse: this.#generateProviderResponse,
|
|
111
106
|
subagents,
|
|
112
|
-
projectRoot
|
|
107
|
+
projectRoot,
|
|
108
|
+
randomUUID: this.#platform.randomUUID
|
|
113
109
|
})
|
|
114
110
|
);
|
|
115
111
|
}
|
|
@@ -137,10 +133,11 @@ class OrchaRuntimeCore {
|
|
|
137
133
|
return this.#agents.get(name);
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
|
-
function createOrcha(resolveBundle, generateProviderResponse) {
|
|
136
|
+
function createOrcha(resolveBundle, generateProviderResponse, platform) {
|
|
141
137
|
const core = new OrchaRuntimeCore(
|
|
142
138
|
resolveBundle,
|
|
143
|
-
generateProviderResponse
|
|
139
|
+
generateProviderResponse,
|
|
140
|
+
platform
|
|
144
141
|
);
|
|
145
142
|
const client = new Proxy(core, {
|
|
146
143
|
get(target, property) {
|
|
@@ -0,0 +1,48 @@
|
|
|
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 platform_browser_exports = {};
|
|
21
|
+
__export(platform_browser_exports, {
|
|
22
|
+
browserRuntimePlatform: () => browserRuntimePlatform
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(platform_browser_exports);
|
|
25
|
+
var import_browser_indexeddb = require("../storage/browser-indexeddb.js");
|
|
26
|
+
var import_random_id = require("./random-id.js");
|
|
27
|
+
const browserRuntimePlatform = {
|
|
28
|
+
randomUUID: import_random_id.portableRandomUUID,
|
|
29
|
+
projectRoot(configuration) {
|
|
30
|
+
return configuration.root ?? "/";
|
|
31
|
+
},
|
|
32
|
+
createSessionStore({ configuration, manifest }) {
|
|
33
|
+
const strategy = configuration.storage?.strategy ?? "indexeddb";
|
|
34
|
+
if (strategy !== "indexeddb") {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Browser runtimes require storage strategy "indexeddb", received "${strategy}".`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return new import_browser_indexeddb.BrowserIndexedDbSessionStore(
|
|
40
|
+
manifest.key ?? manifest.name,
|
|
41
|
+
configuration.storage?.directory ?? "orchajs"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
browserRuntimePlatform
|
|
48
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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 platform_node_exports = {};
|
|
21
|
+
__export(platform_node_exports, {
|
|
22
|
+
nodeRuntimePlatform: () => nodeRuntimePlatform
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(platform_node_exports);
|
|
25
|
+
var import_crypto = require("crypto");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_sync = require("../amarsia/sync.js");
|
|
28
|
+
var import_create_store = require("../storage/create-store.js");
|
|
29
|
+
const nodeRuntimePlatform = {
|
|
30
|
+
randomUUID: import_crypto.randomUUID,
|
|
31
|
+
projectRoot(configuration) {
|
|
32
|
+
return (0, import_path.resolve)(
|
|
33
|
+
configuration.root ?? process.env.ORCHA_PROJECT_ROOT ?? process.cwd()
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
createSessionStore({ configuration, projectRoot, manifest }) {
|
|
37
|
+
return (0, import_create_store.createSessionStore)({
|
|
38
|
+
strategy: configuration.storage?.strategy,
|
|
39
|
+
directory: configuration.storage?.directory,
|
|
40
|
+
projectRoot,
|
|
41
|
+
agentName: manifest.key ?? manifest.name
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
syncProject({ configuration, bundle, projectRoot }) {
|
|
45
|
+
if (!configuration.amarsia?.key) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
(0, import_sync.syncAmarsiaProject)({
|
|
49
|
+
key: configuration.amarsia.key,
|
|
50
|
+
endpoint: configuration.amarsia.endpoint,
|
|
51
|
+
bundle,
|
|
52
|
+
projectRoot
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
nodeRuntimePlatform
|
|
59
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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 platform_react_native_exports = {};
|
|
21
|
+
__export(platform_react_native_exports, {
|
|
22
|
+
reactNativeRuntimePlatform: () => reactNativeRuntimePlatform
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(platform_react_native_exports);
|
|
25
|
+
var import_react_native_jsonl = require("../storage/react-native-jsonl.js");
|
|
26
|
+
var import_random_id = require("./random-id.js");
|
|
27
|
+
const reactNativeRuntimePlatform = {
|
|
28
|
+
randomUUID: import_random_id.portableRandomUUID,
|
|
29
|
+
projectRoot(configuration) {
|
|
30
|
+
return configuration.root ?? "/";
|
|
31
|
+
},
|
|
32
|
+
createSessionStore({ configuration, manifest }) {
|
|
33
|
+
const strategy = configuration.storage?.strategy ?? "react-native";
|
|
34
|
+
if (strategy !== "react-native") {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`React Native requires storage strategy "react-native", received "${strategy}".`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return new import_react_native_jsonl.ReactNativeJsonlSessionStore(manifest.key ?? manifest.name);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
reactNativeRuntimePlatform
|
|
45
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var platform_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(platform_exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
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 random_id_exports = {};
|
|
21
|
+
__export(random_id_exports, {
|
|
22
|
+
portableRandomUUID: () => portableRandomUUID
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(random_id_exports);
|
|
25
|
+
let fallbackSequence = 0;
|
|
26
|
+
function portableRandomUUID() {
|
|
27
|
+
const crypto = globalThis.crypto;
|
|
28
|
+
if (typeof crypto?.randomUUID === "function") {
|
|
29
|
+
return crypto.randomUUID();
|
|
30
|
+
}
|
|
31
|
+
if (typeof crypto?.getRandomValues === "function") {
|
|
32
|
+
return formatUuid(crypto.getRandomValues(new Uint8Array(16)));
|
|
33
|
+
}
|
|
34
|
+
fallbackSequence = fallbackSequence + 1 >>> 0;
|
|
35
|
+
const bytes = new Uint8Array(16);
|
|
36
|
+
let state = Date.now() ^ fallbackSequence ^ Math.floor(Math.random() * 4294967296);
|
|
37
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
38
|
+
state = Math.imul(state, 1664525) + 1013904223 >>> 0;
|
|
39
|
+
bytes[index] = state >>> 24;
|
|
40
|
+
}
|
|
41
|
+
return formatUuid(bytes);
|
|
42
|
+
}
|
|
43
|
+
function formatUuid(bytes) {
|
|
44
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
45
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
46
|
+
const value = Array.from(
|
|
47
|
+
bytes,
|
|
48
|
+
(byte) => byte.toString(16).padStart(2, "0")
|
|
49
|
+
).join("");
|
|
50
|
+
return `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20)}`;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
portableRandomUUID
|
|
55
|
+
});
|