@executor-js/execution 0.0.1-beta.4 → 0.0.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 +94 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @executor/execution
|
|
2
|
+
|
|
3
|
+
Sandboxed JavaScript execution for an executor. Hands a `tools.<namespace>.<name>(...)` proxy into a code sandbox so an agent (or any caller) can run generated TypeScript/JavaScript that invokes the executor's registered tools.
|
|
4
|
+
|
|
5
|
+
Supports pause/resume for elicitation-driven flows: tools that need user input (OAuth, form fill, approval) suspend the sandbox, surface a `PausedExecution`, and resume on a `ResumeResponse`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun add @executor/sdk @executor/execution @executor/runtime-quickjs
|
|
11
|
+
# or
|
|
12
|
+
npm install @executor/sdk @executor/execution @executor/runtime-quickjs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`@executor/runtime-quickjs` is the sandbox runtime. It's not a dependency of `@executor/execution` — you bring your own so consumers with a different runtime don't ship ~13 MB of WASM they never use.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createExecutor } from "@executor/sdk";
|
|
21
|
+
import { createExecutionEngine } from "@executor/execution";
|
|
22
|
+
import { makeQuickJsExecutor } from "@executor/runtime-quickjs";
|
|
23
|
+
|
|
24
|
+
const executor = await createExecutor({
|
|
25
|
+
scope: { name: "my-app" },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const engine = createExecutionEngine({
|
|
29
|
+
executor,
|
|
30
|
+
codeExecutor: makeQuickJsExecutor({
|
|
31
|
+
timeoutMs: 2_000,
|
|
32
|
+
memoryLimitBytes: 32 * 1024 * 1024,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const result = await engine.execute(
|
|
37
|
+
`
|
|
38
|
+
const pets = await tools.petstore.findPetsByStatus({ status: "available" });
|
|
39
|
+
return pets.length;
|
|
40
|
+
`,
|
|
41
|
+
{
|
|
42
|
+
onElicitation: async (ctx) => {
|
|
43
|
+
// A tool asked for user input mid-execution. Your UI decides what to do.
|
|
44
|
+
console.log("tool needs input:", ctx.request);
|
|
45
|
+
return { action: "decline" };
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
console.log(result);
|
|
51
|
+
// { result: 12, logs: [...] }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Pause/resume for elicitation
|
|
55
|
+
|
|
56
|
+
When the host doesn't support inline elicitation, use `executeWithPause` to intercept the first request as a pause point:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const started = await engine.executeWithPause(code);
|
|
60
|
+
|
|
61
|
+
if (started.status === "paused") {
|
|
62
|
+
const { id, elicitationContext } = started.execution;
|
|
63
|
+
// Render the elicitation request in your UI. Later:
|
|
64
|
+
const resumed = await engine.resume(id, {
|
|
65
|
+
action: "accept",
|
|
66
|
+
content: { name: "Ada" },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Workflow description for LLMs
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const docs = await engine.getDescription();
|
|
75
|
+
// Returns the canonical "use tools.search(), then tools.describe.tool(), then call …"
|
|
76
|
+
// workflow prose + per-namespace tool listing. Feed this to an LLM so it knows
|
|
77
|
+
// how to drive the sandbox.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Using with Effect
|
|
81
|
+
|
|
82
|
+
If you're building on `@executor/sdk` (the raw Effect entry), import from the `/core` subpath. The returned engine is Effect-native: `execute`, `executeWithPause`, and `resume` all become `Effect.Effect<...>`, and `onElicitation` is an `ElicitationHandler` returning `Effect.Effect<ElicitationResponse>`.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { createExecutionEngine } from "@executor/execution";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Status
|
|
89
|
+
|
|
90
|
+
Pre-`1.0`. APIs may still change between beta releases. Part of the [executor monorepo](https://github.com/RhysSullivan/executor).
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executor-js/execution",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/core/execution",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/RhysSullivan/executor/issues"
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"typecheck:slow": "bunx tsc --noEmit -p tsconfig.json"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@executor-js/codemode-core": "0.0.1
|
|
42
|
+
"@executor-js/codemode-core": "0.0.1",
|
|
43
43
|
"@executor-js/sdk": "0.0.1",
|
|
44
44
|
"effect": "^3.21.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@effect/vitest": "^0.29.0",
|
|
48
|
-
"@executor-js/runtime-quickjs": "0.0.1
|
|
48
|
+
"@executor-js/runtime-quickjs": "0.0.1",
|
|
49
49
|
"@types/node": "^24.3.1",
|
|
50
50
|
"bun-types": "^1.2.22",
|
|
51
51
|
"tsup": "^8.5.0",
|