mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 05:30:46 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
38
tests/test_openclaw_dynamic_expert.py
Normal file
38
tests/test_openclaw_dynamic_expert.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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