mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 22:15:57 +08:00
重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。 Made-with: Cursor
This commit is contained in:
parent
ba3836f00f
commit
4a23b715a2
498 changed files with 2760 additions and 2200 deletions
|
|
@ -1,38 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.tools.base import ToolSpec
|
||||
from oclaw.tools.catalog import _apply_declared_tool_policy
|
||||
|
||||
|
||||
def _tool(name: str, tags: set[str]) -> ToolSpec:
|
||||
return ToolSpec(
|
||||
name=name,
|
||||
description=name,
|
||||
parameters={"type": "object", "properties": {}},
|
||||
handler=lambda _args: {"ok": True},
|
||||
tags=frozenset(tags),
|
||||
)
|
||||
|
||||
|
||||
def test_declared_tool_policy_filters_by_tags_and_names() -> None:
|
||||
tools = [
|
||||
_tool("search_workspace", {"search", "read"}),
|
||||
_tool("run_command", {"shell", "exec"}),
|
||||
_tool("read_file", {"read", "fs"}),
|
||||
]
|
||||
out = _apply_declared_tool_policy(
|
||||
tools,
|
||||
allow_tags=["read"],
|
||||
allow_tools=["run_command"],
|
||||
)
|
||||
names = {t.name for t in out}
|
||||
assert "search_workspace" in names
|
||||
assert "read_file" in names
|
||||
assert "run_command" in names
|
||||
|
||||
|
||||
def test_declared_tool_policy_empty_rules_returns_original() -> None:
|
||||
tools = [_tool("a", {"x"}), _tool("b", {"y"})]
|
||||
out = _apply_declared_tool_policy(tools, allow_tags=[], allow_tools=[])
|
||||
assert [t.name for t in out] == ["a", "b"]
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue