feat(agent): sandbox conversation analysis
Generic Container CI/CD / test-build-publish (push) Successful in 2m44s
Agent CI/CD v2 / build-test-publish-and-deploy (push) Successful in 2m44s

This commit is contained in:
2026-08-25 16:08:33 +08:00
parent ce04704af2
commit 80cfc1f2ab
27 changed files with 2387 additions and 125 deletions
+53
View File
@@ -0,0 +1,53 @@
import { tool } from "@opencode-ai/plugin";
const internalBaseUrl =
process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
export default tool({
description:
"在当前对话专属的 Landlock 沙箱中运行 Shell 命令。只能读写当前对话工作区,不能访问网络、密钥、其他对话或应用源码。",
args: {
command: tool.schema.string().describe("需要在沙箱中执行的 Shell 命令。"),
description: tool.schema
.string()
.optional()
.describe("面向用户的简短命令说明。"),
timeout: tool.schema
.number()
.optional()
.describe("超时秒数,默认 120,最大 1800。"),
},
async execute(args, context) {
await context.ask({
permission: "bash",
patterns: [args.command],
always: [args.command],
metadata: {
command: args.command,
...(args.description ? { description: args.description } : {}),
},
});
const response = await fetch(
`${internalBaseUrl}/internal/tools/sandbox-shell`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-agent-internal-token": internalToken,
},
body: JSON.stringify({
session_id: context.sessionID,
command: args.command,
description: args.description,
timeout: args.timeout,
}),
},
);
const text = await response.text();
if (!response.ok) {
throw new Error(text);
}
return text;
},
});