@poe-platform/safe-js 0.1.799 → 0.1.801

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 (46) hide show
  1. package/README.md +4 -2
  2. package/dist/safe-js/chunks/{chunk-KULEMOAE.js → chunk-4KMUWNZD.js} +5 -156
  3. package/dist/safe-js/chunks/{chunk-ULPZIHB5.js → chunk-5RLD4TVI.js} +174 -127
  4. package/dist/safe-js/chunks/{chunk-MCFRB5X3.js → chunk-6H5VC5W5.js} +84 -14
  5. package/dist/safe-js/chunks/{chunk-TBZILU4U.js → chunk-7THYP46K.js} +1 -1
  6. package/dist/safe-js/chunks/{chunk-UU4T2KIT.js → chunk-CK3YK2EC.js} +1 -1
  7. package/dist/safe-js/chunks/{chunk-3O7HA6WT.js → chunk-F6Y734YA.js} +2 -2
  8. package/dist/safe-js/chunks/{chunk-M6S3F3WM.js → chunk-HFRBLE6Y.js} +42 -36
  9. package/dist/safe-js/chunks/{chunk-OPYN6N5M.js → chunk-HPHCQNFV.js} +154 -1
  10. package/dist/safe-js/chunks/{chunk-W6C3Q6U4.js → chunk-IB6WAQAE.js} +2 -2
  11. package/dist/safe-js/chunks/{chunk-ZKLJW27N.js → chunk-PMOXSLM5.js} +1 -1
  12. package/dist/safe-js/chunks/chunk-QRWRR6IA.js +78 -0
  13. package/dist/safe-js/chunks/{chunk-MDJ7MJYI.js → chunk-XOMGWE37.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-QTCPJ7FN.js → chunk-XV5OYKND.js} +1 -1
  15. package/dist/safe-js/chunks/{chunk-OTVZWRYE.js → chunk-YCFOANSU.js} +23 -18
  16. package/dist/safe-js/chunks/{cli-runtime-DYXJZCGV.js → cli-runtime-L4IABN2W.js} +15 -15
  17. package/dist/safe-js/chunks/{dump-XDJEF2LG.js → dump-KUPBSXSL.js} +2 -2
  18. package/dist/safe-js/chunks/{harness-32OOFC5A.js → harness-3DDUS3RY.js} +2 -2
  19. package/dist/safe-js/chunks/{mcp-PTCA53MN.js → mcp-5TMFK3UE.js} +3 -3
  20. package/dist/safe-js/chunks/{migration-file-EEGIOHQB.js → migration-file-4CYSJ6LO.js} +3 -3
  21. package/dist/safe-js/chunks/{restore-U3CCH36B.js → restore-GDHBT5ZD.js} +3 -3
  22. package/dist/safe-js/chunks/{run-Q74MU3QQ.js → run-M6N5KCPF.js} +5 -5
  23. package/dist/safe-js/chunks/{runtime-modules-SL5D6LAJ.js → runtime-modules-MGSXY4BN.js} +2 -2
  24. package/dist/safe-js/cli.js +2 -2
  25. package/dist/safe-js/core.d.ts +6 -0
  26. package/dist/safe-js/core.js +33 -7
  27. package/dist/safe-js/index.js +24 -93
  28. package/dist/safe-js/interp/data-copy.d.ts +3 -2
  29. package/dist/safe-js/interp/host-bridge.d.ts +5 -4
  30. package/dist/safe-js/modules/fs-config.d.ts +1 -0
  31. package/dist/safe-js/modules/fs.d.ts +2 -0
  32. package/dist/safe-js/modules/fs.js +2 -2
  33. package/dist/safe-js/node-unavailable.d.ts +1 -0
  34. package/dist/safe-js/portable/chunks/chunk-2FNMGWDK.js +58703 -0
  35. package/dist/safe-js/portable/chunks/chunk-H5X3T5VP.js +909 -0
  36. package/dist/safe-js/portable/chunks/chunk-XCTU25SU.js +111 -0
  37. package/dist/safe-js/portable/chunks/source-files-CVU252FB.js +7 -0
  38. package/dist/safe-js/portable/core.js +14763 -0
  39. package/dist/safe-js/portable/modules/fs.js +9 -0
  40. package/dist/safe-js/snapshot/arguments.d.ts +2 -0
  41. package/dist/safe-js/snapshot/property-descriptors.d.ts +2 -0
  42. package/dist/safe-js/snapshot/regexp-properties.d.ts +2 -0
  43. package/dist/safe-js/snapshot/symbols.d.ts +2 -0
  44. package/dist/safe-js/workerd.d.ts +3 -0
  45. package/dist/safe-js/workerd.js +74436 -0
  46. package/package.json +30 -6
