mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 01:50:44 +08:00
- Rename platform/ to svc/ to avoid shadowing stdlib platform. - Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths. - tests/conftest: prepend repo root to sys.path (no parent-folder package name). - CI: paths and offline_eval script under repo root. - Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup). - Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config. Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
2.2 KiB
Python
53 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from runtime.agents.factory import build_gateway_executor
|
|
from svc.persistence.sqlite_store import SqliteStore
|
|
|
|
|
|
def test_build_gateway_executor_defaults_to_generalist(tmp_path: Path) -> None:
|
|
store = SqliteStore(str(tmp_path / "ops.sqlite"))
|
|
ex = build_gateway_executor(store, lang="zh")
|
|
assert type(ex).__name__ == "Agent"
|
|
assert hasattr(ex, "tools")
|
|
assert hasattr(ex, "model")
|
|
|
|
|
|
def test_build_gateway_executor_generalist_run_command_is_disabled_by_default(tmp_path: Path) -> None:
|
|
os.environ.pop("AIA_ENABLE_RUN_COMMAND", None)
|
|
os.environ["AIA_PUBLIC_TOOLS_ALLOW_HIGH"] = "1"
|
|
os.environ["OPS_ASSISTANT_DB_PATH"] = str(tmp_path / "ops.sqlite")
|
|
try:
|
|
store = SqliteStore(str(tmp_path / "ops.sqlite"))
|
|
ex = build_gateway_executor(store, lang="zh", specialist="generalist")
|
|
run_tool = next((t for t in ex.tools.list() if t.name == "run_command"), None)
|
|
assert run_tool is not None
|
|
out = run_tool.handler({"command": "echo hi"})
|
|
assert isinstance(out, dict)
|
|
assert out.get("ok") is False
|
|
assert out.get("error") == "disabled"
|
|
finally:
|
|
os.environ.pop("AIA_PUBLIC_TOOLS_ALLOW_HIGH", None)
|
|
os.environ.pop("OPS_ASSISTANT_DB_PATH", None)
|
|
|
|
|
|
def test_build_gateway_executor_generalist_run_command_prefers_db_setting(tmp_path: Path) -> None:
|
|
os.environ["AIA_ENABLE_RUN_COMMAND"] = "0"
|
|
os.environ["AIA_PUBLIC_TOOLS_ALLOW_HIGH"] = "1"
|
|
os.environ["OPS_ASSISTANT_DB_PATH"] = str(tmp_path / "ops.sqlite")
|
|
try:
|
|
store = SqliteStore(str(tmp_path / "ops.sqlite"))
|
|
store.set_setting("AIA_ENABLE_RUN_COMMAND", "1")
|
|
ex = build_gateway_executor(store, lang="zh", specialist="generalist")
|
|
run_tool = next((t for t in ex.tools.list() if t.name == "run_command"), None)
|
|
assert run_tool is not None
|
|
out = run_tool.handler({"command": "echo hi"})
|
|
assert isinstance(out, dict)
|
|
assert out.get("ok") is True
|
|
finally:
|
|
os.environ.pop("AIA_ENABLE_RUN_COMMAND", None)
|
|
os.environ.pop("AIA_PUBLIC_TOOLS_ALLOW_HIGH", None)
|
|
os.environ.pop("OPS_ASSISTANT_DB_PATH", None)
|
|
|