@opencode/codemode 0.0.0-dev-1249 → 0.0.0-dev-1257
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 +1 -1
- package/dist/{vm/async.d.ts → async.d.ts} +1 -1
- package/dist/codemode.d.ts +3 -3
- package/dist/codemode.js +5 -5
- package/dist/{vm/data.d.ts → data.d.ts} +0 -1
- package/dist/{vm/data.js → data.js} +0 -1
- package/dist/extension.d.ts +1 -1
- package/dist/{vm/host.d.ts → host.d.ts} +1 -1
- package/dist/{vm/opcodes.d.ts → opcodes.d.ts} +1 -1
- package/dist/{vm/prelude → prelude}/helpers.js +1 -1
- package/dist/{vm/runtime → runtime}/driver.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/driver.js +1 -1
- package/dist/{vm/runtime → runtime}/errors.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/errors.js +2 -2
- package/dist/{vm/runtime → runtime}/execute.d.ts +2 -3
- package/dist/{vm/runtime → runtime}/execute.js +1 -2
- package/dist/{vm/runtime → runtime}/extensions.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/extensions.js +2 -2
- package/dist/{vm/runtime → runtime}/globals.js +1 -1
- package/dist/{vm/runtime → runtime}/interpreter.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/model.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/objects.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/objects.js +1 -1
- package/dist/{vm/runtime → runtime}/operations.d.ts +1 -1
- package/dist/{vm/runtime → runtime}/operations.js +1 -1
- package/dist/{vm/runtime → runtime}/references.js +1 -1
- package/dist/scan.js +2 -2
- package/dist/{vm/scheduler.d.ts → scheduler.d.ts} +1 -1
- package/dist/{vm/snapshot → snapshot}/codec.d.ts +3 -3
- package/dist/{vm/snapshot → snapshot}/codec.js +2 -2
- package/dist/{vm/snapshot → snapshot}/snapshot.d.ts +2 -2
- package/dist/{vm/snapshot → snapshot}/snapshot.js +1 -1
- package/dist/{vm/snapshot.js → snapshot.js} +1 -1
- package/dist/{vm/stdlib → stdlib}/array.js +1 -1
- package/dist/{vm/stdlib → stdlib}/console.js +1 -1
- package/dist/{vm/stdlib → stdlib}/object.js +1 -1
- package/dist/{vm/stdlib → stdlib}/web.js +1 -1
- package/dist/tool-runtime.d.ts +1 -1
- package/dist/{vm/vm.d.ts → vm.d.ts} +3 -3
- package/dist/{vm/vm.js → vm.js} +1 -1
- package/package.json +1 -1
- /package/dist/{vm/async.js → async.js} +0 -0
- /package/dist/{vm/code.d.ts → code.d.ts} +0 -0
- /package/dist/{vm/code.js → code.js} +0 -0
- /package/dist/{vm/compiler → compiler}/compile.d.ts +0 -0
- /package/dist/{vm/compiler → compiler}/compile.js +0 -0
- /package/dist/{vm/compiler → compiler}/scope.d.ts +0 -0
- /package/dist/{vm/compiler → compiler}/scope.js +0 -0
- /package/dist/{vm/generators.d.ts → generators.d.ts} +0 -0
- /package/dist/{vm/generators.js → generators.js} +0 -0
- /package/dist/{vm/host.js → host.js} +0 -0
- /package/dist/{vm/internal-prelude.d.ts → internal-prelude.d.ts} +0 -0
- /package/dist/{vm/internal-prelude.js → internal-prelude.js} +0 -0
- /package/dist/{vm/opcodes.js → opcodes.js} +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.js +0 -0
- /package/dist/{vm/prelude → prelude}/bytecode.json +0 -0
- /package/dist/{vm/prelude → prelude}/helpers.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/prelude.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/prelude.js +0 -0
- /package/dist/{vm/prelude → prelude}/source.d.ts +0 -0
- /package/dist/{vm/prelude → prelude}/source.js +0 -0
- /package/dist/{vm/runtime → runtime}/callback.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/callback.js +0 -0
- /package/dist/{vm/runtime → runtime}/generators.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/generators.js +0 -0
- /package/dist/{vm/runtime → runtime}/globals.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/interpreter.js +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsic-names.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsic-names.js +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsics.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/intrinsics.js +0 -0
- /package/dist/{vm/runtime → runtime}/limits.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/limits.js +0 -0
- /package/dist/{vm/runtime → runtime}/model.js +0 -0
- /package/dist/{vm/runtime → runtime}/modules.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/modules.js +0 -0
- /package/dist/{vm/runtime → runtime}/native.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/native.js +0 -0
- /package/dist/{vm/runtime → runtime}/promises.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/promises.js +0 -0
- /package/dist/{vm/runtime → runtime}/references.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/signals.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/signals.js +0 -0
- /package/dist/{vm/runtime → runtime}/source.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/source.js +0 -0
- /package/dist/{vm/runtime → runtime}/table.d.ts +0 -0
- /package/dist/{vm/runtime → runtime}/table.js +0 -0
- /package/dist/{vm/scheduler.js → scheduler.js} +0 -0
- /package/dist/{vm/snapshot.d.ts → snapshot.d.ts} +0 -0
- /package/dist/{vm/stdlib → stdlib}/array.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/bytes.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/bytes.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/collections.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/collections.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/console.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/date.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/date.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/headers.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/headers.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/iterator.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/iterator.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/json.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/json.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/math.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/math.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/number.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/number.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/object.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/regexp.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/regexp.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/string.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/string.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/url.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/url.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/value.d.ts +0 -0
- /package/dist/{vm/stdlib → stdlib}/value.js +0 -0
- /package/dist/{vm/stdlib → stdlib}/web.d.ts +0 -0
package/README.md
CHANGED
|
@@ -246,7 +246,7 @@ Every value crossing in either direction is converted, never shared: arguments c
|
|
|
246
246
|
copies, and a function inside a result is callable the same way. A global that shadows a built-in or another
|
|
247
247
|
extension throws at `CodeMode.make`.
|
|
248
248
|
|
|
249
|
-
Functions inside a result have no data form, so a suspended
|
|
249
|
+
Functions inside a result have no data form, so a suspended run loses them by default: after a resume, calling one
|
|
250
250
|
throws a `TypeError`. An extension can preserve them across suspend and resume with `snapshot` hooks. `encode` receives
|
|
251
251
|
a value one of the extension's functions returned, as the host function returned it, and returns plain data (JSON
|
|
252
252
|
values and `Uint8Array`s); on resume, `decode` receives that data once per value and returns a host value of the same
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic } from "
|
|
1
|
+
import type { Diagnostic } from "./codemode.js";
|
|
2
2
|
import { type AstNode } from "./runtime/model.js";
|
|
3
3
|
import { type Callable, PromiseObj, type Value } from "./runtime/objects.js";
|
|
4
4
|
import { type Completion } from "./runtime/signals.js";
|
package/dist/codemode.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { Extension } from "./extension.js";
|
|
|
3
3
|
import { scanTools } from "./scan.js";
|
|
4
4
|
import { type Services, type ToolDescription, ToolRuntime } from "./tool-runtime.js";
|
|
5
5
|
import type { Tools } from "./tools.js";
|
|
6
|
-
import { SuspendError } from "./
|
|
7
|
-
import { fromBytes, type Snapshot, SnapshotError, type SnapshotHeader, toBytes } from "./
|
|
6
|
+
import { SuspendError } from "./runtime/execute.js";
|
|
7
|
+
import { fromBytes, type Snapshot, SnapshotError, type SnapshotHeader, toBytes } from "./snapshot/snapshot.js";
|
|
8
8
|
export { fromBytes, scanTools, SnapshotError, SuspendError, toBytes };
|
|
9
9
|
export type { Snapshot, SnapshotHeader };
|
|
10
10
|
/** A tool call admitted during an execution. */
|
|
@@ -179,7 +179,7 @@ export type Runtime<R = never> = {
|
|
|
179
179
|
readonly resume: (state: Snapshot | Uint8Array) => Program<R, SnapshotError>;
|
|
180
180
|
};
|
|
181
181
|
/**
|
|
182
|
-
* One run of a program
|
|
182
|
+
* One run of a program. `run()` runs it in the current fiber until it ends or is suspended, and owns its host
|
|
183
183
|
* calls: interrupting `run()` interrupts them. A program runs once: running it again is a defect.
|
|
184
184
|
*/
|
|
185
185
|
export type Program<R = never, E = never> = {
|
package/dist/codemode.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Deferred, Effect, Exit, Schema } from "effect";
|
|
2
2
|
import { scanTools } from "./scan.js";
|
|
3
3
|
import { ToolRuntime } from "./tool-runtime.js";
|
|
4
|
-
import { fromJson } from "./
|
|
5
|
-
import { finishExecution, resumeProgram, startProgram, SuspendError } from "./
|
|
6
|
-
import { extensionGlobals } from "./
|
|
7
|
-
import { globalNames } from "./
|
|
8
|
-
import { fromBytes, SnapshotError, toBytes } from "./
|
|
4
|
+
import { fromJson } from "./data.js";
|
|
5
|
+
import { finishExecution, resumeProgram, startProgram, SuspendError } from "./runtime/execute.js";
|
|
6
|
+
import { extensionGlobals } from "./runtime/extensions.js";
|
|
7
|
+
import { globalNames } from "./runtime/globals.js";
|
|
8
|
+
import { fromBytes, SnapshotError, toBytes } from "./snapshot/snapshot.js";
|
|
9
9
|
export { fromBytes, scanTools, SnapshotError, SuspendError, toBytes };
|
|
10
10
|
/** Signature-construction helpers for host-owned catalog instructions. */
|
|
11
11
|
export { searchSignature, toolExpression } from "./tool-runtime.js";
|
package/dist/extension.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Effect } from "effect";
|
|
|
11
11
|
* promise of an asynchronous global and by throwing from a synchronous one. Functions inside a global object are
|
|
12
12
|
* called the same way, named by their path (`fs.readFile`).
|
|
13
13
|
*
|
|
14
|
-
* Programs can also `import` or `require` a global by its Node module name; see `
|
|
14
|
+
* Programs can also `import` or `require` a global by its Node module name; see `runtime/modules.ts`.
|
|
15
15
|
*/
|
|
16
16
|
export type Extension<Globals extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> = {
|
|
17
17
|
readonly name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiagnosticKind } from "
|
|
1
|
+
import type { DiagnosticKind } from "./codemode.js";
|
|
2
2
|
import type { ErrorType } from "./runtime/intrinsics.js";
|
|
3
3
|
/** Uninitialized lexical binding sentinel (temporal dead zone). */
|
|
4
4
|
export declare const HOLE: unique symbol;
|
|
@@ -9,7 +9,7 @@ import { native, receiver } from "../runtime/native.js";
|
|
|
9
9
|
import { Arr, Bytes, coerceToString, data, define, hidden, hasPrototype, keys, getOwn, IteratorObj, positionIterator, coerceToNumber, get, MapObj, Obj, PromiseObj, SetObj, WeakMapObj, WeakSetObj, } from "../runtime/objects.js";
|
|
10
10
|
import { builtinCursor, requireIteratorObject } from "../runtime/operations.js";
|
|
11
11
|
import { containsOpaqueReference, describeValue, isOpaque } from "../runtime/references.js";
|
|
12
|
-
import { compareText } from "
|
|
12
|
+
import { compareText } from "../tool-runtime.js";
|
|
13
13
|
import { Invoke } from "../runtime/signals.js";
|
|
14
14
|
const classes = { Array: Arr, Uint8Array: Bytes, Map: MapObj, Set: SetObj };
|
|
15
15
|
export const helpers = (ctx) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Context, Effect } from "effect";
|
|
2
2
|
import type { HostCall } from "../scheduler.js";
|
|
3
|
-
import { type ToolRuntime } from "
|
|
3
|
+
import { type ToolRuntime } from "../tool-runtime.js";
|
|
4
4
|
import type { Vm } from "../vm.js";
|
|
5
5
|
import { type Completion } from "./signals.js";
|
|
6
6
|
/** What `Driver.run` returns once the run was suspended: its state is saved, and the VM stopped. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cause, Effect, Exit, Fiber } from "effect";
|
|
2
|
-
import { toolExpression } from "
|
|
2
|
+
import { toolExpression } from "../tool-runtime.js";
|
|
3
3
|
import { locate } from "./errors.js";
|
|
4
4
|
import { PendingThrow } from "./model.js";
|
|
5
5
|
import { abrupt, Interruption, normal } from "./signals.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic } from "
|
|
1
|
+
import type { Diagnostic } from "../codemode.js";
|
|
2
2
|
import { type AstNode } from "./model.js";
|
|
3
3
|
import { type ErrorType } from "./intrinsics.js";
|
|
4
4
|
import { type Native, ErrorObj, Obj, type Value } from "./objects.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ToolError } from "
|
|
2
|
-
import { ToolRuntimeError } from "
|
|
1
|
+
import { ToolError } from "../tool-error.js";
|
|
2
|
+
import { ToolRuntimeError } from "../tool-runtime.js";
|
|
3
3
|
import { formatLocation, PendingThrow, Throw, sourceLocation } from "./model.js";
|
|
4
4
|
import { containsRuntimeReference } from "./references.js";
|
|
5
5
|
import { createErrorValue, isErrorType } from "./intrinsics.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Program } from "acorn";
|
|
2
2
|
import { Cause, Effect, Schema } from "effect";
|
|
3
|
-
import type { Diagnostic, Outcome, ResolvedExecutionLimits, Result } from "
|
|
3
|
+
import type { Diagnostic, Outcome, ResolvedExecutionLimits, Result } from "../codemode.js";
|
|
4
4
|
import { type Snapshot, SnapshotError } from "../snapshot/snapshot.js";
|
|
5
|
-
import { ToolRuntime } from "
|
|
5
|
+
import { ToolRuntime } from "../tool-runtime.js";
|
|
6
6
|
import { Interpreter } from "./interpreter.js";
|
|
7
7
|
import type { Value } from "./objects.js";
|
|
8
8
|
import { Source } from "./source.js";
|
|
@@ -33,7 +33,6 @@ export type Setup<R> = {
|
|
|
33
33
|
};
|
|
34
34
|
/** Turns a suspended outcome into a failure, for callers that only run programs to their end. */
|
|
35
35
|
export declare const finishExecution: <E, R>(outcome: Effect.Effect<Outcome, E, R>) => Effect.Effect<Result, E, R>;
|
|
36
|
-
export declare const executeProgram: <R>(code: string, prepared: ToolRuntime.Prepared<R>, limits: ResolvedExecutionLimits, hooks: ToolRuntime.Hooks<R>, globals?: Globals<R>, bindings?: Globals<R>, lossy?: boolean) => Effect.Effect<Result, never, R>;
|
|
37
36
|
/** A program ready to run on the VM: nothing runs until `run`. */
|
|
38
37
|
export declare const startProgram: <R>(setup: Setup<R>, code: string, bindings?: Globals<R>, runId?: string) => Running<R>;
|
|
39
38
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parse } from "acorn";
|
|
2
2
|
import { Cause, Deferred, Effect, Option, Schema } from "effect";
|
|
3
3
|
import { fromBytes, header, SnapshotError, toBytes } from "../snapshot/snapshot.js";
|
|
4
|
-
import { ToolRuntime } from "
|
|
4
|
+
import { ToolRuntime } from "../tool-runtime.js";
|
|
5
5
|
import { normalizeError } from "./errors.js";
|
|
6
6
|
import { createBuiltins } from "./intrinsics.js";
|
|
7
7
|
import { Interpreter } from "./interpreter.js";
|
|
@@ -29,7 +29,6 @@ export const finishExecution = (outcome) => Effect.map(outcome, (outcome) => {
|
|
|
29
29
|
toolCalls: outcome.state.header.toolCalls,
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
|
-
export const executeProgram = (code, prepared, limits, hooks, globals, bindings, lossy = false) => finishExecution(startProgram({ prepared, limits, hooks, globals, lossy }, code, bindings).run());
|
|
33
32
|
/** A program ready to run on the VM: nothing runs until `run`. */
|
|
34
33
|
export const startProgram = (setup, code, bindings, runId = crypto.randomUUID()) => new Running(setup, 0, () => {
|
|
35
34
|
if (code.trim().length === 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { isAsync } from "
|
|
3
|
-
import { hooked } from "
|
|
2
|
+
import { isAsync } from "../extension.js";
|
|
3
|
+
import { hooked } from "../tool-runtime.js";
|
|
4
4
|
import { errorMessage, errorType } from "./errors.js";
|
|
5
5
|
import { createErrorValue } from "./intrinsics.js";
|
|
6
6
|
import { MAX_ARRAY_LENGTH, MAX_VALUE_DEPTH } from "./limits.js";
|
|
@@ -15,7 +15,7 @@ import { headersGlobal } from "../stdlib/headers.js";
|
|
|
15
15
|
import { iteratorGlobals } from "../stdlib/iterator.js";
|
|
16
16
|
import { coercion } from "../stdlib/value.js";
|
|
17
17
|
import { base64Global, cryptoGlobal, structuredCloneGlobal } from "../stdlib/web.js";
|
|
18
|
-
import { ToolReference } from "
|
|
18
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
19
19
|
import { errorGlobal } from "./errors.js";
|
|
20
20
|
import { errorTypes } from "./intrinsics.js";
|
|
21
21
|
import { constants, constructor, methods, native, receiver } from "./native.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node } from "acorn";
|
|
2
2
|
import type { ErrorType } from "./intrinsics.js";
|
|
3
|
-
import type { DiagnosticKind } from "
|
|
3
|
+
import type { DiagnosticKind } from "../codemode.js";
|
|
4
4
|
import type { ErrorObj, Value } from "./objects.js";
|
|
5
5
|
/** Any parsed node; the compiler narrows on `type`, and diagnostics read `loc`. */
|
|
6
6
|
export type AstNode = Node;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolReference } from "
|
|
1
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
2
2
|
import type { Builtins } from "./intrinsics.js";
|
|
3
3
|
import { type AstNode, type PendingThrow } from "./model.js";
|
|
4
4
|
import { type Convert, type GeneratorRequest, Invoke, type Push, type Resume } from "./signals.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolReference } from "
|
|
1
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
2
2
|
import { checkArrayLength } from "./limits.js";
|
|
3
3
|
import { AsyncIteratorSymbol, IteratorSymbol, rangeError, Throw, typeError, } from "./model.js";
|
|
4
4
|
import { Invoke } from "./signals.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Expression, MemberExpression, NewExpression, Super } from "acorn";
|
|
2
|
-
import { ToolReference } from "
|
|
2
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
3
3
|
import { type AstNode } from "./model.js";
|
|
4
4
|
import { type Builtins } from "./intrinsics.js";
|
|
5
5
|
import { type Cursor, Obj, type Value } from "./objects.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolReference } from "
|
|
1
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
2
2
|
import { invalidData } from "./model.js";
|
|
3
3
|
import { Callable, getOwn, isRuntimeReference, Obj, Opaque, ownKeys } from "./objects.js";
|
|
4
4
|
/** Interpreter machinery that is never data, unlike a Date or Map, which cross some boundaries as copies. */
|
package/dist/scan.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "effect";
|
|
2
|
-
import { parseProgram } from "./
|
|
3
|
-
import { formatLocation } from "./
|
|
2
|
+
import { parseProgram } from "./runtime/execute.js";
|
|
3
|
+
import { formatLocation } from "./runtime/model.js";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts every `tools.<path>` referenced by a Code Mode program, in first-seen order. Fails on syntax errors,
|
|
6
6
|
* dynamic bracket access (`tools[name]`), or aliasing/passing `tools` rather than calling `tools.<path>(...)` directly.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Json } from "./data.js";
|
|
2
|
-
import type { ExtensionInvocation } from "
|
|
2
|
+
import type { ExtensionInvocation } from "./tool-runtime.js";
|
|
3
3
|
import type { AstNode } from "./runtime/model.js";
|
|
4
4
|
import type { Callable, Cursor, GeneratorObj, Obj, PromiseObj, Value } from "./runtime/objects.js";
|
|
5
5
|
import type { Completion } from "./runtime/signals.js";
|
|
@@ -12,7 +12,7 @@ export type Json = null | boolean | number | string | ReadonlyArray<Json> | {
|
|
|
12
12
|
* - `["s", name]` an interpreter symbol;
|
|
13
13
|
* - `["i", name]` a built-in or host global, unchanged since the runtime was made;
|
|
14
14
|
* - `["a", source, index]` an AST node (a call site, an error's location);
|
|
15
|
-
* - `["x", data]` something the
|
|
15
|
+
* - `["x", data]` something the VM names itself (compiled code, by source and function index);
|
|
16
16
|
* - `["r", id]` another record.
|
|
17
17
|
*/
|
|
18
18
|
export type Encoded = string | number | boolean | null | ReadonlyArray<Json>;
|
|
@@ -66,9 +66,9 @@ export type EncodeEnv = {
|
|
|
66
66
|
readonly lost: Array<string>;
|
|
67
67
|
readonly strict: boolean;
|
|
68
68
|
readonly hosts?: HostBridge | undefined;
|
|
69
|
-
/** More classes to save
|
|
69
|
+
/** More classes to save (the VM's frames and closures), after the built-in ones. */
|
|
70
70
|
readonly specs?: ReadonlyArray<ClassSpec> | undefined;
|
|
71
|
-
/** The data
|
|
71
|
+
/** The data the VM names an object or symbol by, saved as `["x", data]`, instead of copying it. */
|
|
72
72
|
readonly external?: ((value: object | symbol) => Json | undefined) | undefined;
|
|
73
73
|
};
|
|
74
74
|
/** What the decoder asks of the fresh runtime it restores into. */
|
|
@@ -6,8 +6,8 @@ import { deleted, OrderedTable } from "../runtime/table.js";
|
|
|
6
6
|
import { AsyncFromSyncIterator } from "../generators.js";
|
|
7
7
|
import { HostCall, Resolving } from "../scheduler.js";
|
|
8
8
|
import { TextDecoderObj } from "../stdlib/bytes.js";
|
|
9
|
-
import { ToolError, toolError } from "
|
|
10
|
-
import { ToolReference, ToolRuntimeError } from "
|
|
9
|
+
import { ToolError, toolError } from "../tool-error.js";
|
|
10
|
+
import { ToolReference, ToolRuntimeError } from "../tool-runtime.js";
|
|
11
11
|
/** A saved state can't be read, or doesn't fit this runtime. */
|
|
12
12
|
export class SnapshotError extends Error {
|
|
13
13
|
name = "SnapshotError";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Interpreter } from "../runtime/interpreter.js";
|
|
2
|
-
import type { ToolCall } from "
|
|
2
|
+
import type { ToolCall } from "../tool-runtime.js";
|
|
3
3
|
import { type Encoded, type Record, SnapshotError } from "./codec.js";
|
|
4
4
|
export { SnapshotError };
|
|
5
5
|
/** A snapshot as bytes: UTF-8 JSON. */
|
|
6
6
|
export declare const toBytes: (snapshot: Snapshot) => Uint8Array;
|
|
7
7
|
/** Reads bytes `toBytes` wrote; `restore` checks what they hold. */
|
|
8
8
|
export declare const fromBytes: (bytes: Uint8Array) => unknown;
|
|
9
|
-
/** The snapshot format this build writes and reads
|
|
9
|
+
/** The snapshot format this build writes and reads (see `src/snapshot.ts`). */
|
|
10
10
|
export declare const FORMAT = 2;
|
|
11
11
|
/**
|
|
12
12
|
* A suspended run's whole state as JSON: a header that says which build and sources it belongs to and what budget it
|
|
@@ -11,7 +11,7 @@ export const fromBytes = (bytes) => {
|
|
|
11
11
|
throw new SnapshotError(`Invalid snapshot: the bytes are not UTF-8 JSON (${String(error)}).`);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
/** The snapshot format this build writes and reads
|
|
14
|
+
/** The snapshot format this build writes and reads (see `src/snapshot.ts`). */
|
|
15
15
|
export const FORMAT = 2;
|
|
16
16
|
export const hostsId = (ctx) => hash([
|
|
17
17
|
...ctx.intrinsics.hosts(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import packageJson from "
|
|
1
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
2
2
|
import { staticNames, unchanged } from "./runtime/intrinsic-names.js";
|
|
3
3
|
import { Fn, Obj } from "./runtime/objects.js";
|
|
4
4
|
import { nodeId } from "./runtime/source.js";
|
|
@@ -6,7 +6,7 @@ import { invalidData, IteratorSymbol, rangeError, typeError } from "../runtime/m
|
|
|
6
6
|
import { changed, define, get, hidden, Arr, Bytes, GeneratorObj, Obj, PromiseObj, coerceToInteger, coerceToNumber, coerceToString, rejectAddition, } from "../runtime/objects.js";
|
|
7
7
|
import { describeValue, rejectCircularInsertion } from "../runtime/references.js";
|
|
8
8
|
import { requireCallback, withPrimitives } from "../runtime/callback.js";
|
|
9
|
-
import { compareText } from "
|
|
9
|
+
import { compareText } from "../tool-runtime.js";
|
|
10
10
|
const arrayLikeSource = (source) => {
|
|
11
11
|
// JS would treat a promise as an empty array-like; that would hide a missing `await`.
|
|
12
12
|
if (source instanceof Obj && !(source instanceof PromiseObj)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { methods } from "../runtime/native.js";
|
|
2
2
|
import { entries, get, Arr, Obj } from "../runtime/objects.js";
|
|
3
|
-
import { ToolReference } from "
|
|
3
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
4
4
|
import { containsOpaqueReference } from "../runtime/references.js";
|
|
5
5
|
const consoleMethods = ["log", "info", "debug", "warn", "error", "dir", "table"];
|
|
6
6
|
/** Captured console: every method appends one formatted line to `logs`. */
|
|
@@ -4,7 +4,7 @@ import { changed, entries, enumerableKeys, getOwn, hasOwn, hasPrototype, keys, o
|
|
|
4
4
|
import { primitivePrototype } from "../runtime/intrinsics.js";
|
|
5
5
|
import { describeValue, rejectCircularInsertion } from "../runtime/references.js";
|
|
6
6
|
import { invokeMethod } from "../runtime/callback.js";
|
|
7
|
-
import { ToolReference } from "
|
|
7
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
8
8
|
// ToObject for enumeration.
|
|
9
9
|
export const enumerableSource = (ctx, label, value, node) => {
|
|
10
10
|
if (value === null || value === undefined) {
|
|
@@ -3,7 +3,7 @@ import { typeError } from "../runtime/model.js";
|
|
|
3
3
|
import { define, entries, get, getOwn, hasOwn, hidden, isRuntimeReference, Arr, Bytes, DateObj, ErrorObj, MapObj, Obj, RegExpObj, SetObj, WeakMapObj, WeakSetObj, coerceToString, } from "../runtime/objects.js";
|
|
4
4
|
import { createErrorValue, isErrorType } from "../runtime/intrinsics.js";
|
|
5
5
|
import { describeValue } from "../runtime/references.js";
|
|
6
|
-
import { ToolReference } from "
|
|
6
|
+
import { ToolReference } from "../tool-runtime.js";
|
|
7
7
|
// WebIDL DOMString conversion: a missing argument is a TypeError, anything else stringifies. Invalid input is a
|
|
8
8
|
// TypeError as well; browsers throw a DOMException named InvalidCharacterError, which CodeMode does not have.
|
|
9
9
|
export const base64Global = (ctx, name) => fn(ctx.builtins, name, 1, (_, args) => {
|
package/dist/tool-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type { Json } from "./
|
|
2
|
+
import type { Json } from "./data.js";
|
|
3
3
|
import type { DiagnosticKind } from "./codemode.js";
|
|
4
4
|
import { type Namespace } from "./namespace.js";
|
|
5
5
|
import { type Durable, type Idempotent, type Tool } from "./tool.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic } from "
|
|
1
|
+
import type { Diagnostic } from "./codemode.js";
|
|
2
2
|
import type { Interpreter } from "./runtime/interpreter.js";
|
|
3
3
|
import { type AstNode } from "./runtime/model.js";
|
|
4
4
|
import { Arr, Fn, Obj, type Value } from "./runtime/objects.js";
|
|
@@ -124,11 +124,11 @@ export declare class Vm {
|
|
|
124
124
|
} | undefined;
|
|
125
125
|
/** Saves the run's state as it is now. */
|
|
126
126
|
capture(options: CaptureOptions): {
|
|
127
|
-
readonly snapshot: import("./
|
|
127
|
+
readonly snapshot: import("./codemode.js").Snapshot;
|
|
128
128
|
readonly lost: ReadonlyArray<string>;
|
|
129
129
|
};
|
|
130
130
|
/** Restores a saved state into this fresh VM, after checking it belongs to this build and runtime. */
|
|
131
|
-
restore(saved: unknown, options: RestoreOptions): import("./
|
|
131
|
+
restore(saved: unknown, options: RestoreOptions): import("./codemode.js").Snapshot;
|
|
132
132
|
deliverAnswer(frame: Frame): void;
|
|
133
133
|
acquire(code: Code): Frame;
|
|
134
134
|
release(frame: Frame): void;
|
package/dist/{vm/vm.js → vm.js}
RENAMED
|
@@ -12,7 +12,7 @@ import { Source } from "./runtime/source.js";
|
|
|
12
12
|
import { compiledPrelude } from "./prelude/prelude.js";
|
|
13
13
|
import { constructRegExp } from "./stdlib/regexp.js";
|
|
14
14
|
import { enumerableSource } from "./stdlib/object.js";
|
|
15
|
-
import { ToolReference } from "
|
|
15
|
+
import { ToolReference } from "./tool-runtime.js";
|
|
16
16
|
import { registerAsyncIntrinsics, VmScheduler } from "./async.js";
|
|
17
17
|
import { captureVm, restoreVm } from "./snapshot.js";
|
|
18
18
|
import { compileSource } from "./compiler/compile.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/codemode",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-1257",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|