File size: 1,161 Bytes
39b3fb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import type { TaskRequest, TaskResult } from "../shared/protocol.js";
import { commandAllowed } from "./plugins.js";
export async function runBridgeTask(task: TaskRequest, entropy: number): Promise<TaskResult> {
if (!commandAllowed(task.command, task.vmTarget, task.ideTarget)) {
return {
id: task.id,
contextId: task.contextId,
status: "failed",
entropy,
message: `Command is not allowlisted for ${task.vmTarget}/${task.ideTarget}: ${task.command}`,
output: {
vmTarget: task.vmTarget,
ideTarget: task.ideTarget,
},
completedAt: new Date().toISOString(),
};
}
return {
id: task.id,
contextId: task.contextId,
status: "succeeded",
entropy,
message: `${task.command} accepted by ${task.vmTarget}/${task.ideTarget} bridge`,
output: {
vmTarget: task.vmTarget,
ideTarget: task.ideTarget,
runtimeAuthority: task.vmTarget === "apl-wasm" ? "APL/Rust/WASM substrate" : "plugin adapter",
simulated: true,
payloadKeys: Object.keys(task.payload),
},
completedAt: new Date().toISOString(),
};
}
|