poe-code 14.0.5 → 14.0.6

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 (36) hide show
  1. package/dist/index.js +1176 -242
  2. package/dist/index.js.map +4 -4
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-B7H4ZL65.js → chunk-2M6MNQBY.js} +1937 -1008
  6. package/packages/safe-js/dist/chunks/chunk-2M6MNQBY.js.map +7 -0
  7. package/packages/safe-js/dist/chunks/{chunk-7B7BKWVF.js → chunk-QSSQJNKE.js} +2 -2
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.d.ts +3 -0
  10. package/packages/safe-js/dist/core.js +5 -1
  11. package/packages/safe-js/dist/extensions.d.ts +42 -0
  12. package/packages/safe-js/dist/extensions.js +83 -0
  13. package/packages/safe-js/dist/index.d.ts +4 -1
  14. package/packages/safe-js/dist/index.js +6 -2
  15. package/packages/safe-js/dist/index.js.map +2 -2
  16. package/packages/safe-js/dist/interp/async.d.ts +1 -0
  17. package/packages/safe-js/dist/interp/globals/object-array.js +5 -0
  18. package/packages/safe-js/dist/interp/globals.d.ts +31 -0
  19. package/packages/safe-js/dist/interp/globals.js +22 -0
  20. package/packages/safe-js/dist/interp/host-bridge.d.ts +14 -1
  21. package/packages/safe-js/dist/interp/host-bridge.js +19 -4
  22. package/packages/safe-js/dist/interp/host-capabilities.d.ts +43 -0
  23. package/packages/safe-js/dist/interp/host-capabilities.js +123 -0
  24. package/packages/safe-js/dist/interp/interpreter.d.ts +4 -0
  25. package/packages/safe-js/dist/interp/interpreter.js +22 -4
  26. package/packages/safe-js/dist/interp/object-model.js +7 -0
  27. package/packages/safe-js/dist/interp/values.d.ts +1 -0
  28. package/packages/safe-js/dist/interp/values.js +15 -0
  29. package/packages/safe-js/dist/modules/registry.d.ts +3 -1
  30. package/packages/safe-js/dist/modules/registry.js +2 -1
  31. package/packages/safe-js/dist/realm.d.ts +43 -0
  32. package/packages/safe-js/dist/realm.js +713 -0
  33. package/packages/safe-js/dist/run.d.ts +5 -1
  34. package/packages/safe-js/dist/run.js +6 -35
  35. package/packages/safe-js/dist/chunks/chunk-B7H4ZL65.js.map +0 -7
  36. /package/packages/safe-js/dist/chunks/{chunk-7B7BKWVF.js.map → chunk-QSSQJNKE.js.map} +0 -0
@@ -1,10 +1,11 @@
1
+ import { type RealmOptions } from "./realm.js";
1
2
  import { type ErrorSourceSpan } from "./error/shape.js";
2
3
  import { type SourceSpan } from "./parse/parser.js";
3
4
  import { type SafeJSSnapshot } from "./restore.js";
4
5
  import { Budget } from "./interp/budget.js";
5
6
  import { type PromiseReplaySnapshot } from "./interp/promise-replay.js";
6
7
  import { type HostCallRecord, type HostCallReplay, type HostCallResumeProvider } from "./interp/host-call.js";
7
- import { type ConsoleSink } from "./interp/globals/console-json.js";
8
+ import type { ConsoleSink } from "./interp/globals/console-json.js";
8
9
  import { type CallerInjectedBinding } from "./interp/host-bridge.js";
9
10
  import { type InterpreterResult, type LoopIterationSnapshot } from "./interp/interpreter.js";
10
11
  import { type ModuleRegistry } from "./modules/registry.js";
@@ -12,6 +13,9 @@ import { type OtelSink } from "./observability/otel.js";
12
13
  import type { SnapshotBackend } from "./snapshot/backend.js";
13
14
  import { type ReplayData } from "./snapshot/replay-data.js";
