@poe-platform/safe-js 0.1.730 → 0.1.732

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 (100) hide show
  1. package/README.md +5 -5
  2. package/dist/safe-js/chunks/{chunk-SJZWSPWD.js → chunk-2GVBG23M.js} +1 -1
  3. package/dist/safe-js/chunks/{chunk-SJZWSPWD.js.map → chunk-2GVBG23M.js.map} +1 -1
  4. package/dist/safe-js/chunks/{chunk-MW2QLYVN.js → chunk-3ITVV2R6.js} +77 -66
  5. package/dist/safe-js/chunks/chunk-3ITVV2R6.js.map +7 -0
  6. package/dist/safe-js/chunks/{chunk-VIMROAQA.js → chunk-E4XLBT7R.js} +2 -2
  7. package/dist/safe-js/chunks/chunk-F6CV74HU.js +114 -0
  8. package/dist/safe-js/chunks/chunk-F6CV74HU.js.map +7 -0
  9. package/dist/safe-js/chunks/{chunk-OZLTLIHX.js → chunk-G6WTEIJJ.js} +2 -2
  10. package/dist/safe-js/chunks/{chunk-XX57YCGZ.js → chunk-GNEORAQI.js} +55 -50
  11. package/dist/safe-js/chunks/chunk-GNEORAQI.js.map +7 -0
  12. package/dist/safe-js/chunks/chunk-GVKXZW53.js +76 -0
  13. package/dist/safe-js/chunks/chunk-GVKXZW53.js.map +7 -0
  14. package/dist/safe-js/chunks/{chunk-MRULOD5J.js → chunk-K4T4EBED.js} +59 -38
  15. package/dist/safe-js/chunks/chunk-K4T4EBED.js.map +7 -0
  16. package/dist/safe-js/chunks/{chunk-MFCEBCGV.js → chunk-KETIFEA7.js} +17 -8
  17. package/dist/safe-js/chunks/chunk-KETIFEA7.js.map +7 -0
  18. package/dist/safe-js/chunks/{chunk-S5YDMMM3.js → chunk-MDIWQFYU.js} +95 -169
  19. package/dist/safe-js/chunks/{chunk-S5YDMMM3.js.map → chunk-MDIWQFYU.js.map} +4 -4
  20. package/dist/safe-js/chunks/{chunk-EN724VH3.js → chunk-O4IDRXW7.js} +4 -4
  21. package/dist/safe-js/chunks/{chunk-3LSNBW5N.js → chunk-P64CQIUA.js} +4 -4
  22. package/dist/safe-js/chunks/{chunk-EA7AHM2X.js → chunk-PSVV3IG2.js} +3 -3
  23. package/dist/safe-js/chunks/{chunk-Y5EZYHU6.js → chunk-QKO4FATZ.js} +33 -5
  24. package/dist/safe-js/chunks/chunk-QKO4FATZ.js.map +7 -0
  25. package/dist/safe-js/chunks/{chunk-EG3QWREA.js → chunk-RULU2F5J.js} +2 -2
  26. package/dist/safe-js/chunks/chunk-UQPYTZOZ.js +72 -0
  27. package/dist/safe-js/chunks/chunk-UQPYTZOZ.js.map +7 -0
  28. package/dist/safe-js/chunks/{chunk-LRSWTDIV.js → chunk-W4SWUHCQ.js} +58 -23
  29. package/dist/safe-js/chunks/chunk-W4SWUHCQ.js.map +7 -0
  30. package/dist/safe-js/chunks/{chunk-W3IY6FKO.js → chunk-WS2FJBH6.js} +2 -2
  31. package/dist/safe-js/chunks/{chunk-MVLDRXWS.js → chunk-X3CKAZQ4.js} +3 -3
  32. package/dist/safe-js/chunks/chunk-YUQFFRUF.js +26 -0
  33. package/dist/safe-js/chunks/chunk-YUQFFRUF.js.map +7 -0
  34. package/dist/safe-js/chunks/{cli-runtime-WSVW5DNT.js → cli-runtime-ZSOTNIVC.js} +51 -30
  35. package/dist/safe-js/chunks/cli-runtime-ZSOTNIVC.js.map +7 -0
  36. package/dist/safe-js/chunks/{dump-UNYK24YS.js → dump-RGRC3CG3.js} +5 -4
  37. package/dist/safe-js/chunks/harness-UMOMFXDT.js +11 -0
  38. package/dist/safe-js/chunks/mcp-2Z4XWHKW.js +12 -0
  39. package/dist/safe-js/chunks/migration-file-KRXQYI3Q.js +15 -0
  40. package/dist/safe-js/chunks/restore-GEO7VN2R.js +14 -0
  41. package/dist/safe-js/chunks/run-ZSFX66RN.js +20 -0
  42. package/dist/safe-js/chunks/runtime-modules-A3U2DKFL.js +11 -0
  43. package/dist/safe-js/chunks/source-files-L3SGK63Z.js +10 -0
  44. package/dist/safe-js/cli-runtime.d.ts +2 -0
  45. package/dist/safe-js/cli.js +4 -4
  46. package/dist/safe-js/core.d.ts +1 -0
  47. package/dist/safe-js/core.js +15 -8
  48. package/dist/safe-js/error/shape.js +170 -0
  49. package/dist/safe-js/index.js +42 -33
  50. package/dist/safe-js/index.js.map +2 -2
  51. package/dist/safe-js/interp/budget.js +600 -0
  52. package/dist/safe-js/interp/internal-symbols.js +1 -0
  53. package/dist/safe-js/interp/promise-replay.d.ts +1 -1
  54. package/dist/safe-js/interp/template-cache.js +7 -0
  55. package/dist/safe-js/migration-file.d.ts +2 -0
  56. package/dist/safe-js/modules/fs-config.d.ts +3 -1
  57. package/dist/safe-js/modules/fs.d.ts +8 -4
  58. package/dist/safe-js/modules/fs.js +16 -0
  59. package/dist/safe-js/modules/source-files.d.ts +3 -2
  60. package/dist/safe-js/platform/context.js +58 -0
  61. package/dist/safe-js/platform/node.js +64 -0
  62. package/dist/safe-js/platform/types.js +63 -0
  63. package/dist/safe-js/platform/workerd.js +39 -0
  64. package/dist/safe-js/runner/run-harness.d.ts +2 -0
  65. package/dist/safe-js/snapshot/backend.d.ts +2 -0
  66. package/package.json +9 -2
  67. package/dist/safe-js/chunks/chunk-FCCA27RC.js +0 -69
  68. package/dist/safe-js/chunks/chunk-FCCA27RC.js.map +0 -7
  69. package/dist/safe-js/chunks/chunk-LRSWTDIV.js.map +0 -7
  70. package/dist/safe-js/chunks/chunk-MFCEBCGV.js.map +0 -7
  71. package/dist/safe-js/chunks/chunk-MRULOD5J.js.map +0 -7
  72. package/dist/safe-js/chunks/chunk-MW2QLYVN.js.map +0 -7
  73. package/dist/safe-js/chunks/chunk-XX57YCGZ.js.map +0 -7
  74. package/dist/safe-js/chunks/chunk-Y5EZYHU6.js.map +0 -7
  75. package/dist/safe-js/chunks/cli-runtime-WSVW5DNT.js.map +0 -7
  76. package/dist/safe-js/chunks/fs-AOV77RQC.js +0 -13
  77. package/dist/safe-js/chunks/harness-ZIEO7NAV.js +0 -10
  78. package/dist/safe-js/chunks/mcp-E2AJXEQM.js +0 -11
  79. package/dist/safe-js/chunks/migration-file-3SWGNDS2.js +0 -12
  80. package/dist/safe-js/chunks/restore-FCTWPLU3.js +0 -13
  81. package/dist/safe-js/chunks/run-ESJHEXCE.js +0 -17
  82. package/dist/safe-js/chunks/runtime-modules-7V6BWCRK.js +0 -10
  83. package/dist/safe-js/chunks/source-files-73OHLNGH.js +0 -8
  84. /package/dist/safe-js/chunks/{chunk-VIMROAQA.js.map → chunk-E4XLBT7R.js.map} +0 -0
  85. /package/dist/safe-js/chunks/{chunk-OZLTLIHX.js.map → chunk-G6WTEIJJ.js.map} +0 -0
  86. /package/dist/safe-js/chunks/{chunk-EN724VH3.js.map → chunk-O4IDRXW7.js.map} +0 -0
  87. /package/dist/safe-js/chunks/{chunk-3LSNBW5N.js.map → chunk-P64CQIUA.js.map} +0 -0
  88. /package/dist/safe-js/chunks/{chunk-EA7AHM2X.js.map → chunk-PSVV3IG2.js.map} +0 -0
  89. /package/dist/safe-js/chunks/{chunk-EG3QWREA.js.map → chunk-RULU2F5J.js.map} +0 -0
  90. /package/dist/safe-js/chunks/{chunk-W3IY6FKO.js.map → chunk-WS2FJBH6.js.map} +0 -0
  91. /package/dist/safe-js/chunks/{chunk-MVLDRXWS.js.map → chunk-X3CKAZQ4.js.map} +0 -0
  92. /package/dist/safe-js/chunks/{dump-UNYK24YS.js.map → dump-RGRC3CG3.js.map} +0 -0
  93. /package/dist/safe-js/chunks/{fs-AOV77RQC.js.map → harness-UMOMFXDT.js.map} +0 -0
  94. /package/dist/safe-js/chunks/{harness-ZIEO7NAV.js.map → mcp-2Z4XWHKW.js.map} +0 -0
  95. /package/dist/safe-js/chunks/{mcp-E2AJXEQM.js.map → migration-file-KRXQYI3Q.js.map} +0 -0
  96. /package/dist/safe-js/chunks/{migration-file-3SWGNDS2.js.map → restore-GEO7VN2R.js.map} +0 -0
  97. /package/dist/safe-js/chunks/{restore-FCTWPLU3.js.map → run-ZSFX66RN.js.map} +0 -0
  98. /package/dist/safe-js/chunks/{run-ESJHEXCE.js.map → runtime-modules-A3U2DKFL.js.map} +0 -0
  99. /package/dist/safe-js/chunks/{runtime-modules-7V6BWCRK.js.map → source-files-L3SGK63Z.js.map} +0 -0
  100. /package/dist/safe-js/{chunks/source-files-73OHLNGH.js.map → modules/fs.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli-runtime.ts"],
4
+ "sourcesContent": ["import {createFsBridge, type FileSystem} from \"@poe-code/safe-fs/core\";\nimport {fsCodec} from \"./modules/fs-codec.js\";\nimport {createRootedSourceResolver} from \"./modules/source-files.js\";\nimport {parseSourceModule} from \"./parse/source-module.js\";\nimport { hostFs } from \"#safe-js-platform\";\nimport path, { dirname, extname } from \"./modules/paths.js\";\nimport { formatWithOptions } from \"#safe-js-platform\";\n\nimport { hasOwnErrorCode } from \"./error-codes.js\";\nimport { formatInterpreterError } from \"./error/format.js\";\nimport { replaceErrorStack } from \"./error/shape.js\";\nimport { Budget, SandboxError } from \"./interp/budget.js\";\nimport { countLineBreaks, extractBlock, maskSource } from \"./loader/extract-block.js\";\nimport { splitFrontmatter } from \"./loader/frontmatter.js\";\nimport { lint, type Diagnostic, type Fix } from \"./lint.js\";\nimport { makeAgentModule } from \"./modules/agent.js\";\nimport { makeEnvModule, parseEnvConfig, type EnvModuleOptions } from \"./modules/env.js\";\nimport { makeFailModule } from \"./modules/fail.js\";\nimport type { FsModuleOptions } from \"./modules/fs.js\";\nimport { parseFsConfig, resolveFsConfig } from \"./modules/fs-config.js\";\nimport { parseMcpConfig, type McpModuleOptions } from \"./modules/mcp-transport.js\";\nimport { makeLogModule, type LogModuleEntry } from \"./modules/log.js\";\nimport { makeMetricModule } from \"./modules/metric.js\";\nimport {\n createBrokenPipeState,\n createSafeOutputStream,\n withBrokenPipeGuard,\n type BrokenPipeState,\n type OutputStream\n} from \"./output-stream.js\";\nimport type { ModuleExports, ModuleRegistry } from \"./modules/registry.js\";\nimport { parseModule } from \"./parse/parser.js\";\nimport type { SafeJSSnapshot } from \"./restore.js\";\nimport type { RunResult } from \"./run.js\";\nimport type { SnapshotMigrationFileOptions } from \"./migration-file.js\";\n\ntype CliStream = OutputStream;\n\ntype CliProcess = Pick<NodeJS.Process, \"off\" | \"on\">;\n\ntype FileStats = {\n isFile(): boolean;\n};\n\nexport type ReadMarkdownFile = (filepath: string, encoding: \"utf8\") => Promise<string>;\nexport type WriteMarkdownFile = (\n filepath: string,\n source: string,\n options: { encoding: \"utf8\" }\n) => Promise<void>;\n\nexport type RunCliOptions = {\n adapter?: FileSystem;\n cwd?: string;\n env?: EnvModuleOptions;\n mcp?: McpModuleOptions;\n modulesFor?: (\n frontmatter: Record<string, unknown>,\n meta: HarnessMeta,\n streams: { stderr: CliStream; stdout: CliStream }\n ) => ModuleRegistry;\n process?: CliProcess;\n readFile?: ReadMarkdownFile;\n stat?: (filepath: string) => Promise<FileStats>;\n stdout?: CliStream;\n stderr?: CliStream;\n writeFile?: WriteMarkdownFile;\n};\n\ntype HarnessMeta = {\n filepath: string;\n kind: unknown;\n version: unknown;\n};\n\ntype ParsedArgs = {\n sourceType?: \"module\";\n sourceRoot?: string;\n filepath?: string;\n fix: boolean;\n fs: boolean;\n fsRoot?: string;\n fsConfig?: string;\n envConfig?: string;\n mcpConfig?: string;\n dataSize?: number;\n maxSteps?: number;\n restorePath?: string;\n snapshotPath?: string;\n};\n\ntype LoadedSource = {\n sourceOffset: number;\n fixRanges?: readonly Fix[\"range\"][];\n executableSource: string;\n frontmatter: Record<string, unknown>;\n isRawScript: boolean;\n rawSource: string;\n};\n\ntype CliRuntime = {\n registry: ModuleRegistry;\n};\n\nconst EXIT_RUNTIME = 1;\nconst EXIT_PARSE = 2;\nconst EXIT_BUDGET = 3;\nconst EXIT_SIGINT = 130;\n\nexport async function runCli(\n argv: readonly string[],\n options: RunCliOptions,\n usage: string\n): Promise<number> {\n const io = options.adapter ? createFsBridge(options.adapter, {codec: fsCodec}) : hostFs;\n const readFile = io.readFile.bind(io);\n const writeFile = io.writeFile.bind(io);\n const stat = io.stat.bind(io);\n const brokenPipe = createBrokenPipeState();\n const stdout = createSafeOutputStream(options.stdout ?? process.stdout, brokenPipe);\n const stderr = createSafeOutputStream(options.stderr ?? process.stderr, brokenPipe);\n\n return withBrokenPipeGuard(\n [options.stdout ?? process.stdout, options.stderr ?? process.stderr],\n brokenPipe,\n async () => {\n try {\n if (argv[0] === \"migrate\") {\n const { migrateSnapshotFile } = await import(\"./migration-file.js\");\n const result = await migrateSnapshotFile({\n ...parseMigrationArgs(argv.slice(1)),\n cwd: options.cwd ?? readCurrentWorkingDirectory(),\n adapter: options.adapter\n });\n stdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n return 0;\n }\n const parsed = parseArgs(argv);\n if (parsed.filepath === undefined) {\n stderr.write(`${usage}\\n`);\n return brokenPipe.closed ? 0 : EXIT_RUNTIME;\n }\n\n const cwd = options.cwd ?? readCurrentWorkingDirectory();\n const filepath = path.resolve(cwd, parsed.filepath);\n const configuredFs =\n parsed.fsConfig === undefined\n ? undefined\n : await resolveFsConfig(\n parseFsConfig(\n await (options.readFile ?? readFile)(path.resolve(cwd, parsed.fsConfig), \"utf8\")\n )\n );\n await assertHarnessFile({\n displayPath: parsed.filepath,\n filepath,\n statFile: options.stat ?? stat\n });\n\n return await runScriptFile(filepath, parsed, {\n cwd,\n configuredFs,\n adapter: options.adapter,\n env: options.env,\n mcp: options.mcp,\n modulesFor: options.modulesFor,\n process: options.process ?? process,\n readFile: options.readFile ?? readFile,\n brokenPipe,\n stderr,\n stdout,\n writeFile: options.writeFile ?? writeFile\n });\n } catch (error) {\n if (brokenPipe.closed) {\n return 0;\n }\n stderr.write(`${isParseError(error) ? formatInterpreterError(error) : readErrorMessage(error)}\\n`);\n return brokenPipe.closed\n ? 0\n : error instanceof CliExitError\n ? error.exitCode\n : exitCodeForError(error);\n }\n }\n );\n}\n\nfunction readCurrentWorkingDirectory(): string {\n try {\n return process.cwd();\n } catch (error) {\n throw new Error(`Unable to resolve current working directory: ${readErrorMessage(error)}`);\n }\n}\n\nfunction parseMigrationArgs(argv: readonly string[]): SnapshotMigrationFileOptions {\n const result: SnapshotMigrationFileOptions = { snapshotPath: \"\", sourcePath: \"\" };\n const paths = new Map<string, \"sourcePath\" | \"targetSourcePath\" | \"planPath\" | \"outputPath\">([\n [\"--from\", \"sourcePath\"],\n [\"--to\", \"targetSourcePath\"],\n [\"--plan\", \"planPath\"],\n [\"--output\", \"outputPath\"]\n ]);\n const seen = new Set<string>();\n for (let index = 0; index < argv.length; index += 1) {\n const argument = argv[index]!;\n if (!argument.startsWith(\"-\")) {\n if (result.snapshotPath.length > 0)\n throw new TypeError(\"Migration accepts exactly one snapshot path.\");\n result.snapshotPath = argument;\n continue;\n }\n if (seen.has(argument)) throw new TypeError(`Duplicate migration option: ${argument}`);\n seen.add(argument);\n if (argument === \"--inspect\") {\n result.inspect = true;\n continue;\n }\n if (argument === \"--dry-run\") {\n result.dryRun = true;\n continue;\n }\n const key = paths.get(argument);\n if (key === undefined) throw new TypeError(`Unknown migration option: ${argument}`);\n const value = argv[++index];\n if (value === undefined || value.startsWith(\"--\"))\n throw new TypeError(`${argument} requires a path.`);\n result[key] = value;\n }\n return result;\n}\n\nfunction parseArgs(argv: readonly string[]): ParsedArgs {\n const parsed: ParsedArgs = {\n fix: false,\n fs: false\n };\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n\n if (arg === \"--fix\") {\n parsed.fix = true;\n continue;\n }\n\n if (arg === \"--fs\") {\n parsed.fs = true;\n continue;\n }\n\n if (arg === \"--source-type\") {\n const type = readFlagValue(argv,index,arg);\n if (type !== \"module\") throw new CliExitError(\"--source-type must be module.\",EXIT_RUNTIME);\n parsed.sourceType = type;\n index += 1;\n continue;\n }\n if (arg === \"--source-root\") {\n parsed.sourceRoot = readFlagValue(argv,index,arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--fs-root\") {\n parsed.fsRoot = readFlagValue(argv, index, arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--fs-config\") {\n if (parsed.fsConfig !== undefined) {\n throw new CliExitError(\"--fs-config may be specified only once.\", EXIT_RUNTIME);\n }\n const value = readFlagValue(argv, index, arg);\n if (value.trim().length === 0 || value.startsWith(\"--\")) {\n throw new CliExitError(\"--fs-config needs a JSON file path.\", EXIT_RUNTIME);\n }\n parsed.fsConfig = value;\n index += 1;\n continue;\n }\n\n if (arg === \"--mcp-config\") {\n parsed.mcpConfig = readFlagValue(argv, index, arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--env-config\") {\n parsed.envConfig = readFlagValue(argv, index, arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--snapshot\") {\n parsed.snapshotPath = readFlagValue(argv, index, arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--restore\") {\n parsed.restorePath = readFlagValue(argv, index, arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--max-steps\") {\n parsed.maxSteps = readPositiveInteger(readFlagValue(argv, index, arg), arg);\n index += 1;\n continue;\n }\n\n if (arg === \"--data-size\") {\n parsed.dataSize = readPositiveInteger(readFlagValue(argv, index, arg), arg);\n index += 1;\n continue;\n }\n\n if (arg.startsWith(\"-\")) {\n throw new CliExitError(`Unknown flag: ${arg}`, EXIT_RUNTIME);\n }\n\n if (parsed.filepath !== undefined) {\n throw new CliExitError(`Unexpected argument: ${arg}`, EXIT_RUNTIME);\n }\n\n parsed.filepath = arg;\n }\n\n if (parsed.fsConfig !== undefined && (parsed.fs || parsed.fsRoot !== undefined)) {\n throw new CliExitError(\"--fs-config cannot be combined with --fs or --fs-root.\", EXIT_RUNTIME);\n }\n\n if (!parsed.fs && parsed.fsRoot !== undefined) {\n throw new CliExitError(\n \"--fs-root requires --fs. Pass --fs to give the script a filesystem confined to that root, or drop --fs-root.\",\n EXIT_RUNTIME\n );\n }\n\n return parsed;\n}\n\nfunction readFlagValue(argv: readonly string[], index: number, flag: string): string {\n const value = argv[index + 1];\n if (value === undefined || value.length === 0) {\n throw new CliExitError(`Missing value for ${flag}`, EXIT_RUNTIME);\n }\n\n return value;\n}\n\nfunction readPositiveInteger(value: string, flag: string): number {\n const parsed = Number(value);\n\n if (!Number.isInteger(parsed) || parsed <= 0) {\n throw new CliExitError(`${flag} must be a positive integer`, EXIT_RUNTIME);\n }\n\n return parsed;\n}\n\nasync function assertHarnessFile(input: {\n displayPath: string;\n filepath: string;\n statFile: (filepath: string) => Promise<FileStats>;\n}): Promise<void> {\n let stats: FileStats;\n try {\n stats = await input.statFile(input.filepath);\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) {\n throw new CliExitError(`File not found: ${input.displayPath}`, EXIT_RUNTIME);\n }\n\n throw error;\n }\n\n if (!stats.isFile()) {\n throw new CliExitError(`Harness path must point to a file: ${input.displayPath}`, EXIT_RUNTIME);\n }\n}\n\nasync function runScriptFile(\n filepath: string,\n parsed: ParsedArgs,\n options: {\n cwd: string;\n configuredFs: FsModuleOptions | undefined;\n env: EnvModuleOptions | undefined;\n mcp: McpModuleOptions | undefined;\n modulesFor: RunCliOptions[\"modulesFor\"];\n brokenPipe: BrokenPipeState;\n process: CliProcess;\n readFile: ReadMarkdownFile;\n stderr: CliStream;\n stdout: CliStream;\n writeFile: WriteMarkdownFile;\n adapter?: FileSystem;\n }\n): Promise<number> {\n const [{ run }, { restore }, { dump, dumpCurrent }, { createLintModulesFromRuntimeRegistry }, { makeFsModule }, { makeMcpModule }] = await Promise.all([\n import(\"./run.js\"), import(\"./restore.js\"), import(\"./snapshot/dump.js\"),\n import(\"./lint/runtime-modules.js\"), import(\"./modules/fs.js\"), import(\"./modules/mcp.js\")\n ]);\n const loaded = loadExecutableSource(filepath, await options.readFile(filepath, \"utf8\"));\n const meta = {\n filepath,\n kind: loaded.frontmatter.kind,\n version: loaded.frontmatter.version\n };\n const runtime = await createRuntime(loaded.frontmatter, meta, {\n fs: parsed.fs\n ? { root: path.resolve(options.cwd, parsed.fsRoot ?? dirname(filepath)), ...(options.adapter ? {adapter: options.adapter} : {}) }\n : undefined,\n modulesFor: options.modulesFor,\n stderr: options.stderr,\n stdout: options.stdout\n });\n if (options.configuredFs !== undefined) {\n const registry = new Map(\n runtime.registry instanceof Map ? runtime.registry : Object.entries(runtime.registry)\n );\n if (registry.has(\"fs\")) throw new TypeError(\"fs is already registered by modulesFor.\");\n registry.set(\"fs\", toModuleExports(makeFsModule(options.configuredFs)));\n runtime.registry = registry;\n }\n let env = options.env;\n if (parsed.envConfig !== undefined) {\n if (env !== undefined)\n throw new TypeError(\"Pass environment options or --env-config, not both.\");\n const configPath = path.resolve(options.cwd, parsed.envConfig);\n env = parseEnvConfig(await options.readFile(configPath, \"utf8\"));\n }\n if (env !== undefined) {\n const registry = new Map(\n runtime.registry instanceof Map ? runtime.registry : Object.entries(runtime.registry)\n );\n if (registry.has(\"env\"))\n throw new TypeError(\"Environment is already registered by modulesFor.\");\n registry.set(\"env\", makeEnvModule(env));\n runtime.registry = registry;\n }\n let mcp = options.mcp;\n if (parsed.mcpConfig !== undefined) {\n if (mcp !== undefined) throw new TypeError(\"Pass MCP options or --mcp-config, not both.\");\n const configPath = path.resolve(options.cwd, parsed.mcpConfig);\n mcp = parseMcpConfig(await options.readFile(configPath, \"utf8\"), dirname(configPath));\n }\n if (mcp !== undefined) {\n const registry = new Map(\n runtime.registry instanceof Map ? runtime.registry : Object.entries(runtime.registry)\n );\n if (registry.has(\"mcp\")) throw new TypeError(\"MCP is already registered by modulesFor.\");\n registry.set(\"mcp\", makeMcpModule(mcp));\n runtime.registry = registry;\n }\n const modules = excludeHarnessModule(runtime.registry, loaded.isRawScript);\n let executableSource = loaded.executableSource;\n const diagnosticFilename = parsed.filepath ?? filepath;\n if (parsed.sourceRoot !== undefined && parsed.sourceType !== \"module\")\n throw new CliExitError(\"--source-root requires --source-type module.\",EXIT_RUNTIME);\n if (parsed.sourceType === \"module\") {\n if (parsed.fix) throw new CliExitError(\"--fix applies to harness sources, not source modules.\",EXIT_RUNTIME);\n parseSourceModule(executableSource,diagnosticFilename);\n }\n const lintResult = parsed.sourceType === \"module\" ? [] : parsed.fix\n ? lint(executableSource, {\n allowedExportNames: [\"schema\"],\n filename: diagnosticFilename,\n fix: true,\n fixRanges: loaded.fixRanges,\n frontmatterFields: Object.keys(loaded.frontmatter),\n modules: createLintModulesFromRuntimeRegistry(modules)\n })\n : lint(executableSource, {\n allowedExportNames: [\"schema\"],\n filename: diagnosticFilename,\n frontmatterFields: Object.keys(loaded.frontmatter),\n modules: createLintModulesFromRuntimeRegistry(modules)\n });\n const diagnostics = Array.isArray(lintResult) ? lintResult : lintResult.diagnostics;\n\n if (!Array.isArray(lintResult)) {\n executableSource = lintResult.fixed;\n if (lintResult.fixed !== loaded.executableSource) {\n await options.writeFile(\n filepath,\n replaceExecutableSource(loaded.rawSource, loaded, lintResult.fixes),\n {\n encoding: \"utf8\"\n }\n );\n }\n }\n\n const lintErrors = diagnostics.filter((diagnostic) => diagnostic.severity === \"error\");\n if (lintErrors.length > 0) {\n options.stderr.write(`Lint failed:\\n${formatDiagnostics(lintErrors)}\\n`);\n if (options.brokenPipe.closed) {\n return 0;\n }\n return lintErrors.some((diagnostic) => diagnostic.code === \"AS001\") ? EXIT_PARSE : EXIT_RUNTIME;\n }\n\n const lintWarnings = diagnostics.filter((diagnostic) => diagnostic.severity === \"warning\");\n if (lintWarnings.length > 0) {\n options.stderr.write(`Lint warnings:\\n${formatDiagnostics(lintWarnings)}\\n`);\n if (options.brokenPipe.closed) {\n return 0;\n }\n }\n\n const snapshot = await readRestoreSnapshot(parsed.restorePath, options);\n if (snapshot !== undefined) {\n restore(snapshot, { source: executableSource });\n }\n\n const abortController = new AbortController();\n let interrupted = false;\n let runPromise: Promise<RunResult> | undefined;\n let signalSnapshotWrite: Promise<void> | undefined;\n const onSigint = () => {\n interrupted = true;\n abortController.abort(createAbortError());\n options.stderr.write(\"Interrupted by SIGINT\\n\");\n\n if (parsed.snapshotPath !== undefined && runPromise !== undefined) {\n signalSnapshotWrite = writeCurrentSnapshot(runPromise, parsed.snapshotPath, options, dumpCurrent);\n }\n };\n\n const sourceResolver = parsed.sourceRoot !== undefined && options.adapter !== undefined\n ? await createRootedSourceResolver(path.resolve(options.cwd, parsed.sourceRoot), options.adapter)\n : undefined;\n options.process.on(\"SIGINT\", onSigint);\n try {\n runPromise = run(executableSource, {\n budget:\n parsed.maxSteps === undefined && parsed.dataSize === undefined\n ? undefined\n : new Budget({ dataSize: parsed.dataSize, maxSteps: parsed.maxSteps }),\n entryPointArgs: parsed.sourceType === \"module\" ? undefined : hasDefaultExport(executableSource, diagnosticFilename) ? [] : undefined,\n sourceType:parsed.sourceType,\n sourceResolver,\n sourceRoot:sourceResolver !== undefined || parsed.sourceRoot === undefined ? undefined : path.resolve(options.cwd,parsed.sourceRoot),\n filename: sourceResolver === undefined ? diagnosticFilename : await sourceResolver.entryId(filepath),\n modules,\n signal: abortController.signal,\n sink: createConsoleSink(options.stdout, options.stderr),\n snapshot\n });\n const result = await runPromise;\n await signalSnapshotWrite;\n\n if (options.brokenPipe.closed) {\n return 0;\n }\n\n if (parsed.snapshotPath !== undefined) {\n await writeSnapshot(parsed.snapshotPath, await dump(result), options);\n }\n\n if (!result.ok) {\n options.stderr.write(\n `${formatInterpreterError(result.error, {\n filename: diagnosticFilename,\n source: executableSource\n })}\\n`\n );\n if (options.brokenPipe.closed) {\n return 0;\n }\n return interrupted ? EXIT_SIGINT : exitCodeForError(result.error);\n }\n\n options.stdout.write(`${JSON.stringify({ ok: true, returnValue: result.returnValue })}\\n`);\n return options.brokenPipe.closed ? 0 : interrupted ? EXIT_SIGINT : 0;\n } catch (error) {\n await signalSnapshotWrite;\n if (parsed.snapshotPath !== undefined && runPromise !== undefined) {\n try {\n await writeSnapshot(\n parsed.snapshotPath,\n await dump(runPromise, { onFailure: \"checkpoint\" }),\n options\n );\n } catch (snapshotError) {\n options.stderr.write(\n `Failed to write recovery snapshot at ${parsed.snapshotPath}: ${readErrorMessage(snapshotError)}. Any existing snapshot may be stale.\\n`\n );\n }\n }\n if (options.brokenPipe.closed) {\n return 0;\n }\n options.stderr.write(\n `${formatInterpreterError(error, {\n filename: diagnosticFilename,\n source: executableSource\n })}\\n`\n );\n return options.brokenPipe.closed ? 0 : interrupted ? EXIT_SIGINT : exitCodeForError(error);\n } finally {\n options.process.off(\"SIGINT\", onSigint);\n }\n}\n\nfunction loadExecutableSource(filepath: string, rawSource: string): LoadedSource {\n const source = stripByteOrderMark(rawSource);\n const byteOrderMarkLength = rawSource.length - source.length;\n\n if (isRawScriptExtension(extname(filepath))) {\n return {\n sourceOffset: byteOrderMarkLength,\n executableSource: source,\n frontmatter: {},\n isRawScript: true,\n rawSource\n };\n }\n\n const { frontmatter, body } = splitFrontmatter(source);\n const bodyStartOffset = rawSource.length - body.length;\n const executableBlock = extractBlock(body, countLineBreaks(rawSource, 0, bodyStartOffset) + 1);\n\n return {\n sourceOffset: 0,\n fixRanges: executableBlock.ranges.map(([start, end]) => [\n bodyStartOffset + start,\n bodyStartOffset + end\n ]),\n executableSource:\n maskSource(rawSource.slice(0, bodyStartOffset + executableBlock.startOffset)) +\n executableBlock.source,\n frontmatter,\n isRawScript: false,\n rawSource\n };\n}\n\nfunction isRawScriptExtension(extension: string): boolean {\n return extension === \".safejs\" || extension === \".ajs\";\n}\n\nfunction replaceExecutableSource(\n source: string,\n loaded: LoadedSource,\n fixes: readonly Fix[]\n): string {\n return fixes.reduce(\n (result, fix) =>\n `${result.slice(0, loaded.sourceOffset + fix.range[0])}${fix.replacement}${result.slice(loaded.sourceOffset + fix.range[1])}`,\n source\n );\n}\n\nasync function createRuntime(\n frontmatter: Record<string, unknown>,\n meta: HarnessMeta,\n options: {\n fs: FsModuleOptions | undefined;\n modulesFor: RunCliOptions[\"modulesFor\"];\n stderr: CliStream;\n stdout: CliStream;\n }\n): Promise<CliRuntime> {\n if (options.modulesFor !== undefined) {\n return {\n registry: options.modulesFor(frontmatter, meta, {\n stderr: options.stderr,\n stdout: options.stdout\n })\n };\n }\n\n const [{ makeHarnessModule }, { makeFsModule }] = await Promise.all([\n import(\"./modules/harness.js\"), import(\"./modules/fs.js\")\n ]);\n const state = {\n metricCalls: new Map<string, number>(),\n spawnCount: 0\n };\n const harness = makeHarnessModule(frontmatter, meta);\n const agent = makeAgentModule(async (input) => {\n state.spawnCount += 1;\n\n return {\n exitCode: 0,\n stdout: \"\",\n stderr: \"\",\n summary: `${input.agent} handled ${summarizePrompt(input.prompt)}`,\n durationMs: 25 * state.spawnCount\n };\n });\n const log = makeLogModule((entry) => {\n const normalized = normalizeLogEntry(entry);\n const stream = normalized.type === \"error\" ? options.stderr : options.stdout;\n stream.write(`${JSON.stringify(normalized)}\\n`);\n });\n const metric = makeMetricModule(async (scriptName) => `${readMetricScore(scriptName, state)}\\n`);\n\n return {\n registry: {\n agent: toModuleExports(agent),\n fail: toModuleExports(new Map([[\"default\", makeFailModule().default]])),\n // The one module here that is not a stub, so it is registered only when asked for.\n ...(options.fs === undefined ? {} : { fs: toModuleExports(makeFsModule(options.fs)) }),\n harness: toModuleExports(harness),\n log: toModuleExports(log),\n metric: toModuleExports(metric)\n }\n };\n}\n\nasync function readRestoreSnapshot(\n restorePath: string | undefined,\n options: {\n cwd: string;\n readFile: ReadMarkdownFile;\n }\n): Promise<SafeJSSnapshot | undefined> {\n if (restorePath === undefined) {\n return undefined;\n }\n\n const snapshotPath = path.resolve(options.cwd, restorePath);\n let rawSnapshot: string;\n try {\n rawSnapshot = await options.readFile(snapshotPath, \"utf8\");\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) {\n throw new CliExitError(`Snapshot not found: ${restorePath}`, EXIT_RUNTIME);\n }\n\n throw error;\n }\n\n try {\n return JSON.parse(rawSnapshot) as SafeJSSnapshot;\n } catch (error) {\n throw new Error(`Failed to parse snapshot at ${restorePath}: ${readErrorMessage(error)}`);\n }\n}\n\nasync function writeCurrentSnapshot(\n result: PromiseLike<RunResult>,\n snapshotPath: string,\n options: {\n cwd: string;\n stderr: CliStream;\n writeFile: WriteMarkdownFile;\n adapter?: FileSystem;\n },\n capture: typeof import(\"./snapshot/dump.js\").dumpCurrent\n): Promise<void> {\n try {\n await writeSnapshot(snapshotPath, await capture(result), options);\n } catch (error) {\n options.stderr.write(\n `Failed to write snapshot at ${snapshotPath}: ${readErrorMessage(error)}\\n`\n );\n }\n}\n\nasync function writeSnapshot(\n snapshotPath: string,\n content: string,\n options: {\n cwd: string;\n writeFile: WriteMarkdownFile;\n adapter?: FileSystem;\n }\n): Promise<void> {\n const resolvedPath = path.resolve(options.cwd, snapshotPath);\n await (options.adapter ? createFsBridge(options.adapter, {codec: fsCodec}) : hostFs).mkdir(dirname(resolvedPath), { recursive: true });\n await options.writeFile(resolvedPath, content, { encoding: \"utf8\" });\n}\n\nfunction createConsoleSink(\n stdout: CliStream,\n stderr: CliStream\n): {\n error: (...args: unknown[]) => void;\n log: (...args: unknown[]) => void;\n} {\n return {\n error(...args) {\n stderr.write(`${formatConsoleArgs(args)}\\n`);\n },\n log(...args) {\n stdout.write(`${formatConsoleArgs(args)}\\n`);\n }\n };\n}\n\nfunction formatConsoleArgs(args: readonly unknown[]): string {\n return formatWithOptions({ colors: false, depth: 4 }, ...args);\n}\n\nfunction formatDiagnostics(diagnostics: readonly Diagnostic[]): string {\n return diagnostics\n .map(\n (diagnostic) =>\n `${diagnostic.filename}:${diagnostic.line}:${diagnostic.column} ${diagnostic.code} ${diagnostic.message}`\n )\n .join(\"\\n\");\n}\n\nexport function exitCodeForError(error: unknown): number {\n if (error instanceof SandboxError && error.code === \"budgetExceeded\") {\n return EXIT_BUDGET;\n }\n\n if (isParseError(error)) {\n return EXIT_PARSE;\n }\n\n return EXIT_RUNTIME;\n}\n\nfunction isParseError(error: unknown): boolean {\n return error instanceof Error && (error.name === \"ParseError\" ||\n (\"kind\" in error && error.kind === \"ParseError\"));\n}\n\nfunction hasDefaultExport(source: string, filename: string): boolean {\n return parseModule(source, filename).body.some(\n (statement) => statement.type === \"ExportDefaultDeclaration\"\n );\n}\n\nfunction excludeHarnessModule(modules: ModuleRegistry, isRawScript: boolean): ModuleRegistry {\n if (!isRawScript) {\n return modules;\n }\n\n if (modules instanceof Map) {\n const rawModules = new Map(modules);\n rawModules.delete(\"harness\");\n return rawModules;\n }\n\n const rawModules = Object.create(null) as Record<string, ModuleExports>;\n\n for (const [moduleName, moduleExports] of Object.entries(modules)) {\n if (moduleName !== \"harness\") {\n rawModules[moduleName] = moduleExports;\n }\n }\n\n return rawModules;\n}\n\nfunction stripByteOrderMark(source: string): string {\n return source.startsWith(\"\\uFEFF\") ? source.slice(1) : source;\n}\n\nfunction normalizeLogEntry(entry: LogModuleEntry): LogModuleEntry {\n return {\n ...entry,\n ts: \"2026-04-29T00:00:00.000Z\"\n };\n}\n\nfunction summarizePrompt(prompt: string): string {\n const normalizedPrompt = prompt.trim().replaceAll(\"\\n\", \" \");\n return normalizedPrompt.length <= 48 ? normalizedPrompt : `${normalizedPrompt.slice(0, 45)}...`;\n}\n\nfunction readMetricScore(\n scriptName: string,\n state: {\n metricCalls: Map<string, number>;\n }\n): number {\n const callCount = (state.metricCalls.get(scriptName) ?? 0) + 1;\n state.metricCalls.set(scriptName, callCount);\n\n if (scriptName === \"tests\" && callCount === 1) {\n return 10;\n }\n\n if (scriptName === \"tests\" && callCount === 2) {\n return 9;\n }\n\n return 9 + callCount;\n}\n\nfunction toModuleExports(value: unknown): ModuleExports {\n return value as ModuleExports;\n}\n\nfunction createAbortError(): Error {\n if (typeof DOMException === \"function\") {\n const error = new DOMException(\"This operation was aborted\", \"AbortError\");\n replaceErrorStack(error);\n return error;\n }\n\n const error = new Error(\"This operation was aborted\");\n error.name = \"AbortError\";\n replaceErrorStack(error);\n return error;\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n return hasOwnErrorCode(error, code);\n}\n\nfunction readErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n if (\"filename\" in error && typeof error.filename === \"string\") {\n return `${error.name}: ${error.filename}\\n\\n${error.message}`;\n }\n return error.message;\n }\n\n return String(error);\n}\n\nclass CliExitError extends Error {\n readonly exitCode: number;\n\n constructor(message: string, exitCode: number) {\n super(message);\n this.name = \"CliExitError\";\n this.exitCode = exitCode;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQ,sBAAsC;AAwG9C,IAAM,eAAe;AACrB,IAAM,aAAa;AACnB,IAAM,cAAc;AACpB,IAAM,cAAc;AAEpB,eAAsB,OACpB,MACA,SACA,OACiB;AACjB,QAAM,KAAK,QAAQ,UAAU,eAAe,QAAQ,SAAS,EAAC,OAAO,QAAO,CAAC,IAAI;AACjF,QAAM,WAAW,GAAG,SAAS,KAAK,EAAE;AACpC,QAAM,YAAY,GAAG,UAAU,KAAK,EAAE;AACtC,QAAM,OAAO,GAAG,KAAK,KAAK,EAAE;AAC5B,QAAM,aAAa,sBAAsB;AACzC,QAAM,SAAS,uBAAuB,QAAQ,UAAU,QAAQ,QAAQ,UAAU;AAClF,QAAM,SAAS,uBAAuB,QAAQ,UAAU,QAAQ,QAAQ,UAAU;AAElF,SAAO;AAAA,IACL,CAAC,QAAQ,UAAU,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,MAAM;AAAA,IACnE;AAAA,IACA,YAAY;AACV,UAAI;AACF,YAAI,KAAK,CAAC,MAAM,WAAW;AACzB,gBAAM,EAAE,oBAAoB,IAAI,MAAM,OAAO,8BAAqB;AAClE,gBAAM,SAAS,MAAM,oBAAoB;AAAA,YACvC,GAAG,mBAAmB,KAAK,MAAM,CAAC,CAAC;AAAA,YACnC,KAAK,QAAQ,OAAO,4BAA4B;AAAA,YAChD,SAAS,QAAQ;AAAA,UACnB,CAAC;AACD,iBAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,CAAI;AACnD,iBAAO;AAAA,QACT;AACA,cAAM,SA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AAAA;AAAA,EAAO,MAAM,OAAO;AAAA,IAC7D;AACA,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,OAAO,KAAK;AACrB;AAEA,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtB;AAAA,EAET,YAAY,SAAiB,UAAkB;AAC7C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;",
6
+ "names": ["rawModules", "error"]
7
+ }
@@ -4,9 +4,10 @@ import {
4
4
  dump,
5
5
  dumpCurrent,
6
6
  serializeRunSnapshot
7
- } from "./chunk-MVLDRXWS.js";
8
- import "./chunk-S5YDMMM3.js";
9
- import "./chunk-Y5EZYHU6.js";
7
+ } from "./chunk-X3CKAZQ4.js";
8
+ import "./chunk-MDIWQFYU.js";
9
+ import "./chunk-QKO4FATZ.js";
10
+ import "./chunk-UQPYTZOZ.js";
10
11
  import "./chunk-4YIDX44G.js";
