@opencode/codemode 0.0.0-dev-1180 → 0.0.0-dev-1189

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.
Files changed (91) hide show
  1. package/README.md +6 -12
  2. package/dist/codemode.d.ts +7 -21
  3. package/dist/codemode.js +17 -38
  4. package/dist/extension.d.ts +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/scan.js +2 -2
  7. package/dist/tool-runtime.d.ts +8 -11
  8. package/dist/tool-runtime.js +13 -11
  9. package/dist/tool.d.ts +18 -9
  10. package/dist/tool.js +15 -23
  11. package/dist/vm/data.d.ts +1 -1
  12. package/dist/vm/runtime/execute.d.ts +16 -6
  13. package/dist/vm/runtime/execute.js +10 -7
  14. package/dist/vm/snapshot/codec.d.ts +3 -2
  15. package/dist/vm/snapshot/codec.js +3 -2
  16. package/dist/vm/snapshot/snapshot.d.ts +6 -3
  17. package/dist/vm/snapshot/snapshot.js +13 -2
  18. package/dist/vm/vm.d.ts +2 -2
  19. package/package.json +3 -5
  20. package/dist/data.d.ts +0 -21
  21. package/dist/data.js +0 -93
  22. package/dist/interpreter/callback.d.ts +0 -35
  23. package/dist/interpreter/callback.js +0 -98
  24. package/dist/interpreter/errors.d.ts +0 -23
  25. package/dist/interpreter/errors.js +0 -173
  26. package/dist/interpreter/execute.d.ts +0 -14
  27. package/dist/interpreter/execute.js +0 -207
  28. package/dist/interpreter/extensions.d.ts +0 -9
  29. package/dist/interpreter/extensions.js +0 -248
  30. package/dist/interpreter/generators.d.ts +0 -3
  31. package/dist/interpreter/generators.js +0 -168
  32. package/dist/interpreter/globals.d.ts +0 -6
  33. package/dist/interpreter/globals.js +0 -144
  34. package/dist/interpreter/interpreter.d.ts +0 -48
  35. package/dist/interpreter/interpreter.js +0 -2253
  36. package/dist/interpreter/intrinsics.d.ts +0 -15
  37. package/dist/interpreter/intrinsics.js +0 -105
  38. package/dist/interpreter/limits.d.ts +0 -10
  39. package/dist/interpreter/limits.js +0 -19
  40. package/dist/interpreter/model.d.ts +0 -68
  41. package/dist/interpreter/model.js +0 -54
  42. package/dist/interpreter/modules.d.ts +0 -4
  43. package/dist/interpreter/modules.js +0 -33
  44. package/dist/interpreter/native.d.ts +0 -17
  45. package/dist/interpreter/native.js +0 -35
  46. package/dist/interpreter/objects.d.ts +0 -301
  47. package/dist/interpreter/objects.js +0 -592
  48. package/dist/interpreter/promises.d.ts +0 -18
  49. package/dist/interpreter/promises.js +0 -292
  50. package/dist/interpreter/references.d.ts +0 -8
  51. package/dist/interpreter/references.js +0 -51
  52. package/dist/interpreter/runner.d.ts +0 -178
  53. package/dist/interpreter/runner.js +0 -480
  54. package/dist/interpreter/scope.d.ts +0 -16
  55. package/dist/interpreter/scope.js +0 -79
  56. package/dist/stdlib/array.d.ts +0 -11
  57. package/dist/stdlib/array.js +0 -498
  58. package/dist/stdlib/bytes.d.ts +0 -10
  59. package/dist/stdlib/bytes.js +0 -253
  60. package/dist/stdlib/collections.d.ts +0 -7
  61. package/dist/stdlib/collections.js +0 -497
  62. package/dist/stdlib/console.d.ts +0 -6
  63. package/dist/stdlib/console.js +0 -93
  64. package/dist/stdlib/date.d.ts +0 -2
  65. package/dist/stdlib/date.js +0 -132
  66. package/dist/stdlib/headers.d.ts +0 -2
  67. package/dist/stdlib/headers.js +0 -110
  68. package/dist/stdlib/iterator.d.ts +0 -2
  69. package/dist/stdlib/iterator.js +0 -322
  70. package/dist/stdlib/json.d.ts +0 -3
  71. package/dist/stdlib/json.js +0 -58
  72. package/dist/stdlib/math.d.ts +0 -8
  73. package/dist/stdlib/math.js +0 -97
  74. package/dist/stdlib/number.d.ts +0 -3
  75. package/dist/stdlib/number.js +0 -72
  76. package/dist/stdlib/object.d.ts +0 -6
  77. package/dist/stdlib/object.js +0 -219
  78. package/dist/stdlib/regexp.d.ts +0 -7
  79. package/dist/stdlib/regexp.js +0 -114
  80. package/dist/stdlib/string.d.ts +0 -2
  81. package/dist/stdlib/string.js +0 -272
  82. package/dist/stdlib/url.d.ts +0 -13
  83. package/dist/stdlib/url.js +0 -255
  84. package/dist/stdlib/value.d.ts +0 -7
  85. package/dist/stdlib/value.js +0 -33
  86. package/dist/stdlib/web.d.ts +0 -5
  87. package/dist/stdlib/web.js +0 -97
  88. package/dist/suspend-error.d.ts +0 -24
  89. package/dist/suspend-error.js +0 -25
  90. package/dist/vm/index.d.ts +0 -6
  91. package/dist/vm/index.js +0 -6
@@ -1,301 +0,0 @@
1
- import type { BlockStatement, Expression, Pattern } from "acorn";
2
- import { ToolReference } from "../tool-runtime.js";
3
- import type { Builtins } from "./intrinsics.js";
4
- import { type AstNode, type Binding } from "./model.js";
5
- import type { Entry, Eval, GeneratorRequest, Reaction, Resolving } from "./runner.js";
6
- /** Property attributes, as in a JS property descriptor. */
7
- export type Attributes = {
8
- readonly writable: boolean;
9
- readonly enumerable: boolean;
10
- readonly configurable: boolean;
11
- };
12
- export type Getter = (receiver: Value) => Value;
13
- export type Setter = (receiver: Value, value: Value) => void;
14
- /** One own property: a data slot or a native accessor pair. */
15
- export type Slot = {
16
- value: Value;
17
- writable: boolean;
18
- enumerable: boolean;
19
- configurable: boolean;
20
- } | {
21
- get: Getter | undefined;
22
- set: Setter | undefined;
23
- enumerable: boolean;
24
- configurable: boolean;
25
- };
26
- /** Ordinary assignment: writable, enumerable, configurable. */
27
- export declare const data: Attributes;
28
- /** Built-in methods and `constructor`: writable and configurable but hidden from enumeration. */
29
- export declare const hidden: Attributes;
30
- /** Function `name` and `length`: read-only but deletable. */
31
- export declare const readonly: Attributes;
32
- /** Constants such as `Math.PI` and a constructor's `prototype`. */
33
- export declare const frozen: Attributes;
34
- /**
35
- * An object owned by the program: own properties plus a prototype link. Subclasses answer, in one place, how a
36
- * built-in kind of object prints, coerces, iterates, and crosses to the host.
37
- */
38
- export declare class Obj {
39
- proto: Obj | null;
40
- readonly props: Map<string | symbol, Slot>;
41
- /** [[Extensible]]: cleared by `Object.preventExtensions`, `seal`, and `freeze`. */
42
- extensible: boolean;
43
- constructor(proto: Obj | null);
44
- /** The class name `Object.prototype.toString` reports: `[object Map]`. */
45
- readonly tag: string;
46
- /** How diagnostics refer to a value of this kind. */
47
- get describe(): string;
48
- /** ToString without consulting program-defined methods. */
49
- toString(): string;
50
- /** ToPrimitive without consulting program-defined methods: only a Date answers a number hint differently. */
51
- toPrimitive(hint: "default" | "number" | "string"): string | number;
52
- /** ToNumber without consulting program-defined methods. */
53
- toNumber(): number;
54
- /** How `console.log` shows the value; `item` formats a child with cycle and depth tracking. */
55
- inspect(item: (value: Value) => string): string;
56
- /** A copy the host can hold; `item` converts a child. A `__proto__` key never reaches host code. */
57
- toHost(item: (value: Value) => unknown): unknown;
58
- /** The built-in iteration `for...of` and spread use, when this kind of object has one. */
59
- iterator(builtins: Builtins): Iterator<Value, undefined> | undefined;
60
- }
61
- export declare class Arr extends Obj {
62
- readonly items: Array<Value>;
63
- readonly tag = "Array";
64
- /** The attributes every live element shares; `seal` and `freeze` narrow them since elements have no slots. */
65
- elements: Attributes;
66
- constructor(proto: Obj, items?: Array<Value>);
67
- get describe(): string;
68
- toString(): string;
69
- inspect(item: (value: Value) => string): string;
70
- toHost(item: (value: Value) => unknown): unknown[];
71
- iterator(): ArrayIterator<Value>;
72
- }
73
- /** An object with the [[ErrorData]] slot: what `Error.prototype.toString` and the host boundary recognize as an error. */
74
- export declare class ErrorObj extends Obj {
75
- readonly tag = "Error";
76
- /** The failure this error materialized from, so rethrowing it keeps the diagnostic kind and location. */
77
- host?: unknown;
78
- /** Error.prototype.toString: "name: message", or just one when the other is empty. */
79
- toString(): string;
80
- inspect(): string;
81
- }
82
- /** Interpreter machinery a program can hold but never inspect, serialize, or hand to the host. */
83
- export declare abstract class Opaque extends Obj {
84
- inspect(): string;
85
- }
86
- export declare abstract class Callable extends Opaque {
87
- readonly length: number;
88
- readonly tag = "Function";
89
- constructor(proto: Obj, name: string, length: number);
90
- get describe(): string;
91
- }
92
- export declare class Fn extends Callable {
93
- readonly parameters: ReadonlyArray<Pattern>;
94
- readonly body: BlockStatement | Expression;
95
- readonly capturedScopes: Array<Map<string, Binding>>;
96
- readonly async: boolean;
97
- readonly generator: boolean;
98
- /** Arrows have no `this` or `arguments` of their own; they read the enclosing function's. */
99
- readonly arrow: boolean;
100
- constructor(proto: Obj, name: string, parameters: ReadonlyArray<Pattern>, body: BlockStatement | Expression, capturedScopes: Array<Map<string, Binding>>, async: boolean, generator: boolean,
101
- /** Arrows have no `this` or `arguments` of their own; they read the enclosing function's. */
102
- arrow: boolean);
103
- }
104
- /** The strict `arguments` object: an ordinary object with indexed own properties and a hidden `length`. */
105
- export declare class Arguments extends Obj {
106
- readonly tag = "Arguments";
107
- constructor(proto: Obj, args: Array<Value>);
108
- iterator(): ArrayIterator<Value>;
109
- }
110
- /** A native function body: a value, or interpreter work for bodies that call program code or the host. */
111
- export type NativeResult = Value | Eval<Value>;
112
- /** `site` is the call running the built-in, where a failure it reports later (a rejection) is located. */
113
- export type NativeCall = (thisValue: Value, args: Array<Value>, site: AstNode | undefined) => NativeResult;
114
- export type NativeConstruct = (args: Array<Value>, newTarget: Callable, site: AstNode | undefined) => NativeResult;
115
- export type NativeOptions = {
116
- readonly name: string;
117
- readonly length?: number;
118
- readonly call: NativeCall;
119
- /** `new name(...)`; without it the function is not a constructor. */
120
- readonly construct?: NativeConstruct;
121
- /** Whether callback sites (array methods, replacers, promise reactions) admit this function. Defaults to true. */
122
- readonly callback?: boolean;
123
- };
124
- export declare class Native extends Callable {
125
- readonly call: NativeCall;
126
- readonly construct: NativeConstruct | undefined;
127
- readonly callback: boolean;
128
- constructor(proto: Obj, options: NativeOptions);
129
- }
130
- export declare class PromiseObj extends Opaque {
131
- /** Creation order, for reporting unhandled rejections in the order their promises were made. */
132
- readonly id: number;
133
- readonly tag = "Promise";
134
- state: "pending" | "fulfilled" | "rejected";
135
- /** The value, or the failure as thrown; a handler receives it materialized. */
136
- result: unknown;
137
- reactions: Array<Reaction>;
138
- /** [[PromiseIsHandled]]: a reaction was attached, so a rejection is not reported as unhandled. */
139
- handled: boolean;
140
- constructor(proto: Obj,
141
- /** Creation order, for reporting unhandled rejections in the order their promises were made. */
142
- id: number);
143
- get describe(): string;
144
- inspect(): string;
145
- }
146
- export type GeneratorState = "suspendedStart" | "suspendedYield" | "executing" | "awaiting-return" | "draining" | "completed";
147
- export declare class GeneratorObj extends Opaque {
148
- readonly asynchronous: boolean;
149
- /** The body, started by the first `next()`. */
150
- readonly body: Eval<Value>;
151
- readonly tag = "Generator";
152
- state: GeneratorState;
153
- /** The suspended body's activations, kept while it waits for the next request. */
154
- entries: Array<Entry> | undefined;
155
- /** An async generator's requests, oldest first, each with the functions that settle its promise. */
156
- readonly queue: Array<{
157
- readonly request: GeneratorRequest;
158
- readonly resolving: Resolving;
159
- }>;
160
- constructor(proto: Obj, asynchronous: boolean,
161
- /** The body, started by the first `next()`. */
162
- body: Eval<Value>);
163
- get describe(): string;
164
- }
165
- /** One pull from an iterator, as `for...of` sees it. */
166
- export type Step = {
167
- readonly done: boolean;
168
- readonly value: Value;
169
- };
170
- /** How the interpreter drives any iterator: pull the next step, or close it early. */
171
- export type Cursor = {
172
- readonly next: () => Eval<Step>;
173
- readonly close: () => Eval<void>;
174
- };
175
- /** A cursor over a host iterator; there is nothing to close. */
176
- export declare const hostCursor: (iterator: Iterator<Value, undefined>) => Cursor;
177
- /** A built-in iterator: a live cursor over a host collection or an iterator helper, yielding program values. */
178
- export declare class IteratorObj extends Opaque {
179
- readonly cursor: Cursor;
180
- readonly tag = "Iterator";
181
- constructor(proto: Obj, cursor: Cursor);
182
- get describe(): string;
183
- }
184
- /** A built-in iterator over a host iterator, e.g. `array.values()`. */
185
- export declare const hostIterator: (builtins: Builtins, iterator: Iterator<Value, undefined>) => IteratorObj;
186
- /** A built-in object around a host value: data-like, so it prints as itself and crosses to extensions as a copy. */
187
- export declare abstract class Wrapper extends Obj {
188
- inspect(item: (value: Value) => string): string;
189
- }
190
- export declare class DateObj extends Wrapper {
191
- time: number;
192
- readonly tag = "Date";
193
- constructor(proto: Obj, time: number);
194
- toString(): string;
195
- toPrimitive(hint: "default" | "number" | "string"): string | number;
196
- toHost(): Date;
197
- }
198
- export declare class RegExpObj extends Wrapper {
199
- readonly tag = "RegExp";
200
- readonly regex: RegExp;
201
- constructor(proto: Obj, pattern: string, flags: string);
202
- toString(): string;
203
- toHost(): RegExp;
204
- }
205
- export declare class MapObj extends Wrapper {
206
- readonly tag = "Map";
207
- readonly map: Map<Value, Value>;
208
- inspect(item: (value: Value) => string): string;
209
- toHost(item: (value: Value) => unknown): Map<unknown, unknown>;
210
- iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
211
- }
212
- export declare class SetObj extends Wrapper {
213
- readonly tag = "Set";
214
- readonly set: Set<Value>;
215
- inspect(item: (value: Value) => string): string;
216
- toHost(item: (value: Value) => unknown): Set<unknown>;
217
- iterator(): SetIterator<Value>;
218
- }
219
- /** Keys are program objects, so a host WeakMap gives the same lifetime rule as JavaScript without any bookkeeping. */
220
- export declare class WeakMapObj extends Wrapper {
221
- readonly tag = "WeakMap";
222
- readonly map: WeakMap<Obj, Value>;
223
- inspect(): string;
224
- }
225
- export declare class WeakSetObj extends Wrapper {
226
- readonly tag = "WeakSet";
227
- readonly set: WeakSet<Obj>;
228
- inspect(): string;
229
- }
230
- export declare class URLSearchParamsObj extends Wrapper {
231
- readonly params: URLSearchParams;
232
- readonly tag = "URLSearchParams";
233
- constructor(proto: Obj, params: URLSearchParams);
234
- toString(): string;
235
- toHost(): URLSearchParams;
236
- iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
237
- }
238
- export declare class HeadersObj extends Wrapper {
239
- readonly headers: Headers;
240
- readonly tag = "Headers";
241
- constructor(proto: Obj, headers: Headers);
242
- inspect(): string;
243
- toHost(): Headers;
244
- iterator(builtins: Builtins): IteratorObject<Arr, undefined, unknown>;
245
- }
246
- export declare class URLObj extends Wrapper {
247
- readonly url: URL;
248
- readonly tag = "URL";
249
- readonly searchParams: URLSearchParamsObj;
250
- constructor(proto: Obj, searchParamsProto: Obj, url: URL);
251
- toString(): string;
252
- toHost(): URL;
253
- }
254
- /** A `Uint8Array`: the host array does the byte clamping and ignores out-of-range writes, as JS does. */
255
- export declare class Bytes extends Wrapper {
256
- readonly bytes: Uint8Array;
257
- readonly tag = "Uint8Array";
258
- constructor(proto: Obj, bytes: Uint8Array);
259
- toString(): string;
260
- inspect(): string;
261
- toHost(): Uint8Array<ArrayBuffer>;
262
- iterator(): ArrayIterator<number>;
263
- }
264
- /** Every value a program can hold. Host values never appear here; they are copied in at the boundaries. */
265
- export type Value = string | number | boolean | null | undefined | symbol | Obj | ToolReference;
266
- /** ToString without consulting program-defined methods. */
267
- export declare const coerceToString: (value: Value) => string;
268
- /** ToNumber without consulting program-defined methods; tool references are not numbers. */
269
- export declare const coerceToNumber: (value: Value) => number;
270
- /** ToIntegerOrInfinity: NaN is 0, fractions truncate. */
271
- export declare const coerceToInteger: (value: Value) => number;
272
- /** Values that cannot cross the data boundary: opaque machinery and host-backed wrappers. */
273
- export declare const isRuntimeReference: (value: Value) => boolean;
274
- export declare const parseArrayIndex: (key: string | number) => number | undefined;
275
- /** The own property under `key`, including an array's live indexes and `length`. */
276
- export declare const own: (target: Obj, key: PropertyKey) => Slot | undefined;
277
- export declare const hasOwn: (target: Obj, key: PropertyKey) => boolean;
278
- export declare const getOwn: (target: Obj, key: PropertyKey) => Value;
279
- /** [[Get]]: walks the prototype chain; accessors see `receiver`, which is the primitive for wrapper prototypes. */
280
- export declare const get: (target: Obj, key: PropertyKey, receiver?: Value) => Value;
281
- export declare const has: (target: Obj, key: PropertyKey) => boolean;
282
- export declare const hasPrototype: (value: Value, proto: Obj) => boolean;
283
- /** [[Set]]: an inherited setter or read-only property decides before an own data property is created. */
284
- export declare const set: (target: Obj, key: PropertyKey, value: Value) => boolean;
285
- /** Creating a property on a non-extensible object is the one [[Set]] failure with its own message. */
286
- export declare const rejectAddition: (target: Obj, key: string | symbol | number) => void;
287
- /** [[DefineOwnProperty]] for a data property, ignoring the chain. */
288
- export declare const define: (target: Obj, key: PropertyKey, value: Value, attrs?: Attributes) => void;
289
- export declare const defineAccessor: (target: Obj, key: PropertyKey, get: Getter | undefined, set?: Setter) => void;
290
- export declare const remove: (target: Obj, key: PropertyKey) => boolean;
291
- export declare const ownKeys: (target: Obj) => Array<string | symbol>;
292
- /** Own enumerable keys, including the iterator symbols; what spread and `Object.assign` copy. */
293
- export declare const enumerableKeys: (target: Obj) => Array<string | symbol>;
294
- /** Own enumerable string keys: `Object.keys`. */
295
- export declare const keys: (target: Obj) => Array<string>;
296
- /** Own enumerable string entries: `Object.entries` and serialization. */
297
- export declare const entries: (target: Obj) => Array<[string, Value]>;
298
- /** An iterator result `{ value, done }`, built directly since every iteration step makes one. */
299
- export declare const iteratorResult: (proto: Obj, value: Value, done: boolean) => Obj;
300
- export declare const record: (proto: Obj, fields: Record<string, Value>) => Obj;
301
- export declare const assign: (target: Obj, source: Obj, skip?: ReadonlySet<PropertyKey>) => void;