14
15
  export type RunOptions = {
16
+ extensions?: RealmOptions["extensions"];
17
+ grants?: RealmOptions["grants"];
18
+ limits?: RealmOptions["limits"];
15
19
  bindings?: Record<string, CallerInjectedBinding>;
16
20
  budget?: Budget;
17
21
  clock?: RunClock;
@@ -1,4 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { runWithExtensions } from "./realm.js";
2
3
  import { hashParsedAst, hashSource } from "./parse/hash.js";
3
4
  import { withRunResources } from "./interp/resources.js";
4
5
  import { createReplayableRandom } from "./random.js";
@@ -12,17 +13,10 @@ import { wrapCancelableBindings } from "./interp/cancel.js";
12
13
  import { enterSnapshotRun } from "./interp/running-state.js";
13
14
  import { createSandboxPromiseRejectionTracker, observeSandboxPromise, withSandboxPromiseRejectionTracker } from "./interp/promise-tracker.js";
14
15
  import { HostCallJournal } from "./interp/host-call.js";
15
- import { createConsoleJsonGlobals } from "./interp/globals/console-json.js";
16
- import { createCollectionGlobals } from "./interp/globals/collections.js";
17
- import { createFloat32ArrayGlobal } from "./interp/globals/float32array.js";
18
- import { createErrorGlobals } from "./interp/globals/error.js";
19
- import { createMathGlobals } from "./interp/globals/math.js";
20
- import { createRegexGlobals } from "./interp/globals/regex.js";
21
- import { createMiscGlobals } from "./interp/globals/misc.js";
22
- import { createObjectArrayGlobals } from "./interp/globals/object-array.js";
16
+ import { createBuiltinBindings } from "./interp/globals.js";
23
17
  import { declareHostOperation, wrapCallerInjectedBindings } from "./interp/host-bridge.js";
24
18
  import { interpret, Scope } from "./interp/interpreter.js";
25
- import { consumeSettledHostCall, createPromiseGlobals } from "./interp/promise.js";
19
+ import { consumeSettledHostCall } from "./interp/promise.js";
26
20
  import { deepCopyToSandbox, isSandboxClosure, isSandboxPromise, measureSandboxData, reconcileCompiledValues } from "./interp/values.js";
27
21
  import { resolveModuleImports } from "./modules/registry.js";
28
22
  import { activateOtelSink, getActiveOtelSpan, safeAddEvent } from "./observability/otel.js";
@@ -44,6 +38,8 @@ export class UnhandledRejectionError extends Error {
44
38
  }
45
39
  const DEFAULT_MAX_CALL_DEPTH = 1_000;
46
40
  export function run(source, options = {}) {
41
+ if (options.extensions !== undefined)
42
+ return runWithExtensions(source, options);
47
43
  const lifecycle = {
48
44
  hostCallbackDepth: 0,
49
45
  hostCallbackContext: new AsyncLocalStorage()
@@ -113,32 +109,7 @@ export function run(source, options = {}) {
113
109
  signal: options.signal,
114
110
  lifecycle
115
111
  }));
116
- const builtinBindings = {
117
- ...createConsoleJsonGlobals({
118
- compileOwner: operation.owner,
119
- budget,
120
- hostCalls,
121
- sink: options.sink
122
- }),
123
- ...createCollectionGlobals({ budget }),
124
- Float32Array: createFloat32ArrayGlobal(budget),
125
- ...createErrorGlobals({
126
- budget
127
- }),
128
- ...createMathGlobals({
129
- random: random?.generator.next
130
- }),
131
- ...createObjectArrayGlobals({
132
- budget
133
- }),
134
- ...createMiscGlobals({
135
- budget
136
- }),
137
- ...createPromiseGlobals({
138
- budget
139
- }),
140
- ...createRegexGlobals(operation.owner)
141
- };
112
+ const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next });
142
113
  const importMeta = convertInitialInput(() => deepCopyToSandbox(options.importMeta ?? {}));
143
114
  if (restoredSnapshot?.migration !== undefined) {
144
115
  if (Object.hasOwn(importMeta, "migration"))