@poe-platform/safe-js 0.1.802 → 0.1.804

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 (57) hide show
  1. package/README.md +4 -4
  2. package/dist/safe-js/bundled-yaml/LICENSE +13 -0
  3. package/dist/safe-js/bundled-yaml/index.js +6601 -0
  4. package/dist/safe-js/chunks/{chunk-HFRBLE6Y.js → chunk-36PBWSDR.js} +23 -11
  5. package/dist/safe-js/chunks/{chunk-CK3YK2EC.js → chunk-6AO2T2VZ.js} +1 -1
  6. package/dist/safe-js/chunks/{chunk-5RLD4TVI.js → chunk-BKNQTNHP.js} +36 -23
  7. package/dist/safe-js/chunks/{chunk-YCFOANSU.js → chunk-BYDDUKS3.js} +3 -3
  8. package/dist/safe-js/chunks/{chunk-6H5VC5W5.js → chunk-CKOGIOB3.js} +470 -464
  9. package/dist/safe-js/chunks/{chunk-XOMGWE37.js → chunk-CVPZFRCC.js} +3 -3
  10. package/dist/safe-js/chunks/{chunk-4KMUWNZD.js → chunk-ECMGBHAB.js} +13 -137
  11. package/dist/safe-js/chunks/{chunk-A3LXCGMJ.js → chunk-EQUBWQJN.js} +57 -34
  12. package/dist/safe-js/chunks/{chunk-QRWRR6IA.js → chunk-JMDWLOJV.js} +26 -3
  13. package/dist/safe-js/chunks/{chunk-3NFTBEZR.js → chunk-JQ5QJV5Q.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-MMN3IESA.js → chunk-KMBCLXER.js} +1 -1
  15. package/dist/safe-js/chunks/{chunk-PMOXSLM5.js → chunk-MJH73KJI.js} +2 -2
  16. package/dist/safe-js/chunks/{chunk-IB6WAQAE.js → chunk-P66QKVQC.js} +3 -3
  17. package/dist/safe-js/chunks/{chunk-HPHCQNFV.js → chunk-RPGCF4KE.js} +130 -3
  18. package/dist/safe-js/chunks/{chunk-F6Y734YA.js → chunk-SIR35W6T.js} +5 -5
  19. package/dist/safe-js/chunks/{chunk-7THYP46K.js → chunk-SMGNJNDU.js} +1 -1
  20. package/dist/safe-js/chunks/{chunk-XV5OYKND.js → chunk-VLRTLEDI.js} +2 -2
  21. package/dist/safe-js/chunks/{chunk-JCHJGIQA.js → chunk-VVOPJZRG.js} +2 -0
  22. package/dist/safe-js/chunks/{cli-runtime-L4IABN2W.js → cli-runtime-A353G7DR.js} +15 -15
  23. package/dist/safe-js/chunks/{dump-KUPBSXSL.js → dump-KQZFULX2.js} +4 -4
  24. package/dist/safe-js/chunks/harness-XT6K6X67.js +10 -0
  25. package/dist/safe-js/chunks/mcp-VWE444VD.js +11 -0
  26. package/dist/safe-js/chunks/migration-file-NSKXOMAO.js +14 -0
  27. package/dist/safe-js/chunks/restore-SHPORPY4.js +13 -0
  28. package/dist/safe-js/chunks/run-FQOSICOT.js +19 -0
  29. package/dist/safe-js/chunks/{runtime-modules-MGSXY4BN.js → runtime-modules-DBRXXRND.js} +4 -4
  30. package/dist/safe-js/chunks/{source-files-BSDM22Y2.js → source-files-A2WSOO6G.js} +3 -3
  31. package/dist/safe-js/cli.js +2 -2
  32. package/dist/safe-js/core.d.ts +19 -0
  33. package/dist/safe-js/core.js +39 -15
  34. package/dist/safe-js/error/format.d.ts +3 -0
  35. package/dist/safe-js/index.d.ts +1 -12
  36. package/dist/safe-js/index.js +30 -39
  37. package/dist/safe-js/interp/host-call.d.ts +1 -0
  38. package/dist/safe-js/interp/interpreter.d.ts +1 -3
  39. package/dist/safe-js/modules/fs.js +5 -5
  40. package/dist/safe-js/platform/node.d.ts +1 -0
  41. package/dist/safe-js/platform/node.js +1 -0
  42. package/dist/safe-js/platform/workerd.d.ts +1 -0
  43. package/dist/safe-js/platform/workerd.js +2 -0
  44. package/dist/safe-js/portable/chunks/{chunk-XCTU25SU.js → chunk-NLGXLZCK.js} +1 -1
  45. package/dist/safe-js/portable/chunks/{chunk-2FNMGWDK.js → chunk-SRMMDXD3.js} +127 -91
  46. package/dist/safe-js/portable/chunks/{chunk-H5X3T5VP.js → chunk-W6MZOTYR.js} +2 -0
  47. package/dist/safe-js/portable/chunks/{source-files-CVU252FB.js → source-files-AEDWESAJ.js} +2 -2
  48. package/dist/safe-js/portable/core.js +467 -249
  49. package/dist/safe-js/portable/modules/fs.js +2 -2
  50. package/dist/safe-js/workerd.js +57987 -57738
  51. package/package.json +6 -5
  52. package/dist/safe-js/chunks/harness-3DDUS3RY.js +0 -10
  53. package/dist/safe-js/chunks/mcp-5TMFK3UE.js +0 -11
  54. package/dist/safe-js/chunks/migration-file-4CYSJ6LO.js +0 -14
  55. package/dist/safe-js/chunks/restore-GDHBT5ZD.js +0 -13
  56. package/dist/safe-js/chunks/run-M6N5KCPF.js +0 -19
  57. package/dist/safe-js/node-unavailable.d.ts +0 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ built-ins. It is suitable for capability-controlled scripts and agent workflows.
