Skip to content

Commit 8db7f66

Browse files
authored
Merge pull request Stack-Cairn#329 from yyg-max/feat/tool-approval-gate
feat: add per-tool execution approval gate and streamline tool settings
2 parents 717a1eb + f69f24d commit 8db7f66

90 files changed

Lines changed: 2070 additions & 2256 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 182 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ BUF_BREAKING_AGAINST ?= ../../.git\#subdir=$(AGENT_GATEWAY_DIR)
150150
proto-check:
151151
@command -v buf >/dev/null || (echo "buf is required. Run: mise install" && exit 1)
152152
cd $(AGENT_GATEWAY_DIR) && buf lint
153-
node scripts/check-buf-breaking.mjs "$(AGENT_GATEWAY_DIR)" "$(BUF_BREAKING_AGAINST)"
153+
cd $(AGENT_GATEWAY_DIR) && buf breaking --against '$(BUF_BREAKING_AGAINST)'
154154

155155
webui:
156156
pnpm --dir $(AGENT_GATEWAY_WEB_DIR) install --offline

crates/agent-gateway/buf.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ lint:
1111
except:
1212
# 历史布局 proto/<版本>/ 早于 buf;迁目录会改 import 路径、破坏 Rust build.rs 与生成物,不翻新。
1313
- PACKAGE_DIRECTORY_MATCH
14-
# 共享业务消息沿用已发布的枚举命名;只对该迁移文件保留最小豁免
14+
# gateway.proto 中已发布的枚举命名保持不变,仅保留必要的 lint 豁免
1515
ignore_only:
1616
ENUM_VALUE_PREFIX:
1717
- proto/v2/gateway.proto
1818
ENUM_ZERO_VALUE_SUFFIX:
1919
- proto/v2/gateway.proto
2020
breaking:
2121
use:
22-
# WIRE_JSON:兼守二进制与 JSON 线格式兼容(chat 事件与公开分享页仍走 JSON 载荷)
22+
# 同时保护 Protobuf 二进制线格式与 proto JSON 表示的兼容性
2323
- WIRE_JSON

