接续L4-TOOL-DB浏览器Provider协议

结论:浏览器 Worker 已支持可插拔 Python runtime provider 的 line I/O,缺真实 Python/WASM runtime 时仍保持阻塞不解锁。
This commit is contained in:
2026-06-19 07:13:52 +08:00
parent 63870fd6d7
commit db33224dd0
6 changed files with 159 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
self.linuxCncToolDbPythonRuntimeProvider = {
lines: [
"v2.1",
"T10 P110 D0.10 Z0.10",
"FINI (get_cmd)",
"FINI (update recvd) t11 p111 d0.33 z0.11",
"FINI (update recvd) t14 p0",
"FINI (update recvd) t0 p0",
],
async start() {},
async writeLine() {},
async readLine() {
return this.lines.shift();
},
async close() {},
};
await import("../../runtime/workers/tool-db-python-worker.js");

View File

@@ -85,6 +85,23 @@
assertEqual(workerPlanResult.promotionAllowed, false, "worker promotion guard");
await workerPort.close();
const fakeRuntimeAdapter = createLinuxCncToolDbBrowserWorkerAdapter({
workerUrl: new URL("./tool_db_fake_python_runtime_worker.js", import.meta.url),
});
const fakeRuntimePort = createLinuxCncToolDbProcessPort({
dbProgramPath: "./db_nonran.py",
runtimeMode: fakeRuntimeAdapter.runtimeMode,
runtimeAdapter: fakeRuntimeAdapter,
});
const fakeRuntimeStart = await fakeRuntimePort.start();
assertEqual(fakeRuntimeStart.runtimeExecutionReady, true, "fake provider runtime readiness");
assertEqual(fakeRuntimeStart.status, "browser_python_wasm_runtime_ready", "fake provider runtime status");
const fakeRuntimePlan = await fakeRuntimePort.runTransactionPlan();
assertEqual(fakeRuntimePlan.status, "runtime_adapter_transaction_plan_executed", "fake provider plan");
assertEqual(fakeRuntimePlan.promotionAllowed, false, "fake provider promotion guard");
assertEqual(validateToolDbTranscript(fakeRuntimePort.exportTranscript()).ready, true, "fake provider transcript");
await fakeRuntimePort.close();
const transcript = [
{ direction: "read", line: "v2.1" },
{ direction: "write", line: "g" },