@opencode/codemode 0.0.0-dev-19631 → 0.0.0-dev-19634

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 (62) hide show
  1. package/dist/codemode.js +1 -1
  2. package/dist/data.d.ts +3 -3
  3. package/dist/data.js +37 -31
  4. package/dist/interpreter/callback.d.ts +20 -0
  5. package/dist/interpreter/{runner.js → callback.js} +10 -10
  6. package/dist/interpreter/errors.d.ts +5 -5
  7. package/dist/interpreter/errors.js +21 -22
  8. package/dist/interpreter/execute.d.ts +2 -2
  9. package/dist/interpreter/execute.js +11 -11
  10. package/dist/interpreter/extensions.d.ts +2 -2
  11. package/dist/interpreter/extensions.js +42 -36
  12. package/dist/interpreter/generators.d.ts +2 -3
  13. package/dist/interpreter/generators.js +8 -8
  14. package/dist/interpreter/globals.d.ts +2 -12
  15. package/dist/interpreter/globals.js +41 -37
  16. package/dist/interpreter/interpreter.d.ts +31 -0
  17. package/dist/interpreter/{runtime.js → interpreter.js} +118 -117
  18. package/dist/interpreter/intrinsics.d.ts +5 -5
  19. package/dist/interpreter/intrinsics.js +16 -10
  20. package/dist/interpreter/model.d.ts +3 -3
  21. package/dist/interpreter/model.js +1 -1
  22. package/dist/interpreter/native.d.ts +9 -9
  23. package/dist/interpreter/native.js +9 -9
  24. package/dist/interpreter/objects.d.ts +51 -46
  25. package/dist/interpreter/objects.js +57 -40
  26. package/dist/interpreter/promises.d.ts +13 -13
  27. package/dist/interpreter/promises.js +70 -70
  28. package/dist/interpreter/references.js +17 -15
  29. package/dist/openapi/types.d.ts +1 -1
  30. package/dist/stdlib/array.d.ts +3 -3
  31. package/dist/stdlib/array.js +31 -31
  32. package/dist/stdlib/bytes.d.ts +10 -0
  33. package/dist/stdlib/bytes.js +228 -0
  34. package/dist/stdlib/collections.d.ts +4 -4
  35. package/dist/stdlib/collections.js +55 -55
  36. package/dist/stdlib/console.d.ts +3 -3
  37. package/dist/stdlib/console.js +24 -22
  38. package/dist/stdlib/date.d.ts +2 -2
  39. package/dist/stdlib/date.js +19 -19
  40. package/dist/stdlib/json.d.ts +3 -3
  41. package/dist/stdlib/json.js +24 -24
  42. package/dist/stdlib/math.d.ts +3 -3
  43. package/dist/stdlib/math.js +7 -7
  44. package/dist/stdlib/number.d.ts +3 -3
  45. package/dist/stdlib/number.js +11 -11
  46. package/dist/stdlib/object.d.ts +5 -5
  47. package/dist/stdlib/object.js +41 -39
  48. package/dist/stdlib/regexp.d.ts +6 -6
  49. package/dist/stdlib/regexp.js +24 -24
  50. package/dist/stdlib/string.d.ts +2 -2
  51. package/dist/stdlib/string.js +24 -24
  52. package/dist/stdlib/url.d.ts +6 -6
  53. package/dist/stdlib/url.js +39 -39
  54. package/dist/stdlib/value.d.ts +3 -3
  55. package/dist/stdlib/value.js +18 -14
  56. package/dist/stdlib/web.d.ts +4 -4
  57. package/dist/stdlib/web.js +19 -5
  58. package/dist/tool-runtime.d.ts +2 -2
  59. package/dist/tool-runtime.js +2 -2
  60. package/package.json +1 -1
  61. package/dist/interpreter/runner.d.ts +0 -27
  62. package/dist/interpreter/runtime.d.ts +0 -19
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import type { Prototypes } from "./interpreter/intrinsics.js";
2
+ import type { Builtins } from "./interpreter/intrinsics.js";
3
3
  import { type Namespace } from "./namespace.js";
4
4
  import { type Tool } from "./tool.js";
5
5
  import type { Tools } from "./tools.js";
@@ -66,5 +66,5 @@ export type ToolRuntime<R = never> = {
66
66
  readonly keys: (path: ReadonlyArray<string>) => ReadonlyArray<string>;
67
67
  };
68
68
  /** Per-execution call state over tools prepared once for the runtime. */
69
- export declare const make: <R>(prepared: Prepared<R>, prototypes: Prototypes, maxToolCalls: number | undefined, hooks?: ToolCallHooks<R>) => ToolRuntime<R>;
69
+ export declare const make: <R>(prepared: Prepared<R>, builtins: Builtins, maxToolCalls: number | undefined, hooks?: ToolCallHooks<R>) => ToolRuntime<R>;
70
70
  export * as ToolRuntime from "./tool-runtime.js";
@@ -184,7 +184,7 @@ const resolve = (root, path) => {
184
184
  return node.tool;
185
185
  };
186
186
  /** Per-execution call state over tools prepared once for the runtime. */
187
- export const make = (prepared, prototypes, maxToolCalls, hooks) => {
187
+ export const make = (prepared, builtins, maxToolCalls, hooks) => {
188
188
  const calls = [];
189
189
  const root = prepared.root;
190
190
  const searchTool = makeSearchTool(prepared.searchIndex);
@@ -234,7 +234,7 @@ export const make = (prepared, prototypes, maxToolCalls, hooks) => {
234
234
  .join("\n")));
235
235
  }));
236
236
  return yield* Effect.try({
237
- try: () => fromData(prototypes, decodeToolOutput(tool, raw), `Result from tool '${name}'`),
237
+ try: () => fromData(builtins, decodeToolOutput(tool, raw), `Result from tool '${name}'`),
238
238
  catch: (cause) => new ToolRuntimeError("InvalidToolOutput", `Invalid output from tool '${name}': ${cause}`),
239
239
  });
240
240
  }), call);
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-19631",
4
+ "version": "0.0.0-dev-19634",
5
5
  "description": "Effect-native confined code execution over schema-described tools",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -1,27 +0,0 @@
1
- import { Effect } from "effect";
2
- import type { Prototypes } from "./intrinsics.js";
3
- import { Callable, ProgramPromise } from "./objects.js";
4
- export type IteratorCursor<R> = {
5
- readonly next: Effect.Effect<{
6
- readonly done: boolean;
7
- readonly value: unknown;
8
- }, unknown, R>;
9
- readonly close: Effect.Effect<void, unknown, R>;
10
- };
11
- /** Everything a native function needs from the realm: calling back into the program and its intrinsic objects. */
12
- export type Runner<R> = {
13
- readonly invokeCallable: (callable: unknown, thisValue: unknown, args: Array<unknown>) => Effect.Effect<unknown, unknown, R>;
14
- readonly settlePromise: (promise: ProgramPromise) => Effect.Effect<unknown, unknown, never>;
15
- readonly syncIterator: (value: unknown) => Effect.Effect<IteratorCursor<R> | undefined, unknown, R>;
16
- readonly prototypes: Prototypes;
17
- };
18
- export declare const preserveConsumerError: <A, R>(cursor: IteratorCursor<R>, effect: Effect.Effect<A, unknown, R>) => Effect.Effect<A, unknown, R>;
19
- /**
20
- * ToPrimitive: calls `valueOf`/`toString` in hint order and returns the first primitive result. Dates treat the
21
- * default hint as "string", like their `Symbol.toPrimitive`.
22
- */
23
- export declare const toPrimitive: <R>(runner: Runner<R>, value: unknown, hint: "number" | "string" | "default") => Effect.Effect<unknown, unknown, R>;
24
- export declare const toPrimitiveString: <R>(runner: Runner<R>, value: unknown) => Effect.Effect<string, unknown, R>;
25
- export declare const toPrimitiveNumber: <R>(runner: Runner<R>, value: unknown) => Effect.Effect<number, unknown, R>;
26
- export declare const isSupportedCallback: (value: unknown) => value is Callable;
27
- export declare const applyCollectionCallback: <R>(runner: Runner<R>, callback: unknown, name: string) => ((args: Array<unknown>) => Effect.Effect<unknown, unknown, R>);
@@ -1,19 +0,0 @@
1
- import type { Program } from "acorn";
2
- import { Effect } from "effect";
3
- import type { Prototypes } from "./intrinsics.js";
4
- import { type Host } from "./globals.js";
5
- import { type Runner } from "./runner.js";
6
- import { PromiseRuntime } from "./promises.js";
7
- /** One program execution: the tool bridge, promise scheduler, captured logs, and the global scope built once. */
8
- export declare class Runtime<R> {
9
- readonly executeTool: (path: ReadonlyArray<string>, args: Array<unknown>) => Effect.Effect<unknown, unknown, R>;
10
- readonly search: (args: Array<unknown>) => Effect.Effect<unknown, unknown, R>;
11
- readonly toolKeys: (path: ReadonlyArray<string>) => ReadonlyArray<string>;
12
- readonly promises: PromiseRuntime<R>;
13
- readonly prototypes: Prototypes;
14
- readonly logs: Array<string>;
15
- readonly runner: Runner<R>;
16
- private readonly root;
17
- constructor(executeTool: (path: ReadonlyArray<string>, args: Array<unknown>) => Effect.Effect<unknown, unknown, R>, search: (args: Array<unknown>) => Effect.Effect<unknown, unknown, R>, toolKeys: (path: ReadonlyArray<string>) => ReadonlyArray<string>, promises: PromiseRuntime<R>, prototypes: Prototypes, logs?: Array<string>, extraGlobals?: (host: Host<R>) => ReadonlyArray<readonly [string, unknown]>);
18
- run(program: Program): Effect.Effect<unknown, unknown, R>;
19
- }