feat(agent): 完善权限与结果引用安全

This commit is contained in:
2026-08-06 18:41:52 +08:00
parent a5e91ac2b8
commit b19af8846a
22 changed files with 621 additions and 47 deletions
+27
View File
@@ -129,4 +129,31 @@ describe("OpencodeRuntimeAdapter.warmup", () => {
"session.delete:warmup-session",
]);
});
it("submits question answers through the stable question API", async () => {
const calls: unknown[] = [];
const client = {
question: {
reply: async (input: unknown) => {
calls.push(input);
return { data: { ok: true } };
},
},
} as unknown as OpencodeClient;
const runtime = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), {
clientPromise: null,
closeServer: null,
ensureClient: async () => client,
}) as OpencodeRuntimeAdapter;
await runtime.replyQuestion({
requestId: "question-1",
sessionId: "session-1",
answers: [["继续"]],
});
expect(calls).toEqual([
{ requestID: "question-1", answers: [["继续"]] },
]);
});
});