11
12
  export {
12
13
  attachDumpController,
@@ -15,4 +16,4 @@ export {
15
16
  dumpCurrent,
16
17
  serializeRunSnapshot
17
18
  };
18
- //# sourceMappingURL=dump-UNYK24YS.js.map
19
+ //# sourceMappingURL=dump-RGRC3CG3.js.map
@@ -0,0 +1,11 @@
1
+ import {
2
+ makeHarnessModule
3
+ } from "./chunk-WS2FJBH6.js";
4
+ import "./chunk-MDIWQFYU.js";
5
+ import "./chunk-QKO4FATZ.js";
6
+ import "./chunk-UQPYTZOZ.js";
7
+ import "./chunk-4YIDX44G.js";
8
+ export {
9
+ makeHarnessModule
10
+ };
11
+ //# sourceMappingURL=harness-UMOMFXDT.js.map
@@ -0,0 +1,12 @@
1
+ import {
2
+ makeMcpModule
3
+ } from "./chunk-P64CQIUA.js";
4
+ import "./chunk-3ITVV2R6.js";
5
+ import "./chunk-MDIWQFYU.js";
6
+ import "./chunk-QKO4FATZ.js";
7
+ import "./chunk-UQPYTZOZ.js";
8
+ import "./chunk-4YIDX44G.js";
9
+ export {
10
+ makeMcpModule
11
+ };
12
+ //# sourceMappingURL=mcp-2Z4XWHKW.js.map
@@ -0,0 +1,15 @@
1
+ import {
2
+ migrateSnapshotFile
3
+ } from "./chunk-W4SWUHCQ.js";
4
+ import "./chunk-GVKXZW53.js";
5
+ import "./chunk-2GVBG23M.js";
6
+ import "./chunk-PSVV3IG2.js";
7
+ import "./chunk-MDIWQFYU.js";
8
+ import "./chunk-QKO4FATZ.js";
9
+ import "./chunk-YUQFFRUF.js";
10
+ import "./chunk-UQPYTZOZ.js";
11
+ import "./chunk-4YIDX44G.js";
12
+ export {
13
+ migrateSnapshotFile
14
+ };
15
+ //# sourceMappingURL=migration-file-KRXQYI3Q.js.map
@@ -0,0 +1,14 @@
1
+ import {
2
+ SnapshotMismatchError,
3
+ restore
4
+ } from "./chunk-O4IDRXW7.js";
5
+ import "./chunk-PSVV3IG2.js";
6
+ import "./chunk-MDIWQFYU.js";
7
+ import "./chunk-QKO4FATZ.js";
8
+ import "./chunk-UQPYTZOZ.js";
9
+ import "./chunk-4YIDX44G.js";
10
+ export {
11
+ SnapshotMismatchError,
12
+ restore
13
+ };
14
+ //# sourceMappingURL=restore-GEO7VN2R.js.map
@@ -0,0 +1,20 @@
1
+ import {
2
+ UnhandledRejectionError,
3
+ run
4
+ } from "./chunk-GNEORAQI.js";
5
+ import "./chunk-U7ZNMTSQ.js";
6
+ import "./chunk-GVKXZW53.js";
7
+ import "./chunk-2GVBG23M.js";
8
+ import "./chunk-O4IDRXW7.js";
9
+ import "./chunk-PSVV3IG2.js";
10
+ import "./chunk-X3CKAZQ4.js";
11
+ import "./chunk-MDIWQFYU.js";
12
+ import "./chunk-QKO4FATZ.js";
13
+ import "./chunk-YUQFFRUF.js";
14
+ import "./chunk-UQPYTZOZ.js";
15
+ import "./chunk-4YIDX44G.js";
16
+ export {
17
+ UnhandledRejectionError,
18
+ run
19
+ };
20
+ //# sourceMappingURL=run-ZSFX66RN.js.map
@@ -0,0 +1,11 @@
1
+ import {
2
+ createLintModulesFromRuntimeRegistry
3
+ } from "./chunk-E4XLBT7R.js";
4
+ import "./chunk-MDIWQFYU.js";
5
+ import "./chunk-QKO4FATZ.js";
6
+ import "./chunk-UQPYTZOZ.js";
7
+ import "./chunk-4YIDX44G.js";
8
+ export {
9
+ createLintModulesFromRuntimeRegistry
10
+ };
11
+ //# sourceMappingURL=runtime-modules-A3U2DKFL.js.map
@@ -0,0 +1,10 @@
1
+ import {
2
+ createRootedSourceResolver
3
+ } from "./chunk-F6CV74HU.js";
4
+ import "./chunk-YUQFFRUF.js";
5
+ import "./chunk-UQPYTZOZ.js";
6
+ import "./chunk-4YIDX44G.js";
7
+ export {
8
+ createRootedSourceResolver
9
+ };
10
+ //# sourceMappingURL=source-files-L3SGK63Z.js.map
@@ -1,3 +1,4 @@
1
+ import { type FileSystem } from "@poe-platform/safe-fs/core";
1
2
  import { type EnvModuleOptions } from "./modules/env.js";
2
3
  import { type McpModuleOptions } from "./modules/mcp-transport.js";
3
4
  import { type OutputStream } from "./output-stream.js";
@@ -12,6 +13,7 @@ export type WriteMarkdownFile = (filepath: string, source: string, options: {
12
13
  encoding: "utf8";
13
14
  }) => Promise<void>;
14
15
  export type RunCliOptions = {
16
+ adapter?: FileSystem;
15
17
  cwd?: string;
16
18
  env?: EnvModuleOptions;
17
19
  mcp?: McpModuleOptions;
@@ -3,8 +3,8 @@ import {
3
3
  createBrokenPipeState,
4
4
  createSafeOutputStream,
5
5
  withBrokenPipeGuard
6
- } from "./chunks/chunk-OZLTLIHX.js";
7
- import "./chunks/chunk-SJZWSPWD.js";
6
+ } from "./chunks/chunk-G6WTEIJJ.js";
7
+ import "./chunks/chunk-2GVBG23M.js";
8
8
  import "./chunks/chunk-4YIDX44G.js";
9
9
 
10
10
  // packages/safe-js/src/cli.ts
@@ -13,7 +13,7 @@ import path from "node:path";
13
13
  import { fileURLToPath } from "node:url";
14
14
  async function runCli(argv, options = {}) {
15
15
  if (!argv.includes("--help") && !argv.includes("-h")) {
16
- const runtime = await import("./chunks/cli-runtime-WSVW5DNT.js");
16
+ const runtime = await import("./chunks/cli-runtime-ZSOTNIVC.js");
17
17
  return runtime.runCli(argv, options, createUsage());
18
18
  }
19
19
  const brokenPipe = createBrokenPipeState();
@@ -32,7 +32,7 @@ async function runCli(argv, options = {}) {
32
32
  stderr.write(`${error instanceof Error ? error.message : String(error)}
33
33
  `);
34
34
  if (brokenPipe.closed) return 0;
35
- const { exitCodeForError } = await import("./chunks/cli-runtime-WSVW5DNT.js");
35
+ const { exitCodeForError } = await import("./chunks/cli-runtime-ZSOTNIVC.js");
36
36
  return exitCodeForError(error);
37
37
  }
38
38
  }
@@ -11,3 +11,4 @@ export type { RunClock, RunClockSnapshot, RunRandom } from "./run.js";
11
11
  export { Budget } from "./interp/budget.js";
12
12
  export type { SnapshotValidationCode } from "./snapshot/validation.js";
13
13
  export type { SourceResolver, SourceModule } from "./modules/source-graph.js";
14
+ export { createRootedSourceResolver } from "./modules/source-files.js";
@@ -1,29 +1,36 @@
1
1
  import {
2
2
  lint
3
- } from "./chunks/chunk-EG3QWREA.js";
3
+ } from "./chunks/chunk-RULU2F5J.js";
4
+ import {
5
+ createRootedSourceResolver
6
+ } from "./chunks/chunk-F6CV74HU.js";
4
7
  import {
5
8
  createRealm,
6
9
  createReplayableRandom,
7
10
  run
8
- } from "./chunks/chunk-XX57YCGZ.js";
11
+ } from "./chunks/chunk-GNEORAQI.js";
9
12
  import "./chunks/chunk-U7ZNMTSQ.js";
