Skip to content

Commit 653b346

Browse files
committed
feat(permissions)!: Refine Ask-mode tool approvals
Allow ordinary workspace edits and routine tool operations without confirmation while retaining approval for deletion, sensitive paths, external directories, publishing, and command execution. Define domain actions and concrete resource scopes for built-in tools. Separate Agent process control from user terminal control, update the rules editor and permission copy, and refresh generated documentation. Validation: 76 focused Rust tests, 9 frontend tests, check:web, i18n:audit, and capability catalog checks. BREAKING CHANGE: Migrated built-in tools use domain permission actions. Existing custom_tool rules and grants for those tools are not migrated.
1 parent 76bc00e commit 653b346

33 files changed

Lines changed: 1148 additions & 100 deletions

File tree

‎docs/interactive-capabilities/capabilities.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"title": "OpenBitFun Playbook",
55
"origin": "https://playbook.openbitfun.com",
66
"source": "src/shared/interactive-capabilities/catalog.json",
7-
"digest": "bec28fbd98726d074ccb1073068d0b9c147dddba552cbd46736305e58852b681",
7+
"digest": "95af08a07e006197f38bc56624636046d2b825a055cc28cc341f4024c49ff8e6",
88
"ownerDigest": "1fdb9c49d404c02483c08e1e0fe9effa0aaa4f0f2914578bcaa63e04de16cc16",
99
"searchAcceptance": [
1010
{
@@ -33416,8 +33416,8 @@
3341633416
"id": "default-permission-posture",
3341733417
"titleZh": "在需要确认(默认)、自动审批与完全访问三种默认权限模式间切换",
3341833418
"titleEn": "Switch the default permission mode between Ask (default), Auto-approve, and Full access",
33419-
"descriptionZh": "“需要确认”对写入和命令执行保持人工把关;“自动审批”先由模型评估风险;“完全访问”需二次确认高风险提示,跳过常规询问但依然遵守产品底层硬性安全限制。",
33420-
"descriptionEn": "Ask keeps a human in the loop for writes and shell commands; Auto-approve screens calls with an AI reviewer first; Full access requires confirming a risk warning and skips routine prompts while keeping hard product safety limits intact.",
33419+
"descriptionZh": "“需要确认”默认放行普通工作区编辑、常规查询、任务调度和会话间消息,对命令执行、删除、敏感文件和发布操作保持人工把关;“自动审批”先由模型评估风险;“完全访问”需二次确认高风险提示,跳过常规询问但依然遵守产品底层硬性安全限制。",
33420+
"descriptionEn": "Ask allows ordinary workspace edits, routine queries, scheduling, and messages between sessions, while keeping commands, deletions, sensitive files, and publishing subject to confirmation; Auto-approve screens calls with an AI reviewer first; Full access requires confirming a risk warning and skips routine prompts while keeping hard product safety limits intact.",
3342133421
"control": {
3342233422
"kind": "open",
3342333423
"reasonCode": "unstructuredInteraction",

‎docs/interactive-capabilities/capabilities/setting.ai.permissions.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Set the default safety posture for agent tool calls (Ask, Auto-approve, or Full
2828

2929
- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 在需要确认(默认)、自动审批与完全访问三种默认权限模式间切换
3030
- Switch the default permission mode between Ask (default), Auto-approve, and Full access
31-
- 说明:“需要确认”对写入和命令执行保持人工把关;“自动审批”先由模型评估风险;“完全访问”需二次确认高风险提示,跳过常规询问但依然遵守产品底层硬性安全限制。
32-
- Why & how: Ask keeps a human in the loop for writes and shell commands; Auto-approve screens calls with an AI reviewer first; Full access requires confirming a risk warning and skips routine prompts while keeping hard product safety limits intact.
31+
- 说明:“需要确认”默认放行普通工作区编辑、常规查询、任务调度和会话间消息,对命令执行、删除、敏感文件和发布操作保持人工把关;“自动审批”先由模型评估风险;“完全访问”需二次确认高风险提示,跳过常规询问但依然遵守产品底层硬性安全限制。
32+
- Why & how: Ask allows ordinary workspace edits, routine queries, scheduling, and messages between sessions, while keeping commands, deletions, sensitive files, and publishing subject to confirmation; Auto-approve screens calls with an AI reviewer first; Full access requires confirming a risk warning and skips routine prompts while keeping hard product safety limits intact.
3333
- **智能体可定位入口,需交互完成 / Agent opens; interaction required** · 为自动审批选择聊天审查模型或专用 Jev 决策模型并加密保存凭据
3434
- Choose a chat screener model or dedicated Jev decision model for auto-approval with encrypted credentials
3535
- 说明:聊天模型模式默认优先选用“快速模型”(亦可改为“主模型”或任一已启用模型);专用决策模型模式默认使用 jev-latest,其 API Key 仅加密保存在当前执行主机。

‎docs/interactive-capabilities/technical/product-control-open-audit.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schemaVersion": 1,
33
"generatedFrom": "src/shared/interactive-capabilities/catalog.json",
4-
"catalogDigest": "bec28fbd98726d074ccb1073068d0b9c147dddba552cbd46736305e58852b681",
4+
"catalogDigest": "95af08a07e006197f38bc56624636046d2b825a055cc28cc341f4024c49ff8e6",
55
"count": 231,
66
"reasonCounts": {
77
"externalAuth": 4,

‎docs/interactive-capabilities/technical/tauri-command-map.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schemaVersion": 2,
33
"generatedFrom": "src/shared/interactive-capabilities/catalog.json",
4-
"catalogDigest": "bec28fbd98726d074ccb1073068d0b9c147dddba552cbd46736305e58852b681",
4+
"catalogDigest": "95af08a07e006197f38bc56624636046d2b825a055cc28cc341f4024c49ff8e6",
55
"commandCount": 702,
66
"coverage": {
77
"commandCount": 702,

‎src/crates/assembly/core/src/agentic/tools/file_permissions.rs‎

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::agentic::tools::framework::{PermissionIntent, ToolPathResolution, ToolUseContext};
22
use crate::agentic::tools::restrictions::{
33
canonicalize_local_path_best_effort, is_local_path_within_root,
4+
is_remote_posix_path_within_root,
45
};
56
use crate::infrastructure::get_path_manager_arc;
67
use crate::util::errors::{OpenBitFunError, OpenBitFunResult};
@@ -90,9 +91,28 @@ fn external_directory_resource(
9091
context: &ToolUseContext,
9192
resolved: &ToolPathResolution,
9293
) -> OpenBitFunResult<Option<String>> {
93-
if resolved.uses_remote_workspace_backend() || resolved.is_runtime_artifact() {
94+
if resolved.is_runtime_artifact() {
9495
return Ok(None);
9596
}
97+
if resolved.uses_remote_workspace_backend() {
98+
let workspace = context.workspace.as_ref().ok_or_else(|| {
99+
OpenBitFunError::validation("A workspace is required for file permissions".to_string())
100+
})?;
101+
if is_remote_posix_path_within_root(&resolved.resolved_path, &workspace.root_path_string())
102+
{
103+
return Ok(None);
104+
}
105+
// Remote paths are POSIX even when the controller runs Windows. Do not
106+
// inspect the controller filesystem to classify a target-side path.
107+
let directory = resolved
108+
.resolved_path
109+
.rsplit_once('/')
110+
.map(|(parent, _)| if parent.is_empty() { "/" } else { parent })
111+
.ok_or_else(|| {
112+
OpenBitFunError::validation("Remote path has no parent directory".to_string())
113+
})?;
114+
return Ok(Some(directory.to_string()));
115+
}
96116

97117
if is_openbitfun_managed_local_path(context, resolved)? {
98118
return Ok(None);
@@ -198,6 +218,47 @@ mod tests {
198218
use serde_json::{json, Value};
199219
use std::fs;
200220

221+
#[test]
222+
fn permission_defaults_remote_edits_keep_posix_external_directory_approval() {
223+
use crate::agentic::workspace::WorkspaceBackend;
224+
use openbitfun_agent_runtime::permission::{plan_permission_intents, PermissionIntentPlan};
225+
use openbitfun_runtime_ports::{
226+
PermissionPolicyPreset, PermissionResourceCaseSensitivity, ResolvedPermissionPolicy,
227+
};
228+
let mut workspace = WorkspaceBinding::new(None, PathBuf::from("/remote/workspace"));
229+
workspace.backend = WorkspaceBackend::Remote {
230+
connection_id: "ssh-test".into(),
231+
connection_name: "Test SSH".into(),
232+
};
233+
let context = ToolUseContext::for_tool_listing(Some(workspace), None);
234+
let policy =
235+
ResolvedPermissionPolicy::new(PermissionPolicyPreset::Ask.baseline_rules(), Vec::new());
236+
for (path, allowed) in [
237+
("src/main.rs", true),
238+
(".env", false),
239+
("/remote/outside/file.rs", false),
240+
("../outside/file.rs", false),
241+
] {
242+
let intents = file_permission_intents("edit", [path], &context).unwrap();
243+
assert!(intents[0].resources[0].starts_with('/'));
244+
if path.contains("outside") {
245+
assert_eq!(intents[1].action, "external_directory");
246+
assert_eq!(intents[1].resources, ["/remote/outside"]);
247+
}
248+
let plan = plan_permission_intents(
249+
intents,
250+
&policy,
251+
&[],
252+
PermissionResourceCaseSensitivity::Sensitive,
253+
);
254+
assert_eq!(
255+
matches!(plan, PermissionIntentPlan::Allowed),
256+
allowed,
257+
"{path}: {plan:?}"
258+
);
259+
}
260+
}
261+
201262
#[test]
202263
fn local_external_file_adds_external_directory_intent() {
203264
let temp = tempfile::tempdir().expect("temp dir");
@@ -423,8 +484,9 @@ mod tests {
423484
let delete = DeleteFileTool::new()
424485
.permission_intents(&json!({ "path": plan_path.as_ref() }), &context)
425486
.expect("plan delete permission intents");
426-
assert_eq!(delete.len(), 1);
487+
assert_eq!(delete.len(), 2);
427488
assert_eq!(delete[0].action, "edit");
489+
assert_eq!(delete[1].action, "delete");
428490

429491
let transcript_path = transcript.to_string_lossy();
430492
let transcript_edit = FileEditTool::new()
@@ -558,7 +620,12 @@ mod tests {
558620
let intents = tool
559621
.permission_intents(&input, &context)
560622
.expect("file tool permission intent");
561-
assert_eq!(intents.len(), 1, "{}", tool.name());
623+
assert_eq!(
624+
intents.len(),
625+
if tool.name() == "Delete" { 2 } else { 1 },
626+
"{}",
627+
tool.name()
628+
);
562629
assert_eq!(intents[0].action, expected_action, "{}", tool.name());
563630
assert_eq!(intents[0].resources.len(), 1, "{}", tool.name());
564631
}

0 commit comments

Comments
 (0)