@poe-platform/safe-bash 0.1.821 → 0.1.823
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/safe-bash/chunks/{chunk-HNT2MR4W.js → chunk-363QOIDR.js} +2 -1
- package/dist/safe-bash/chunks/chunk-AGHV53VF.js +42 -0
- package/dist/safe-bash/chunks/{chunk-VF3Q2V3E.js → chunk-RAFD5ZAH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-67QE3JLU.js → chunk-TZRVK3NU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-IRJS54AA.js → chunk-VWLQDZFF.js} +20 -12
- package/dist/safe-bash/chunks/{chunk-NAETSXBW.js → chunk-ZJAXMB5M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QX3WKBLI.js → chunk-36FV6BAG.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-ZSHXZ3XG.js → chunk-3EAZRKI4.js} +7 -7
- package/dist/safe-bash/command-chunks/chunk-64HIOP7Q.js +993 -0
- package/dist/safe-bash/command-chunks/{chunk-WOT2YXBT.js → chunk-7ZQVMPSB.js} +213 -42
- package/dist/safe-bash/command-chunks/{chunk-GRFJKJFN.js → chunk-AVSINNZ6.js} +233 -3
- package/dist/safe-bash/command-chunks/{chunk-BZLLQWRK.js → chunk-E5CDHXFA.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RHXV2KG5.js → chunk-EO3RYGUZ.js} +1010 -58
- package/dist/safe-bash/command-chunks/{chunk-MCUDSE4H.js → chunk-EWECMOQ5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RTUDDAAY.js → chunk-O3KFOFJM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SLD5A7IL.js → chunk-OU5UEUZN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RKAL5VFP.js → chunk-PLVFJ6FF.js} +255 -616
- package/dist/safe-bash/command-chunks/{chunk-CJIFJ45R.js → chunk-QBCEAYQT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4Q3HP33O.js → chunk-RGKHTSUY.js} +146 -123
- package/dist/safe-bash/command-chunks/{chunk-I7MEH76L.js → chunk-UYNJF5QN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IAHYG67O.js → chunk-V5ZBRM5R.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-R4NPYXQX.js → chunk-WDTWJFPK.js} +320 -67
- package/dist/safe-bash/command-chunks/{chunk-GQV5RWMN.js → chunk-ZFXHSFTU.js} +1 -1
- package/dist/safe-bash/command-chunks/{prompt-tool-debug-ERJKK3XZ.js → prompt-tool-debug-3POFNRYP.js} +5 -5
- package/dist/safe-bash/commands/bc/index.browser.js +1 -1
- package/dist/safe-bash/commands/llm/index.browser.js +3 -1
- package/dist/safe-bash/commands/llm/index.js +1 -1
- package/dist/safe-bash/commands/python/executor.browser.js +12 -1
- package/dist/safe-bash/commands/python/executor.js +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +23 -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 +30 -6
- package/dist/safe-bash/plugins/index.browser.js +3 -3
- package/dist/safe-bash/registry-entry.browser.js +2 -2
- package/dist/safe-bash/search.browser.js +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +2 -2
- package/dist/safe-bash/shell/runtime.js +11 -2
- package/dist/safe-bash/shell/sync-extra-evaluators.js +12 -12
- package/dist/safe-bash/shell-entry.browser.js +2 -2
- package/dist/safe-bash-command-llm/collections.js +24 -65
- package/dist/safe-bash-command-llm/command.js +6 -6
- package/dist/safe-bash-command-llm/fragment-loaders.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.js +10 -8
- package/dist/safe-bash-command-llm/loader-provider.d.ts +25 -0
- package/dist/safe-bash-command-llm/openai-sse.js +2 -2
- package/dist/safe-bash-command-llm/openai.js +4 -4
- package/dist/safe-bash-command-llm/providers/index.js +4 -4
- package/dist/safe-bash-command-llm/providers/openai.js +4 -4
- package/dist/safe-bash-command-llm/python-unicode.d.ts +2 -0
- package/dist/safe-bash-command-llm/templates.d.ts +7 -2
- package/dist/safe-bash-command-llm/types.d.ts +7 -1
- package/dist/safe-bash-command-mcp/index.browser.js +3 -0
- package/dist/safe-bash-command-mcp/index.js +3 -0
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-python/build-backend.d.ts +51 -0
- package/dist/safe-bash-command-python/build-dependencies.d.ts +12 -0
- package/dist/safe-bash-command-python/build-environment.d.ts +3 -0
- package/dist/safe-bash-command-python/build-wheel.d.ts +8 -0
- package/dist/safe-bash-command-python/executor.d.ts +12 -2
- package/dist/safe-bash-command-python/executor.js +26 -4
- package/dist/safe-bash-command-python/index.js +26 -4
- package/dist/safe-bash-command-python/jspi.js +2 -2
- package/dist/safe-bash-command-python/llm-assets-node.js +1 -1
- package/dist/safe-bash-command-python/llm-fragment-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/llm-functions-loader.d.ts +5 -1
- package/dist/safe-bash-command-python/llm-loader-discovery.d.ts +13 -0
- package/dist/safe-bash-command-python/llm-package-manager.d.ts +7 -0
- package/dist/safe-bash-command-python/llm-template-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/manifest.d.ts +13 -0
- package/dist/safe-bash-command-python/provisioning.d.ts +33 -5
- package/dist/safe-bash-command-python/provisioning.js +1 -1
- package/dist/safe-bash-command-python/source-environment.d.ts +9 -0
- package/dist/safe-bash-command-python/source-snapshot.d.ts +8 -0
- package/dist/safe-bash-command-python/worker.js +3 -185
- package/dist/safe-bash-csv-engine/index.js +1 -1
- package/dist/safe-bash-csv-engine/python-iso2022.d.ts +21 -0
- package/dist/safe-bash-csv-engine/python-utf7.d.ts +18 -0
- package/dist/safe-bash-csv-engine/text-decoder.d.ts +2 -0
- package/dist/safe-bash-csv-engine/text-decoder.js +7 -3
- package/dist/safe-bash-zip-engine/index.js +1 -1
- package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.d.ts +3 -1
- package/dist/safe-bash-zip-engine/zip-format.js +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +35 -20
- package/package.json +3 -3
- package/dist/safe-bash/chunks/chunk-PSD2RSOS.js +0 -31
- package/dist/safe-bash/command-chunks/chunk-5EFNQ6FY.js +0 -458
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
installPythonShellModule
|
|
3
3
|
} from "./chunk-FXWKMNX2.js";
|
|
4
4
|
import {
|
|
5
|
+
installPythonPackages,
|
|
5
6
|
parsePythonInvocation,
|
|
6
7
|
pythonDirectoryEntries,
|
|
7
8
|
pythonExecution,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
pythonRuntimeRelocation,
|
|
10
11
|
pythonStatProjection,
|
|
11
12
|
pythonTreeCleanup
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-64HIOP7Q.js";
|
|
13
14
|
import {
|
|
14
15
|
pythonJspiSignatures
|
|
15
16
|
} from "./chunk-P56KGNW7.js";
|
|
@@ -30,6 +31,7 @@ import { createPythonNativeSyscalls } from "@poe-platform/safe-fs/core";
|
|
|
30
31
|
function installPythonJspiRunSync(runtime) {
|
|
31
32
|
runtime.runPython(`
|
|
32
33
|
import pyodide.ffi as _safe_jspi_ffi
|
|
34
|
+
import pyodide.webloop as _safe_jspi_webloop
|
|
33
35
|
def _safe_jspi_run_sync(awaitable, _original=_safe_jspi_ffi.run_sync):
|
|
34
36
|
async def capture():
|
|
35
37
|
try:
|
|
@@ -41,7 +43,10 @@ def _safe_jspi_run_sync(awaitable, _original=_safe_jspi_ffi.run_sync):
|
|
|
41
43
|
return value
|
|
42
44
|
raise value
|
|
43
45
|
_safe_jspi_ffi.run_sync = _safe_jspi_run_sync
|
|
44
|
-
|
|
46
|
+
# WebLoop captures this import during runtime initialization. asyncio.run()
|
|
47
|
+
# must use the same exception envelope as explicit synchronous model calls.
|
|
48
|
+
_safe_jspi_webloop.run_sync = _safe_jspi_run_sync
|
|
49
|
+
del _safe_jspi_ffi, _safe_jspi_webloop, _safe_jspi_run_sync
|
|
45
50
|
`);
|
|
46
51
|
}
|
|
47
52
|
|
|
@@ -366,7 +371,6 @@ function createPythonJspiExecutor(options) {
|
|
|
366
371
|
let hostCleanupFailure;
|
|
367
372
|
try {
|
|
368
373
|
signal.throwIfAborted();
|
|
369
|
-
if (start.packages?.requirements.length || start.installOnly) throw new PythonFailure("runtime-assets", { cause: new Error("JSPI runtime requires statically qualified packages") });
|
|
370
374
|
runtime = await options.loadRuntime({
|
|
371
375
|
jsglobals: /* @__PURE__ */ Object.create(null),
|
|
372
376
|
args: configuration.startupArgs,
|
|
@@ -415,116 +419,134 @@ function createPythonJspiExecutor(options) {
|
|
|
415
419
|
qualified = true;
|
|
416
420
|
runtime._api.config.enableRunUntilComplete = true;
|
|
417
421
|
signal.throwIfAborted();
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
runtime.runPython(pythonRuntimeRelocation);
|
|
427
|
-
filesystem.currentPath = start.invocation.cwd;
|
|
428
|
-
native = createPythonNativeSyscalls({
|
|
429
|
-
getUmask: () => guestMask,
|
|
430
|
-
runtime: runtime._module,
|
|
431
|
-
cwd: start.invocation.cwd,
|
|
432
|
-
runtimeMount: start.runtimeMount,
|
|
433
|
-
maxTransferBytes: start.maxTransferBytes,
|
|
434
|
-
signal,
|
|
435
|
-
dispatch: start.dispatch,
|
|
436
|
-
original: (name, args) => originals[name](...args)
|
|
437
|
-
});
|
|
438
|
-
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)})"));
|
|
439
|
-
const encode = async (operation) => {
|
|
440
|
-
try {
|
|
441
|
-
return JSON.stringify(await operation());
|
|
442
|
-
} catch (error) {
|
|
443
|
-
return JSON.stringify({ errno: signal.aborted ? errno.EINTR : error.errno ?? errno[error.code ?? ""] ?? errno.EIO });
|
|
444
|
-
}
|
|
422
|
+
if (start.packages) await installPythonPackages(
|
|
423
|
+
runtime,
|
|
424
|
+
start.packages,
|
|
425
|
+
(op, ...args) => start.dispatch({ op, args }),
|
|
426
|
+
start.maxTransferBytes
|
|
427
|
+
);
|
|
428
|
+
const unavailablePackage = () => {
|
|
429
|
+
throw new Error("Python package transport is only available during installation");
|
|
445
430
|
};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
431
|
+
if ("loadPackage" in runtime) runtime.loadPackage = unavailablePackage;
|
|
432
|
+
if (runtime._api.packageManager) runtime._api.packageManager.downloadPackage = unavailablePackage;
|
|
433
|
+
if (start.installOnly) {
|
|
434
|
+
start.onReady();
|
|
435
|
+
const message = new TextEncoder().encode(start.packages?.uninstall ? "" : "Successfully installed requested Python packages\n");
|
|
436
|
+
for (let offset = 0; offset < message.length; offset += start.maxTransferBytes) {
|
|
437
|
+
await start.dispatch({ op: "stdout", args: [Array.from(message.subarray(offset, offset + start.maxTransferBytes))] });
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
runtime.runPython("import sys, os, json, runpy, traceback, types, warnings, textwrap, io, struct, linecache, importlib.machinery, shutil, stat, pyodide.ffi");
|
|
441
|
+
runtime.globals.set("_safe_runtime_mount", start.runtimeMount);
|
|
442
|
+
const filesystem = runtime.FS;
|
|
443
|
+
const bootstrap = filesystem.root;
|
|
444
|
+
filesystem.root = null;
|
|
445
|
+
filesystem.mount(filesystem.filesystems.MEMFS, {}, "/");
|
|
446
|
+
filesystem.mkdir(start.runtimeMount);
|
|
447
|
+
filesystem.mount({ mount: () => bootstrap }, {}, start.runtimeMount);
|
|
448
|
+
runtime.runPython(pythonRuntimeRelocation);
|
|
449
|
+
filesystem.currentPath = start.invocation.cwd;
|
|
450
|
+
native = createPythonNativeSyscalls({
|
|
451
|
+
getUmask: () => guestMask,
|
|
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 });
|
|
468
466
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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
|
+
}
|
|
476
481
|
}
|
|
477
|
-
|
|
478
|
-
|
|
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 };
|
|
490
|
+
}
|
|
491
|
+
if (operation === "tree") {
|
|
492
|
+
if (bootstrapPath(target) || !await start.dispatch({ op: "rmtreeSupported", args: [target] })) return { supported: false };
|
|
493
|
+
try {
|
|
494
|
+
await start.dispatch({ op: "rmtree", args: [target] });
|
|
495
|
+
return { supported: true };
|
|
496
|
+
} catch (error) {
|
|
497
|
+
return { supported: true, errno: errno[error.code ?? ""] ?? errno.EIO };
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
throw Object.assign(new Error("Invalid native Python operation"), { code: "EINVAL" });
|
|
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 }
|
|
479
521
|
});
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
module.
|
|
486
|
-
module.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
python: {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (!extension || !callable || module._PyModule_AddObject(extension, methodDefinition + 16, callable) < 0) throw new PythonFailure("runtime-abi");
|
|
509
|
-
const fields = Number(runtime.runPython("os.stat_result.n_fields"));
|
|
510
|
-
const statResult = new engine.Instance(options.statResult, { python: {
|
|
511
|
-
fields: new engine.Global({ value: "i32" }, fields),
|
|
512
|
-
create: module._PyStructSequence_New,
|
|
513
|
-
size: module._PyTuple_Size,
|
|
514
|
-
item: module._PyTuple_GetItem,
|
|
515
|
-
retain: module._Py_IncRef,
|
|
516
|
-
set: module._PyStructSequence_SetItem,
|
|
517
|
-
invalid: module._PyErr_BadArgument
|
|
518
|
-
} });
|
|
519
|
-
statPointer = module.addFunction(statResult.exports.construct, "iii");
|
|
520
|
-
module.HEAPU8.set(new TextEncoder().encode("stat_result\0os\0"), methodDefinition + 80);
|
|
521
|
-
module.HEAPU32.set([methodDefinition + 80, statPointer, 8, 0], (methodDefinition + 64) / 4);
|
|
522
|
-
const osModule = module._PyImport_AddModule(methodDefinition + 92);
|
|
523
|
-
const statType = module._PyObject_GetAttrString(osModule, methodDefinition + 80);
|
|
524
|
-
const constructStat = module._PyCFunction_NewEx(methodDefinition + 64, statType, 0);
|
|
525
|
-
module._Py_DecRef(statType);
|
|
526
|
-
if (!constructStat || module._PyModule_AddObject(extension, methodDefinition + 80, constructStat) < 0) throw new PythonFailure("runtime-abi");
|
|
527
|
-
runtime.runPython(`
|
|
522
|
+
methodPointer = module.addFunction(nativeCall.exports.call, "iii");
|
|
523
|
+
methodDefinition = module._malloc(128);
|
|
524
|
+
if (!methodDefinition) throw new PythonFailure("runtime-assets");
|
|
525
|
+
module.HEAPU8.fill(0, methodDefinition, methodDefinition + 128);
|
|
526
|
+
module.HEAPU8.set(new TextEncoder().encode("request\0_safe_native_fs\0"), methodDefinition + 16);
|
|
527
|
+
module.HEAPU32.set([methodDefinition + 16, methodPointer, 8, 0], methodDefinition / 4);
|
|
528
|
+
const extension = module._PyImport_AddModule(methodDefinition + 24);
|
|
529
|
+
const callable = module._PyCFunction_NewEx(methodDefinition, 0, 0);
|
|
530
|
+
if (!extension || !callable || module._PyModule_AddObject(extension, methodDefinition + 16, callable) < 0) throw new PythonFailure("runtime-abi");
|
|
531
|
+
const fields = Number(runtime.runPython("os.stat_result.n_fields"));
|
|
532
|
+
const statResult = new engine.Instance(options.statResult, { python: {
|
|
533
|
+
fields: new engine.Global({ value: "i32" }, fields),
|
|
534
|
+
create: module._PyStructSequence_New,
|
|
535
|
+
size: module._PyTuple_Size,
|
|
536
|
+
item: module._PyTuple_GetItem,
|
|
537
|
+
retain: module._Py_IncRef,
|
|
538
|
+
set: module._PyStructSequence_SetItem,
|
|
539
|
+
invalid: module._PyErr_BadArgument
|
|
540
|
+
} });
|
|
541
|
+
statPointer = module.addFunction(statResult.exports.construct, "iii");
|
|
542
|
+
module.HEAPU8.set(new TextEncoder().encode("stat_result\0os\0"), methodDefinition + 80);
|
|
543
|
+
module.HEAPU32.set([methodDefinition + 80, statPointer, 8, 0], (methodDefinition + 64) / 4);
|
|
544
|
+
const osModule = module._PyImport_AddModule(methodDefinition + 92);
|
|
545
|
+
const statType = module._PyObject_GetAttrString(osModule, methodDefinition + 80);
|
|
546
|
+
const constructStat = module._PyCFunction_NewEx(methodDefinition + 64, statType, 0);
|
|
547
|
+
module._Py_DecRef(statType);
|
|
548
|
+
if (!constructStat || module._PyModule_AddObject(extension, methodDefinition + 80, constructStat) < 0) throw new PythonFailure("runtime-abi");
|
|
549
|
+
runtime.runPython(`
|
|
528
550
|
from _safe_native_fs import request as _safe_native_request
|
|
529
551
|
def _safe_stat_projection(path, follow):
|
|
530
552
|
return _safe_native_request(json.dumps(['stat', path, follow]))
|
|
@@ -535,8 +557,8 @@ def _safe_directory_entries(path):
|
|
|
535
557
|
def _safe_tree_cleanup(path):
|
|
536
558
|
return _safe_native_request(json.dumps(['tree', path]))
|
|
537
559
|
`);
|
|
538
|
-
|
|
539
|
-
|
|
560
|
+
for (const script of [pythonImportMetadata, pythonDirectoryEntries, pythonStatProjection, pythonTreeCleanup]) runtime.runPython(script);
|
|
561
|
+
runtime.runPython(`
|
|
540
562
|
from _safe_native_fs import stat_result as _safe_construct_stat
|
|
541
563
|
_safe_stat_fields = os.stat_result.n_fields
|
|
542
564
|
_safe_stat_probe = os.stat_result(tuple(range(_safe_stat_fields)))
|
|
@@ -549,18 +571,18 @@ def _safe_native_stat_type(values, extras):
|
|
|
549
571
|
return _safe_construct_stat(tuple(fields))
|
|
550
572
|
_safe_stat_type = _safe_native_stat_type
|
|
551
573
|
`);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
574
|
+
runtime.runPython(pythonHostModule);
|
|
575
|
+
installPythonLlmModule(runtime);
|
|
576
|
+
installPythonShellModule(runtime);
|
|
577
|
+
installPythonJspiRunSync(runtime);
|
|
578
|
+
runtime.runPython(pythonLibraryAdapter);
|
|
579
|
+
runtime.runPython("import tempfile; tempfile.tempdir = None");
|
|
580
|
+
runtime.globals.set("_safe_invocation_json", JSON.stringify(start.invocation));
|
|
581
|
+
runtime.globals.set("_safe_execution_code", pythonExecution);
|
|
582
|
+
runtime.globals.set("_safe_is_cancelled", () => signal.aborted);
|
|
583
|
+
active.value = 1;
|
|
584
|
+
start.onReady();
|
|
585
|
+
exitCode = Number(await runtime.runPythonAsync(`
|
|
564
586
|
try:
|
|
565
587
|
exec(_safe_execution_code)
|
|
566
588
|
except BaseException:
|
|
@@ -569,6 +591,7 @@ except BaseException:
|
|
|
569
591
|
_safe_exit = 130
|
|
570
592
|
_safe_exit
|
|
571
593
|
`)) & 255;
|
|
594
|
+
}
|
|
572
595
|
} finally {
|
|
573
596
|
try {
|
|
574
597
|
if (qualified) {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
openAiToolCallsJson,
|
|
6
6
|
openAiTools,
|
|
7
7
|
openAiUsage
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QBCEAYQT.js";
|
|
9
9
|
import {
|
|
10
10
|
openAiBytes,
|
|
11
11
|
openAiError,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from "./chunk-GDH7OVYK.js";
|
|
30
30
|
import {
|
|
31
31
|
base64Stream
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-ZFXHSFTU.js";
|
|
33
33
|
import {
|
|
34
34
|
jsonDictionaryKeys,
|
|
35
35
|
parseLlmNumericOption,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from "./chunk-E47FFS5M.js";
|
|
44
44
|
import {
|
|
45
45
|
sourceBytes
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-36FV6BAG.js";
|
|
47
47
|
import {
|
|
48
48
|
jsonValue
|
|
49
49
|
} from "./chunk-GNPPPYDF.js";
|