@opencode/codemode 0.0.0-dev-1032 → 0.0.0-dev-1035
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/dist/interpreter/callback.d.ts +12 -1
- package/dist/interpreter/callback.js +13 -1
- package/dist/interpreter/interpreter.js +2 -2
- package/dist/interpreter/promises.js +2 -2
- package/dist/interpreter/runner.d.ts +1 -11
- package/dist/interpreter/runner.js +1 -13
- package/dist/stdlib/iterator.js +1 -2
- package/package.json +1 -1
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import type { Cause } from "effect";
|
|
1
2
|
import type { Interpreter } from "./interpreter.js";
|
|
2
3
|
import { Callable, type Cursor, type NativeResult, type Value } from "./objects.js";
|
|
3
|
-
import {
|
|
4
|
+
import type { Eval } from "./runner.js";
|
|
5
|
+
/**
|
|
6
|
+
* Host work that was interrupted on its own. It settles its promise like a rejection, but program code cannot catch
|
|
7
|
+
* it: handlers, `catch`, and `finally` are skipped, an unobserved one is not reported, and one that reaches the
|
|
8
|
+
* program's body interrupts the execution.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Interruption {
|
|
11
|
+
readonly cause: Cause.Cause<unknown>;
|
|
12
|
+
constructor(cause: Cause.Cause<unknown>);
|
|
13
|
+
}
|
|
14
|
+
export declare const isEval: <A>(value: A | Eval<A>) => value is Eval<A>;
|
|
4
15
|
/** IteratorClose: a consumer failure closes the iterator and wins over any close failure, except that a generator's
|
|
5
16
|
* return() is a return completion, so a failing close wins over it, as after `break`. */
|
|
6
17
|
export declare function preserveConsumerError<A>(close: Cursor["close"], body: Eval<A>): Eval<A>;
|
|
@@ -2,7 +2,19 @@ import { primitivePrototype } from "./intrinsics.js";
|
|
|
2
2
|
import { GeneratorReturn, typeError } from "./model.js";
|
|
3
3
|
import { Callable, get, Native, DateObj, Obj, coerceToNumber, coerceToString, } from "./objects.js";
|
|
4
4
|
import { isOpaque, typeofValue } from "./references.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Host work that was interrupted on its own. It settles its promise like a rejection, but program code cannot catch
|
|
7
|
+
* it: handlers, `catch`, and `finally` are skipped, an unobserved one is not reported, and one that reaches the
|
|
8
|
+
* program's body interrupts the execution.
|
|
9
|
+
*/
|
|
10
|
+
export class Interruption {
|
|
11
|
+
cause;
|
|
12
|
+
constructor(cause) {
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Program values never have a `next` method of their own: an object's properties live in its property map.
|
|
17
|
+
export const isEval = (value) => typeof value === "object" && value !== null && typeof value.next === "function";
|
|
6
18
|
/** IteratorClose: a consumer failure closes the iterator and wins over any close failure, except that a generator's
|
|
7
19
|
* return() is a return completion, so a failing close wins over it, as after `break`. */
|
|
8
20
|
export function* preserveConsumerError(close, body) {
|
|
@@ -6,8 +6,8 @@ import { locate, materialize } from "./errors.js";
|
|
|
6
6
|
import { primitivePrototype } from "./intrinsics.js";
|
|
7
7
|
import { globals } from "./globals.js";
|
|
8
8
|
import { assign, Callable, define, frozen, get, hostCursor, IteratorObj, has, hasOwn, hidden, hasPrototype, keys, Native, parseArrayIndex, Arguments, Arr, Fn, GeneratorObj, Obj, PromiseObj, iteratorResult, remove, set, coerceToNumber, coerceToString, entries, getOwn, } from "./objects.js";
|
|
9
|
-
import { preserveConsumerError, toPrimitive } from "./callback.js";
|
|
10
|
-
import { AsyncBoundary, Await, Call,
|
|
9
|
+
import { Interruption, isEval, preserveConsumerError, toPrimitive } from "./callback.js";
|
|
10
|
+
import { AsyncBoundary, Await, Call, MAX_CALL_DEPTH, Runner, Slice, Task, Yield, normal, } from "./runner.js";
|
|
11
11
|
import { moduleName, resolveModule } from "./modules.js";
|
|
12
12
|
import { describeValue, isOpaque, rejectCircularInsertion, typeofValue } from "./references.js";
|
|
13
13
|
import { fn } from "./native.js";
|
|
@@ -3,8 +3,8 @@ import { Callable, define, get, hidden, Arr, Fn, Obj, PromiseObj, record } from
|
|
|
3
3
|
import { constructor, fn, methods, native, receiver, requiresNew } from "./native.js";
|
|
4
4
|
import { createAggregateErrorValue, materialize } from "./errors.js";
|
|
5
5
|
import { describeValue, typeofValue } from "./references.js";
|
|
6
|
-
import { isSupportedCallback } from "./callback.js";
|
|
7
|
-
import {
|
|
6
|
+
import { Interruption, isSupportedCallback } from "./callback.js";
|
|
7
|
+
import { normal, Task } from "./runner.js";
|
|
8
8
|
// A `resolve`/`reject` handed to an executor or thenable: calling it settles the capability.
|
|
9
9
|
const resolvingFunctions = (ctx, resolving) => ({
|
|
10
10
|
resolve: fn(ctx.builtins, "resolve", 1, (_, args) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Context, Effect } from "effect";
|
|
2
2
|
import type { Diagnostic } from "../codemode.js";
|
|
3
3
|
import type { Interpreter } from "./interpreter.js";
|
|
4
4
|
import { type AstNode, type GeneratorRequestKind } from "./model.js";
|
|
@@ -46,15 +46,6 @@ export declare class Host {
|
|
|
46
46
|
readonly effect: Effect.Effect<unknown, unknown>;
|
|
47
47
|
constructor(effect: Effect.Effect<unknown, unknown>);
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Host work that was interrupted on its own. It settles its promise like a rejection, but program code cannot catch
|
|
51
|
-
* it: handlers, `catch`, and `finally` are skipped, an unobserved one is not reported, and one that reaches the
|
|
52
|
-
* program's body interrupts the execution.
|
|
53
|
-
*/
|
|
54
|
-
export declare class Interruption {
|
|
55
|
-
readonly cause: Cause.Cause<unknown>;
|
|
56
|
-
constructor(cause: Cause.Cause<unknown>);
|
|
57
|
-
}
|
|
58
49
|
/** Let the host run; the current job continues before any other job. */
|
|
59
50
|
export declare const Slice: unique symbol;
|
|
60
51
|
export type Signal = Call | Enter | Await | Yield | Host | typeof Slice;
|
|
@@ -110,7 +101,6 @@ export type Resolving = {
|
|
|
110
101
|
type Job = () => Start | void;
|
|
111
102
|
/** Most activations one task may hold, as the call-stack limit. */
|
|
112
103
|
export declare const MAX_CALL_DEPTH = 10000;
|
|
113
|
-
export declare const isEval: <A>(value: A | Eval<A>) => value is Eval<A>;
|
|
114
104
|
/**
|
|
115
105
|
* One execution's job queue. Program code runs only inside a job, one job at a time and each to completion, as in a
|
|
116
106
|
* JavaScript engine: promise reactions and resumed awaits queue in order, host work runs concurrently and settles its
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Cause, Effect, Exit, Fiber } from "effect";
|
|
2
|
+
import { Interruption } from "./callback.js";
|
|
2
3
|
import { locate, normalizeError } from "./errors.js";
|
|
3
4
|
import { MAX_PENDING_PROMISES } from "./limits.js";
|
|
4
5
|
import { PendingThrow, rangeError, Throw, typeError } from "./model.js";
|
|
@@ -48,17 +49,6 @@ export class Host {
|
|
|
48
49
|
this.effect = effect;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Host work that was interrupted on its own. It settles its promise like a rejection, but program code cannot catch
|
|
53
|
-
* it: handlers, `catch`, and `finally` are skipped, an unobserved one is not reported, and one that reaches the
|
|
54
|
-
* program's body interrupts the execution.
|
|
55
|
-
*/
|
|
56
|
-
export class Interruption {
|
|
57
|
-
cause;
|
|
58
|
-
constructor(cause) {
|
|
59
|
-
this.cause = cause;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
52
|
/** Let the host run; the current job continues before any other job. */
|
|
63
53
|
export const Slice = Symbol("codemode.slice");
|
|
64
54
|
/** The boundary of an async body: the body's completion settles it, and the caller receives `result` at once. */
|
|
@@ -94,8 +84,6 @@ export const MAX_CALL_DEPTH = 10_000;
|
|
|
94
84
|
/** Interpreter steps between clock checks, and how long one slice may run before the host gets a turn. */
|
|
95
85
|
const FUEL = 64;
|
|
96
86
|
const SLICE_MS = 1;
|
|
97
|
-
// Program values never have a `next` method of their own: an object's properties live in its property map.
|
|
98
|
-
export const isEval = (value) => typeof value === "object" && value !== null && typeof value.next === "function";
|
|
99
87
|
/**
|
|
100
88
|
* One execution's job queue. Program code runs only inside a job, one job at a time and each to completion, as in a
|
|
101
89
|
* JavaScript engine: promise reactions and resumed awaits queue in order, host work runs concurrently and settles its
|
package/dist/stdlib/iterator.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { applyCollectionCallback } from "../interpreter/callback.js";
|
|
1
|
+
import { applyCollectionCallback, Interruption } from "../interpreter/callback.js";
|
|
2
2
|
import { rangeError, typeError } from "../interpreter/model.js";
|
|
3
3
|
import { constructor, fn, methods, receiver, requiresNew } from "../interpreter/native.js";
|
|
4
4
|
import { Arr, coerceToNumber, define, hasPrototype, hidden, iteratorResult, IteratorObj, Obj, } from "../interpreter/objects.js";
|
|
5
5
|
import { describeValue } from "../interpreter/references.js";
|
|
6
|
-
import { Interruption } from "../interpreter/runner.js";
|
|
7
6
|
const finished = { done: true, value: undefined };
|
|
8
7
|
// Every built-in iterator and helper shares the Iterator prototype; JS gives each collection its own, which is only
|
|
9
8
|
// observable through getPrototypeOf.
|
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-1035",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|