crates/agent-gateway/internal/chatcmd/chatcmd.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func NormalizeRequestBody(body *handler.ChatRequestBody) error {
6565
body.ExecutionMode = handler.NormalizeExecutionMode(body.ExecutionMode)
6666
body.Workdir = handler.NormalizeWorkdir(body.Workdir)
6767
body.QueuePolicy = normalizeQueuePolicy(body.QueuePolicy)
68-
body.SelectedSystemTools = handler.NormalizeSelectedSystemTools(body.SelectedSystemTools)
6968
body.UploadedFiles = handler.NormalizeChatUploadedFiles(body.UploadedFiles)
7069
body.RuntimeControls = handler.NormalizeChatRuntimeControls(body.RuntimeControls)
7170
selectedModel, err := handler.NormalizeChatSelectedModel(body.SelectedModel)
@@ -275,7 +274,6 @@ func buildUserMessageAppendedPayload(
275274
"uploaded_files": body.UploadedFiles,
276275
"execution_mode": body.ExecutionMode,
277276
"workdir": body.Workdir,
278-
"selected_system_tools": body.SelectedSystemTools,
279277
"runtime_controls": body.RuntimeControls,
280278
"selected_model": body.SelectedModel,
281279
}
@@ -326,7 +324,6 @@ func buildProtoRequest(body handler.ChatRequestBody) *gatewayv2.ChatRequest {
326324
RuntimeControls: handler.ToProtoChatRuntimeControls(body.RuntimeControls),
327325
ExecutionMode: body.ExecutionMode,
328326
Workdir: body.Workdir,
329-
SelectedSystemTools: body.SelectedSystemTools,
330327
UploadedFiles: handler.ToProtoChatUploadedFiles(body.UploadedFiles),
331328
QueuePolicy: body.QueuePolicy,
332329
}
@@ -359,7 +356,6 @@ func RequestBodyFromProto(req *gatewayv2.ChatRequest) handler.ChatRequestBody {
359356
Message: req.GetMessage(),
360357
ExecutionMode: req.GetExecutionMode(),
361358
Workdir: req.GetWorkdir(),
362-
SelectedSystemTools: req.GetSelectedSystemTools(),
363359
QueuePolicy: req.GetQueuePolicy(),
364360
}
365361
if selected := req.GetSelectedModel(); selected != nil {

crates/agent-gateway/internal/handler/types.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type ChatRequestBody struct {
3535
RuntimeControls *ChatRuntimeControlsBody `json:"runtime_controls,omitempty"`
3636
ExecutionMode string `json:"execution_mode,omitempty"`
3737
Workdir string `json:"workdir,omitempty"`
38-
SelectedSystemTools []string `json:"selected_system_tools,omitempty"`
3938
UploadedFiles []ChatUploadedFileBody `json:"uploaded_files,omitempty"`
4039
QueuePolicy string `json:"queue_policy,omitempty"`
4140
}
@@ -73,10 +72,6 @@ func boolValue(input *bool, fallback bool) bool {
7372
return *input
7473
}
7574

76-
var validSystemToolIDs = map[string]struct{}{
77-
"http_get_test": {},
78-
}
79-
8075
func NormalizeChatSelectedModel(
8176
input *ChatSelectedModelBody,
8277
) (*ChatSelectedModelBody, error) {
@@ -148,28 +143,6 @@ func NormalizeWorkdir(value string) string {
148143
return normalizeTrimmedText(value)
149144
}
150145

151-
func NormalizeSelectedSystemTools(input []string) []string {
152-
out := make([]string, 0, len(input))
153-
seen := make(map[string]struct{}, len(input))
154-
155-
for _, item := range input {
156-
value := normalizeTrimmedText(item)
157-
if value == "" {
158-
continue
159-
}
160-
if _, ok := validSystemToolIDs[value]; !ok {
161-
continue
162-
}
163-
if _, ok := seen[value]; ok {
164-
continue
165-
}
166-
seen[value] = struct{}{}
167-
out = append(out, value)
168-
}
169-
170-
return out
171-
}
172-
173146
func NormalizeChatUploadedFiles(input []ChatUploadedFileBody) []ChatUploadedFileBody {
174147
out := make([]ChatUploadedFileBody, 0, len(input))
175148
seen := make(map[string]struct{}, len(input))

crates/agent-gateway/internal/handler/types_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@ func TestNormalizeExecutionMode(t *testing.T) {
2323
}
2424
}
2525

26-
func TestNormalizeSelectedSystemTools(t *testing.T) {
27-
t.Parallel()
28-
29-
got := NormalizeSelectedSystemTools([]string{
30-
" http_get_test ",
31-
"http_get_test",
32-
"",
33-
"unknown_tool",
34-
})
35-
want := []string{"http_get_test"}
36-
37-
if !reflect.DeepEqual(got, want) {
38-
t.Fatalf("NormalizeSelectedSystemTools() = %#v, want %#v", got, want)
39-
}
40-
}
41-
4226
func TestNormalizeChatSelectedModelAcceptsGemini(t *testing.T) {
4327
t.Parallel()
4428

crates/agent-gateway/internal/proto/v2/gateway.pb.go

Lines changed: 15 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/agent-gateway/proto/v2/gateway.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ message ChatRequest {
609609
ChatSelectedModel selected_model = 3;
610610
string execution_mode = 4;
611611
string workdir = 5;
612-
repeated string selected_system_tools = 6;
612+
reserved 6;
613+
reserved "selected_system_tools";
613614
repeated ChatUploadedFile uploaded_files = 7;
614615
string client_request_id = 8;
615616
ChatRuntimeControls runtime_controls = 9;

crates/agent-gateway/test/webui/gateway-socket-client.test.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,6 @@ test("GatewayWebSocketClient chatCommand sends the command frame and parses the
12651265
systemSettings: {
12661266
executionMode: "agent",
12671267
workdir: "/workspace/project",
1268-
selectedSystemTools: ["Bash"],
12691268
},
12701269
});
12711270
const socket = await connectAndAuth(codec);
@@ -1277,7 +1276,6 @@ test("GatewayWebSocketClient chatCommand sends the command frame and parses the
12771276
assert.equal(command.json.chat_command.request.client_request_id, "req-1");
12781277
assert.equal(command.json.chat_command.request.queue_policy, "append");
12791278
assert.equal(command.json.chat_command.request.workdir, "/workspace/project");
1280-
assert.deepEqual(command.json.chat_command.request.selected_system_tools, ["Bash"]);
12811279

12821280
socket.receiveBinary(
12831281
codec.encodeServerFrame({

crates/agent-gateway/test/webui/web-settings.test.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ test("gateway settings sync keeps remote connection local and syncs web terminal
615615
system: {
616616
executionMode: "tools",
617617
workdir: "/remote-workdir",
618-
selectedSystemTools: ["http_get_test"],
619618
},
620619
chatRuntimeControls: {
621620
thinkingEnabled: false,
@@ -633,7 +632,6 @@ test("gateway settings sync keeps remote connection local and syncs web terminal
633632

634633
assert.equal(synced.system.executionMode, "tools");
635634
assert.equal(synced.system.workdir, "/remote-workdir");
636-
assert.deepEqual(synced.system.selectedSystemTools, ["http_get_test"]);
637635
assert.equal(synced.chatRuntimeControls.thinkingEnabled, false);
638636
assert.equal(synced.chatRuntimeControls.nativeWebSearchEnabled, false);
639637
assert.equal(synced.chatRuntimeControls.reasoning, "minimal");

0 commit comments

Comments
 (0)