10
- import "./chunks/chunk-EN724VH3.js";
11
- import "./chunks/chunk-MVLDRXWS.js";
12
- import "./chunks/chunk-SJZWSPWD.js";
13
- import "./chunks/chunk-EA7AHM2X.js";
13
+ import "./chunks/chunk-GVKXZW53.js";
14
+ import "./chunks/chunk-2GVBG23M.js";
15
+ import "./chunks/chunk-O4IDRXW7.js";
16
+ import "./chunks/chunk-PSVV3IG2.js";
17
+ import "./chunks/chunk-X3CKAZQ4.js";
14
18
  import {
15
19
  admitNativePromiseProperties,
16
20
  defineExtension
17
- } from "./chunks/chunk-S5YDMMM3.js";
21
+ } from "./chunks/chunk-MDIWQFYU.js";
18
22
  import {
19
23
  Budget
20
- } from "./chunks/chunk-Y5EZYHU6.js";
24
+ } from "./chunks/chunk-QKO4FATZ.js";
25
+ import "./chunks/chunk-YUQFFRUF.js";
26
+ import "./chunks/chunk-UQPYTZOZ.js";
21
27
  import "./chunks/chunk-4YIDX44G.js";
22
28
  export {
23
29
  Budget,
24
30
  admitNativePromiseProperties,
25
31
  createRealm,
26
32
  createReplayableRandom,
33
+ createRootedSourceResolver,
27
34
  defineExtension,
28
35
  lint,
29
36
  run
@@ -0,0 +1,170 @@
1
+ import { internalSymbols } from "../interp/internal-symbols.js";
2
+ const wrappedErrorCause = Symbol("wrappedErrorCause");
3
+ internalSymbols.add(wrappedErrorCause);
4
+ export const sandboxErrorNames = [
5
+ "Error",
6
+ "TypeError",
7
+ "RangeError",
8
+ "ReferenceError",
9
+ "SyntaxError",
10
+ "URIError",
11
+ "EvalError",
12
+ "AbortError",
13
+ "AggregateError",
14
+ "SuppressedError",
15
+ "HarnessFailure"
16
+ ];
17
+ export const sandboxErrorTypes = new WeakMap();
18
+ export const hostErrorData = new WeakMap();
19
+ export function formatErrorStack(name, message, stackFrames = []) {
20
+ const header = message.length === 0 ? name : `${name}: ${message}`;
21
+ return [header, ...stackFrames].join("\n");
22
+ }
23
+ export function replaceErrorStack(error, stackFrames = []) {
24
+ error.stack = formatErrorStack(error.name, error.message, stackFrames);
25
+ }
26
+ export function attachErrorSpan(error, span) {
27
+ if (span === undefined || hasOwnProperty(error, "span")) {
28
+ return;
29
+ }
30
+ Object.defineProperty(error, "span", {
31
+ configurable: true,
32
+ value: span
33
+ });
34
+ }
35
+ export function attachErrorCause(error, cause) {
36
+ if (cause === undefined || hasOwnProperty(error, "cause")) {
37
+ return;
38
+ }
39
+ Object.defineProperty(error, "cause", {
40
+ configurable: true,
41
+ value: cause
42
+ });
43
+ }
44
+ export function attachWrappedErrorCause(error, cause) {
45
+ if (cause === undefined || wrappedErrorCause in error) {
46
+ return;
47
+ }
48
+ Object.defineProperty(error, wrappedErrorCause, {
49
+ configurable: true,
50
+ value: cause
51
+ });
52
+ }
53
+ export function materializeWrappedErrorCause(value) {
54
+ if (typeof value !== "object" || value === null || !(wrappedErrorCause in value)) {
55
+ return;
56
+ }
57
+ attachErrorCause(value, value[wrappedErrorCause]);
58
+ }
59
+ export function readErrorSpan(value) {
60
+ if (typeof value !== "object" || value === null || !hasOwnProperty(value, "span")) {
61
+ return undefined;
62
+ }
63
+ const span = value.span;
64
+ return isErrorSourceSpan(span) ? span : undefined;
65
+ }
66
+ export function readErrorCause(value) {
67
+ return typeof value === "object" && value !== null && hasOwnProperty(value, "cause")
68
+ ? value.cause
69
+ : undefined;
70
+ }
71
+ export function isErrorSourceSpan(value) {
72
+ if (typeof value !== "object" ||
73
+ value === null ||
74
+ !hasOwnProperty(value, "start") ||
75
+ !hasOwnProperty(value, "end")) {
76
+ return false;
77
+ }
78
+ return isErrorSourcePosition(value.start) && isErrorSourcePosition(value.end);
79
+ }
80
+ export function createSourceSpan(source, line, column, endLine, endColumn) {
81
+ const start = createSourcePosition(source, line, column);
82
+ const rawEnd = createSourcePosition(source, endLine, endColumn);
83
+ const end = rawEnd.offset > start.offset
84
+ ? rawEnd
85
+ : createSourcePositionFromOffset(source, Math.min(start.offset + 1, source.length));
86
+ return { start, end };
87
+ }
88
+ export function describeThrownValue(value) {
89
+ if (value instanceof Error) {
90
+ return value.message.length > 0 ? `${value.name}: ${value.message}` : value.name;
91
+ }
92
+ if (typeof value === "string") {
93
+ return value;
94
+ }
95
+ if (value === undefined ||
96
+ value === null ||
97
+ typeof value === "number" ||
98
+ typeof value === "boolean" ||
99
+ typeof value === "bigint" ||
100
+ typeof value === "symbol") {
101
+ return String(value);
102
+ }
103
+ try {
104
+ const serialized = JSON.stringify(value);
105
+ return serialized === undefined ? String(value) : serialized;
106
+ }
107
+ catch {
108
+ return String(value);
109
+ }
110
+ }
111
+ function isErrorSourcePosition(value) {
112
+ return (typeof value === "object" &&
113
+ value !== null &&
114
+ hasOwnProperty(value, "line") &&
115
+ typeof value.line === "number" &&
116
+ hasOwnProperty(value, "column") &&
117
+ typeof value.column === "number" &&
118
+ hasOwnProperty(value, "offset") &&
119
+ typeof value.offset === "number");
120
+ }
121
+ function hasOwnProperty(value, name) {
122
+ return Object.prototype.hasOwnProperty.call(value, name);
123
+ }
124
+ function createSourcePosition(source, line, column) {
125
+ return createSourcePositionFromOffset(source, findSourceOffset(source, line, column));
126
+ }
127
+ function createSourcePositionFromOffset(source, offset) {
128
+ let line = 1;
129
+ let column = 1;
130
+ for (let index = 0; index < offset; index += 1) {
131
+ const character = source[index];
132
+ if (character === "\r" || character === "\n" || character === "\u2028" || character === "\u2029") {
133
+ if (character === "\r" && source[index + 1] === "\n" && index + 1 < offset)
134
+ index += 1;
135
+ line += 1;
136
+ column = 1;
137
+ }
138
+ else {
139
+ column += 1;
140
+ }
141
+ }
142
+ return {
143
+ column,
144
+ line,
145
+ offset
146
+ };
147
+ }
148
+ function findSourceOffset(source, line, column) {
149
+ let currentLine = 1;
150
+ let currentColumn = 1;
151
+ for (let offset = 0; offset <= source.length; offset += 1) {
152
+ if (currentLine === line && currentColumn === column) {
153
+ return offset;
154
+ }
155
+ const character = source[offset];
156
+ if (character === undefined) {
157
+ return source.length;
158
+ }
159
+ if (character === "\r" || character === "\n" || character === "\u2028" || character === "\u2029") {
160
+ if (character === "\r" && source[offset + 1] === "\n")
161
+ offset += 1;
162
+ currentLine += 1;
163
+ currentColumn = 1;
164
+ }
165
+ else {
166
+ currentColumn += 1;
167
+ }
168
+ }
169
+ return source.length;
170
+ }
@@ -1,15 +1,17 @@
1
1
  import {
2
- createLintModulesFromRuntimeRegistry
3
- } from "./chunks/chunk-VIMROAQA.js";
2
+ inspectSnapshotMigration,
3
+ migrateSnapshot,
4
+ migrateSnapshotFile
5
+ } from "./chunks/chunk-W4SWUHCQ.js";
4
6
  import {
5
- makeFsModule
6
- } from "./chunks/chunk-MRULOD5J.js";
7
+ createLintModulesFromRuntimeRegistry
8
+ } from "./chunks/chunk-E4XLBT7R.js";
7
9
  import {
8
10
  makeHarnessModule
9
- } from "./chunks/chunk-W3IY6FKO.js";
11
+ } from "./chunks/chunk-WS2FJBH6.js";
10
12
  import {
11
13
  makeMcpModule
12
- } from "./chunks/chunk-3LSNBW5N.js";
14
+ } from "./chunks/chunk-P64CQIUA.js";
13
15
  import {
14
16
  AgentSpawnError,
15
17
  EnvAccessError,
@@ -30,39 +32,40 @@ import {
30
32
  runWithSpawnUsageAccumulator,
31
33
  splitFrontmatter,
32
34
  supportsSpawnMode
33
- } from "./chunks/chunk-MFCEBCGV.js";
35
+ } from "./chunks/chunk-KETIFEA7.js";
34
36
  import {
35
37
  parseMcpConfig
36
- } from "./chunks/chunk-MW2QLYVN.js";
38
+ } from "./chunks/chunk-3ITVV2R6.js";
37
39
  import {
38
40
  lint
39
- } from "./chunks/chunk-EG3QWREA.js";
40
- import "./chunks/chunk-OZLTLIHX.js";
41
+ } from "./chunks/chunk-RULU2F5J.js";
42
+ import "./chunks/chunk-G6WTEIJJ.js";
43
+ import {
44
+ makeFsModule
45
+ } from "./chunks/chunk-K4T4EBED.js";
41
46
  import {
42
47
  createRootedSourceResolver
43
- } from "./chunks/chunk-FCCA27RC.js";
48
+ } from "./chunks/chunk-F6CV74HU.js";
44
49
  import {
45
50
  FileSnapshotBackend,
46
51
  createRealm,
47
52
  createReplayableRandom,
48
53
  run
49
- } from "./chunks/chunk-XX57YCGZ.js";
54
+ } from "./chunks/chunk-GNEORAQI.js";
50
55
  import "./chunks/chunk-U7ZNMTSQ.js";