8
8
  Complete ECMAScript conformance has not been established; see
9
9
  [development status](#development-status) and [meaningful limitations](#meaningful-limitations).
10
10
 
11
- Under `workerd` and `browser` conditions, the standalone root and `/core` exports select the portable interpreter with `makeFsModule`, `makeEnvModule`, `makeTimeModule`, `makeFailModule`, `makeMetricModule`, and `makeHarnessModule`. The `/modules/fs` entry is also portable; supply a filesystem adapter for host file access.
11
+ Under `workerd` and `browser` conditions, the standalone root and `/core` exports select the portable interpreter with parsing (`parse`, `parseModule`, `parseSourceModule`), checkpoints (`dump`, `restore`), sandbox copy helpers, error classes, `declareHostOperation`, `makeFsModule`, `makeEnvModule`, `makeTimeModule`, `makeFailModule`, `makeMetricModule`, and `makeHarnessModule`. The `/modules/fs` entry is also portable; supply a filesystem adapter for host file access.
12
12
 
13
13
  ## Quickstart
14
14
 
@@ -38,7 +38,7 @@ console.log(result.returnValue);
38
38
 
39
39
  `run()` takes source text, not a file path. Success returns `ok`, `returnValue`, `snapshot`, and `stats`. Handle both an `ok: false` result and a rejected promise: parsing, budget exhaustion, cancellation, and some execution failures can reject. Top-level `await` in this example lets rejections reach Node.
40
40
 
41
- `@poe-platform/safe-js/core` exposes `run`, `createRealm`, `defineExtension`, `lint`, `Budget`, and replayable-random helpers for Node.js. In Workers, the `@poe-platform/safe-js` root selects `/workerd`: it exports the portable core API plus `declareHostOperation` without requiring `nodejs_compat`, including the runtime hooks needed by Safe Bash's `nodeCommands()`. The `/core` and `/modules/fs` workspace entries also bundle with the `workerd` or `browser` condition without Node built-ins. Supply a `@poe-platform/safe-fs/core` adapter for filesystem capabilities; `createRootedSourceResolver(root, adapter)` grants portable source imports. File snapshots, migrations, harnesses, and file-running helpers also accept an `adapter`. The shared filesystem lives in `@poe-platform/safe-fs`, with a portable `/core` entry. Existing `@poe-platform/safe-js/fs`, `/fs/core`, and `/fs/node` imports re-export it. Legacy `poe-code/safe-js` imports remain available through the CLI package but use a separate runtime; keep factories and errors within one import family.
41
+ `@poe-platform/safe-js/core` exposes `run`, `createRealm`, `defineExtension`, `lint`, `Budget`, and replayable-random helpers for Node.js. In Workers, the `@poe-platform/safe-js` root selects `/workerd`: it exports the portable core API plus `declareHostOperation` without requiring `nodejs_compat`, including the runtime hooks needed by Safe Bash's `nodeCommands()`. The `/core` and `/modules/fs` workspace entries also bundle with the `workerd` or `browser` condition without Node built-ins. Supply a `@poe-platform/safe-fs/core` adapter for filesystem capabilities; `createRootedSourceResolver(root, adapter)` grants portable source imports. File snapshots, migrations, harnesses, and file-running helpers also accept an `adapter`. The root export selects the portable API under `workerd`, `worker`, and `browser` conditions. `makeEnvModule` uses explicit allowed values when supplied and returns `undefined` for missing host variables; `makeLogModule` writes JSON records through `console.log` when writable stdout is unavailable. The shared filesystem lives in `@poe-platform/safe-fs`, with a portable `/core` entry. Existing `@poe-platform/safe-js/fs`, `/fs/core`, and `/fs/node` imports re-export it. Legacy `poe-code/safe-js` imports remain available through the CLI package but use a separate runtime; keep factories and errors within one import family.
42
42
 
43
43
  ## Supported features
44
44
 
@@ -462,7 +462,7 @@ For one-shot use, `run(source, { extensions, grants, ... })` accepts the same re
462
462
 
463
463
  `JSON.parse` checks both parse paths before building native objects: input work counts toward steps and deadlines, array lengths and object member counts use `arrayLength`, and nesting uses `maxCallDepth` only when explicitly configured. Parsing requires room for a conservative temporary allocation bound of `16 * text.length + 8` data units alongside existing data; whitespace and duplicate keys count toward this bound.
464
464
 
465
- There are no runtime environment variables to set. `makeEnvModule({ allow, values? })` grants reads of names in `allow`; `values` supplies an explicit string map instead of reading the host's `process.env`. Hosts without `process.env` have no ambient values; pass Worker bindings through `values`. Disallowed reads throw `EnvAccessError`; allowed but unset names return `undefined`. Agent and MCP integrations may require their own credentials.
465
+ There are no runtime environment variables to set. `makeEnvModule({ allow, values? })` grants reads of names in `allow`; `values` supplies an explicit string map instead of reading the host's `process.env`. Portable hosts never read ambient environment values, including with `nodejs_compat`; pass Worker bindings through `values`. Disallowed reads throw `EnvAccessError`; allowed but unset names return `undefined`. Agent and MCP integrations may require their own credentials.
466
466
 
467
467
  <details>
468
468
  <summary>Linting, parsing, and value conversion</summary>
@@ -479,7 +479,7 @@ There are no runtime environment variables to set. `makeEnvModule({ allow, value
479
479
  | `largeLiteralThreshold` | Threshold for large-literal diagnostics. |
480
480
  | `fix`, `fixRanges` | Apply available fixes, optionally restricted to source ranges. |
481
481
 
482
- `parse(source, filename?)` parses a single statement/expression; `parseModule(source, filename?)` parses a harness module. `parseSourceModule(source, filename?)` uses the same built-in parser for ECMAScript source modules and returns executable syntax plus import/export metadata. Source-module execution uses `run(source, { sourceType: "module", sourceResolver })`; the resolver explicitly grants each imported source. `formatInterpreterError(error, { source?, filename?, hostCallName?, maxMessageLength? })` formats an error; `(source, diagnostic)` is also supported.
482
+ `parse(source, filename?)` parses a single statement/expression; `parseModule(source, filename?)` parses a harness module. `parseSourceModule(source, filename?)` uses the same built-in parser for ECMAScript source modules and returns executable syntax plus import/export metadata. Source-module execution uses `run(source, { sourceType: "module", sourceResolver })`; the resolver explicitly grants each imported source. `formatInterpreterError(error, { source?, filename?, hostCallName?, maxMessageLength?, maxCauseDepth? })` formats an error; `(source, diagnostic)` is also supported. Messages and cause chains are unlimited by default; set `maxMessageLength` or `maxCauseDepth` to opt into truncation. Circular cause chains always stop.
483
483
  Diagnostic module parsing retains missing-`async` forms so lint can report and
484
484
  autofix them. Executable parsing and restored-source compilation reject `await`
485
485
  inside non-async functions, including nested functions and template substitutions.
@@ -0,0 +1,13 @@
1
+ Copyright Eemeli Aro <eemeli@gmail.com>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose
4
+ with or without fee is hereby granted, provided that the above copyright notice
5
+ and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13
+ THIS SOFTWARE.