@@ -2,47 +2,50 @@ import {
2
2
  inspectSnapshotMigration,
3
3
  migrateSnapshot,
4
4
  migrateSnapshotFile
5
- } from "./chunks/chunk-3O7HA6WT.js";
5
+ } from "./chunks/chunk-F6Y734YA.js";
6
6
  import {
7
7
  createLintModulesFromRuntimeRegistry
8
- } from "./chunks/chunk-TBZILU4U.js";
9
- import {
10
- makeHarnessModule
11
- } from "./chunks/chunk-UU4T2KIT.js";
8
+ } from "./chunks/chunk-7THYP46K.js";
12
9
  import {
13
10
  makeMcpModule
14
- } from "./chunks/chunk-W6C3Q6U4.js";
11
+ } from "./chunks/chunk-IB6WAQAE.js";
15
12
  import {
16
13
  AgentSpawnError,
17
- EnvAccessError,
18
14
  SPAWN_MODES,
19
15
  countLineBreaks,
20
16
  createSpawnUsageAccumulator,
21
17
  extractBlock,
22
18
  formatInterpreterError,
23
19
  makeAgentModule,
24
- makeEnvModule,
25
- makeFailModule,
26
20
  makeLogModule,
27
- makeMetricModule,
28
21
  maskSource,
29
- parseEnvConfig,
30
22
  parseFsConfig,
31
23
  resolveFsConfig,
32
24
  runWithSpawnUsageAccumulator,
33
25
  splitFrontmatter,
34
26
  supportsSpawnMode
35
- } from "./chunks/chunk-KULEMOAE.js";
27
+ } from "./chunks/chunk-4KMUWNZD.js";
36
28
  import {
37
29
  parseMcpConfig
38
- } from "./chunks/chunk-MCFRB5X3.js";
30
+ } from "./chunks/chunk-6H5VC5W5.js";
31
+ import {
32
+ makeTimeModule
33
+ } from "./chunks/chunk-QRWRR6IA.js";
39
34
  import {
40
- lint
41
- } from "./chunks/chunk-OPYN6N5M.js";
35
+ makeHarnessModule
36
+ } from "./chunks/chunk-CK3YK2EC.js";
37
+ import {
38
+ EnvAccessError,
39
+ lint,
40
+ makeEnvModule,
41
+ makeFailModule,
42
+ makeMetricModule,
43
+ parseEnvConfig
44
+ } from "./chunks/chunk-HPHCQNFV.js";
42
45
  import "./chunks/chunk-X3YCE3ZH.js";
43
46
  import {
44
47
  makeFsModule
45
- } from "./chunks/chunk-OTVZWRYE.js";
48
+ } from "./chunks/chunk-YCFOANSU.js";
46
49
  import {
47
50
  createRootedSourceResolver
48
51
  } from "./chunks/chunk-3NFTBEZR.js";
@@ -51,7 +54,7 @@ import {
51
54
  createRealm,
52
55
  createReplayableRandom,
53
56
  run
54
- } from "./chunks/chunk-M6S3F3WM.js";
57
+ } from "./chunks/chunk-HFRBLE6Y.js";
55
58
  import "./chunks/chunk-DHGJSEFX.js";