51
56
  import {
52
- restore
53
- } from "./chunks/chunk-EN724VH3.js";
57
+ fsCodec
58
+ } from "./chunks/chunk-GVKXZW53.js";
54
59
  import {
55
- dump
56
- } from "./chunks/chunk-MVLDRXWS.js";
60
+ hasOwnErrorCode
61
+ } from "./chunks/chunk-2GVBG23M.js";
57
62
  import {
58
- inspectSnapshotMigration,
59
- migrateSnapshot,
60
- migrateSnapshotFile
61
- } from "./chunks/chunk-LRSWTDIV.js";
63
+ restore
64
+ } from "./chunks/chunk-O4IDRXW7.js";
65
+ import "./chunks/chunk-PSVV3IG2.js";
62
66
  import {
63
- hasOwnErrorCode
64
- } from "./chunks/chunk-SJZWSPWD.js";
65
- import "./chunks/chunk-EA7AHM2X.js";
67
+ dump
68
+ } from "./chunks/chunk-X3CKAZQ4.js";
66
69
  import {
67
70
  HostCallResumabilityError,
68
71
  HostOperationResumePolicyError,
@@ -74,7 +77,7 @@ import {
74
77
  deepCopyToSandbox,
75
78
  defineExtension,
76
79
  registerPendingHostCallPolicy
77
- } from "./chunks/chunk-S5YDMMM3.js";
80
+ } from "./chunks/chunk-MDIWQFYU.js";
78
81
  import {
79
82
  Budget,
80
83
  SandboxError,
@@ -82,15 +85,20 @@ import {
82
85
  parse,
83
86
  parseModule,
84
87
  parseSourceModule
85
- } from "./chunks/chunk-Y5EZYHU6.js";
88
+ } from "./chunks/chunk-QKO4FATZ.js";
89
+ import {
90
+ extname
91
+ } from "./chunks/chunk-YUQFFRUF.js";
92
+ import {
93
+ hostFs
94
+ } from "./chunks/chunk-UQPYTZOZ.js";
86
95
  import "./chunks/chunk-4YIDX44G.js";
