完善 MCP/会话上下文治理并补齐搜索与诊断能力。

补充历史压缩与会话诊断链路,强化 tool pairing 与空响应兜底观测;完善 Admin MCP 导入/绑定与相关前端展示;新增 web_search_fast/web_fetch_clean 及多项测试与文档更新,并同步技能安装与角色绑定策略改进。

Made-with: Cursor
This commit is contained in:
oliver 2026-05-01 17:46:50 +08:00
parent df91434936
commit ae44cbcad5
43 changed files with 3549 additions and 57 deletions

View file

@ -5,9 +5,13 @@ from typing import Any
from oclaw.platform.config.paths import db_path
from oclaw.platform.persistence.sqlite_store import SqliteStore
from oclaw.runtime.chat.tool_invocation_context import (
current_tool_lane_sessions,
current_tool_workspace_lane_role,
)
from oclaw.runtime.skill_installer import auto_install_skill_from_payload, install_skill_from_registry_archive
from oclaw.runtime.skills import default_skills_root
from oclaw.runtime.skills_market import get_market_adapter, normalize_skill_market_provider_setting
from oclaw.runtime.skills_workspace_lane import resolve_auto_install_parent
from oclaw.runtime.tools.base import ToolSpec
@ -15,14 +19,32 @@ def _store() -> SqliteStore:
return SqliteStore(db_path())
def _agent_workspace_skills_root() -> Path:
return default_skills_root() / "_workspace"
def _coerce_public_flag(raw: Any) -> bool:
if isinstance(raw, bool):
return raw
return str(raw or "").strip().lower() in {"1", "true", "yes", "on", "public"}
def _agent_skill_install_parent(*, public: bool) -> Path:
role = current_tool_workspace_lane_role()
owner, sid = current_tool_lane_sessions()
return resolve_auto_install_parent(
public=public,
workspace_lane_role=role,
workspace_owner_session_id=owner,
session_id=sid,
skills_home=None,
)
def skill_auto_install_tool() -> ToolSpec:
def _handler(args: dict[str, Any]) -> dict[str, Any]:
payload = args if isinstance(args, dict) else {}
store = _store()
public = _coerce_public_flag(payload.get("public"))
install_parent = _agent_skill_install_parent(public=public)
lane_role = current_tool_workspace_lane_role()
auto_bind = bool(public)
archive_url = str(payload.get("archive_url") or "").strip()
slug = str(payload.get("slug") or "").strip()
version = str(payload.get("version") or "").strip() or None
@ -41,8 +63,8 @@ def skill_auto_install_tool() -> ToolSpec:
store=store,
archive_url=archive_url,
overwrite=overwrite,
skills_root=_agent_workspace_skills_root(),
auto_bind=True,
skills_root=install_parent,
auto_bind=auto_bind,
)
return {
"ok": bool(out.ok),
@ -54,6 +76,9 @@ def skill_auto_install_tool() -> ToolSpec:
"auto_enabled": bool(getattr(out, "auto_enabled", False)),
"binding_applied_roles": list(getattr(out, "binding_applied_roles", ()) or []),
"provider": provider,
"public": public,
"install_lane": str(install_parent),
"workspace_lane_role": lane_role,
}
skill_payload = {
@ -68,7 +93,12 @@ def skill_auto_install_tool() -> ToolSpec:
return {"ok": False, "error_code": "name_required", "error": "name_required"}
if not skill_payload["description"]:
skill_payload["description"] = f"{skill_payload['name']} skill"
out = auto_install_skill_from_payload(store=store, payload=skill_payload)
out = auto_install_skill_from_payload(
store=store,
payload=skill_payload,
workspace_install_parent=install_parent,
auto_bind=auto_bind,
)
return {
"ok": bool(out.ok),
"name": out.name,
@ -78,11 +108,18 @@ def skill_auto_install_tool() -> ToolSpec:
"retryable": bool(out.retryable),
"auto_enabled": bool(getattr(out, "auto_enabled", False)),
"binding_applied_roles": list(getattr(out, "binding_applied_roles", ()) or []),
"public": public,
"install_lane": str(install_parent),
"workspace_lane_role": lane_role,
}
return ToolSpec(
name="skill_auto_install",
description="Auto install a skill into _workspace lane (payload or market/archive).",
description=(
"Auto install a skill under the agent workspace lane. "
"Use public=true for shared _workspace/public; omit or false for a role folder "
"sibling to public: _workspace/<skill_binding_role>/ (e.g. generalist, ops)."
),
parameters={
"type": "object",
"properties": {
@ -95,6 +132,10 @@ def skill_auto_install_tool() -> ToolSpec:
"version": {"type": "string"},
"archive_url": {"type": "string"},
"overwrite": {"type": "boolean"},
"public": {
"type": "boolean",
"description": "If true, install to shared _workspace/public with role auto-bind; if false, install under this tool run's session lane only.",
},
},
"required": [],
"additionalProperties": False,