mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 06:40:45 +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
|
|
@ -145,7 +145,7 @@ class AdminChatStreamAsyncTaskTests(unittest.TestCase):
|
|||
self.assertEqual(str(body.get("mode") or ""), "async_task")
|
||||
task_id = str(body.get("task_id") or "")
|
||||
self.assertTrue(task_id.strip())
|
||||
task = self.store.openclaw_task_get(task_id=task_id, tenant_id=self.tenant_id)
|
||||
task = self.store.oclaw_task_get(task_id=task_id, tenant_id=self.tenant_id)
|
||||
self.assertIsNotNone(task)
|
||||
payload = json.loads(str(task.payload or "{}"))
|
||||
self.assertEqual(str(payload.get("selected_specialist") or ""), "generalist")
|
||||
|
|
@ -202,7 +202,7 @@ class AdminChatStreamAsyncTaskTests(unittest.TestCase):
|
|||
self.assertTrue(body.get("ok"), body)
|
||||
task_id = str(body.get("task_id") or "")
|
||||
self.assertTrue(task_id.strip())
|
||||
task = self.store.openclaw_task_get(task_id=task_id, tenant_id=self.tenant_id)
|
||||
task = self.store.oclaw_task_get(task_id=task_id, tenant_id=self.tenant_id)
|
||||
self.assertIsNotNone(task)
|
||||
payload = json.loads(str(task.payload or "{}"))
|
||||
self.assertEqual(str(payload.get("interaction_mode") or ""), "expert")
|
||||
|
|
|
|||
|
|
@ -68,13 +68,13 @@ class AdminChatWikiEventsApiTests(unittest.TestCase):
|
|||
|
||||
def test_wiki_events_endpoint_returns_finished_wiki_capture_tasks(self) -> None:
|
||||
token = self._login()
|
||||
task = self.store.openclaw_task_create(
|
||||
task = self.store.oclaw_task_create(
|
||||
tenant_id=self.tenant_id,
|
||||
session_id=str(self.session_id),
|
||||
task_type="wiki_capture",
|
||||
payload={"kind": "captureAfterTurn", "session_id": str(self.session_id)},
|
||||
)
|
||||
self.assertTrue(self.store.openclaw_task_finish(task_id=task.id, result={"ok": True, "dedupMerge": {"merged_count": 1, "skipped_dup": 0}}))
|
||||
self.assertTrue(self.store.oclaw_task_finish(task_id=task.id, result={"ok": True, "dedupMerge": {"merged_count": 1, "skipped_dup": 0}}))
|
||||
headers = {"authorization": f"Bearer {token}", "accept": "application/json"}
|
||||
resp = self.client.get(
|
||||
f"/admin/api/chat/sessions/{self.session_id}/wiki-events?limit=10",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from fastapi.testclient import TestClient
|
|||
|
||||
from oclaw.interfaces.http.fastapi_app import create_app
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.exposure_plan import build_llm_tools_plan
|
||||
from oclaw.runtime.tools.exposure_plan import build_llm_tools_plan
|
||||
|
||||
|
||||
class AdminLLMPreviewPlannerConsistencyTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from oclaw.interfaces.http.fastapi_app import create_app
|
|||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
class AdminOpenClawRunsApiTests(unittest.TestCase):
|
||||
class AdminOclawRunsApiTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self._tmp = tempfile.TemporaryDirectory(ignore_cleanup_errors=True)
|
||||
self.db = Path(self._tmp.name) / "ops.sqlite"
|
||||
|
|
@ -35,14 +35,14 @@ class AdminOpenClawRunsApiTests(unittest.TestCase):
|
|||
tenant_id=self.tenant_id,
|
||||
user_id=self.user_id,
|
||||
).id
|
||||
self.store.openclaw_run_upsert(
|
||||
self.store.oclaw_run_upsert(
|
||||
run_id="run-1",
|
||||
tenant_id=self.tenant_id,
|
||||
session_id=self.session_id,
|
||||
status="failed",
|
||||
payload={"stop_reason": "non_retryable_error"},
|
||||
)
|
||||
self.store.openclaw_attempt_append(
|
||||
self.store.oclaw_attempt_append(
|
||||
run_id="run-1",
|
||||
tenant_id=self.tenant_id,
|
||||
session_id=self.session_id,
|
||||
|
|
@ -69,7 +69,7 @@ class AdminOpenClawRunsApiTests(unittest.TestCase):
|
|||
def test_runs_list_and_get(self) -> None:
|
||||
token = self._login()
|
||||
headers = {"authorization": f"Bearer {token}"}
|
||||
r1 = self.client.get(f"/admin/api/openclaw/runs?session_id={self.session_id}&include_attempts=1", headers=headers)
|
||||
r1 = self.client.get(f"/admin/api/oclaw/runs?session_id={self.session_id}&include_attempts=1", headers=headers)
|
||||
self.assertEqual(r1.status_code, 200)
|
||||
b1 = r1.json()
|
||||
self.assertTrue(b1.get("ok"))
|
||||
|
|
@ -79,7 +79,7 @@ class AdminOpenClawRunsApiTests(unittest.TestCase):
|
|||
self.assertEqual(str(rows[0].get("run_id") or ""), "run-1")
|
||||
self.assertTrue(isinstance(rows[0].get("attempts"), list))
|
||||
|
||||
r2 = self.client.get("/admin/api/openclaw/runs?run_id=run-1&include_attempts=1", headers=headers)
|
||||
r2 = self.client.get("/admin/api/oclaw/runs?run_id=run-1&include_attempts=1", headers=headers)
|
||||
self.assertEqual(r2.status_code, 200)
|
||||
b2 = r2.json()
|
||||
self.assertTrue(b2.get("ok"))
|
||||
|
|
@ -12,7 +12,7 @@ from oclaw.interfaces.http.fastapi_app import create_app
|
|||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
class AdminOpenClawTasksApiTests(unittest.TestCase):
|
||||
class AdminOclawTasksApiTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self._tmp = tempfile.TemporaryDirectory(ignore_cleanup_errors=True)
|
||||
self.db = Path(self._tmp.name) / "ops.sqlite"
|
||||
|
|
@ -35,7 +35,7 @@ class AdminOpenClawTasksApiTests(unittest.TestCase):
|
|||
tenant_id=self.tenant_id,
|
||||
user_id=self.user_id,
|
||||
).id
|
||||
self.task_a = self.store.openclaw_task_create(
|
||||
self.task_a = self.store.oclaw_task_create(
|
||||
tenant_id=self.tenant_id,
|
||||
session_id=self.session_a,
|
||||
payload={"text": "hello"},
|
||||
|
|
@ -56,7 +56,7 @@ class AdminOpenClawTasksApiTests(unittest.TestCase):
|
|||
tenant_id=other_tenant,
|
||||
user_id=str(other_user["id"]),
|
||||
).id
|
||||
self.store.openclaw_task_create(tenant_id=other_tenant, session_id=other_session, payload={"text": "secret"})
|
||||
self.store.oclaw_task_create(tenant_id=other_tenant, session_id=other_session, payload={"text": "secret"})
|
||||
|
||||
self.client = TestClient(create_app())
|
||||
self.client.post("/admin/api/auth/bootstrap", json={})
|
||||
|
|
@ -78,10 +78,10 @@ class AdminOpenClawTasksApiTests(unittest.TestCase):
|
|||
self.assertTrue(data.get("ok"), data)
|
||||
return str(data.get("token") or "")
|
||||
|
||||
def test_openclaw_tasks_api_lists_only_current_tenant(self) -> None:
|
||||
def test_oclaw_tasks_api_lists_only_current_tenant(self) -> None:
|
||||
token = self._login()
|
||||
headers = {"authorization": f"Bearer {token}"}
|
||||
r = self.client.get("/admin/api/openclaw/tasks?limit=50", headers=headers)
|
||||
r = self.client.get("/admin/api/oclaw/tasks?limit=50", headers=headers)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
body = r.json()
|
||||
self.assertTrue(body.get("ok"))
|
||||
|
|
@ -90,10 +90,10 @@ class AdminOpenClawTasksApiTests(unittest.TestCase):
|
|||
self.assertTrue(all(str(x.get("tenant_id") or "") == self.tenant_id for x in tasks))
|
||||
self.assertTrue(any(str(x.get("id") or "") == self.task_a.id for x in tasks))
|
||||
|
||||
def test_openclaw_task_get_by_id(self) -> None:
|
||||
def test_oclaw_task_get_by_id(self) -> None:
|
||||
token = self._login()
|
||||
headers = {"authorization": f"Bearer {token}"}
|
||||
r = self.client.get(f"/admin/api/openclaw/tasks?task_id={self.task_a.id}", headers=headers)
|
||||
r = self.client.get(f"/admin/api/oclaw/tasks?task_id={self.task_a.id}", headers=headers)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
body = r.json()
|
||||
self.assertTrue(body.get("ok"))
|
||||
|
|
@ -12,7 +12,7 @@ from oclaw.interfaces.http.fastapi_app import create_app
|
|||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
||||
class AdminToolPolicyOclawRetryCodesTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self._tmp = tempfile.TemporaryDirectory(ignore_cleanup_errors=True)
|
||||
self.db = Path(self._tmp.name) / "ops.sqlite"
|
||||
|
|
@ -44,15 +44,15 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
self.assertTrue(body.get("ok"), body)
|
||||
return str(body.get("token") or "")
|
||||
|
||||
def test_tool_policy_get_and_save_openclaw_retry_codes(self) -> None:
|
||||
def test_tool_policy_get_and_save_oclaw_retry_codes(self) -> None:
|
||||
token = self._login()
|
||||
headers = {"authorization": f"Bearer {token}"}
|
||||
r1 = self.client.get("/admin/api/tool-policy", headers=headers)
|
||||
self.assertEqual(r1.status_code, 200)
|
||||
b1 = r1.json()
|
||||
self.assertTrue(b1.get("ok"))
|
||||
self.assertTrue(str(b1.get("openclaw_retryable_error_codes") or "").strip())
|
||||
self.assertFalse(bool(b1.get("openclaw_retry_codes_strict_mode")))
|
||||
self.assertTrue(str(b1.get("oclaw_retryable_error_codes") or "").strip())
|
||||
self.assertFalse(bool(b1.get("oclaw_retry_codes_strict_mode")))
|
||||
|
||||
payload = {
|
||||
"turn_max_tool_workers": 8,
|
||||
|
|
@ -65,8 +65,8 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
"tool_llm_message_max_chars": 0,
|
||||
"mcp_filesystem_extra_roots": "",
|
||||
"mcp_env_allowlist": "",
|
||||
"openclaw_retryable_error_codes": "provider_timeout, context_overflow",
|
||||
"openclaw_retry_codes_strict_mode": False,
|
||||
"oclaw_retryable_error_codes": "provider_timeout, context_overflow",
|
||||
"oclaw_retry_codes_strict_mode": False,
|
||||
"wecom_longconn_workers": 2,
|
||||
"wecom_longconn_inbound_queue_maxsize": 200,
|
||||
}
|
||||
|
|
@ -74,8 +74,8 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
self.assertEqual(r2.status_code, 200)
|
||||
b2 = r2.json()
|
||||
self.assertTrue(b2.get("ok"))
|
||||
self.assertEqual(str(b2.get("openclaw_retryable_error_codes") or ""), "provider_timeout,context_overflow")
|
||||
self.assertFalse(bool(b2.get("openclaw_retry_codes_strict_mode")))
|
||||
self.assertEqual(str(b2.get("oclaw_retryable_error_codes") or ""), "provider_timeout,context_overflow")
|
||||
self.assertFalse(bool(b2.get("oclaw_retry_codes_strict_mode")))
|
||||
self.assertEqual(list(b2.get("unknown_retryable_error_codes") or []), [])
|
||||
|
||||
def test_tool_policy_retry_codes_unknown_filtered(self) -> None:
|
||||
|
|
@ -92,8 +92,8 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
"tool_llm_message_max_chars": 0,
|
||||
"mcp_filesystem_extra_roots": "",
|
||||
"mcp_env_allowlist": "",
|
||||
"openclaw_retryable_error_codes": "provider_timeout, typo_code_x, context_overflow",
|
||||
"openclaw_retry_codes_strict_mode": False,
|
||||
"oclaw_retryable_error_codes": "provider_timeout, typo_code_x, context_overflow",
|
||||
"oclaw_retry_codes_strict_mode": False,
|
||||
"wecom_longconn_workers": 2,
|
||||
"wecom_longconn_inbound_queue_maxsize": 200,
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
self.assertEqual(r.status_code, 200)
|
||||
b = r.json()
|
||||
self.assertTrue(b.get("ok"))
|
||||
self.assertEqual(str(b.get("openclaw_retryable_error_codes") or ""), "provider_timeout,context_overflow")
|
||||
self.assertEqual(str(b.get("oclaw_retryable_error_codes") or ""), "provider_timeout,context_overflow")
|
||||
self.assertEqual(list(b.get("unknown_retryable_error_codes") or []), ["typo_code_x"])
|
||||
|
||||
def test_tool_policy_retry_codes_unknown_rejected_in_strict_mode(self) -> None:
|
||||
|
|
@ -118,8 +118,8 @@ class AdminToolPolicyOpenClawRetryCodesTests(unittest.TestCase):
|
|||
"tool_llm_message_max_chars": 0,
|
||||
"mcp_filesystem_extra_roots": "",
|
||||
"mcp_env_allowlist": "",
|
||||
"openclaw_retryable_error_codes": "provider_timeout, typo_code_x",
|
||||
"openclaw_retry_codes_strict_mode": True,
|
||||
"oclaw_retryable_error_codes": "provider_timeout, typo_code_x",
|
||||
"oclaw_retry_codes_strict_mode": True,
|
||||
"wecom_longconn_workers": 2,
|
||||
"wecom_longconn_inbound_queue_maxsize": 200,
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
|||
|
||||
from unittest.mock import patch
|
||||
|
||||
from oclaw.tools.base import ToolSpec
|
||||
from oclaw.tools.catalog import materialize_tool_specs
|
||||
from oclaw.runtime.tools.base import ToolSpec
|
||||
from oclaw.runtime.tools.catalog import materialize_tool_specs
|
||||
|
||||
|
||||
def _mk_spec(name: str) -> ToolSpec:
|
||||
|
|
@ -18,10 +18,10 @@ def _mk_spec(name: str) -> ToolSpec:
|
|||
|
||||
def test_catalog_loads_role_scoped_expert_tools() -> None:
|
||||
with patch(
|
||||
"oclaw.tools.catalog.materialize_tools_for_expert",
|
||||
"oclaw.runtime.tools.catalog.materialize_tools_for_expert",
|
||||
return_value=[_mk_spec("custom_tool_a"), _mk_spec("custom_tool_b")],
|
||||
):
|
||||
with patch("oclaw.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
||||
with patch("oclaw.runtime.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
||||
specs = materialize_tool_specs(expert="generalist")
|
||||
names = {x.name for x in specs}
|
||||
assert "system_time" in names
|
||||
|
|
@ -31,10 +31,10 @@ def test_catalog_loads_role_scoped_expert_tools() -> None:
|
|||
|
||||
def test_catalog_deduplicates_same_tool_name() -> None:
|
||||
with patch(
|
||||
"oclaw.tools.catalog.materialize_tools_for_expert",
|
||||
"oclaw.runtime.tools.catalog.materialize_tools_for_expert",
|
||||
return_value=[_mk_spec("system_time"), _mk_spec("custom_tool_a")],
|
||||
):
|
||||
with patch("oclaw.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
||||
with patch("oclaw.runtime.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
||||
specs = materialize_tool_specs(expert="generalist")
|
||||
names = [x.name for x in specs]
|
||||
assert names.count("system_time") == 1
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.catalog import materialize_tool_specs
|
||||
from oclaw.runtime.tools.catalog import materialize_tool_specs
|
||||
|
||||
|
||||
def _seed_single_mcp_tool(store: SqliteStore) -> None:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.tools.skills import clawhub_client
|
||||
from oclaw.runtime.tools.skills import clawhub_client
|
||||
|
||||
|
||||
def test_get_skill_detail_handles_latest_version_object(monkeypatch) -> None:
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ from oclaw.prompts.frontmatter import parse_frontmatter_dict, parse_markdown_doc
|
|||
|
||||
def test_parse_yaml_frontmatter_nested_metadata() -> None:
|
||||
fm = parse_frontmatter_dict(
|
||||
"name: demo\ndescription: x\nmetadata:\n openclaw:\n install:\n - id: i1\n kind: node\n",
|
||||
"name: demo\ndescription: x\nmetadata:\n oclaw:\n install:\n - id: i1\n kind: node\n",
|
||||
source="test",
|
||||
)
|
||||
assert fm.get("name") == "demo"
|
||||
md = fm.get("metadata")
|
||||
assert isinstance(md, dict)
|
||||
assert isinstance(md.get("openclaw"), dict)
|
||||
assert isinstance(md.get("oclaw"), dict)
|
||||
|
||||
|
||||
def test_parse_markdown_document_roundtrip() -> None:
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ from __future__ import annotations
|
|||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.gateway.server_plugins import load_gateway_plugins
|
||||
from oclaw.interfaces.gateway.server_plugins import load_gateway_plugins
|
||||
|
||||
|
||||
def _load_image_core_generate_image():
|
||||
file_path = (Path(__file__).resolve().parents[1] / "extensions" / "image-generation-core" / "api.py").resolve()
|
||||
file_path = (Path(__file__).resolve().parents[1] / "runtime" / "extensions" / "image-generation-core" / "api.py").resolve()
|
||||
spec = importlib.util.spec_from_file_location("test_image_generation_core_api", str(file_path))
|
||||
if spec is None or spec.loader is None:
|
||||
raise RuntimeError("failed to load image-generation-core api module")
|
||||
|
|
|
|||
|
|
@ -2,36 +2,36 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from oclaw.gateway.server_methods.agent import agent_handlers
|
||||
from oclaw.gateway.server_methods.agents import agents_handlers
|
||||
from oclaw.gateway.server_methods.chat import chat_handlers
|
||||
from oclaw.gateway.server_methods.send import send_handlers
|
||||
from oclaw.gateway.server_methods.image import image_handlers
|
||||
from oclaw.gateway.server_methods.skills import skills_handlers
|
||||
from oclaw.gateway.server_methods.system import system_handlers
|
||||
from oclaw.gateway.server_methods.cron import cron_handlers
|
||||
from oclaw.gateway.server_methods.devices import device_handlers
|
||||
from oclaw.gateway.server_methods.models import models_handlers
|
||||
from oclaw.gateway.server_methods.models_auth_status import (
|
||||
from oclaw.interfaces.gateway.server_methods.agent import agent_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.agents import agents_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.chat import chat_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.send import send_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.image import image_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.skills import skills_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.system import system_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.cron import cron_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.devices import device_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.models import models_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.models_auth_status import (
|
||||
invalidate_model_auth_status_cache,
|
||||
models_auth_status_handlers,
|
||||
)
|
||||
from oclaw.gateway.server_methods.push import push_handlers
|
||||
from oclaw.gateway.server_methods.channels import channels_handlers
|
||||
from oclaw.gateway.server_methods.update import update_handlers
|
||||
from oclaw.gateway.server_methods.voicewake import voicewake_handlers
|
||||
from oclaw.gateway.server_methods.wizard import wizard_handlers
|
||||
from oclaw.gateway.server_methods.tts import tts_handlers
|
||||
from oclaw.gateway.server_methods.web import web_handlers
|
||||
from oclaw.gateway.server_methods.tools_catalog import tools_catalog_handlers
|
||||
from oclaw.gateway.server_methods.tools_effective import tools_effective_handlers
|
||||
from oclaw.gateway.server_methods.talk import talk_handlers
|
||||
from oclaw.gateway.server_methods.usage import usage_handlers
|
||||
from oclaw.gateway.server_methods.exec_approvals import exec_approvals_handlers
|
||||
from oclaw.gateway.server_methods.nodes_pending import node_pending_handlers
|
||||
from oclaw.gateway.server_methods.nodes import node_handlers
|
||||
from oclaw.gateway.server_methods.sessions import sessions_handlers
|
||||
from oclaw.gateway.server_methods.doctor import doctor_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.push import push_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.channels import channels_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.update import update_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.voicewake import voicewake_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.wizard import wizard_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.tts import tts_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.web import web_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.tools_catalog import tools_catalog_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.tools_effective import tools_effective_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.talk import talk_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.usage import usage_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.exec_approvals import exec_approvals_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.nodes_pending import node_pending_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.nodes import node_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.sessions import sessions_handlers
|
||||
from oclaw.interfaces.gateway.server_methods.doctor import doctor_handlers
|
||||
|
||||
|
||||
def _call(handler, *, params: dict[str, Any], context: dict[str, Any] | None = None, client: dict[str, Any] | None = None):
|
||||
|
|
@ -271,7 +271,7 @@ def test_skills_status_requires_store_then_lists_skills() -> None:
|
|||
assert ok["ok"] is True
|
||||
payload = ok["payload"] or {}
|
||||
assert isinstance(payload.get("skills"), list)
|
||||
# Repo ships oclaw/skills/{main,coding,social}
|
||||
# Repo ships oclaw/runtime/skills/{main,coding,social}
|
||||
names = {str(x.get("name")) for x in payload["skills"] if isinstance(x, dict)}
|
||||
assert "main" in names
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ def test_cron_add_and_run_fallback() -> None:
|
|||
|
||||
def test_image_generate_falls_back_to_registered_openai_provider() -> None:
|
||||
# Get providers via plugin load, then inject into gateway context.
|
||||
from oclaw.gateway.server_plugins import load_gateway_plugins
|
||||
from oclaw.interfaces.gateway.server_plugins import load_gateway_plugins
|
||||
|
||||
plugin_out = load_gateway_plugins(
|
||||
cfg={"plugins": {"enabled": ["openai"]}},
|
||||
|
|
@ -532,9 +532,9 @@ def test_voicewake_set_requires_triggers_array() -> None:
|
|||
bad = _call(voicewake_handlers["voicewake.set"], params={"triggers": "hey"})
|
||||
assert bad["ok"] is False
|
||||
assert bad["error"]["code"] == "INVALID_REQUEST"
|
||||
ok = _call(voicewake_handlers["voicewake.set"], params={"triggers": ["Hey OpenClaw", " ", "hey openclaw"]})
|
||||
ok = _call(voicewake_handlers["voicewake.set"], params={"triggers": ["Hey Oclaw", " ", "hey oclaw"]})
|
||||
assert ok["ok"] is True
|
||||
assert (ok["payload"] or {}).get("triggers") == ["Hey OpenClaw"]
|
||||
assert (ok["payload"] or {}).get("triggers") == ["Hey Oclaw"]
|
||||
|
||||
|
||||
def test_wizard_start_next_status_cancel_flow() -> None:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.gateway.server_methods.telegram_send_normalize import normalize_transport_target_for_channel
|
||||
from oclaw.interfaces.gateway.server_methods.telegram_send_normalize import normalize_transport_target_for_channel
|
||||
|
||||
|
||||
def test_normalize_transport_target_for_channel_non_telegram_passthrough() -> None:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.chat.agent_messages import build_llm_messages
|
||||
from oclaw.runtime.chat.agent_messages import build_llm_messages
|
||||
from oclaw.platform.llm.chat_models import RuleBasedChatModel
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import unittest
|
|||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.mcp.adapter import materialize_mcp_tools, materialize_mcp_tools_for_specialist
|
||||
from oclaw.runtime.tools.mcp.adapter import materialize_mcp_tools, materialize_mcp_tools_for_specialist
|
||||
|
||||
|
||||
class McpAdapterTests(unittest.TestCase):
|
||||
|
|
@ -147,7 +147,7 @@ class McpAdapterTests(unittest.TestCase):
|
|||
self.assertIn("mcp__echo-b__ping", names)
|
||||
|
||||
def test_mcp_local_env_file_path_prefers_src_local(self) -> None:
|
||||
from oclaw.ops import mcp_env
|
||||
from oclaw.runtime.operations import mcp_env
|
||||
|
||||
p = mcp_env.mcp_local_env_file_path()
|
||||
self.assertEqual(p.name, "mcp_local.env")
|
||||
|
|
@ -156,7 +156,7 @@ class McpAdapterTests(unittest.TestCase):
|
|||
self.assertIn("_local", parts)
|
||||
|
||||
def test_mcp_env_allowlist_keys_default_when_unset(self) -> None:
|
||||
from oclaw.ops import mcp_env
|
||||
from oclaw.runtime.operations import mcp_env
|
||||
|
||||
old = os.environ.pop("OPS_MCP_ENV_ALLOWLIST", None)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
|||
|
||||
import unittest
|
||||
|
||||
from oclaw.admin.mcp_e2e_probe import build_mcp_e2e_probe_plans, parse_mcp_bound_tool_name
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.interfaces.admin.mcp_e2e_probe import build_mcp_e2e_probe_plans, parse_mcp_bound_tool_name
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
class McpE2eProbeTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
from unittest import mock
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.mcp.filesystem_argv import augment_filesystem_mcp_argv, build_mcp_process_command
|
||||
from oclaw.runtime.tools.mcp.filesystem_argv import augment_filesystem_mcp_argv, build_mcp_process_command
|
||||
|
||||
|
||||
def _wincase_set(items: list[str]) -> set[str]:
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ from __future__ import annotations
|
|||
|
||||
import unittest
|
||||
|
||||
from oclaw.tools.mcp.installer import (
|
||||
from oclaw.runtime.tools.mcp.installer import (
|
||||
_safe_server_id,
|
||||
detect_local_dependencies,
|
||||
install_mcp_server,
|
||||
preflight_mcp_server,
|
||||
uninstall_mcp_server,
|
||||
)
|
||||
from oclaw.tools.mcp.manifest import McpServerManifest
|
||||
from oclaw.runtime.tools.mcp.manifest import McpServerManifest
|
||||
|
||||
|
||||
class McpInstallerTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ from __future__ import annotations
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from oclaw.tools.mcp.market import infer_install_template, search_mcp_market, trending_mcp_market
|
||||
from oclaw.runtime.tools.mcp.market import infer_install_template, search_mcp_market, trending_mcp_market
|
||||
|
||||
|
||||
class McpMarketTests(unittest.TestCase):
|
||||
@patch("oclaw.tools.mcp.market.search_github_repos")
|
||||
@patch("oclaw.tools.mcp.market.search_npm_packages")
|
||||
@patch("oclaw.tools.mcp.market.search_pypi_packages")
|
||||
@patch("oclaw.runtime.tools.mcp.market.search_github_repos")
|
||||
@patch("oclaw.runtime.tools.mcp.market.search_npm_packages")
|
||||
@patch("oclaw.runtime.tools.mcp.market.search_pypi_packages")
|
||||
def test_aggregate_results(self, pypi_mock, npm_mock, gh_mock) -> None:
|
||||
gh_mock.return_value = [{"source_type": "github", "name": "a"}]
|
||||
npm_mock.return_value = [{"source_type": "npm", "name": "b"}]
|
||||
|
|
@ -28,7 +28,7 @@ class McpMarketTests(unittest.TestCase):
|
|||
self.assertEqual(t2["entry_command"], "python")
|
||||
self.assertEqual(t2["entry_args"][:1], ["-m"])
|
||||
|
||||
@patch("oclaw.tools.mcp.market.search_mcp_market")
|
||||
@patch("oclaw.runtime.tools.mcp.market.search_mcp_market")
|
||||
def test_trending_cache(self, search_mock) -> None:
|
||||
search_mock.return_value = [{"source_type": "github", "name": "a", "stars": 9}]
|
||||
rows = trending_mcp_market(force_refresh=True, per_source_limit=2)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import unittest
|
|||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.mcp.manifest import McpServerManifest
|
||||
from oclaw.tools.mcp.registry import McpRegistry
|
||||
from oclaw.runtime.tools.mcp.manifest import McpServerManifest
|
||||
from oclaw.runtime.tools.mcp.registry import McpRegistry
|
||||
|
||||
|
||||
class McpRegistryTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import textwrap
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.tools.mcp.runtime import McpProcessRuntime
|
||||
from oclaw.runtime.tools.mcp.runtime import McpProcessRuntime
|
||||
|
||||
|
||||
class McpRuntimeTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.tools.mcp.adapter import materialize_mcp_skills_for_specialist
|
||||
from oclaw.runtime.tools.mcp.adapter import materialize_mcp_skills_for_specialist
|
||||
|
||||
|
||||
class _Store:
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ import tempfile
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.agents.network_ops_agent import NetworkOpsAgent
|
||||
from oclaw.runtime.agents.network_ops_agent import NetworkOpsAgent
|
||||
from oclaw.platform.llm.chat_models import RuleBasedChatModel
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.mcp.adapter import materialize_mcp_tools_for_specialist
|
||||
from oclaw.tools.mcp.filesystem_argv import build_mcp_process_command, collect_filesystem_mcp_extra_roots
|
||||
from oclaw.tools.mcp.runtime import McpProcessRuntime
|
||||
from oclaw.runtime.tools.mcp.adapter import materialize_mcp_tools_for_specialist
|
||||
from oclaw.runtime.tools.mcp.filesystem_argv import build_mcp_process_command, collect_filesystem_mcp_extra_roots
|
||||
from oclaw.runtime.tools.mcp.runtime import McpProcessRuntime
|
||||
|
||||
|
||||
class McpWorkspaceFilesystemE2ETests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import tempfile
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.orchestration.memory import maybe_write_turn_memory, semantic_retrieve
|
||||
from oclaw.runtime.orchestration.memory import maybe_write_turn_memory, semantic_retrieve
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ import os
|
|||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from oclaw.gateway.python_extensions_loader import build_python_extensions_registry
|
||||
from oclaw.gateway.server_plugins import load_gateway_plugins
|
||||
from oclaw.tools.catalog import materialize_tool_specs
|
||||
from oclaw.interfaces.gateway.python_extensions_loader import build_python_extensions_registry
|
||||
from oclaw.interfaces.gateway.server_plugins import load_gateway_plugins
|
||||
from oclaw.runtime.tools.catalog import materialize_tool_specs
|
||||
|
||||
|
||||
def _load_memory_wiki_api_module():
|
||||
p = Path("d:/project/chatgpt/oclaw/extensions/memory-wiki/api.py")
|
||||
p = Path("d:/project/chatgpt/oclaw/runtime/extensions/memory-wiki/api.py")
|
||||
module_name = "test_memory_wiki_api"
|
||||
spec = importlib.util.spec_from_file_location(module_name, str(p))
|
||||
assert spec is not None and spec.loader is not None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.openclaw_runtime.relay_pointer import build_acp_relay_result, validate_relay_share_envelope
|
||||
from oclaw.runtime.relay_pointer import build_acp_relay_result, validate_relay_share_envelope
|
||||
|
||||
|
||||
def test_validate_relay_share_envelope_ok() -> None:
|
||||
|
|
@ -2,12 +2,12 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.agent_core_run import AgentCoreRunInput, run_agent_core
|
||||
from oclaw.openclaw_runtime.gateway import OpenClawGateway
|
||||
from oclaw.openclaw_runtime.types import StandardMessage
|
||||
from oclaw.runtime.agent_core_run import AgentCoreRunInput, run_agent_core
|
||||
from oclaw.runtime.gateway import OclawGateway
|
||||
from oclaw.runtime.types import StandardMessage
|
||||
from oclaw.platform.llm.chat_models import LLMResponse, StaticTextChatModel
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.base import ToolRegistry
|
||||
from oclaw.runtime.tools.base import ToolRegistry
|
||||
|
||||
|
||||
class _FailOnceModel:
|
||||
|
|
@ -58,7 +58,7 @@ def test_agent_core_run_retries_then_succeeds(tmp_path: Path) -> None:
|
|||
assert out.run_state.attempts[0].status == "retry"
|
||||
assert out.run_state.attempts[1].status == "success"
|
||||
|
||||
rows = store.openclaw_attempt_list(run_id=out.run_state.run_id)
|
||||
rows = store.oclaw_attempt_list(run_id=out.run_state.run_id)
|
||||
assert len(rows) == 2
|
||||
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ def test_agent_core_relay_envelope_error_not_retryable(tmp_path: Path) -> None:
|
|||
def test_gateway_fail_closed_when_executor_missing_model_tools(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "b.sqlite"))
|
||||
sess = store.create_session("t")
|
||||
gw = OpenClawGateway(store=store)
|
||||
gw = OclawGateway(store=store)
|
||||
|
||||
class _BadExecutor:
|
||||
pass
|
||||
|
|
@ -4,11 +4,11 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from oclaw.openclaw_runtime.agent_core_run import AgentCoreRunInput, run_agent_core
|
||||
from oclaw.openclaw_runtime.types import StandardMessage
|
||||
from oclaw.runtime.agent_core_run import AgentCoreRunInput, run_agent_core
|
||||
from oclaw.runtime.types import StandardMessage
|
||||
from oclaw.platform.llm.chat_models import StaticTextChatModel
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.base import ToolRegistry
|
||||
from oclaw.runtime.tools.base import ToolRegistry
|
||||
|
||||
|
||||
def _msg(session_id: str, *, metadata: dict | None = None) -> StandardMessage:
|
||||
|
|
@ -48,21 +48,21 @@ def test_agent_core_run_started_trace_payload_keys(tmp_path: Path, monkeypatch:
|
|||
trace_id=trace_id,
|
||||
parent_span_id=None,
|
||||
max_attempts=1,
|
||||
openclaw_task_id="task-99",
|
||||
openclaw_worker_id="worker-zz",
|
||||
oclaw_task_id="task-99",
|
||||
oclaw_worker_id="worker-zz",
|
||||
),
|
||||
)
|
||||
|
||||
started = [e for e in events if e.get("event_type") == "run_started"]
|
||||
assert started, events
|
||||
pl = started[0].get("payload") or {}
|
||||
assert pl.get("pipeline") == "openclaw_agent_core"
|
||||
assert pl.get("pipeline") == "oclaw_agent_core"
|
||||
assert pl.get("oc_stage") == "run_start"
|
||||
assert pl.get("trace_id") == trace_id
|
||||
assert pl.get("lang") == "zh"
|
||||
assert "run_id" in pl
|
||||
assert pl.get("openclaw_task_id") == "task-99"
|
||||
assert pl.get("openclaw_worker_id") == "worker-zz"
|
||||
assert pl.get("oclaw_task_id") == "task-99"
|
||||
assert pl.get("oclaw_worker_id") == "worker-zz"
|
||||
assert pl.get("relay_envelope_present") is False
|
||||
assert pl.get("relay_envelope_pointer_count") == 0
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.openclaw_runtime.command_parser import parse_internal_command
|
||||
from oclaw.runtime.command_parser import parse_internal_command
|
||||
|
||||
|
||||
def test_parse_internal_command_basic() -> None:
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.tools.base import ToolSpec
|
||||
from oclaw.tools.catalog import _apply_declared_tool_policy
|
||||
from oclaw.runtime.tools.base import ToolSpec
|
||||
from oclaw.runtime.tools.catalog import _apply_declared_tool_policy
|
||||
|
||||
|
||||
def _tool(name: str, tags: set[str]) -> ToolSpec:
|
||||
|
|
@ -17,7 +17,7 @@ def _load_module(module_name: str, path: Path):
|
|||
|
||||
|
||||
def _mount_webhooks_package():
|
||||
root = Path(__file__).resolve().parents[1] / "extensions" / "webhooks"
|
||||
root = Path(__file__).resolve().parents[1] / "runtime" / "extensions" / "webhooks"
|
||||
pkg_root = types.ModuleType("ocx")
|
||||
pkg_root.__path__ = [str(root.parent)]
|
||||
sys.modules["ocx"] = pkg_root
|
||||
|
|
@ -150,7 +150,7 @@ def test_webhooks_handler_auth_and_actions() -> None:
|
|||
missing = handler(
|
||||
{
|
||||
"path": "/hooks/a",
|
||||
"headers": {"x-openclaw-webhook-secret": "sekret"},
|
||||
"headers": {"x-oclaw-webhook-secret": "sekret"},
|
||||
"json": {"action": "request_cancel", "flowId": "missing", "expectedRevision": 1},
|
||||
}
|
||||
)
|
||||
|
|
@ -17,7 +17,7 @@ def _load_module(module_name: str, path: Path):
|
|||
|
||||
|
||||
def _mount_whatsapp_module():
|
||||
root = Path(__file__).resolve().parents[1] / "extensions" / "whatsapp"
|
||||
root = Path(__file__).resolve().parents[1] / "runtime" / "extensions" / "whatsapp"
|
||||
pkg_root = types.ModuleType("ocxw")
|
||||
pkg_root.__path__ = [str(root.parent)]
|
||||
sys.modules["ocxw"] = pkg_root
|
||||
|
|
@ -16,7 +16,7 @@ def test_wait_for_agent_job_is_non_blocking_pending(monkeypatch) -> None:
|
|||
return False
|
||||
|
||||
class DummyStore:
|
||||
def openclaw_run_get(self, run_id: str) -> None:
|
||||
def oclaw_run_get(self, run_id: str) -> None:
|
||||
return None
|
||||
|
||||
def get_messages(self, session_id: str, limit: int) -> list[Any]:
|
||||
|
|
@ -100,7 +100,7 @@ def test_turn_runner_emits_delta_only(monkeypatch) -> None:
|
|||
|
||||
monkeypatch.setattr(turn_runner, "SqliteStore", lambda _p: DummyStore())
|
||||
monkeypatch.setattr(turn_runner, "db_path", lambda: "dummy.sqlite")
|
||||
monkeypatch.setattr(turn_runner, "OpenClawGateway", lambda store: DummyGateway())
|
||||
monkeypatch.setattr(turn_runner, "OclawGateway", lambda store: DummyGateway())
|
||||
monkeypatch.setattr(turn_runner, "build_gateway_executor", lambda *a, **k: object())
|
||||
|
||||
conn = DummyConn()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import json
|
|||
import pytest
|
||||
|
||||
from oclaw.platform.llm.chat_models import LLMResponse
|
||||
from oclaw.openclaw_runtime.gateway import OpenClawGateway
|
||||
from oclaw.openclaw_runtime.types import StandardMessage
|
||||
from oclaw.runtime.gateway import OclawGateway
|
||||
from oclaw.runtime.types import StandardMessage
|
||||
|
||||
|
||||
def test_gateway_async_trace_payload_has_pipeline_and_oc_stage(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
|
|
@ -18,7 +18,7 @@ def test_gateway_async_trace_payload_has_pipeline_and_oc_stage(monkeypatch: pyte
|
|||
def add_trace_event(self, **kwargs: object) -> None:
|
||||
events.append(dict(kwargs))
|
||||
|
||||
def openclaw_task_create(self, **_kwargs: object) -> object:
|
||||
def oclaw_task_create(self, **_kwargs: object) -> object:
|
||||
class T:
|
||||
id = "task-1"
|
||||
task_type = "async_turn"
|
||||
|
|
@ -26,9 +26,9 @@ def test_gateway_async_trace_payload_has_pipeline_and_oc_stage(monkeypatch: pyte
|
|||
|
||||
return T()
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-1",
|
||||
tenant_id="t1",
|
||||
|
|
@ -44,7 +44,7 @@ def test_gateway_async_trace_payload_has_pipeline_and_oc_stage(monkeypatch: pyte
|
|||
sent = [e for e in events if e.get("event_type") == "response_sent"]
|
||||
assert sent
|
||||
payload = sent[-1].get("payload") or {}
|
||||
assert payload.get("pipeline") == "openclaw_gateway"
|
||||
assert payload.get("pipeline") == "oclaw_gateway"
|
||||
assert payload.get("oc_stage") == "response"
|
||||
assert "elapsed_ms_since_gateway_start" in payload
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ def test_gateway_received_trace_includes_relay_pointer_stats(monkeypatch: pytest
|
|||
def add_trace_event(self, **kwargs: object) -> None:
|
||||
events.append(dict(kwargs))
|
||||
|
||||
def openclaw_task_create(self, **_kwargs: object) -> object:
|
||||
def oclaw_task_create(self, **_kwargs: object) -> object:
|
||||
class T:
|
||||
id = "task-2"
|
||||
task_type = "async_turn"
|
||||
|
|
@ -67,9 +67,9 @@ def test_gateway_received_trace_includes_relay_pointer_stats(monkeypatch: pytest
|
|||
|
||||
return T()
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-2",
|
||||
tenant_id="t1",
|
||||
|
|
@ -104,7 +104,7 @@ def test_gateway_async_task_payload_preserves_relay_envelope(monkeypatch: pytest
|
|||
def add_trace_event(self, **_kwargs: object) -> None:
|
||||
return None
|
||||
|
||||
def openclaw_task_create(self, **kwargs: object) -> object:
|
||||
def oclaw_task_create(self, **kwargs: object) -> object:
|
||||
captured.update(kwargs)
|
||||
|
||||
class T:
|
||||
|
|
@ -114,8 +114,8 @@ def test_gateway_async_task_payload_preserves_relay_envelope(monkeypatch: pytest
|
|||
|
||||
return T()
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
gw = OpenClawGateway(store=Store())
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-3",
|
||||
tenant_id="t1",
|
||||
|
|
@ -150,7 +150,7 @@ def test_gateway_async_task_payload_preserves_acp_ids(monkeypatch: pytest.Monkey
|
|||
def add_trace_event(self, **_kwargs: object) -> None:
|
||||
return None
|
||||
|
||||
def openclaw_task_create(self, **kwargs: object) -> object:
|
||||
def oclaw_task_create(self, **kwargs: object) -> object:
|
||||
captured.update(kwargs)
|
||||
|
||||
class T:
|
||||
|
|
@ -160,8 +160,8 @@ def test_gateway_async_task_payload_preserves_acp_ids(monkeypatch: pytest.Monkey
|
|||
|
||||
return T()
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
gw = OpenClawGateway(store=Store())
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-4",
|
||||
tenant_id="t1",
|
||||
|
|
@ -196,7 +196,7 @@ def test_gateway_expert_mode_uses_requested_specialist() -> None:
|
|||
chosen["sid"] = sid
|
||||
return _Exec()
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-e1",
|
||||
tenant_id="t1",
|
||||
|
|
@ -236,7 +236,7 @@ def test_gateway_comprehensive_mode_manager_first_selects_specialist(monkeypatch
|
|||
chosen["sid"] = sid
|
||||
return _Exec()
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-c1",
|
||||
tenant_id="t1",
|
||||
|
|
@ -276,9 +276,9 @@ def test_gateway_comprehensive_mode_dynamic_agent_fallback_success(monkeypatch:
|
|||
self.model = model
|
||||
self.tools = None
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.build_ephemeral_executor", lambda *args, **kwargs: _Exec())
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.build_ephemeral_executor", lambda *args, **kwargs: _Exec())
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-d1",
|
||||
tenant_id="t1",
|
||||
|
|
@ -323,7 +323,7 @@ def test_gateway_comprehensive_mode_dynamic_agent_invalid_falls_back_generalist(
|
|||
picked["sid"] = sid
|
||||
return _Exec()
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-d2",
|
||||
tenant_id="t1",
|
||||
|
|
@ -350,7 +350,7 @@ def test_gateway_command_hook_uses_parsed_command_and_context(monkeypatch: pytes
|
|||
def add_trace_event(self, **_kwargs: object) -> None:
|
||||
return None
|
||||
|
||||
def openclaw_task_create(self, **_kwargs: object) -> object:
|
||||
def oclaw_task_create(self, **_kwargs: object) -> object:
|
||||
class T:
|
||||
id = "task-cmd-1"
|
||||
task_type = "async_turn"
|
||||
|
|
@ -358,19 +358,19 @@ def test_gateway_command_hook_uses_parsed_command_and_context(monkeypatch: pytes
|
|||
|
||||
return T()
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.initialize_hooks_runtime", lambda **kwargs: 0)
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.ensure_worker_started", lambda store: "worker-1")
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.initialize_hooks_runtime", lambda **kwargs: 0)
|
||||
monkeypatch.setattr(
|
||||
"oclaw.openclaw_runtime.gateway.get_active_hooks_config",
|
||||
"oclaw.runtime.gateway.get_active_hooks_config",
|
||||
lambda: {"hooks": {"internal": {"enabled": True, "entries": {"session-memory": {"messages": 33}}}}},
|
||||
)
|
||||
|
||||
def _capture(**kwargs):
|
||||
calls.append(dict(kwargs))
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.gateway.trigger_hook_event", _capture)
|
||||
monkeypatch.setattr("oclaw.runtime.gateway.trigger_hook_event", _capture)
|
||||
|
||||
gw = OpenClawGateway(store=Store())
|
||||
gw = OclawGateway(store=Store())
|
||||
msg = StandardMessage(
|
||||
session_id="sid-cmd-1",
|
||||
tenant_id="t1",
|
||||
|
|
@ -420,8 +420,8 @@ def test_tabular_system_hint_uses_configured_preview_and_rows_read(
|
|||
cfg_path.write_text(json.dumps(cfg, ensure_ascii=False), encoding="utf-8")
|
||||
monkeypatch.setenv("AIA_OCLAW_CONFIG_PATH", str(cfg_path))
|
||||
|
||||
zh_hint = OpenClawGateway._tabular_query_system_hint("zh")
|
||||
en_hint = OpenClawGateway._tabular_query_system_hint("en")
|
||||
zh_hint = OclawGateway._tabular_query_system_hint("zh")
|
||||
en_hint = OclawGateway._tabular_query_system_hint("en")
|
||||
|
||||
assert "前30行" in zh_hint
|
||||
assert "5000行" in zh_hint
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.agents.factory import build_gateway_executor
|
||||
from oclaw.runtime.agents.factory import build_gateway_executor
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
|
|
@ -3,28 +3,28 @@ from __future__ import annotations
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.hooks_runtime import resolve_runtime_config
|
||||
from oclaw.runtime.hooks_runtime import resolve_runtime_config
|
||||
|
||||
|
||||
def test_resolve_runtime_config_from_env_json(monkeypatch) -> None:
|
||||
monkeypatch.setenv(
|
||||
"OPENCLAW_RUNTIME_CONFIG_JSON",
|
||||
"OCLAW_RUNTIME_CONFIG_JSON",
|
||||
json.dumps({"hooks": {"internal": {"enabled": False, "entries": {"x": {"enabled": False}}}}}),
|
||||
)
|
||||
monkeypatch.delenv("OPENCLAW_CONFIG_PATH", raising=False)
|
||||
monkeypatch.delenv("OCLAW_CONFIG_PATH", raising=False)
|
||||
cfg = resolve_runtime_config()
|
||||
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("enabled") is False
|
||||
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("entries", {}).get("x", {}).get("enabled") is False
|
||||
|
||||
|
||||
def test_resolve_runtime_config_from_config_path(monkeypatch, tmp_path: Path) -> None:
|
||||
cfg_path = tmp_path / "openclaw.custom.json"
|
||||
cfg_path = tmp_path / "oclaw.custom.json"
|
||||
cfg_path.write_text(
|
||||
json.dumps({"hooks": {"internal": {"enabled": True, "entries": {"session-memory": {"messages": 99}}}}}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.delenv("OPENCLAW_RUNTIME_CONFIG_JSON", raising=False)
|
||||
monkeypatch.setenv("OPENCLAW_CONFIG_PATH", str(cfg_path))
|
||||
monkeypatch.delenv("OCLAW_RUNTIME_CONFIG_JSON", raising=False)
|
||||
monkeypatch.setenv("OCLAW_CONFIG_PATH", str(cfg_path))
|
||||
cfg = resolve_runtime_config()
|
||||
assert ((cfg.get("hooks") or {}).get("internal") or {}).get("enabled") is True
|
||||
assert (
|
||||
|
|
@ -4,14 +4,14 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from oclaw.openclaw_runtime.memory_stage import after_turn_memory, render_memory_context_block
|
||||
from oclaw.openclaw_runtime.types import OpenClawMemoryContext
|
||||
from oclaw.runtime.memory_stage import after_turn_memory, render_memory_context_block
|
||||
from oclaw.runtime.types import OclawMemoryContext
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
def test_render_memory_context_block_contains_sections() -> None:
|
||||
text = render_memory_context_block(
|
||||
OpenClawMemoryContext(
|
||||
OclawMemoryContext(
|
||||
short_term=("user prefers concise summary",),
|
||||
semantic_hits=({"content": "meeting summary style: bullets only", "score": 0.77},),
|
||||
)
|
||||
|
|
@ -28,7 +28,7 @@ def test_after_turn_memory_invokes_maybe_write_turn_memory(tmp_path: Path, monke
|
|||
calls.append({"store": store, **kwargs})
|
||||
return {"ok": True, "written": 0, "reason": "stub"}
|
||||
|
||||
monkeypatch.setattr("oclaw.orchestration.memory.maybe_write_turn_memory", _fake_maybe_write)
|
||||
monkeypatch.setattr("oclaw.runtime.orchestration.memory.maybe_write_turn_memory", _fake_maybe_write)
|
||||
|
||||
store = SqliteStore(str(tmp_path / "m.sqlite"))
|
||||
store.create_session("s1")
|
||||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.project_context_prompt import build_project_context_block
|
||||
from oclaw.runtime.project_context_prompt import build_project_context_block
|
||||
|
||||
|
||||
class _Store:
|
||||
|
|
@ -14,11 +14,11 @@ class _Store:
|
|||
|
||||
|
||||
def test_build_project_context_block_reads_workspace_bootstrap(monkeypatch, tmp_path: Path) -> None:
|
||||
ws = tmp_path / "oclaw" / "agent" / "workspace-main"
|
||||
ws = tmp_path / "oclaw" / "runtime" / "assets" / "agent_workspaces" / "workspace-main"
|
||||
ws.mkdir(parents=True, exist_ok=True)
|
||||
(ws / "AGENTS.md").write_text("agents rules", encoding="utf-8")
|
||||
(ws / "SOUL.md").write_text("soul voice", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
out = build_project_context_block(store=_Store())
|
||||
assert "[project_context]" in out
|
||||
assert "[AGENTS.md]" in out
|
||||
|
|
@ -26,14 +26,14 @@ def test_build_project_context_block_reads_workspace_bootstrap(monkeypatch, tmp_
|
|||
|
||||
|
||||
def test_build_project_context_block_empty_when_no_files(monkeypatch, tmp_path: Path) -> None:
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
out = build_project_context_block(store=_Store())
|
||||
assert out == ""
|
||||
|
||||
|
||||
def test_build_project_context_block_fallback_to_project_root(monkeypatch, tmp_path: Path) -> None:
|
||||
(tmp_path / "AGENTS.md").write_text("legacy root agents", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
out = build_project_context_block(store=_Store())
|
||||
assert "[AGENTS.md]" in out
|
||||
assert "legacy root agents" in out
|
||||
|
|
@ -43,7 +43,7 @@ def test_build_project_context_block_legacy_workspace_fallback(monkeypatch, tmp_
|
|||
ws = tmp_path / "oclaw" / "workspace"
|
||||
ws.mkdir(parents=True, exist_ok=True)
|
||||
(ws / "AGENTS.md").write_text("legacy workspace agents", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
out = build_project_context_block(store=_Store())
|
||||
assert "[AGENTS.md]" in out
|
||||
assert "legacy workspace agents" in out
|
||||
|
|
@ -53,29 +53,29 @@ def test_build_project_context_block_workspace_main_fallback(monkeypatch, tmp_pa
|
|||
ws = tmp_path / "oclaw" / "workspace-main"
|
||||
ws.mkdir(parents=True, exist_ok=True)
|
||||
(ws / "AGENTS.md").write_text("legacy workspace-main agents", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
out = build_project_context_block(store=_Store())
|
||||
assert "[AGENTS.md]" in out
|
||||
assert "legacy workspace-main agents" in out
|
||||
|
||||
|
||||
def test_build_project_context_block_triggers_bootstrap_for_each_root(monkeypatch, tmp_path: Path) -> None:
|
||||
ws_agent = tmp_path / "oclaw" / "agent" / "workspace-main"
|
||||
ws_agent = tmp_path / "oclaw" / "runtime" / "assets" / "agent_workspaces" / "workspace-main"
|
||||
ws_main = tmp_path / "oclaw" / "workspace-main"
|
||||
ws_agent.mkdir(parents=True, exist_ok=True)
|
||||
ws_main.mkdir(parents=True, exist_ok=True)
|
||||
(ws_agent / "AGENTS.md").write_text("agent root", encoding="utf-8")
|
||||
(ws_main / "AGENTS.md").write_text("main root", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
|
||||
calls: list[dict] = []
|
||||
|
||||
def _capture(**kwargs):
|
||||
calls.append(dict(kwargs))
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.trigger_hook_event", _capture)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.trigger_hook_event", _capture)
|
||||
monkeypatch.setattr(
|
||||
"oclaw.openclaw_runtime.project_context_prompt.get_active_hooks_config",
|
||||
"oclaw.runtime.project_context_prompt.get_active_hooks_config",
|
||||
lambda: {"hooks": {"internal": {"enabled": True}}},
|
||||
)
|
||||
_ = build_project_context_block(store=_Store())
|
||||
|
|
@ -87,22 +87,22 @@ def test_build_project_context_block_triggers_bootstrap_for_each_root(monkeypatc
|
|||
|
||||
|
||||
def test_project_context_bootstrap_includes_agent_id_when_config_matches(monkeypatch, tmp_path: Path) -> None:
|
||||
ws_agent = tmp_path / "oclaw" / "agent" / "workspace-main"
|
||||
ws_agent = tmp_path / "oclaw" / "runtime" / "assets" / "agent_workspaces" / "workspace-main"
|
||||
ws_social = tmp_path / "oclaw" / "workspace-social"
|
||||
ws_agent.mkdir(parents=True, exist_ok=True)
|
||||
ws_social.mkdir(parents=True, exist_ok=True)
|
||||
(ws_agent / "AGENTS.md").write_text("agent root", encoding="utf-8")
|
||||
(ws_social / "AGENTS.md").write_text("social root", encoding="utf-8")
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.PROJECT_ROOT", tmp_path)
|
||||
|
||||
calls: list[dict] = []
|
||||
|
||||
def _capture(**kwargs):
|
||||
calls.append(dict(kwargs))
|
||||
|
||||
monkeypatch.setattr("oclaw.openclaw_runtime.project_context_prompt.trigger_hook_event", _capture)
|
||||
monkeypatch.setattr("oclaw.runtime.project_context_prompt.trigger_hook_event", _capture)
|
||||
monkeypatch.setattr(
|
||||
"oclaw.openclaw_runtime.project_context_prompt.get_active_hooks_config",
|
||||
"oclaw.runtime.project_context_prompt.get_active_hooks_config",
|
||||
lambda: {
|
||||
"hooks": {"internal": {"enabled": True}},
|
||||
"agents": {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.openclaw_runtime.relay_pointer import build_manifest_from_attachment_refs
|
||||
from oclaw.openclaw_runtime.types import RelayShareEnvelope, SharedAttachmentManifest, SharedFilePointer
|
||||
from oclaw.runtime.relay_pointer import build_manifest_from_attachment_refs
|
||||
from oclaw.runtime.types import RelayShareEnvelope, SharedAttachmentManifest, SharedFilePointer
|
||||
|
||||
|
||||
def test_shared_pointer_roundtrip_with_extra_fields() -> None:
|
||||
|
|
@ -5,7 +5,7 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from oclaw.openclaw_runtime.relay_pointer import (
|
||||
from oclaw.runtime.relay_pointer import (
|
||||
RelayPointerError,
|
||||
build_pointer_uri,
|
||||
decode_base64_payload,
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.agents.specialists import default_system_prefix_for_specialist
|
||||
from oclaw.runtime.agents.specialists import default_system_prefix_for_specialist
|
||||
|
||||
|
||||
def test_specialist_prompts_loaded_from_openclaw_tree() -> None:
|
||||
def test_specialist_prompts_loaded_from_oclaw_tree() -> None:
|
||||
ops = default_system_prefix_for_specialist("ops", "zh")
|
||||
gen = default_system_prefix_for_specialist("generalist", "zh")
|
||||
img = default_system_prefix_for_specialist("image", "zh")
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.platform.llm.chat_models import LLMResponse
|
||||
from oclaw.openclaw_runtime.router import decide_route
|
||||
from oclaw.openclaw_runtime.types import StandardMessage, normalize_interaction_mode, normalize_requested_specialist
|
||||
from oclaw.runtime.router import decide_route
|
||||
from oclaw.runtime.types import StandardMessage, normalize_interaction_mode, normalize_requested_specialist
|
||||
|
||||
|
||||
def _msg(text: str, attachments: list[dict] | None = None) -> StandardMessage:
|
||||
|
|
@ -41,7 +41,7 @@ class _RouterJsonModel:
|
|||
def test_router_llm_json_mode_uses_model() -> None:
|
||||
class Store:
|
||||
def get_setting(self, key: str) -> str:
|
||||
if key == "AIA_OPENCLAW_ROUTER_MODE":
|
||||
if key == "AIA_OCLAW_ROUTER_MODE":
|
||||
return "llm_json"
|
||||
return ""
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ def test_router_llm_json_mode_uses_model() -> None:
|
|||
def test_router_llm_json_invalid_json_falls_back_to_rule() -> None:
|
||||
class Store:
|
||||
def get_setting(self, key: str) -> str:
|
||||
if key == "AIA_OPENCLAW_ROUTER_MODE":
|
||||
if key == "AIA_OCLAW_ROUTER_MODE":
|
||||
return "llm_json"
|
||||
return ""
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ def test_router_llm_json_invalid_json_falls_back_to_rule() -> None:
|
|||
def test_router_llm_json_tolerates_extra_dynamic_agent_fields() -> None:
|
||||
class Store:
|
||||
def get_setting(self, key: str) -> str:
|
||||
if key == "AIA_OPENCLAW_ROUTER_MODE":
|
||||
if key == "AIA_OCLAW_ROUTER_MODE":
|
||||
return "llm_json"
|
||||
return ""
|
||||
|
||||
|
|
@ -2,11 +2,11 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.skills import build_skill_manifest, discover_workspace_skill_manifests, load_skill_manifest
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.skills import build_skill_manifest, discover_workspace_skill_manifests, load_skill_manifest
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def test_load_skill_manifest_with_openclaw_metadata(tmp_path: Path) -> None:
|
||||
def test_load_skill_manifest_with_oclaw_metadata(tmp_path: Path) -> None:
|
||||
d = tmp_path / "skills" / "demo"
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
(d / "SKILL.md").write_text(
|
||||
|
|
@ -15,7 +15,7 @@ name: demo
|
|||
description: demo skill
|
||||
user-invocable: true
|
||||
disable-model-invocation: false
|
||||
metadata: {"openclaw":{"install":[{"id":"i1","kind":"node","package":"foo"}]}}
|
||||
metadata: {"oclaw":{"install":[{"id":"i1","kind":"node","package":"foo"}]}}
|
||||
---
|
||||
|
||||
# Demo
|
||||
|
|
@ -2,10 +2,10 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.system_prompt import build_openclaw_executor_system_prompt
|
||||
from oclaw.openclaw_runtime.types import OpenClawMemoryContext
|
||||
from oclaw.runtime.system_prompt import build_oclaw_executor_system_prompt
|
||||
from oclaw.runtime.types import OclawMemoryContext
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def _spec(name: str) -> ToolSpec:
|
||||
|
|
@ -18,45 +18,45 @@ def _spec(name: str) -> ToolSpec:
|
|||
)
|
||||
|
||||
|
||||
def test_build_openclaw_executor_system_prompt_includes_skills_block(tmp_path: Path) -> None:
|
||||
def test_build_oclaw_executor_system_prompt_includes_skills_block(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "sp.sqlite"))
|
||||
store.create_session("s")
|
||||
reg = ToolRegistry([_spec("demo_tool")])
|
||||
out = build_openclaw_executor_system_prompt(
|
||||
out = build_oclaw_executor_system_prompt(
|
||||
store=store,
|
||||
tools=reg,
|
||||
base_url="",
|
||||
base_system="You are helpful.",
|
||||
memory_context=OpenClawMemoryContext(),
|
||||
memory_context=OclawMemoryContext(),
|
||||
lang="zh",
|
||||
)
|
||||
assert "<available_skills>" in out
|
||||
|
||||
|
||||
def test_build_openclaw_executor_system_prompt_without_tools_has_no_skills_block(tmp_path: Path) -> None:
|
||||
def test_build_oclaw_executor_system_prompt_without_tools_has_no_skills_block(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "sp1.sqlite"))
|
||||
store.create_session("s")
|
||||
out = build_openclaw_executor_system_prompt(
|
||||
out = build_oclaw_executor_system_prompt(
|
||||
store=store,
|
||||
tools=None,
|
||||
base_url="",
|
||||
base_system=" plain ",
|
||||
memory_context=OpenClawMemoryContext(),
|
||||
memory_context=OclawMemoryContext(),
|
||||
lang="zh",
|
||||
)
|
||||
assert "<available_skills>" not in out
|
||||
|
||||
|
||||
def test_build_openclaw_executor_system_prompt_with_tools_has_skills(tmp_path: Path) -> None:
|
||||
def test_build_oclaw_executor_system_prompt_with_tools_has_skills(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "sp2.sqlite"))
|
||||
store.create_session("s")
|
||||
reg = ToolRegistry([_spec("x")])
|
||||
out = build_openclaw_executor_system_prompt(
|
||||
out = build_oclaw_executor_system_prompt(
|
||||
store=store,
|
||||
tools=reg,
|
||||
base_url="",
|
||||
base_system="base",
|
||||
memory_context=OpenClawMemoryContext(),
|
||||
memory_context=OclawMemoryContext(),
|
||||
lang="zh",
|
||||
)
|
||||
assert "<available_skills>" in out
|
||||
|
|
@ -5,25 +5,25 @@ from pathlib import Path
|
|||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
def test_openclaw_task_status_flow(tmp_path: Path) -> None:
|
||||
def test_oclaw_task_status_flow(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "task.sqlite"))
|
||||
task = store.openclaw_task_create(
|
||||
task = store.oclaw_task_create(
|
||||
tenant_id="tenant-a",
|
||||
session_id="session-a",
|
||||
payload={"text": "hello"},
|
||||
)
|
||||
assert task.status == "queued"
|
||||
|
||||
claimed = store.openclaw_task_claim(worker_id="worker-1")
|
||||
claimed = store.oclaw_task_claim(worker_id="worker-1")
|
||||
assert claimed is not None
|
||||
assert claimed.id == task.id
|
||||
assert claimed.status == "claimed"
|
||||
assert claimed.claimed_by == "worker-1"
|
||||
assert claimed.attempt_count >= 1
|
||||
|
||||
ok = store.openclaw_task_finish(task_id=task.id, result={"reply_text": "done"})
|
||||
ok = store.oclaw_task_finish(task_id=task.id, result={"reply_text": "done"})
|
||||
assert ok
|
||||
done = store.openclaw_task_get(task_id=task.id)
|
||||
done = store.oclaw_task_get(task_id=task.id)
|
||||
assert done is not None
|
||||
assert done.status == "done"
|
||||
assert "done" in done.result
|
||||
|
|
@ -2,12 +2,12 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.direct_loop import _OPENCLAW_TOOL_RESULT_HARD_CAP_CHARS, _build_model_context
|
||||
from oclaw.runtime.direct_loop import _OCLAW_TOOL_RESULT_HARD_CAP_CHARS, _build_model_context
|
||||
from oclaw.platform.llm.chat_models import RuleBasedChatModel
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
def test_openclaw_tool_result_context_guard_truncates_large_tool_message(tmp_path: Path) -> None:
|
||||
def test_oclaw_tool_result_context_guard_truncates_large_tool_message(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "ops.sqlite"))
|
||||
sess = store.create_session("t")
|
||||
# Ensure the tool message is not a dangling orphan (some providers require pairing).
|
||||
|
|
@ -17,7 +17,7 @@ def test_openclaw_tool_result_context_guard_truncates_large_tool_message(tmp_pat
|
|||
content="",
|
||||
tool_calls=[{"id": "c1", "name": "echo", "arguments": {"x": 1}}],
|
||||
)
|
||||
huge = "X" * (_OPENCLAW_TOOL_RESULT_HARD_CAP_CHARS + 5000)
|
||||
huge = "X" * (_OCLAW_TOOL_RESULT_HARD_CAP_CHARS + 5000)
|
||||
store.add_message(
|
||||
session_id=sess.id,
|
||||
role="tool",
|
||||
|
|
@ -38,6 +38,6 @@ def test_openclaw_tool_result_context_guard_truncates_large_tool_message(tmp_pat
|
|||
tool_msgs = [m for m in msgs if m.get("role") == "tool"]
|
||||
assert tool_msgs, msgs
|
||||
guarded = str(tool_msgs[-1].get("content") or "")
|
||||
assert len(guarded) <= _OPENCLAW_TOOL_RESULT_HARD_CAP_CHARS + 2000
|
||||
assert len(guarded) <= _OCLAW_TOOL_RESULT_HARD_CAP_CHARS + 2000
|
||||
assert "_tool_result_guarded" in guarded
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
import oclaw.ops.main as ops_main
|
||||
import oclaw.runtime.operations.main as ops_main
|
||||
|
||||
|
||||
def test_gateway_start_uses_fastapi_only(monkeypatch) -> None:
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ from oclaw.platform.config.paths import PROJECT_ROOT
|
|||
|
||||
|
||||
_PROMPT_CRITICAL_FILES = (
|
||||
"oclaw/chat/agent.py",
|
||||
"oclaw/agents/network_ops_agent.py",
|
||||
"oclaw/agents/factory.py",
|
||||
"oclaw/chat/agent_messages.py",
|
||||
"oclaw/openclaw_runtime/system_prompt.py",
|
||||
"oclaw/openclaw_runtime/memory_stage.py",
|
||||
"oclaw/openclaw_runtime/project_context_prompt.py",
|
||||
"oclaw/chat/agent_errors.py",
|
||||
"oclaw/runtime/chat/agent.py",
|
||||
"oclaw/runtime/agents/network_ops_agent.py",
|
||||
"oclaw/runtime/agents/factory.py",
|
||||
"oclaw/runtime/chat/agent_messages.py",
|
||||
"oclaw/runtime/system_prompt.py",
|
||||
"oclaw/runtime/memory_stage.py",
|
||||
"oclaw/runtime/project_context_prompt.py",
|
||||
"oclaw/runtime/chat/agent_errors.py",
|
||||
"oclaw/platform/llm/image_message_client.py",
|
||||
"oclaw/openclaw_runtime/gateway.py",
|
||||
"oclaw/runtime/gateway.py",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ def test_prompt_critical_paths_use_prompt_templates() -> None:
|
|||
assert (
|
||||
"render_prompt(" in text
|
||||
or "render_prompt_for_lang(" in text
|
||||
or "render_openclaw_prompt(" in text
|
||||
or "render_runtime_prompt(" in text
|
||||
), (
|
||||
f"{rel} must render prompts from oclaw/prompts*.md"
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ def test_prompt_critical_paths_use_prompt_templates() -> None:
|
|||
def test_prompt_markdown_frontmatter_keys_present() -> None:
|
||||
roots = [
|
||||
PROJECT_ROOT / "oclaw" / "prompts",
|
||||
PROJECT_ROOT / "oclaw" / "prompts_openclaw",
|
||||
PROJECT_ROOT / "oclaw" / "prompts_runtime",
|
||||
]
|
||||
for prompts_root in roots:
|
||||
for p in prompts_root.rglob("*.md"):
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ def _read(rel: str) -> str:
|
|||
def test_no_legacy_inline_manager_prompts() -> None:
|
||||
# Manager orchestrator was removed; keep this test as a smoke-guard for any new inline
|
||||
# manager-style prompt leakage into the runtime entrypoints.
|
||||
content = _read("oclaw/openclaw_runtime/gateway.py")
|
||||
content = _read("oclaw/runtime/gateway.py")
|
||||
assert "【重要:只返回合法 JSON】" not in content
|
||||
assert "你是 AI 助手的路由(Routing)智能体" not in content
|
||||
|
||||
|
||||
def test_no_legacy_inline_specialist_prompts() -> None:
|
||||
content = _read("oclaw/agents/specialists.py")
|
||||
content = _read("oclaw/runtime/agents/specialists.py")
|
||||
assert "【最高优先级执行规则(必须遵守)】" not in content
|
||||
assert "【职责范围】" not in content
|
||||
|
||||
|
||||
def test_no_legacy_inline_runtime_prompt() -> None:
|
||||
content = _read("oclaw/chat/agent.py")
|
||||
content = _read("oclaw/runtime/chat/agent.py")
|
||||
assert "你是一个通用 AI 助手。" not in content
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from oclaw.prompts.loader import load_openclaw_prompt_doc, load_prompt_doc, render_openclaw_prompt, render_prompt
|
||||
from oclaw.prompts.loader import load_runtime_prompt_doc, load_prompt_doc, render_runtime_prompt, render_prompt
|
||||
|
||||
|
||||
def test_load_prompt_doc_with_frontmatter() -> None:
|
||||
|
|
@ -26,14 +26,14 @@ def test_render_prompt_success() -> None:
|
|||
assert "ok=true" in out
|
||||
|
||||
|
||||
def test_load_openclaw_prompt_doc_with_frontmatter() -> None:
|
||||
doc = load_openclaw_prompt_doc("roles/specialists/ops/system.md")
|
||||
def test_load_runtime_prompt_doc_with_frontmatter() -> None:
|
||||
doc = load_runtime_prompt_doc("roles/specialists/ops/system.md")
|
||||
assert doc.frontmatter.get("title") == "oclaw_role_specialist_ops_system"
|
||||
assert "你是网络运维专家" in doc.body
|
||||
|
||||
|
||||
def test_render_openclaw_prompt_success() -> None:
|
||||
out = render_openclaw_prompt(
|
||||
def test_render_runtime_prompt_success() -> None:
|
||||
out = render_runtime_prompt(
|
||||
"runtime/project_context_block.md",
|
||||
variables={"project_context": "[AGENTS.md]\nfoo"},
|
||||
strict=True,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.openclaw_runtime.memory_stage import render_memory_context_block
|
||||
from oclaw.openclaw_runtime.types import OpenClawMemoryContext
|
||||
from oclaw.prompts.loader import render_openclaw_prompt
|
||||
from oclaw.runtime.memory_stage import render_memory_context_block
|
||||
from oclaw.runtime.types import OclawMemoryContext
|
||||
from oclaw.prompts.loader import render_runtime_prompt
|
||||
|
||||
|
||||
def test_router_prompt_renders() -> None:
|
||||
txt = render_openclaw_prompt(
|
||||
txt = render_runtime_prompt(
|
||||
"router/decide_route.md",
|
||||
variables={"user_text": "hi", "has_attachments": "no"},
|
||||
strict=True,
|
||||
|
|
@ -17,7 +17,7 @@ def test_router_prompt_renders() -> None:
|
|||
|
||||
|
||||
def test_memory_context_markdown_block() -> None:
|
||||
ctx = OpenClawMemoryContext(
|
||||
ctx = OclawMemoryContext(
|
||||
short_term=("用户想排查网络问题",),
|
||||
semantic_hits=({"content": "上次 DNS 配置异常", "score": 0.91},),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Regression tests for OpenClaw-style tool_call_id replay (see src/platform/llm/tool_call_id.py)."""
|
||||
"""Regression tests for Oclaw-style tool_call_id replay (see src/platform/llm/tool_call_id.py)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.direct_loop import run_openclaw_direct_loop
|
||||
from oclaw.runtime.direct_loop import run_oclaw_direct_loop
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.platform.llm.transports.base import LLMResponse, LLMToolCall
|
||||
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ def test_direct_loop_propagates_on_token_streaming(tmp_path: Path) -> None:
|
|||
store = SqliteStore(str(tmp_path / "s.sqlite"))
|
||||
sess = store.create_session("t")
|
||||
seen: list[str] = []
|
||||
out = run_openclaw_direct_loop(
|
||||
out = run_oclaw_direct_loop(
|
||||
store=store,
|
||||
session_id=sess.id,
|
||||
lang="zh",
|
||||
|
|
@ -68,7 +68,7 @@ def test_direct_loop_supports_multi_round_tool_then_final(tmp_path: Path) -> Non
|
|||
)
|
||||
]
|
||||
)
|
||||
out = run_openclaw_direct_loop(
|
||||
out = run_oclaw_direct_loop(
|
||||
store=store,
|
||||
session_id=sess.id,
|
||||
lang="zh",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
|||
|
||||
from types import SimpleNamespace
|
||||
|
||||
from oclaw.openclaw_runtime.skill_executor import SkillExecutionContext, SkillExecutor
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.skill_executor import SkillExecutionContext, SkillExecutor
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
class _DummyStore:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
from pathlib import Path
|
||||
import zipfile
|
||||
|
||||
from oclaw.openclaw_runtime.skill_installer import (
|
||||
from oclaw.runtime.skill_installer import (
|
||||
auto_install_skill_from_payload,
|
||||
create_skill_from_template,
|
||||
install_skill_from_local_dir,
|
||||
|
|
@ -61,7 +61,7 @@ def test_install_skill_from_registry_archive_file_url(tmp_path: Path) -> None:
|
|||
inner = pkg_dir / "demo"
|
||||
inner.mkdir(parents=True, exist_ok=True)
|
||||
(inner / "SKILL.md").write_text(
|
||||
"---\nname: reg_demo\ndescription: x\nmetadata: {\"openclaw\":{}}\n---\n",
|
||||
"---\nname: reg_demo\ndescription: x\nmetadata: {\"oclaw\":{}}\n---\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
archive = tmp_path / "reg.zip"
|
||||
|
|
@ -83,7 +83,7 @@ def test_install_skill_from_clawhub_page_url(tmp_path: Path, monkeypatch) -> Non
|
|||
inner = pkg_dir / "demo"
|
||||
inner.mkdir(parents=True, exist_ok=True)
|
||||
(inner / "SKILL.md").write_text(
|
||||
"---\nname: reg_clawhub_demo\ndescription: x\nmetadata: {\"openclaw\":{}}\n---\n",
|
||||
"---\nname: reg_clawhub_demo\ndescription: x\nmetadata: {\"oclaw\":{}}\n---\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
archive = tmp_path / "reg_clawhub.zip"
|
||||
|
|
@ -96,7 +96,7 @@ def test_install_skill_from_clawhub_page_url(tmp_path: Path, monkeypatch) -> Non
|
|||
captured["slug"] = slug
|
||||
return {"archiveUrl": archive.resolve().as_uri()}
|
||||
|
||||
monkeypatch.setattr("oclaw.tools.skills.clawhub_client.get_skill_detail", _mock_get_detail)
|
||||
monkeypatch.setattr("oclaw.runtime.tools.skills.clawhub_client.get_skill_detail", _mock_get_detail)
|
||||
|
||||
out = install_skill_from_registry_archive(
|
||||
store=store,
|
||||
|
|
@ -114,7 +114,7 @@ def test_install_local_allows_sh_files(tmp_path: Path) -> None:
|
|||
src = tmp_path / "local_skill"
|
||||
src.mkdir(parents=True, exist_ok=True)
|
||||
(src / "SKILL.md").write_text(
|
||||
"---\nname: local_with_sh\ndescription: x\nmetadata: {\"openclaw\":{}}\n---\n",
|
||||
"---\nname: local_with_sh\ndescription: x\nmetadata: {\"oclaw\":{}}\n---\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(src / "activator.sh").write_text("#!/usr/bin/env bash\necho ok\n", encoding="utf-8")
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ from __future__ import annotations
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.skill_role_binding import (
|
||||
from oclaw.runtime.skill_role_binding import (
|
||||
SKILL_ROLE_BINDING_ENABLED_SETTING,
|
||||
SKILL_ROLE_BINDING_KEY,
|
||||
normalize_skill_role_binding,
|
||||
ordered_binding_roles,
|
||||
)
|
||||
from oclaw.openclaw_runtime.skills_prompt import collect_skill_catalog_entries
|
||||
from oclaw.runtime.skills_prompt import collect_skill_catalog_entries
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.catalog import default_registry
|
||||
from oclaw.runtime.tools.catalog import default_registry
|
||||
|
||||
|
||||
def _write_skill(root: Path, name: str) -> None:
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import tempfile
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.openclaw_runtime.skills import discover_workspace_skill_manifests
|
||||
from oclaw.tools.skills_runtime.materialize_skill_tools import materialize_executable_skill_tools
|
||||
from oclaw.runtime.skills import discover_workspace_skill_manifests
|
||||
from oclaw.runtime.tools.skills_runtime.materialize_skill_tools import materialize_executable_skill_tools
|
||||
|
||||
|
||||
class SkillRuntimeMetadataAndToolsTests(unittest.TestCase):
|
||||
|
|
@ -30,7 +30,7 @@ class SkillRuntimeMetadataAndToolsTests(unittest.TestCase):
|
|||
"name: demo_runtime\n"
|
||||
"description: demo\n"
|
||||
"metadata:\n"
|
||||
" openclaw:\n"
|
||||
" oclaw:\n"
|
||||
" runtime:\n"
|
||||
" type: python\n"
|
||||
" entry: scripts/run.py\n"
|
||||
|
|
@ -62,7 +62,7 @@ class SkillRuntimeMetadataAndToolsTests(unittest.TestCase):
|
|||
"name: demo_runtime_tool\n"
|
||||
"description: demo\n"
|
||||
"metadata:\n"
|
||||
" openclaw:\n"
|
||||
" oclaw:\n"
|
||||
" runtime:\n"
|
||||
" type: python\n"
|
||||
" entry: scripts/run.py\n"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import tempfile
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.tools.skills_runtime.subprocess_exec import run_skill_runtime_entry
|
||||
from oclaw.runtime.tools.skills_runtime.subprocess_exec import run_skill_runtime_entry
|
||||
|
||||
|
||||
class SkillRuntimeRestrictedFsPermissionTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.openclaw_runtime.skills_prompt import format_skills_for_prompt
|
||||
from oclaw.runtime.skills_prompt import format_skills_for_prompt
|
||||
|
||||
|
||||
def test_format_skills_for_prompt_xml_shape() -> None:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.chat.tool_runtime import partition_tool_use_batches
|
||||
from oclaw.runtime.chat.tool_runtime import partition_tool_use_batches
|
||||
from oclaw.platform.llm.chat_models import LLMToolCall
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def _spec(name: str, *, read_only: bool) -> ToolSpec:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import json
|
||||
import unittest
|
||||
|
||||
from oclaw.chat.tool_runtime import truncate_tool_result_for_llm_messages, tool_llm_message_max_chars
|
||||
from oclaw.runtime.chat.tool_runtime import truncate_tool_result_for_llm_messages, tool_llm_message_max_chars
|
||||
|
||||
|
||||
class ToolLlmTruncationTests(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ from __future__ import annotations
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.chat.tool_runtime import ToolExecutionContext, ToolExecutor
|
||||
from oclaw.runtime.chat.tool_runtime import ToolExecutionContext, ToolExecutor
|
||||
from oclaw.platform.llm.chat_models import LLMToolCall
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
from oclaw.runtime.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def test_tool_loop_guard_blocks_repeated_signature(tmp_path: Path) -> None:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
|
||||
from oclaw.chat.agent_messages import build_llm_messages
|
||||
from oclaw.runtime.chat.agent_messages import build_llm_messages
|
||||
from oclaw.platform.llm.chat_models import RuleBasedChatModel
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import pytest
|
|||
|
||||
def test_wecom_longconn_drains_outbound_on_idle_timeout(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
# Import module under test.
|
||||
import oclaw.channels.wecom.longconn_runner as m
|
||||
import oclaw.interfaces.channels.wecom.longconn_runner as m
|
||||
|
||||
# Build a fake websocket that raises timeout once, then exits by raising KeyboardInterrupt.
|
||||
class _TimeoutOnceWs:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from pathlib import Path
|
|||
|
||||
|
||||
def _load_handler_module():
|
||||
p = Path("d:/project/chatgpt/oclaw/hooks/bundled/wiki-auto-inject/handler.py").resolve()
|
||||
p = Path("d:/project/chatgpt/oclaw/runtime/hooks/bundled/wiki-auto-inject/handler.py").resolve()
|
||||
spec = importlib.util.spec_from_file_location("wiki_auto_inject_handler_test", str(p))
|
||||
assert spec and spec.loader
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ from __future__ import annotations
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import OpenClawTask
|
||||
from oclaw.wiki_worker.main import _capture_after_turn, _dedup_merge, _process_task
|
||||
from oclaw.platform.persistence.sqlite_store import OclawTask
|
||||
from oclaw.runtime.workers.wiki.main import _capture_after_turn, _dedup_merge, _process_task
|
||||
|
||||
|
||||
def _task(task_id: str = "t1") -> OpenClawTask:
|
||||
return OpenClawTask(
|
||||
def _task(task_id: str = "t1") -> OclawTask:
|
||||
return OclawTask(
|
||||
id=task_id,
|
||||
tenant_id="tenant-1",
|
||||
session_id="session-1",
|
||||
|
|
@ -68,7 +68,7 @@ def test_process_task_writes_index_and_lint_report(tmp_path: Path) -> None:
|
|||
"assistant_text": "answer",
|
||||
}
|
||||
task = _task("t-proc")
|
||||
task = OpenClawTask(**{**task.__dict__, "payload": json.dumps(payload, ensure_ascii=False)})
|
||||
task = OclawTask(**{**task.__dict__, "payload": json.dumps(payload, ensure_ascii=False)})
|
||||
|
||||
def _wiki_apply(args: dict) -> dict:
|
||||
rel = str(args.get("path") or "").replace("\\", "/").strip("/")
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ from fastapi.testclient import TestClient
|
|||
from oclaw.interfaces.http.fastapi_app import create_app
|
||||
from oclaw.platform.config.paths import db_path
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.experts.workspace.fs_tools import list_files_tool
|
||||
from oclaw.tools.experts.workspace.workspace_base import (
|
||||
from oclaw.runtime.tools.experts.workspace.fs_tools import list_files_tool
|
||||
from oclaw.runtime.tools.experts.workspace.workspace_base import (
|
||||
access_from_env,
|
||||
build_workspace_path_access,
|
||||
clear_workspace_path_access_for_tests,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from unittest import mock
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from oclaw.interfaces.http.fastapi_app import create_app
|
||||
from oclaw.openclaw_runtime.gateway import OpenClawGatewayResult
|
||||
from oclaw.runtime.gateway import OclawGatewayResult
|
||||
|
||||
|
||||
def _connect_params() -> dict:
|
||||
|
|
@ -72,7 +72,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
on_tool_ui("skill", {"ok": True})
|
||||
if callable(on_token):
|
||||
on_token("hello")
|
||||
return OpenClawGatewayResult(
|
||||
return OclawGatewayResult(
|
||||
run_id=str(rid),
|
||||
reply_text="done",
|
||||
trace_id="trace_test",
|
||||
|
|
@ -83,7 +83,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
interaction_mode="comprehensive",
|
||||
)
|
||||
|
||||
with mock.patch("oclaw.openclaw_runtime.gateway.OpenClawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with mock.patch("oclaw.runtime.gateway.OclawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with self.client.websocket_connect("/ws") as ws:
|
||||
ws.receive_json() # connect.challenge
|
||||
ws.send_json({"type": "req", "id": "c1", "method": "connect", "params": _connect_params()})
|
||||
|
|
@ -129,7 +129,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
def test_ws_sessions_send_routes_to_agent_flow(self) -> None:
|
||||
def _fake_handle_turn(self, **kwargs): # noqa: ANN001
|
||||
rid = kwargs.get("run_id") or "run_test"
|
||||
return OpenClawGatewayResult(
|
||||
return OclawGatewayResult(
|
||||
run_id=str(rid),
|
||||
reply_text="done",
|
||||
trace_id="trace_sessions_send",
|
||||
|
|
@ -140,7 +140,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
interaction_mode="comprehensive",
|
||||
)
|
||||
|
||||
with mock.patch("oclaw.openclaw_runtime.gateway.OpenClawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with mock.patch("oclaw.runtime.gateway.OclawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with self.client.websocket_connect("/ws") as ws:
|
||||
ws.receive_json()
|
||||
ws.send_json({"type": "req", "id": "c1", "method": "connect", "params": _connect_params()})
|
||||
|
|
@ -166,7 +166,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
def test_ws_agent_run_alias_works(self) -> None:
|
||||
def _fake_handle_turn(self, **kwargs): # noqa: ANN001
|
||||
rid = kwargs.get("run_id") or "run_alias"
|
||||
return OpenClawGatewayResult(
|
||||
return OclawGatewayResult(
|
||||
run_id=str(rid),
|
||||
reply_text="ok",
|
||||
trace_id="trace_alias",
|
||||
|
|
@ -177,7 +177,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
interaction_mode="comprehensive",
|
||||
)
|
||||
|
||||
with mock.patch("oclaw.openclaw_runtime.gateway.OpenClawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with mock.patch("oclaw.runtime.gateway.OclawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with self.client.websocket_connect("/ws") as ws:
|
||||
ws.receive_json()
|
||||
ws.send_json({"type": "req", "id": "c1", "method": "connect", "params": _connect_params()})
|
||||
|
|
@ -208,7 +208,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
if callable(on_token):
|
||||
on_token("he")
|
||||
on_token("llo")
|
||||
return OpenClawGatewayResult(
|
||||
return OclawGatewayResult(
|
||||
run_id=str(rid),
|
||||
reply_text="hello",
|
||||
trace_id="trace_chat_send",
|
||||
|
|
@ -219,7 +219,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
interaction_mode="comprehensive",
|
||||
)
|
||||
|
||||
with mock.patch("oclaw.openclaw_runtime.gateway.OpenClawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with mock.patch("oclaw.runtime.gateway.OclawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with self.client.websocket_connect("/ws") as ws:
|
||||
ws.receive_json()
|
||||
ws.send_json({"type": "req", "id": "c1", "method": "connect", "params": _connect_params()})
|
||||
|
|
@ -266,7 +266,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
if callable(on_token):
|
||||
on_token("Hel")
|
||||
on_token("lo")
|
||||
return OpenClawGatewayResult(
|
||||
return OclawGatewayResult(
|
||||
run_id=str(rid),
|
||||
reply_text="Hello",
|
||||
trace_id="trace_chat_send_stream",
|
||||
|
|
@ -277,7 +277,7 @@ class WsGatewayTests(unittest.TestCase):
|
|||
interaction_mode="comprehensive",
|
||||
)
|
||||
|
||||
with mock.patch("oclaw.openclaw_runtime.gateway.OpenClawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with mock.patch("oclaw.runtime.gateway.OclawGateway.handle_turn", new=_fake_handle_turn):
|
||||
with self.client.websocket_connect("/ws") as ws:
|
||||
ws.receive_json()
|
||||
ws.send_json({"type": "req", "id": "c1", "method": "connect", "params": _connect_params()})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue