@opencode/codemode 0.0.0-dev-19406 → 0.0.0-dev-19411
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 +0 -1
- package/dist/data.js +7 -10
- package/dist/interpreter/methods.js +2 -3
- package/dist/interpreter/runtime.js +4 -22
- package/dist/openapi/spec.js +3 -6
- package/dist/stdlib/collections.js +0 -4
- package/dist/stdlib/json.d.ts +0 -3
- package/dist/stdlib/json.js +0 -3
- package/dist/stdlib/object.js +2 -6
- package/dist/stdlib/regexp.js +2 -5
- package/package.json +1 -1
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
|
-
|
|
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
|
|
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 {
|
|
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
|
-
|
|
245
|
-
safeGroups[key] = group;
|
|
244
|
+
safeGroups[key] = group;
|
|
246
245
|
}
|
|
247
246
|
callbackArgs[callbackArgs.length - 1] = safeGroups;
|
|
248
247
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cause, Deferred, Effect, Exit } from "effect";
|
|
2
|
-
import {
|
|
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";
|
|
@@ -811,7 +811,7 @@ class Frame {
|
|
|
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)
|
|
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
|
}
|
|
@@ -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)
|
|
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
|
}
|
|
@@ -1577,11 +1571,8 @@ class Frame {
|
|
|
1577
1571
|
if (typeof spread !== "object" || Array.isArray(spread) || isRuntimeReference(spread)) {
|
|
1578
1572
|
throw new InterpreterRuntimeError(`Object spread requires a data object, received ${describeValue(spread)}.`, property, "InvalidDataValue");
|
|
1579
1573
|
}
|
|
1580
|
-
for (const [key, value] of Object.entries(spread))
|
|
1581
|
-
if (isBlockedMember(key))
|
|
1582
|
-
throw new InterpreterRuntimeError(`Property '${key}' is not available.`, property);
|
|
1574
|
+
for (const [key, value] of Object.entries(spread))
|
|
1583
1575
|
objectValue[key] = value;
|
|
1584
|
-
}
|
|
1585
1576
|
copyIteratorSymbols(spread, objectValue);
|
|
1586
1577
|
continue;
|
|
1587
1578
|
}
|
|
@@ -1602,9 +1593,6 @@ class Frame {
|
|
|
1602
1593
|
else {
|
|
1603
1594
|
throw new InterpreterRuntimeError("Unsupported object property key shape.", keyNode);
|
|
1604
1595
|
}
|
|
1605
|
-
if (isBlockedMember(String(key))) {
|
|
1606
|
-
throw new InterpreterRuntimeError(`Property '${String(key)}' is not available.`, keyNode);
|
|
1607
|
-
}
|
|
1608
1596
|
Reflect.set(objectValue, key, yield* self.evaluateExpression(property.value));
|
|
1609
1597
|
}
|
|
1610
1598
|
return objectValue;
|
|
@@ -1695,9 +1683,6 @@ class Frame {
|
|
|
1695
1683
|
return new ToolReference([...objectValue.path, key]);
|
|
1696
1684
|
}
|
|
1697
1685
|
if (objectValue instanceof HostFunction || objectValue instanceof HostNamespace) {
|
|
1698
|
-
if (typeof key === "string" && isBlockedMember(key)) {
|
|
1699
|
-
throw new InterpreterRuntimeError(`${objectValue.name}.${key} is not available.`, propertyNode);
|
|
1700
|
-
}
|
|
1701
1686
|
// Unknown static members read as undefined so feature detection works like native JS.
|
|
1702
1687
|
return new ComputedValue(objectValue.member(key, propertyNode));
|
|
1703
1688
|
}
|
|
@@ -1786,9 +1771,6 @@ class Frame {
|
|
|
1786
1771
|
if (typeof objectValue !== "object" || objectValue === null) {
|
|
1787
1772
|
throw new InterpreterRuntimeError("Cannot access a property on a non-object value.", objectNode);
|
|
1788
1773
|
}
|
|
1789
|
-
if (typeof key === "string" && isBlockedMember(key)) {
|
|
1790
|
-
throw new InterpreterRuntimeError(`Property '${key}' is not available.`, propertyNode);
|
|
1791
|
-
}
|
|
1792
1774
|
if (Array.isArray(objectValue)) {
|
|
1793
1775
|
if (operation === "delete")
|
|
1794
1776
|
return { target: objectValue, key };
|
package/dist/openapi/spec.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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,5 +1,4 @@
|
|
|
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
4
|
import { describeValue, isRuntimeReference } from "../interpreter/references.js";
|
|
@@ -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];
|
package/dist/stdlib/json.d.ts
CHANGED
|
@@ -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;
|
package/dist/stdlib/json.js
CHANGED
|
@@ -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) }),
|
package/dist/stdlib/object.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
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
5
|
import { containsOpaqueReference, describeValue, rejectCircularInsertion, typeofValue, } from "../interpreter/references.js";
|
|
@@ -27,8 +27,6 @@ export const objectAssign = (args, node) => {
|
|
|
27
27
|
const out = target;
|
|
28
28
|
const seen = new Set();
|
|
29
29
|
const guardedSet = (key, item) => {
|
|
30
|
-
if (typeof key === "string" && isBlockedMember(key))
|
|
31
|
-
throw new InterpreterRuntimeError(`Property '${key}' is not available.`, node);
|
|
32
30
|
rejectCircularInsertion(out, item, "Object.assign result", node, seen);
|
|
33
31
|
if (!Reflect.set(out, key, item))
|
|
34
32
|
throw new InterpreterRuntimeError(`Object.assign could not assign property '${String(key)}'.`, node).as("TypeError");
|
|
@@ -76,8 +74,6 @@ const objectFromEntries = (runner, source, node) => {
|
|
|
76
74
|
toProgram(entry[0], "Object.fromEntries key");
|
|
77
75
|
toProgram(entry[1], "Object.fromEntries value");
|
|
78
76
|
const key = coerceToString(entry[0]);
|
|
79
|
-
if (isBlockedMember(key))
|
|
80
|
-
throw new InterpreterRuntimeError(`Property '${key}' is not available.`, node);
|
|
81
77
|
out[key] = entry[1];
|
|
82
78
|
}));
|
|
83
79
|
}
|
|
@@ -86,7 +82,7 @@ const objectFromEntries = (runner, source, node) => {
|
|
|
86
82
|
const constructObject = (args, node) => {
|
|
87
83
|
const first = args[0];
|
|
88
84
|
if (first === null || first === undefined)
|
|
89
|
-
return
|
|
85
|
+
return Object.create(null);
|
|
90
86
|
if (typeof first === "object")
|
|
91
87
|
return first;
|
|
92
88
|
throw new InterpreterRuntimeError(`Object(${typeof first}) wrapper objects are not supported; use the primitive value directly.`, node);
|
package/dist/stdlib/regexp.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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-dev-
|
|
4
|
+
"version": "0.0.0-dev-19411",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|