@opencode/codemode 0.0.0-dev-19396 → 0.0.0-dev-19399
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.
|
@@ -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 = "Programs run a JavaScript subset for calling tools: plain and async functions, data literals, destructuring, standard control flow, await/Promise, and common built-ins (Array, Object, Math, JSON, Date, RegExp, Map, Set, URL). Classes, this, getters/setters, tagged templates, BigInt, and custom Symbols are unavailable; 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 = "Programs run a JavaScript subset for calling tools: plain and async functions, data literals, destructuring, standard control flow, await/Promise, and common built-ins (Array, Object, Math, JSON, Date, RegExp, Map, Set, URL). Classes, this, getters/setters, tagged templates, BigInt, and custom Symbols are unavailable; 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) => ({
|
|
@@ -1014,8 +1014,18 @@ class Frame {
|
|
|
1014
1014
|
const callee = yield* self.evaluateExpression(node.callee);
|
|
1015
1015
|
// Globals are built with this interpreter's R; `instanceof` cannot recover the type argument.
|
|
1016
1016
|
const construct = callee instanceof HostFunction ? callee.construct : undefined;
|
|
1017
|
-
if (construct === undefined)
|
|
1018
|
-
|
|
1017
|
+
if (construct === undefined) {
|
|
1018
|
+
// `new` itself is supported, so a non-constructible callee is a TypeError like JS rather than
|
|
1019
|
+
// unsupported syntax. Built-ins like Number are real constructors in JS, so do not claim
|
|
1020
|
+
// otherwise; say `new` is unsupported for them and point at the plain call.
|
|
1021
|
+
const name = calleeDescription(node.callee);
|
|
1022
|
+
const message = callee instanceof CodeModeFunction
|
|
1023
|
+
? `${name} cannot be constructed: user-defined constructors and classes are not supported. Call it as a function that returns a plain object instead.`
|
|
1024
|
+
: callee instanceof HostFunction
|
|
1025
|
+
? `new ${name}(...) is not supported; call ${name}(...) without new instead.`
|
|
1026
|
+
: `${name} is not a constructor.`;
|
|
1027
|
+
throw new InterpreterRuntimeError(message, node).as("TypeError");
|
|
1028
|
+
}
|
|
1019
1029
|
const args = yield* self.evaluateCallArguments(node.arguments);
|
|
1020
1030
|
return yield* construct(args, node);
|
|
1021
1031
|
});
|
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-19399",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|