orchajs 0.0.1 → 0.1.0-next.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 +130 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +86 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler/build-project.d.ts +5 -0
- package/dist/compiler/build-project.d.ts.map +1 -0
- package/dist/compiler/build-project.js +72 -0
- package/dist/compiler/build-project.js.map +1 -0
- package/dist/compiler/compile.d.ts +4 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/compile.js +103 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/esbuild.d.ts +10 -0
- package/dist/integrations/esbuild.d.ts.map +1 -0
- package/dist/integrations/esbuild.js +22 -0
- package/dist/integrations/esbuild.js.map +1 -0
- package/dist/orcha.d.ts +3 -0
- package/dist/orcha.d.ts.map +1 -0
- package/dist/orcha.js +13 -0
- package/dist/orcha.js.map +1 -0
- package/dist/providers/anthropic.d.ts +23 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +92 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/runtime/agent.d.ts +12 -0
- package/dist/runtime/agent.d.ts.map +1 -0
- package/dist/runtime/agent.js +142 -0
- package/dist/runtime/agent.js.map +1 -0
- package/dist/runtime/create-orcha.d.ts +11 -0
- package/dist/runtime/create-orcha.d.ts.map +1 -0
- package/dist/runtime/create-orcha.js +74 -0
- package/dist/runtime/create-orcha.js.map +1 -0
- package/dist/runtime/session-events.d.ts +13 -0
- package/dist/runtime/session-events.d.ts.map +1 -0
- package/dist/runtime/session-events.js +62 -0
- package/dist/runtime/session-events.js.map +1 -0
- package/dist/runtime/structured-output.d.ts +2 -0
- package/dist/runtime/structured-output.d.ts.map +1 -0
- package/dist/runtime/structured-output.js +123 -0
- package/dist/runtime/structured-output.js.map +1 -0
- package/dist/storage/browser-indexeddb.d.ts +20 -0
- package/dist/storage/browser-indexeddb.d.ts.map +1 -0
- package/dist/storage/browser-indexeddb.js +23 -0
- package/dist/storage/browser-indexeddb.js.map +1 -0
- package/dist/storage/edge-store.d.ts +19 -0
- package/dist/storage/edge-store.d.ts.map +1 -0
- package/dist/storage/edge-store.js +22 -0
- package/dist/storage/edge-store.js.map +1 -0
- package/dist/storage/node-jsonl.d.ts +9 -0
- package/dist/storage/node-jsonl.d.ts.map +1 -0
- package/dist/storage/node-jsonl.js +64 -0
- package/dist/storage/node-jsonl.js.map +1 -0
- package/dist/storage/react-native-jsonl.d.ts +20 -0
- package/dist/storage/react-native-jsonl.d.ts.map +1 -0
- package/dist/storage/react-native-jsonl.js +23 -0
- package/dist/storage/react-native-jsonl.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -1
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# OrchaJS
|
|
2
|
+
|
|
3
|
+
**An agent is a folder.** OrchaJS is a filesystem-convention framework for building AI agents in JavaScript — no orchestration graph, no client to instantiate, no export step. It's a library, not a platform: add it to Next.js, React, React Native, Express, NestJS, or plain Node, the way you'd add Prisma or Zod.
|
|
4
|
+
|
|
5
|
+
> Early and moving fast. Not yet accepting external contributions — see [Status](#status) below.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
Most agent frameworks or platforms ask you to trust a black box: the real logic lives inside someone else's runtime, and what you get to "own" is a copy or an export of it. OrchaJS removes that gap by making the file tree the actual source of truth — there's no internal state that isn't also a file you can open, edit, and run yourself.
|
|
12
|
+
|
|
13
|
+
Read the full concept: [`docs/concept.md`](./docs/concept.md)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## The convention
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
/agentname
|
|
21
|
+
index.js | index.json → provider, model, generation config, output schema
|
|
22
|
+
instructions.md → required base agent instructions
|
|
23
|
+
/skills
|
|
24
|
+
/skillname
|
|
25
|
+
index.json → { name, description, triggers }
|
|
26
|
+
instructions.md → procedural knowledge, lazy-loaded into context
|
|
27
|
+
/actions
|
|
28
|
+
/actionname
|
|
29
|
+
index.json → definition — name, params, when to use it
|
|
30
|
+
index.js → the code — what actually runs
|
|
31
|
+
/guardrails → input/output policy
|
|
32
|
+
/tests → test cases, auto-run before every release
|
|
33
|
+
/evaluations → metrics each run is judged against
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Placement determines behavior. No manual registration of tools, skills, or routes.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Model Action Protocol
|
|
41
|
+
|
|
42
|
+
What a model can do lives in `/actions`. Each action is a folder with two files — no server, no protocol handshake, no dependency to install.
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
actions/
|
|
46
|
+
send-refund/
|
|
47
|
+
index.json // the definition
|
|
48
|
+
index.js // the code
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`index.json` — tells the model what the action is and when to use it:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"name": "send_refund",
|
|
56
|
+
"description": "Issues a refund for an order. Use when a customer asks for money back and the order qualifies.",
|
|
57
|
+
"params": {
|
|
58
|
+
"orderId": "string",
|
|
59
|
+
"amount": "number"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`index.js` — the function that runs when the model calls it, in your own code:
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
export default async function sendRefund(params, ctx) {
|
|
68
|
+
const key = ctx.env.STRIPE_SECRET_KEY;
|
|
69
|
+
// call Stripe, hit your own API, query your own DB — whatever this needs
|
|
70
|
+
return { refunded: true, orderId: params.orderId };
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
No MCP server to stand up, no SDK to pull in, no integration to configure. If you can write the function, the model can call it. Actions run sandboxed with declared permissions (network, env access), the same way in Node or the browser.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Quick start
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install orchajs
|
|
82
|
+
npx orcha init
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
// Import the consumer registry once from the application entrypoint.
|
|
87
|
+
import './orcha/index.js';
|
|
88
|
+
import { orcha } from 'orchajs';
|
|
89
|
+
|
|
90
|
+
const execution = orcha.exampleAgent.run({
|
|
91
|
+
input: 'Help me understand this invoice'
|
|
92
|
+
});
|
|
93
|
+
const result = await execution.result;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Registered agents are exposed as `orcha.<agentName>`. The first implementation
|
|
97
|
+
supports durable Node.js runs backed by `.orcha/sessions/<sessionId>.jsonl`.
|
|
98
|
+
Single-shot invocation, pause/resume, actions, and streaming will follow.
|
|
99
|
+
|
|
100
|
+
For esbuild production applications, add `orchaPlugin()` from
|
|
101
|
+
`orchajs/esbuild` to the existing build. It compiles the registry and replaces
|
|
102
|
+
unchanged `orchajs` imports with the self-contained generated runtime. The
|
|
103
|
+
application continues to use its normal `npm run build` command.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## What's in this repo right now
|
|
108
|
+
|
|
109
|
+
- [x] Registry compiler + `orcha build`
|
|
110
|
+
- [ ] Model Action Protocol — schema, sandboxed execution
|
|
111
|
+
- [ ] Compiler — one provider, correct tool calls + streaming
|
|
112
|
+
- [ ] Stateful sessions — Node JSONL foundation implemented; replay and human-in-the-loop next
|
|
113
|
+
- [ ] `orcha.run()` one-shot entry point
|
|
114
|
+
- [ ] CLI (`orcha init`, `orcha build`, `orcha dev`) + example agents
|
|
115
|
+
|
|
116
|
+
See [`ROADMAP.md`](./ROADMAP.md) for what's coming after — a second provider, an evaluations runner, OpenTelemetry tracing, MCP interop adapters, and remote session storage are all deliberately out of scope for the first release.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Status
|
|
121
|
+
|
|
122
|
+
This project is being built in the open by a solo maintainer. It's not yet stable enough to take contributions productively — the core convention and API are still moving. `CONTRIBUTING.md` will open up once the shape settles.
|
|
123
|
+
|
|
124
|
+
In the meantime: [star the repo](.) to follow along, open an issue if you hit something worth flagging, or watch for weekly build-in-public updates on [X/Twitter](.).
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
[MIT](./LICENSE)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { buildProject } from "./compiler/build-project.js";
|
|
6
|
+
const command = process.argv[2];
|
|
7
|
+
try {
|
|
8
|
+
if (command === "init") {
|
|
9
|
+
await initializeProject(process.cwd());
|
|
10
|
+
}
|
|
11
|
+
else if (command === "build") {
|
|
12
|
+
const outputPath = await buildProject({ projectRoot: process.cwd() });
|
|
13
|
+
console.log(`Built ${outputPath}`);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
printUsage();
|
|
17
|
+
process.exitCode = command ? 1 : 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
}
|
|
24
|
+
async function initializeProject(projectRoot) {
|
|
25
|
+
const files = new Map([
|
|
26
|
+
[
|
|
27
|
+
"orcha/exampleAgent/index.json",
|
|
28
|
+
`${JSON.stringify({
|
|
29
|
+
provider: "anthropic",
|
|
30
|
+
model: "claude-sonnet-4-6",
|
|
31
|
+
region: "provider_managed",
|
|
32
|
+
maxTokens: 1024,
|
|
33
|
+
reasoningLevel: "disabled",
|
|
34
|
+
outputType: "text",
|
|
35
|
+
}, null, 2)}\n`,
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
"orcha/exampleAgent/instructions.md",
|
|
39
|
+
"You are a concise and helpful assistant.\n",
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"orcha/index.ts",
|
|
43
|
+
[
|
|
44
|
+
'import { orcha } from "orchajs";',
|
|
45
|
+
"",
|
|
46
|
+
"orcha.init({",
|
|
47
|
+
" providers: {",
|
|
48
|
+
" anthropic: process.env.ANTHROPIC_API_KEY ?? \"\",",
|
|
49
|
+
" },",
|
|
50
|
+
" agents: {",
|
|
51
|
+
" exampleAgent: \"./exampleAgent\",",
|
|
52
|
+
" },",
|
|
53
|
+
"});",
|
|
54
|
+
"",
|
|
55
|
+
].join("\n"),
|
|
56
|
+
],
|
|
57
|
+
]);
|
|
58
|
+
for (const [relativePath, contents] of files) {
|
|
59
|
+
const path = resolve(projectRoot, relativePath);
|
|
60
|
+
if (existsSync(path)) {
|
|
61
|
+
console.log(`Skipped existing ${relativePath}`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
await mkdir(dirname(path), { recursive: true });
|
|
65
|
+
await writeFile(path, contents, "utf8");
|
|
66
|
+
console.log(`Created ${relativePath}`);
|
|
67
|
+
}
|
|
68
|
+
await ensureGitignore(projectRoot);
|
|
69
|
+
console.log('\nImport "./orcha/index.js" once from your application entrypoint, then run your existing development command.');
|
|
70
|
+
}
|
|
71
|
+
async function ensureGitignore(projectRoot) {
|
|
72
|
+
const path = resolve(projectRoot, ".gitignore");
|
|
73
|
+
const entry = ".orcha/";
|
|
74
|
+
const current = existsSync(path) ? await readFile(path, "utf8") : "";
|
|
75
|
+
const entries = current.split(/\r?\n/).map((line) => line.trim());
|
|
76
|
+
if (entries.includes(entry)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
|
|
80
|
+
await appendFile(path, `${prefix}${entry}\n`, "utf8");
|
|
81
|
+
console.log("Updated .gitignore");
|
|
82
|
+
}
|
|
83
|
+
function printUsage() {
|
|
84
|
+
console.log(["Usage: orcha <command>", "", "Commands:", " init", " build"].join("\n"));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEhC,IAAI,CAAC;IACH,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,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,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,CAAC,wBAAwB,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-project.d.ts","sourceRoot":"","sources":["../../src/compiler/build-project.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,YAAY,CAChC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CA8EjB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
+
import { build as bundleEntry } from "esbuild";
|
|
6
|
+
import { orcha } from "../orcha.js";
|
|
7
|
+
export async function buildProject(options = {}) {
|
|
8
|
+
const projectRoot = resolve(options.projectRoot ?? process.cwd());
|
|
9
|
+
const registryPath = resolve(projectRoot, "orcha/index.ts");
|
|
10
|
+
if (!existsSync(registryPath)) {
|
|
11
|
+
throw new Error('Missing "orcha/index.ts". Run "orcha init" first.');
|
|
12
|
+
}
|
|
13
|
+
const temporaryDirectory = resolve(projectRoot, ".orcha/.build");
|
|
14
|
+
const registryBundlePath = resolve(temporaryDirectory, "registry.mjs");
|
|
15
|
+
const productionEntryPath = resolve(temporaryDirectory, "production-entry.mjs");
|
|
16
|
+
const outputPath = resolve(projectRoot, ".orcha/dist/bundle.js");
|
|
17
|
+
await mkdir(temporaryDirectory, { recursive: true });
|
|
18
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
19
|
+
try {
|
|
20
|
+
await bundleEntry({
|
|
21
|
+
entryPoints: [registryPath],
|
|
22
|
+
outfile: registryBundlePath,
|
|
23
|
+
bundle: true,
|
|
24
|
+
format: "esm",
|
|
25
|
+
platform: "node",
|
|
26
|
+
target: "node20",
|
|
27
|
+
packages: "external",
|
|
28
|
+
logLevel: "silent",
|
|
29
|
+
});
|
|
30
|
+
const previousCompiling = process.env.ORCHA_COMPILING;
|
|
31
|
+
process.env.ORCHA_COMPILING = "1";
|
|
32
|
+
try {
|
|
33
|
+
await import(`${pathToFileURL(registryBundlePath).href}?time=${Date.now()}`);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
if (previousCompiling === undefined) {
|
|
37
|
+
delete process.env.ORCHA_COMPILING;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
process.env.ORCHA_COMPILING = previousCompiling;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const compiledBundle = orcha.getCompiledBundle();
|
|
44
|
+
const runtimeFactoryPath = resolve(dirname(fileURLToPath(import.meta.url)), "../runtime/create-orcha.js").replaceAll("\\", "/");
|
|
45
|
+
await writeFile(productionEntryPath, [
|
|
46
|
+
`import { createOrcha } from ${JSON.stringify(runtimeFactoryPath)};`,
|
|
47
|
+
`const compiledBundle = ${JSON.stringify(compiledBundle)};`,
|
|
48
|
+
"export const orcha = createOrcha(() => compiledBundle);",
|
|
49
|
+
"export default orcha;",
|
|
50
|
+
"",
|
|
51
|
+
].join("\n"), "utf8");
|
|
52
|
+
await bundleEntry({
|
|
53
|
+
entryPoints: [productionEntryPath],
|
|
54
|
+
outfile: outputPath,
|
|
55
|
+
bundle: true,
|
|
56
|
+
format: "esm",
|
|
57
|
+
platform: "node",
|
|
58
|
+
target: "node20",
|
|
59
|
+
minify: true,
|
|
60
|
+
legalComments: "none",
|
|
61
|
+
logLevel: "silent",
|
|
62
|
+
});
|
|
63
|
+
return outputPath;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
await rm(temporaryDirectory, {
|
|
67
|
+
recursive: true,
|
|
68
|
+
force: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=build-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-project.js","sourceRoot":"","sources":["../../src/compiler/build-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAA+B,EAAE;IAEjC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC5D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;IACvE,MAAM,mBAAmB,GAAG,OAAO,CACjC,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;IACF,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IACjE,MAAM,KAAK,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,C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AG;YAC3D,yDAAyD;YACzD,uBAAuB;YACvB,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,MAAM,CACP,CAAC;QACF,MAAM,WAAW,CAAC;YAChB,WAAW,EAAE,CAAC,mBAAmB,CAAC;YAClC,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,IAAI;YACZ,aAAa,EAAE,MAAM;YACrB,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,kBAAkB,EAAE;YAC3B,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompiledBundle } from "../types.js";
|
|
2
|
+
export declare function compileRegistry(registrations: Record<string, string>, registryRoot: string): CompiledBundle;
|
|
3
|
+
export declare function serializeBundle(bundle: CompiledBundle): string;
|
|
4
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,aAAa,CAAC;AAIrB,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,YAAY,EAAE,MAAM,GACnB,cAAc,CA8GhB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAO9D"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
const SUPPORTED_PROVIDERS = new Set(["anthropic"]);
|
|
4
|
+
export function compileRegistry(registrations, registryRoot) {
|
|
5
|
+
if (!registrations ||
|
|
6
|
+
typeof registrations !== "object" ||
|
|
7
|
+
Array.isArray(registrations)) {
|
|
8
|
+
throw new TypeError('orcha.init() requires an "agents" object of registered folder paths.');
|
|
9
|
+
}
|
|
10
|
+
const agents = {};
|
|
11
|
+
for (const [name, registeredPath] of Object.entries(registrations)) {
|
|
12
|
+
if (!name.trim()) {
|
|
13
|
+
throw new Error("Registered agent names cannot be empty.");
|
|
14
|
+
}
|
|
15
|
+
if (typeof registeredPath !== "string" || !registeredPath.trim()) {
|
|
16
|
+
throw new Error(`Agent "${name}" must register a folder path.`);
|
|
17
|
+
}
|
|
18
|
+
const sourceDirectory = resolve(registryRoot, registeredPath);
|
|
19
|
+
const configPath = resolve(sourceDirectory, "index.json");
|
|
20
|
+
let configuration;
|
|
21
|
+
try {
|
|
22
|
+
configuration = JSON.parse(readFileSync(configPath, "utf8"));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(`Agent "${name}" is missing a valid index.json at ${configPath}.`, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
if (!SUPPORTED_PROVIDERS.has(configuration.provider)) {
|
|
28
|
+
throw new Error(`Agent "${name}" uses unsupported provider "${configuration.provider}".`);
|
|
29
|
+
}
|
|
30
|
+
if (!configuration.model?.trim()) {
|
|
31
|
+
throw new Error(`Agent "${name}" must configure a model.`);
|
|
32
|
+
}
|
|
33
|
+
validateNumber(name, "maxTokens", configuration.maxTokens, {
|
|
34
|
+
integer: true,
|
|
35
|
+
minimum: 1,
|
|
36
|
+
});
|
|
37
|
+
if (configuration.outputType &&
|
|
38
|
+
!["text", "json", "image", "audio"].includes(configuration.outputType)) {
|
|
39
|
+
throw new Error(`Agent "${name}" has an invalid outputType.`);
|
|
40
|
+
}
|
|
41
|
+
if (configuration.reasoningLevel &&
|
|
42
|
+
!["disabled", "low", "medium", "high"].includes(configuration.reasoningLevel)) {
|
|
43
|
+
throw new Error(`Agent "${name}" has an invalid reasoningLevel.`);
|
|
44
|
+
}
|
|
45
|
+
if (!["text", "json"].includes(configuration.outputType ?? "text")) {
|
|
46
|
+
throw new Error(`Agent "${name}" outputType "${configuration.outputType}" is not implemented yet.`);
|
|
47
|
+
}
|
|
48
|
+
if (configuration.outputType === "json" &&
|
|
49
|
+
(!configuration.outputSchema ||
|
|
50
|
+
typeof configuration.outputSchema !== "object")) {
|
|
51
|
+
throw new Error(`Agent "${name}" must configure outputSchema when outputType is "json".`);
|
|
52
|
+
}
|
|
53
|
+
const instructionsPath = resolve(sourceDirectory, "instructions.md");
|
|
54
|
+
let systemPrompt;
|
|
55
|
+
try {
|
|
56
|
+
systemPrompt = readFileSync(instructionsPath, "utf8").trim();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Agent "${name}" is missing required instructions.md at ${instructionsPath}.`, { cause: error });
|
|
60
|
+
}
|
|
61
|
+
if (!systemPrompt) {
|
|
62
|
+
throw new Error(`Agent "${name}" instructions.md cannot be empty.`);
|
|
63
|
+
}
|
|
64
|
+
agents[name] = Object.freeze({
|
|
65
|
+
name,
|
|
66
|
+
provider: configuration.provider,
|
|
67
|
+
model: configuration.model,
|
|
68
|
+
systemPrompt,
|
|
69
|
+
region: configuration.region,
|
|
70
|
+
maxTokens: configuration.maxTokens,
|
|
71
|
+
reasoningLevel: configuration.reasoningLevel ?? "disabled",
|
|
72
|
+
outputType: configuration.outputType ?? "text",
|
|
73
|
+
outputSchema: configuration.outputSchema,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (Object.keys(agents).length === 0) {
|
|
77
|
+
throw new Error("At least one agent must be registered.");
|
|
78
|
+
}
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
schemaVersion: 1,
|
|
81
|
+
agents: Object.freeze(agents),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export function serializeBundle(bundle) {
|
|
85
|
+
return [
|
|
86
|
+
"// Generated by OrchaJS. Do not edit manually.",
|
|
87
|
+
`export const bundle = ${JSON.stringify(bundle, null, 2)};`,
|
|
88
|
+
"export default bundle;",
|
|
89
|
+
"",
|
|
90
|
+
].join("\n");
|
|
91
|
+
}
|
|
92
|
+
function validateNumber(agentName, field, value, constraints) {
|
|
93
|
+
if (value === undefined) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!Number.isFinite(value) ||
|
|
97
|
+
(constraints.integer && !Number.isInteger(value)) ||
|
|
98
|
+
(constraints.minimum !== undefined && value < constraints.minimum) ||
|
|
99
|
+
(constraints.maximum !== undefined && value > constraints.maximum)) {
|
|
100
|
+
throw new Error(`Agent "${agentName}" has an invalid ${field}.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAEnD,MAAM,UAAU,eAAe,CAC7B,aAAqC,EACrC,YAAoB;IAEpB,IACE,CAAC,aAAa;QACd,OAAO,aAAa,KAAK,QAAQ;QACjC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5B,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,sEAAsE,CACvE,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAA0C,EAAE,CAAC;IAEzD,KAAK,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CA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AAC,OAAO,KAAK,SAAS,IAAI,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,EAClE,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,oBAAoB,KAAK,GAAG,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { orcha } from "./orcha.js";
|
|
2
|
+
export type { Orcha, OrchaClient } from "./orcha.js";
|
|
3
|
+
export { NodeJsonlSessionStore } from "./storage/node-jsonl.js";
|
|
4
|
+
export type { AgentConfiguration, AgentInput, AgentRuntime, CompiledAgentManifest, CompiledBundle, Execution, OrchaInitConfiguration, ProjectConfiguration, RunResult, SessionEvent, SessionEventType, SessionStore, Usage, } from "./types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,KAAK,GACN,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Plugin } from "esbuild";
|
|
2
|
+
export interface OrchaEsbuildPluginOptions {
|
|
3
|
+
projectRoot?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Compiles the consumer's Orcha registry and replaces unchanged `orchajs`
|
|
7
|
+
* application imports with the self-contained generated production runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare function orchaPlugin(options?: OrchaEsbuildPluginOptions): Plugin;
|
|
10
|
+
//# sourceMappingURL=esbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","sourceRoot":"","sources":["../../src/integrations/esbuild.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAgBR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { buildProject } from "../compiler/build-project.js";
|
|
3
|
+
/**
|
|
4
|
+
* Compiles the consumer's Orcha registry and replaces unchanged `orchajs`
|
|
5
|
+
* application imports with the self-contained generated production runtime.
|
|
6
|
+
*/
|
|
7
|
+
export function orchaPlugin(options = {}) {
|
|
8
|
+
const projectRoot = resolve(options.projectRoot ?? process.cwd());
|
|
9
|
+
const generatedBundle = resolve(projectRoot, ".orcha/dist/bundle.js");
|
|
10
|
+
return {
|
|
11
|
+
name: "orchajs",
|
|
12
|
+
setup(builder) {
|
|
13
|
+
builder.onStart(async () => {
|
|
14
|
+
await buildProject({ projectRoot });
|
|
15
|
+
});
|
|
16
|
+
builder.onResolve({ filter: /^orchajs$/ }, () => ({
|
|
17
|
+
path: generatedBundle,
|
|
18
|
+
}));
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=esbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../src/integrations/esbuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,UAAqC,EAAE;IAEvC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IAEtE,OAAO;QACL,IAAI,EAAE,SAAS;QACf,KAAK,CAAC,OAAO;YACX,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;gBACzB,MAAM,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;gBAChD,IAAI,EAAE,eAAe;aACtB,CAAC,CAAC,CAAC;QACN,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/orcha.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orcha.d.ts","sourceRoot":"","sources":["../src/orcha.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEpE,eAAO,MAAM,KAAK,iDAYhB,CAAC"}
|
package/dist/orcha.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { compileRegistry } from "./compiler/compile.js";
|
|
3
|
+
import { createOrcha } from "./runtime/create-orcha.js";
|
|
4
|
+
export const orcha = createOrcha((configuration) => {
|
|
5
|
+
if (process.env.NODE_ENV === "production" &&
|
|
6
|
+
process.env.ORCHA_COMPILING !== "1") {
|
|
7
|
+
throw new Error("ORCHA_PRODUCTION_BUNDLE_MISSING: configure the Orcha integration in your application build.");
|
|
8
|
+
}
|
|
9
|
+
const projectRoot = resolve(configuration.root ?? process.cwd());
|
|
10
|
+
const registryRoot = resolve(projectRoot, "orcha");
|
|
11
|
+
return compileRegistry(configuration.agents, registryRoot);
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=orcha.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orcha.js","sourceRoot":"","sources":["../src/orcha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,aAAa,EAAE,EAAE;IACjD,IACE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACrC,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,GAAG,EACnC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,eAAe,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CompiledAgentManifest, ProviderConfiguration, Usage } from "../types.js";
|
|
2
|
+
interface AnthropicMessage {
|
|
3
|
+
role: "user" | "assistant";
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AnthropicContentBlock {
|
|
7
|
+
type: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
thinking?: string;
|
|
10
|
+
signature?: string;
|
|
11
|
+
data?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface ModelResponse {
|
|
15
|
+
output: unknown;
|
|
16
|
+
responseId?: string;
|
|
17
|
+
stopReason?: string | null;
|
|
18
|
+
content: AnthropicContentBlock[];
|
|
19
|
+
usage: Usage;
|
|
20
|
+
}
|
|
21
|
+
export declare function callAnthropic(agent: CompiledAgentManifest, provider: ProviderConfiguration, messages: AnthropicMessage[]): Promise<ModelResponse>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,EACN,MAAM,aAAa,CAAC;AAGrB,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAiBD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,EAAE,qBAAqB,EAC/B,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,OAAO,CAAC,aAAa,CAAC,CAqExB"}
|