mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
Add save_deliverable_attachment for explicit document outbound, pass channel user_id into tool risk gating so write_file/run_command respect per-user allow_high settings, and document the workflow in channel-file-delivery skill. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from runtime.tools.catalog import materialize_tool_specs
|
|
from runtime.tools.public_registry import clear_public_tool_cache
|
|
|
|
|
|
def test_materialize_tools_respects_user_allow_high_risk_public_tools(monkeypatch) -> None:
|
|
clear_public_tool_cache()
|
|
monkeypatch.delenv("AIA_PUBLIC_TOOLS_ALLOW_HIGH", raising=False)
|
|
|
|
class _Store:
|
|
def get_user_workspace_path_allowlist(self, *, tenant_id: str, user_id: str):
|
|
assert tenant_id == "tenant-a"
|
|
assert user_id == "user-a"
|
|
return {"allow_high_risk_public_tools": True}
|
|
|
|
names = {
|
|
t.name
|
|
for t in materialize_tool_specs(
|
|
store=_Store(),
|
|
path_policy_tenant_id="tenant-a",
|
|
path_policy_user_id="user-a",
|
|
)
|
|
}
|
|
assert "write_file" in names
|
|
assert "run_command" in names
|
|
assert "save_deliverable_attachment" in names
|
|
|
|
|
|
def test_materialize_tools_blocks_high_risk_without_user_policy(monkeypatch) -> None:
|
|
clear_public_tool_cache()
|
|
monkeypatch.delenv("AIA_PUBLIC_TOOLS_ALLOW_HIGH", raising=False)
|
|
|
|
names = {
|
|
t.name
|
|
for t in materialize_tool_specs(
|
|
store=None,
|
|
path_policy_tenant_id="tenant-a",
|
|
path_policy_user_id=None,
|
|
)
|
|
}
|
|
assert "write_file" not in names
|
|
assert "run_command" not in names
|
|
assert "save_deliverable_attachment" in names
|