重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。

本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-25 01:24:23 +08:00
parent ba3836f00f
commit 4a23b715a2
498 changed files with 2760 additions and 2200 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2025 Peter Steinberger (OpenClaw)
Copyright (c) 2025 Peter Steinberger (Oclaw)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -23,5 +23,5 @@ SOFTWARE.
---
The Python modules `tool_call_id.py` and `replay_policy.py` in this directory
implement replay / tool-call-id handling inspired by OpenClaw's
implement replay / tool-call-id handling inspired by Oclaw's
`src/agents/tool-call-id.ts` and `src/agents/transcript-policy.ts`.

View file

@ -37,7 +37,7 @@ def build_default_model() -> ChatModel:
return RuleBasedChatModel()
if mode == "ollama":
try:
from oclaw.agents.factory import DEFAULT_OLLAMA_BASE_URL, DEFAULT_OLLAMA_MODEL
from oclaw.runtime.agents.factory import DEFAULT_OLLAMA_BASE_URL, DEFAULT_OLLAMA_MODEL
return OpenAIChatModel(model=DEFAULT_OLLAMA_MODEL, api_key="ollama", base_url=DEFAULT_OLLAMA_BASE_URL)
except Exception:

View file

@ -1,10 +1,10 @@
"""Transcript replay policy for OpenAI-compatible Chat Completions.
Inspired by OpenClaw (MIT) `src/agents/transcript-policy.ts` defaults for
Inspired by Oclaw (MIT) `src/agents/transcript-policy.ts` defaults for
`openai-completions`: enable strict tool-call-id sanitization so proxies and
multi-provider histories do not break on id format / length.
See OPENCLAW_MIT_LICENSE.txt in this package.
See OCLAW_MIT_LICENSE.txt in this package.
"""
from __future__ import annotations

View file

@ -1,10 +1,10 @@
"""OpenAI-compatible tool_call_id / tool result id rewriting.
Inspired by OpenClaw (MIT) `src/agents/tool-call-id.ts`: sanitize ids to strict
Inspired by Oclaw (MIT) `src/agents/tool-call-id.ts`: sanitize ids to strict
alphanumeric form and keep assistant.tool_calls[].id paired with role=tool
tool_call_id in encounter order.
See OPENCLAW_MIT_LICENSE.txt in this package.
See OCLAW_MIT_LICENSE.txt in this package.
"""
from __future__ import annotations

View file

@ -705,7 +705,7 @@ def penalty_row_status(
def build_tool_wire_snapshot(store: Any, *, role: str | None = None) -> dict[str, Any]:
"""Aggregate MCP install list + usage + policies for Admin GET."""
from oclaw.tools.mcp.registry import McpRegistry
from oclaw.runtime.tools.mcp.registry import McpRegistry
admin = load_merged_admin_config(store)
role_norm = str(role or "").strip().lower() or None

View file

@ -10,7 +10,7 @@ from oclaw.platform.llm.transports.base import ChatModel, LLMResponse, LLMToolCa
class GoogleGeminiChatModel(ChatModel):
"""Native Google Gemini streaming transport (SSE), modeled after OpenClaw's google transport."""
"""Native Google Gemini streaming transport (SSE), modeled after Oclaw's google transport."""
def __init__(self, *, model: str, api_key: str, base_url: str | None = None):
self.model = (model or "").strip() or "gemini-2.5-pro"
@ -34,7 +34,7 @@ class GoogleGeminiChatModel(ChatModel):
{
"name": name,
"description": str(fn.get("description") or ""),
# OpenClaw uses `parametersJsonSchema`
# Oclaw uses `parametersJsonSchema`
"parametersJsonSchema": fn.get("parameters") if isinstance(fn.get("parameters"), dict) else {"type": "object"},
}
)
@ -122,7 +122,7 @@ class GoogleGeminiChatModel(ChatModel):
model_path = self.model
if not model_path.startswith("models/") and not model_path.startswith("tunedModels/"):
model_path = f"models/{model_path}"
# Prefer header auth (OpenClaw-style); avoid forcing key into query string.
# Prefer header auth (Oclaw-style); avoid forcing key into query string.
return f"{base}/{model_path}:streamGenerateContent?alt=sse"
@staticmethod

View file

@ -153,7 +153,7 @@ class OpenAIChatModel(ChatModel):
try:
from oclaw.platform.config.paths import db_path
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
plan = build_llm_tools_plan(
store=SqliteStore(db_path()),