feat(agent): add controlled task execution

This commit is contained in:
2026-09-24 04:19:02 +08:00
parent d018bcae67
commit b31033e9ce
48 changed files with 14498 additions and 86 deletions
+29
View File
@@ -91,6 +91,35 @@ describe("OpencodeRuntimeAdapter.ensureClient", () => {
});
});
describe("OpencodeRuntimeAdapter.resolveAvailableModel", () => {
it("selects the first preferred model actually exposed by OpenCode", async () => {
const client = {
config: {
providers: async () => ({
data: {
providers: [{
id: "deepseek",
models: {
"deepseek-flash": {},
"deepseek-v4-pro": {},
},
}],
default: {},
},
}),
},
} as unknown as OpencodeClient;
const runtime = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), {
ensureClient: async () => client,
}) as OpencodeRuntimeAdapter;
await expect(runtime.resolveAvailableModel([
"deepseek/deepseek-v4-flash",
"deepseek/deepseek-v4-pro",
])).resolves.toBe("deepseek/deepseek-v4-pro");
});
});
describe("resolveEmbeddedOpencodePort", () => {
it("falls back to a dynamic port when the configured port is occupied", async () => {
const server = createServer();
+20
View File
@@ -0,0 +1,20 @@
import { describe, expect, it } from "bun:test";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
const projectRoot = join(import.meta.dir, "../..");
describe("supply Agent identity", () => {
it("keeps the primary instruction scoped to validated supply data", async () => {
const instruction = await readFile(
join(projectRoot, ".opencode/agents/instruction.md"),
"utf8",
);
expect(instruction).toContain("TJWater 实验性供水数据 Agent");
expect(instruction).toContain("供水事件数据边界");
expect(instruction).not.toContain("source/");
expect(instruction).not.toContain("排水");
expect(instruction).not.toContain("雨污混接");
});
});