87
96
 
88
97
  // packages/safe-js/src/parse.ts
89
98
  var parse2 = parse;
90
99
 
91
100
  // packages/safe-js/src/runner/run-harness.ts
92
- import { readFile, stat } from "node:fs/promises";
93
- import { extname } from "node:path";
101
+ import { createFsBridge } from "@poe-platform/safe-fs/core";
94
102
  function getOwnEntry(record, key) {
95
103
  return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : void 0;
96
104
  }
@@ -133,7 +141,7 @@ var LintError = class extends Error {
133
141
  }
134
142
  };
135
143
  async function runHarness(filepath, options) {
136
- const rawSource = await readHarnessFile(filepath);
144
+ const rawSource = await readHarnessFile(filepath, options.adapter);
137
145
  const { executableSource, frontmatter, isRawScript } = loadExecutableSource(filepath, rawSource);
138
146
  assertFrontmatterAgentModes(frontmatter);
139
147
  const meta = createHarnessMeta(filepath, frontmatter);
@@ -161,8 +169,8 @@ async function runHarness(filepath, options) {
161
169
  async function runHarnessPair(filepath, options) {
162
170
  const pair = resolveHarnessPair(filepath);
163
171
  const [rawMarkdown, rawScript] = await Promise.all([
164
- readHarnessFile(pair.markdownPath),
165
- readHarnessFile(pair.scriptPath)
172
+ readHarnessFile(pair.markdownPath, options.adapter),
173
+ readHarnessFile(pair.scriptPath, options.adapter)
166
174
  ]);
167
175
  const { frontmatter, body } = splitFrontmatter(stripByteOrderMark(rawMarkdown));
168
176
  assertFrontmatterAgentModes(frontmatter);
@@ -201,13 +209,14 @@ async function runHarnessPair(filepath, options) {
201
209
  snapshotPath: options.snapshotPath
202
210
  });
203
211
  }
204
- async function readHarnessFile(filepath) {
212
+ async function readHarnessFile(filepath, adapter) {
213
+ const io = adapter ? createFsBridge(adapter, { codec: fsCodec }) : hostFs;
205
214
  try {
206
- const stats = await stat(filepath);
215
+ const stats = await io.stat(filepath);
207
216
  if (!stats.isFile()) {
208
217
  throw new Error(`Harness path must point to a file: ${filepath}`);
209
218
  }
210
- return await readFile(filepath, "utf8");
219
+ return await io.readFile(filepath, "utf8");
211
220
  } catch (error) {
212
221
  if (hasOwnErrorCode(error, "ENOENT") || hasOwnErrorCode(error, "ENOTDIR")) {
213
222
  throw new Error(`Harness file not found: ${filepath}`);