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
+28
View File
@@ -61,6 +61,34 @@ describe("Agent REST OpenAPI", () => {
expect(document.paths["/api/v1/agent/chat/stream"]).toBeUndefined();
});
test("separates automatic approval from persistent permission grants", () => {
const document = generateAgentOpenApi();
const runRequest = document.paths["/api/v1/agent/sessions/{session_id}/runs"]
?.post?.requestBody;
const permissionRequest = document.paths[
"/api/v1/agent/sessions/{session_id}/permission-responses"
]?.post?.requestBody;
expect(
runRequest && !("$ref" in runRequest)
? runRequest.content["application/json"]?.schema
: undefined,
).toMatchObject({
properties: {
approval_mode: { enum: ["request", "auto", "always"] },
},
});
expect(
permissionRequest && !("$ref" in permissionRequest)
? permissionRequest.content["application/json"]?.schema
: undefined,
).toMatchObject({
properties: {
reply: { enum: ["once", "always", "reject"] },
},
});
});
test("matches the public session runtime response shapes", () => {
const document = generateAgentOpenApi();
const schemas = document.components?.schemas ?? {};