接续L4-TOOL-DB浏览器Worker边界
结论:浏览器 Tool DB Worker 传输层已接入并明确阻塞缺失的 Python/WASM runtime,未冒充 DB_PROGRAM 执行就绪。
This commit is contained in:
39
wasm-port/runtime/workers/tool-db-python-worker.js
Normal file
39
wasm-port/runtime/workers/tool-db-python-worker.js
Normal file
@@ -0,0 +1,39 @@
|
||||
function postReply(id, type, payload) {
|
||||
self.postMessage({ id, type, ok: true, ...payload });
|
||||
}
|
||||
|
||||
function postError(id, type, error) {
|
||||
self.postMessage({
|
||||
id,
|
||||
type,
|
||||
ok: false,
|
||||
error: error?.message ?? String(error),
|
||||
});
|
||||
}
|
||||
|
||||
function pythonRuntimeAvailable() {
|
||||
return typeof self.loadPyodide === "function" || Boolean(self.pyodide?.runPythonAsync);
|
||||
}
|
||||
|
||||
self.addEventListener("message", async (event) => {
|
||||
const message = event.data ?? {};
|
||||
const { id, type } = message;
|
||||
try {
|
||||
if (type === "start") {
|
||||
const ready = pythonRuntimeAvailable();
|
||||
postReply(id, type, {
|
||||
runtimeMode: "browser-python-wasm-worker",
|
||||
runtimeExecutionReady: ready,
|
||||
status: ready
|
||||
? "browser_python_wasm_runtime_ready"
|
||||
: "blocked_browser_python_wasm_runtime_missing",
|
||||
executionEnabled: false,
|
||||
promotionAllowed: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
throw new Error("blocked_browser_python_wasm_runtime_missing");
|
||||
} catch (error) {
|
||||
postError(id, type, error);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user