feat: add claw backend adapter
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { selectExecutionBackendForTesting } from "@/lib/execution/backend-selector";
|
||||
import {
|
||||
listExecutionBackendChoices,
|
||||
selectExecutionBackendForTesting,
|
||||
} from "@/lib/execution/backend-selector";
|
||||
|
||||
test("selectExecutionBackendForTesting prefers the ready primary master codex node", async () => {
|
||||
const backend = await selectExecutionBackendForTesting({
|
||||
@@ -73,3 +76,46 @@ test("selectExecutionBackendForTesting falls back to master node last when highe
|
||||
|
||||
assert.equal(backend.backendId, "master-codex-node");
|
||||
});
|
||||
|
||||
test("listExecutionBackendChoices keeps claw disabled by default", () => {
|
||||
const backends = listExecutionBackendChoices({
|
||||
primary: { provider: "master_codex_node", status: "ready" },
|
||||
backups: [{ provider: "openai_api", status: "ready" }],
|
||||
requestKind: "master_agent_reply",
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
backends.map((backend) => backend.backendId),
|
||||
["master-codex-node", "openai-api"],
|
||||
);
|
||||
});
|
||||
|
||||
test("selectExecutionBackendForTesting honors an explicit claw request when claw is enabled", async () => {
|
||||
const backend = await selectExecutionBackendForTesting({
|
||||
primary: { provider: "master_codex_node", status: "ready" },
|
||||
backups: [{ provider: "openai_api", status: "ready" }],
|
||||
requestKind: "master_agent_reply",
|
||||
requestedBackendId: "claw-runtime",
|
||||
claw: {
|
||||
enabled: true,
|
||||
supportsKinds: ["master_agent_reply", "thread_reply"],
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(backend.backendId, "claw-runtime");
|
||||
});
|
||||
|
||||
test("selectExecutionBackendForTesting falls back when claw is requested but unavailable", async () => {
|
||||
const backend = await selectExecutionBackendForTesting({
|
||||
primary: { provider: "master_codex_node", status: "ready" },
|
||||
backups: [{ provider: "openai_api", status: "ready" }],
|
||||
requestKind: "master_agent_reply",
|
||||
requestedBackendId: "claw-runtime",
|
||||
claw: {
|
||||
enabled: false,
|
||||
supportsKinds: ["master_agent_reply"],
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(backend.backendId, "master-codex-node");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user