56
59
  import {
57
60
  fsCodec
@@ -61,23 +64,22 @@ import {
61
64
  } from "./chunks/chunk-ONWFPHUI.js";
62
65
  import {
63
66
  restore
64
- } from "./chunks/chunk-MDJ7MJYI.js";
65
- import "./chunks/chunk-ZKLJW27N.js";
67
+ } from "./chunks/chunk-XOMGWE37.js";
68
+ import "./chunks/chunk-PMOXSLM5.js";
66
69
  import {
67
70
  dump
68
- } from "./chunks/chunk-QTCPJ7FN.js";
71
+ } from "./chunks/chunk-XV5OYKND.js";
69
72
  import {
70
73
  HostCallResumabilityError,
71
74
  HostOperationResumePolicyError,
72
75
  SnapshotValidationError,
73
76
  admitNativePromiseProperties,
74
- createSeededRandom,
75
77
  declareHostOperation,
76
78
  deepCopyFromSandbox,
77
79
  deepCopyToSandbox,
78
80
  defineExtension,
79
81
  registerPendingHostCallPolicy
80
- } from "./chunks/chunk-ULPZIHB5.js";
82
+ } from "./chunks/chunk-5RLD4TVI.js";
81
83
  import {
82
84
  Budget,
83
85
  SandboxError,
@@ -370,77 +372,6 @@ function findExportedConstInitializer(module, name) {
370
372
  return void 0;
371
373
  }
372
374
 
373
- // packages/safe-js/src/modules/time.ts
374
- function makeTimeModule(options = {}) {
375
- const hasDeterministicRandom = options.random !== void 0 || options.seed !== void 0;
376
- const random = options.random ?? (options.seed === void 0 ? () => Math.random() : createSeededRandom(options.seed).next);
377
- const now = options.now ?? (() => Date.now());
378
- const signal = options.signal;
379
- async function sleep(ms) {
380
- assertSleepDelay(ms);
381
- return await new Promise((resolve, reject) => {
382
- if (signal?.aborted === true) {
383
- reject(createSleepAbortError());
384
- return;
385
- }
386
- const start = performance.now();
387
- let timeout = setTimeout(resolveSleep, ms);
388
- function cleanup() {
389
- clearTimeout(timeout);
390
- signal?.removeEventListener("abort", rejectSleep);
391
- }
392
- function resolveSleep() {
393
- const remainingMs = ms - (performance.now() - start);
394
- if (remainingMs > 0) {
395
- timeout = setTimeout(resolveSleep, remainingMs);
396
- return;
397
- }
398
- cleanup();
399
- resolve();
400
- }
401
- function rejectSleep() {
402
- cleanup();
403
- reject(createSleepAbortError());
404
- }
405
- signal?.addEventListener("abort", rejectSleep, { once: true });
406
- });
407
- }
408
- return {
409
- random,
410
- now,
411
- sleep,
412
- uuid: hasDeterministicRandom ? () => createRandomUuid(random) : () => globalThis.crypto.randomUUID()
413
- };
414
- }
415
- function createRandomUuid(random) {
416
- const bytes = Array.from({ length: 16 }, () => Math.floor(readRandomUnit(random()) * 256));
417
- bytes[6] = bytes[6] & 15 | 64;
418
- bytes[8] = bytes[8] & 63 | 128;
419
- const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("");
420
- return [
421
- hex.slice(0, 8),
422
- hex.slice(8, 12),
423
- hex.slice(12, 16),
424
- hex.slice(16, 20),
425
- hex.slice(20)
426
- ].join("-");
427
- }
428
- function readRandomUnit(value) {
429
- if (Number.isFinite(value) && value >= 0 && value < 1) {
430
- return value;
431
- }
432
- throw new RangeError("time.uuid() random source must return a number in [0, 1).");
433
- }
434
- function assertSleepDelay(ms) {
435
- if (Number.isFinite(ms) && ms >= 0) {
436
- return;
437
- }
438
- throw new RangeError("time.sleep(ms) requires a non-negative finite millisecond delay.");
439
- }
440
- function createSleepAbortError() {
441
- return new Error("time.sleep aborted.");
442
- }
443
-
444
375
  // packages/safe-js/src/index.ts
445
376
  var parseModule2 = parseModule;
446
377
  var parseSourceModule2 = parseSourceModule;
@@ -1,2 +1,3 @@
1
- export type DataCopyOperation<T> = Generator<DataCopyOperation<T>, T, T>;
2
- export declare function runDataCopy<T>(operation: DataCopyOperation<T>): T;
1
+ export type DataCopyOperation<T, Result = T> = Generator<DataCopyOperation<T>, Result, T>;
2
+ export declare function dataCopyIterable<T, Result>(operation: DataCopyOperation<T, Result>): Iterable<DataCopyOperation<T>, Result, T>;
3
+ export declare function runDataCopy<T, Result = T>(operation: DataCopyOperation<T, Result>): Result;
@@ -49,11 +49,12 @@ export declare function wrapHostConstructor(name: string, construct: CallerInjec
49
49
  hasInstance?: CallerInjectedFunction;
50
50
  constants: Record<string, number>;
51
51
  }): SandboxClosure;
52
- export declare function copyHostValueToSandbox(value: unknown, stackFrames: readonly string[], options: HostBridgeOptions & {
53
- errorData?: boolean;
54
- }, state: {
52
+ type HostCopyState = {
55
53
  seen: WeakMap<object, SandboxValue>;
56
54
  float32Buffers?: WeakMap<ArrayBufferLike, ArrayBufferLike>;
57
55
  promiseIdentities?: WeakMap<object, SandboxValue>;
58
- }, path: string): SandboxValue;
56
+ };
57
+ export declare function copyHostValueToSandbox(value: unknown, stackFrames: readonly string[], options: HostBridgeOptions & {
58
+ errorData?: boolean;
59
+ }, state: HostCopyState, path: string): SandboxValue;
59
60
  export {};
@@ -6,6 +6,7 @@ export type FsConfig = {
6
6
  readonly cwd?: string;
7
7
  readonly readFileMaxBytes?: number;
8
8
  readonly hostReadMemoryLimit?: number;
9
+ readonly maxSymlinkFollows?: number;
9
10
  };
10
11
  export type ResolveFsConfigOptions = {
11
12
  readonly registry?: FileSystemAdapterRegistry;
@@ -44,6 +44,8 @@ type StatOptions = {
44
44
  bigint?: false;
45
45
  };
46
46
  export type FsModuleOptions = {
47
+ /** Dangling-symlink canonicalization quota; unlimited by default. */
48
+ maxSymlinkFollows?: number;
47
49
  hostReadMemoryLimit?: number;
48
50
  readFileMaxBytes?: number;
49
51
  } & ({
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  FS_OPTION_SURFACE,
3
3
  makeFsModule
4
- } from "../chunks/chunk-OTVZWRYE.js";
4
+ } from "../chunks/chunk-YCFOANSU.js";
5
5
  import "../chunks/chunk-DIG26TEI.js";
6
6
  import "../chunks/chunk-ONWFPHUI.js";
7
- import "../chunks/chunk-ULPZIHB5.js";
7
+ import "../chunks/chunk-5RLD4TVI.js";
8
8
  import "../chunks/chunk-A3LXCGMJ.js";
9
9
  import "../chunks/chunk-MMN3IESA.js";
10
10
  import "../chunks/chunk-JCHJGIQA.js";
@@ -0,0 +1 @@
1
+ export {};