@opencode/codemode 0.0.0-beta-19381 → 0.0.0-beta-19419

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/data.d.ts CHANGED
@@ -7,7 +7,6 @@ export declare class ToolRuntimeError extends Error {
7
7
  readonly suggestions: ReadonlyArray<string>;
8
8
  constructor(kind: Extract<DiagnosticKind, "UnknownTool" | "InvalidToolInput" | "InvalidToolOutput" | "InvalidDataValue" | "ToolCallLimitExceeded">, message: string, suggestions?: ReadonlyArray<string>);
9
9
  }
10
- export declare const isBlockedMember: (name: string) => boolean;
11
10
  /**
12
11
  * Brings a host-produced runtime value into the program: runtime values pass through, their host
13
12
  * counterparts (Date, RegExp, Map, Set, URL, URLSearchParams) are wrapped, and objects become
package/dist/data.js CHANGED
@@ -11,8 +11,6 @@ export class ToolRuntimeError extends Error {
11
11
  this.name = "ToolRuntimeError";
12
12
  }
13
13
  }
14
- const blockedMemberNames = new Set(["__proto__", "constructor", "prototype"]);
15
- export const isBlockedMember = (name) => blockedMemberNames.has(name);
16
14
  /**
17
15
  * Brings a host-produced runtime value into the program: runtime values pass through, their host
18
16
  * counterparts (Date, RegExp, Map, Set, URL, URLSearchParams) are wrapped, and objects become
@@ -102,10 +100,7 @@ const copy = (value, label, mode, depth, seen) => {
102
100
  for (const [key, item] of Object.entries(value)) {
103
101
  if (Object.hasOwn(copied, key))
104
102
  continue;
105
- if (isBlockedMember(key)) {
106
- throw new ToolRuntimeError("InvalidDataValue", `${label} contains blocked property '${key}'.`);
107
- }
108
- Reflect.set(copied, key, copy(item, label, mode, depth + 1, seen));
103
+ define(copied, key, copy(item, label, mode, depth + 1, seen));
109
104
  }
110
105
  }
111
106
  seen.delete(value);
@@ -117,14 +112,16 @@ const copy = (value, label, mode, depth, seen) => {
117
112
  }
118
113
  const copied = plain ? Object.create(null) : {};
119
114
  for (const [key, item] of Object.entries(value)) {
120
- if (isBlockedMember(key)) {
121
- throw new ToolRuntimeError("InvalidDataValue", `${label} contains blocked property '${key}'.`);
122
- }
123
115
  const next = copy(item, label, mode, depth + 1, seen);
124
116
  if (next === undefined && mode === "json")
125
117
  continue;
126
- copied[key] = next;
118
+ define(copied, key, next);
127
119
  }
128
120
  seen.delete(value);
129
121
  return copied;
130
122
  };
123
+ // Own data property regardless of the target's prototype, so a "__proto__" key on a host object or
124
+ // array never reaches the Object.prototype setter.
125
+ const define = (target, key, value) => {
126
+ Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
127
+ };
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { isBlockedMember, toProgram } from "../data.js";
2
+ import { toProgram } from "../data.js";
3
3
  import { dateSetterArgumentCount, invokeDateMethod } from "../stdlib/date.js";
4
4
  import { invokeNumberMethod } from "../stdlib/number.js";
5
5
  import { invokeRegExpMethod, matchToValue, toHostRegex } from "../stdlib/regexp.js";
@@ -241,8 +241,7 @@ const invokeStringReplacer = (runner, value, name, args, node) => {
241
241
  if (hasGroups) {
242
242
  const safeGroups = Object.create(null);
243
243
  for (const [key, group] of Object.entries(groups)) {
244
- if (!isBlockedMember(key))
245
- safeGroups[key] = group;
244
+ safeGroups[key] = group;
246
245
  }
247
246
  callbackArgs[callbackArgs.length - 1] = safeGroups;
248
247
  }
@@ -72,7 +72,6 @@ export declare class GeneratorReturn {
72
72
  constructor(value: unknown);
73
73
  }
74
74
  export declare const OptionalShortCircuit: unique symbol;
75
- export declare const supportedSyntaxMessage = "Supported orchestration syntax: tools.* calls (they return promises - resolve them with await), data literals, destructuring, optional chaining, template literals, conditionals, switch, loops (incl. for...of and for...in over object/array/tools keys), arrow functions, spread, try/catch, array methods (map/filter/find/findIndex/some/every/reduce/flatMap/forEach/sort/slice/concat/indexOf/lastIndexOf/at/flat/reverse/includes/join), string methods (incl. match/matchAll/replace/split with regular expressions), Date/RegExp/Map/Set/URL/URLSearchParams, URI encoding helpers, Object/Math/JSON helpers, captured console.log/warn/error/dir/table, Promise.all/allSettled/race/any/resolve/reject over arrays mixing promises and plain values for parallel tool calls, promise chaining with .then/.catch/.finally, and new Promise((resolve, reject) => ...) construction.";
76
75
  export declare class InterpreterRuntimeError extends Error {
77
76
  readonly kind: DiagnosticKind;
78
77
  readonly suggestions?: ReadonlyArray<string> | undefined;
@@ -81,6 +80,7 @@ export declare class InterpreterRuntimeError extends Error {
81
80
  constructor(message: string, node?: AstNode, kind?: DiagnosticKind, suggestions?: ReadonlyArray<string> | undefined);
82
81
  as(errorName: string): this;
83
82
  }
83
+ export declare const supportedSyntaxMessage = "This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, this, getters/setters, tagged templates, BigInt, and custom Symbols. Use plain functions and data objects instead.";
84
84
  export declare const unsupportedSyntax: (kind: string, node: AstNode) => InterpreterRuntimeError;
85
85
  export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
86
86
  export declare const sourceLocation: (node: AstNode) => {
@@ -66,7 +66,6 @@ export class GeneratorReturn {
66
66
  }
67
67
  }
68
68
  export const OptionalShortCircuit = Symbol("codemode.optional-short-circuit");
69
- export const supportedSyntaxMessage = "Supported orchestration syntax: tools.* calls (they return promises - resolve them with await), data literals, destructuring, optional chaining, template literals, conditionals, switch, loops (incl. for...of and for...in over object/array/tools keys), arrow functions, spread, try/catch, array methods (map/filter/find/findIndex/some/every/reduce/flatMap/forEach/sort/slice/concat/indexOf/lastIndexOf/at/flat/reverse/includes/join), string methods (incl. match/matchAll/replace/split with regular expressions), Date/RegExp/Map/Set/URL/URLSearchParams, URI encoding helpers, Object/Math/JSON helpers, captured console.log/warn/error/dir/table, Promise.all/allSettled/race/any/resolve/reject over arrays mixing promises and plain values for parallel tool calls, promise chaining with .then/.catch/.finally, and new Promise((resolve, reject) => ...) construction.";
70
69
  export class InterpreterRuntimeError extends Error {
71
70
  kind;
72
71
  suggestions;
@@ -85,6 +84,8 @@ export class InterpreterRuntimeError extends Error {
85
84
  return this;
86
85
  }
87
86
  }
87
+ // Orient the agent rather than enumerate JavaScript; interpreter-support.md is the full matrix.
88
+ export const supportedSyntaxMessage = "This is a restricted JavaScript-like language. Supported: plain and async functions, data literals, destructuring, standard control flow, await and Promise, and built-ins such as Array, Object, Math, JSON, Date, RegExp, Map, Set, and URL. Unsupported: classes, this, getters/setters, tagged templates, BigInt, and custom Symbols. Use plain functions and data objects instead.";
88
89
  export const unsupportedSyntax = (kind, node) => new InterpreterRuntimeError(`Syntax '${kind}' is not supported. ${supportedSyntaxMessage}`, node, "UnsupportedSyntax", [supportedSyntaxMessage]);
89
90
  export const isRecord = (value) => typeof value === "object" && value !== null;
90
91
  export const sourceLocation = (node) => ({
@@ -3,4 +3,5 @@ export declare const isRuntimeReference: (value: unknown) => boolean;
3
3
  export declare const containsRuntimeReference: (value: unknown) => boolean;
4
4
  export declare const containsOpaqueReference: (value: unknown) => boolean;
5
5
  export declare const rejectCircularInsertion: (container: object, value: unknown, label: string, node: AstNode, seen?: Set<object>) => void;
6
+ export declare const describeValue: (value: unknown) => string;
6
7
  export declare const typeofValue: (value: unknown) => string;
@@ -50,6 +50,35 @@ export const rejectCircularInsertion = (container, value, label, node, seen = ne
50
50
  throw new InterpreterRuntimeError(`${label} contains a circular value.`, node, "InvalidDataValue");
51
51
  }
52
52
  };
53
+ export const describeValue = (value) => {
54
+ if (value === null)
55
+ return "null";
56
+ if (Array.isArray(value))
57
+ return "an array";
58
+ if (value instanceof Values.Promise)
59
+ return "an un-awaited Promise";
60
+ if (value instanceof ToolReference)
61
+ return "a tool reference";
62
+ if (value instanceof Values.Date)
63
+ return "a Date";
64
+ if (value instanceof Values.RegExp)
65
+ return "a RegExp";
66
+ if (value instanceof Values.Map)
67
+ return "a Map";
68
+ if (value instanceof Values.Set)
69
+ return "a Set";
70
+ if (value instanceof Values.URL)
71
+ return "a URL";
72
+ if (value instanceof Values.URLSearchParams)
73
+ return "a URLSearchParams";
74
+ if (value instanceof CodeModeGenerator)
75
+ return "a generator";
76
+ if (isRuntimeReference(value))
77
+ return "a function";
78
+ if (typeof value === "object")
79
+ return "a data object";
80
+ return `a ${typeof value}`;
81
+ };
53
82
  export const typeofValue = (value) => {
54
83
  if (value instanceof HostFunction ||
55
84
  value instanceof CodeModeFunction ||
@@ -1,5 +1,5 @@
1
1
  import { Cause, Deferred, Effect, Exit } from "effect";
2
- import { isBlockedMember, ToolRuntimeError, toProgram } from "../data.js";
2
+ import { ToolRuntimeError, toProgram } from "../data.js";
3
3
  import { ToolReference } from "../tool-runtime.js";
4
4
  import { AsyncIteratorSymbol, CodeModeFunction, CodeModeGenerator, ComputedValue, GeneratorMethodReference, GeneratorReturn, IntrinsicReference, InterpreterRuntimeError, isRecord, IteratorSymbol, IteratorSymbols, OptionalShortCircuit, PromiseInstanceMethodReference, ProgramThrow, unsupportedSyntax, } from "./model.js";
5
5
  import { caughtErrorValue } from "./errors.js";
@@ -8,7 +8,7 @@ import { HostFunction, HostNamespace } from "./host.js";
8
8
  import { invokeIntrinsic } from "./methods.js";
9
9
  import { preserveConsumerError } from "./runner.js";
10
10
  import { invokePromiseInstanceMethod, PromiseRuntime, resolvePromise, resolvePromiseValue } from "./promises.js";
11
- import { containsOpaqueReference, isRuntimeReference, rejectCircularInsertion, typeofValue } from "./references.js";
11
+ import { containsOpaqueReference, describeValue, isRuntimeReference, rejectCircularInsertion, typeofValue, } from "./references.js";
12
12
  import { ScopeStack } from "./scope.js";
13
13
  import { arrayMethods, mapMethods, setMethods } from "../stdlib/collections.js";
14
14
  import { dateMethods } from "../stdlib/date.js";
@@ -804,14 +804,14 @@ class Frame {
804
804
  }
805
805
  if (pattern.type === "ObjectPattern") {
806
806
  if (value === null || typeof value !== "object" || isRuntimeReference(value)) {
807
- throw new InterpreterRuntimeError("Object destructuring requires a data object or array value.", pattern, "InvalidDataValue");
807
+ throw new InterpreterRuntimeError(`Object destructuring requires a data object or array value, received ${describeValue(value)}.`, pattern, "InvalidDataValue");
808
808
  }
809
809
  const consumed = new Set();
810
810
  for (const property of pattern.properties) {
811
811
  if (property.type === "RestElement") {
812
812
  const rest = Object.create(null);
813
813
  for (const [key, item] of Object.entries(value)) {
814
- if (!consumed.has(key) && !isBlockedMember(key))
814
+ if (!consumed.has(key))
815
815
  rest[key] = item;
816
816
  }
817
817
  copyIteratorSymbols(value, rest, consumed);
@@ -819,9 +819,6 @@ class Frame {
819
819
  continue;
820
820
  }
821
821
  const key = yield* self.destructuringPropertyKey(property);
822
- if (isBlockedMember(String(key))) {
823
- throw new InterpreterRuntimeError(`Property '${String(key)}' is not available.`, property);
824
- }
825
822
  consumed.add(typeof key === "symbol" ? key : String(key));
826
823
  yield* self.declarePattern(property.value, self.destructuringPropertyValue(value, key), mutable, property, initialize);
827
824
  }
@@ -851,7 +848,7 @@ class Frame {
851
848
  }
852
849
  if (pattern.type === "ObjectPattern") {
853
850
  if (value === null || typeof value !== "object" || isRuntimeReference(value)) {
854
- throw new InterpreterRuntimeError("Object destructuring requires a data object or array value.", pattern, "InvalidDataValue");
851
+ throw new InterpreterRuntimeError(`Object destructuring requires a data object or array value, received ${describeValue(value)}.`, pattern, "InvalidDataValue");
855
852
  }
856
853
  const source = value;
857
854
  const consumed = new Set();
@@ -859,7 +856,7 @@ class Frame {
859
856
  if (property.type === "RestElement") {
860
857
  const rest = Object.create(null);
861
858
  for (const [key, item] of Object.entries(source)) {
862
- if (!consumed.has(key) && !isBlockedMember(key))
859
+ if (!consumed.has(key))
863
860
  rest[key] = item;
864
861
  }
865
862
  copyIteratorSymbols(source, rest, consumed);
@@ -867,9 +864,6 @@ class Frame {
867
864
  continue;
868
865
  }
869
866
  const key = yield* self.destructuringPropertyKey(property);
870
- if (isBlockedMember(String(key))) {
871
- throw new InterpreterRuntimeError(`Property '${String(key)}' is not available.`, property);
872
- }
873
867
  consumed.add(typeof key === "symbol" ? key : String(key));
874
868
  yield* self.assignPattern(property.value, self.destructuringPropertyValue(source, key), property);
875
869
  }
@@ -1014,8 +1008,18 @@ class Frame {
1014
1008
  const callee = yield* self.evaluateExpression(node.callee);
1015
1009
  // Globals are built with this interpreter's R; `instanceof` cannot recover the type argument.
1016
1010
  const construct = callee instanceof HostFunction ? callee.construct : undefined;
1017
- if (construct === undefined)
1018
- throw unsupportedSyntax("NewExpression", node);
1011
+ if (construct === undefined) {
1012
+ // `new` itself is supported, so a non-constructible callee is a TypeError like JS rather than
1013
+ // unsupported syntax. Built-ins like Number are real constructors in JS, so do not claim
1014
+ // otherwise; say `new` is unsupported for them and point at the plain call.
1015
+ const name = calleeDescription(node.callee);
1016
+ const message = callee instanceof CodeModeFunction
1017
+ ? `${name} cannot be constructed: user-defined constructors and classes are not supported. Call it as a function that returns a plain object instead.`
1018
+ : callee instanceof HostFunction
1019
+ ? `new ${name}(...) is not supported; call ${name}(...) without new instead.`
1020
+ : `${name} is not a constructor.`;
1021
+ throw new InterpreterRuntimeError(message, node).as("TypeError");
1022
+ }
1019
1023
  const args = yield* self.evaluateCallArguments(node.arguments);
1020
1024
  return yield* construct(args, node);
1021
1025
  });
@@ -1565,13 +1569,10 @@ class Frame {
1565
1569
  if (spread === null || spread === undefined || Values.isValue(spread))
1566
1570
  continue;
1567
1571
  if (typeof spread !== "object" || Array.isArray(spread) || isRuntimeReference(spread)) {
1568
- throw new InterpreterRuntimeError("Object spread requires a data object.", property, "InvalidDataValue");
1572
+ throw new InterpreterRuntimeError(`Object spread requires a data object, received ${describeValue(spread)}.`, property, "InvalidDataValue");
1569
1573
  }
1570
- for (const [key, value] of Object.entries(spread)) {
1571
- if (isBlockedMember(key))
1572
- throw new InterpreterRuntimeError(`Property '${key}' is not available.`, property);
1574
+ for (const [key, value] of Object.entries(spread))
1573
1575
  objectValue[key] = value;
1574
- }
1575
1576
  copyIteratorSymbols(spread, objectValue);
1576
1577
  continue;
1577
1578
  }
@@ -1592,9 +1593,6 @@ class Frame {
1592
1593
  else {
1593
1594
  throw new InterpreterRuntimeError("Unsupported object property key shape.", keyNode);
1594
1595
  }
1595
- if (isBlockedMember(String(key))) {
1596
- throw new InterpreterRuntimeError(`Property '${String(key)}' is not available.`, keyNode);
1597
- }
1598
1596
  Reflect.set(objectValue, key, yield* self.evaluateExpression(property.value));
1599
1597
  }
1600
1598
  return objectValue;
@@ -1685,9 +1683,6 @@ class Frame {
1685
1683
  return new ToolReference([...objectValue.path, key]);
1686
1684
  }
1687
1685
  if (objectValue instanceof HostFunction || objectValue instanceof HostNamespace) {
1688
- if (typeof key === "string" && isBlockedMember(key)) {
1689
- throw new InterpreterRuntimeError(`${objectValue.name}.${key} is not available.`, propertyNode);
1690
- }
1691
1686
  // Unknown static members read as undefined so feature detection works like native JS.
1692
1687
  return new ComputedValue(objectValue.member(key, propertyNode));
1693
1688
  }
@@ -1771,14 +1766,11 @@ class Frame {
1771
1766
  return new ComputedValue(undefined);
1772
1767
  }
1773
1768
  if (isRuntimeReference(objectValue)) {
1774
- throw new InterpreterRuntimeError("Runtime references are opaque and do not expose properties.", objectNode, "InvalidDataValue");
1769
+ throw new InterpreterRuntimeError(`Cannot read properties of ${describeValue(objectValue)}; only data values expose properties.`, objectNode, "InvalidDataValue");
1775
1770
  }
1776
1771
  if (typeof objectValue !== "object" || objectValue === null) {
1777
1772
  throw new InterpreterRuntimeError("Cannot access a property on a non-object value.", objectNode);
1778
1773
  }
1779
- if (typeof key === "string" && isBlockedMember(key)) {
1780
- throw new InterpreterRuntimeError(`Property '${key}' is not available.`, propertyNode);
1781
- }
1782
1774
  if (Array.isArray(objectValue)) {
1783
1775
  if (operation === "delete")
1784
1776
  return { target: objectValue, key };
@@ -1,5 +1,4 @@
1
1
  import { fromSchemaOpenApi3_0, fromSchemaOpenApi3_1 } from "effect/JsonSchema";
2
- import { isBlockedMember } from "../data.js";
3
2
  export const methods = new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
4
3
  const parameterLocations = ["path", "query", "header"];
5
4
  const ignoredHeaderParameters = new Set(["accept", "content-type", "authorization"]);
@@ -363,8 +362,7 @@ export const operationInput = (document, pathItem, operation) => {
363
362
  ok: true,
364
363
  value: {
365
364
  fields: fields.map((field) => {
366
- const visibleName = isBlockedMember(field.name) ? `${field.name}_2` : field.name;
367
- const base = conflicts.has(field.name) ? `${field.location}_${visibleName}` : visibleName;
365
+ const base = conflicts.has(field.name) ? `${field.location}_${field.name}` : field.name;
368
366
  const next = (index) => {
369
367
  const candidate = index === 1 ? base : `${base}_${index}`;
370
368
  return used.has(candidate) ? next(index + 1) : candidate;
@@ -444,11 +442,10 @@ export const operationOutput = (document, operation, definitions) => {
444
442
  };
445
443
  };
446
444
  const sanitizeOperationSegment = (raw) => {
447
- const base = raw
445
+ return (raw
448
446
  .replaceAll(/[^A-Za-z0-9_$]+/g, "_")
449
447
  .replace(/^_+|_+$/g, "")
450
- .replace(/^([0-9])/, "_$1") || "operation";
451
- return isBlockedMember(base) ? `${base}_2` : base;
448
+ .replace(/^([0-9])/, "_$1") || "operation");
452
449
  };
453
450
  const fallbackOperationId = (method, path) => [
454
451
  method,
@@ -1,8 +1,8 @@
1
1
  import { Effect } from "effect";
2
2
  import { HostFunction, sync, syncCall } from "../interpreter/host.js";
3
3
  import { CodeModeGenerator, InterpreterRuntimeError } from "../interpreter/model.js";
4
+ import { describeValue } from "../interpreter/references.js";
4
5
  import { applyCollectionCallback, preserveConsumerError } from "../interpreter/runner.js";
5
- import { Values } from "../values.js";
6
6
  const constructArray = (args, node) => {
7
7
  if (args.length !== 1)
8
8
  return [...args];
@@ -16,9 +16,6 @@ const constructArray = (args, node) => {
16
16
  return new Array(first);
17
17
  };
18
18
  const arrayLikeSource = (source, node) => {
19
- if (source instanceof Values.Promise) {
20
- throw new InterpreterRuntimeError("Array.from received an un-awaited Promise; await it before creating the array.", node, "InvalidDataValue");
21
- }
22
19
  if (source !== null &&
23
20
  typeof source === "object" &&
24
21
  (Object.getPrototypeOf(source) === Object.prototype || Object.getPrototypeOf(source) === null) &&
@@ -29,7 +26,7 @@ const arrayLikeSource = (source, node) => {
29
26
  throw new RangeError("Invalid array length");
30
27
  return { length: normalized, source };
31
28
  }
32
- throw new InterpreterRuntimeError("Array.from expects an array, string, Map, Set, or array-like value.", node, "InvalidDataValue");
29
+ throw new InterpreterRuntimeError(`Array.from expects an array, string, Map, Set, or array-like value, received ${describeValue(source)}.`, node, "InvalidDataValue");
33
30
  };
34
31
  const arrayFrom = (runner, args, node) => {
35
32
  const source = args[0];
@@ -1,8 +1,7 @@
1
1
  import { Effect } from "effect";
2
- import { isBlockedMember } from "../data.js";
3
2
  import { HostFunction, requiresNew } from "../interpreter/host.js";
4
3
  import { InterpreterRuntimeError, isRecord } from "../interpreter/model.js";
5
- import { isRuntimeReference } from "../interpreter/references.js";
4
+ import { describeValue, isRuntimeReference } from "../interpreter/references.js";
6
5
  import { applyCollectionCallback, preserveConsumerError, toPrimitive } from "../interpreter/runner.js";
7
6
  import { Values } from "../values.js";
8
7
  import { coerceToString } from "./value.js";
@@ -66,7 +65,7 @@ const coerceGroupByPropertyKey = (runner, value, node) => {
66
65
  if (value instanceof Values.Promise)
67
66
  return Effect.succeed("[object Promise]");
68
67
  if (!Values.isValue(value) && isRuntimeReference(value)) {
69
- throw new InterpreterRuntimeError("Object.groupBy callback must return a data value.", node, "InvalidDataValue");
68
+ throw new InterpreterRuntimeError(`Object.groupBy callback must return a data value, received ${describeValue(value)}.`, node, "InvalidDataValue");
70
69
  }
71
70
  return Effect.map(toPrimitive(runner, value, "string", node), coerceToString);
72
71
  };
@@ -109,9 +108,6 @@ export const groupBy = (runner, namespace) => new HostFunction({
109
108
  return result;
110
109
  const item = step.value;
111
110
  const key = yield* preserveConsumerError(cursor, Effect.flatMap(apply([item, index]), (value) => coerceGroupByPropertyKey(runner, value, node)));
112
- if (isBlockedMember(key)) {
113
- return yield* preserveConsumerError(cursor, Effect.fail(new InterpreterRuntimeError(`Property '${key}' is not available.`, node)));
114
- }
115
111
  const group = result[key];
116
112
  if (group === undefined)
117
113
  result[key] = [item];
@@ -1,6 +1,3 @@
1
- import { Effect } from "effect";
2
1
  import { HostNamespace } from "../interpreter/host.js";
3
2
  import { type Runner } from "../interpreter/runner.js";
4
- import { type AstNode } from "../interpreter/model.js";
5
- export declare const invokeJsonMethod: <R>(runner: Runner<R>, name: "parse" | "stringify", args: Array<unknown>, node: AstNode) => Effect.Effect<unknown, unknown, R>;
6
3
  export declare const jsonGlobal: <R>(runner: Runner<R>) => HostNamespace;
@@ -5,9 +5,6 @@ import { InterpreterRuntimeError } from "../interpreter/model.js";
5
5
  import { typeofValue } from "../interpreter/references.js";
6
6
  import { fromData, toData, toProgram } from "../data.js";
7
7
  import { Values } from "../values.js";
8
- export const invokeJsonMethod = (runner, name, args, node) => {
9
- return name === "parse" ? parse(runner, args, node) : stringify(runner, args, node);
10
- };
11
8
  export const jsonGlobal = (runner) => new HostNamespace("JSON", {
12
9
  parse: new HostFunction({ name: "JSON.parse", call: (args, node) => parse(runner, args, node) }),
13
10
  stringify: new HostFunction({ name: "JSON.stringify", call: (args, node) => stringify(runner, args, node) }),
@@ -1,8 +1,8 @@
1
1
  import { Effect } from "effect";
2
- import { isBlockedMember, toProgram } from "../data.js";
2
+ import { toProgram } from "../data.js";
3
3
  import { HostFunction, sync, syncCall } from "../interpreter/host.js";
4
4
  import { AsyncIteratorSymbol, InterpreterRuntimeError, IteratorSymbol } from "../interpreter/model.js";
5
- import { containsOpaqueReference, rejectCircularInsertion, typeofValue } from "../interpreter/references.js";
5
+ import { containsOpaqueReference, describeValue, rejectCircularInsertion, typeofValue, } from "../interpreter/references.js";
6
6
  import { preserveConsumerError } from "../interpreter/runner.js";
7
7
  import { ToolReference } from "../tool-runtime.js";
8
8
  import { Values } from "../values.js";
@@ -13,15 +13,9 @@ const requireObject = (name, input, node) => {
13
13
  return input;
14
14
  if (Values.isValue(input))
15
15
  return {};
16
- if (input instanceof Values.Promise) {
17
- throw new InterpreterRuntimeError(`Object.${name} received an un-awaited Promise; await it before inspecting the result.`, node, "InvalidDataValue");
18
- }
19
- if (input === null || typeof input !== "object") {
20
- throw new InterpreterRuntimeError(`Object.${name} expects a data object or array.`, node, "InvalidDataValue");
21
- }
22
- const prototype = Object.getPrototypeOf(input);
16
+ const prototype = input === null || typeof input !== "object" ? undefined : Object.getPrototypeOf(input);
23
17
  if (prototype !== null && prototype !== Object.prototype) {
24
- throw new InterpreterRuntimeError(`Object.${name} expects a data object or array.`, node, "InvalidDataValue");
18
+ throw new InterpreterRuntimeError(`Object.${name} expects a data object or array, received ${describeValue(input)}.`, node, "InvalidDataValue");
25
19
  }
26
20
  return input;
27
21
  };
@@ -33,8 +27,6 @@ export const objectAssign = (args, node) => {
33
27
  const out = target;
34
28
  const seen = new Set();
35
29
  const guardedSet = (key, item) => {
36
- if (typeof key === "string" && isBlockedMember(key))
37
- throw new InterpreterRuntimeError(`Property '${key}' is not available.`, node);
38
30
  rejectCircularInsertion(out, item, "Object.assign result", node, seen);
39
31
  if (!Reflect.set(out, key, item))
40
32
  throw new InterpreterRuntimeError(`Object.assign could not assign property '${String(key)}'.`, node).as("TypeError");
@@ -82,8 +74,6 @@ const objectFromEntries = (runner, source, node) => {
82
74
  toProgram(entry[0], "Object.fromEntries key");
83
75
  toProgram(entry[1], "Object.fromEntries value");
84
76
  const key = coerceToString(entry[0]);
85
- if (isBlockedMember(key))
86
- throw new InterpreterRuntimeError(`Property '${key}' is not available.`, node);
87
77
  out[key] = entry[1];
88
78
  }));
89
79
  }
@@ -92,7 +82,7 @@ const objectFromEntries = (runner, source, node) => {
92
82
  const constructObject = (args, node) => {
93
83
  const first = args[0];
94
84
  if (first === null || first === undefined)
95
- return {};
85
+ return Object.create(null);
96
86
  if (typeof first === "object")
97
87
  return first;
98
88
  throw new InterpreterRuntimeError(`Object(${typeof first}) wrapper objects are not supported; use the primitive value directly.`, node);
@@ -1,6 +1,5 @@
1
1
  import { sync, syncCall } from "../interpreter/host.js";
2
2
  import { InterpreterRuntimeError } from "../interpreter/model.js";
3
- import { isBlockedMember } from "../data.js";
4
3
  import { Values } from "../values.js";
5
4
  import { coerceToNumber, coerceToString } from "./value.js";
6
5
  export const regexpMethods = new Set(["test", "exec", "toString"]);
@@ -42,8 +41,7 @@ export const matchToValue = (match) => {
42
41
  if (match.groups) {
43
42
  const groups = Object.create(null);
44
43
  for (const [key, group] of Object.entries(match.groups)) {
45
- if (!isBlockedMember(key))
46
- groups[key] = group;
44
+ groups[key] = group;
47
45
  }
48
46
  result.groups = groups;
49
47
  }
@@ -118,8 +116,7 @@ const indicesToValue = (indices) => {
118
116
  if (indices.groups) {
119
117
  const groups = Object.create(null);
120
118
  for (const [key, range] of Object.entries(indices.groups)) {
121
- if (!isBlockedMember(key))
122
- groups[key] = range === undefined ? undefined : [...range];
119
+ groups[key] = range === undefined ? undefined : [...range];
123
120
  }
124
121
  result.groups = groups;
125
122
  return result;
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-beta-19381",
4
+ "version": "0.0.0-beta-19419",
5
5
  "description": "Effect-native confined code execution over schema-described tools",
6
6
  "type": "module",
7
7
  "license": "MIT",