@poe-platform/safe-js 0.1.805 → 0.1.807
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.
- package/README.md +17 -1
- package/dist/agent-harness-tools/execution-env.d.ts +1 -1
- package/dist/agent-harness-tools/harness-dashboard.d.ts +2 -1
- package/dist/agent-harness-tools/poe-command-execution.d.ts +5 -3
- package/dist/agent-harness-tools/runner.d.ts +1 -1
- package/dist/agent-harness-tools/workspace-transfer.d.ts +2 -2
- package/dist/poe-acp-client/acp-transport.d.ts +1 -1
- package/dist/poe-code-config/memory.d.ts +1 -0
- package/dist/poe-code-config/runtime.d.ts +5 -2
- package/dist/process-runner/types.d.ts +1 -1
- package/dist/process-runner/workspace-transfer.d.ts +6 -5
- package/dist/safe-js/chunks/{chunk-KMBCLXER.js → chunk-2IYZK337.js} +1 -1
- package/dist/safe-js/chunks/{chunk-WNCT5WTP.js → chunk-3W4JJFK6.js} +1 -1
- package/dist/safe-js/chunks/{chunk-GJPD4ALZ.js → chunk-425IYA26.js} +1 -1
- package/dist/safe-js/chunks/{chunk-2LI4AP6C.js → chunk-5FPEN6AM.js} +8 -7
- package/dist/safe-js/chunks/{chunk-NOS76GMS.js → chunk-5ZVTZBH2.js} +1 -1
- package/dist/safe-js/chunks/{chunk-N3EL5B4L.js → chunk-7RGEML7S.js} +5 -4
- package/dist/safe-js/chunks/{chunk-VQKUOXQ2.js → chunk-BEA7FA5M.js} +9 -2
- package/dist/safe-js/chunks/{chunk-WZ27FAD3.js → chunk-C5NG3LHQ.js} +3 -3
- package/dist/safe-js/chunks/{chunk-HFCSCNZN.js → chunk-E7V44LSN.js} +54 -47
- package/dist/safe-js/chunks/{chunk-VVOPJZRG.js → chunk-H25SH6HQ.js} +3 -1
- package/dist/safe-js/chunks/{chunk-AN6Z3R6M.js → chunk-MJH5AYEK.js} +1 -1
- package/dist/safe-js/chunks/{chunk-JQ5QJV5Q.js → chunk-P5Y4UF4L.js} +2 -2
- package/dist/safe-js/chunks/{chunk-JVE54EBX.js → chunk-ROIZEQTS.js} +7 -4
- package/dist/safe-js/chunks/{chunk-HR3HSM26.js → chunk-SAYUBVHD.js} +2 -2
- package/dist/safe-js/chunks/{chunk-IRCZI6HL.js → chunk-SV37HEM5.js} +4 -4
- package/dist/safe-js/chunks/{chunk-RPGCF4KE.js → chunk-TG7TRXYG.js} +49 -2
- package/dist/safe-js/chunks/{chunk-ECMGBHAB.js → chunk-XQOJJA4C.js} +11 -65
- package/dist/safe-js/chunks/{cli-runtime-6EBUM6AL.js → cli-runtime-EV4DQ7UW.js} +16 -16
- package/dist/safe-js/chunks/{dump-S6HOPYA6.js → dump-OX7M4C56.js} +3 -3
- package/dist/safe-js/chunks/{harness-GQGDTZ5P.js → harness-4BETCNJY.js} +3 -3
- package/dist/safe-js/chunks/mcp-DSJET2K4.js +12 -0
- package/dist/safe-js/chunks/{migration-file-BJVZMCID.js → migration-file-6LFFQLZN.js} +5 -5
- package/dist/safe-js/chunks/{restore-GU6CISV6.js → restore-BFVCW6H4.js} +4 -4
- package/dist/safe-js/chunks/{run-STNASYDW.js → run-PWX3SVTF.js} +7 -7
- package/dist/safe-js/chunks/{runtime-modules-5MQCTIB5.js → runtime-modules-UOVJSSD7.js} +3 -3
- package/dist/safe-js/chunks/{source-files-A2WSOO6G.js → source-files-QT24SQTE.js} +3 -3
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.d.ts +3 -0
- package/dist/safe-js/core.js +19 -13
- package/dist/safe-js/host-context.d.ts +5 -0
- package/dist/safe-js/index.d.ts +1 -0
- package/dist/safe-js/index.js +22 -20
- package/dist/safe-js/interp/host-bridge.d.ts +2 -0
- package/dist/safe-js/interp/resources.d.ts +23 -0
- package/dist/safe-js/modules/fs-config.d.ts +1 -1
- package/dist/safe-js/modules/fs.js +4 -4
- package/dist/safe-js/modules/mcp-transport.d.ts +1 -1
- package/dist/safe-js/modules/registry.d.ts +2 -0
- package/dist/safe-js/platform/context.js +19 -8
- package/dist/safe-js/platform/node.d.ts +1 -0
- package/dist/safe-js/platform/node.js +1 -0
- package/dist/safe-js/platform/workerd.d.ts +1 -0
- package/dist/safe-js/platform/workerd.js +1 -0
- package/dist/safe-js/portable/chunks/{chunk-W6MZOTYR.js → chunk-LCUQNFD2.js} +17 -7
- package/dist/safe-js/portable/chunks/{chunk-NLGXLZCK.js → chunk-MKRVEJD6.js} +1 -1
- package/dist/safe-js/portable/chunks/{chunk-OCBLPMJE.js → chunk-OCBYWLKS.js} +7 -4
- package/dist/safe-js/portable/chunks/{source-files-AEDWESAJ.js → source-files-HMG6KJLP.js} +2 -2
- package/dist/safe-js/portable/core.js +56 -4
- package/dist/safe-js/portable/modules/fs.js +2 -2
- package/dist/safe-js/workerd.d.ts +1 -2
- package/dist/safe-js/workerd.js +11645 -831
- package/package.json +2 -2
- package/dist/safe-js/chunks/mcp-MILSUBPS.js +0 -11
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
AsyncLocalStorage,
|
|
15
15
|
hostCwd
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-H25SH6HQ.js";
|
|
17
17
|
|
|
18
18
|
// packages/safe-js/src/error/format.ts
|
|
19
19
|
var DEFAULT_MAX_MESSAGE_LENGTH = Infinity;
|
|
@@ -1684,7 +1684,7 @@ function makeAgentModule(spawnAgent, moduleOptions = {}) {
|
|
|
1684
1684
|
const input = resolveSpawnInput(agentDef, options);
|
|
1685
1685
|
const spawnId = nextSpawnId;
|
|
1686
1686
|
nextSpawnId += 1;
|
|
1687
|
-
|
|
1687
|
+
activeUsageAccumulator.getStore()?.beginSpawn?.();
|
|
1688
1688
|
return runObservedSpawn(moduleOptions.otelSink, input, async () => {
|
|
1689
1689
|
return defaultRetry === void 0 ? runSpawnAttempt(spawnAgent, input, moduleOptions.onEvent, spawnId) : runSpawnRetry(spawnAgent, input, defaultRetry, moduleOptions.onEvent, spawnId);
|
|
1690
1690
|
});
|
|
@@ -1696,7 +1696,7 @@ function makeAgentModule(spawnAgent, moduleOptions = {}) {
|
|
|
1696
1696
|
const normalizedRetry = normalizeRetryOptions(retryOptions);
|
|
1697
1697
|
const spawnId = nextSpawnId;
|
|
1698
1698
|
nextSpawnId += 1;
|
|
1699
|
-
|
|
1699
|
+
activeUsageAccumulator.getStore()?.beginSpawn?.();
|
|
1700
1700
|
return await runObservedSpawn(
|
|
1701
1701
|
moduleOptions.otelSink,
|
|
1702
1702
|
input,
|
|
@@ -1718,7 +1718,7 @@ function makeAgentModule(spawnAgent, moduleOptions = {}) {
|
|
|
1718
1718
|
const input = resolveSpawnInput(agentDef, spawnOptions);
|
|
1719
1719
|
const spawnId = nextSpawnId;
|
|
1720
1720
|
nextSpawnId += 1;
|
|
1721
|
-
|
|
1721
|
+
activeUsageAccumulator.getStore()?.beginSpawn?.();
|
|
1722
1722
|
return runObservedSpawn(
|
|
1723
1723
|
moduleOptions.otelSink,
|
|
1724
1724
|
input,
|
|
@@ -1751,6 +1751,7 @@ function makeAgentModule(spawnAgent, moduleOptions = {}) {
|
|
|
1751
1751
|
};
|
|
1752
1752
|
}
|
|
1753
1753
|
async function runSpawnAttempt(spawnAgent, input, onEvent, spawnId) {
|
|
1754
|
+
const accumulator = activeUsageAccumulator.getStore();
|
|
1754
1755
|
const task = resolveTaskLabel(input);
|
|
1755
1756
|
const startedAt = Date.now();
|
|
1756
1757
|
try {
|
|
@@ -1768,10 +1769,10 @@ async function runSpawnAttempt(spawnAgent, input, onEvent, spawnId) {
|
|
|
1768
1769
|
maxAttempts: 1
|
|
1769
1770
|
});
|
|
1770
1771
|
try {
|
|
1771
|
-
|
|
1772
|
+
accumulator?.beginAttempt?.();
|
|
1772
1773
|
const result = validateSpawnResult(await spawnAgent(toProviderSpawnInput(input)));
|
|
1773
1774
|
throwIfAborted2(input.signal);
|
|
1774
|
-
|
|
1775
|
+
accumulator?.record(result.usage);
|
|
1775
1776
|
if (result.exitCode !== 0) {
|
|
1776
1777
|
const error = new AgentSpawnError(result);
|
|
1777
1778
|
if (input.check) {
|
|
@@ -1858,6 +1859,7 @@ function readCurrentWorkingDirectory() {
|
|
|
1858
1859
|
}
|
|
1859
1860
|
}
|
|
1860
1861
|
async function runSpawnRetry(spawnAgent, input, retryOptions, onEvent, spawnId) {
|
|
1862
|
+
const accumulator = activeUsageAccumulator.getStore();
|
|
1861
1863
|
const task = resolveTaskLabel(input);
|
|
1862
1864
|
const startedAt = Date.now();
|
|
1863
1865
|
for (let attempt = 1; attempt <= retryOptions.maxAttempts; attempt += 1) {
|
|
@@ -1886,7 +1888,7 @@ async function runSpawnRetry(spawnAgent, input, retryOptions, onEvent, spawnId)
|
|
|
1886
1888
|
});
|
|
1887
1889
|
let result;
|
|
1888
1890
|
try {
|
|
1889
|
-
|
|
1891
|
+
accumulator?.beginAttempt?.();
|
|
1890
1892
|
result = validateSpawnResult(await spawnAgent(toProviderSpawnInput(input)));
|
|
1891
1893
|
throwIfAborted2(input.signal);
|
|
1892
1894
|
} catch (error2) {
|
|
@@ -1974,7 +1976,7 @@ async function runSpawnRetry(spawnAgent, input, retryOptions, onEvent, spawnId)
|
|
|
1974
1976
|
}
|
|
1975
1977
|
continue;
|
|
1976
1978
|
}
|
|
1977
|
-
|
|
1979
|
+
accumulator?.record(result.usage);
|
|
1978
1980
|
if (result.exitCode === 0) {
|
|
1979
1981
|
emitSpawnEvent(onEvent, {
|
|
1980
1982
|
type: "spawn.succeeded",
|
|
@@ -2342,15 +2344,6 @@ function validateSpawnResult(result) {
|
|
|
2342
2344
|
...usage === void 0 ? {} : { usage: readSpawnUsage(usage) }
|
|
2343
2345
|
});
|
|
2344
2346
|
}
|
|
2345
|
-
function recordActiveSpawnUsage(usage) {
|
|
2346
|
-
activeUsageAccumulator.getStore()?.record(usage);
|
|
2347
|
-
}
|
|
2348
|
-
function recordActiveSpawnAttempt() {
|
|
2349
|
-
activeUsageAccumulator.getStore()?.beginAttempt?.();
|
|
2350
|
-
}
|
|
2351
|
-
function recordActiveSpawnStart() {
|
|
2352
|
-
activeUsageAccumulator.getStore()?.beginSpawn?.();
|
|
2353
|
-
}
|
|
2354
2347
|
function readSpawnUsage(value) {
|
|
2355
2348
|
if (!isRecord2(value)) {
|
|
2356
2349
|
throw new Error("spawnAgent result usage must be an object.");
|
|
@@ -2519,51 +2512,6 @@ function isRecord2(value) {
|
|
|
2519
2512
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2520
2513
|
}
|
|
2521
2514
|
|
|
2522
|
-
// packages/safe-js/src/modules/fs-config.ts
|
|
2523
|
-
import {
|
|
2524
|
-
createFileSystem,
|
|
2525
|
-
createNodeFileSystemAdapterRegistry,
|
|
2526
|
-
readConfigRecord,
|
|
2527
|
-
validateFileSystemConfig
|
|
2528
|
-
} from "@poe-platform/safe-fs";
|
|
2529
|
-
function validateFsConfig(value) {
|
|
2530
|
-
const config = readConfigRecord(value, "fs config", ["adapter", "root", "cwd", "readFileMaxBytes", "hostReadMemoryLimit", "maxSymlinkFollows"]);
|
|
2531
|
-
const paths = {};
|
|
2532
|
-
for (const key of ["root", "cwd"]) {
|
|
2533
|
-
const path = config[key];
|
|
2534
|
-
if (path === void 0) continue;
|
|
2535
|
-
if (typeof path !== "string" || !path.startsWith("/") || path.includes("\0")) {
|
|
2536
|
-
throw new TypeError(`${key} must be an absolute virtual path`);
|
|
2537
|
-
}
|
|
2538
|
-
paths[key] = path;
|
|
2539
|
-
}
|
|
2540
|
-
const limits = {};
|
|
2541
|
-
for (const key of ["readFileMaxBytes", "hostReadMemoryLimit", "maxSymlinkFollows"]) {
|
|
2542
|
-
const value2 = config[key];
|
|
2543
|
-
if (value2 === void 0) continue;
|
|
2544
|
-
if (value2 !== Infinity && (typeof value2 !== "number" || !Number.isSafeInteger(value2) || value2 < 0))
|
|
2545
|
-
throw new TypeError(`${key} must be a non-negative safe integer or Infinity`);
|
|
2546
|
-
Object.assign(limits, { [key]: value2 });
|
|
2547
|
-
}
|
|
2548
|
-
return {
|
|
2549
|
-
adapter: validateFileSystemConfig(config.adapter),
|
|
2550
|
-
...paths,
|
|
2551
|
-
...limits
|
|
2552
|
-
};
|
|
2553
|
-
}
|
|
2554
|
-
function parseFsConfig(json) {
|
|
2555
|
-
return validateFsConfig(JSON.parse(json));
|
|
2556
|
-
}
|
|
2557
|
-
async function resolveFsConfig(config, options = {}) {
|
|
2558
|
-
const { adapter: adapterConfig, ...paths } = validateFsConfig(config);
|
|
2559
|
-
const resolution = readConfigRecord(options, "fs resolution option", ["registry"]);
|
|
2560
|
-
const registry = createNodeFileSystemAdapterRegistry(
|
|
2561
|
-
resolution.registry
|
|
2562
|
-
);
|
|
2563
|
-
const adapter = await createFileSystem(adapterConfig, { registry });
|
|
2564
|
-
return { adapter, ...paths };
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
2515
|
export {
|
|
2568
2516
|
formatInterpreterError,
|
|
2569
2517
|
SPAWN_MODES,
|
|
@@ -2575,7 +2523,5 @@ export {
|
|
|
2575
2523
|
AgentSpawnError,
|
|
2576
2524
|
createSpawnUsageAccumulator,
|
|
2577
2525
|
runWithSpawnUsageAccumulator,
|
|
2578
|
-
makeAgentModule
|
|
2579
|
-
parseFsConfig,
|
|
2580
|
-
resolveFsConfig
|
|
2526
|
+
makeAgentModule
|
|
2581
2527
|
};
|
|
@@ -4,21 +4,21 @@ import {
|
|
|
4
4
|
formatInterpreterError,
|
|
5
5
|
makeAgentModule,
|
|
6
6
|
maskSource,
|
|
7
|
-
parseFsConfig,
|
|
8
|
-
resolveFsConfig,
|
|
9
7
|
splitFrontmatter
|
|
10
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XQOJJA4C.js";
|
|
11
9
|
import {
|
|
12
10
|
parseMcpConfig
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-E7V44LSN.js";
|
|
14
12
|
import {
|
|
15
13
|
lint,
|
|
16
14
|
makeEnvModule,
|
|
17
15
|
makeFailModule,
|
|
18
16
|
makeLogModule,
|
|
19
17
|
makeMetricModule,
|
|
20
|
-
parseEnvConfig
|
|
21
|
-
|
|
18
|
+
parseEnvConfig,
|
|
19
|
+
parseFsConfig,
|
|
20
|
+
resolveFsConfig
|
|
21
|
+
} from "./chunk-TG7TRXYG.js";
|
|
22
22
|
import {
|
|
23
23
|
createBrokenPipeState,
|
|
24
24
|
createSafeOutputStream,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./chunk-X3YCE3ZH.js";
|
|
27
27
|
import {
|
|
28
28
|
createRootedSourceResolver
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-P5Y4UF4L.js";
|
|
30
30
|
import "./chunk-DHGJSEFX.js";
|
|
31
31
|
import {
|
|
32
32
|
fsCodec
|
|
@@ -45,11 +45,11 @@ import {
|
|
|
45
45
|
dirname,
|
|
46
46
|
extname,
|
|
47
47
|
paths_default
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-2IYZK337.js";
|
|
49
49
|
import {
|
|
50
50
|
formatWithOptions,
|
|
51
51
|
hostFs
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-H25SH6HQ.js";
|
|
53
53
|
import "./chunk-CQ52GEHY.js";
|
|
54
54
|
|
|
55
55
|
// packages/safe-js/src/cli-runtime.ts
|
|
@@ -72,7 +72,7 @@ async function runCli(argv, options, usage) {
|
|
|
72
72
|
async () => {
|
|
73
73
|
try {
|
|
74
74
|
if (argv[0] === "migrate") {
|
|
75
|
-
const { migrateSnapshotFile } = await import("./migration-file-
|
|
75
|
+
const { migrateSnapshotFile } = await import("./migration-file-6LFFQLZN.js");
|
|
76
76
|
const result = await migrateSnapshotFile({
|
|
77
77
|
...parseMigrationArgs(argv.slice(1)),
|
|
78
78
|
cwd: options.cwd ?? readCurrentWorkingDirectory(),
|
|
@@ -291,12 +291,12 @@ async function assertHarnessFile(input) {
|
|
|
291
291
|
}
|
|
292
292
|
async function runScriptFile(filepath, parsed, options) {
|
|
293
293
|
const [{ run }, { restore }, { dump, dumpCurrent }, { createLintModulesFromRuntimeRegistry }, { makeFsModule }, { makeMcpModule }] = await Promise.all([
|
|
294
|
-
import("./run-
|
|
295
|
-
import("./restore-
|
|
296
|
-
import("./dump-
|
|
297
|
-
import("./runtime-modules-
|
|
294
|
+
import("./run-PWX3SVTF.js"),
|
|
295
|
+
import("./restore-BFVCW6H4.js"),
|
|
296
|
+
import("./dump-OX7M4C56.js"),
|
|
297
|
+
import("./runtime-modules-UOVJSSD7.js"),
|
|
298
298
|
import("../modules/fs.js"),
|
|
299
|
-
import("./mcp-
|
|
299
|
+
import("./mcp-DSJET2K4.js")
|
|
300
300
|
]);
|
|
301
301
|
const loaded = loadExecutableSource(filepath, await options.readFile(filepath, "utf8"));
|
|
302
302
|
const meta = {
|
|
@@ -534,7 +534,7 @@ async function createRuntime(frontmatter, meta, options) {
|
|
|
534
534
|
};
|
|
535
535
|
}
|
|
536
536
|
const [{ makeHarnessModule }, { makeFsModule }] = await Promise.all([
|
|
537
|
-
import("./harness-
|
|
537
|
+
import("./harness-4BETCNJY.js"),
|
|
538
538
|
import("../modules/fs.js")
|
|
539
539
|
]);
|
|
540
540
|
const state = {
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
dump,
|
|
5
5
|
dumpCurrent,
|
|
6
6
|
serializeRunSnapshot
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-3W4JJFK6.js";
|
|
8
|
+
import "./chunk-ROIZEQTS.js";
|
|
9
9
|
import "./chunk-EQUBWQJN.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-H25SH6HQ.js";
|
|
11
11
|
import "./chunk-CQ52GEHY.js";
|
|
12
12
|
export {
|
|
13
13
|
attachDumpController,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
makeHarnessModule
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-5ZVTZBH2.js";
|
|
4
|
+
import "./chunk-ROIZEQTS.js";
|
|
5
5
|
import "./chunk-EQUBWQJN.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-H25SH6HQ.js";
|
|
7
7
|
import "./chunk-CQ52GEHY.js";
|
|
8
8
|
export {
|
|
9
9
|
makeHarnessModule
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
makeMcpModule
|
|
3
|
+
} from "./chunk-7RGEML7S.js";
|
|
4
|
+
import "./chunk-E7V44LSN.js";
|
|
5
|
+
import "./chunk-ROIZEQTS.js";
|
|
6
|
+
import "./chunk-EQUBWQJN.js";
|
|
7
|
+
import "./chunk-2IYZK337.js";
|
|
8
|
+
import "./chunk-H25SH6HQ.js";
|
|
9
|
+
import "./chunk-CQ52GEHY.js";
|
|
10
|
+
export {
|
|
11
|
+
makeMcpModule
|
|
12
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
migrateSnapshotFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SV37HEM5.js";
|
|
4
4
|
import "./chunk-DIG26TEI.js";
|
|
5
5
|
import "./chunk-ONWFPHUI.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-MJH5AYEK.js";
|
|
7
|
+
import "./chunk-ROIZEQTS.js";
|
|
8
8
|
import "./chunk-EQUBWQJN.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-2IYZK337.js";
|
|
10
|
+
import "./chunk-H25SH6HQ.js";
|
|
11
11
|
import "./chunk-CQ52GEHY.js";
|
|
12
12
|
export {
|
|
13
13
|
migrateSnapshotFile
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnapshotMismatchError,
|
|
3
3
|
restore
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-SAYUBVHD.js";
|
|
5
|
+
import "./chunk-MJH5AYEK.js";
|
|
6
|
+
import "./chunk-ROIZEQTS.js";
|
|
7
7
|
import "./chunk-EQUBWQJN.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-H25SH6HQ.js";
|
|
9
9
|
import "./chunk-CQ52GEHY.js";
|
|
10
10
|
export {
|
|
11
11
|
SnapshotMismatchError,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UnhandledRejectionError,
|
|
3
3
|
run
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5FPEN6AM.js";
|
|
5
5
|
import "./chunk-DHGJSEFX.js";
|
|
6
6
|
import "./chunk-DIG26TEI.js";
|
|
7
7
|
import "./chunk-ONWFPHUI.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-SAYUBVHD.js";
|
|
9
|
+
import "./chunk-MJH5AYEK.js";
|
|
10
|
+
import "./chunk-3W4JJFK6.js";
|
|
11
|
+
import "./chunk-ROIZEQTS.js";
|
|
12
12
|
import "./chunk-EQUBWQJN.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-2IYZK337.js";
|
|
14
|
+
import "./chunk-H25SH6HQ.js";
|
|
15
15
|
import "./chunk-CQ52GEHY.js";
|
|
16
16
|
export {
|
|
17
17
|
UnhandledRejectionError,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLintModulesFromRuntimeRegistry
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-425IYA26.js";
|
|
4
|
+
import "./chunk-ROIZEQTS.js";
|
|
5
5
|
import "./chunk-EQUBWQJN.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-H25SH6HQ.js";
|
|
7
7
|
import "./chunk-CQ52GEHY.js";
|
|
8
8
|
export {
|
|
9
9
|
createLintModulesFromRuntimeRegistry
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRootedSourceResolver
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-P5Y4UF4L.js";
|
|
4
|
+
import "./chunk-2IYZK337.js";
|
|
5
|
+
import "./chunk-H25SH6HQ.js";
|
|
6
6
|
import "./chunk-CQ52GEHY.js";
|
|
7
7
|
export {
|
|
8
8
|
createRootedSourceResolver
|
package/dist/safe-js/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createHostFileSystem } from "@poe-platform/safe-fs/node";
|
|
|
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-
|
|
16
|
+
const runtime = await import("./chunks/cli-runtime-EV4DQ7UW.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-
|
|
35
|
+
const { exitCodeForError } = await import("./chunks/cli-runtime-EV4DQ7UW.js");
|
|
36
36
|
return exitCodeForError(error);
|
|
37
37
|
}
|
|
38
38
|
}
|
package/dist/safe-js/core.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const deepCopyFromSandbox: {
|
|
|
12
12
|
(value: SandboxValue, options?: PublicCopyOptions): unknown;
|
|
13
13
|
};
|
|
14
14
|
export { admitNativePromiseProperties } from "./interp/native-promise-properties.js";
|
|
15
|
+
export { captureHostContext } from "./host-context.js";
|
|
15
16
|
export { lint, type Diagnostic, type Fix, type LintFixResult, type LintOptions } from "./lint.js";
|
|
16
17
|
export { run } from "./run.js";
|
|
17
18
|
export type { RunPromise } from "./run.js";
|
|
@@ -37,3 +38,5 @@ export { deepCopyToSandbox } from "./interp/values.js";
|
|
|
37
38
|
export { SandboxError } from "./interp/budget.js";
|
|
38
39
|
export { SnapshotValidationError } from "./snapshot/validation.js";
|
|
39
40
|
export { declareHostOperation } from "./interp/host-bridge.js";
|
|
41
|
+
export { parseFsConfig, resolveFsConfig } from "./modules/fs-config.js";
|
|
42
|
+
export type { FsConfig, ResolveFsConfigOptions } from "./modules/fs-config.js";
|
package/dist/safe-js/core.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
captureHostContext,
|
|
2
3
|
deepCopyFromSandbox,
|
|
3
4
|
makeTimeModule,
|
|
4
5
|
parse,
|
|
5
6
|
parseModule,
|
|
6
7
|
parseSourceModule,
|
|
7
8
|
restore
|
|
8
|
-
} from "./chunks/chunk-
|
|
9
|
+
} from "./chunks/chunk-BEA7FA5M.js";
|
|
9
10
|
import {
|
|
10
11
|
makeHarnessModule
|
|
11
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-5ZVTZBH2.js";
|
|
12
13
|
import {
|
|
13
14
|
EnvAccessError,
|
|
14
15
|
HarnessFailure,
|
|
@@ -17,42 +18,44 @@ import {
|
|
|
17
18
|
makeFailModule,
|
|
18
19
|
makeLogModule,
|
|
19
20
|
makeMetricModule,
|
|
20
|
-
parseEnvConfig
|
|
21
|
-
|
|
21
|
+
parseEnvConfig,
|
|
22
|
+
parseFsConfig,
|
|
23
|
+
resolveFsConfig
|
|
24
|
+
} from "./chunks/chunk-TG7TRXYG.js";
|
|
22
25
|
import "./chunks/chunk-X3YCE3ZH.js";
|
|
23
26
|
import {
|
|
24
27
|
FS_OPTION_SURFACE,
|
|
25
28
|
makeFsModule
|
|
26
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-C5NG3LHQ.js";
|
|
27
30
|
import {
|
|
28
31
|
createRootedSourceResolver
|
|
29
|
-
} from "./chunks/chunk-
|
|
32
|
+
} from "./chunks/chunk-P5Y4UF4L.js";
|
|
30
33
|
import {
|
|
31
34
|
createRealm,
|
|
32
35
|
createReplayableRandom,
|
|
33
36
|
run
|
|
34
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-5FPEN6AM.js";
|
|
35
38
|
import "./chunks/chunk-DHGJSEFX.js";
|
|
36
39
|
import "./chunks/chunk-DIG26TEI.js";
|
|
37
40
|
import "./chunks/chunk-ONWFPHUI.js";
|
|
38
|
-
import "./chunks/chunk-
|
|
39
|
-
import "./chunks/chunk-
|
|
41
|
+
import "./chunks/chunk-SAYUBVHD.js";
|
|
42
|
+
import "./chunks/chunk-MJH5AYEK.js";
|
|
40
43
|
import {
|
|
41
44
|
dump
|
|
42
|
-
} from "./chunks/chunk-
|
|
45
|
+
} from "./chunks/chunk-3W4JJFK6.js";
|
|
43
46
|
import {
|
|
44
47
|
SnapshotValidationError,
|
|
45
48
|
admitNativePromiseProperties,
|
|
46
49
|
declareHostOperation,
|
|
47
50
|
deepCopyToSandbox,
|
|
48
51
|
defineExtension
|
|
49
|
-
} from "./chunks/chunk-
|
|
52
|
+
} from "./chunks/chunk-ROIZEQTS.js";
|
|
50
53
|
import {
|
|
51
54
|
Budget,
|
|
52
55
|
SandboxError
|
|
53
56
|
} from "./chunks/chunk-EQUBWQJN.js";
|
|
54
|
-
import "./chunks/chunk-
|
|
55
|
-
import "./chunks/chunk-
|
|
57
|
+
import "./chunks/chunk-2IYZK337.js";
|
|
58
|
+
import "./chunks/chunk-H25SH6HQ.js";
|
|
56
59
|
import "./chunks/chunk-CQ52GEHY.js";
|
|
57
60
|
export {
|
|
58
61
|
Budget,
|
|
@@ -62,6 +65,7 @@ export {
|
|
|
62
65
|
SandboxError,
|
|
63
66
|
SnapshotValidationError,
|
|
64
67
|
admitNativePromiseProperties,
|
|
68
|
+
captureHostContext,
|
|
65
69
|
createRealm,
|
|
66
70
|
createReplayableRandom,
|
|
67
71
|
createRootedSourceResolver,
|
|
@@ -80,8 +84,10 @@ export {
|
|
|
80
84
|
makeTimeModule,
|
|
81
85
|
parse,
|
|
82
86
|
parseEnvConfig,
|
|
87
|
+
parseFsConfig,
|
|
83
88
|
parseModule,
|
|
84
89
|
parseSourceModule,
|
|
90
|
+
resolveFsConfig,
|
|
85
91
|
restore,
|
|
86
92
|
run
|
|
87
93
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Capture the current host scope before awaiting or scheduling a callback.
|
|
2
|
+
* The returned function restores that scope for one synchronous continuation.
|
|
3
|
+
* Call it again around later continuations; it does not change native await.
|
|
4
|
+
*/
|
|
5
|
+
export declare const captureHostContext: () => <Result>(callback: () => Result) => Result;
|
package/dist/safe-js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { admitNativePromiseProperties } from "./interp/native-promise-properties.js";
|
|
2
|
+
export { captureHostContext } from "./host-context.js";
|
|
2
3
|
export { parse, parseModule, parseSourceModule, restore, deepCopyFromSandbox } from "./core.js";
|
|
3
4
|
export type { ParsedSourceModule, SourceImport, SourceExport } from "./parse/module-syntax.js";
|
|
4
5
|
export { lint, type Diagnostic, type Fix, type LintFixResult, type LintOptions } from "./lint.js";
|
package/dist/safe-js/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
inspectSnapshotMigration,
|
|
3
3
|
migrateSnapshot,
|
|
4
4
|
migrateSnapshotFile
|
|
5
|
-
} from "./chunks/chunk-
|
|
5
|
+
} from "./chunks/chunk-SV37HEM5.js";
|
|
6
6
|
import {
|
|
7
7
|
createLintModulesFromRuntimeRegistry
|
|
8
|
-
} from "./chunks/chunk-
|
|
8
|
+
} from "./chunks/chunk-425IYA26.js";
|
|
9
9
|
import {
|
|
10
10
|
makeMcpModule
|
|
11
|
-
} from "./chunks/chunk-
|
|
11
|
+
} from "./chunks/chunk-7RGEML7S.js";
|
|
12
12
|
import {
|
|
13
13
|
AgentSpawnError,
|
|
14
14
|
SPAWN_MODES,
|
|
@@ -18,26 +18,25 @@ import {
|
|
|
18
18
|
formatInterpreterError,
|
|
19
19
|
makeAgentModule,
|
|
20
20
|
maskSource,
|
|
21
|
-
parseFsConfig,
|
|
22
|
-
resolveFsConfig,
|
|
23
21
|
runWithSpawnUsageAccumulator,
|
|
24
22
|
splitFrontmatter,
|
|
25
23
|
supportsSpawnMode
|
|
26
|
-
} from "./chunks/chunk-
|
|
24
|
+
} from "./chunks/chunk-XQOJJA4C.js";
|
|
27
25
|
import {
|
|
28
26
|
parseMcpConfig
|
|
29
|
-
} from "./chunks/chunk-
|
|
27
|
+
} from "./chunks/chunk-E7V44LSN.js";
|
|
30
28
|
import {
|
|
29
|
+
captureHostContext,
|
|
31
30
|
deepCopyFromSandbox,
|
|
32
31
|
makeTimeModule,
|
|
33
32
|
parse,
|
|
34
33
|
parseModule as parseModule2,
|
|
35
34
|
parseSourceModule,
|
|
36
35
|
restore
|
|
37
|
-
} from "./chunks/chunk-
|
|
36
|
+
} from "./chunks/chunk-BEA7FA5M.js";
|
|
38
37
|
import {
|
|
39
38
|
makeHarnessModule
|
|
40
|
-
} from "./chunks/chunk-
|
|
39
|
+
} from "./chunks/chunk-5ZVTZBH2.js";
|
|
41
40
|
import {
|
|
42
41
|
EnvAccessError,
|
|
43
42
|
lint,
|
|
@@ -45,21 +44,23 @@ import {
|
|
|
45
44
|
makeFailModule,
|
|
46
45
|
makeLogModule,
|
|
47
46
|
makeMetricModule,
|
|
48
|
-
parseEnvConfig
|
|
49
|
-
|
|
47
|
+
parseEnvConfig,
|
|
48
|
+
parseFsConfig,
|
|
49
|
+
resolveFsConfig
|
|
50
|
+
} from "./chunks/chunk-TG7TRXYG.js";
|
|
50
51
|
import "./chunks/chunk-X3YCE3ZH.js";
|
|
51
52
|
import {
|
|
52
53
|
makeFsModule
|
|
53
|
-
} from "./chunks/chunk-
|
|
54
|
+
} from "./chunks/chunk-C5NG3LHQ.js";
|
|
54
55
|
import {
|
|
55
56
|
createRootedSourceResolver
|
|
56
|
-
} from "./chunks/chunk-
|
|
57
|
+
} from "./chunks/chunk-P5Y4UF4L.js";
|
|
57
58
|
import {
|
|
58
59
|
FileSnapshotBackend,
|
|
59
60
|
createRealm,
|
|
60
61
|
createReplayableRandom,
|
|
61
62
|
run
|
|
62
|
-
} from "./chunks/chunk-
|
|
63
|
+
} from "./chunks/chunk-5FPEN6AM.js";
|
|
63
64
|
import "./chunks/chunk-DHGJSEFX.js";
|
|
64
65
|
import {
|
|
65
66
|
fsCodec
|
|
@@ -67,11 +68,11 @@ import {
|
|
|
67
68
|
import {
|
|
68
69
|
hasOwnErrorCode
|
|
69
70
|
} from "./chunks/chunk-ONWFPHUI.js";
|
|
70
|
-
import "./chunks/chunk-
|
|
71
|
-
import "./chunks/chunk-
|
|
71
|
+
import "./chunks/chunk-SAYUBVHD.js";
|
|
72
|
+
import "./chunks/chunk-MJH5AYEK.js";
|
|
72
73
|
import {
|
|
73
74
|
dump
|
|
74
|
-
} from "./chunks/chunk-
|
|
75
|
+
} from "./chunks/chunk-3W4JJFK6.js";
|
|
75
76
|
import {
|
|
76
77
|
HostCallResumabilityError,
|
|
77
78
|
HostOperationResumePolicyError,
|
|
@@ -81,7 +82,7 @@ import {
|
|
|
81
82
|
deepCopyToSandbox,
|
|
82
83
|
defineExtension,
|
|
83
84
|
registerPendingHostCallPolicy
|
|
84
|
-
} from "./chunks/chunk-
|
|
85
|
+
} from "./chunks/chunk-ROIZEQTS.js";
|
|
85
86
|
import {
|
|
86
87
|
Budget,
|
|
87
88
|
SandboxError,
|
|
@@ -90,10 +91,10 @@ import {
|
|
|
90
91
|
} from "./chunks/chunk-EQUBWQJN.js";
|
|
91
92
|
import {
|
|
92
93
|
extname
|
|
93
|
-
} from "./chunks/chunk-
|
|
94
|
+
} from "./chunks/chunk-2IYZK337.js";
|
|
94
95
|
import {
|
|
95
96
|
hostFs
|
|
96
|
-
} from "./chunks/chunk-
|
|
97
|
+
} from "./chunks/chunk-H25SH6HQ.js";
|
|
97
98
|
import "./chunks/chunk-CQ52GEHY.js";
|
|
98
99
|
|
|
99
100
|
// packages/safe-js/src/runner/run-harness.ts
|
|
@@ -378,6 +379,7 @@ export {
|
|
|
378
379
|
SandboxError,
|
|
379
380
|
SnapshotValidationError,
|
|
380
381
|
admitNativePromiseProperties,
|
|
382
|
+
captureHostContext,
|
|
381
383
|
createRealm,
|
|
382
384
|
createReplayableRandom,
|
|
383
385
|
createRootedSourceResolver,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RunResources } from "./resources.js";
|
|
1
2
|
import { type Budget, type CompileOwner } from "./budget.js";
|
|
2
3
|
import { type PendingHostCallPolicyMode } from "../snapshot/policy.js";
|
|
3
4
|
import { type HostCallJournal, type HostCallOutcome } from "./host-call.js";
|
|
@@ -20,6 +21,7 @@ export type RealmBridge = {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
export type HostBridgeOptions = {
|
|
24
|
+
resources?: RunResources;
|
|
23
25
|
realm?: RealmBridge;
|
|
24
26
|
registerCapabilities?: boolean;
|
|
25
27
|
capabilityPath?: readonly string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "#safe-js-platform";
|
|
2
|
+
import type { Budget } from "./budget.js";
|
|
3
|
+
export type RunResources = {
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
functionSourceText?: boolean;
|
|
6
|
+
hostDataMetadata?: boolean;
|
|
7
|
+
nativeDataResults?: boolean;
|
|
8
|
+
sourceLocation?: (position: {
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}) => {
|
|
12
|
+
filename: string;
|
|
13
|
+
line: number;
|
|
14
|
+
column: number;
|
|
15
|
+
} | undefined;
|
|
16
|
+
canBlock?: boolean;
|
|
17
|
+
referenceReleases: Set<() => void>;
|
|
18
|
+
reportError?: (reason: unknown) => void;
|
|
19
|
+
add(close: () => Promise<void>): void | (() => void);
|
|
20
|
+
};
|
|
21
|
+
export declare const runResources: AsyncLocalStorage<RunResources>;
|
|
22
|
+
export declare function retainValues(budget: Budget, values: () => Iterable<unknown>): () => void;
|
|
23
|
+
export declare function withRunResources<Result>(signal: AbortSignal | undefined, execute: () => Promise<Result>): Promise<Result>;
|