feat(agent): 完善分析编排与结果传输
Generic Container CI/CD / test-build-publish (push) Failing after 1m20s
Agent CI/CD v2 / build-test-publish-and-deploy (push) Failing after 1m20s

This commit is contained in:
2026-08-26 18:04:51 +08:00
parent a438433068
commit 72ebf4d6c1
33 changed files with 1027 additions and 705 deletions
-52
View File
@@ -117,58 +117,6 @@ describe("OpencodeRuntimeAdapter.subscribeEvents", () => {
});
});
describe("OpencodeRuntimeAdapter.prompt", () => {
it("forwards the final answer schema", async () => {
const calls: unknown[] = [];
const client = {
session: {
prompt: async (input: unknown) => {
calls.push(input);
return { data: {} };
},
},
} as unknown as OpencodeClient;
const runtime = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), {
ensureClient: async () => client,
}) as OpencodeRuntimeAdapter;
await runtime.prompt(
"session-1",
"分析供水分区",
{ providerID: "deepseek", modelID: "deepseek-v4-flash" },
{
format: {
type: "json_schema",
schema: {
type: "object",
properties: { answer: { type: "string" } },
required: ["answer"],
},
},
},
);
expect(calls).toEqual([
{
sessionID: "session-1",
model: {
providerID: "deepseek",
modelID: "deepseek-v4-flash",
},
format: {
type: "json_schema",
schema: {
type: "object",
properties: { answer: { type: "string" } },
required: ["answer"],
},
},
parts: [{ type: "text", text: "分析供水分区" }],
},
]);
});
});
describe("OpencodeRuntimeAdapter interaction replies", () => {
it("replies to permissions in the conversation workspace directory", async () => {
const calls: unknown[] = [];
+33 -2
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { readFile } from "node:fs/promises";
import { readFile, readdir } from "node:fs/promises";
import sandboxBash from "../../.opencode/tools/bash.js";
import tjwaterCli from "../../.opencode/tools/tjwater_cli.js";
import storeRenderRef, {
@@ -37,6 +37,8 @@ describe("internal OpenCode permissions", () => {
expect(permission.external_directory).toBe("deny");
expect(permission.task).toBe("deny");
expect(permission.question).toBe("allow");
expect(permission.activity_update).toBe("allow");
expect(permission.final_answer).toBe("allow");
expect(permission.todowrite).toBe("allow");
expect(read?.["*"]).toBe("allow");
expect(read?.["data/**"]).toBe("deny");
@@ -56,6 +58,22 @@ describe("internal OpenCode permissions", () => {
expect(bash?.["*data/*"]).toBeUndefined();
expect(bash?.["*logs/*"]).toBeUndefined();
});
it("keeps reason only on the activity grouping tool", async () => {
const toolFiles = (await readdir(".opencode/tools"))
.filter((file) => file.endsWith(".ts"));
const sources = await Promise.all(
toolFiles.map(async (file) => ({
file,
source: await readFile(`.opencode/tools/${file}`, "utf8"),
})),
);
const reasonSchemaFiles = sources
.filter(({ source }) => /reason:\s*tool\.schema/u.test(source))
.map(({ file }) => file);
expect(reasonSchemaFiles).toEqual(["activity_update.ts"]);
});
});
describe("store_render_ref arguments", () => {
@@ -154,6 +172,20 @@ describe("sandbox bash tool", () => {
});
describe("tjwater_cli storage request", () => {
it("keeps command discovery rules in the always-visible tool contract", () => {
const definition = tjwaterCli as unknown as {
description: string;
args: { command: { description?: string } };
};
expect(definition.description).toContain("help");
expect(definition.args.command.description).toContain("禁止类推");
expect(definition.args.command.description).toContain("simulation runs list");
expect(definition.args.command.description).not.toContain(
"示例:'analysis runs list'",
);
});
it("forwards store_result so small workflow inputs can be staged", async () => {
const originalFetch = globalThis.fetch;
let requestBody: unknown;
@@ -168,7 +200,6 @@ describe("tjwater_cli storage request", () => {
await definition.execute(
{
command: "network get-all-reservoirs-properties",
reason: "prepare workflow input",
store_result: true,
},
{ sessionID: "session-test" } as never,