mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 05:01:15 +00:00
fix(exec): clarify auto routing semantics (#58897) (thanks @vincentkoc)
This commit is contained in:
@@ -47,6 +47,36 @@ describe("resolveExecTarget", () => {
|
||||
({ resolveExecTarget } = await import("./bash-tools.exec-runtime.js"));
|
||||
});
|
||||
|
||||
it("keeps implicit auto on sandbox when a sandbox runtime is available", () => {
|
||||
expect(
|
||||
resolveExecTarget({
|
||||
configuredTarget: "auto",
|
||||
elevatedRequested: false,
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
configuredTarget: "auto",
|
||||
requestedTarget: null,
|
||||
selectedTarget: "auto",
|
||||
effectiveHost: "sandbox",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps implicit auto on gateway when no sandbox runtime is available", () => {
|
||||
expect(
|
||||
resolveExecTarget({
|
||||
configuredTarget: "auto",
|
||||
elevatedRequested: false,
|
||||
sandboxAvailable: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
configuredTarget: "auto",
|
||||
requestedTarget: null,
|
||||
selectedTarget: "auto",
|
||||
effectiveHost: "gateway",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects host overrides when configured host is auto", () => {
|
||||
expect(() =>
|
||||
resolveExecTarget({
|
||||
@@ -84,6 +114,49 @@ describe("resolveExecTarget", () => {
|
||||
effectiveHost: "sandbox",
|
||||
});
|
||||
});
|
||||
|
||||
it("requires an exact match for non-auto configured targets", () => {
|
||||
expect(() =>
|
||||
resolveExecTarget({
|
||||
configuredTarget: "gateway",
|
||||
requestedTarget: "auto",
|
||||
elevatedRequested: false,
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toThrow("exec host not allowed");
|
||||
});
|
||||
|
||||
it("allows exact node matches", () => {
|
||||
expect(
|
||||
resolveExecTarget({
|
||||
configuredTarget: "node",
|
||||
requestedTarget: "node",
|
||||
elevatedRequested: false,
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
configuredTarget: "node",
|
||||
requestedTarget: "node",
|
||||
selectedTarget: "node",
|
||||
effectiveHost: "node",
|
||||
});
|
||||
});
|
||||
|
||||
it("still forces elevated requests onto the gateway host", () => {
|
||||
expect(
|
||||
resolveExecTarget({
|
||||
configuredTarget: "auto",
|
||||
requestedTarget: "sandbox",
|
||||
elevatedRequested: true,
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
configuredTarget: "auto",
|
||||
requestedTarget: "sandbox",
|
||||
selectedTarget: "gateway",
|
||||
effectiveHost: "gateway",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("emitExecSystemEvent", () => {
|
||||
|
||||
Reference in New Issue
Block a user