@poe-platform/safe-bash 0.1.825 → 0.1.827
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/dist/image-ast/index.js +39 -18
- package/dist/pdf-ast/image.js +1 -1
- package/dist/pdf-ast/index.js +1 -1
- package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +9 -3
- package/dist/safe-bash/chunks/{chunk-AGHV53VF.js → chunk-M6XFU6LQ.js} +3 -1
- package/dist/safe-bash/chunks/{chunk-363QOIDR.js → chunk-T6FHWSHM.js} +3 -1
- package/dist/safe-bash/command-chunks/{chunk-ZPBL7TYJ.js → chunk-2JRHCVMQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-FMGNXOMV.js → chunk-2L3NMRLG.js} +7 -3
- package/dist/safe-bash/command-chunks/{chunk-DAQO64WC.js → chunk-2YKOJPIW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-EPYJSPOY.js → chunk-3QCW4VQF.js} +12 -8
- package/dist/safe-bash/command-chunks/{chunk-YRBFNT5B.js → chunk-3YL2TMLA.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-5H7ZHP7F.js → chunk-43NDRBKY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-BBOYR6LV.js → chunk-46GA576V.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-WPT2FCHH.js → chunk-4SLPM2WM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7ZQVMPSB.js → chunk-5CAXR62E.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3DTHX5UU.js → chunk-66653AEZ.js} +40 -14
- package/dist/safe-bash/command-chunks/{chunk-ETFJ4L7F.js → chunk-6OLE6CLV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZIDESNHW.js → chunk-7M3M6FKC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2KMNVJB7.js → chunk-A7PKUIJT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AVSINNZ6.js → chunk-DEQ47SBQ.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-EV7A5FNN.js → chunk-FFFRLPXU.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4MVQE6CT.js → chunk-FYTBEGSY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LFTGMUAV.js → chunk-HQIZR6EU.js} +192 -489
- package/dist/safe-bash/command-chunks/chunk-HS2L7I4N.js +219 -0
- package/dist/safe-bash/command-chunks/{chunk-WKS2PAZL.js → chunk-HUGKO4ZE.js} +10 -1
- package/dist/safe-bash/command-chunks/chunk-IGXH5W5Z.js +111 -0
- package/dist/safe-bash/command-chunks/{chunk-CMJBRGU2.js → chunk-IHQZKUBS.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-JADJ4BMN.js +1519 -0
- package/dist/safe-bash/command-chunks/{chunk-5AQAWIYK.js → chunk-JEZC5V3B.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-YB5TNDY6.js → chunk-K5VJ4NNL.js} +39 -5
- package/dist/safe-bash/command-chunks/{chunk-7RQGRFHJ.js → chunk-KHWDEAE4.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-L54KVUSY.js +604 -0
- package/dist/safe-bash/command-chunks/{chunk-3NJETNC2.js → chunk-MBXNG6C3.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HCPEYQKT.js → chunk-N4SH6QY5.js} +285 -302
- package/dist/safe-bash/command-chunks/{chunk-3DID6MQY.js → chunk-OWTQYLID.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4EA7WI3L.js → chunk-QOOQD6BD.js} +42 -33
- package/dist/safe-bash/command-chunks/{chunk-RQTFK7AV.js → chunk-QZYEI4N6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-R3SLT3ZX.js → chunk-R6GON4H3.js} +11 -1
- package/dist/safe-bash/command-chunks/{chunk-2GILUQJY.js → chunk-R7ZGDHME.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HNEWGADJ.js → chunk-RUXOFW5G.js} +7 -6
- package/dist/safe-bash/command-chunks/{chunk-LKAFLJ5L.js → chunk-RWQKX44L.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-PKH57OIC.js → chunk-SG2KOOD4.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-T4TGJYFV.js +60 -0
- package/dist/safe-bash/command-chunks/chunk-TGSNVLFZ.js +105 -0
- package/dist/safe-bash/command-chunks/{chunk-NXCJNPL3.js → chunk-UCE77LYV.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-EWECMOQ5.js → chunk-UIHPHIKI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XSZNL3GV.js → chunk-UJPWPRVB.js} +191 -146
- package/dist/safe-bash/command-chunks/{chunk-E5CDHXFA.js → chunk-VOR6YDZC.js} +26 -1
- package/dist/safe-bash/command-chunks/chunk-VSNVYOK2.js +30 -0
- package/dist/safe-bash/command-chunks/{chunk-4XYGJB24.js → chunk-VTH4AORO.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-W5LH7D23.js → chunk-WKKJJBJQ.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-OLXMWQJ5.js → chunk-WRO3PB2M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RUAGHZNF.js → chunk-X5ODTF3E.js} +7 -5
- package/dist/safe-bash/command-chunks/{chunk-LH4VBNF6.js → chunk-XGTSP2CP.js} +84 -16
- package/dist/safe-bash/command-chunks/{chunk-K576GZED.js → chunk-XTHKXCF2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-J3VS55K4.js → chunk-YHRESVJ7.js} +9 -3
- package/dist/safe-bash/command-chunks/{chunk-UWIDPTOB.js → chunk-YSCKOUQP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-UYNJF5QN.js → chunk-ZALAWNOE.js} +76 -122
- package/dist/safe-bash/command-chunks/{chunk-OT75C5YS.js → chunk-ZYXKW2K7.js} +1 -1
- package/dist/safe-bash/command-chunks/{pdf-renderer-346WYKSZ.js → pdf-renderer-5QWOVFA4.js} +1 -1
- package/dist/safe-bash/command-chunks/{prompt-tool-debug-3POFNRYP.js → prompt-tool-debug-G7ATE7D5.js} +6 -4
- package/dist/safe-bash/commands/llm/index.browser.js +5 -1
- package/dist/safe-bash/commands/llm/index.js +1 -1
- package/dist/safe-bash/commands/python/executor.browser.js +3 -1
- package/dist/safe-bash/commands/python/executor.js +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +5 -1
- package/dist/safe-bash/commands/python/index.js +1 -1
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/full-core.browser.js +10 -2
- package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
- package/dist/safe-bash-command-awk/awk-syntax.js +1 -1
- package/dist/safe-bash-command-awk/awk.js +3 -3
- package/dist/safe-bash-command-awk/index.js +3 -3
- package/dist/safe-bash-command-gpg/index.js +11 -3
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-llm/collections.js +6 -4
- package/dist/safe-bash-command-llm/command.js +4 -4
- package/dist/safe-bash-command-llm/import-json-document.d.ts +9 -2
- package/dist/safe-bash-command-llm/index.d.ts +2 -1
- package/dist/safe-bash-command-llm/index.js +10 -4
- package/dist/safe-bash-command-llm/loader-provider.d.ts +5 -0
- package/dist/safe-bash-command-mcp/index.js +10 -13
- package/dist/safe-bash-command-pdftoppm/index.js +2 -2
- package/dist/safe-bash-command-playwright-cli/index.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.d.ts +1 -0
- package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/controller.d.ts +2 -0
- package/dist/safe-bash-command-playwright-cli/playwright/controller.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/index.js +2 -2
- package/dist/safe-bash-command-python/build-backend.d.ts +2 -0
- package/dist/safe-bash-command-python/cache.d.ts +1 -1
- package/dist/safe-bash-command-python/executor.d.ts +5 -2
- package/dist/safe-bash-command-python/executor.js +11 -6
- package/dist/safe-bash-command-python/host-capabilities.js +1 -1
- package/dist/safe-bash-command-python/index.js +11 -6
- package/dist/safe-bash-command-python/jspi.js +5 -3
- package/dist/safe-bash-command-python/manifest-file.d.ts +44 -0
- package/dist/safe-bash-command-python/manifest.d.ts +45 -0
- package/dist/safe-bash-command-python/provisioning.d.ts +20 -1
- package/dist/safe-bash-command-python/provisioning.js +3 -2
- package/dist/safe-bash-command-python/reply.js +7 -11
- package/dist/safe-bash-command-python/source-archive.js +2 -2
- package/dist/safe-bash-command-python/source-zip.js +2 -2
- package/dist/safe-bash-command-python/worker.js +34 -21
- package/dist/safe-bash-command-sqlite3/engine.d.ts +4 -0
- package/dist/safe-bash-command-sqlite3/index.js +174 -18
- package/dist/safe-bash-command-svgo/index.js +1 -1
- package/dist/safe-bash-command-tar/create.js +3 -3
- package/dist/safe-bash-command-tar/extract.js +3 -3
- package/dist/safe-bash-command-tar/index.js +5 -5
- package/dist/safe-bash-command-tar/modes.js +5 -5
- package/dist/safe-bash-command-tar/options.d.ts +1 -1
- package/dist/safe-bash-command-tar/options.js +1 -1
- package/dist/safe-bash-command-tar/stream.js +1 -1
- package/dist/safe-bash-command-wkhtmltopdf/index.js +1 -1
- package/dist/safe-bash-command-xan/argv.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +3 -3
- package/dist/safe-bash-command-xan/index.js +3 -3
- package/dist/safe-bash-command-xan/io.js +2 -2
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/options.js +1 -1
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +1 -1
- package/dist/safe-bash-csv-engine/index.js +6 -6
- package/dist/safe-bash-csv-engine/python-codec-aliases.js +1 -1
- package/dist/safe-bash-csv-engine/python-codepages.js +3 -3
- package/dist/safe-bash-csv-engine/python-file-codepages.js +2 -2
- package/dist/safe-bash-csv-engine/python-utf16.js +4 -4
- package/dist/safe-bash-csv-engine/text-decoder.js +6 -6
- package/dist/safe-bash-graphviz-engine/index.js +1 -1
- package/dist/safe-bash-pager-engine/index.js +2 -2
- package/dist/safe-bash-query-engine/capture.js +3 -3
- package/dist/safe-bash-query-engine/delpaths.js +3 -3
- package/dist/safe-bash-query-engine/formats.js +2 -2
- package/dist/safe-bash-query-engine/index.js +10 -10
- package/dist/safe-bash-query-engine/indices.js +3 -3
- package/dist/safe-bash-query-engine/input.d.ts +3 -3
- package/dist/safe-bash-query-engine/input.js +1 -1
- package/dist/safe-bash-query-engine/interpreter.js +9 -9
- package/dist/safe-bash-query-engine/query-core.js +10 -10
- package/dist/safe-bash-query-engine/regex.js +4 -4
- package/dist/safe-bash-query-engine/splits.js +5 -5
- package/dist/safe-bash-query-engine/values.js +2 -2
- package/package.json +2 -2
- package/dist/safe-bash/command-chunks/chunk-OOYVZAWL.js +0 -90
- package/dist/safe-bash/command-chunks/chunk-RZOHZGEZ.js +0 -772
- package/dist/safe-bash/command-chunks/chunk-WIUEM7HP.js +0 -58
- package/dist/safe-bash/command-chunks/chunk-WY6THI6J.js +0 -673
- package/dist/safe-bash/command-chunks/chunk-ZERCTWUI.js +0 -467
|
@@ -3,14 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-FXWKMNX2.js";
|
|
4
4
|
import {
|
|
5
5
|
installPythonPackages,
|
|
6
|
+
loadPythonRuntimePrograms,
|
|
6
7
|
parsePythonInvocation,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
pythonImportMetadata,
|
|
10
|
-
pythonRuntimeRelocation,
|
|
11
|
-
pythonStatProjection,
|
|
12
|
-
pythonTreeCleanup
|
|
13
|
-
} from "./chunk-WY6THI6J.js";
|
|
8
|
+
pythonExecution
|
|
9
|
+
} from "./chunk-L54KVUSY.js";
|
|
14
10
|
import {
|
|
15
11
|
pythonJspiSignatures
|
|
16
12
|
} from "./chunk-P56KGNW7.js";
|
|
@@ -22,7 +18,33 @@ import {
|
|
|
22
18
|
} from "./chunk-TO6UNFEF.js";
|
|
23
19
|
import {
|
|
24
20
|
pythonHostFailureCode
|
|
25
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3QCW4VQF.js";
|
|
22
|
+
|
|
23
|
+
// packages/safe-bash-command-python/src/jspi-dynlib.ts
|
|
24
|
+
function installPythonJspiDynlib(module, active) {
|
|
25
|
+
const engine = globalThis.WebAssembly;
|
|
26
|
+
const load = engine.promising(module._emscripten_dlopen_promise);
|
|
27
|
+
module._emscripten_dlopen_promise = (pointer, flags) => {
|
|
28
|
+
const bytes = new TextEncoder().encode(module.UTF8ToString(pointer) + "\0");
|
|
29
|
+
const owned = module._malloc(bytes.length);
|
|
30
|
+
if (!owned) throw new Error("Native library pathname allocation failed");
|
|
31
|
+
module.HEAPU8.set(bytes, owned);
|
|
32
|
+
const promise = Promise.resolve().then(async () => {
|
|
33
|
+
const previous = active.value;
|
|
34
|
+
active.value = 2;
|
|
35
|
+
try {
|
|
36
|
+
const id = await load(owned, flags);
|
|
37
|
+
const completion = module.getPromise(id);
|
|
38
|
+
module.promiseMap.free(id);
|
|
39
|
+
return await completion;
|
|
40
|
+
} finally {
|
|
41
|
+
active.value = previous;
|
|
42
|
+
module._free(owned);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return module.promiseMap.allocate({ promise });
|
|
46
|
+
};
|
|
47
|
+
}
|
|
26
48
|
|
|
27
49
|
// packages/safe-bash-command-python/src/jspi.ts
|
|
28
50
|
import { createPythonNativeSyscalls } from "@poe-platform/safe-fs/core";
|
|
@@ -361,6 +383,14 @@ function createPythonJspiExecutor(options) {
|
|
|
361
383
|
let statPointer;
|
|
362
384
|
const originals = {};
|
|
363
385
|
const execute = async (start) => {
|
|
386
|
+
let pendingDispatch = Promise.resolve();
|
|
387
|
+
const dispatch = (request) => {
|
|
388
|
+
const operation = pendingDispatch.then(() => start.dispatch(request));
|
|
389
|
+
pendingDispatch = operation.then(() => {
|
|
390
|
+
}, () => {
|
|
391
|
+
});
|
|
392
|
+
return operation;
|
|
393
|
+
};
|
|
364
394
|
const signal = AbortSignal.any([start.signal, controller.signal]);
|
|
365
395
|
const configuration = parsePythonInvocation(start.invocation.args, start.invocation.env);
|
|
366
396
|
let guestMask = 18;
|
|
@@ -397,7 +427,7 @@ function createPythonJspiExecutor(options) {
|
|
|
397
427
|
name,
|
|
398
428
|
(...args) => native.invoke(name, args)
|
|
399
429
|
]));
|
|
400
|
-
const shutdown = Object.fromEntries(Object.entries(request).map(([name,
|
|
430
|
+
const shutdown = Object.fromEntries(Object.entries(request).map(([name, dispatch2]) => [name, new engine.Suspending(dispatch2)]));
|
|
401
431
|
const bridge = new engine.Instance(options.trampoline, { original, request, shutdown, control: { active, syncify } });
|
|
402
432
|
for (const namespace of namespaces) for (const name of Object.keys(originals)) {
|
|
403
433
|
if (typeof namespace[name] === "function") namespace[name] = bridge.exports[name];
|
|
@@ -419,134 +449,119 @@ function createPythonJspiExecutor(options) {
|
|
|
419
449
|
qualified = true;
|
|
420
450
|
runtime._api.config.enableRunUntilComplete = true;
|
|
421
451
|
signal.throwIfAborted();
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
452
|
+
runtime.runPython("import sys, os, json, runpy, traceback, types, warnings, textwrap, io, struct, linecache, importlib.machinery, shutil, stat, pyodide.ffi, site, sysconfig, pyodide._package_loader");
|
|
453
|
+
runtime.globals.set("_safe_runtime_mount", start.runtimeMount);
|
|
454
|
+
const filesystem = runtime.FS;
|
|
455
|
+
const bootstrap = filesystem.root;
|
|
456
|
+
filesystem.root = null;
|
|
457
|
+
filesystem.mount(filesystem.filesystems.MEMFS, {}, "/");
|
|
458
|
+
filesystem.mkdir(start.runtimeMount);
|
|
459
|
+
filesystem.mount({ mount: () => bootstrap }, {}, start.runtimeMount);
|
|
460
|
+
const { pythonRuntimeRelocation, pythonImportMetadata, pythonDirectoryEntries, pythonStatProjection, pythonTreeCleanup, pythonMetadataDiscovery } = await loadPythonRuntimePrograms();
|
|
461
|
+
runtime.runPython(pythonRuntimeRelocation);
|
|
462
|
+
filesystem.currentPath = start.invocation.cwd;
|
|
463
|
+
native = createPythonNativeSyscalls({
|
|
464
|
+
getUmask: () => guestMask,
|
|
465
|
+
runtime: runtime._module,
|
|
466
|
+
cwd: start.invocation.cwd,
|
|
467
|
+
runtimeMount: start.runtimeMount,
|
|
468
|
+
maxTransferBytes: start.maxTransferBytes,
|
|
469
|
+
signal,
|
|
470
|
+
dispatch,
|
|
471
|
+
original: (name, args) => originals[name](...args)
|
|
472
|
+
});
|
|
473
|
+
const errno = JSON.parse(runtime.runPython("__import__('json').dumps({name:value for name,value in vars(__import__('errno')).items() if name.startswith('E') and isinstance(value,int)})"));
|
|
474
|
+
const encode = async (operation) => {
|
|
475
|
+
try {
|
|
476
|
+
return JSON.stringify(await operation());
|
|
477
|
+
} catch (error) {
|
|
478
|
+
return JSON.stringify({ errno: signal.aborted ? errno.EINTR : error.errno ?? errno[error.code ?? ""] ?? errno.EIO });
|
|
438
479
|
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
runtime: runtime._module,
|
|
453
|
-
cwd: start.invocation.cwd,
|
|
454
|
-
runtimeMount: start.runtimeMount,
|
|
455
|
-
maxTransferBytes: start.maxTransferBytes,
|
|
456
|
-
signal,
|
|
457
|
-
dispatch: start.dispatch,
|
|
458
|
-
original: (name, args) => originals[name](...args)
|
|
459
|
-
});
|
|
460
|
-
const errno = JSON.parse(runtime.runPython("__import__('json').dumps({name:value for name,value in vars(__import__('errno')).items() if name.startswith('E') and isinstance(value,int)})"));
|
|
461
|
-
const encode = async (operation) => {
|
|
462
|
-
try {
|
|
463
|
-
return JSON.stringify(await operation());
|
|
464
|
-
} catch (error) {
|
|
465
|
-
return JSON.stringify({ errno: signal.aborted ? errno.EINTR : error.errno ?? errno[error.code ?? ""] ?? errno.EIO });
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
const absolute = (path) => path.startsWith("/") ? path : filesystem.cwd() + "/" + path;
|
|
469
|
-
const bootstrapPath = (path) => path === start.runtimeMount || path.startsWith(start.runtimeMount + "/");
|
|
470
|
-
const module = runtime._module;
|
|
471
|
-
const send = async (pointer) => {
|
|
472
|
-
let response = await encode(async () => {
|
|
473
|
-
const payload = JSON.parse(module.UTF8ToString(pointer));
|
|
474
|
-
if (payload[0] === "host") {
|
|
475
|
-
try {
|
|
476
|
-
if (!start.host || !acceptingHostCalls) throw new Error("Python host capability unavailable");
|
|
477
|
-
return { value: await start.host.request(payload[1]) };
|
|
478
|
-
} catch (error) {
|
|
479
|
-
return { errorCode: pythonHostFailureCode(error), error: signal.aborted ? "Python host operation cancelled" : "Python host operation failed" };
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
signal.throwIfAborted();
|
|
483
|
-
const [operation, path, follow] = payload;
|
|
484
|
-
if (operation === "stat") return native.metadata(path, follow);
|
|
485
|
-
if (typeof path !== "string") throw Object.assign(new Error("Invalid native Python path"), { code: "EINVAL" });
|
|
486
|
-
const target = absolute(path);
|
|
487
|
-
if (operation === "directory") {
|
|
488
|
-
const entries = bootstrapPath(target) ? filesystem.readdir(target).filter((name) => name !== "." && name !== "..") : (await start.dispatch({ op: "readdir", args: [target] })).map((entry) => entry.name);
|
|
489
|
-
return { entries };
|
|
480
|
+
};
|
|
481
|
+
const absolute = (path) => path.startsWith("/") ? path : filesystem.cwd() + "/" + path;
|
|
482
|
+
const bootstrapPath = (path) => path === start.runtimeMount || path.startsWith(start.runtimeMount + "/");
|
|
483
|
+
const module = runtime._module;
|
|
484
|
+
const send = async (pointer) => {
|
|
485
|
+
let response = await encode(async () => {
|
|
486
|
+
const payload = JSON.parse(module.UTF8ToString(pointer));
|
|
487
|
+
if (payload[0] === "host") {
|
|
488
|
+
try {
|
|
489
|
+
if (!start.host || !acceptingHostCalls) throw new Error("Python host capability unavailable");
|
|
490
|
+
return { value: await start.host.request(payload[1]) };
|
|
491
|
+
} catch (error) {
|
|
492
|
+
return { errorCode: pythonHostFailureCode(error), error: signal.aborted ? "Python host operation cancelled" : "Python host operation failed" };
|
|
490
493
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
494
|
+
}
|
|
495
|
+
if (payload[0] === "cursor" && ["directoryOpen", "directoryNext", "close"].includes(payload[1])) return { value: await dispatch({ op: payload[1], args: [payload[2]] }) };
|
|
496
|
+
signal.throwIfAborted();
|
|
497
|
+
const [operation, path, follow] = payload;
|
|
498
|
+
if (operation === "metadata") return { value: await dispatch({ op: "package-root", args: [start.packages?.session] }) };
|
|
499
|
+
if (operation === "stat") return native.metadata(path, follow);
|
|
500
|
+
if (typeof path !== "string") throw Object.assign(new Error("Invalid native Python path"), { code: "EINVAL" });
|
|
501
|
+
const target = absolute(path);
|
|
502
|
+
if (operation === "directory") {
|
|
503
|
+
const entries = bootstrapPath(target) ? filesystem.readdir(target).filter((name) => name !== "." && name !== "..") : (await dispatch({ op: "readdir", args: [target] })).map((entry) => entry.name);
|
|
504
|
+
return { entries };
|
|
505
|
+
}
|
|
506
|
+
if (operation === "tree") {
|
|
507
|
+
if (bootstrapPath(target) || !await dispatch({ op: "rmtreeSupported", args: [target] })) return { supported: false };
|
|
508
|
+
try {
|
|
509
|
+
await dispatch({ op: "rmtree", args: [target] });
|
|
510
|
+
return { supported: true };
|
|
511
|
+
} catch (error) {
|
|
512
|
+
return { supported: true, errno: errno[error.code ?? ""] ?? errno.EIO };
|
|
499
513
|
}
|
|
500
|
-
|
|
501
|
-
});
|
|
502
|
-
if (response.length > 1048576) response = JSON.stringify({ errno: errno.EFBIG });
|
|
503
|
-
let bytes = new TextEncoder().encode(response);
|
|
504
|
-
if (bytes.length > 1048576) bytes = new TextEncoder().encode(JSON.stringify({ errno: errno.EFBIG }));
|
|
505
|
-
const output = module._malloc(bytes.length + 1);
|
|
506
|
-
if (!output) return 0;
|
|
507
|
-
module.HEAPU8.set(bytes, output);
|
|
508
|
-
module.HEAPU8[output + bytes.length] = 0;
|
|
509
|
-
return output;
|
|
510
|
-
};
|
|
511
|
-
const nativeCall = new engine.Instance(options.nativeCall, {
|
|
512
|
-
python: {
|
|
513
|
-
utf8: module._PyUnicode_AsUTF8,
|
|
514
|
-
unicode: module._PyUnicode_FromString,
|
|
515
|
-
free: module._free,
|
|
516
|
-
noMemory: module._PyErr_NoMemory
|
|
517
|
-
},
|
|
518
|
-
request: { send },
|
|
519
|
-
shutdown: { send: new engine.Suspending(send) },
|
|
520
|
-
control: { active, syncify }
|
|
514
|
+
}
|
|
515
|
+
throw Object.assign(new Error("Invalid native Python operation"), { code: "EINVAL" });
|
|
521
516
|
});
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (
|
|
525
|
-
module.
|
|
526
|
-
|
|
527
|
-
module.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
517
|
+
if (response.length > 1048576) response = JSON.stringify({ errno: errno.EFBIG });
|
|
518
|
+
let bytes = new TextEncoder().encode(response);
|
|
519
|
+
if (bytes.length > 1048576) bytes = new TextEncoder().encode(JSON.stringify({ errno: errno.EFBIG }));
|
|
520
|
+
const output = module._malloc(bytes.length + 1);
|
|
521
|
+
if (!output) return 0;
|
|
522
|
+
module.HEAPU8.set(bytes, output);
|
|
523
|
+
module.HEAPU8[output + bytes.length] = 0;
|
|
524
|
+
return output;
|
|
525
|
+
};
|
|
526
|
+
const nativeCall = new engine.Instance(options.nativeCall, {
|
|
527
|
+
python: {
|
|
528
|
+
utf8: module._PyUnicode_AsUTF8,
|
|
529
|
+
unicode: module._PyUnicode_FromString,
|
|
530
|
+
free: module._free,
|
|
531
|
+
noMemory: module._PyErr_NoMemory
|
|
532
|
+
},
|
|
533
|
+
request: { send },
|
|
534
|
+
shutdown: { send: new engine.Suspending(send) },
|
|
535
|
+
control: { active, syncify }
|
|
536
|
+
});
|
|
537
|
+
methodPointer = module.addFunction(nativeCall.exports.call, "iii");
|
|
538
|
+
methodDefinition = module._malloc(128);
|
|
539
|
+
if (!methodDefinition) throw new PythonFailure("runtime-assets");
|
|
540
|
+
module.HEAPU8.fill(0, methodDefinition, methodDefinition + 128);
|
|
541
|
+
module.HEAPU8.set(new TextEncoder().encode("request\0_safe_native_fs\0"), methodDefinition + 16);
|
|
542
|
+
module.HEAPU32.set([methodDefinition + 16, methodPointer, 8, 0], methodDefinition / 4);
|
|
543
|
+
const extension = module._PyImport_AddModule(methodDefinition + 24);
|
|
544
|
+
const callable = module._PyCFunction_NewEx(methodDefinition, 0, 0);
|
|
545
|
+
if (!extension || !callable || module._PyModule_AddObject(extension, methodDefinition + 16, callable) < 0) throw new PythonFailure("runtime-abi");
|
|
546
|
+
const fields = Number(runtime.runPython("os.stat_result.n_fields"));
|
|
547
|
+
const statResult = new engine.Instance(options.statResult, { python: {
|
|
548
|
+
fields: new engine.Global({ value: "i32" }, fields),
|
|
549
|
+
create: module._PyStructSequence_New,
|
|
550
|
+
size: module._PyTuple_Size,
|
|
551
|
+
item: module._PyTuple_GetItem,
|
|
552
|
+
retain: module._Py_IncRef,
|
|
553
|
+
set: module._PyStructSequence_SetItem,
|
|
554
|
+
invalid: module._PyErr_BadArgument
|
|
555
|
+
} });
|
|
556
|
+
statPointer = module.addFunction(statResult.exports.construct, "iii");
|
|
557
|
+
module.HEAPU8.set(new TextEncoder().encode("stat_result\0os\0"), methodDefinition + 80);
|
|
558
|
+
module.HEAPU32.set([methodDefinition + 80, statPointer, 8, 0], (methodDefinition + 64) / 4);
|
|
559
|
+
const osModule = module._PyImport_AddModule(methodDefinition + 92);
|
|
560
|
+
const statType = module._PyObject_GetAttrString(osModule, methodDefinition + 80);
|
|
561
|
+
const constructStat = module._PyCFunction_NewEx(methodDefinition + 64, statType, 0);
|
|
562
|
+
module._Py_DecRef(statType);
|
|
563
|
+
if (!constructStat || module._PyModule_AddObject(extension, methodDefinition + 80, constructStat) < 0) throw new PythonFailure("runtime-abi");
|
|
564
|
+
runtime.runPython(`
|
|
550
565
|
from _safe_native_fs import request as _safe_native_request
|
|
551
566
|
def _safe_stat_projection(path, follow):
|
|
552
567
|
return _safe_native_request(json.dumps(['stat', path, follow]))
|
|
@@ -554,11 +569,18 @@ def _safe_import_stat(path):
|
|
|
554
569
|
return _safe_stat_projection(path, True)
|
|
555
570
|
def _safe_directory_entries(path):
|
|
556
571
|
return _safe_native_request(json.dumps(['directory', path]))
|
|
572
|
+
def _safe_directory_cursor(operation, value):
|
|
573
|
+
return _safe_native_request(json.dumps(['cursor', operation, value]))
|
|
557
574
|
def _safe_tree_cleanup(path):
|
|
558
575
|
return _safe_native_request(json.dumps(['tree', path]))
|
|
576
|
+
def _safe_metadata_root():
|
|
577
|
+
value = json.loads(_safe_native_request('["metadata"]'))
|
|
578
|
+
if 'errno' in value:
|
|
579
|
+
raise OSError(value['errno'], 'metadata backing unavailable')
|
|
580
|
+
return value['value']
|
|
559
581
|
`);
|
|
560
|
-
|
|
561
|
-
|
|
582
|
+
for (const script of [pythonImportMetadata, pythonDirectoryEntries, pythonStatProjection, pythonTreeCleanup]) runtime.runPython(script);
|
|
583
|
+
runtime.runPython(`
|
|
562
584
|
from _safe_native_fs import stat_result as _safe_construct_stat
|
|
563
585
|
_safe_stat_fields = os.stat_result.n_fields
|
|
564
586
|
_safe_stat_probe = os.stat_result(tuple(range(_safe_stat_fields)))
|
|
@@ -571,17 +593,40 @@ def _safe_native_stat_type(values, extras):
|
|
|
571
593
|
return _safe_construct_stat(tuple(fields))
|
|
572
594
|
_safe_stat_type = _safe_native_stat_type
|
|
573
595
|
`);
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
596
|
+
runtime.runPython(pythonHostModule);
|
|
597
|
+
installPythonLlmModule(runtime);
|
|
598
|
+
installPythonShellModule(runtime);
|
|
599
|
+
installPythonJspiRunSync(runtime);
|
|
600
|
+
runtime.runPython(pythonLibraryAdapter);
|
|
601
|
+
runtime.runPython("import tempfile; tempfile.tempdir = None");
|
|
602
|
+
runtime.globals.set("_safe_invocation_json", JSON.stringify(start.invocation));
|
|
603
|
+
runtime.globals.set("_safe_execution_code", pythonExecution);
|
|
604
|
+
runtime.globals.set("_safe_is_cancelled", () => signal.aborted);
|
|
605
|
+
active.value = 1;
|
|
606
|
+
if (typeof module._emscripten_dlopen_promise === "function") installPythonJspiDynlib(module, active);
|
|
607
|
+
if (start.packages) {
|
|
608
|
+
await runtime.runPythonAsync(pythonMetadataDiscovery);
|
|
609
|
+
const installationRoot = start.packages.requirements.length || start.packages.uninstall || start.packages.bootstrap ? await dispatch({ op: "package-root", args: [start.packages.session] }) : void 0;
|
|
610
|
+
await installPythonPackages(
|
|
611
|
+
runtime,
|
|
612
|
+
start.packages,
|
|
613
|
+
(op, ...args) => dispatch({ op, args }),
|
|
614
|
+
start.maxTransferBytes,
|
|
615
|
+
installationRoot
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
const unavailablePackage = () => {
|
|
619
|
+
throw new Error("Python package transport is only available during installation");
|
|
620
|
+
};
|
|
621
|
+
if ("loadPackage" in runtime) runtime.loadPackage = unavailablePackage;
|
|
622
|
+
if (runtime._api.packageManager) runtime._api.packageManager.downloadPackage = unavailablePackage;
|
|
623
|
+
start.onReady();
|
|
624
|
+
if (start.installOnly) {
|
|
625
|
+
const message = new TextEncoder().encode(start.packages?.uninstall ? "" : "Successfully installed requested Python packages\n");
|
|
626
|
+
for (let offset = 0; offset < message.length; offset += start.maxTransferBytes) {
|
|
627
|
+
await dispatch({ op: "stdout", args: [Array.from(message.subarray(offset, offset + start.maxTransferBytes))] });
|
|
628
|
+
}
|
|
629
|
+
} else {
|
|
585
630
|
exitCode = Number(await runtime.runPythonAsync(`
|
|
586
631
|
try:
|
|
587
632
|
exec(_safe_execution_code)
|
|
@@ -226,8 +226,32 @@ function stripPythonWhitespace(value) {
|
|
|
226
226
|
return value.slice(start, end);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
// packages/safe-bash-command-llm/src/unicode-ranges.ts
|
|
230
|
+
var ranges = /* @__PURE__ */ (() => {
|
|
231
|
+
let packed = "M^8p.2pM,81$4%+m2u2Fe5bf4*$y442&3$70+$2j2O+G49B52B&07E1E2q53K1G1m95%y3$g{e)h02tuU2c0fG1a1.6l.a}oo8aS1k2hZ1R1(j089592f573&l-$43(h0e%25b35)955&l-2%%1w&$8932h8+2l-2%4(j0g`9a0c73&l-2%4(v%259-c0254+341$/4@>bn0mcj7+2m2f(r-`996$57+2m[>(x,/59/i8+2E&0h06+95i256h4n28$36w^iL%1d6a9E<$>2n$[/a034$a9?x,w1jd72z1s4Q3G1la7553(4{25cd0[7B1$]3G%Ia:36$:3E%?w%?6$:3e2U%?y2fj4fhR:54Hj3g2p6G>a8c:fhfhfc+gP1A,.4979n97U2843x1$6B2buE1D&4cH`p7aC1maQ1I^79e0!2K1i659G1teT1rz1t94M&88G&2G&25/(6#5x2R8353B&537$$$2u3Q%6$4+64?55c6+6Q3&56a7cC).39$4470$$:2a?64.2V1TmX1L2lTjtJz1K%K%A47341a03B1$]3T1*hma6-------N$Se2q884345R27+V+36G%Z>3bvN1fx^v72ex^E1exa#J6x2YLk4IA1A2J&I84rlK1hu3L2E{3C?Q&8H1c+:2me5bP1fN1t9p5(2%B=mqs8K1ta74~E1o+7597m(4N1$4&4)$p:a82d53535a6-2G%d7O3e97zZadm5M1BE8Jb3F3D16d4][2c>$2%%H3y1Gbj#&R1F=R342C4k98p7pcU>5353532A=2p2i2%e3dz1W3dI1dU1i1R7s4M1hq5z1at6B=t3z`7>H1Z4397z`z`D^P1Z4S9alb7V45)2H%1(3m3u3B^8N1i/6w`pD2T`j3K1g3+2sb8ou2vx;2r74hR=l3q6po6N2E2U1O1eO{F1d9D9u2F;1L2D^lc3Y2rlmdQ1rtkI1x1o89az1g9.)9y1(dL1f3ca$5jch2oR-$:2e[8K1i9c73&l-2%4(j0d4#4Q1j36962vL1l1$99D5K1G&B1L1l0c9D1G1e089T1qmbB6H1R3O2d7)372%ng0$f9D273C1h0$t0bD1*m0cJ1k0z1U1E882A1i0gs6tN362%B1m0a9752%vf089T9i!.gkI1VsD3K3iz6ZR2Kx1O!3CiWJ8Uh8u[D3tjL1h3d9-2k6iNlS2G3G-0z2cx/$tT#59RC1H{UT8!8O%i39HcBE2G36c4889DO5jJ3oE4Q+C+&03&32b$-2w+?7-2r:>$462Pa3o~u~u~u~u~73N1xE2I=639.ObH`9DE1A638N1z2*59UoW%+3J2I%ez632q/$)[:$$70.$$+/$)$$$$/$?-::$[2g6+42gBicAT[Dw1ZSF1z1Qx4cZ63xQ5fMF7wx3ZgzL1GW4|0vw3x1d0Hm;3*$l0Kc0D<P<(U;s37gn1w]N<Y<C3dY<O<g0t1$cQ1m0jag0y.9&1n0*+51a&`7:)61q1(7?1n0*))31$6?@+6.-i9(a}n0*)6=}4%e51d6*(9&1n0*)61a&@643)61j9)72(52)$3:>2d362(5%52dm4e}o0h[}56)445=6n}o0b061a}5636$5=03ce}Q,(73h1r}j2p0a0/8+370$95b@bX&uA&0$]p0$o1]$7=`vF$B&E,B,g0eA1D]>/Wb051*$51G,51y,51*$51g0W,51A/x%r5T/71xk0t2W-e08ao8lbe}3b#/b5b5f=5W-I@D[w,d3d3+H<6aJ&r5c2#<y$u1c5b5f1i!1J:K%R37Z%g2Z16I<c7I@X70Y8;1D1;^0$$$w<S,g0f;0k1(agp7M1g31s0e2x1fy1eJ43UkockRU<x,V(M,R44K,>/V163dp8********Q3I1r0W2bT6pd4w$T/E34I,#$R2bM,!Kr2KA%U{ZajV57x61aF1V%b5V;D27d5R3av2L$c3y,U{f=1E3nt97;;8**Z=5BZabo3O1zE8Lb1H3B{b64r0]$))Z3gKbfx/T1D1f1r5Q,k053]E43#527;;@2*8c31d0r0k0)g1fx1Y3443K%V$e+K1L1x4u2O1et3B{v4I@v0C&fF1#4=5B&B&F;R1a2L4U98n99T471$J,3+1o0F27aL1k034y%s42#1V&l1P,349}u@3b6a6x2vE&d8T%u1s4r65b8L2G2S1Q1cQ16L;bB9w,H,4&J2F;H1R2tjo8L:ve#,5dq6b5S,j7E{x)laj0J1w2*$.g0c5Y@b5.9&1n0*)]b&@%5>8{-G4Z$6tF27bB5T<D1x1C2ab5eiW16bR1s1g3h#5Z1z3Q2b9%^0)v031d8bB[1L<cqF27Q2sW1C8a0K,f9u2x<n0fE2*)J%$)a7b570)C,)76bR9qS52eP1cYsB3M)6aB6XR2Mx1M!3EiUJ8Wh6w,b?#2v;9D[b0*m4kLlY2A3I:W16i#16a3dV#57TC1F1aST8w9M@g57JczE2I34e2a6b`#W4T79E<H27L3mD2V4lbU28qC4S$E$3%&1.d0$*y$5^0*t0.]+*Ra1B91#le]gLG1*i1*)6Q6K%f=?LbX@2#D1C61hE1J:b?MoB2H2!1x6.s0)/$b0.$25:$$$()/$$$$$)/.*..$b0i4(]iP&J8J&B3bg1g0g0C^L5T1ucJ&a63d7V4Vu7e2e2R3bW-djd3V;b5F;v&J2W)P$E4bf16>488q6884c8E1Q(U1A=Bw1#SF1x1Sx4a#61zQ5dOF7!w3#gxL1IW4QJXlN7LM#5";
|
|
232
|
+
const markers = "$%&()*+,-./:;<=>?@[]^`{}~", fragments = "20~12~13~40~30~80~22~10~26~50~21~23~17~11~1b~24~33~14~29~60~19~15~18~0(~2o2".split("~");
|
|
233
|
+
for (let index = fragments.length; index--; ) packed = packed.split(markers[index]).join(fragments[index]);
|
|
234
|
+
return packed.split("|");
|
|
235
|
+
})();
|
|
236
|
+
function decodeUnicodeRanges(index) {
|
|
237
|
+
const result = [], alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#";
|
|
238
|
+
let point = 0, value = 0, shift = 0;
|
|
239
|
+
for (const char of ranges[index]) {
|
|
240
|
+
const digit = alphabet.indexOf(char);
|
|
241
|
+
value += (digit & 31) * 2 ** shift;
|
|
242
|
+
if (digit < 32) {
|
|
243
|
+
result.push(point += value);
|
|
244
|
+
value = 0;
|
|
245
|
+
shift = 0;
|
|
246
|
+
} else shift += 5;
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// packages/safe-bash-command-llm/src/printable-ranges.ts
|
|
252
|
+
var excluded = /* @__PURE__ */ decodeUnicodeRanges(1);
|
|
253
|
+
|
|
229
254
|
// packages/safe-bash-command-llm/src/python-printable.ts
|
|
230
|
-
var excluded = [0, 31, 127, 160, 173, 173, 888, 889, 896, 899, 907, 907, 909, 909, 930, 930, 1328, 1328, 1367, 1368, 1419, 1420, 1424, 1424, 1480, 1487, 1515, 1518, 1525, 1541, 1564, 1565, 1757, 1757, 1806, 1807, 1867, 1868, 1970, 1983, 2043, 2044, 2094, 2095, 2111, 2111, 2140, 2141, 2143, 2143, 2155, 2207, 2229, 2229, 2248, 2258, 2274, 2274, 2436, 2436, 2445, 2446, 2449, 2450, 2473, 2473, 2481, 2481, 2483, 2485, 2490, 2491, 2501, 2502, 2505, 2506, 2511, 2518, 2520, 2523, 2526, 2526, 2532, 2533, 2559, 2560, 2564, 2564, 2571, 2574, 2577, 2578, 2601, 2601, 2609, 2609, 2612, 2612, 2615, 2615, 2618, 2619, 2621, 2621, 2627, 2630, 2633, 2634, 2638, 2640, 2642, 2648, 2653, 2653, 2655, 2661, 2679, 2688, 2692, 2692, 2702, 2702, 2706, 2706, 2729, 2729, 2737, 2737, 2740, 2740, 2746, 2747, 2758, 2758, 2762, 2762, 2766, 2767, 2769, 2783, 2788, 2789, 2802, 2808, 2816, 2816, 2820, 2820, 2829, 2830, 2833, 2834, 2857, 2857, 2865, 2865, 2868, 2868, 2874, 2875, 2885, 2886, 2889, 2890, 2894, 2900, 2904, 2907, 2910, 2910, 2916, 2917, 2936, 2945, 2948, 2948, 2955, 2957, 2961, 2961, 2966, 2968, 2971, 2971, 2973, 2973, 2976, 2978, 2981, 2983, 2987, 2989, 3002, 3005, 3011, 3013, 3017, 3017, 3022, 3023, 3025, 3030, 3032, 3045, 3067, 3071, 3085, 3085, 3089, 3089, 3113, 3113, 3130, 3132, 3141, 3141, 3145, 3145, 3150, 3156, 3159, 3159, 3163, 3167, 3172, 3173, 3184, 3190, 3213, 3213, 3217, 3217, 3241, 3241, 3252, 3252, 3258, 3259, 3269, 3269, 3273, 3273, 3278, 3284, 3287, 3293, 3295, 3295, 3300, 3301, 3312, 3312, 3315, 3327, 3341, 3341, 3345, 3345, 3397, 3397, 3401, 3401, 3408, 3411, 3428, 3429, 3456, 3456, 3460, 3460, 3479, 3481, 3506, 3506, 3516, 3516, 3518, 3519, 3527, 3529, 3531, 3534, 3541, 3541, 3543, 3543, 3552, 3557, 3568, 3569, 3573, 3584, 3643, 3646, 3676, 3712, 3715, 3715, 3717, 3717, 3723, 3723, 3748, 3748, 3750, 3750, 3774, 3775, 3781, 3781, 3783, 3783, 3790, 3791, 3802, 3803, 3808, 3839, 3912, 3912, 3949, 3952, 3992, 3992, 4029, 4029, 4045, 4045, 4059, 4095, 4294, 4294, 4296, 4300, 4302, 4303, 4681, 4681, 4686, 4687, 4695, 4695, 4697, 4697, 4702, 4703, 4745, 4745, 4750, 4751, 4785, 4785, 4790, 4791, 4799, 4799, 4801, 4801, 4806, 4807, 4823, 4823, 4881, 4881, 4886, 4887, 4955, 4956, 4989, 4991, 5018, 5023, 5110, 5111, 5118, 5119, 5760, 5760, 5789, 5791, 5881, 5887, 5901, 5901, 5909, 5919, 5943, 5951, 5972, 5983, 5997, 5997, 6001, 6001, 6004, 6015, 6110, 6111, 6122, 6127, 6138, 6143, 6158, 6159, 6170, 6175, 6265, 6271, 6315, 6319, 6390, 6399, 6431, 6431, 6444, 6447, 6460, 6463, 6465, 6467, 6510, 6511, 6517, 6527, 6572, 6575, 6602, 6607, 6619, 6621, 6684, 6685, 6751, 6751, 6781, 6782, 6794, 6799, 6810, 6815, 6830, 6831, 6849, 6911, 6988, 6991, 7037, 7039, 7156, 7163, 7224, 7226, 7242, 7244, 7305, 7311, 7355, 7356, 7368, 7375, 7419, 7423, 7674, 7674, 7958, 7959, 7966, 7967, 8006, 8007, 8014, 8015, 8024, 8024, 8026, 8026, 8028, 8028, 8030, 8030, 8062, 8063, 8117, 8117, 8133, 8133, 8148, 8149, 8156, 8156, 8176, 8177, 8181, 8181, 8191, 8207, 8232, 8239, 8287, 8303, 8306, 8307, 8335, 8335, 8349, 8351, 8384, 8399, 8433, 8447, 8588, 8591, 9255, 9279, 9291, 9311, 11124, 11125, 11158, 11158, 11311, 11311, 11359, 11359, 11508, 11512, 11558, 11558, 11560, 11564, 11566, 11567, 11624, 11630, 11633, 11646, 11671, 11679, 11687, 11687, 11695, 11695, 11703, 11703, 11711, 11711, 11719, 11719, 11727, 11727, 11735, 11735, 11743, 11743, 11859, 11903, 11930, 11930, 12020, 12031, 12246, 12271, 12284, 12288, 12352, 12352, 12439, 12440, 12544, 12548, 12592, 12592, 12687, 12687, 12772, 12783, 12831, 12831, 40957, 40959, 42125, 42127, 42183, 42191, 42540, 42559, 42744, 42751, 42944, 42945, 42955, 42996, 43053, 43055, 43066, 43071, 43128, 43135, 43206, 43213, 43226, 43231, 43348, 43358, 43389, 43391, 43470, 43470, 43482, 43485, 43519, 43519, 43575, 43583, 43598, 43599, 43610, 43611, 43715, 43738, 43767, 43776, 43783, 43784, 43791, 43792, 43799, 43807, 43815, 43815, 43823, 43823, 43884, 43887, 44014, 44015, 44026, 44031, 55204, 55215, 55239, 55242, 55292, 63743, 64110, 64111, 64218, 64255, 64263, 64274, 64280, 64284, 64311, 64311, 64317, 64317, 64319, 64319, 64322, 64322, 64325, 64325, 64450, 64466, 64832, 64847, 64912, 64913, 64968, 65007, 65022, 65023, 65050, 65055, 65107, 65107, 65127, 65127, 65132, 65135, 65141, 65141, 65277, 65280, 65471, 65473, 65480, 65481, 65488, 65489, 65496, 65497, 65501, 65503, 65511, 65511, 65519, 65531, 65534, 65535, 65548, 65548, 65575, 65575, 65595, 65595, 65598, 65598, 65614, 65615, 65630, 65663, 65787, 65791, 65795, 65798, 65844, 65846, 65935, 65935, 65949, 65951, 65953, 65999, 66046, 66175, 66205, 66207, 66257, 66271, 66300, 66303, 66340, 66348, 66379, 66383, 66427, 66431, 66462, 66462, 66500, 66503, 66518, 66559, 66718, 66719, 66730, 66735, 66772, 66775, 66812, 66815, 66856, 66863, 66916, 66926, 66928, 67071, 67383, 67391, 67414, 67423, 67432, 67583, 67590, 67591, 67593, 67593, 67638, 67638, 67641, 67643, 67645, 67646, 67670, 67670, 67743, 67750, 67760, 67807, 67827, 67827, 67830, 67834, 67868, 67870, 67898, 67902, 67904, 67967, 68024, 68027, 68048, 68049, 68100, 68100, 68103, 68107, 68116, 68116, 68120, 68120, 68150, 68151, 68155, 68158, 68169, 68175, 68185, 68191, 68256, 68287, 68327, 68330, 68343, 68351, 68406, 68408, 68438, 68439, 68467, 68471, 68498, 68504, 68509, 68520, 68528, 68607, 68681, 68735, 68787, 68799, 68851, 68857, 68904, 68911, 68922, 69215, 69247, 69247, 69290, 69290, 69294, 69295, 69298, 69375, 69416, 69423, 69466, 69551, 69580, 69599, 69623, 69631, 69710, 69713, 69744, 69758, 69821, 69821, 69826, 69839, 69865, 69871, 69882, 69887, 69941, 69941, 69960, 69967, 70007, 70015, 70112, 70112, 70133, 70143, 70162, 70162, 70207, 70271, 70279, 70279, 70281, 70281, 70286, 70286, 70302, 70302, 70314, 70319, 70379, 70383, 70394, 70399, 70404, 70404, 70413, 70414, 70417, 70418, 70441, 70441, 70449, 70449, 70452, 70452, 70458, 70458, 70469, 70470, 70473, 70474, 70478, 70479, 70481, 70486, 70488, 70492, 70500, 70501, 70509, 70511, 70517, 70655, 70748, 70748, 70754, 70783, 70856, 70863, 70874, 71039, 71094, 71095, 71134, 71167, 71237, 71247, 71258, 71263, 71277, 71295, 71353, 71359, 71370, 71423, 71451, 71452, 71468, 71471, 71488, 71679, 71740, 71839, 71923, 71934, 71943, 71944, 71946, 71947, 71956, 71956, 71959, 71959, 71990, 71990, 71993, 71994, 72007, 72015, 72026, 72095, 72104, 72105, 72152, 72153, 72165, 72191, 72264, 72271, 72355, 72383, 72441, 72703, 72713, 72713, 72759, 72759, 72774, 72783, 72813, 72815, 72848, 72849, 72872, 72872, 72887, 72959, 72967, 72967, 72970, 72970, 73015, 73017, 73019, 73019, 73022, 73022, 73032, 73039, 73050, 73055, 73062, 73062, 73065, 73065, 73103, 73103, 73106, 73106, 73113, 73119, 73130, 73439, 73465, 73647, 73649, 73663, 73714, 73726, 74650, 74751, 74863, 74863, 74869, 74879, 75076, 77823, 78895, 82943, 83527, 92159, 92729, 92735, 92767, 92767, 92778, 92781, 92784, 92879, 92910, 92911, 92918, 92927, 92998, 93007, 93018, 93018, 93026, 93026, 93048, 93052, 93072, 93759, 93851, 93951, 94027, 94030, 94088, 94094, 94112, 94175, 94181, 94191, 94194, 94207, 100344, 100351, 101590, 101631, 101641, 110591, 110879, 110927, 110931, 110947, 110952, 110959, 111356, 113663, 113771, 113775, 113789, 113791, 113801, 113807, 113818, 113819, 113824, 118783, 119030, 119039, 119079, 119080, 119155, 119162, 119273, 119295, 119366, 119519, 119540, 119551, 119639, 119647, 119673, 119807, 119893, 119893, 119965, 119965, 119968, 119969, 119971, 119972, 119975, 119976, 119981, 119981, 119994, 119994, 119996, 119996, 120004, 120004, 120070, 120070, 120075, 120076, 120085, 120085, 120093, 120093, 120122, 120122, 120127, 120127, 120133, 120133, 120135, 120137, 120145, 120145, 120486, 120487, 120780, 120781, 121484, 121498, 121504, 121504, 121520, 122879, 122887, 122887, 122905, 122906, 122914, 122914, 122917, 122917, 122923, 123135, 123181, 123183, 123198, 123199, 123210, 123213, 123216, 123583, 123642, 123646, 123648, 124927, 125125, 125126, 125143, 125183, 125260, 125263, 125274, 125277, 125280, 126064, 126133, 126208, 126270, 126463, 126468, 126468, 126496, 126496, 126499, 126499, 126501, 126502, 126504, 126504, 126515, 126515, 126520, 126520, 126522, 126522, 126524, 126529, 126531, 126534, 126536, 126536, 126538, 126538, 126540, 126540, 126544, 126544, 126547, 126547, 126549, 126550, 126552, 126552, 126554, 126554, 126556, 126556, 126558, 126558, 126560, 126560, 126563, 126563, 126565, 126566, 126571, 126571, 126579, 126579, 126584, 126584, 126589, 126589, 126591, 126591, 126602, 126602, 126620, 126624, 126628, 126628, 126634, 126634, 126652, 126703, 126706, 126975, 127020, 127023, 127124, 127135, 127151, 127152, 127168, 127168, 127184, 127184, 127222, 127231, 127406, 127461, 127491, 127503, 127548, 127551, 127561, 127567, 127570, 127583, 127590, 127743, 128728, 128735, 128749, 128751, 128765, 128767, 128884, 128895, 128985, 128991, 129004, 129023, 129036, 129039, 129096, 129103, 129114, 129119, 129160, 129167, 129198, 129199, 129202, 129279, 129401, 129401, 129484, 129484, 129620, 129631, 129646, 129647, 129653, 129655, 129659, 129663, 129671, 129679, 129705, 129711, 129719, 129727, 129731, 129743, 129751, 129791, 129939, 129939, 129995, 130031, 130042, 131071, 173790, 173823, 177973, 177983, 178206, 178207, 183970, 183983, 191457, 194559, 195102, 196607, 201547, 917759, 918e3, 1114111];
|
|
231
255
|
function isPythonPrintable(point) {
|
|
232
256
|
let low = 0, high = excluded.length / 2;
|
|
233
257
|
while (low < high) {
|
|
@@ -286,6 +310,7 @@ async function* serializeLlmEmbedding(vector, format, signal) {
|
|
|
286
310
|
}
|
|
287
311
|
|
|
288
312
|
export {
|
|
313
|
+
decodeUnicodeRanges,
|
|
289
314
|
isPythonPrintable,
|
|
290
315
|
floatText,
|
|
291
316
|
serializeLlmEmbedding,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// packages/safe-bash-csv-engine/src/python-codec-aliases.ts
|
|
2
|
+
var pythonCodecAliases = /* @__PURE__ */ (() => {
|
|
3
|
+
let packed = "cp273,273<273W273H424,424<424KheW424H43|437Gpc8Ppage437W437H50}500<500KbeKchW500;ascii,64{*si_x3.4S6=*si_x3.4SR,*si_x3_4S68$367GasciiW36|B646_us,B_646.irvS91I{us,us_asciiH775,775Gpc775balticW775HZ}Z0GpcZ0multilingualWZ0HZ>Z2GpcpZ2WZ2HZ5,Z5<Z5WZ5HZ|Z7<Z7WZ7HZ=Z8<Z8WZ8HR}R0<R0WR0HR:R1$_is<R1WR1HR>R2GpcR2ChebrewWR2HR3,R3<R3WR3HR4,R4<R4WR4HR5,R5<R5WR5HR{R6<R6WR6HR9,R9$_gr<R9WR9H874,874,ms874,windows_874H93>93>ms93>ms_k*ji,msk*ji,windows_31j;gbk,936$93{ms936H949,949,ms949,uhcH95}95}ms950H!2{!26<!26W!26H1N,1N$R6uW1N,rusciiH114}1140W1140HN}N0D0HN:N1D1HN>N2D2HN3,N3D3HN4,N4D4HN5,N5D5HN{N6D6HN|N7D7HN=N8D8E:8Z9$819%1W819,B8Z9A1A1~7I!}l:C,C:C_1H03|037<037KcaKnlKusKwtW037W039E{arabic,asmo_708%arabic,ecma_114A6A6~7I127;base64,base64_Pc,base_64;?,?_twG?,x_L_trad_^;?hkscs,?_hkscs,hkscs;bz>bz2_Pc;charmap;#,^GB58#8}X_cn,Xcn,X#_cn,#~}#_80I5=x_L_simp_^H!06;hp-@8$!51W!5:r=@8;johab$136:ms1361;ptcp154$154Gptcp154,U_asi*,pt154+8$6500:u=O,O=O8_ucs>O8_ucs4H720H737HZ6H875;X_krGXkr,Xkr,kore*,ks_c_560:ks_c_5601~|ks_x_!0:ksc560:ksx!0:x_L_kore*;BJ_jpG(,(,B_J_jp;BJ_krGBJkr,BJkr,B_J_krE2%2A2A2~7I!:l>C2E3%3A3A3~8I!9,l3,C3E4%4A4A4~8I1!,l4,C4E9%5A9A9~9I14=l5,C5E!%6A!A!S92I15|l{C6E5%U,UA5A5~8I144E7%/,ecma_11=elot_92=/,/8A7A7~7I126E8%hebrew,hebrewA8A8~8A8_eA8_iI138;koi8-rGkoi8r;Y_VGYV,s_V,YV,sV,x_L_jap*ese;X_V_TX_VTXVTM;X_M,XM;X_jp,Xjp,u_V,uV;gb1803}gb18030[0;hex,hex_Pc;hz,hz_gb,hz_gb_231>hzgb;idna;BQ:(_:B_Q1;BQ>(_>B_Q2;BQT(_TB_Q2004;BQ3,(_3,B_Q3;BQext,(_ext,B_QextE11A11A11[:thaiE13A13,l|C7E14A14A14S9=B_celticI199,l=C8E15A15,l9,C9E16A16A16[1I22{l!,C!;tis-620I16{tis62))2529_)2529_1;koi8-t;koi8-u;kz!4=kz_!4=rk!4=strk!48[2&arabic&C>L_centeuro,Lcentraleurope,LC2&croati*&U,LU&farsi&/,L/&icel*d,Licel*d&@,Lintosh,L@&@i*&turkish,Lturkish;palmos;punyP;quopri,quopri_Pc,quoted_printable,quotedprintable;raw-]-escape;rot-13,rot13;Y_V_Ts_V_TYVTsV[4;Y_M,s_M,YM,sM+1{u1{O16+3>u3>O32+|u|]_1_1_O_|O7;undefined;]-escape+16-be,]big`be+16-le,]little`le+32-be,O_32be+32-le,O_32le+8-sig;uu,uu_Pc;zlib,zip,zlib_Pc";
|
|
4
|
+
const markers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&()*+/:<=>?@[]^`{|}~", fragments = ",iso_8859_~iso~latin~,windows_125~;B8859-~ibm~,cs~;cp~,B_ir_~2022~,ebcdic_cp_~mac~jisx0213~125~utf~code~J_jp_~86~_19~2004,~cyrillic~jis~,F~euc~shift~85~10~gb2312~,cp~GBC~;L-~BJjp~0,tis_620_~an~;O-~greek~1,~GF~8,~2,~big5~rom*~_200~uniP~chinese~unmarked,O_16~6,~7,~0,~S8".split("~");
|
|
5
|
+
for (let i = fragments.length - 1; i >= 0; i--) packed = packed.split(markers[i]).join(fragments[i]);
|
|
6
|
+
const entries = packed.split(";").flatMap((group) => {
|
|
7
|
+
const [codec, ...aliases] = group.split(",");
|
|
8
|
+
aliases.push(codec.replaceAll("-", "_"));
|
|
9
|
+
return aliases.map((alias) => [alias, codec]);
|
|
10
|
+
});
|
|
11
|
+
entries.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
12
|
+
return Object.freeze(Object.fromEntries(entries));
|
|
13
|
+
})();
|
|
14
|
+
function normalizeEncoding(encoding) {
|
|
15
|
+
let result = "", punctuation = false;
|
|
16
|
+
for (const char of encoding) {
|
|
17
|
+
const code = char.codePointAt(0);
|
|
18
|
+
if (code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === ".") {
|
|
19
|
+
if (punctuation && result) result += "_";
|
|
20
|
+
result += char.toLowerCase();
|
|
21
|
+
punctuation = false;
|
|
22
|
+
} else punctuation = true;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
pythonCodecAliases,
|
|
29
|
+
normalizeEncoding
|
|
30
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
regexError,
|
|
3
3
|
regexFlags
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XTHKXCF2.js";
|
|
5
5
|
import {
|
|
6
6
|
extendedPattern
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YSCKOUQP.js";
|
|
8
8
|
import {
|
|
9
9
|
describe
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7M3M6FKC.js";
|
|
11
11
|
import {
|
|
12
12
|
JqError
|
|
13
13
|
} from "./chunk-3K5FCRUG.js";
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-2IGH6JIP.js";
|
|
4
4
|
import {
|
|
5
5
|
splitRegex
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VTH4AORO.js";
|
|
7
7
|
import {
|
|
8
8
|
matchRegex,
|
|
9
9
|
scanRegex,
|
|
10
10
|
substituteRegex
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XTHKXCF2.js";
|
|
12
12
|
import {
|
|
13
13
|
capture
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YSCKOUQP.js";
|
|
15
15
|
import {
|
|
16
16
|
fromDateIso8601,
|
|
17
17
|
gmtime,
|
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
} from "./chunk-BTDSUATE.js";
|
|
23
23
|
import {
|
|
24
24
|
delpaths
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZYXKW2K7.js";
|
|
26
26
|
import {
|
|
27
27
|
formatValue
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HUGKO4ZE.js";
|
|
29
29
|
import {
|
|
30
30
|
indices
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-QZYEI4N6.js";
|
|
32
32
|
import {
|
|
33
33
|
binary,
|
|
34
34
|
compare,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
sortedKeys,
|
|
43
43
|
stableSort,
|
|
44
44
|
type
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-7M3M6FKC.js";
|
|
46
46
|
import {
|
|
47
47
|
splitString
|
|
48
48
|
} from "./chunk-BOMCPF7N.js";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
measureValue,
|
|
52
52
|
parseJson,
|
|
53
53
|
stringify
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-N4SH6QY5.js";
|
|
55
55
|
import {
|
|
56
56
|
JqError,
|
|
57
57
|
JqHalt,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
} from "./chunk-D43FDVLM.js";
|
|
62
62
|
import {
|
|
63
63
|
executePlaywrightAbility
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-A7PKUIJT.js";
|
|
65
65
|
import {
|
|
66
66
|
createPlaywrightCommandBudget
|
|
67
67
|
} from "./chunk-GYGORRXA.js";
|
|
@@ -127,7 +127,7 @@ function createPlaywrightController(options = {}) {
|
|
|
127
127
|
if (options.persistence?.close !== void 0 && typeof options.persistence.close !== "function") throw new TypeError("Invalid Playwright persistence close");
|
|
128
128
|
if (options.persistence?.list !== void 0 && typeof options.persistence.list !== "function") throw new TypeError("Invalid Playwright persistence list");
|
|
129
129
|
for (const key of ["inspectRecovery", "recordOperation"]) if (options.persistence?.[key] !== void 0 && typeof options.persistence[key] !== "function") throw new TypeError("Invalid Playwright recovery persistence");
|
|
130
|
-
if (options.limits !== void 0 && (!options.limits || typeof options.limits !== "object" || Object.keys(options.limits).some((key) => !["maxSessions", "actionTimeoutMs", "codeExecutionTimeoutMs", "maxSnapshotBytes", "maxSnapshotRefs", "maxArtifactBytes", "maxTabs", "maxCommandBytes", ...Object.keys(playwrightStructureDefaults)].includes(key)))) throw new TypeError("Unsupported Playwright limits");
|
|
130
|
+
if (options.limits !== void 0 && (!options.limits || typeof options.limits !== "object" || Object.keys(options.limits).some((key) => !["maxSessions", "actionTimeoutMs", "codeExecutionTimeoutMs", "maxSnapshotBytes", "maxSnapshotRefs", "maxArtifactBytes", "maxTabs", "maxCommandBytes", "maxOutputArtifactBytes", ...Object.keys(playwrightStructureDefaults)].includes(key)))) throw new TypeError("Unsupported Playwright limits");
|
|
131
131
|
if (options.billing !== void 0) throw new Error("Live billing is not implemented");
|
|
132
132
|
const maxSessions = options.limits?.maxSessions ?? Infinity;
|
|
133
133
|
const actionTimeoutMs = options.limits?.actionTimeoutMs ?? Infinity;
|
|
@@ -137,9 +137,10 @@ function createPlaywrightController(options = {}) {
|
|
|
137
137
|
const maxArtifactBytes = options.limits?.maxArtifactBytes ?? Infinity;
|
|
138
138
|
const maxTabs = options.limits?.maxTabs ?? Infinity;
|
|
139
139
|
const maxCommandBytes = options.limits?.maxCommandBytes ?? Infinity;
|
|
140
|
+
const maxOutputArtifactBytes = options.limits?.maxOutputArtifactBytes;
|
|
140
141
|
const abilities = registerPlaywrightAbilities(options.abilities, options.adapter !== void 0);
|
|
141
142
|
let refSequence = 0;
|
|
142
|
-
for (const value of [options.limits?.maxSessions, options.limits?.maxSnapshotBytes, actionTimeoutMs, codeExecutionTimeoutMs, options.limits?.maxSnapshotRefs, options.limits?.maxArtifactBytes, options.limits?.maxTabs, options.limits?.maxCommandBytes]) if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError("Invalid Playwright limit");
|
|
143
|
+
for (const value of [options.limits?.maxSessions, options.limits?.maxSnapshotBytes, actionTimeoutMs, codeExecutionTimeoutMs, options.limits?.maxSnapshotRefs, options.limits?.maxArtifactBytes, options.limits?.maxTabs, options.limits?.maxCommandBytes, maxOutputArtifactBytes]) if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError("Invalid Playwright limit");
|
|
143
144
|
for (const key of Object.keys(playwrightStructureDefaults)) {
|
|
144
145
|
const value = options.limits?.[key];
|
|
145
146
|
if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 0)) throw new RangeError("Invalid Playwright structure limit");
|
|
@@ -797,6 +798,7 @@ function createPlaywrightController(options = {}) {
|
|
|
797
798
|
};
|
|
798
799
|
const run = async (invocation) => {
|
|
799
800
|
const commandBudget = createPlaywrightCommandBudget(maxCommandBytes);
|
|
801
|
+
const artifactBudget = maxOutputArtifactBytes === void 0 ? commandBudget : createPlaywrightCommandBudget(maxOutputArtifactBytes);
|
|
800
802
|
let reportedError = false;
|
|
801
803
|
const writtenFiles = /* @__PURE__ */ new Set();
|
|
802
804
|
const original = invocation;
|
|
@@ -890,7 +892,7 @@ function createPlaywrightController(options = {}) {
|
|
|
890
892
|
check();
|
|
891
893
|
if (!invocation.writeArtifact) throw new Error("Artifact byte destination unsupported");
|
|
892
894
|
if (bytes.byteLength > maxArtifactBytes) throw new PlaywrightResourceLimitError("Artifact byte limit exceeded");
|
|
893
|
-
|
|
895
|
+
artifactBudget.admit(bytes.byteLength);
|
|
894
896
|
await invocation.writeArtifact(bytes, filename);
|
|
895
897
|
check();
|
|
896
898
|
};
|
|
@@ -1489,7 +1491,7 @@ function createPlaywrightController(options = {}) {
|
|
|
1489
1491
|
}
|
|
1490
1492
|
});
|
|
1491
1493
|
}
|
|
1492
|
-
const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, structureLimits: options.limits, maxCommandBytes, maxArtifactBytes, commandBudget, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...browserSession ? { browserSession } : {}, check: () => active ? checkSession(active) : check() });
|
|
1494
|
+
const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, structureLimits: options.limits, maxCommandBytes, maxArtifactBytes, commandBudget, artifactBudget, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...browserSession ? { browserSession } : {}, check: () => active ? checkSession(active) : check() });
|
|
1493
1495
|
let result;
|
|
1494
1496
|
try {
|
|
1495
1497
|
result = active ? await active.snapshot.withReferences(executeAbility) : await executeAbility();
|