@openpond/evals 0.7.4 → 0.7.5
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/JAVASCRIPT_ENVIRONMENTS.md +4 -2
- package/dist/javascript-environment-node.js +6 -0
- package/dist/javascript-isolate-process-entry.js +8 -0
- package/dist/javascript-isolate-process-source.js +1 -0
- package/dist/javascript-isolate-process.js +73 -0
- package/dist/javascript-verifier-node.js +5 -0
- package/dist/types/javascript-environment-node.d.ts +2 -0
- package/dist/types/javascript-environment-node.d.ts.map +1 -1
- package/dist/types/javascript-isolate-process-entry.d.ts +2 -0
- package/dist/types/javascript-isolate-process-entry.d.ts.map +1 -0
- package/dist/types/javascript-isolate-process-source.d.ts +2 -0
- package/dist/types/javascript-isolate-process.d.ts +4 -0
- package/dist/types/javascript-isolate-process.d.ts.map +1 -0
- package/dist/types/javascript-verifier-node.d.ts +2 -0
- package/dist/types/javascript-verifier-node.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
These entrypoints execute authored tool modules over owner-held JSON state:
|
|
4
4
|
|
|
5
5
|
- `@openpond/evals/javascript-environment` validates immutable definitions and creates an episode with `step`, `collect`, `snapshot` and `destroy`.
|
|
6
|
-
- `@openpond/evals/javascript-environment/node`
|
|
6
|
+
- `@openpond/evals/javascript-environment/node` exposes worker and Node subprocess owners around the isolated interpreter.
|
|
7
7
|
- `@openpond/evals/javascript-environment/attempt` runs a policy adapter through the declared tools and returns its messages, output and independently recorded state.
|
|
8
8
|
|
|
9
9
|
The interpreter exposes no host functions, filesystem, network, timers or module loader. Environment code receives an explicit seed and supplied inputs; ambient `Date` and `Math.random` are unavailable. A module cannot call a production connector or launch a process. Tools that require those capabilities need a separate host adapter and its permissions.
|
|
@@ -53,7 +53,9 @@ Hosts persist the returned attempt under their task/model/release identity and g
|
|
|
53
53
|
|
|
54
54
|
## Lifecycle ownership
|
|
55
55
|
|
|
56
|
-
Server hosts should pass `
|
|
56
|
+
Server hosts that require process isolation should pass `executeJavaScriptEnvironmentInProcess` as the session or attempt runner. It requires Node 22.14–24 on `PATH` and gives each operation a fresh Node child and QuickJS interpreter. The child inherits only `PATH`, uses a bounded heap and response stream, and is killed on timeout or cancellation. Authored source travels as JSON interpreter data. A promise settles only after the child exits. This keeps interpreter allocation outside the execution owner's worker-thread lifecycle. `executeJavaScriptVerifierInProcess` provides the same ownership for graders from `@openpond/evals/javascript-verifier/node`.
|
|
57
|
+
|
|
58
|
+
Node hosts can also use `executeJavaScriptEnvironmentInWorker`. Each worker runs a fresh interpreter and settles only after termination. Both owners include startup in the declared deadline; neither retries failed operations. The session rejects overlapping operations and waits for active execution to stop before cleanup. Call `destroy` in `finally` when using the session API directly; the attempt runner does this automatically.
|
|
57
59
|
|
|
58
60
|
Cleanup receives the definition's `operationTimeoutMs`, including interpreter and
|
|
59
61
|
worker startup, with no shorter implicit deadline. It still runs after the episode
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { JavaScriptEnvironmentOperationSchema, JavaScriptEnvironmentResultSchema } from "./javascript-environment-contract.js";
|
|
2
2
|
import { executeJavaScriptIsolateInWorker } from "./javascript-isolate-node.js";
|
|
3
|
+
import { executeJavaScriptIsolateInProcess } from "./javascript-isolate-process.js";
|
|
3
4
|
/** The execution owner awaits termination before recording a step or cleanup. */
|
|
4
5
|
export async function executeJavaScriptEnvironmentInWorker(input) {
|
|
5
6
|
const operation = JavaScriptEnvironmentOperationSchema.parse(input.operation);
|
|
6
7
|
return JavaScriptEnvironmentResultSchema.parse(await executeJavaScriptIsolateInWorker({ ...input, exportName: operation, maxResultBytes: 1_572_864, deterministic: true, errorPrefix: "environment" }));
|
|
7
8
|
}
|
|
9
|
+
/** Uses a Node child process independently of the execution owner's runtime. */
|
|
10
|
+
export async function executeJavaScriptEnvironmentInProcess(input) {
|
|
11
|
+
const operation = JavaScriptEnvironmentOperationSchema.parse(input.operation);
|
|
12
|
+
return JavaScriptEnvironmentResultSchema.parse(await executeJavaScriptIsolateInProcess({ ...input, exportName: operation, maxResultBytes: 1_572_864, deterministic: true, errorPrefix: "environment" }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { executeJavaScriptIsolate } from "./javascript-isolate.js";
|
|
2
|
+
// Only this bundled, trusted program runs in Node. Authored source is interpreter data.
|
|
3
|
+
const owner = globalThis;
|
|
4
|
+
const input = owner.__openpondIsolateInput;
|
|
5
|
+
delete owner.__openpondIsolateInput;
|
|
6
|
+
if (!input)
|
|
7
|
+
throw new Error("JavaScript process requires its execution owner.");
|
|
8
|
+
void executeJavaScriptIsolate(input).then((result) => process.stdout.write(JSON.stringify({ ok: true, result })), (error) => process.stdout.write(JSON.stringify({ ok: false, error: (error instanceof Error ? error.message : "JavaScript execution failed.").slice(0, 8_192) })));
|